qlogicagent 2.20.6 → 2.20.7

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 (183) hide show
  1. package/README.md +27 -54
  2. package/dist/agent-contract.js +1 -1
  3. package/dist/agent.js +42 -41
  4. package/dist/cli.js +1 -1
  5. package/dist/host-contract.js +1 -1
  6. package/dist/index.js +539 -565
  7. package/dist/orchestration.js +14 -14
  8. package/dist/project-memory-host.js +30 -33
  9. package/dist/protocol.js +1 -1
  10. package/dist/types/agent/memory-recall-context.d.ts +7 -0
  11. package/dist/types/agent/tool-loop/artifact-final-contract.d.ts +2 -0
  12. package/dist/types/agent/tool-loop/direct-response-contract.d.ts +12 -0
  13. package/dist/types/agent/tool-loop/final-status-stream-suppressor.d.ts +22 -0
  14. package/dist/types/agent/tool-loop/loop-helpers.d.ts +2 -2
  15. package/dist/types/agent/tool-loop.d.ts +5 -1
  16. package/dist/types/agent/types.d.ts +27 -15
  17. package/dist/types/cli/acp-commands.d.ts +1 -1
  18. package/dist/types/cli/acp-extended-handlers.d.ts +13 -3
  19. package/dist/types/cli/agent-runtime-session-state.d.ts +1 -0
  20. package/dist/types/cli/base-tool-bootstrap.d.ts +0 -7
  21. package/dist/types/cli/community-skill-installer.d.ts +2 -0
  22. package/dist/types/cli/core-tool-coordinator.d.ts +0 -3
  23. package/dist/types/cli/core-tools/registry.d.ts +1 -4
  24. package/dist/types/cli/handlers/config-handler.d.ts +0 -1
  25. package/dist/types/cli/handlers/goal-handler.d.ts +24 -0
  26. package/dist/types/cli/handlers/memory-handler.d.ts +1 -2
  27. package/dist/types/cli/handlers/skill-curator-handler.d.ts +8 -0
  28. package/dist/types/cli/handlers/turn-handler.d.ts +9 -12
  29. package/dist/types/cli/memory-candidate-service.d.ts +1 -8
  30. package/dist/types/cli/memory-coordinator.d.ts +1 -13
  31. package/dist/types/cli/product-acp-params.d.ts +1 -0
  32. package/dist/types/cli/provider-core-facade.d.ts +2 -30
  33. package/dist/types/cli/rpc-registry.d.ts +2 -4
  34. package/dist/types/cli/runtime-hook-bootstrap.d.ts +1 -2
  35. package/dist/types/cli/stdio-acp-request-host.d.ts +1 -2
  36. package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +0 -2
  37. package/dist/types/cli/stdio-runtime-bootstrap.d.ts +0 -7
  38. package/dist/types/cli/stdio-runtime-services.d.ts +1 -8
  39. package/dist/types/cli/stdio-server.d.ts +0 -4
  40. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +0 -4
  41. package/dist/types/cli/tool-bootstrap.d.ts +0 -17
  42. package/dist/types/contracts/memory-recall-packet.d.ts +31 -0
  43. package/dist/types/contracts/memory-response-contract.d.ts +2 -0
  44. package/dist/types/contracts/tool-execution-evidence.d.ts +8 -0
  45. package/dist/types/contracts/tool-name.d.ts +10 -0
  46. package/dist/types/contracts/turn-event.d.ts +36 -3
  47. package/dist/types/host-contract/acp-content.d.ts +45 -0
  48. package/dist/types/host-contract/index.d.ts +59 -48
  49. package/dist/types/orchestration/agent-instance.d.ts +21 -1
  50. package/dist/types/orchestration/agent-roster.d.ts +14 -15
  51. package/dist/types/orchestration/dag-scheduler.d.ts +4 -0
  52. package/dist/types/orchestration/goal-context-envelope.d.ts +7 -0
  53. package/dist/types/orchestration/goal-loop-coordinator.d.ts +55 -12
  54. package/dist/types/orchestration/goal-mode-adapters.d.ts +13 -1
  55. package/dist/types/orchestration/goal-run-persistence.d.ts +9 -2
  56. package/dist/types/orchestration/goal-run-types.d.ts +127 -13
  57. package/dist/types/orchestration/index.d.ts +1 -1
  58. package/dist/types/orchestration/product-persistence.d.ts +10 -1
  59. package/dist/types/orchestration/product-planner.d.ts +3 -3
  60. package/dist/types/orchestration/testing/delegate-test-bridge.d.ts +1 -0
  61. package/dist/types/orchestration/workflow/data-item.d.ts +1 -1
  62. package/dist/types/orchestration/workflow/expression.d.ts +1 -2
  63. package/dist/types/orchestration/workflow/workflow-patch.d.ts +1 -2
  64. package/dist/types/orchestration/workflow/workflow-render.d.ts +1 -2
  65. package/dist/types/project-memory-host.d.ts +1 -0
  66. package/dist/types/protocol/agent-contract.d.ts +10 -8
  67. package/dist/types/protocol/methods.d.ts +2 -19
  68. package/dist/types/protocol/notifications.d.ts +1 -1
  69. package/dist/types/protocol/wire/acp-agent-management.d.ts +48 -6
  70. package/dist/types/protocol/wire/acp-protocol.d.ts +11 -24
  71. package/dist/types/protocol/wire/agent-methods.d.ts +5 -142
  72. package/dist/types/protocol/wire/chat-types.d.ts +50 -0
  73. package/dist/types/protocol/wire/index.d.ts +2 -2
  74. package/dist/types/protocol/wire/notification-payloads.d.ts +73 -122
  75. package/dist/types/protocol/wire/thread-protocol.d.ts +4 -40
  76. package/dist/types/runtime/community/community-consent-client.d.ts +0 -13
  77. package/dist/types/runtime/context/context-compression-strategies.d.ts +29 -0
  78. package/dist/types/runtime/context/context-envelope.d.ts +3 -0
  79. package/dist/types/runtime/execution/dream-agent.d.ts +4 -5
  80. package/dist/types/runtime/execution/mcp-capability-selection.d.ts +54 -0
  81. package/dist/types/runtime/execution/memory-decay.d.ts +1 -1
  82. package/dist/types/runtime/execution/search-result-quality.d.ts +22 -0
  83. package/dist/types/runtime/execution/streaming-tool-executor.d.ts +2 -0
  84. package/dist/types/runtime/execution/tool-result-storage.d.ts +44 -0
  85. package/dist/types/runtime/hooks/memory-hooks.d.ts +3 -2
  86. package/dist/types/runtime/infra/agent-paths.d.ts +0 -8
  87. package/dist/types/runtime/infra/default-path-service.d.ts +0 -2
  88. package/dist/types/runtime/infra/llmrouter-managed-inference.d.ts +54 -1
  89. package/dist/types/runtime/infra/media-persistence.d.ts +6 -36
  90. package/dist/types/runtime/memory/implicit-extraction.d.ts +7 -15
  91. package/dist/types/runtime/memory/memory-recall-attribution.d.ts +24 -0
  92. package/dist/types/runtime/ports/agent-runtime-ports.d.ts +14 -0
  93. package/dist/types/runtime/ports/index.d.ts +1 -3
  94. package/dist/types/runtime/ports/memory-provider.d.ts +2 -19
  95. package/dist/types/runtime/ports/memory-writer.d.ts +1 -1
  96. package/dist/types/runtime/ports/path-service.d.ts +0 -2
  97. package/dist/types/runtime/prompt/capability-routing-policy.d.ts +13 -0
  98. package/dist/types/runtime/prompt/environment-context.d.ts +3 -6
  99. package/dist/types/runtime/prompt/fresh-workspace-evidence.d.ts +8 -13
  100. package/dist/types/runtime/prompt/tool-necessity-policy.d.ts +12 -0
  101. package/dist/types/skills/mcp/mcp-manager.d.ts +29 -4
  102. package/dist/types/skills/memory/host-memory-provider.d.ts +3 -9
  103. package/dist/types/skills/memory/memdir.d.ts +1 -1
  104. package/dist/types/skills/memory/memory-content-safety.d.ts +1 -0
  105. package/dist/types/skills/permissions/hook-runner.d.ts +3 -3
  106. package/dist/types/skills/portable-tool.d.ts +5 -0
  107. package/dist/types/skills/skill-system/skill-lifecycle.d.ts +1 -0
  108. package/dist/types/skills/tools/exec-tool.d.ts +1 -5
  109. package/dist/types/skills/tools/shell/command-compatibility.d.ts +3 -0
  110. package/dist/types/skills/tools/shell/index.d.ts +4 -3
  111. package/dist/types/skills/tools/shell/shell-exec.d.ts +15 -8
  112. package/dist/types/skills/tools/shell/shell-provider.d.ts +26 -0
  113. package/dist/types/transport/acp-server.d.ts +4 -1
  114. package/dist/types/transport/host-community-client.d.ts +0 -1
  115. package/dist/types/transport/host-request-client.d.ts +1 -0
  116. package/dist/types/transport/host-run-state-client.d.ts +1 -1
  117. package/dist/workflow-host.js +6 -6
  118. package/package.json +4 -3
  119. package/dist/skills/mcp/astraclaw-native-mcp-server.js +0 -12
  120. package/dist/types/cli/core-tools/checkpoint-tool-bootstrap.d.ts +0 -9
  121. package/dist/types/cli/core-tools/checkpoint-tool-service.d.ts +0 -7
  122. package/dist/types/cli/core-tools/config-tool-bootstrap.d.ts +0 -7
  123. package/dist/types/cli/core-tools/config-tool-service.d.ts +0 -13
  124. package/dist/types/cli/core-tools/monitor-tool-bootstrap.d.ts +0 -7
  125. package/dist/types/cli/core-tools/monitor-tool-service.d.ts +0 -6
  126. package/dist/types/cli/dev-tool-bootstrap.d.ts +0 -9
  127. package/dist/types/cli/dev-tools/dev-tool-bootstrap-service.d.ts +0 -7
  128. package/dist/types/cli/dev-tools/dev-tool-registry.d.ts +0 -8
  129. package/dist/types/cli/dev-tools/incremental-repo-map.d.ts +0 -81
  130. package/dist/types/cli/dev-tools/lsp-supervisor.d.ts +0 -59
  131. package/dist/types/cli/dev-tools/lsp-tool-service.d.ts +0 -7
  132. package/dist/types/cli/handlers/media-handler.d.ts +0 -19
  133. package/dist/types/cli/handlers/skills-handler.d.ts +0 -37
  134. package/dist/types/cli/industrial-runtime-store.d.ts +0 -16
  135. package/dist/types/cli/media-capability-schema.d.ts +0 -49
  136. package/dist/types/cli/media-file-api-service.d.ts +0 -73
  137. package/dist/types/cli/media-file-tool-service.d.ts +0 -13
  138. package/dist/types/cli/media-inline.d.ts +0 -31
  139. package/dist/types/cli/media-runtime-facade.d.ts +0 -51
  140. package/dist/types/cli/media-understanding.d.ts +0 -102
  141. package/dist/types/cli/skill-invocation-service.d.ts +0 -10
  142. package/dist/types/cli/skill-tools-bootstrap.d.ts +0 -35
  143. package/dist/types/cli/skills-query-service.d.ts +0 -41
  144. package/dist/types/cli/tool-bootstrap-media-registration.d.ts +0 -20
  145. package/dist/types/cli/turn-media-setup.d.ts +0 -34
  146. package/dist/types/cli/turn-preview-browser-setup.d.ts +0 -15
  147. package/dist/types/runtime/infra/astraclaw-capabilities.d.ts +0 -33
  148. package/dist/types/runtime/infra/builtin-skills-seed.d.ts +0 -31
  149. package/dist/types/runtime/infra/checkpoint-backend.d.ts +0 -9
  150. package/dist/types/runtime/infra/industrial-runtime-session-server.d.ts +0 -20
  151. package/dist/types/runtime/infra/migrate-project-skills.d.ts +0 -24
  152. package/dist/types/runtime/infra/project-skill-manifest.d.ts +0 -21
  153. package/dist/types/runtime/infra/skill-resolver.d.ts +0 -74
  154. package/dist/types/runtime/infra/worktree-backend.d.ts +0 -86
  155. package/dist/types/runtime/ports/checkpoint-contracts.d.ts +0 -19
  156. package/dist/types/runtime/ports/worktree-contracts.d.ts +0 -22
  157. package/dist/types/skills/mcp/astraclaw-native-mcp-server.d.ts +0 -1
  158. package/dist/types/skills/memory/memory-tool.d.ts +0 -87
  159. package/dist/types/skills/tools/checkpoint-tool.d.ts +0 -66
  160. package/dist/types/skills/tools/config-tool.d.ts +0 -61
  161. package/dist/types/skills/tools/file-management-tool.d.ts +0 -90
  162. package/dist/types/skills/tools/image-generate-tool.d.ts +0 -98
  163. package/dist/types/skills/tools/instructions-tool.d.ts +0 -65
  164. package/dist/types/skills/tools/lsp-tool.d.ts +0 -153
  165. package/dist/types/skills/tools/media-cancel-tool.d.ts +0 -30
  166. package/dist/types/skills/tools/media-understand-tool.d.ts +0 -28
  167. package/dist/types/skills/tools/monitor-tool.d.ts +0 -113
  168. package/dist/types/skills/tools/music-generate-tool.d.ts +0 -80
  169. package/dist/types/skills/tools/notebook-edit-tool.d.ts +0 -15
  170. package/dist/types/skills/tools/preview-browser-tool.d.ts +0 -136
  171. package/dist/types/skills/tools/repo-map-tool.d.ts +0 -52
  172. package/dist/types/skills/tools/skill-tool.d.ts +0 -142
  173. package/dist/types/skills/tools/sleep-tool.d.ts +0 -49
  174. package/dist/types/skills/tools/stt-tool.d.ts +0 -33
  175. package/dist/types/skills/tools/subagent-decision-tool.d.ts +0 -15
  176. package/dist/types/skills/tools/three-d-generate-tool.d.ts +0 -46
  177. package/dist/types/skills/tools/tts-tool.d.ts +0 -50
  178. package/dist/types/skills/tools/video-edit-tool.d.ts +0 -72
  179. package/dist/types/skills/tools/video-generate-tool.d.ts +0 -162
  180. package/dist/types/skills/tools/video-merge-tool.d.ts +0 -105
  181. package/dist/types/skills/tools/video-upscale-tool.d.ts +0 -45
  182. package/dist/types/skills/tools/voice-clone-tool.d.ts +0 -40
  183. package/dist/types/skills/tools/worktree-tool.d.ts +0 -69
