qlogicagent 2.20.1 → 2.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/agent-contract.js +1 -1
  2. package/dist/agent.js +39 -35
  3. package/dist/cli.js +1 -1
  4. package/dist/host-contract.js +1 -1
  5. package/dist/host-session-collection-contract.js +1 -1
  6. package/dist/index.js +624 -549
  7. package/dist/memory-category-contract.js +1 -0
  8. package/dist/orchestration.js +1 -1
  9. package/dist/project-memory-host.js +21 -21
  10. package/dist/protocol.js +1 -1
  11. package/dist/skill-category-contract.js +1 -0
  12. package/dist/skills/builtin/web-research/SKILL.md +37 -0
  13. package/dist/skills/mcp/astraclaw-native-mcp-server.js +1 -1
  14. package/dist/tunables.js +1 -1
  15. package/dist/types/agent/memory-recall-context.d.ts +6 -9
  16. package/dist/types/agent/memory-recall-injection.d.ts +1 -6
  17. package/dist/types/agent/tool-loop/agent-argument-normalizer.d.ts +12 -0
  18. package/dist/types/agent/tool-loop/artifact-final-contract.d.ts +8 -0
  19. package/dist/types/agent/tool-loop.d.ts +5 -0
  20. package/dist/types/agent/types.d.ts +5 -0
  21. package/dist/types/cli/acp-extended-handlers.d.ts +11 -9
  22. package/dist/types/cli/acp-session-handlers.d.ts +1 -1
  23. package/dist/types/cli/acp-session-host.d.ts +8 -0
  24. package/dist/types/cli/agent-runtime-bootstrap.d.ts +7 -1
  25. package/dist/types/cli/agent-runtime-session-state.d.ts +23 -6
  26. package/dist/types/cli/atomic-text-file.d.ts +31 -0
  27. package/dist/types/cli/background-context-capsule.d.ts +12 -0
  28. package/dist/types/cli/base-tool-bootstrap.d.ts +1 -0
  29. package/dist/types/cli/cli-acp-request-handler.d.ts +3 -1
  30. package/dist/types/cli/community-workflow-installer.d.ts +1 -1
  31. package/dist/types/cli/core-tool-coordinator.d.ts +1 -0
  32. package/dist/types/cli/core-tools/agent-tool-service.d.ts +17 -1
  33. package/dist/types/cli/dev-tool-bootstrap.d.ts +3 -2
  34. package/dist/types/cli/dev-tools/dev-tool-bootstrap-service.d.ts +1 -0
  35. package/dist/types/cli/dev-tools/dev-tool-registry.d.ts +3 -1
  36. package/dist/types/cli/dev-tools/incremental-repo-map.d.ts +81 -0
  37. package/dist/types/cli/dev-tools/lsp-supervisor.d.ts +59 -0
  38. package/dist/types/cli/dev-tools/lsp-tool-service.d.ts +2 -0
  39. package/dist/types/cli/handlers/dream-handler.d.ts +1 -1
  40. package/dist/types/cli/handlers/memory-handler.d.ts +2 -14
  41. package/dist/types/cli/handlers/product-handler.d.ts +6 -24
  42. package/dist/types/cli/handlers/turn-handler.d.ts +1 -0
  43. package/dist/types/cli/idle-dream-coordinator.d.ts +9 -5
  44. package/dist/types/cli/memory-background-coordinator.d.ts +26 -0
  45. package/dist/types/cli/memory-candidate-service.d.ts +2 -3
  46. package/dist/types/cli/memory-coordinator.d.ts +12 -8
  47. package/dist/types/cli/permission-bootstrap.d.ts +10 -1
  48. package/dist/types/cli/product-acp-params.d.ts +29 -0
  49. package/dist/types/cli/resolved-agent-cache.d.ts +18 -7
  50. package/dist/types/cli/rpc-registry.d.ts +2 -1
  51. package/dist/types/cli/runtime-hook-bootstrap.d.ts +2 -0
  52. package/dist/types/cli/stdio-acp-request-host.d.ts +7 -4
  53. package/dist/types/cli/stdio-agent-session-bootstrap.d.ts +8 -2
  54. package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +4 -2
  55. package/dist/types/cli/stdio-runtime-bootstrap.d.ts +1 -0
  56. package/dist/types/cli/stdio-server.d.ts +49 -16
  57. package/dist/types/cli/stdio-session-runtime-coordinator.d.ts +0 -2
  58. package/dist/types/cli/task-distillation-coordinator.d.ts +42 -14
  59. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +14 -4
  60. package/dist/types/cli/tool-bootstrap.d.ts +2 -1
  61. package/dist/types/cli/turn-core.d.ts +4 -0
  62. package/dist/types/cli/turn-lifecycle.d.ts +1 -0
  63. package/dist/types/contracts/hooks.d.ts +3 -2
  64. package/dist/types/contracts/turn-event.d.ts +7 -0
  65. package/dist/types/host-contract/index.d.ts +111 -12
  66. package/dist/types/host-contract/memory-category.d.ts +8 -0
  67. package/dist/types/host-contract/skill-category.d.ts +5 -0
  68. package/dist/types/host-session-collection-contract.d.ts +1 -0
  69. package/dist/types/orchestration/agent-instance.d.ts +15 -0
  70. package/dist/types/orchestration/dag-scheduler.d.ts +18 -0
  71. package/dist/types/orchestration/delegate-approval-policy.d.ts +8 -0
  72. package/dist/types/orchestration/goal-acceptance.d.ts +2 -5
  73. package/dist/types/orchestration/goal-loop-coordinator.d.ts +4 -2
  74. package/dist/types/orchestration/goal-mode-adapters.d.ts +16 -0
  75. package/dist/types/orchestration/goal-run-types.d.ts +6 -1
  76. package/dist/types/orchestration/product-budget.d.ts +35 -16
  77. package/dist/types/orchestration/product-persistence.d.ts +5 -14
  78. package/dist/types/orchestration/product-planner.d.ts +38 -0
  79. package/dist/types/orchestration/product-worktree.d.ts +4 -2
  80. package/dist/types/orchestration/solo-evaluator.d.ts +42 -2
  81. package/dist/types/orchestration/solo-spec-builder.d.ts +3 -0
  82. package/dist/types/orchestration/testing/delegate-test-bridge.d.ts +6 -0
  83. package/dist/types/orchestration/testing/run-state-client-double.d.ts +13 -0
  84. package/dist/types/orchestration/workflow/builtin-capabilities.d.ts +3 -0
  85. package/dist/types/orchestration/workflow/capability-catalog.d.ts +31 -0
  86. package/dist/types/orchestration/workflow/cron-schedule.d.ts +3 -4
  87. package/dist/types/orchestration/workflow/expression.d.ts +2 -1
  88. package/dist/types/orchestration/workflow/n8n-import.d.ts +3 -0
  89. package/dist/types/orchestration/workflow/node-registry.d.ts +2 -2
  90. package/dist/types/orchestration/workflow/node-schema.d.ts +20 -4
  91. package/dist/types/orchestration/workflow/params-schema.d.ts +7 -6
  92. package/dist/types/orchestration/workflow/qla-executor-host.d.ts +4 -1
  93. package/dist/types/orchestration/workflow/run-history-store.d.ts +33 -3
  94. package/dist/types/orchestration/workflow/semantic-acceptance.d.ts +65 -0
  95. package/dist/types/orchestration/workflow/workflow-authoring.d.ts +74 -0
  96. package/dist/types/orchestration/workflow/workflow-bundle.d.ts +4 -0
  97. package/dist/types/orchestration/workflow/workflow-controller.d.ts +16 -4
  98. package/dist/types/orchestration/workflow/workflow-edit-context.d.ts +46 -0
  99. package/dist/types/orchestration/workflow/workflow-intent-contract.d.ts +56 -0
  100. package/dist/types/orchestration/workflow/workflow-patch.d.ts +7 -0
  101. package/dist/types/orchestration/workflow/workflow-runtime.d.ts +5 -0
  102. package/dist/types/orchestration/workflow/workflow-scheduler.d.ts +11 -0
  103. package/dist/types/orchestration/workflow/workflow-store.d.ts +5 -0
  104. package/dist/types/orchestration/workflow/workflow-template-setup.d.ts +65 -0
  105. package/dist/types/orchestration/workflow/workflow-trigger.d.ts +4 -0
  106. package/dist/types/orchestration/workflow-chat-builder.d.ts +105 -20
  107. package/dist/types/orchestration/worktree-task-prompt.d.ts +1 -0
  108. package/dist/types/protocol/agent-contract.d.ts +49 -8
  109. package/dist/types/protocol/notifications.d.ts +1 -1
  110. package/dist/types/protocol/wire/acp-agent-management.d.ts +97 -9
  111. package/dist/types/protocol/wire/acp-protocol.d.ts +7 -1
  112. package/dist/types/protocol/wire/agent-methods.d.ts +15 -1
  113. package/dist/types/protocol/wire/index.d.ts +2 -4
  114. package/dist/types/protocol/wire/memory-provider-lifecycle.d.ts +1 -39
  115. package/dist/types/protocol/wire/notification-payloads.d.ts +96 -1
  116. package/dist/types/protocol/wire/web-capability.d.ts +2 -2
  117. package/dist/types/runtime/config/tunable-defaults.d.ts +0 -6
  118. package/dist/types/runtime/execution/bounded-output-tail.d.ts +7 -0
  119. package/dist/types/runtime/execution/dream-agent.d.ts +8 -5
  120. package/dist/types/runtime/execution/dream-category-context.d.ts +3 -3
  121. package/dist/types/runtime/execution/structured-tool-progress.d.ts +21 -0
  122. package/dist/types/runtime/hooks/memory-hooks.d.ts +20 -8
  123. package/dist/types/runtime/infra/background-tasks.d.ts +5 -1
  124. package/dist/types/runtime/infra/subagent-turn-snapshot.d.ts +32 -0
  125. package/dist/types/runtime/infra/turn-telemetry-store.d.ts +22 -0
  126. package/dist/types/runtime/memory/implicit-extraction.d.ts +23 -7
  127. package/dist/types/runtime/ports/agent-runtime-ports.d.ts +0 -5
  128. package/dist/types/runtime/ports/index.d.ts +2 -3
  129. package/dist/types/runtime/ports/memory-provider.d.ts +31 -16
  130. package/dist/types/runtime/ports/memory-writer.d.ts +55 -6
  131. package/dist/types/runtime/ports/permission-contracts.d.ts +2 -0
  132. package/dist/types/runtime/ports/tool-contracts.d.ts +3 -1
  133. package/dist/types/runtime/prompt/identity-section.d.ts +2 -0
  134. package/dist/types/runtime/session/session-permission-store.d.ts +6 -0
  135. package/dist/types/runtime/tasks/task-types.d.ts +2 -0
  136. package/dist/types/skills/memory/host-memory-provider.d.ts +59 -9
  137. package/dist/types/skills/memory/memory-tool.d.ts +3 -1
  138. package/dist/types/skills/memory/task-distillation.d.ts +22 -3
  139. package/dist/types/skills/permissions/hook-runner.d.ts +8 -0
  140. package/dist/types/skills/permissions/operation-classifier.d.ts +7 -0
  141. package/dist/types/skills/skill-system/skill-category.d.ts +10 -0
  142. package/dist/types/skills/tools/agent-tool.d.ts +13 -21
  143. package/dist/types/skills/tools/edit-tool.d.ts +10 -2
  144. package/dist/types/skills/tools/exec-tool.d.ts +2 -2
  145. package/dist/types/skills/tools/file-text-snapshot.d.ts +24 -0
  146. package/dist/types/skills/tools/lsp-tool.d.ts +1 -1
  147. package/dist/types/skills/tools/patch-tool.d.ts +10 -3
  148. package/dist/types/skills/tools/read-tool.d.ts +23 -1
  149. package/dist/types/skills/tools/repo-map-tool.d.ts +52 -0
  150. package/dist/types/skills/tools/search-tool.d.ts +10 -1
  151. package/dist/types/skills/tools/shell/index.d.ts +1 -2
  152. package/dist/types/skills/tools/shell/shell-command.d.ts +1 -1
  153. package/dist/types/skills/tools/shell/shell-exec.d.ts +2 -2
  154. package/dist/types/skills/tools/shell/task-output.d.ts +12 -3
  155. package/dist/types/skills/tools/subagent-decision-tool.d.ts +15 -0
  156. package/dist/types/skills/tools/task-tool.d.ts +16 -2
  157. package/dist/types/skills/tools/write-tool.d.ts +2 -1
  158. package/dist/types/transport/acp-server.d.ts +1 -0
  159. package/dist/types/transport/host-run-state-client.d.ts +6 -0
  160. package/dist/types/workflow-host.d.ts +8 -1
  161. package/dist/workflow-host.js +9 -9
  162. package/package.json +25 -6
  163. package/dist/types/cli/tool-bootstrap-web-registration.d.ts +0 -14
  164. package/dist/types/orchestration/tool-cascade.d.ts +0 -49
  165. package/dist/types/protocol/wire/channel-ingress.d.ts +0 -29
  166. package/dist/types/protocol/wire/channel.d.ts +0 -89
  167. package/dist/types/runtime/infra/native-mcp-config-sync.d.ts +0 -16
  168. package/dist/types/runtime/memory/categories.d.ts +0 -5
  169. package/dist/types/runtime/memory/recall-category-filter.d.ts +0 -42
  170. package/dist/types/runtime/ports/source-provider.d.ts +0 -39
  171. package/dist/types/runtime/ports/web-search-contracts.d.ts +0 -21
  172. package/dist/types/server/search-svc.d.ts +0 -1
  173. package/dist/types/skills/memory/local-embedding.d.ts +0 -80
  174. package/dist/types/skills/memory/memory-config-resolver.d.ts +0 -4
  175. package/dist/types/skills/memory/memory-embedding-config.d.ts +0 -31
  176. package/dist/types/skills/tools/web-answer-tool.d.ts +0 -27
  177. package/dist/types/skills/tools/web-fetch-tool.d.ts +0 -80
  178. package/dist/types/skills/tools/web-research-tool.d.ts +0 -48
  179. package/dist/types/skills/tools/web-search-tool.d.ts +0 -46
  180. package/dist/types/skills/web-search/brave-source.d.ts +0 -3
  181. package/dist/types/skills/web-search/crawl4ai-extractor.d.ts +0 -16
  182. package/dist/types/skills/web-search/embedding-rerank.d.ts +0 -13
  183. package/dist/types/skills/web-search/exa-source.d.ts +0 -3
  184. package/dist/types/skills/web-search/multi-source-backend.d.ts +0 -23
  185. package/dist/types/skills/web-search/redis-source-cache.d.ts +0 -6
  186. package/dist/types/skills/web-search/search-svc-source.d.ts +0 -5
  187. package/dist/types/skills/web-search/searxng-source.d.ts +0 -4
  188. package/dist/types/skills/web-search/serper-source.d.ts +0 -3
  189. package/dist/types/skills/web-search/source-factory.d.ts +0 -6
  190. package/dist/types/skills/web-search/stability.d.ts +0 -26
  191. package/dist/types/skills/web-search/web-tunable-resolver.d.ts +0 -16
