qlogicagent 2.12.3 → 2.12.5

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 (44) hide show
  1. package/dist/agent.js +6 -6
  2. package/dist/cli.js +344 -316
  3. package/dist/index.js +344 -316
  4. package/dist/orchestration.js +1 -1
  5. package/dist/protocol.js +1 -1
  6. package/dist/types/cli/acp-extended-handlers.d.ts +0 -1
  7. package/dist/types/cli/agent-runtime-bootstrap.d.ts +2 -0
  8. package/dist/types/cli/conversation-context.d.ts +30 -0
  9. package/dist/types/cli/core-tool-coordinator.d.ts +6 -1
  10. package/dist/types/cli/core-tools/agent-tool-service.d.ts +12 -0
  11. package/dist/types/cli/core-tools/registry.d.ts +1 -1
  12. package/dist/types/cli/core-tools/team-registry.d.ts +62 -0
  13. package/dist/types/cli/core-tools/team-tool-bootstrap.d.ts +3 -1
  14. package/dist/types/cli/core-tools/team-tool-service.d.ts +12 -1
  15. package/dist/types/cli/core-tools/utility-tool-bootstrap.d.ts +3 -1
  16. package/dist/types/cli/dream-host-adapter.d.ts +1 -0
  17. package/dist/types/cli/handlers/config-handler.d.ts +2 -0
  18. package/dist/types/cli/handlers/dream-handler.d.ts +2 -0
  19. package/dist/types/cli/runtime-hook-bootstrap.d.ts +2 -0
  20. package/dist/types/cli/session-coordinator.d.ts +7 -6
  21. package/dist/types/cli/session-history-coordinator.d.ts +2 -0
  22. package/dist/types/cli/stdio-agent-session-bootstrap.d.ts +2 -0
  23. package/dist/types/cli/stdio-server.d.ts +10 -0
  24. package/dist/types/cli/tool-bootstrap.d.ts +7 -12
  25. package/dist/types/contracts/fire-hook.d.ts +14 -0
  26. package/dist/types/protocol/wire/acp-protocol.d.ts +0 -1
  27. package/dist/types/runtime/execution/dream-agent.d.ts +30 -5
  28. package/dist/types/runtime/execution/fork-context.d.ts +14 -0
  29. package/dist/types/runtime/infra/background-tasks.d.ts +89 -0
  30. package/dist/types/runtime/infra/task-runtime.d.ts +1 -38
  31. package/dist/types/runtime/tasks/task-types.d.ts +22 -8
  32. package/dist/types/skills/memory/local-memory-provider.d.ts +15 -0
  33. package/dist/types/skills/memory/local-store.d.ts +11 -0
  34. package/dist/types/skills/memory/memory-consolidation.d.ts +7 -0
  35. package/dist/types/skills/tools/agent-tool.d.ts +21 -10
  36. package/dist/types/skills/tools/exec-tool.d.ts +13 -0
  37. package/dist/types/skills/tools/monitor-tool.d.ts +3 -3
  38. package/dist/types/skills/tools/send-message-tool.d.ts +6 -0
  39. package/dist/types/skills/tools/shell/index.d.ts +1 -1
  40. package/dist/types/skills/tools/shell/task-output.d.ts +0 -1
  41. package/dist/types/skills/tools/task-tool.d.ts +37 -5
  42. package/dist/types/skills/tools/team-tool.d.ts +5 -0
  43. package/dist/types/transport/acp-server.d.ts +0 -1
  44. package/package.json +1 -1
@@ -13,6 +13,7 @@
13
13
  import type { DreamTaskState, DreamTurn } from "../tasks/task-types.js";
14
14
  import type { ToolDefinition, ToolInvoker, AgentLogger, HookRegistry, ForkedAgentRunnerFactory } from "../ports/agent-execution-contracts.js";
15
15
  import type { LLMTransport } from "../ports/index.js";