@@ -12,12 +12,14 @@
12
12
  * 其字段以 freeze 正文/recon 注释为据;实现 lane 负责与现状 store 形状做映射。
13
13
  */
14
14
  import { type ModelPurpose } from "@xiaozhiclaw/module-sdk/model-access";
15
+ import type { AcpContentBlock } from "./acp-content.js";
15
16
  import type { NativeTranscript } from "../host-session-collection-contract.js";
16
17
  export { MODEL_PURPOSES, type ModelPurpose } from "@xiaozhiclaw/module-sdk/model-access";
17
18
  export type { HostSessionCollectionDelta, HostSessionCollectionScope, HostSessionCollectionSnapshot, HostSessionLifecycle, HostSessionProviderDiagnostic, HostSessionSummary, HostSessionTitleSource, NativeTranscript, NativeTranscriptMessage, } from "../host-session-collection-contract.js";
18
19
  export { isHostSessionCollectionDelta, isHostSessionCollectionSnapshot, isNativeTranscript, } from "../host-session-collection-contract.js";
19
20
  export * from "./provider-profile.js";
20
21
  export * from "./memory-category.js";
22
+ export type { AcpContentBlock, AcpResourceContents } from "./acp-content.js";
21
23
  /** agent 逻辑身份(小智自身也是一个 agentId="qlogicagent")。自身 vs 第三方仅由此值决定(F2)。 */
