@agent-assistant/continuation

中文文档
0.4.37发布于 2026/10/04TypeScriptES Module构建来源已验证近 30 天下载 6092

基础延续原始——将可恢复的利用成果转化为明确状态,验证恢复触发器,以及真正的后续交付

中文使用文档
文档目录20 节
  1. 概览
  2. 安装
  3. 快开始
  4. API 参考
  5. createContinuationRuntime(config)
  6. ContinuationRuntime
  7. create(input)
  8. resume(input)
  9. stop(input)
  10. 连续生命周期
  11. 等待条件和触发
  12. TTL 默认
  13. 适配器
  14. ContinuationHarnessAdapter
  15. ContinuationDeliveryAdapter
  16. ContinuationSchedulerAdapter
  17. ContinuationStore
  18. 交货状态
  19. 错误类型
  20. 边界

@agent-assistant/continuation

限定运行时间的原始方式,将可恢复的利用结果转化为明确状态,验证恢复触发,以及真正的后续交付.

概览

续作从 @agent-assistant/harness 这名助理诚实地但最后地提出了澄清问题,一项行动正在等待批准,或者由于外部程序仍未完成而推迟工作。 续作包拥有该站后发生的一切:

  • 将可恢复的转折状态作为已键入 ContinuationRecord
  • 接受一个与续作中等待的匹配的明确恢复触发器
  • 验证活性( 未过期, 尚未终止, 在最大尝试范围内)
  • 以新的有界限的转弯重新入手
  • 记录后续执行状态

它不拥有的东西:

  • 限定的回合执行 + @agent-assistant/harness
  • 段 次 页 次 @agent-assistant/sessions
  • (a) 运输 @agent-assistant/surfaces
  • 核准/风险决定 @agent-assistant/policy
  • 长期记忆 @agent-assistant/memory
  • 通用排行榜 @agent-assistant/proactive

安装

npm install @agent-assistant/continuation

快开始

import { createContinuationRuntime, InMemoryContinuationStore } from '@agent-assistant/continuation';

const runtime = createContinuationRuntime({
  store: new InMemoryContinuationStore(),
  harness: myHarnessAdapter,    // implements ContinuationHarnessAdapter
  delivery: myDeliveryAdapter,  // optional: implements ContinuationDeliveryAdapter
});

// 1. After harness returns needs_clarification:
const { continuation } = await runtime.create({
  assistantId: 'sage',
  sessionId: 'session-123',
  originTurnId: 'turn-abc',
  harnessResult,  // the HarnessResult with outcome: 'needs_clarification'
});
// continuation.status === 'pending'
// continuation.waitFor.type === 'user_reply'

// 2. When the user replies:
const result = await runtime.resume({
  continuationId: continuation.id,
  trigger: {
    type: 'user_reply',
    message: { id: 'msg-2', text: 'London', receivedAt: new Date().toISOString() },
    receivedAt: new Date().toISOString(),
  },
});
// result.continuation.status === 'completed'
// result.harnessResult — the result of the resumed bounded turn

// 3. Cancel when no longer needed:
await runtime.stop({
  continuationId: continuation.id,
  reason: 'cancelled_by_user',
});

API 参考

createContinuationRuntime(config)

回返a ContinuationRuntime 绑在提供配置.

interface ContinuationConfig {
  store: ContinuationStore;
  harness: ContinuationHarnessAdapter;
  delivery?: ContinuationDeliveryAdapter;
  scheduler?: ContinuationSchedulerAdapter;
  clock?: ContinuationClock;
  trace?: ContinuationTraceSink;
  defaults?: ContinuationDefaults;
}

ContinuationRuntime

方法说明
create(input)利用可更新的牵引结果创建续作
resume(input)以明确触发方式恢复待续
stop(input)以真实的理由终止续作
get({ continuationId })通过 id 检索续作记录

create(input)

接受一个可恢复的 HarnessResult (单位:千美元)needs_clarification, (中文(简体) ), awaiting_approval, (中文(简体) ), deferred返回 a ContinuationCreateResult 包含新的 ContinuationRecord。 。 。 .

拒绝不可恢复的结果 (单位:千美元)completed, (中文(简体) ), failed与 ContinuationInvalidInputError。 。 。 .

等待条件源于结果:

结果等待条件
needs_clarificationuser_reply
awaiting_approvalapproval_resolution 要求 approvalId 状态或元数据
deferred (默认)external_result 要求 operationId 状态或元数据
deferred + 键 metadata.scheduledWake: truescheduled_wake

resume(input)

接受一个 ContinuationResumeTrigger 如果所有验证都通过,则重新使用:

  1. 记录存在
  2. 记录状态为 pending
  3. 现在的时间是以前 expiresAt
  4. 触发类型匹配 waitFor.type
  5. 关联标识符匹配( 核准Id, 操作) (d) 国家
  6. resumeAttempts < maxResumeAttempts

拒绝批准: 如果触发是 approval_resolution 与 decision: 'denied',不调用并标出记录 cancelled 有理无据 approval_denied。 。 。 .

转帐: 如果调用返回另一个可重复的结果,则记录会以新的等待条件(而不是新的记录)被重新修改.

stop(input)

状态的终端原因映射 :