16
+ import type { TaskStore } from "../infra/task-runtime.js";
16
17
  export interface DreamTriggerConfig {
17
18
  /** Minimum hours since last consolidation. Default: 24. */
18
19
  minHours: number;
@@ -99,17 +100,32 @@ export declare function shouldTriggerDream(ctx: DreamContext, config?: Partial<D
99
100
  sessionIds: string[];
100
101
  } | null>;
101
102
  /**
102
- * Attempt to acquire the consolidation lock.
103
+ * Attempt to acquire the consolidation liveness lock.
103
104
  *
104
- * @returns Prior mtime (for rollback) or null if blocked.
105
+ * A held lock is "live" only if its mtime is fresh (< MAX_DREAM_RUN_MS) AND the
106
+ * recorded PID is alive. A stale mtime reclaims unconditionally — this defends
107
+ * against a crashed holder whose PID was reused by an unrelated process (the old
108
+ * pure-PID check would falsely see it as alive and deadlock for up to an hour).
109
+ *
110
+ * @returns 0 on acquisition, or null if blocked by a live holder.
105
111
  */
106
112
  export declare function tryAcquireConsolidationLock(memoryRoot: string): Promise<number | null>;
107
113
  /**
108
- * Rollback the lock mtime after a failed dream run.
114
+ * Refresh the lock mtime so a long-but-legitimate dream is not reclaimed.
115
+ * Called periodically by the dream runner. No-op if we no longer own the lock.
116
+ */
117
+ export declare function heartbeatConsolidationLock(memoryRoot: string): Promise<void>;
118
+ /** Release the liveness lock explicitly (on failure, abort, or shutdown). */
119
+ export declare function releaseConsolidationLock(memoryRoot: string): Promise<void>;
120
+ /**
121
+ * Rollback after a FAILED dream run: release the lock. The gate marker is NOT
122
+ * touched (only success advances it), so a failed run never delays the next gate.
123
+ * `_priorMtime` is retained for call-site compatibility and ignored.
109
124
  */
110
- export declare function rollbackConsolidationLock(memoryRoot: string, priorMtime: number): Promise<void>;
125
+ export declare function rollbackConsolidationLock(memoryRoot: string, _priorMtime: number): Promise<void>;
111
126
  /**
112
- * Update the lock file to record successful consolidation (mtime = now).
127
+ * Record a SUCCESSFUL consolidation: advance the gate marker (mtime = now) and
128
+ * release the liveness lock.
113
129
  */
114
130
  export declare function markConsolidationComplete(memoryRoot: string): Promise<void>;
115
131
  /** Create initial DreamTaskState. */
@@ -158,6 +174,8 @@ export interface DreamRunDeps {
158
174
  createAgentRunner: ForkedAgentRunnerFactory;
159
175
  /** Available tools (will be filtered by canUseDreamTool) */
160
176
  tools: ToolDefinition[];
177
+ /** Task store — when provided, the dream registers as a `dream` task (lifecycle visible to host + LLM). */
178
+ taskStore?: TaskStore;
161
179
  /** API key */
162
180
  apiKey: string;
163
181
  /** Model for dream */
@@ -213,6 +231,13 @@ export interface DreamRunDeps {
213
231
  getProfile?(userId: string, key: string): string | null;
214
232
  setProfile?(userId: string, key: string, value: string): void;
215
233
  getAllProfiles?(userId: string): Record<string, string>;
234
+ /** Drain consolidation backlog: resolve conflicts + promote corroborated pending claims. */
235
+ resolveConflicts?(userId: string, opts?: {
236
+ minEvidenceToPromote?: number;
237
+ }): Promise<{
238
+ conflictsResolved: number;
239
+ claimsPromoted: number;
240
+ }>;
216
241
  };
217
242
  /** User ID for memory operations. */
218
243
  memoryUserId?: string;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Fork execution context — AsyncLocalStorage-based depth tracking.
3
+ *
4
+ * runForkedAgent() enters a child context at depth = parent + 1. Any tool
5
+ * executed inside that fork (including a nested `agent` tool call) reads the
6
+ * live depth via getCurrentForkDepth(), so the MAX_FORK_DEPTH guard operates
7
+ * on real values instead of a hardcoded 0.
8
+ *
9
+ * Top-level (no fork active) → depth 0.
10
+ */
11
+ /** Current fork depth: 0 at top level, N inside an N-deep forked agent. */
12
+ export declare function getCurrentForkDepth(): number;
13
+ /** Run fn inside a fork context at the given depth. */
14
+ export declare function runAtForkDepth<T>(depth: number, fn: () => T): T;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * BackgroundTaskManager — the single registry for all background execution.
3
+ *
4
+ * Every background unit of work (forked agent, backgrounded shell command,
5
+ * dream consolidation) registers here so that:
6
+ * 1. The TaskStore holds its lifecycle state (task.updated notifications fire)
7
+ * 2. The LLM can query status/output via the task tool ("output" action)
8
+ * 3. Completion is queued as a <task_notification> for the next turn
9
+ * 4. Cancellation actually kills the underlying process / aborts the agent
10
+ *
11
+ * This is the ONLY producer surface for TaskStore background tasks.
12
+ * Do not register tasks into the store directly from feature code.
13
+ */
14
+ import type { LocalAgentTaskState, LocalBashTaskState, TaskState } from "../tasks/task-types.js";
15
+ import { type TaskStore } from "./task-runtime.js";
16
+ /** Result contract for a background agent runner. */
17
+ export interface AgentRunOutcome {
18
+ ok: boolean;
19
+ output?: string;
20
+ error?: string;
21
+ }
22
+ /** Structural handle for a backgrounded shell process (avoids skills-layer import). */
23
+ export interface BashTaskHandle {
24
+ kill(): void;
25
+ result: Promise<{
26
+ code: number;
27
+ stdout: string;
28
+ stderr: string;
29
+ }>;
30
+ taskOutput: {
31
+ taskId: string;
32
+ path: string;
33
+ };
34
+ }
35
+ export interface StartAgentTaskOptions {
36
+ agentName: string;
37
+ label: string;
38
+ depth: number;
39
+ maxTurns: number;
40
+ parentTaskId?: string;
41
+ /** The actual work. Receives the task's own abort signal and task id. */
42
+ run(signal: AbortSignal, taskId: string): Promise<AgentRunOutcome>;
43
+ }
44
+ export interface RegisterBashTaskOptions {
45
+ command: string;
46
+ cwd: string;
47
+ label?: string;
48
+ pid?: number;
49
+ handle: BashTaskHandle;
50
+ }
51
+ export interface TaskOutputSnapshot {
52
+ task: TaskState;
53
+ /** Current output: final result for terminal tasks, live tail for running bash tasks. */
54
+ output: string;
55
+ running: boolean;
56
+ }
57
+ export declare class BackgroundTaskManager {
58
+ private readonly store;
59
+ private readonly controllers;
60
+ private readonly bashHandles;
61
+ private readonly settledListeners;
62
+ constructor(store: TaskStore);
63
+ /** Subscribe to natural task settlement (completed/failed). Returns unregister fn. */
64
+ onTaskSettled(listener: (task: TaskState) => void): () => void;
65
+ private fireSettled;
66
+ /**
67
+ * Start a background forked agent. Registers a local_agent task,
68
+ * floats the runner, and settles the task when the runner finishes.
69
+ */
70
+ startAgentTask(opts: StartAgentTaskOptions): LocalAgentTaskState;
71
+ /**
72
+ * Register an already-backgrounded shell command. The handle's result
73
+ * promise settles the task; live output is readable from outputPath.
74
+ */
75
+ registerBashTask(opts: RegisterBashTaskOptions): LocalBashTaskState;
76
+ private settle;
77
+ getTask(taskId: string): TaskState | undefined;
78
+ listTasks(): TaskState[];
79
+ /**
80
+ * Read a task's output. For running bash tasks this reads the live
81
+ * output file; for everything else it returns the stored final output.
82
+ */
83
+ readOutput(taskId: string): Promise<TaskOutputSnapshot | null>;
84
+ /**
85
+ * Cancel a running task: kills the shell process / aborts the agent,
86
+ * then marks the task cancelled. Returns false if not found or already terminal.
87
+ */
88
+ cancelTask(taskId: string): boolean;
89
+ }
@@ -9,12 +9,8 @@
9
9
  * Architecture note: CC uses React-style setAppState(prev => next). We use
10
10
  * a simple Map-based store since we're in a subprocess (no React).
11
11
  */
12
- import type { TaskState, TaskType, TaskLifecycle, PermissionRole, IsolationMode, LocalAgentTaskState, LocalBashTaskState } from "../tasks/task-types.js";
12
+ import type { TaskState, TaskType, TaskLifecycle } from "../tasks/task-types.js";
13
13
  import type { HookRegistry } from "../../contracts/hooks.js";
14
- /** Polling interval for running tasks (ms) */
15
- export declare const POLL_INTERVAL_MS = 1000;
16
- /** Display duration for killed tasks before eviction (ms) */
17
- export declare const STOPPED_DISPLAY_MS = 3000;
18
14
  /** Grace period for terminal tasks before eviction (ms) */
19
15
  export declare const PANEL_GRACE_MS = 30000;
20
16
  export declare function generateTaskId(type: TaskType): string;
@@ -68,41 +64,8 @@ export declare class TaskStore {
68
64
  evictStaleTasks(graceMs?: number): void;
69
65
  }
70
66
  export declare function isTerminalLifecycle(lifecycle: TaskLifecycle): boolean;
71
- /**
72
- * Transition a task to a terminal state.
73
- */
74
- export declare function completeTask(store: TaskStore, taskId: string): void;
75
- export declare function failTask(store: TaskStore, taskId: string, error?: string): void;
76
- export declare function cancelTask(store: TaskStore, taskId: string): void;
77
- /**
78
- * Create and register a local agent task.
79
- */
80
- export declare function createLocalAgentTask(store: TaskStore, opts: {
81
- agentName: string;
82
- systemPrompt: string;
83
- allowedTools?: string[];
84
- parentTaskId?: string;
85
- tokenBudget?: number;
86
- maxTurns?: number;
87
- permissionRole?: PermissionRole;
88
- isolation?: IsolationMode;
89
- worktreeBranch?: string;
90
- }): LocalAgentTaskState;
91
- /**
92
- * Create and register a local bash task.
93
- */
94
- export declare function createLocalBashTask(store: TaskStore, opts: {
95
- command: string;
96
- cwd: string;
97
- parentTaskId?: string;
98
- label?: string;
99
- }): LocalBashTaskState;
100
67
  /**
101
68
  * Build a task notification message in CC's XML format.
102
69
  * This is injected into the conversation as context for the model.
103
70
  */
104
71
  export declare function buildTaskNotification(task: TaskState, summary: string): string;
105
- /**
106
- * Get the global task store singleton.
107
- */
108
- export declare function getTaskStore(): TaskStore;
@@ -11,15 +11,21 @@
11
11
  */
12
12
  import type { PermissionMode } from "../ports/permission-contracts.js";
13
13
  /**
14
- * The 7 task types from CC's sub-agent architecture.
14
+ * Sub-agent task types.
15
15
  *
16
- * - local_bash: Subprocess shell execution (bash/powershell)
17
- * - local_agent: Background forked Node process with its own tool loop
18
- * - remote_agent: Cloud environment (polling-based, e.g., CCR sandbox)
19
- * - in_process_teammate: Same process, AsyncLocalStorage-isolated agent
20
- * - local_workflow: DAG/pipeline execution (planned)
21
- * - monitor_mcp: MCP server monitoring agent (planned)
22
- * - dream: Background memory consolidation agent
16
+ * PRODUCED today (have a real registration site):
17
+ * - local_bash: backgrounded shell command (BackgroundTaskManager.registerBashTask)
18
+ * - local_agent: backgrounded forked agent (BackgroundTaskManager.startAgentTask)
19
+ * - dream: memory consolidation (runDream taskStore.registerTask)
20
+ *
21
+ * PLANNED declared for the TASK_PREFIX taxonomy + UI/protocol contract, but NO
22
+ * producer exists yet. Do not assume these are created anywhere; wire a producer
23
+ * before relying on them:
24
+ * - remote_agent: cloud sandbox (polling-based)
25
+ * - in_process_teammate: AsyncLocalStorage-isolated same-process agent
26
+ * (team members currently spawn as local subprocesses, not this)
27
+ * - local_workflow: DAG/pipeline execution
28
+ * - monitor_mcp: MCP server monitoring agent
23
29
  */
24
30
  export type TaskType = "local_bash" | "local_agent" | "remote_agent" | "in_process_teammate" | "local_workflow" | "monitor_mcp" | "dream";
25
31
  /**
@@ -66,6 +72,10 @@ export interface TaskStateBase {
66
72
  startedAt: number;
67
73
  /** End timestamp (ms), set when completed/failed. */
68
74
  endedAt?: number;
75
+ /** Final output (agent answer / command output tail), set on terminal lifecycle. */
76
+ output?: string;
77
+ /** Error message, set when lifecycle is failed. */
78
+ error?: string;
69
79
  }
70
80
  export type TaskLifecycle = "pending" | "running" | "completed" | "failed" | "cancelled" | "timeout";
71
81
  /** Local bash task — subprocess shell execution. */
@@ -74,6 +84,10 @@ export interface LocalBashTaskState extends TaskStateBase {
74
84
  command: string;
75
85
  cwd: string;
76
86
  pid?: number;
87
+ /** Exit code, set when the process exits. */
88
+ exitCode?: number;
89
+ /** Path to the live output file (background tasks stream here). */
90
+ outputPath?: string;
77
91
  }
78
92
  /** Local agent task — forked agent with its own tool loop. */
79
93
  export interface LocalAgentTaskState extends TaskStateBase {
@@ -76,6 +76,21 @@ export declare class LocalMemoryProvider implements MemoryProvider {
76
76
  proposeExtracted(items: ExtractedMemoryItem[], userId: string, options?: MemoryIngestOptions): Promise<MemoryConsolidationResult>;
77
77
  listClaims(userId: string): MemoryClaimRecord[];
78
78
  listConflicts(userId: string): MemoryConflictRecord[];
79
+ /**
80
+ * Drain the consolidation backlog: auto-resolve open conflicts and promote
81
+ * corroborated pending claims. Called by dream after consolidation so the
82
+ * observation→proposal→claim pipeline doesn't accumulate unresolved state
83
+ * forever (the "proposals black hole").
84
+ *
85
+ * Conflict winner = higher source priority, then confidence, then recency.
86
+ * The loser claim is superseded and its backing memory archived.
87
+ */
88
+ resolveConflicts(userId: string, opts?: {
89
+ minEvidenceToPromote?: number;
90
+ }): Promise<{
91
+ conflictsResolved: number;
92
+ claimsPromoted: number;
93
+ }>;
79
94
  /**
80
95
  * Trigger memory decay - multi-strategy (temporal + staleness + noise).
81
96
  * Also enforces capacity limit and runs vacuum for space reclamation.
@@ -451,6 +451,17 @@ export declare class LocalMemoryStore {
451
451
  reason: string;
452
452
  }): string;
453
453
  listConflicts(userId: string): MemoryConflictRecord[];
454
+ getClaimById(id: string): MemoryClaimRecord | undefined;
455
+ setClaimStatus(id: string, status: MemoryClaimStatus): boolean;
456
+ /** Mark a conflict resolved (the resolver has already updated the claims). */
457
+ setConflictStatus(id: string, status: "open" | "resolved" | "dismissed"): boolean;
458
+ /** Open conflicts only (the ones needing resolution). */
459
+ listOpenConflicts(userId: string): MemoryConflictRecord[];
460
+ /**
461
+ * Promote pending_confirmation claims that have accumulated enough independent
462
+ * evidence to become active. Returns the number promoted.
463
+ */
464
+ promotePendingClaims(userId: string, minEvidence: number): number;
454
465
  insertAttachment(input: MemoryAttachmentInsert): void;
455
466
  getAttachmentById(id: string): MemoryAttachmentRow | null;
456
467
  listAttachmentsByMemoryId(memoryId: string): MemoryAttachmentRow[];
@@ -32,5 +32,12 @@ export declare class MemoryConsolidator {
32
32
  observe(items: ExtractedMemoryItem[], userId: string, options?: MemoryConsolidationOptions): Promise<MemoryConsolidationResult>;
33
33
  proposeExtracted(items: ExtractedMemoryItem[], userId: string, options?: MemoryConsolidationOptions): Promise<MemoryConsolidationResult>;
34
34
  commitExtracted(items: ExtractedMemoryItem[], userId: string, options?: MemoryConsolidationOptions): Promise<MemoryConsolidationResult>;
35
+ /**
36
+ * Find an existing active memory that is a near-duplicate of `text`.
37
+ * Token containment (Latin/digit words + CJK bigrams) against recent
38
+ * memories; digit-bearing token mismatches veto the match because numbers
39
+ * and ids are precise facts, not phrasing variance.
40
+ */
41
+ private findNearDuplicateMemory;
35
42
  }
36
43
  export declare function sourcePriorityOf(source: string): number;
@@ -17,6 +17,8 @@ export interface AgentToolParams {
17
17
  maxTurns?: number;
18
18
  /** Run in background (returns task_id immediately). */
19
19
  background?: boolean;
20
+ /** Inherit a trimmed prefix of the parent conversation (default false). */
21
+ inheritContext?: boolean;
20
22
  }
21
23
  export declare const AGENT_TOOL_SCHEMA: {
22
24
  readonly type: "object";
@@ -40,13 +42,18 @@ export declare const AGENT_TOOL_SCHEMA: {
40
42
  };
41
43
  readonly background: {
42
44
  readonly type: "boolean";
43
- readonly description: "If true, runs in background and returns a task_id. Poll with task tool. Default: false.";
45
+ readonly description: string;
46
+ };
47
+ readonly inheritContext: {
48
+ readonly type: "boolean";
49
+ readonly description: string;
44
50
  };
45
51
  };
46
52
  readonly required: readonly ["agent", "prompt"];
47
53
  readonly additionalProperties: false;
48
54
  };
49
55
  export interface AgentResult {
56
+ /** Foreground: synthetic fork id. Background: real TaskStore task id (poll via task tool). */
50
57
  agentId: string;
51
58
  status: "completed" | "running" | "failed";
52
59
  output?: string;
@@ -55,22 +62,25 @@ export interface AgentResult {
55
62
  tokensUsed?: number;
56
63
  }
57
64
  /**
58
- * Host-provided fork execution backend (CC-aligned).
65
+ * Host-provided fork execution backend.
59
66
  *
60
- * Key properties of the fork mechanism:
61
- * 1. Child shares parent's message prefix (prompt cache hit)
62
- * 2. Child uses byte-identical prefix via placeholder results
63
- * 3. Child has independent tool context (isolation)
64
- * 4. Results flow back via in-memory streaming (not DB)
65
- * 5. Fork depth tracked in-memory (max 4 layers)
67
+ * Actual behavior (not aspirational):
68
+ * - The child starts FRESH by default: it receives only the `prompt` as a single
69
+ * user message. With inheritContext=true (foreground only), the host prepends a
70
+ * trimmed, budget-capped slice of the parent conversation (no system prompt,
71
+ * media/tool plumbing stripped) best-effort cache reuse, NOT byte-identical.
72
+ * - Child inherits the parent's tool pool, filtered by the agent definition.
73
+ * - Fork depth is tracked via AsyncLocalStorage; spawns past MAX_FORK_DEPTH are rejected.
74
+ * - Output is returned via in-memory streaming (not DB).
66
75
  */
67
76
  export interface AgentToolDeps {
68
77
  /**
69
78
  * Fork and run a sub-agent.
70
79
  * The implementation must:
71
- * - Share parent's rendered system prompt (byte-identical for cache)
80
+ * - Pass `prompt` as the child's task; if inheritContext, prepend the parent
81
+ * conversation slice (foreground only — background always starts fresh)
72
82
  * - Inherit parent's tool pool (filtered by agent definition)
73
- * - Track fork depth (reject if > MAX_FORK_DEPTH)
83
+ * - Track fork depth (reject if >= MAX_FORK_DEPTH)
74
84
  * - Return output via in-memory streaming backflow
75
85
  */
76
86
  forkAgent(params: {
@@ -79,6 +89,7 @@ export interface AgentToolDeps {
79
89
  description?: string;
80
90
  maxTurns?: number;
81
91
  background?: boolean;
92
+ inheritContext?: boolean;
82
93
  abortSignal?: AbortSignal;
83
94
  }): Promise<AgentResult>;
84
95
  /** Abort signal from the parent turn. */
@@ -1,4 +1,5 @@
1
1
  import type { PortableTool } from "../portable-tool.js";
2
+ import type { BashTaskHandle } from "../../runtime/infra/background-tasks.js";
2
3
  import type { CommandClassification } from "./shell/command-classification.js";
3
4
  import type { SandboxConfig } from "./shell/sandbox/sandbox-types.js";
4
5
  export declare const EXEC_TOOL_NAME: "exec";
@@ -89,6 +90,18 @@ export interface ExecToolHost {
89
90
  * The host can forward these to the UI for real-time output display.
90
91
  */
91
92
  onProgress?(progress: ExecProgress): void;
93
+ /**
94
+ * Register a backgrounded command in the host's unified task registry
95
+ * (lifecycle tracking + output queries + cancellation).
96
+ * Returns false when the host has no registry — background mode is then refused.
97
+ */
98
+ registerBackgroundTask?(info: {
99
+ command: string;
100
+ cwd: string;
101
+ description?: string;
102
+ pid?: number;
103
+ handle: BashTaskHandle;
104
+ }): boolean;
92
105
  }
93
106
  /**
94
107
  * Auto-background trigger threshold (assistant mode).
@@ -36,12 +36,12 @@ export declare const MONITOR_TOOL_SCHEMA: {
36
36
  };
37
37
  readonly source: {
38
38
  readonly type: "string";
39
- readonly enum: readonly ["process", "file", "task", "custom"];
40
- readonly description: "Type of event source to watch.";
39
+ readonly enum: readonly ["file"];
40
+ readonly description: "Type of event source to watch. Currently only \"file\" is supported.";
41
41
  };
42
42
  readonly target: {
43
43
  readonly type: "string";
44
- readonly description: string;
44
+ readonly description: "Selector for the monitored target. For file: a path or glob pattern.";
45
45
  };
46
46
  readonly conditions: {
47
47
  readonly type: "array";
@@ -30,6 +30,12 @@ export interface SendMessageResult {
30
30
  success: boolean;
31
31
  recipients?: string[];
32
32
  error?: string;
33
+ /** Replies collected from the recipient(s) — the message loop is synchronous. */
34
+ replies?: Array<{
35
+ memberId: string;
36
+ name: string;
37
+ reply: string;
38
+ }>;
33
39
  }
34
40
  /**
35
41
  * Host-provided message routing backend.
@@ -9,7 +9,7 @@ export { SAFE_ENV_VARS, BARE_SHELL_PREFIXES, stripSafeWrappers, stripAllLeadingE
9
9
  export { getDestructiveCommandWarning, getPowerShellDestructiveCommandWarning, } from "./destructive-command-warning.js";
10
10
  export type { CommandSemanticResult } from "./command-semantics.js";
11
11
  export { interpretCommandResult } from "./command-semantics.js";
12
- export { TaskOutput, generateTaskId, getTaskOutputDir, setTaskOutputDir, getTaskOutputPath, MAX_TASK_OUTPUT_BYTES, } from "./task-output.js";
12
+ export { TaskOutput, getTaskOutputDir, setTaskOutputDir, getTaskOutputPath, MAX_TASK_OUTPUT_BYTES, } from "./task-output.js";
13
13
  export type { ProgressCallback } from "./task-output.js";
14
14
  export type { ExecResult, ShellCommand } from "./shell-command.js";
15
15
  export { wrapSpawn, createAbortedCommand, createFailedCommand, } from "./shell-command.js";
@@ -8,7 +8,6 @@ export declare function getTaskOutputDir(): string;
8
8
  /** Set the task output directory (for embedding hosts to override). */
9
9
  export declare function setTaskOutputDir(dir: string): void;
10
10
  export declare function getTaskOutputPath(taskId: string): string;
11
- export declare function generateTaskId(prefix?: string): string;
12
11
  /**
13
12
  * Single source of truth for a shell command's output.
14
13
  * Ported from cc's TaskOutput.
@@ -1,7 +1,34 @@
1
1
  import type { PortableTool } from "../portable-tool.js";
2
2
  export declare const TASK_TOOL_NAME: "task";
3
- export declare const TASK_ACTIONS: readonly ["create", "update", "delete", "list", "get"];
3
+ export declare const TASK_ACTIONS: readonly ["create", "update", "delete", "list", "get", "output", "cancel"];
4
4
  export type TaskAction = (typeof TASK_ACTIONS)[number];
5
+ /**
6
+ * Structural view of the host's background task registry
7
+ * (implemented by BackgroundTaskManager; kept structural so this file stays zero-dep).
8
+ */
9
+ export interface TaskRuntimeAccess {
10
+ getTask(taskId: string): RuntimeTaskView | undefined;
11
+ listTasks(): RuntimeTaskView[];
12
+ readOutput(taskId: string): Promise<{
13
+ task: RuntimeTaskView;
14
+ output: string;
15
+ running: boolean;
16
+ } | null>;
17
+ cancelTask(taskId: string): boolean;
18
+ }
19
+ export interface RuntimeTaskView {
20
+ taskId: string;
21
+ type: string;
22
+ label: string;
23
+ lifecycle: string;
24
+ startedAt: number;
25
+ endedAt?: number;
26
+ error?: string;
27
+ }
28
+ export interface TaskToolRuntimeDeps {
29
+ /** Live accessor — the registry is bound by the host after bootstrap. */
30
+ getRuntime(): TaskRuntimeAccess | null;
31
+ }
5
32
  export type TaskStatus = "not-started" | "in-progress" | "completed";
6
33
  export declare const TASK_STATUS_VALUES: readonly TaskStatus[];
7
34
  export interface TaskItem {
@@ -23,6 +50,7 @@ export interface TaskListSummary {
23
50
  export interface TaskToolParams {
24
51
  action: TaskAction;
25
52
  id?: number;
53
+ taskId?: string;
26
54
  title?: string;
27
55
  description?: string;
28
56
  status?: TaskStatus;
@@ -35,12 +63,16 @@ export declare const TASK_TOOL_SCHEMA: {
35
63
  readonly properties: {
36
64
  readonly action: {
37
65
  readonly type: "string";
38
- readonly enum: readonly ["create", "update", "delete", "list", "get"];
66
+ readonly enum: readonly ["create", "update", "delete", "list", "get", "output", "cancel"];
39
67
  readonly description: string;
40
68
  };
41
69
  readonly id: {
42
70
  readonly type: "number";
43
- readonly description: "[update|delete|get] Task id to operate on.";
71
+ readonly description: "[update|delete|get] Checklist task id to operate on.";
72
+ };
73
+ readonly taskId: {
74
+ readonly type: "string";
75
+ readonly description: "[output|cancel] Background task id (returned by agent background=true / exec background=true).";
44
76
  };
45
77
  readonly title: {
46
78
  readonly type: "string";
@@ -57,7 +89,7 @@ export declare const TASK_TOOL_SCHEMA: {
57
89
  };
58
90
  readonly owner: {
59
91
  readonly type: "string";
60
- readonly description: "[create|update] Owner agent/subagent identifier.";
92
+ readonly description: string;
61
93
  };
62
94
  readonly addBlocks: {
63
95
  readonly type: "array";
@@ -90,4 +122,4 @@ export declare function summarizeTaskList(items: readonly TaskItem[]): TaskListS
90
122
  /**
91
123
  * Create a stateful task tool instance (V2 — CC TaskCreate/Update/List/Get aligned).
92
124
  */
93
- export declare function createTaskTool(options?: TaskToolOptions, hooks?: TaskToolHooks): PortableTool<TaskToolParams>;
125
+ export declare function createTaskTool(options?: TaskToolOptions, hooks?: TaskToolHooks, runtimeDeps?: TaskToolRuntimeDeps): PortableTool<TaskToolParams>;
@@ -79,6 +79,11 @@ export interface TeamResult {
79
79
  team?: Team;
80
80
  teams?: Team[];
81
81
  error?: string;
82
+ /** Members that failed to spawn (team still created with the survivors). */
83
+ partialFailures?: Array<{
84
+ name: string;
85
+ error: string;
86
+ }>;
82
87
  }
83
88
  /**
84
89
  * Host-provided team management backend.
@@ -92,7 +92,6 @@ export interface AcpRequestHandler {
92
92
  handleAcpProductRollback(params: Record<string, unknown>): Promise<unknown>;
93
93
  handleAcpProductStatus(params: Record<string, unknown>): Promise<unknown>;
94
94
  handleAcpProductSubscribe(params: Record<string, unknown>): Promise<unknown>;
95
- handleAcpTeamDelegate(params: Record<string, unknown>): Promise<unknown>;
96
95
  }
97
96
  export interface AcpServerConfig {
98
97
  verbose?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qlogicagent",
3
- "version": "2.12.3",
3
+ "version": "2.12.5",
4
4
  "description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",