22
24
  export type AgentId = string;
23
25
  /** 确定性派生的项目主键(freeze §11.4#2,抄 VSCode getWorkspaceId)。绝不随机、绝不裸路径。 */
@@ -97,32 +99,8 @@ export interface AgentSpec {
97
99
  /** 仅非密的运行覆盖(如 solo 自身分支 QLOGICAGENT_WORKTREE_WORKDIR/SOLO_LEAN) */
98
100
  envOverrides?: Record<string, string>;
99
101
  }
100
- /**
101
- * 回合输入内容块(多模态)。**精确镜像 `AcpContentBlock`**(acp-protocol.ts:249)——
102
- * 覆盖 text/image/video/audio/file 全五类;评审纠正:早期 text/image/resource 偏窄漏了 video/audio/file。
103
- * 随 ACP block union 演进则同步扩(单一事实源=acp-protocol.ts)。
104
- */
105
- export type ContentBlock = {
106
- type: "text";
107
- text: string;
108
- } | {
109
- type: "image";
110
- url: string;
111
- mimeType?: string;
112
- } | {
113
- type: "video";
114
- url: string;
115
- mimeType?: string;
116
- } | {
117
- type: "audio";
118
- url: string;
119
- mimeType?: string;
120
- } | {
121
- type: "file";
122
- fileId: string;
123
- mimeType?: string;
124
- size?: number;
125
- };
102
+ /** 回合输入内容块直接引用官方 ACP wire 单一事实源。 */
103
+ export type ContentBlock = AcpContentBlock;
126
104
  /**
127
105
  * 每回合上下文(2026-07-09 S3 综合补遗 A1;权威形状 = agent 侧 buildSessionMeta + turnId)。
128
106
  * 现瘦 sendTurn(prompt:string) 收不下这些(executeTurn:632 实证)→ 富签名。
@@ -152,7 +130,7 @@ export interface TurnInput {
152
130
  * - F2 自身/第三方唯一由 agentId 决定;调用点不得再各自决定进程形态。
153
131
  * - F3 结构隔离(§11.4#4):host 与 agent 引导入口物理不同、互不派生;删除运行时"拒 qlogicagent"闸。
154
132
  * - F4 判活单轨(§5.1):仅 ACK 响应性,无 agent 心跳、无方法名豁免清单;unresponsive 是状态非杀。
155
- * - F5 leader 硬约束(§11.4#6):kind∈{product-leader,goal-leader} agentId 必须 ="qlogicagent",接口层硬校验拒第三方。
133
+ * - F5 leader 约束(§11.4#6):product-leader 固定 qlogicagent;goal-leader Gateway canonical session owner。
156
134
  * - F6 判活地板 = "任意协议消息计活"(§6.3);我方 agent 可另加 ping 作补充、不作地板。
157
135
  */
158
136
  export interface AgentSupervisor {
@@ -291,7 +269,7 @@ export interface SessionProjectService {
291
269
  replayStateTo(handle: MemberHandle, sessionId: CanonicalSessionId): Promise<void>;
292
270
  }
293
271
  export interface CapabilityEndpoint {
294
- /** 唯一规范名(astraclaw_capabilities;不再双别名,C1) */
272
+ /** 唯一规范名(astraclaw;不再双别名,C1) */
295
273
  serverName: string;
296
274
  transport: "stdio" | "ipc";
297
275
  /** 网关稳定 endpoint */
@@ -560,22 +538,51 @@ export interface GatewayDelegateRelay {
560
538
  signal?: AbortSignal;
561
539
  granularity?: "full" | "coarse";
562
540
  systemPrompt?: string;
541
+ modelId?: string;
563
542
  }): Promise<TurnResult>;
564
543
  subscribe(handle: MemberHandle, sink: SupervisorEventSink, opts?: {
565
544
  granularity?: "full" | "coarse";
566
545
  }): () => void;
567
546
  }
