qlogicagent 2.15.10 → 2.16.2

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 (56) hide show
  1. package/dist/agent.js +24 -20
  2. package/dist/cli.js +572 -515
  3. package/dist/index.js +571 -514
  4. package/dist/orchestration.js +9 -9
  5. package/dist/protocol.js +1 -1
  6. package/dist/types/agent/tool-loop/artifact-final-contract.d.ts +21 -0
  7. package/dist/types/agent/tool-loop/tool-failure-policy.d.ts +1 -0
  8. package/dist/types/agent/tool-loop.d.ts +2 -0
  9. package/dist/types/agent/types.d.ts +7 -202
  10. package/dist/types/cli/acp-extended-handlers.d.ts +1 -0
  11. package/dist/types/cli/core-tools/agent-tool-service.d.ts +1 -0
  12. package/dist/types/cli/handlers/agents-handler.d.ts +8 -0
  13. package/dist/types/cli/handlers/product-handler.d.ts +21 -2
  14. package/dist/types/cli/handlers/workflow-handler.d.ts +5 -0
  15. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +5 -0
  16. package/dist/types/cli/turn-core.d.ts +2 -0
  17. package/dist/types/contracts/index.d.ts +1 -0
  18. package/dist/types/contracts/turn-event.d.ts +235 -0
  19. package/dist/types/orchestration/agent-instance.d.ts +45 -2
  20. package/dist/types/orchestration/agent-roster.d.ts +17 -0
  21. package/dist/types/orchestration/dag-scheduler.d.ts +27 -0
  22. package/dist/types/orchestration/product-budget.d.ts +7 -1
  23. package/dist/types/orchestration/product-persistence.d.ts +31 -0
  24. package/dist/types/orchestration/product-planner.d.ts +123 -0
  25. package/dist/types/orchestration/product-run-coordinator.d.ts +17 -1
  26. package/dist/types/orchestration/product-worktree.d.ts +3 -0
  27. package/dist/types/orchestration/skill-improvement.d.ts +2 -19
  28. package/dist/types/orchestration/solo-evaluator.d.ts +10 -0
  29. package/dist/types/orchestration/solo-spec-builder.d.ts +4 -0
  30. package/dist/types/orchestration/workflow/n8n-import.d.ts +26 -32
  31. package/dist/types/orchestration/workflow/n8n-template-compat.d.ts +5 -0
  32. package/dist/types/orchestration/workflow/node-registry.d.ts +13 -0
  33. package/dist/types/orchestration/workflow/node-schema.d.ts +10 -0
  34. package/dist/types/orchestration/workflow/qla-executor-host.d.ts +7 -1
  35. package/dist/types/protocol/methods.d.ts +8 -1
  36. package/dist/types/protocol/notifications.d.ts +1 -1
  37. package/dist/types/protocol/wire/acp-agent-management.d.ts +38 -0
  38. package/dist/types/protocol/wire/acp-protocol.d.ts +1 -0
  39. package/dist/types/protocol/wire/agent-events.d.ts +3 -3
  40. package/dist/types/protocol/wire/agent-methods.d.ts +11 -1
  41. package/dist/types/protocol/wire/index.d.ts +1 -1
  42. package/dist/types/protocol/wire/notification-payloads.d.ts +39 -0
  43. package/dist/types/runtime/infra/acp-detector.d.ts +3 -0
  44. package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +9 -0
  45. package/dist/types/runtime/ports/agent-execution-contracts.d.ts +2 -199
  46. package/dist/types/runtime/ports/tool-contracts.d.ts +6 -0
  47. package/dist/types/runtime/prompt/environment-context.d.ts +20 -1
  48. package/dist/types/skills/tools/ask-user-tool.d.ts +4 -2
  49. package/dist/types/skills/tools/shell/command-classification.d.ts +1 -0
  50. package/dist/types/skills/tools/tool-search-tool.d.ts +13 -0
  51. package/dist/types/skills/tools/tool-selection-eval.d.ts +49 -0
  52. package/dist/types/skills/tools/tool-selection-eval.dataset.d.ts +5 -0
  53. package/dist/types/skills/tools/write-tool.d.ts +2 -0
  54. package/dist/types/skills/tools.d.ts +21 -0
  55. package/dist/types/transport/acp-server.d.ts +1 -0
  56. package/package.json +2 -1