原因状态
completedcompleted
cancelled_by_user, (中文(简体) ), cancelled_by_product, (中文(简体) ), approval_deniedcancelled
superseded_by_newer_turnsuperseded
expired_ttlexpired
所有其他国家failed

停下来 专有: 调用一个已死记录的停止返回它不变.


连续生命周期

                    ┌─────────────┐
                    │   pending    │
                    └──────┬───────┘
                           │
         ┌─────────────────┼─────────────────┐
         │                 │                  │
         ▼                 ▼                  ▼
  ┌────────────┐  ┌────────────────┐  ┌──────────────┐
  │  resuming   │  │    expired     │  │  cancelled/  │
  └──────┬─────┘  └────────────────┘  │  superseded  │
         │                            └──────────────┘
  ┌──────┼──────┐
  │      │      │
  ▼      ▼      ▼
completed failed pending (re-pend)

等待条件和触发

等待条件继续触发
user_reply{ type: 'user_reply', message, receivedAt }
approval_resolution{ type: 'approval_resolution', approvalId, decision, resolvedAt }
external_result{ type: 'external_result', operationId, resolvedAt, payload? }
scheduled_wake{ type: 'scheduled_wake', wakeUpId?, firedAt }

TTL 默认

结果默认 TTL
needs_clarification1小时(3 600 000毫秒)
awaiting_approval24小时(86 400 000毫秒)
deferred1小时
scheduled_wake1小时

通过 config.defaults 或通过 create({ bounds })。 。 。 .


适配器

ContinuationHarnessAdapter

interface ContinuationHarnessAdapter {
  runResumedTurn(input: ContinuationResumedTurnInput): Promise<HarnessResult>;
}

产品在调用绳索之前就用它来连接转折文本组装.

ContinuationDeliveryAdapter

interface ContinuationDeliveryAdapter {
  deliver(input: ContinuationDeliveryInput): Promise<ContinuationDeliveryResult>;
}

可选的 当出现时,在恢复转弯后呼叫,会产生一个用户可见的终端结果.

ContinuationSchedulerAdapter

interface ContinuationSchedulerAdapter {
  scheduleWake(input: { continuationId: string; wakeAtMs: number }): Promise<{ wakeUpId: string }>;
  cancelWake?(wakeUpId: string): Promise<void>;
}

可选的 仅限 scheduled_wake 续行.

ContinuationStore

interface ContinuationStore {
  put(record: ContinuationRecord): Promise<void>;
  get(continuationId: string): Promise<ContinuationRecord | null>;
  delete?(continuationId: string): Promise<void>;
  listBySession?(sessionId: string): Promise<ContinuationRecord[]>;
}

仅 put 财务报告和审定财务报表 get 需要这样做。 使用 InMemoryContinuationStore 用于测试和开发.


交货状态

状态含义
not_applicable没有配置送出适配器
pending_delivery交付适配器存在;尚未尝试交付
delivered后续行动成功交付
suppressed_session_reengaged用户重新参与; 后续行动被压制
suppressed_superseded交货前继续替换
suppressed_expired继续交货前过期
delivery_failed交付适配器返回失败

错误类型

错误掷出时
ContinuationNotFoundError未保存的记录 ID
ContinuationExpiredError记录 TTL 已经通过
ContinuationAlreadyTerminalError恢复未用记录
ContinuationTriggerMismatchError触发类型或关联性 ID 不匹配
ContinuationInvalidInputError无效的创建输入( 不良结果, 缺少所需的字段)

边界

  • 利用性释放出可恢复的结果。 继续运作. 这个套件不会影响机能.
  • 主动对接续 : 如果没有原生的 停止转动的ID,它是主动的。 如果该助手正在恢复已知的未完成的转折行系,则继续.
  • 继续不是排程. 预定的守夜是触发器 类型,而非调度器执行.
  • 继续不是一个记忆系统. 它只保存一个未完成的转折线的短寿命运行状态.
  • v1 范围 : 一个现场记录每个源转。 多分支接续图明显超出范围.

版本与发布记录

@agent-assistant/continuation 共发布 64 个版本,首次发布于 2026/04/15;过去 12 个月发布了 64 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.37latest2026/10/041 个月前
0.4.362026/10/041 个月前
0.4.352026/05/235 个月前
0.4.332026/05/155 个月前
0.4.322026/05/125 个月前
0.4.312026/05/086 个月前

关于 @agent-assistant/continuation 的常见问题

@agent-assistant/continuation 是什么?

基础延续原始——将可恢复的利用成果转化为明确状态,验证恢复触发器,以及真正的后续交付

如何安装 @agent-assistant/continuation?

在项目目录运行 npm install @agent-assistant/continuation,或使用 pnpm add / yarn add / bun add。

@agent-assistant/continuation 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agent-assistant/continuation 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@agent-assistant/continuation 可以商用吗?

@agent-assistant/continuation 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@agent-assistant/continuation 的下载量有多少?

根据 npm 官方下载统计,@agent-assistant/continuation 在 2026/10/05 – 2026/11/03 这 30 天内被下载 6,092 次,日均约 203 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agent-assistant/continuation 还在维护吗?

最新版本 0.4.37 发布于 2026/10/04(1 个月前);至今共发布 64 个版本,其中过去 12 个月发布了 64 个;首次发布于 2026/04/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。