@@ -1,14 +1,16 @@
1
1
  /**
2
2
  * Task distillation coordinator (R3 wiring) — 候选采集/空闲窗蒸馏/晋升通知。
3
3
  * 纯逻辑在 skills/memory/task-distillation.ts;本模块只做依赖装配与生命周期:
4
- * · recordTurn: turn-handler 回合完成处调用(轻量,embedding 异步)
4
+ * · captureTurn: 回合完成屏障内只持久化候选;embedding 留给可抢占后台
5
+ * · enrichCandidate: 后台补充 embedding;被前台抢占也不影响已持久化候选
5
6
  * · runPass: idle 空闲窗(stdio-server onIdle 并联)与 memory.distill RPC 共用入口
6
7
  * · 蒸馏产物: category=procedure 进长期记忆(tag distilled@v1+sig),召回自然带出;
7
8
  * LLM 摘要(dream 同款小模型)失败时降级确定性模板 —— 蒸馏永不因模型不可用而丢样本。
8
- * · 晋升(spec:唯一技能入口): accessCount ≥ 阈值且未被负反馈沉底 → system.activity 推荐。
9
+ * · 晋升(spec:唯一技能入口):复用量只用于发现候选;Host 的来源证据与跨会话前台结果验证是硬门槛。
9
10
  */