@@ -5,7 +5,6 @@
5
5
  * protocol/wire/. This file re-exports them and adds
6
6
  * internal-only extensions (e.g. backfillObservableInput on ToolDefinition).
7
7
  */
8
- import type { SkillInstruction } from "../orchestration/index.js";
9
8
  import type { HookRegistry } from "../contracts/hooks.js";
10
9
  import type { AccumulatedToolCall, LLMChunk, LLMRequest, LLMTransport } from "../runtime/ports/index.js";
11
10
  import type { ChatMessage as WireChatMessage, ChatMessageRole as WireChatMessageRole, ThinkingBlock as WireThinkingBlock, ToolCallMessage as WireToolCallMessage, ToolDefinition as WireToolDefinition, WireTokenUsage } from "../protocol/wire/index.js";
@@ -30,6 +29,7 @@ export interface ToolDefinition extends WireToolDefinition {
30
29
  * (inputTokens, outputTokens, reasoningTokens, cacheRead, cacheWrite).
31
30
  */
32
31
  export type TokenUsage = WireTokenUsage;
32
+ export type { DecisionStateRecord, GoalReconstructionState, MaintainedDocumentIndex, ReadCycleGuard, SkillCreateInstruction, SkillImproveInstruction, SkillInstruction, TurnEvent, } from "../contracts/turn-event.js";
33
33
  /**
34
34
  * Why the previous iteration continuedeach variant corresponds to one of
35
35
  * the 7 `continue` sites in the main while(true) loop.
@@ -82,6 +82,12 @@ export interface TurnRequest {
82
82
  /** Full registered tool surface before per-turn policy filtering. */
83
83
  availableTools?: ToolDefinition[];
84
84
  tools: ToolDefinition[];
85
+ /**
86
+ * Live tool-manifest rebuild, consulted each loop iteration (turnCount > 1).
87
+ * Lets a tool activated mid-turn via tool_search become callable in the SAME
88
+ * turn instead of only on the next user message.
89
+ */
90
+ refreshTools?: () => ToolDefinition[];
85
91
  systemPrompt?: string;
86
92
  config?: TurnConfig;
87
93
  }
@@ -160,207 +166,6 @@ export interface TurnConfig {
160
166
  /** MCP server configurations (stdio/sse/http). Passed from host to agent per-turn. */
161
167
  mcpServers?: Record<string, unknown>;
162
168
  }