568
547
  export type RunId = string;
569
- /** [S1 补定] 运行事件(由 relay/supervisor 生命周期喂)。 */
570
- export interface RunEvent {
571
- /** ISO 时间戳 */
548
+ /**
549
+ * Host-wide durable activity protocol.
550
+ *
551
+ * Thread is the durable conversation/session, Turn is one bounded unit of work, and Item is the
552
+ * only append-only fact carried by persistence and live delivery. Domain-specific projections
553
+ * (chat, Solo, Product, Goal, workflow) must derive from this envelope instead of defining another
554
+ * event transport.
555
+ */
556
+ export declare const THREAD_ITEM_PROTOCOL_VERSION: 1;
557
+ export type ThreadItemDomain = "chat" | "solo" | "product" | "goal" | "workflow" | "system";
558
+ export type ThreadItemType = "message" | "state" | "plan" | "task" | "checklist" | "budget" | "input_request" | "summary" | "tool_call" | "tool_result" | "artifact" | "receipt";
559
+ export type ThreadItemRole = "user" | "assistant" | "system" | "tool";
560
+ export type ThreadItemState = "pending" | "in_progress" | "completed" | "failed" | "blocked" | "cancelled";
561
+ export interface ThreadItem {
562
+ /** Stable id used for live/cold replay de-duplication. */
563
+ id: string;
564
+ /** Cross-domain rendering category. */
565
+ type: ThreadItemType;
566
+ /** Namespaced semantic discriminator, for example `goal.phase_assessed`. */
567
+ kind: string;
568
+ domain: ThreadItemDomain;
569
+ role: ThreadItemRole;
570
+ state: ThreadItemState;
571
+ /** Optional user-visible text. Structured domain data remains in data. */
572
+ text?: string;
573
+ data: Record<string, unknown>;
574
+ }
575
+ export interface ThreadItemEvent {
576
+ schemaVersion: typeof THREAD_ITEM_PROTOCOL_VERSION;
572
577
  at: string;
573
- type: string;
574
- /** Optional domain event sequence (Goal event-sourcing recovery). */
578
+ /** Assigned by the producer and checked against Host append order by projections. */
575
579
  sequence?: number;
576
- member?: MemberHandle;
577
- payload?: unknown;
580
+ threadId: string;
581
+ turnId: string;
582
+ item: ThreadItem;
578
583
  }
584
+ /** The RunState journal stores the same canonical envelope delivered live. */
585
+ export type RunEvent = ThreadItemEvent;
579
586
  /** [S1 补定] 运行状态(UI 权威读)。 */
580
587
  export interface RunState {
581
588
  runId: RunId;
@@ -658,6 +665,7 @@ export interface SupervisorEventSink {
658
665
  onToolCall(e: EvBase & {
659
666
  callId: string;
660
667
  name: string;
668
+ displayName?: string;
661
669
  arguments?: string;
662
670
  inputSummary?: string;
663
671
  startedAt?: string;
@@ -669,6 +677,7 @@ export interface SupervisorEventSink {
669
677
  onToolResult(e: EvBase & {
670
678
  callId: string;
671
679
  name: string;
680
+ displayName?: string;
672
681
  ok: boolean;
673
682
  error?: string;
674
683
  outputPreview?: string;
@@ -693,14 +702,17 @@ export interface SupervisorEventSink {
693
702
  }>;
694
703
  }): void;
695
704
  /**
696
- * media:统一 {mediaType,url,model,provider}(非 imageUrls[])。⚠R3:external agent 今天不发此事件
697
- * Provider media must arrive as a first-class lifecycle event, never only as a generic tool call.
705
+ * Provider media and Host-sent attachments arrive as first-class lifecycle events, never only as
706
+ * generic tool output or a path embedded in assistant text.
698
707
  */
699
708
  onMedia(e: EvBase & {
700
709
  mediaType: string;
701
710
  url: string;
702
711
  model?: string;
703
712
  provider?: string;
713
+ filename?: string;
714
+ mimeType?: string;
715
+ size?: number;
704
716
  }): void;
705
717
  /**
706
718
  * 通用透传(S3 综合补遗 A3):承接今天 mapSessionUpdate 的 x_relay→relay 分支
@@ -744,7 +756,7 @@ export type DelegationId = string;
744
756
  /** `x/delegate` 请求参数(agent→host,起一个 worker 回合,resolve TurnResult,隐式订阅该 delegation)。 */
745
757
  export interface DelegateRequestParams {
746
758
  delegationId: DelegationId;
747
- /** F5 leader 硬校验在 gateway 侧,不信任此处传入(T4) */
759
+ /** Product leader 硬约束由 Gateway 校验;Goal leader 身份由 canonical session owner 预先解析。 */
748
760
  to: {
749
761
  handle: MemberHandle;
750
762
  agentId: AgentId;
@@ -756,6 +768,7 @@ export interface DelegateRequestParams {
756
768
  opts?: {
757
769
  timeoutMs?: number;
758
770
  granularity?: "full" | "coarse";
771
+ modelId?: string;
759
772
  };
760
773
  }
761
774
  /** 回流事件种类(与 §4 SupervisorEventSink 方法 1:1,T10 无损镜像)。 */
@@ -828,7 +841,7 @@ export interface HostPendingMemoryExtractionTurn extends HostMemoryExtractionTur
828
841
  * [X7] qlogicagent 大脑经 x/host.request 可调用的 memory proxy 精确方法面。
829
842
  * gateway 白名单与 qla HostMemoryProvider 都必须直接消费此常量,禁止两仓手抄后漂移。
830
843
  */
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"];
844
+ export declare const HOST_MEMORY_PROXY_METHODS: readonly ["search", "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"];
832
845
  export type HostMemoryProxyMethod = (typeof HOST_MEMORY_PROXY_METHODS)[number];
833
846
  /** Host-computed proof that a distilled procedure is a repeatable capability.
834
847
  * Source executions prove how it was learned; helped use rows prove that the
@@ -1101,6 +1114,8 @@ export interface HostSkillLifecycleRecord {
1101
1114
  sourceTier?: "official" | "community";
1102
1115
  riskTier?: "R0" | "R1" | "R2" | "R3";
1103
1116
  artifactDigest?: string;
1117
+ /** Deterministic digest of the installed file tree, used to prove it was not edited locally. */
1118
+ contentTreeDigest?: string;
1104
1119
  registryResourceId?: string;
1105
1120
  registryVersion?: string;
1106
1121
  registrySourceTier?: "official" | "community";
@@ -1163,7 +1178,7 @@ export declare const HOST_SKILL_FILE_MAX_BYTES: number;
1163
1178
  /** [X7-P] 单一 agent→host 一元请求通道的服务域。 */
1164
1179
  export type HostRequestService = "memory" | "projectMemory" | "profile" | "preview" | "capability" | "session" | "feedback" | "project" | "runState" | "provider" | "community" | "cloudAuth";
1165
1180
  /** Host-owned authenticated Hub reads. The Agent never receives or refreshes the desktop session. */
1166
- export declare const HOST_COMMUNITY_PROXY_METHODS: readonly ["resolveInstall", "listResourceVersions", "resolveRuntime"];
1181
+ export declare const HOST_COMMUNITY_PROXY_METHODS: readonly ["resolveInstall", "listResourceVersions"];
1167
1182
  export type HostCommunityProxyMethod = typeof HOST_COMMUNITY_PROXY_METHODS[number];
1168
1183
  export type HostCommunityRequestParams = {
1169
1184
  service: "community";
@@ -1178,13 +1193,6 @@ export type HostCommunityRequestParams = {
1178
1193
  params: {
1179
1194
  resourceId: string;
1180
1195
  };
1181
- } | {
1182
- service: "community";
1183
- method: "resolveRuntime";
1184
- params: {
1185
- id: string;
1186
- platform: string;
1187
- };
1188
1196
  };
1189
1197
  /** Narrow account-session probe for supervised runtimes; no credential material crosses the wire. */
1190
1198
  export declare const HOST_CLOUD_AUTH_PROXY_METHODS: readonly ["probeSession"];
@@ -1505,7 +1513,7 @@ export type HostRunStateRequestParams = {
1505
1513
  method: "recordEvent";
1506
1514
  params: {
1507
1515
  runId: RunId;
1508
- event: Omit<RunEvent, "member">;
1516
+ event: RunEvent;
1509
1517
  sessionId: CanonicalSessionId;
1510
1518
  };
1511
1519
  } | {
@@ -1694,12 +1702,15 @@ export interface HostApplyCuratorPlanResult {
1694
1702
  transitioned: HostCuratorTransition[];
1695
1703
  }
1696
1704
  export type HostSkillInstallRiskTier = "R0" | "R1" | "R2" | "R3";
1705
+ export type HostSkillReplacementPolicy = "managed-unmodified" | "user-confirmed";
1697
1706
  export interface HostPrepareSkillInstallParams {
1698
1707
  name: string;
1699
1708
  version: string;
1700
1709
  checksum: string;
1701
1710
  sizeBytes: number;
1702
1711
  allowReplace: boolean;
1712
+ /** Required whenever allowReplace=true; automated callers must use managed-unmodified. */
1713
+ replacementPolicy?: HostSkillReplacementPolicy;
1703
1714
  provenance: {
1704
1715
  sourceTier: "official" | "community";
1705
1716
  resourceRiskTier: HostSkillInstallRiskTier;
@@ -19,6 +19,21 @@ import type { ProductLeaderCoordinator } from "./product-run-coordinator.js";
19
19
  import { type HostRunStateAuthority } from "./run-state-host-authority.js";
20
20
  import type { DelegateBridge } from "./delegate-bridge.js";
21
21
  export type { ProductLeaderCoordinator } from "./product-run-coordinator.js";
22
+ export interface ProductFailureAssigneeSelection {
23
+ productId: string;
24
+ taskId: string;
25
+ taskPrompt: string;
26
+ error: string;
27
+ current: {
28
+ name: string;
29
+ agentId: string;
30
+ };
31
+ candidates: Array<{
32
+ name: string;
33
+ agentId: string;
34
+ }>;
35
+ }
36
+ export type ProductFailureAssigneeSelector = (input: ProductFailureAssigneeSelection) => Promise<string | undefined>;
22
37
  export interface ProductCallbacks {
23
38
  log?: {
24
39
  info(msg: string): void;
@@ -36,6 +51,8 @@ export interface ProductCallbacks {
36
51
  attempt: number;
37
52
  terminalState: "failed" | "cancelled";
38
53
  }) => void;
54
+ /** Explicit receipt for the one automatic abnormal-worker handoff. */
55
+ onTaskHandoff?: (productId: string, taskId: string, from: string, to: string, reason: string, attempt: number) => void;
39
56
  onCheckpointed?: (productId: string, timestamp: string) => void;
40
57
  onBudgetWarning?: (productId: string, usedTokens: number, maxTotalTokens: number, percentage: number) => void;
41
58
  /** Budget hard limit hit → the run auto-paused. The 100% counterpart of onBudgetWarning (80%): the
@@ -101,6 +118,7 @@ export declare class ProductOrchestrator {
101
118
  */
102
119
  create(params: ProductCreateParams, options?: {
103
120
  authority?: HostRunStateAuthority;
121
+ failureAssigneeSelector?: ProductFailureAssigneeSelector;
104
122
  }): Promise<string>;
105
123
  /** Resume a product from persisted state. */
106
124
  resume(productId: string, opts?: {
@@ -111,6 +129,7 @@ export declare class ProductOrchestrator {
111
129
  authority?: HostRunStateAuthority;
112
130
  projectId?: string;
113
131
  cwd?: string;
132
+ failureAssigneeSelector?: ProductFailureAssigneeSelector;
114
133
  }): Promise<void>;
115
134
  /**
116
135
  * Pause a running product — the SINGLE pause path (I9).
@@ -133,7 +152,7 @@ export declare class ProductOrchestrator {
133
152
  private waitForInFlightSettle;
134
153
  /** Manual checkpoint. */
135
154
  checkpoint(productId: string): Promise<void>;
136
- applyDagMutations(productId: string, mutations: readonly DagMutation[]): Promise<void>;
155
+ applyDagMutations(productId: string, mutations: readonly DagMutation[]): Promise<import("./product-dag-mutation-applier.js").ProductDagMutationApplyResult>;
137
156
  /** Delete a product session, including a persisted execution run after process restart. */
138
157
  delete(productId: string, options?: {
139
158
  authority?: HostRunStateAuthority;
@@ -170,6 +189,7 @@ export declare class ProductOrchestrator {
170
189
  private publishUnassignedTaskFailure;
171
190
  private runTask;
172
191
  private consultLeaderAfterFailure;
192
+ private tryAutomaticAgentHandoff;
173
193
  private applyDagMutationsToSession;
174
194
  private finishProduct;
175
195
  /**
@@ -1,33 +1,32 @@
1
1
  import type { HostAgentProviderListResult } from "../host-contract/index.js";
2
2
  import type { AgentRosterEntry } from "../protocol/wire/acp-agent-management.js";
3
+ interface AgentRosterOptions {
4
+ injectLeader?: boolean;
5
+ leaderAgentId: string;
6
+ }
3
7
  /** Build the team roster the leader sees during planning: every ready agent with a coarse
4
8
  * strengths hint + its backing model. Leader-only soft hints — NOT a capability contract.
5
9
  *
6
10
  * `allowedAgents` is PRESENCE-based (an explicit `[]` is meaningful, NOT the same as omitted):
7
11
  * - `undefined` / omitted → ALL ready agents. The allow-set is `null` and the catalog filter applies
8
12
  * no constraint.
9
- * - `[]` (explicit empty array) → ONLY the leader 小智 (qlogicagent): the allow-set is an empty Set, so
10
- * the catalog filter drops every non-leader entry; the leader is force-included below roster = just
11
- * 小智. This is the user deliberately deselecting every worker.
12
- * - `[ids]` → those ready ids PLUS the leader 小智 (always included). A picked-but-unready id is dropped.
13
+ * - `[]` (explicit empty array) → ONLY the selected session leader: the allow-set is empty, so the
14
+ * catalog filter drops every non-leader entry. This is the user deliberately deselecting workers.
15
+ * - `[ids]` those ready ids PLUS the selected leader. A picked-but-unready id is dropped.
13
16
  *
14
- * The leader `qlogicagent` (小智) is ALWAYS present (universal coordinator / fallback executor) appended
15
- * if not already in the roster, so the leader always has ≥1 valid assignee even when the user's picks turn
16
- * out unready (or when the pool is empty). */
17
- export declare function buildAgentRoster(snapshot: Readonly<HostAgentProviderListResult>, allowedAgents?: string[], options?: {
18
- injectLeader?: boolean;
19
- }): AgentRosterEntry[];
17
+ * The caller supplies the authoritative leader id from the session binding. There is no implicit
18
+ * leader: Product callers pass their Product leader; Goal callers pass the session owner. */
19
+ export declare function buildAgentRoster(snapshot: Readonly<HostAgentProviderListResult>, allowedAgents: string[] | undefined, options: AgentRosterOptions): AgentRosterEntry[];
20
20
  /**
21
21
  * User-PICKED worker ids that did NOT make it into the roster (unready: not installed / not logged in
22
22
  * / not in the catalog). Excludes the leader (always force-included). Empty when nothing was dropped
23
23
  * or when the pool was omitted. Callers surface this so a picked worker doesn't vanish silently and
24
- * collapse the team to just 小智 (honesty over silence — goal used to degrade with no notice).
24
+ * collapse the team to just its leader (honesty over silence).
25
25
  */
26
- export declare function computeUnavailablePicks(allowedAgents: string[] | undefined, rosterIds: readonly string[]): string[];
26
+ export declare function computeUnavailablePicks(allowedAgents: string[] | undefined, rosterIds: readonly string[], leaderAgentId: string): string[];
27
27
  /** buildAgentRoster + the diagnostics of which picked workers were dropped as unavailable. */
28
- export declare function buildAgentRosterWithDiagnostics(snapshot: Readonly<HostAgentProviderListResult>, allowedAgents?: string[], options?: {
29
- injectLeader?: boolean;
30
- }): {
28
+ export declare function buildAgentRosterWithDiagnostics(snapshot: Readonly<HostAgentProviderListResult>, allowedAgents: string[] | undefined, options: AgentRosterOptions): {
31
29
  roster: AgentRosterEntry[];
32
30
  unavailablePicks: string[];
33
31
  };
32
+ export {};
@@ -122,6 +122,10 @@ export declare class DagScheduler {
122
122
  * Removes all edges incident to this node.
123
123
  */
124
124
  removeNode(id: string): void;
125
+ /** Add one dependency edge atomically. Only work that has not started may gain prerequisites. */
126
+ addDependency(from: string, to: string): void;
127
+ /** Remove one dependency edge. Completed/running work remains immutable. */
128
+ removeDependency(from: string, to: string): void;
125
129
  /**
126
130
  * Reset a failed node to pending. Optionally patches params (e.g. revised prompt).
127
131
  */
@@ -0,0 +1,7 @@
1
+ import type { ContextEnvelope } from "../protocol/wire/chat-types.js";
2
+ import type { PersistedGoalRunState, PhaseSpec } from "./goal-run-types.js";
3
+ /**
4
+ * Project the Host-owned Goal checkpoint into bounded Agent-local compaction facts.
5
+ * The envelope is regenerated for every leader/worker turn; it never becomes a second Goal owner.
6
+ */
7
+ export declare function buildGoalContextEnvelope(state: PersistedGoalRunState, operation: string, spec?: PhaseSpec): ContextEnvelope;
@@ -1,12 +1,24 @@
1
1
  import { type HostRunStateAuthority } from "./run-state-host-authority.js";
2
- import { type AcceptanceChecklist, type AcceptanceCriterion, type AcceptanceDelta, type GoalQueuedMessage, type PersistedGoalRunState, type PhaseSpec } from "./goal-run-types.js";
2
+ import type { ContextEnvelope } from "../protocol/wire/chat-types.js";
3
+ import type { ProductFailureAssigneeSelection } from "./agent-instance.js";
4
+ import { type AcceptanceChecklist, type AcceptanceDelta, type GoalInstructionKind, type GoalMilestone, type GoalQueuedMessage, type GoalTaskProjection, type GoalSpec, type GoalTurnContext, type PersistedGoalRunState, type PhaseSpec } from "./goal-run-types.js";
3
5
  export interface LeaderPort {
4
- deriveChecklist(goal: string): Promise<AcceptanceCriterion[]>;
5
- planPhase(goal: string, summary: string, drained: GoalQueuedMessage[], checklist: AcceptanceChecklist, agentPool: string[]): Promise<PhaseSpec>;
6
- critiquePlan(spec: PhaseSpec, goal: string, checklist: AcceptanceChecklist, agentPool: string[]): Promise<PhaseSpec>;
7
- assess(productId: string, checklist: AcceptanceChecklist): Promise<{
6
+ /** Reapply the durable user turn policy before any leader call, including crash recovery. */
7
+ setTurnContext?(context: GoalTurnContext | undefined): void;
8
+ /** Re-ground the native leader's own compaction state in canonical Host Goal facts. */
9
+ setContextEnvelope?(context: ContextEnvelope | undefined): void;
10
+ selectHandoffCandidate(input: ProductFailureAssigneeSelection): Promise<string | undefined>;
11
+ draftGoalSpec(goal: string, revisionFeedback: GoalQueuedMessage[], revision: number): Promise<GoalSpec>;
12
+ planPhase(goalSpec: GoalSpec, summary: string, drained: GoalQueuedMessage[], checklist: AcceptanceChecklist, agentPool: string[]): Promise<PhaseSpec>;
13
+ critiquePlan(spec: PhaseSpec, goalSpec: GoalSpec, checklist: AcceptanceChecklist, agentPool: string[]): Promise<PhaseSpec>;
14
+ assess(productId: string, goalSpec: GoalSpec, checklist: AcceptanceChecklist, milestones?: GoalMilestone[], agentPool?: string[]): Promise<{
8
15
  deltas: AcceptanceDelta[];
9
16
  producedFiles: boolean;
17
+ tasks?: GoalTaskProjection[];
18
+ usage?: {
19
+ inputTokens: number;
20
+ outputTokens: number;
21
+ };
10
22
  }>;
11
23
  compact(prevSummary: string, deltas: AcceptanceDelta[]): Promise<string>;
12
24
  }
@@ -14,6 +26,12 @@ export interface PhaseRunnerPort {
14
26
  startBoundedProductPhase(spec: PhaseSpec, agentPool: string[], cwd: string, opts: {
15
27
  signal: AbortSignal;
16
28
  onProductId: (productId: string) => void;
29
+ budget?: {
30
+ maxTotalTokens?: number;
31
+ maxDuration?: number;
32
+ };
33
+ turnContext?: GoalTurnContext;
34
+ contextEnvelope?: ContextEnvelope;
17
35
  }): Promise<{
18
36
  productId: string;
19
37
  result: string;
@@ -25,6 +43,8 @@ export interface PhaseRunnerPort {
25
43
  }): Promise<{
26
44
  result: string;
27
45
  }>;
46
+ /** Interrupt a persisted in-flight Product when the control RPC cannot see the original AbortController. */
47
+ pausePhase?(productId: string): Promise<void>;
28
48
  }
29
49
  export type GoalNotifier = (method: string, payload: Record<string, unknown>) => void;
30
50
  export interface GoalLoopCoordinatorDeps {
@@ -33,6 +53,7 @@ export interface GoalLoopCoordinatorDeps {
33
53
  cwd: string;
34
54
  projectId: string;
35
55
  canonicalSessionId: string;
56
+ leaderAgentId: string;
36
57
  runStateAuthority?: HostRunStateAuthority;
37
58
  notify?: GoalNotifier;
38
59
  log?: {
@@ -50,14 +71,25 @@ export declare class GoalLoopCoordinator {
50
71
  private notify;
51
72
  private append;
52
73
  private persist;
74
+ private transitionStage;
53
75
  /** Durably reserve a goal-run without entering the leader lane. Returns the goalRunId immediately. */
54
- start(goal: string, agentPool: string[]): Promise<string>;
76
+ start(goal: string, agentPool: string[], budget?: {
77
+ maxTotalTokens?: number;
78
+ maxDurationMs?: number;
79
+ }, turnContext?: GoalTurnContext): Promise<string>;
55
80
  private startImpl;
81
+ private goalSpecConfirmationMessage;
82
+ private ensureGoalSpecImpl;
56
83
  private ensureChecklistInitializedImpl;
84
+ private hydrate;
57
85
  /** Load the run; seed `seq` so a fresh instance (post-crash) keeps appending monotonically. */
58
86
  private load;
59
- enqueueMessage(goalRunId: string, text: string): Promise<void>;
87
+ enqueueMessage(goalRunId: string, text: string, kind?: GoalInstructionKind): Promise<void>;
60
88
  private enqueueMessageImpl;
89
+ /** Resolve a structured blocker and resume in one serialized mutation. A UI or IM client must not
90
+ * coordinate message + resume as two RPCs because a transport failure between them duplicates the
91
+ * answer or leaves the blocker visible after execution has continued. */
92
+ answerBlocker(goalRunId: string, text: string): Promise<PersistedGoalRunState>;
61
93
  /** Run exactly one phase. Returns the updated state. */
62
94
  runOnePhase(goalRunId: string): Promise<PersistedGoalRunState>;
63
95
  private runOnePhaseImpl;
@@ -66,15 +98,18 @@ export declare class GoalLoopCoordinator {
66
98
  * in-flight breadcrumb, then run the terminal checks. Called by BOTH the normal path and crash-recovery
67
99
  * so neither duplicates this logic. Assess throwing propagates to the caller's failure handling. */
68
100
  private finishPhase;
101
+ private planPhaseWithRetry;
102
+ private recordPhasePlan;
103
+ private block;
69
104
  /** B (crash-resume): re-attach to a Product that started before a crash. Restore its Host RunState
70
105
  * checkpoint and re-drive it to terminal (runner.resumePhase), then run the SAME phase tail
71
106
  * (finishPhase). Honest-fail ONLY if resume itself throws — a started phase is recovered, never lost,
72
107
  * but progress is never fabricated. Bounded by an abort handle so pause() can still drain it. */
73
108
  private recoverCrashedPhase;
74
109
  /** #4: classify how an in-flight phase's throw should land. A user pause aborts the signal (whatever
75
- * error then surfaces → "user_pause"); the adapter's GOAL_DRAIN_TIMEOUT_MS wall throws an AbortError
76
- * WITHOUT the signal being aborted, tagged pauseReason="drain_timeout" (untagged AbortErrors from
77
- * simpler runner ports default to drain_timeout — the only engine-side AbortError source). Anything
110
+ * error then surfaces → "user_pause"); the adapter's phase wall throws an AbortError
111
+ * WITHOUT the signal being aborted, tagged pauseReason="phase_timeout" (untagged AbortErrors from
112
+ * simpler runner ports default to phase_timeout — the only engine-side AbortError source). Anything
78
113
  * else is a real failure → undefined (the caller honest-FAILs). */
79
114
  private pauseReasonOf;
80
115
  /** I3: true when the loaded state shows a phase that started (currentProductId set) but never reached
@@ -95,14 +130,22 @@ export declare class GoalLoopCoordinator {
95
130
  * no-ops on the already-paused state. */
96
131
  pause(goalRunId: string): Promise<PersistedGoalRunState>;
97
132
  private pauseImpl;
98
- /** Edit the goal (valid only while paused) derives a new immutable checklist version. */
133
+ /** Edit the goal while paused and invalidate the prior Spec; execution requires fresh confirmation. */
99
134
  updateGoal(goalRunId: string, newGoal: string): Promise<PersistedGoalRunState>;
100
135
  private updateGoalImpl;
101
136
  /** Resume a paused run; an optional newGoal applies a goal-edit first (reusing updateGoalImpl). */
102
- resume(goalRunId: string, newGoal?: string): Promise<PersistedGoalRunState>;
137
+ resume(goalRunId: string, newGoal?: string, additionalBudget?: {
138
+ maxTotalTokens?: number;
139
+ maxDurationMs?: number;
140
+ }): Promise<PersistedGoalRunState>;
103
141
  private resumeImpl;
104
142
  /** User stop — ends the run as stopped. The caller stops driving the detached loop. */
105
143
  stop(goalRunId: string): Promise<PersistedGoalRunState>;
106
144
  private stopImpl;
107
145
  private end;
146
+ private finishTerminal;
147
+ /** Re-attach a fresh Agent process to a durable active run without changing a user pause. */
148
+ recover(goalRunId: string): Promise<PersistedGoalRunState>;
149
+ /** Clear a terminal Goal from the thread-native current-goal projection without deleting its audit log. */
150
+ dismiss(goalRunId: string): Promise<PersistedGoalRunState>;
108
151
  }
@@ -1,7 +1,7 @@
1
1
  import type { HostAgentProviderDirectory } from "../runtime/infra/host-agent-provider-directory.js";
2
2
  import type { DelegateBridge } from "./delegate-bridge.js";
3
3
  import { type PlannerMemoryContext } from "./planner-memory-brief.js";
4
- import type { ProductOrchestrator } from "./agent-instance.js";
4
+ import type { ProductFailureAssigneeSelector, 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";
@@ -17,6 +17,7 @@ export type GoalVerifyCommandValidation = {
17
17
  * runVerifyDeltas repeats the check for old snapshots and defense in depth.
18
18
  */
19
19
  export declare function validateGoalVerifyCommand(command: string): GoalVerifyCommandValidation;
20
+ export declare function validateGoalVerifyCommandInWorkspace(command: string, cwd: string): GoalVerifyCommandValidation;
20
21
  /**
21
22
  * #2 verify 输出的头尾截断:测试/构建命令的失败摘要通常在输出**末尾**(框架的 summary 行),裸
22
23
  * slice(0,N) 保头丢尾会把真正的失败原因截掉,判官只能看到无关的开头。超限时保留头尾各半,并在
@@ -89,6 +90,7 @@ export interface PhaseRunnerAdapterDeps {
89
90
  orchestrator: ProductOrchestrator;
90
91
  projectId: string;
91
92
  runStateAuthority: HostRunStateAuthority;
93
+ failureAssigneeSelector: ProductFailureAssigneeSelector;
92
94
  /** Optional per-phase budget passed through to ProductOrchestrator.create. */
93
95
  budget?: {
94
96
  maxTotalTokens?: number;
@@ -126,6 +128,14 @@ export declare function validateAssessDeltas(rawDeltas: AcceptanceDelta[], chang
126
128
  criteria?: AcceptanceCriterion[];
127
129
  outputTexts?: string[];
128
130
  assignmentReceiptLines?: string[];
131
+ requiredAssignmentAgentIds?: string[];
132
+ }): AcceptanceDelta[];
133
+ /**
134
+ * A Host assignment criterion accepts the Goal's selected worker pool, not merely one authentic
135
+ * receipt. Re-check coverage every phase so a prematurely persisted pass regresses after recovery.
136
+ */
137
+ export declare function runAssignmentEvidenceCoverageDeltas(criteria: AcceptanceCriterion[], assignmentReceiptLines: string[], requiredAgentIds: string[], log?: {
138
+ warn(msg: string): void;
129
139
  }): AcceptanceDelta[];
130
140
  /**
131
141
  * #1②: the judge-prompt view of this phase's project changed files. The PROMPT is windowed to stay
@@ -138,3 +148,5 @@ export declare function buildProjectFilesBlock(allFiles: string[], window?: numb
138
148
  /** Build the evidence block for the judge from a live Product status (task outputs + changed files).
139
149
  * Exported for the #3 regression test: the >ASSESS_MAX_TASKS window note must never silently vanish. */
140
150
  export declare function buildEvidenceBlock(status: ReturnType<ProductOrchestrator["getStatus"]>): string;
151
+ export declare const ASSESS_ASSIGNMENT_HISTORY_WINDOW = 60;
152
+ export declare function buildGoalAssignmentHistoryBlock(allLines: string[], window?: number): string;
@@ -1,14 +1,21 @@
1
1
  import type { GoalRunEvent, PersistedGoalRunState } from "./goal-run-types.js";
2
2
  import type { HostRunStateAuthority } from "./run-state-host-authority.js";
3
+ import { type ThreadItemEvent } from "../host-contract/index.js";
3
4
  export interface GoalPersistenceContext {
4
5
  projectId: string;
5
6
  canonicalSessionId: string;
6
7
  authority: HostRunStateAuthority;
7
8
  }
8
- /** Append one event to the Gateway-owned durable RunState event log. */
9
- export declare function appendGoalRunEvent(goalRunId: string, event: GoalRunEvent, context: GoalPersistenceContext): Promise<void>;
9
+ /** Build the sole live-and-durable representation of a Goal fact. */
10
+ export declare function toGoalThreadItemEvent(goalRunId: string, event: GoalRunEvent, context: GoalPersistenceContext): ThreadItemEvent;
11
+ /** Append one canonical item to the Gateway-owned durable RunState event log. */
12
+ export declare function appendGoalRunEvent(goalRunId: string, event: GoalRunEvent, context: GoalPersistenceContext): Promise<ThreadItemEvent>;
10
13
  export declare function readGoalRunEvents(goalRunId: string, context: GoalPersistenceContext): Promise<GoalRunEvent[]>;
11
14
  export declare function saveGoalRunSnapshot(state: PersistedGoalRunState, context: GoalPersistenceContext): Promise<void>;
12
15
  export declare function loadGoalRunSnapshot(goalRunId: string, context: GoalPersistenceContext): Promise<PersistedGoalRunState | undefined>;
16
+ /** Apply events newer than the checkpoint cursor. This closes the append→checkpoint crash window
17
+ * without introducing a second journal or compatibility reader: Host events.jsonl remains the single
18
+ * durable fact stream, and the checkpoint remains its replaceable projection. */
19
+ export declare function replayGoalRunEvents(state: PersistedGoalRunState, events: GoalRunEvent[]): PersistedGoalRunState;
13
20
  /** Replay the Host event log into a snapshot. Returns undefined before goal_started. */
14
21
  export declare function rebuildSnapshotFromEvents(goalRunId: string, context: GoalPersistenceContext): Promise<PersistedGoalRunState | undefined>;