10
11
  import { type PromotionMetrics, type CandidateStoreFile, type PromotionProposal, type ProcedureUsageStoreFile, type PromotionStoreFile } from "../skills/memory/task-distillation.js";
11
12
  import type { HostCapabilityClient } from "../transport/host-capability-client.js";
13
+ import type { ProcedureVerificationEvidence } from "../host-contract/index.js";
12
14
  /** [A4] addProcedure 落库回执分类(见 TaskDistillationDeps.addProcedure)。 */
13
15
  export type AddProcedureOutcome = "created" | "merged" | "rejected" | "retryable-failure";
14
16
  export interface TaskDistillationDeps {
@@ -16,25 +18,35 @@ export interface TaskDistillationDeps {
16
18
  hostCapabilityClient: () => HostCapabilityClient | undefined;
17
19
  /** 签名 embedding;null=不可用(候选照存但不参与聚类,宁严勿松)。
18
20
  * B3(X7):number[](非 Float32Array)——host 模式下 embedText 结果跨 x/host.request JSON wire。 */
19
- embed: (text: string) => Promise<number[] | null>;
21
+ embed: (text: string, signal?: AbortSignal) => Promise<number[] | null>;
20
22
  /** [A4] 落库回执四分类(由 ingestExtracted 的结构化 items 归并):
21
23
  * created = 真实新落库 → 标 distilled + 发通知(只有它发);
22
24
  * merged = 近重复合并/已入提案管道 —— 合法成功,标 distilled 不通知;
23
25
  * rejected = 安全闸拒/冲突 —— 终态,候选标 rejected 不再重试;
24
26
  * retryable-failure = RPC 抛错/环境未就绪 —— 候选保持 pending 等下轮。 */
25
- addProcedure: (text: string, tags: string[]) => Promise<AddProcedureOutcome>;
27
+ addProcedure: (text: string, tags: string[], evidence: {
28
+ candidateIds: string[];
29
+ idempotencyKey: string;
30
+ }) => Promise<AddProcedureOutcome>;
26
31
  /** 小模型摘要(dream 同款);null/失败 → 降级模板 */
27
- llmExtract?: (prompt: string) => Promise<string | null>;
32
+ llmExtract?: (prompt: string, signal?: AbortSignal) => Promise<string | null>;
28
33
  /** 晋升扫描数据源:全部 distilled 条目 {id,text,accessCount,importance} */
29
34
  listDistilled: () => Promise<Array<{
30
35
  id: string;
31
36
  text: string;
32
37
  accessCount: number;
33
38
  importance: number;
39
+ verification: ProcedureVerificationEvidence;
34
40
  }>>;
35
- /** V3 promote/demote:archive(技能接棒)/unarchive(降格回归)。B3(X7)异步化:16 proxy 方法。
36
- * [A10] 后仅 demote 侧消费(promote 三步已收归 Host saga)。 */
37
- setMemoryArchived: (id: string, archived: boolean) => Promise<boolean>;
41
+ /** Exact archived-aware recovery probe; unlike listDistilled this does not hide retired rows. */
42
+ readDistilledProcedure: (procedureId: string) => Promise<{
43
+ id: string;
44
+ text: string;
45
+ accessCount: number;
46
+ importance: number;
47
+ isArchived: boolean;
48
+ verification: ProcedureVerificationEvidence;
49
+ } | null>;
38
50
  /** [A10] 升格窄 Saga(Host 协调,memory proxy promoteDistilledProcedure):
39
51
  * create+verify → archive → proposal accepted,幂等/补偿/续跑在 Host;
40
52
  * 大脑传入推理产物(渲染并校验过的 SKILL.md 全文、确定性 skillName、标题/计数/auto)。 */
@@ -54,6 +66,17 @@ export interface TaskDistillationDeps {
54
66
  proposalAccepted: boolean;
55
67
  };
56
68
  }>;
69
+ demoteProcedure: (input: {
70
+ procedureId: string;
71
+ }) => Promise<{
72
+ outcome: "completed" | "already-completed";
73
+ skillName: string;
74
+ steps: {
75
+ skillDeleted: boolean;
76
+ memoryUnarchived: boolean;
77
+ proposalReverted: boolean;
78
+ };
79
+ }>;
57
80
  /** [X7] procedure-usage.json 读:store-owner 归 gateway,经 x/host proxy(自动档跨-session 数据源)。 */
58
81
  readProcedureUsage: () => Promise<ProcedureUsageStoreFile>;
59
82
  /** [X7] task-distill-candidates.json 读/写:store-owner 归 gateway;大脑侧裁剪(capCandidateStore)后经 proxy 写。 */
@@ -78,17 +101,22 @@ export interface DistillPassResult {
78
101
  promotionsNotified: number;
79
102
  pendingCandidates: number;
80
103
  }
104
+ export declare function resolveCandidateEmbedding(embed: (text: string, signal?: AbortSignal) => Promise<number[] | null>, text: string, timeoutMs?: number, signal?: AbortSignal): Promise<number[] | null>;
81
105
  export declare class TaskDistillationCoordinator {
82
106
  private readonly deps;
83
107
  private readonly turnIndexBySession;
108
+ private candidateMutationTail;
84
109
  constructor(deps: TaskDistillationDeps);
85
110
  private requireCapability;
86
- /** 回合完成时采集候选。异步(embedding 网络调用),错误吞掉不碰回合主链。 */
87
- recordTurn(input: RecordTurnInput): Promise<void>;
111
+ private withCandidateMutation;
112
+ /** 回合完成屏障内的轻量持久化。Host 写成功后进程回收也不会丢候选。 */
113
+ captureTurn(input: RecordTurnInput): Promise<string | null>;
114
+ /** Cancellable embedding enhancement for a candidate already owned by Host. */
115
+ enrichCandidate(candidateId: string, promptHead: string, signal?: AbortSignal): Promise<void>;
88
116
  /** 空闲窗/手动共用的蒸馏 pass。 */
89
- runPass(reason: "idle" | "manual"): Promise<DistillPassResult>;
117
+ runPass(reason: "idle" | "manual", signal?: AbortSignal): Promise<DistillPassResult>;
90
118
  private renderProcedure;
91
- /** 晋升扫描(spec:技能的唯一产生入口):复用达标且未被负反馈沉底 写持久提议。
119
+ /** 晋升扫描(spec:技能的唯一产生入口):候选先过发现阈值,再以 Host 能力验证作为硬门槛。
92
120
  * V3.1:提议是持久待办(promotion-proposals.json),UI 双入口消费;activity 仅作日志。 */
93
121
  private scanPromotions;
94
122
  listProposals(): Promise<PromotionProposal[]>;
@@ -104,12 +132,12 @@ export declare class TaskDistillationCoordinator {
104
132
  * 该窗口失败即双向死角(重跑撞 already exists,demote 缺 skillName 找不到目标)。 */
105
133
  promote(procedureId: string, opts?: {
106
134
  auto?: boolean;
107
- }): Promise<{
135
+ }, signal?: AbortSignal): Promise<{
108
136
  ok: boolean;
109
137
  skillName?: string;
110
138
  error?: string;
111
139
  }>;
112
- /** 降格(可撤销是信任基础):删技能+unarchive procedure;proposal dismissed(用户明确否定,不再纠缠)。 */
140
+ /** 降格的跨存储事务、补偿与崩溃续跑全部由 Host saga 持有。 */
113
141
  demote(procedureId: string): Promise<{
114
142
  ok: boolean;
115
143
  error?: string;
@@ -36,13 +36,25 @@ export declare function registerLocalCoreTools(context: LocalCoreToolRegistratio
36
36
  export declare function validateExecCommand(command: string, workdir: string, groupMode?: boolean): string | null;
37
37
  /** office/pdf 文档扩展名 → mime;非文档返回 undefined。导出仅为单测。 */
38
38
  export declare function documentMimeForExtension(ext: string): string | undefined;
39
+ interface GrepBackendOptions {
40
+ fileGlob?: string;
41
+ caseInsensitive?: boolean;
42
+ contextLines?: number;
43
+ headLimit?: number;
44
+ offset?: number;
45
+ includePath?: (candidate: string) => boolean;
46
+ }
39
47
  export interface RipgrepGrepOutcome {
40
48
  matches: Array<{
41
49
  path: string;
42
50
  line: number;
43
51
  text: string;
52
+ contextBefore?: string[];
53
+ contextAfter?: string[];
44
54
  }>;
45
55
  truncated: boolean;
56
+ totalMatches?: number;
57
+ totalMatchesKnown: boolean;
46
58
  /** Model-facing incompleteness note (search tool appends it to content). */
47
59
  note?: string;
48
60
  }
@@ -56,7 +68,5 @@ export interface RipgrepGrepOutcome {
56
68
  export declare function resolveRipgrepOutcome(err: (Error & {
57
69
  killed?: boolean;
58
70
  code?: number | string | null;
59
- }) | null, stdout: string, options: {
60
- headLimit?: number;
61
- offset?: number;
62
- }): RipgrepGrepOutcome | null;
71
+ }) | null, stdout: string, options: Pick<GrepBackendOptions, "headLimit" | "offset" | "contextLines" | "includePath">): RipgrepGrepOutcome | null;
72
+ export {};
@@ -53,7 +53,7 @@ export interface BootstrapConfig {
53
53
  log?: AgentLogger;
54
54
  /** Called during foreground shell execution with incremental progress. */
55
55
  onExecProgress?(progress: ExecProgress): void;
56
- /** host 多档 LLM 解析(web_answer/web_research 用);未提供则不注册这些工具(零孤立)。 */
56
+ /** Optional Host model resolver for locally compiled model-backed tools such as media understanding. */
57
57
  resolveClientForPurpose?(purpose: ModelPurpose): {
58
58
  transport: LLMTransport;
59
59
  apiKey: string;
@@ -61,6 +61,7 @@ export interface BootstrapConfig {
61
61
  } | null;
62
62
  getTaskScopeKey?(): string | undefined;
63
63
  getCurrentTurnId?(): string | undefined;
64
+ isGroupSecurityMode?(): boolean;
64
65
  sendNotification?(method: string, params: Record<string, unknown>): void;
65
66
  loadTunableOverrides?(): Promise<Record<string, unknown>>;
66
67
  }
@@ -18,12 +18,16 @@ export interface TurnCoreRequest {
18
18
  refreshTools?: () => ToolDefinition[];
19
19
  /** Mid-turn guidance drain (运行中引导) — forwarded to the tool loop. */
20
20
  drainPendingGuidance?: () => string[];
21
+ /** Session-scoped background result drain — forwarded to the tool loop. */
22
+ drainPendingTaskNotifications?: () => string[];
21
23
  /** Sanitize tool-result media the main model can't consume — forwarded to the tool loop. */
22
24
  sanitizeToolResultMedia?: (message: Record<string, unknown>) => Promise<void>;
23
25
  /** Persist each model-visible tool-stream message to the transcript — forwarded to the tool loop. */
24
26
  persistTurnMessage?: (message: ChatMessage) => void;
25
27
  systemPrompt: string;
26
28
  config: TurnConfig;
29
+ /** Epoch/identity guard supplied by the session lifecycle owner. */
30
+ isTurnCurrent?: () => boolean;
27
31
  }
28
32
  export interface TurnCoreAgent {
29
33
  run(request: TurnCoreRequest, signal?: AbortSignal): AsyncIterable<TurnEvent>;
@@ -9,6 +9,7 @@ export interface TurnLifecycleHost {
9
9
  sessionState: SessionState | null;
10
10
  memoryPrefetchState: MemoryPrefetchState;
11
11
  enableIdleDream(): void;
12
+ log?(message: string): void;
12
13
  }
13
14
  export interface PreparedTurnLifecycle {
14
15
  abortController: AbortController;
@@ -83,6 +83,8 @@ export interface HookContextMap {
83
83
  };
84
84
  "turn.completed": HookTurnContext & {
85
85
  outcomeId?: string;
86
+ prompt?: string;
87
+ response?: string;
86
88
  };
87
89
  "turn.failed": HookTurnContext & {
88
90
  code?: string;
@@ -118,9 +120,8 @@ export interface HookContextMap {
118
120
  category?: string | null;
119
121
  source?: string;
120
122
  label?: string;
123
+ metadata?: Record<string, unknown>;
121
124
  }>;
122
- preferredCategories?: string[];
123
- deprioritizedCategories?: string[];
124
125
  };
125
126
  "memory.after_recall": HookTurnContext & {
126
127
  blockCount?: number;
@@ -110,6 +110,13 @@ export type TurnEvent = {
110
110
  name: string;
111
111
  reason: string;
112
112
  }>;
113
+ argumentCorrections?: {
114
+ roleAlias: number;
115
+ promptAlias: number;
116
+ backgroundAlias: number;
117
+ agentValue: number;
118
+ backgroundValue: number;
119
+ };
113
120
  } | {
114
121
  type: "lifecycle";
115
122
  turnId: string;
@@ -17,6 +17,7 @@ export { MODEL_PURPOSES, type ModelPurpose } from "@xiaozhiclaw/module-sdk/model
17
17
  export type { HostSessionCollectionDelta, HostSessionCollectionScope, HostSessionCollectionSnapshot, HostSessionLifecycle, HostSessionProviderDiagnostic, HostSessionSummary, HostSessionTitleSource, NativeTranscript, NativeTranscriptMessage, } from "../host-session-collection-contract.js";
18
18
  export { isHostSessionCollectionDelta, isHostSessionCollectionSnapshot, isNativeTranscript, } from "../host-session-collection-contract.js";
19
19
  export * from "./provider-profile.js";
20
+ export * from "./memory-category.js";
20
21
  /** agent 逻辑身份(小智自身也是一个 agentId="qlogicagent")。自身 vs 第三方仅由此值决定(F2)。 */
21
22
  export type AgentId = string;
22
23
  /** 确定性派生的项目主键(freeze §11.4#2,抄 VSCode getWorkspaceId)。绝不随机、绝不裸路径。 */
@@ -512,29 +513,24 @@ export interface MemoryRecord {
512
513
  createdAt?: string;
513
514
  updatedAt?: string;
514
515
  }
515
- /** [S1 补定] 记忆匹配条件(delete 用)。 */
516
+ /** Exact durable-memory match used by the Host storage contract. */
516
517
  export interface MemoryMatch {
517
518
  ids?: string[];
518
519
  query?: string;
519
520
  }
520
521
  /**
521
- * MemoryProfileService —— 记忆 + profile 数据(spec §14)。
522
- * 小智可为默认写入/解释者,但非唯一 owner;任意 peer 经 host 读写(P2:写入必带 byAgent)。
523
- * 是 memory MCP 能力模块(freeze §3.7)的 store-owner;三张脸(MCP 面/UI-API 面/brain proxy 面 X7)
524
- * 都是 thin adapter,唯一写者恒为本服务(脸数≠拷贝数,M-1)。
522
+ * Minimal durable-store contract implemented only by Runtime.
525
523
  *
526
- * A 域库面(memories.db + 附件 + 晋升/蒸馏 JSON + 用户级 INDEX.md 派生渲染)与 C 域项目 memdir
527
- * (`<cwd>/.qlogicagent/memory/`)都由 Gateway 独占在线存取。C 域仍是项目文件而非用户 Host store,
528
- * 但 agent 只能经 projectMemory X7 语义代理访问,与 VSCode ext host 经 main IFileService proxy 同构。
524
+ * `memories.db` is the single L2 authority. Project/file memory is a separate L1
525
+ * surface and never acts as a fallback for this service.
529
526
  */
530
527
  export interface MemoryProfileService {
531
528
  atlas(query: MemoryQuery): MemoryRecord[];
532
529
  read(source: string, target: string): MemoryRecord | undefined;
533
- /** 显式记录写入者(M-3) */
530
+ /** Every signed store write records the responsible Agent. */
534
531
  write(record: MemoryRecord, byAgent: AgentId): void;
535
532
  delete(match: MemoryMatch): void;
536
533
  consolidate(candidates: MemoryRecord[], source: string): void;
537
- promote(proposal: unknown): void;
538
534
  }
539
535
  /** [S1 补定] 首启进度状态。 */
540
536
  export interface OnboardingState {
@@ -589,6 +585,15 @@ export interface RunState {
589
585
  status: string;
590
586
  events?: RunEvent[];
591
587
  checkpoint?: unknown;
588
+ /**
589
+ * Rollback history ids, oldest first — ids only, never the snapshots.
590
+ *
591
+ * The store already retains the last 20 named checkpoints, but `RunState` used to carry just the
592
+ * head, so every read surface could only ever report one. A run reopened from history then showed a
593
+ * single-entry timeline and could only roll back to the newest point, silently losing the rest.
594
+ * Snapshots stay out: status/list readers want the timeline, not 20 full Product states.
595
+ */
596
+ checkpointIds?: string[];
592
597
  openedAt: string;
593
598
  updatedAt: string;
594
599
  }
@@ -601,6 +606,18 @@ export interface RunState {
601
606
  export interface RunStateStore {
602
607
  /** Optional caller-selected domain id keeps Solo/Product/Goal public ids identical to host run ids. */
603
608
  openRun(kind: "solo" | "product" | "goal", owner: SessionContext, runId?: RunId): RunId;
609
+ /**
610
+ * Atomic open + first checkpoint: the run becomes addressable ONLY once it already carries a snapshot.
611
+ *
612
+ * `openRun` followed by a separate `checkpoint` is two round trips, and a failure between them leaves
613
+ * an enveloped run with `checkpoint === undefined`. Readers that project a whole project's run list
614
+ * cannot tolerate that shape, so one such remnant permanently breaks the entire list for that project.
615
+ * Writers that always have their first snapshot in hand MUST use this instead of open+checkpoint.
616
+ *
617
+ * Idempotent in the same way as `openRun` (same kind + projectId + owner session re-uses the run);
618
+ * on re-use the snapshot is applied as a normal checkpoint.
619
+ */
620
+ openRunWithCheckpoint(kind: "solo" | "product" | "goal", owner: SessionContext, snapshot: unknown, runId?: RunId, checkpointId?: string): RunId;
604
621
  recordEvent(runId: RunId, ev: RunEvent): void;
605
622
  /** product/solo 检查点 */
606
623
  checkpoint(runId: RunId, snapshot: unknown, checkpointId?: string): void;
@@ -789,12 +806,42 @@ export declare const DELEGATE_WIRE_METHODS: {
789
806
  export interface HostNotificationSink {
790
807
  notify(eventName: string, payload: unknown): void;
791
808
  }
809
+ /** Durable hand-off from a completed foreground turn to the background semantic
810
+ * extractor. The Host owns this operational queue; the Agent owns extraction. */
811
+ export interface HostMemoryExtractionTurnInput {
812
+ sessionId: string;
813
+ turnId: string;
814
+ priorUserMessage?: string;
815
+ userMessage: string;
816
+ assistantMessage: string;
817
+ }
818
+ export interface HostPendingMemoryExtractionTurn extends HostMemoryExtractionTurnInput {
819
+ id: string;
820
+ attempts: number;
821
+ lastError: string;
822
+ leaseOwner: string;
823
+ leasedUntil: number;
824
+ createdAt: number;
825
+ updatedAt: number;
826
+ }
792
827
  /**
793
828
  * [X7] qlogicagent 大脑经 x/host.request 可调用的 memory proxy 精确方法面。
794
829
  * gateway 白名单与 qla HostMemoryProvider 都必须直接消费此常量,禁止两仓手抄后漂移。
795
830
  */
796
- export declare const HOST_MEMORY_PROXY_METHODS: readonly ["search", "addText", "embedText", "ingestExtracted", "proposeExtracted", "consumePendingProposals", "feedback", "findRelatedEvents", "synthesizeTimeline", "getActivitySummary", "getAllProfiles", "setProfile", "getAtlas", "setMemoryArchived", "triggerDecay", "resolveConflicts", "readProcedureUsage", "writeProcedureUsage", "readDistillCandidates", "writeDistillCandidates", "readPromotionProposals", "writePromotionProposals", "listActiveMemoriesByTag", "promoteDistilledProcedure", "recordInjectedAccess"];
831
+ export declare const HOST_MEMORY_PROXY_METHODS: readonly ["search", "addText", "embedText", "ingestExtracted", "proposeExtracted", "consumePendingProposals", "feedback", "findRelatedEvents", "synthesizeTimeline", "getActivitySummary", "getAllProfiles", "setProfile", "getAtlas", "setMemoryArchived", "triggerDecay", "resolveConflicts", "readProcedureUsage", "writeProcedureUsage", "readDistillCandidates", "writeDistillCandidates", "readPromotionProposals", "writePromotionProposals", "listActiveMemoriesByTag", "readDistilledProcedure", "promoteDistilledProcedure", "demoteDistilledProcedure", "recordInjectedAccess", "recordRecallOutcome", "enqueueExtractionTurn", "claimPendingExtractionTurns", "completeExtractionTurn", "releaseExtractionTurn", "recordExtractionTurnFailure"];
797
832
  export type HostMemoryProxyMethod = (typeof HOST_MEMORY_PROXY_METHODS)[number];
833
+ /** Host-computed proof that a distilled procedure is a repeatable capability.
834
+ * Source executions prove how it was learned; helped use rows prove that the
835
+ * distilled procedure itself subsequently worked in foreground turns. */
836
+ export interface ProcedureVerificationEvidence {
837
+ sourceSuccessCount: number;
838
+ sourceDistinctSessions: number;
839
+ sourceDistinctPrompts: number;
840
+ successfulUseCount: number;
841
+ successfulUseSessions: number;
842
+ harmfulUseCount: number;
843
+ passed: boolean;
844
+ }
798
845
  /** Project-scoped Markdown memory face. Gateway resolves cwd/project from the supervised caller. */
799
846
  export declare const HOST_PROJECT_MEMORY_PROXY_METHODS: readonly ["initialize", "getIndex", "addToIndex", "replaceInIndex", "removeFromIndex", "createFile", "writeFile", "readFile", "deleteFile", "listFiles", "searchLocal"];
800
847
  export type HostProjectMemoryProxyMethod = (typeof HOST_PROJECT_MEMORY_PROXY_METHODS)[number];
@@ -882,6 +929,37 @@ export type HostProjectRequestParams = {
882
929
  primaryWorkflowId?: string;
883
930
  };
884
931
  };
932
+ export type HostSubagentType = "general" | "explore" | "plan" | "code" | "research" | "verify";
933
+ export interface HostDelegationTelemetrySummary {
934
+ schemaVersion: 1;
935
+ launched: number;
936
+ completed: number;
937
+ failed: number;
938
+ cancelled: number;
939
+ backgroundCount: number;
940
+ automaticDeliveryCount: number;
941
+ byAgentType: Partial<Record<HostSubagentType, number>>;
942
+ decisionCounts: {
943
+ adopted: number;
944
+ partiallyAdopted: number;
945
+ rejected: number;
946
+ unreported: number;
947
+ };
948
+ argumentCorrections: {
949
+ roleAlias: number;
950
+ promptAlias: number;
951
+ backgroundAlias: number;
952
+ agentValue: number;
953
+ backgroundValue: number;
954
+ };
955
+ durationMs: {
956
+ total: number;
957
+ max: number;
958
+ };
959
+ tokenUsage: {
960
+ total: number;
961
+ };
962
+ }
885
963
  export interface HostTurnTelemetryInput {
886
964
  model?: string;
887
965
  provider?: string;
@@ -902,6 +980,7 @@ export interface HostTurnTelemetryInput {
902
980
  changedPathsPreview?: string[];
903
981
  hasTurnFileChanges?: boolean;
904
982
  };
983
+ delegationSummary?: HostDelegationTelemetrySummary;
905
984
  }
906
985
  /** Minimal, non-message-text evidence returned to the agent-side pure distiller. */
907
986
  export interface HostDistillableFeedbackEvent {
@@ -1210,6 +1289,12 @@ export type HostMemoryRequestParams = {
1210
1289
  service: "memory";
1211
1290
  method: HostMemoryProxyMethod;
1212
1291
  params: unknown[];
1292
+ /**
1293
+ * Optional supervised-session selector for background mutations. The Host
1294
+ * validates that this session belongs to the calling supervised Agent before
1295
+ * using it as evidence provenance; it is never trusted as storage authority.
1296
+ */
1297
+ sessionId?: string;
1213
1298
  };
1214
1299
  export type HostProjectMemoryRequestParams = {
1215
1300
  service: "projectMemory";
@@ -1360,7 +1445,7 @@ export type HostFeedbackRequestParams = {
1360
1445
  };
1361
1446
  };
1362
1447
  /** Agent-originated semantic run-state operations. Owner/project/cwd are resolved by Gateway scope. */
1363
- export declare const HOST_RUN_STATE_PROXY_METHODS: readonly ["open", "recordEvent", "checkpoint", "get", "list", "delete", "getCheckpoint", "listCheckpoints", "restoreCheckpoint"];
1448
+ export declare const HOST_RUN_STATE_PROXY_METHODS: readonly ["open", "openWithCheckpoint", "recordEvent", "checkpoint", "get", "list", "delete", "getCheckpoint", "listCheckpoints", "restoreCheckpoint"];
1364
1449
  export type HostRunStateProxyMethod = typeof HOST_RUN_STATE_PROXY_METHODS[number];
1365
1450
  export type HostRunStateRequestParams = {
1366
1451
  service: "runState";
@@ -1371,6 +1456,19 @@ export type HostRunStateRequestParams = {
1371
1456
  projectId: ProjectId;
1372
1457
  sessionId: CanonicalSessionId;
1373
1458
  };
1459
+ }
1460
+ /** Atomic open + first checkpoint — see RunStateStore.openRunWithCheckpoint for why open+checkpoint is unsafe. */
1461
+ | {
1462
+ service: "runState";
1463
+ method: "openWithCheckpoint";
1464
+ params: {
1465
+ runId: RunId;
1466
+ kind: "solo" | "product" | "goal";
1467
+ projectId: ProjectId;
1468
+ snapshot: unknown;
1469
+ checkpointId?: string;
1470
+ sessionId: CanonicalSessionId;
1471
+ };
1374
1472
  } | {
1375
1473
  service: "runState";
1376
1474
  method: "recordEvent";
@@ -1694,3 +1792,4 @@ export declare function supportsHostRequestService(capability: unknown, service:
1694
1792
  * protocol→host-contract 模块环,check-architecture-boundaries top-level-cycles 抓出)。
1695
1793
  */
1696
1794
  export { segmentForFts, segmentTextForFts } from "./fts-segment.js";
1795
+ export { HUB_SKILL_CATEGORIES, HUB_SKILL_CATEGORY_LABELS, isHubSkillCategory, type HubSkillCategory, } from "./skill-category.js";
@@ -0,0 +1,8 @@
1
+ /** Host-owned taxonomy shared by every long-term-memory producer and consumer. */
2
+ export declare const LONG_TERM_MEMORY_CATEGORIES: readonly ["fact", "preference", "insight", "lesson", "decision", "plan", "event", "pattern", "context", "procedure", "general"];
3
+ export type LongTermMemoryCategory = (typeof LONG_TERM_MEMORY_CATEGORIES)[number];
4
+ /** Logical relation between an atomic claim slot and its structured value. */
5
+ export declare const MEMORY_CLAIM_RELATIONS: readonly ["equals", "includes", "excludes"];
6
+ export type MemoryClaimRelation = (typeof MEMORY_CLAIM_RELATIONS)[number];
7
+ export declare function normalizeLongTermMemoryCategory(value: unknown, fallback?: LongTermMemoryCategory): LongTermMemoryCategory;
8
+ export declare function normalizeMemoryClaimRelation(value: unknown, fallback?: MemoryClaimRelation): MemoryClaimRelation;
@@ -0,0 +1,5 @@
1
+ /** Host-owned taxonomy shared by skill promotion, persistence, and UI. */
2
+ export declare const HUB_SKILL_CATEGORIES: readonly ["efficiency", "dev", "cloud", "data", "industrial", "marketing", "ecommerce", "procurement", "hr", "accounting", "finance", "legal", "lifestyle"];
3
+ export type HubSkillCategory = (typeof HUB_SKILL_CATEGORIES)[number];
4
+ export declare const HUB_SKILL_CATEGORY_LABELS: Readonly<Record<HubSkillCategory, string>>;
5
+ export declare function isHubSkillCategory(value: unknown): value is HubSkillCategory;
@@ -23,6 +23,7 @@ export interface HostSessionSummary {
23
23
  title?: string;
24
24
  titleSource?: HostSessionTitleSource;
25
25
  lastActiveAt: string;
26
+ pinnedAt?: string;
26
27
  lifecycle: HostSessionLifecycle;
27
28
  /** Host-authorized mutation surface. Renderer commands are a projection of this list. */
28
29
  availableCommands: HostSessionCommand[];
@@ -172,6 +172,21 @@ export declare class ProductOrchestrator {
172
172
  private consultLeaderAfterFailure;
173
173
  private applyDagMutationsToSession;
174
174
  private finishProduct;
175
+ /**
176
+ * Durable persistence failed → the run is over. Declaring that is not enough: the in-flight work has
177
+ * to actually stop.
178
+ *
179
+ * This used to only set phase and stop the checkpoint timer, so with 3 parallel tasks the run went
180
+ * "failed" for the client while the other 2 kept executing for up to their full timeout — still
181
+ * writing worktrees and still issuing EXPLICIT checkpoints (`stop()` only cancels the periodic
182
+ * timer, it does not block direct writes). The persisted state then drifted into phase=failed with
183
+ * tasks=completed, `finishProduct` never ran, and the session stayed in the map forever.
184
+ *
185
+ * `session.cancelled` is the existing single flag that closes all of that: it makes in-flight tasks
186
+ * treat their outcome as non-failure, aborts the retry loops, and short-circuits the post-task
187
+ * checkpoint + scheduleNext. Kept synchronous (14 call sites, several inside sync paths) — the
188
+ * per-task `finally` already tears down each task worktree, so no async cleanup is needed here.
189
+ */
175
190
  private failRunStatePersistence;
176
191
  private publishNotification;
177
192
  private emitDagTopology;
@@ -92,6 +92,16 @@ export declare class DagScheduler {
92
92
  changedFiles?: string[];
93
93
  acceptanceUnverified?: boolean;
94
94
  }): void;
95
+ /**
96
+ * Mark failed. Terminal states are immutable: a node that already completed, was skipped, or
97
+ * already failed is left untouched.
98
+ *
99
+ * Without this guard markFailed was the one lifecycle transition with no precondition (markRunning /
100
+ * markCompleted / markSkipped all have one), so teardown and replay — which both call it on whatever
101
+ * task an instance last held — could rewrite a real success as a failure, erase its output, and then
102
+ * propagateSkips() would block the downstream that success had unlocked. Keeping the FIRST error also
103
+ * stops a late generic rejection ("gateway torn down") from burying the actual diagnosis.
104
+ */
95
105
  markFailed(id: string, error: string): void;
96
106
  markPaused(id: string): void;
97
107
  resumePaused(id: string): void;
@@ -126,6 +136,14 @@ export declare class DagScheduler {
126
136
  */
127
137
  resetForReplay(id: string): string[];
128
138
  /** Merge patch into node.params. Node must be pending. */
139
+ /**
140
+ * Merge patch into node.params. Allowed while the node is pending OR failed.
141
+ *
142
+ * "failed" is included because that is exactly when the leader refines a task: the node is not
143
+ * executing, and retryNode resets it to pending anyway, so the patch lands on the DAG that gets
144
+ * checkpointed. Holding such patches outside the node instead (a per-call scratch map) meant a
145
+ * refinement made in one consultation was gone by the next, and the retry re-ran the failing text.
146
+ */
129
147
  updateNodeParams(id: string, patch: Record<string, unknown>): void;
130
148
  /** Add an explicit edge. Validates no cycle. Validates ports exist on source. */
131
149
  addEdge(edge: Edge): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Unattended orchestration runs are explicitly launched by the user and already inherit the
3
+ * Host-projected permission scope. Approve only the current operation; never widen the persisted
4
+ * permission policy. If the provider cannot offer a one-shot approval, fail closed.
5
+ */
6
+ export declare function selectUnattendedApprovalOptionId(options: Array<Record<string, unknown>>): string;
7
+ /** Planning-only delegates must never execute tools; answer explicitly so the provider cannot hang. */
8
+ export declare function selectPlanningRejectionOptionId(options: Array<Record<string, unknown>>): string;
@@ -1,4 +1,4 @@
1
- import type { AcceptanceChecklist, AcceptanceEvidence, AcceptanceStatus } from "./goal-run-types.js";
1
+ import type { AcceptanceChecklist, AcceptanceCriterion, AcceptanceEvidence, AcceptanceStatus } from "./goal-run-types.js";
2
2
  /** Return a NEW checklist with one criterion's status flipped. Never mutates the input.
3
3
  * Monotonicity contract: a criterion that already `passed` may only revert to `failed` via a
4
4
  * deterministic verify REGRESSION (allowRegression=true). Any other downgrade of a passed criterion
@@ -14,7 +14,4 @@ export declare function unreachableCoversRemaining(checklist: AcceptanceChecklis
14
14
  reason: string;
15
15
  }[]): boolean;
16
16
  /** Derive a new immutable checklist version on goal-edit. Dropped criteria -> superseded. */
17
- export declare function newChecklistVersion(prev: AcceptanceChecklist, nextCriteria: {
18
- id: string;
19
- criterion: string;
20
- }[]): AcceptanceChecklist;
17
+ export declare function newChecklistVersion(prev: AcceptanceChecklist, nextCriteria: Pick<AcceptanceCriterion, "id" | "criterion" | "verify" | "evidenceSource">[]): AcceptanceChecklist;
@@ -43,16 +43,17 @@ export declare class GoalLoopCoordinator {
43
43
  private readonly deps;
44
44
  private seq;
45
45
  private opChain;
46
- private activeAbort;
46
+ private activePhase;
47
47
  private readonly persistenceContext;
48
48
  constructor(deps: GoalLoopCoordinatorDeps);
49
49
  private serialize;
50
50
  private notify;
51
51
  private append;
52
52
  private persist;
53
- /** Launch a goal-run (instant, Codex-style). Returns the goalRunId. */
53
+ /** Durably reserve a goal-run without entering the leader lane. Returns the goalRunId immediately. */
54
54
  start(goal: string, agentPool: string[]): Promise<string>;
55
55
  private startImpl;
56
+ private ensureChecklistInitializedImpl;
56
57
  /** Load the run; seed `seq` so a fresh instance (post-crash) keeps appending monotonically. */
57
58
  private load;
58
59
  enqueueMessage(goalRunId: string, text: string): Promise<void>;
@@ -87,6 +88,7 @@ export declare class GoalLoopCoordinator {
87
88
  /** Drive phases until the run ends or is paused. Not serialized: it only calls the serialized
88
89
  * runOnePhase in a loop, so a concurrent pause/stop is observed at the next boundary. */
89
90
  runToCompletion(goalRunId: string): Promise<PersistedGoalRunState>;
91
+ private publishRoundMessage;
90
92
  /** Pause: abort the in-flight phase IMMEDIATELY (before serialize) so it drains fast and the mutex
91
93
  * frees quickly, then persist the paused state. If the in-flight phase is the one being aborted, it
92
94
  * drains via its abort handler and persists `paused` itself (runOnePhaseImpl's catch); pauseImpl then
@@ -5,6 +5,18 @@ import type { ProductOrchestrator } from "./agent-instance.js";
5
5
  import type { HostRunStateAuthority } from "./run-state-host-authority.js";
6
6
  import type { LeaderPort, PhaseRunnerPort } from "./goal-loop-coordinator.js";
7
7
  import { type AcceptanceCriterion, type AcceptanceDelta, type PhaseSpec } from "./goal-run-types.js";
8
+ export type GoalVerifyCommandValidation = {
9
+ valid: true;
10
+ } | {
11
+ valid: false;
12
+ reason: string;
13
+ };
14
+ /**
15
+ * Persisted Goal verifiers are unattended acceptance contracts, not general-purpose shell scripts.
16
+ * Reject known stdin, interactive, host-specific and nondeterministic constructs before persistence;
17
+ * runVerifyDeltas repeats the check for old snapshots and defense in depth.
18
+ */
19
+ export declare function validateGoalVerifyCommand(command: string): GoalVerifyCommandValidation;
8
20
  /**
9
21
  * #2 verify 输出的头尾截断:测试/构建命令的失败摘要通常在输出**末尾**(框架的 summary 行),裸
10
22
  * slice(0,N) 保头丢尾会把真正的失败原因截掉,判官只能看到无关的开头。超限时保留头尾各半,并在
@@ -110,6 +122,10 @@ export declare function parsePhaseSpec(reply: string, availableAgentIds: string[
110
122
  */
111
123
  export declare function validateAssessDeltas(rawDeltas: AcceptanceDelta[], changedFiles: string[], log?: {
112
124
  warn(msg: string): void;
125
+ }, context?: {
126
+ criteria?: AcceptanceCriterion[];
127
+ outputTexts?: string[];
128
+ assignmentReceiptLines?: string[];
113
129
  }): AcceptanceDelta[];
114
130
  /**
115
131
  * #1②: the judge-prompt view of this phase's project changed files. The PROMPT is windowed to stay
@@ -20,6 +20,9 @@ export interface AcceptanceCriterion {
20
20
  id: string;
21
21
  criterion: string;
22
22
  status: AcceptanceStatus;
23
+ /** Output-only criteria (reply/copy/summary/etc.) are accepted from the Product task result text,
24
+ * never by inventing a shell verifier or citing an unrelated file. */
25
+ evidenceSource?: "output" | "host.product.assignment";
23
26
  evidence?: AcceptanceEvidence[];
24
27
  reason?: string;
25
28
  verify?: string;
@@ -71,7 +74,7 @@ export interface GoalQueuedMessage {
71
74
  export interface GoalRunEvent {
72
75
  seq: number;
73
76
  ts: string;
74
- type: "goal_started" | "phase_planned" | "phase_started" | "task_settled" | "phase_assessed" | "progress_compacted" | "goal_edited" | "message_queued" | "paused" | "resumed" | "stopped" | "phase_boundary" | "ended";
77
+ type: "goal_started" | "checklist_initialized" | "phase_planned" | "phase_started" | "task_settled" | "phase_assessed" | "progress_compacted" | "goal_edited" | "message_queued" | "paused" | "resumed" | "stopped" | "phase_boundary" | "round_message" | "ended";
75
78
  payload: Record<string, unknown>;
76
79
  }
77
80
  /** Derived Goal checkpoint stored by Gateway RunState, rebuildable by replaying events. */
@@ -83,6 +86,8 @@ export interface PersistedGoalRunState {
83
86
  currentGoal: string;
84
87
  goalUpdatedAt?: string;
85
88
  checklistVersion: number;
89
+ /** False only between the durable start acknowledgement and the detached leader initialization. */
90
+ checklistInitialized?: boolean;
86
91
  status: GoalRunStatus;
87
92
  pauseState: GoalPauseState;
88
93
  phaseIndex: number;