163
- export type TurnEvent = {
164
- type: "start";
165
- turnId: string;
166
- } | {
167
- type: "delta";
168
- turnId: string;
169
- text: string;
170
- } | {
171
- type: "tool_call";
172
- turnId: string;
173
- callId: string;
174
- name: string;
175
- arguments: string;
176
- inputSummary?: string;
177
- } | {
178
- type: "end";
179
- turnId: string;
180
- content: string;
181
- usage?: TokenUsage;
182
- model?: string;
183
- provider?: string;
184
- /** Per-turn recovery trace (action -> count); present only when recoveries fired. */
185
- recoveryTrace?: Record<string, number>;
186
- } | {
187
- type: "error";
188
- turnId: string;
189
- error: string;
190
- code?: string;
191
- usage?: TokenUsage;
192
- } | {
193
- type: "skill_instruction";
194
- turnId: string;
195
- instruction: SkillInstruction;
196
- } | {
197
- type: "tool_result";
198
- turnId: string;
199
- callId: string;
200
- name: string;
201
- ok: boolean;
202
- error?: string;
203
- outputPreview?: string;
204
- durationMs?: number;
205
- exitCode?: number;
206
- stdout?: string;
207
- stderr?: string;
208
- details?: Record<string, unknown>;
209
- } | {
210
- type: "tool_blocked";
211
- turnId: string;
212
- callId: string;
213
- name: string;
214
- reason: string;
215
- } | {
216
- type: "recovery";
217
- turnId: string;
218
- action: string;
219
- detail?: string;
220
- } | {
221
- type: "plan_update";
222
- turnId: string;
223
- slug: string;
224
- content: string;
225
- } | {
226
- type: "heartbeat";
227
- turnId: string;
228
- message: string;
229
- } | {
230
- type: "tool_use_summary";
231
- turnId: string;
232
- availableToolNames: string[];
233
- enabledToolNames: string[];
234
- toolCallNames: string[];
235
- blockedToolCalls: Array<{
236
- name: string;
237
- reason: string;
238
- }>;
239
- } | {
240
- type: "lifecycle";
241
- turnId: string;
242
- kind: "stage" | "reopen" | "resume" | "context_compression" | "goal_reconstruction" | "memory_drift" | "artifact_path_drift";
243
- stage?: string;
244
- status?: string;
245
- detail?: string;
246
- reconstruction?: GoalReconstructionState;
247
- observedAt?: string;
248
- } | {
249
- type: "document_maintenance";
250
- turnId: string;
251
- checkpointId: string;
252
- documents: MaintainedDocumentIndex[];
253
- decisionStateTable: DecisionStateRecord[];
254
- readCycleFindings: Array<Record<string, unknown>>;
255
- readCycleGuard: ReadCycleGuard;
256
- observedAt?: string;
257
- } | {
258
- type: "reasoning_delta";
259
- turnId: string;
260
- text: string;
261
- } | {
262
- type: "suggestions";
263
- turnId: string;
264
- items: Array<{
265
- text: string;
266
- icon?: string;
267
- action?: string;
268
- }>;
269
- } | {
270
- type: "media_result";
271
- turnId: string;
272
- mediaType: "image" | "tts" | "video" | "music" | "3d";
273
- url: string;
274
- model?: string;
275
- provider?: string;
276
- durationSeconds?: number;
277
- width?: number;
278
- height?: number;
279
- mimeType?: string;
280
- billingUnit?: string;
281
- billingQuantity?: number;
282
- taskId?: string;
283
- } | {
284
- type: "artifact";
285
- turnId: string;
286
- artifactId: string;
287
- artifactType: "code" | "file" | "image" | "document" | "diagram" | "table";
288
- title: string;
289
- filePath?: string;
290
- language?: string;
291
- content?: string;
292
- mimeType?: string;
293
- } | {
294
- type: "artifact_contract";
295
- turnId: string;
296
- artifactRoot?: string;
297
- writePaths: string[];
298
- outOfRootWrites: Array<{
299
- path: string;
300
- artifactRoot: string;
301
- toolName: string;
302
- }>;
303
- devServerUrls: string[];
304
- browserVerified: boolean;
305
- browserEvidence: string[];
306
- requiresBrowserAcceptance: boolean;
307
- } | {
308
- type: "annotations";
309
- turnId: string;
310
- annotations: Array<{
311
- type: string;
312
- url?: string;
313
- title?: string;
314
- [key: string]: unknown;
315
- }>;
316
- } | {
317
- type: "subagent_started";
318
- turnId: string;
319
- subagentId: string;
320
- agentType: string;
321
- prompt?: string;
322
- } | {
323
- type: "subagent_ended";
324
- turnId: string;
325
- subagentId: string;
326
- agentType: string;
327
- ok: boolean;
328
- outputPreview?: string;
329
- error?: string;
330
- };
331
- export interface GoalReconstructionState {
332
- goal: string;
333
- artifactRoot: string;
334
- decisions: string[];
335
- defects: string[];
336
- acceptanceCriteria: string[];
337
- blockers: string[];
338
- nextAction: string;
339
- }
340
- export interface MaintainedDocumentIndex {
341
- name?: string;
342
- path?: string;
343
- indexed: true;
344
- maintained: true;
345
- indexVersion: string;
346
- contentHash: string;
347
- summary: string;
348
- lastReviewedTurn: number;
349
- }
350
- export interface DecisionStateRecord {
351
- id: string;
352
- decision: string;
353
- status: string;
354
- evidence: string;
355
- lastConfirmedTurn: number;
356
- }
357
- export interface ReadCycleGuard {
358
- strategy: string;
359
- nextReadPolicy: string;
360
- budgetStatus: "within-budget";
361
- maxReadsPerDocument: number;
362
- observedReadsByPath: Record<string, number>;
363
- }
364
169
  /**
365
170
  * ToolInvoker: request tool execution from the host process (Gateway).
366
171
  * In CLI mode this sends a JSON-RPC notification over stdio and waits for result.
@@ -67,4 +67,5 @@ export declare function handleAcpProductStatus(host: AcpExtendedHost, params: Re
67
67
  export declare function handleAcpProductPause(host: AcpExtendedHost, params: Record<string, unknown>): Promise<unknown>;
68
68
  export declare function handleAcpProductCancel(host: AcpExtendedHost, params: Record<string, unknown>): Promise<unknown>;
69
69
  export declare function handleAcpProductRollback(host: AcpExtendedHost, params: Record<string, unknown>): Promise<unknown>;
70
+ export declare function handleAcpProductReplay(host: AcpExtendedHost, params: Record<string, unknown>): Promise<unknown>;
70
71
  export declare function handleAcpProductSubscribe(host: AcpExtendedHost, params: Record<string, unknown>): Promise<unknown>;
@@ -10,6 +10,7 @@ export interface AgentToolServiceHost {
10
10
  readonly currentTransport: LLMTransport | null;
11
11
  readonly currentApiKey: string;
12
12
  readonly currentModel: string;
13
+ readonly currentTurnId?: string;
13
14
  sendNotification(method: string, params: Record<string, unknown>): void;
14
15
  /** Unified background execution registry. Required for background=true forks. */
15
16
  getBackgroundTasks(): BackgroundTaskManager | null;
@@ -8,6 +8,7 @@ import { type AgentRpcError, type AgentRpcRequest } from "../../protocol/wire/in
8
8
  import { AgentProcessManager } from "../../runtime/infra/agent-process.js";
9
9
  import type { AgentConfigStore } from "../../runtime/infra/agent-config-store.js";
10
10
  import { type AcpDetector } from "../../runtime/infra/acp-detector.js";
11
+ import { type PooledTurnCtx } from "../../runtime/infra/external-agent-pool.js";
11
12
  export interface AgentsHandlerHost {
12
13
  acpDetector: AcpDetector;
13
14
  soloProcessManager: AgentProcessManager | null;
@@ -19,6 +20,13 @@ export interface AgentsHandlerHost {
19
20
  sendResponse(id: string | number, result?: unknown, error?: AgentRpcError): void;
20
21
  sendNotification?(method: string, params: Record<string, unknown>): void;
21
22
  }
23
+ export declare function relayPooledTurnNotification(input: {
24
+ agentId: string;
25
+ turn: PooledTurnCtx | null;
26
+ method: string;
27
+ payload: unknown;
28
+ sendNotification?: (method: string, params: Record<string, unknown>) => void;
29
+ }): void;
22
30
  /** Resolve a pending external-agent approval with the user's decision (delivered by the gateway). */
23
31
  export declare function handleAgentsApprovalResponse(this: AgentsHandlerHost, msg: AgentRpcRequest): Promise<void>;
24
32
  export declare function handleAgentsScan(this: AgentsHandlerHost, msg: AgentRpcRequest): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Product mode handlers.
3
- * Handles: product.plan/confirm/message/create/resume/pause/checkpoint/status/list/delete/cancel/rollback.
3
+ * Handles: product.plan/confirm/message/create/resume/pause/checkpoint/status/list/delete/cancel/rollback/replay.
4
4
  */
5
5
  import { type AgentRpcError, type AgentRpcRequest } from "../../protocol/wire/index.js";
6
6
  import { type ProductCoordinatorHost } from "../product-coordinator.js";
@@ -31,7 +31,26 @@ export declare function handleProductStatus(this: ProductHandlerHost, msg: Agent
31
31
  /** `product.list` - List all products. */
32
32
  export declare function handleProductList(this: ProductHandlerHost, msg: AgentRpcRequest): Promise<void>;
33
33
  export declare function handleProductDelete(this: ProductHandlerHost, msg: AgentRpcRequest): Promise<void>;
34
- /** `product.cancel` - Cancel a running product. */
34
+ /**
35
+ * Cancel a product no matter which lifecycle phase it is in. The orchestrator only knows
36
+ * POST-confirm (executing) sessions; while the leader is still PLANNING, the product lives in
37
+ * `ProductPlanner.sessions` instead. Previously cancel only routed to `orchestrator.delete`, so
38
+ * cancelling a stalled planning leader threw "Product not found" and never killed it.
39
+ *
40
+ * Strategy (idempotent):
41
+ * 1. Try `orchestrator.delete` (post-confirm path).
42
+ * 2. If that fails because the product isn't an orchestrator session ("not found"), fall back to
43
+ * `planner.cancel` (planning-phase path — kills the leader process).
44
+ * 3. If neither side has the product, resolve ok rather than throwing (cancel is best-effort).
45
+ */
46
+ export declare function cancelProductAnyPhase(orchestrator: {
47
+ delete(productId: string): Promise<void>;
48
+ }, planner: {
49
+ cancel(productId: string): Promise<void>;
50
+ }, productId: string): Promise<void>;
51
+ /** `product.cancel` - Cancel a running product (handles both executing and planning phases). */
35
52
  export declare function handleProductCancel(this: ProductHandlerHost, msg: AgentRpcRequest): Promise<void>;
36
53
  /** `product.rollback` - Rollback a product to a checkpoint. */
37
54
  export declare function handleProductRollback(this: ProductHandlerHost, msg: AgentRpcRequest): Promise<void>;
55
+ /** `product.replay` - Re-run from an arbitrary completed/failed task forward, reusing upstream outputs. */
56
+ export declare function handleProductReplay(this: ProductHandlerHost, msg: AgentRpcRequest): Promise<void>;
@@ -39,6 +39,11 @@ export interface WorkflowCoordinatorHost {
39
39
  handleMcpToolCall(memberId: string, tool: string, args: Record<string, unknown>): Promise<unknown>;
40
40
  sendNotification(method: string, params: Record<string, unknown>): void;
41
41
  toolCatalog: ToolCatalog;
42
+ resolveClientForPurpose?: (purpose: "textGeneration") => {
43
+ transport: import("../provider-core-facade.js").LLMTransport;
44
+ apiKey: string;
45
+ model: string;
46
+ } | null;
42
47
  /** Per-root engine bundles keyed by resolved cwd; built lazily by ensureWorkflowRoot. */
43
48
  workflowRoots: Map<string, WorkflowRootBundle> | null;
44
49
  }
@@ -26,6 +26,11 @@ export interface LocalCoreToolRegistrationContext {
26
26
  listToolNames(): string[];
27
27
  findRegisteredTool(name: string): RuntimeToolContract | undefined;
28
28
  activateRegisteredTool(name: string): boolean;
29
+ listDeferredTools(): Array<{
30
+ name: string;
31
+ description: string;
32
+ searchHint?: string;
33
+ }>;
29
34
  }
30
35
  export declare function setGroupSecurityMode(enabled: boolean): void;
31
36
  export declare const localCoreToolRegistrationModule: import("../runtime/ports/tool-contracts.js").ToolRegistrationModule<LocalCoreToolRegistrationContext>;
@@ -14,6 +14,8 @@ export interface TurnCoreRequest {
14
14
  /** Full registered tool surface before per-turn policy filtering. */
15
15
  availableTools?: ToolDefinition[];
16
16
  tools: ToolDefinition[];
17
+ /** Live tool-manifest rebuild for same-turn activation (forwarded to the loop). */
18
+ refreshTools?: () => ToolDefinition[];
17
19
  systemPrompt: string;
18
20
  config: TurnConfig;
19
21
  }
@@ -2,3 +2,4 @@
2
2
  * Internal contracts — hooks.
3
3
  */
4
4
  export * from "./hooks.js";
5
+ export type { DecisionStateRecord, GoalReconstructionState, MaintainedDocumentIndex, ReadCycleGuard, SkillCreateInstruction, SkillImproveInstruction, SkillInstruction, TurnEvent, } from "./turn-event.js";
@@ -0,0 +1,235 @@
1
+ import type { WireTokenUsage } from "../protocol/wire/index.js";
2
+ export interface SkillCreateInstruction {
3
+ type: "skill.create";
4
+ /** Suggested skill name derived from tool usage pattern */
5
+ suggestedName: string;
6
+ /** Short description of what the skill does */
7
+ description: string;
8
+ /** Tool names involved */
9
+ tools: string[];
10
+ /** Number of orchestration steps */
11
+ stepCount: number;
12
+ }
13
+ export interface SkillImproveInstruction {
14
+ type: "skill.improve";
15
+ /** Existing skill to improve */
16
+ skillName: string;
17
+ /** Reason for improvement */
18
+ reason: string;
19
+ }
20
+ export type SkillInstruction = SkillCreateInstruction | SkillImproveInstruction;
21
+ export type TurnEvent = {
22
+ type: "start";
23
+ turnId: string;
24
+ } | {
25
+ type: "delta";
26
+ turnId: string;
27
+ text: string;
28
+ } | {
29
+ type: "tool_call";
30
+ turnId: string;
31
+ callId: string;
32
+ name: string;
33
+ arguments: string;
34
+ inputSummary?: string;
35
+ } | {
36
+ type: "end";
37
+ turnId: string;
38
+ content: string;
39
+ usage?: WireTokenUsage;
40
+ model?: string;
41
+ provider?: string;
42
+ /** Per-turn recovery trace (action -> count); present only when recoveries fired. */
43
+ recoveryTrace?: Record<string, number>;
44
+ } | {
45
+ type: "error";
46
+ turnId: string;
47
+ error: string;
48
+ code?: string;
49
+ usage?: WireTokenUsage;
50
+ } | {
51
+ type: "skill_instruction";
52
+ turnId: string;
53
+ instruction: SkillInstruction;
54
+ } | {
55
+ type: "tool_result";
56
+ turnId: string;
57
+ callId: string;
58
+ name: string;
59
+ ok: boolean;
60
+ error?: string;
61
+ outputPreview?: string;
62
+ durationMs?: number;
63
+ exitCode?: number;
64
+ stdout?: string;
65
+ stderr?: string;
66
+ details?: Record<string, unknown>;
67
+ } | {
68
+ type: "tool_blocked";
69
+ turnId: string;
70
+ callId: string;
71
+ name: string;
72
+ reason: string;
73
+ } | {
74
+ type: "recovery";
75
+ turnId: string;
76
+ action: string;
77
+ detail?: string;
78
+ } | {
79
+ type: "tool_selection_policy";
80
+ turnId: string;
81
+ policyId: string;
82
+ intent: "benchmark_state_maintenance" | "fresh_evidence" | "verification" | "final_answer" | "deferred_tool_discovery" | "tool_recovery" | "lifecycle_reconciliation";
83
+ reason: string;
84
+ availableToolNames: string[];
85
+ enabledToolNamesBefore: string[];
86
+ enabledToolNamesAfter: string[];
87
+ suppressedToolNames: string[];
88
+ nextAction: string;
89
+ } | {
90
+ type: "plan_update";
91
+ turnId: string;
92
+ slug: string;
93
+ content: string;
94
+ } | {
95
+ type: "heartbeat";
96
+ turnId: string;
97
+ message: string;
98
+ } | {
99
+ type: "tool_use_summary";
100
+ turnId: string;
101
+ telemetrySource?: "agent" | "agent-synthetic";
102
+ availableToolNames: string[];
103
+ enabledToolNames: string[];
104
+ toolCallNames: string[];
105
+ blockedToolCalls: Array<{
106
+ name: string;
107
+ reason: string;
108
+ }>;
109
+ } | {
110
+ type: "lifecycle";
111
+ turnId: string;
112
+ kind: "stage" | "reopen" | "resume" | "context_compression" | "goal_reconstruction" | "memory_drift" | "artifact_path_drift";
113
+ stage?: string;
114
+ status?: string;
115
+ detail?: string;
116
+ reconstruction?: GoalReconstructionState;
117
+ observedAt?: string;
118
+ } | {
119
+ type: "document_maintenance";
120
+ turnId: string;
121
+ checkpointId: string;
122
+ documents: MaintainedDocumentIndex[];
123
+ decisionStateTable: DecisionStateRecord[];
124
+ readCycleFindings: Array<Record<string, unknown>>;
125
+ readCycleGuard: ReadCycleGuard;
126
+ observedAt?: string;
127
+ } | {
128
+ type: "reasoning_delta";
129
+ turnId: string;
130
+ text: string;
131
+ } | {
132
+ type: "suggestions";
133
+ turnId: string;
134
+ items: Array<{
135
+ text: string;
136
+ icon?: string;
137
+ action?: string;
138
+ }>;
139
+ } | {
140
+ type: "media_result";
141
+ turnId: string;
142
+ mediaType: "image" | "tts" | "video" | "music" | "3d";
143
+ url: string;
144
+ model?: string;
145
+ provider?: string;
146
+ durationSeconds?: number;
147
+ width?: number;
148
+ height?: number;
149
+ mimeType?: string;
150
+ billingUnit?: string;
151
+ billingQuantity?: number;
152
+ taskId?: string;
153
+ } | {
154
+ type: "artifact";
155
+ turnId: string;
156
+ artifactId: string;
157
+ artifactType: "code" | "file" | "image" | "document" | "diagram" | "table";
158
+ title: string;
159
+ filePath?: string;
160
+ language?: string;
161
+ content?: string;
162
+ mimeType?: string;
163
+ } | {
164
+ type: "artifact_contract";
165
+ turnId: string;
166
+ artifactRoot?: string;
167
+ writePaths: string[];
168
+ outOfRootWrites: Array<{
169
+ path: string;
170
+ artifactRoot: string;
171
+ toolName: string;
172
+ }>;
173
+ devServerUrls: string[];
174
+ browserVerified: boolean;
175
+ browserEvidence: string[];
176
+ requiresBrowserAcceptance: boolean;
177
+ } | {
178
+ type: "annotations";
179
+ turnId: string;
180
+ annotations: Array<{
181
+ type: string;
182
+ url?: string;
183
+ title?: string;
184
+ [key: string]: unknown;
185
+ }>;
186
+ } | {
187
+ type: "subagent_started";
188
+ turnId: string;
189
+ subagentId: string;
190
+ agentType: string;
191
+ prompt?: string;
192
+ } | {
193
+ type: "subagent_ended";
194
+ turnId: string;
195
+ subagentId: string;
196
+ agentType: string;
197
+ ok: boolean;
198
+ outputPreview?: string;
199
+ error?: string;
200
+ };
201
+ export interface GoalReconstructionState {
202
+ goal: string;
203
+ artifactRoot: string;
204
+ decisions: string[];
205
+ defects: string[];
206
+ acceptanceCriteria: string[];
207
+ blockers: string[];
208
+ nextAction: string;
209
+ }
210
+ export interface MaintainedDocumentIndex {
211
+ name?: string;
212
+ path?: string;
213
+ indexed: true;
214
+ maintained: true;
215
+ indexVersion: string;
216
+ contentHash: string;
217
+ summary: string;
218
+ lastReviewedTurn: number;
219
+ fileSizeBytes: number;
220
+ recordCount: number;
221
+ }
222
+ export interface DecisionStateRecord {
223
+ id: string;
224
+ decision: string;
225
+ status: string;
226
+ evidence: string;
227
+ lastConfirmedTurn: number;
228
+ }
229
+ export interface ReadCycleGuard {
230
+ strategy: string;
231
+ nextReadPolicy: string;
232
+ budgetStatus: "within-budget";
233
+ maxReadsPerDocument: number;
234
+ observedReadsByPath: Record<string, number>;
235
+ }
@@ -24,7 +24,11 @@ export interface ProductCallbacks {
24
24
  warn(msg: string): void;
25
25
  };
26
26
  onTaskStarted?: (productId: string, taskId: string, assignee: string) => void;
27
- onTaskCompleted?: (productId: string, taskId: string, result: string) => void;
27
+ onTaskCompleted?: (productId: string, taskId: string, result: string, meta?: {
28
+ inputTokens: number;
29
+ outputTokens: number;
30
+ changedFiles: string[];
31
+ }) => void;
28
32
  onTaskFailed?: (productId: string, taskId: string, error: string) => void;
29
33
  onCheckpointed?: (productId: string, timestamp: string) => void;
30
34
  onBudgetWarning?: (productId: string, usedTokens: number, maxTotalTokens: number, percentage: number) => void;
@@ -42,7 +46,29 @@ export interface ProductCallbacks {
42
46
  onBudgetUpdate?: (productId: string, inputTokens: number, outputTokens: number, elapsed: number, maxTotalTokens?: number) => void;
43
47
  /** Streaming text output from a running task. */
44
48
  onTaskOutputDelta?: (productId: string, taskId: string, text: string) => void;
49
+ /** Team roster resolved at run start — fired once (engine-driven) for both initial start and resume,
50
+ * so the run view's 团队成员 panel populates live instead of only on a history reopen. */
51
+ onMembers?: (productId: string, members: {
52
+ agentId: string;
53
+ role: string;
54
+ name: string;
55
+ }[]) => void;
45
56
  }
57
+ /**
58
+ * Prepend completed upstream task outputs to a downstream task prompt so the
59
+ * worker agent can see what its predecessors produced (research→writing, etc.).
60
+ * If there are no upstream outputs the original prompt is returned unchanged.
61
+ *
62
+ * NOTE: Only used for the agent-facing sends (spawn/sendTask/recovery).
63
+ * The original prompt is kept separate for evidence heuristics
64
+ * (requiresExplicitCompletionEvidence, assertProductTaskCompletionEvidence,
65
+ * assertProductTaskMaterializedEvidence) which inspect the task instruction
66
+ * for specific markers and keywords — the context prefix must not pollute them.
67
+ */
68
+ export declare function buildTaskContextPrompt(upstream: {
69
+ taskId: string;
70
+ output: string;
71
+ }[], prompt: string): string;
46
72
  export declare class ProductOrchestrator {
47
73
  private processManager;
48
74
  private acpDetector;
@@ -66,9 +92,26 @@ export declare class ProductOrchestrator {
66
92
  /** Delete a product session, pausing first if active. */
67
93
  delete(productId: string): Promise<void>;
68
94
  /** Rollback a product to a checkpoint: delete running session then resume from disk. */
69
- rollback(productId: string, _checkpoint: string): Promise<void>;
95
+ rollback(productId: string, checkpoint?: string): Promise<void>;
96
+ /**
97
+ * Replay from an arbitrary completed/failed task (CrewAI Crew.replay(taskId) parity).
98
+ *
99
+ * Resets the task + all its transitive descendants to pending (clearing their outputs) while
100
+ * leaving ancestors completed — so the re-run automatically reuses upstream outputs via the
101
+ * existing task-context injection (getUpstreamOutputs at dispatch). Unlike rollback (which
102
+ * restores a whole-product checkpoint) or retryNode (which only accepts FAILED nodes), replay
103
+ * targets a successful-but-wrong task and re-runs forward from it in place.
104
+ */
105
+ replayTask(productId: string, taskId: string): Promise<void>;
70
106
  /** Get product status. */
71
107
  getStatus(productId: string): ProductStatus | null;
108
+ /** Live DAG progress snapshot for a product (for the planner's execution-phase leader). */
109
+ getProgressSnapshot(productId: string): {
110
+ total: number;
111
+ completed: number;
112
+ running: number;
113
+ failed: number;
114
+ } | null;
72
115
  getPersistedStatus(productId: string, cwd?: string): Promise<ProductStatus | null>;
73
116
  /** List all products (in-memory + on-disk). */
74
117
  list(cwd?: string): Promise<ProductSummary[]>;
@@ -0,0 +1,17 @@
1
+ import type { AgentRosterEntry, AgentConfigStoreData } from "../protocol/wire/acp-agent-management.js";
2
+ import { type AcpDetector } from "../runtime/infra/acp-detector.js";
3
+ /** Build the team roster the leader sees during planning: every ready agent with a coarse
4
+ * strengths hint + its backing model. Leader-only soft hints — NOT a capability contract.
5
+ *
6
+ * `allowedAgents` is PRESENCE-based (an explicit `[]` is meaningful, NOT the same as omitted):
7
+ * - `undefined` / omitted → ALL ready agents (backward compatible — WS probes, other callers, old
8
+ * sessions). The allow-set is `null` and the catalog filter applies 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
+ *
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(detector: AcpDetector, _configStore: AgentConfigStoreData | null, allowedAgents?: string[]): AgentRosterEntry[];