qlogicagent 2.12.8 → 2.12.10

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 (104) hide show
  1. package/README.md +91 -157
  2. package/dist/agent.js +6 -6
  3. package/dist/cli.js +411 -426
  4. package/dist/index.js +410 -425
  5. package/dist/orchestration.js +6 -6
  6. package/dist/protocol.js +1 -1
  7. package/dist/types/agent/memory-recall-injection.d.ts +34 -0
  8. package/dist/types/agent/tool-loop/budget-continuation-policy.d.ts +22 -0
  9. package/dist/types/agent/tool-loop/completion-action-policy.d.ts +19 -0
  10. package/dist/types/agent/tool-loop/completion-stop-policy.d.ts +19 -0
  11. package/dist/types/agent/tool-loop/compression-pipeline.d.ts +44 -0
  12. package/dist/types/agent/tool-loop/skill-instruction-policy.d.ts +7 -0
  13. package/dist/types/agent/tool-loop/stream-error-recovery.d.ts +59 -0
  14. package/dist/types/agent/tool-loop/tool-failure-policy.d.ts +22 -0
  15. package/dist/types/agent/types.d.ts +2 -2
  16. package/dist/types/cli/acp-message-router.d.ts +8 -0
  17. package/dist/types/cli/acp-session-host.d.ts +3 -0
  18. package/dist/types/cli/cli-agent-builder.d.ts +1 -1
  19. package/dist/types/cli/core-tools/config-tool-bootstrap.d.ts +1 -5
  20. package/dist/types/cli/core-tools/config-tool-service.d.ts +9 -5
  21. package/dist/types/cli/core-tools/registry.d.ts +1 -2
  22. package/dist/types/cli/core-tools/session-tool-manifest.d.ts +12 -0
  23. package/dist/types/cli/core-tools/team-registry.d.ts +8 -8
  24. package/dist/types/cli/dev-tools/dev-tool-registry.d.ts +1 -2
  25. package/dist/types/cli/gateway-rpc-connection.d.ts +50 -0
  26. package/dist/types/cli/handlers/session-handler.d.ts +2 -1
  27. package/dist/types/cli/handlers/workflow-handler.d.ts +10 -0
  28. package/dist/types/cli/model-client-resolver.d.ts +12 -3
  29. package/dist/types/cli/resolved-agent-cache.d.ts +47 -0
  30. package/dist/types/cli/rpc-registry.d.ts +59 -5
  31. package/dist/types/cli/session-context.d.ts +32 -0
  32. package/dist/types/cli/skill-meta-tool-bootstrap.d.ts +7 -0
  33. package/dist/types/cli/stdio-acp-protocol-coordinator.d.ts +18 -0
  34. package/dist/types/cli/stdio-acp-request-host.d.ts +3 -0
  35. package/dist/types/cli/stdio-rpc-handler-hosts.d.ts +50 -0
  36. package/dist/types/cli/stdio-server.d.ts +103 -180
  37. package/dist/types/cli/stdio-session-runtime-coordinator.d.ts +19 -0
  38. package/dist/types/cli/tool-bootstrap-core-registration.d.ts +30 -0
  39. package/dist/types/cli/tool-bootstrap-media-registration.d.ts +8 -0
  40. package/dist/types/cli/tool-bootstrap-paths.d.ts +7 -0
  41. package/dist/types/cli/tool-bootstrap-web-registration.d.ts +13 -0
  42. package/dist/types/cli/tool-bootstrap-workflow-registration.d.ts +7 -0
  43. package/dist/types/cli/tool-bootstrap.d.ts +5 -22
  44. package/dist/types/cli/tunable-store.d.ts +26 -0
  45. package/dist/types/cli/workflow-host-adapter.d.ts +29 -0
  46. package/dist/types/contracts/hooks.d.ts +6 -0
  47. package/dist/types/orchestration/workflow/run-history-store.d.ts +58 -0
  48. package/dist/types/orchestration/workflow/workflow-controller.d.ts +23 -1
  49. package/dist/types/orchestration/workflow/workflow-store.d.ts +24 -0
  50. package/dist/types/protocol/wire/acp-protocol.d.ts +1 -2
  51. package/dist/types/protocol/wire/gateway-rpc.d.ts +0 -112
  52. package/dist/types/runtime/config/tunable-defaults.d.ts +6 -0
  53. package/dist/types/runtime/infra/agent-paths.d.ts +0 -2
  54. package/dist/types/runtime/infra/agent-process.d.ts +1 -1
  55. package/dist/types/runtime/infra/default-path-service.d.ts +0 -1
  56. package/dist/types/runtime/infra/index.d.ts +1 -1
  57. package/dist/types/runtime/infra/key-pool.d.ts +1 -0
  58. package/dist/types/runtime/infra/llmrouter-catalog.d.ts +8 -0
  59. package/dist/types/runtime/ports/path-service.d.ts +0 -1
  60. package/dist/types/runtime/ports/tool-contracts.d.ts +1 -1
  61. package/dist/types/runtime/prompt/environment-context.d.ts +13 -0
  62. package/dist/types/runtime/prompt/index.d.ts +1 -0
  63. package/dist/types/runtime/prompt/prompt-policy.d.ts +2 -0
  64. package/dist/types/runtime/prompt/system-prompt-sections.d.ts +2 -0
  65. package/dist/types/runtime/session/session-catalog.d.ts +4 -0
  66. package/dist/types/runtime/session/session-metadata-store.d.ts +8 -0
  67. package/dist/types/runtime/session/session-paths.d.ts +9 -0
  68. package/dist/types/runtime/session/session-persistence.d.ts +14 -159
  69. package/dist/types/runtime/session/session-resume.d.ts +4 -0
  70. package/dist/types/runtime/session/session-schema.d.ts +10 -0
  71. package/dist/types/runtime/session/session-summary.d.ts +5 -0
  72. package/dist/types/runtime/session/session-transcript-store.d.ts +13 -0
  73. package/dist/types/runtime/session/session-types.d.ts +77 -0
  74. package/dist/types/runtime/session/session-write-queue.d.ts +2 -0
  75. package/dist/types/runtime/tasks/task-types.d.ts +1 -1
  76. package/dist/types/skills/mcp/index.d.ts +1 -3
  77. package/dist/types/skills/mcp/mcp-manager.d.ts +14 -38
  78. package/dist/types/skills/permissions/rule-engine.d.ts +1 -0
  79. package/dist/types/skills/plugins/plugin-api.d.ts +0 -1
  80. package/dist/types/skills/plugins/plugin-loader.d.ts +0 -4
  81. package/dist/types/skills/portable-tool.d.ts +2 -2
  82. package/dist/types/skills/tools/config-tool.d.ts +1 -3
  83. package/dist/types/skills/tools/skill-tool.d.ts +2 -2
  84. package/dist/types/skills/tools/team-tool.d.ts +44 -4
  85. package/dist/types/skills/tools/tool-search-tool.d.ts +11 -0
  86. package/package.json +2 -1
  87. package/dist/types/assistants/assistant-registry.d.ts +0 -4
  88. package/dist/types/assistants/assistant-store.d.ts +0 -23
  89. package/dist/types/assistants/assistant-turn-context.d.ts +0 -20
  90. package/dist/types/assistants/assistant-types.d.ts +0 -38
  91. package/dist/types/assistants/plugin-assistant-registry.d.ts +0 -16
  92. package/dist/types/cli/core-tools/utility-tool-bootstrap.d.ts +0 -12
  93. package/dist/types/cli/dev-tools/repl-tool-service.d.ts +0 -5
  94. package/dist/types/cli/handlers/assistants-handler.d.ts +0 -13
  95. package/dist/types/skills/mcp/mcp-http-client.d.ts +0 -68
  96. package/dist/types/skills/mcp/mcp-stdio-client.d.ts +0 -86
  97. package/dist/types/skills/think-tool.d.ts +0 -16
  98. package/dist/types/skills/tools/apply-patch-tool.d.ts +0 -29
  99. package/dist/types/skills/tools/mcp-client-types.d.ts +0 -269
  100. package/dist/types/skills/tools/mcp-resource-tools.d.ts +0 -14
  101. package/dist/types/skills/tools/mcp-tool.d.ts +0 -249
  102. package/dist/types/skills/tools/project-switch-tool.d.ts +0 -24
  103. package/dist/types/skills/tools/repl-tool.d.ts +0 -70
  104. package/dist/types/skills/tools/send-message-tool.d.ts +0 -57
@@ -9,90 +9,124 @@
9
9
  * The physical I/O layer is abstracted via the Transport interface.
10
10
  */
11
11
  import type { Transport } from "./transport.js";
12
- import { AcpServer } from "../transport/acp-server.js";
12
+ import type { Agent } from "../agent/agent.js";
13
+ import type { TurnConfig } from "../agent/types.js";
14
+ import type { LLMTransport } from "./provider-core-facade.js";
15
+ import { type MemoryPrefetchState } from "../runtime/hooks/memory-hooks.js";
16
+ import { SessionState } from "../runtime/session/session-state.js";
17
+ import { TaskStore } from "../runtime/infra/task-runtime.js";
18
+ import { BackgroundTaskManager } from "../runtime/infra/background-tasks.js";
19
+ import { type TaskDomain } from "../runtime/prompt/task-domain.js";
20
+ import { type AgentRpcError } from "../protocol/wire/index.js";
21
+ import type { AcpServer } from "../transport/acp-server.js";
22
+ import type { NotificationMethod, NotificationMethodMap } from "../protocol/notifications.js";
23
+ import type { SessionLlmConfig } from "./acp-session-host.js";
24
+ import { AgentRuntimeSessionState } from "./agent-runtime-session-state.js";
25
+ import { type MultiAgentHandlerHost } from "./multi-agent-handler-host.js";
26
+ import type { WorkflowHandlerHost } from "./handlers/workflow-handler.js";
27
+ import { SessionHistoryCoordinator } from "./session-history-coordinator.js";
28
+ import { PetConfirmCoordinator } from "./pet-confirm-coordinator.js";
29
+ import type { MemoryDreamRuntimeProvider, MemoryHandlerProvider, ProjectMemoryStore } from "../runtime/ports/index.js";
13
30
  export interface StdioServerConfig {
14
31
  verbose: boolean;
15
32
  transport?: Transport;
16
33
  }
17
34
  export declare class StdioServer {
18
- private running;
19
- private readonly startedAt;
20
- private readonly packageVersion;
21
- private readonly rpcContract;
22
- private readonly rpcIds;
23
- private readonly rpcDeadlineTimers;
24
- private activeTurn;
35
+ running: boolean;
36
+ readonly startedAt: number;
37
+ readonly packageVersion: string;
38
+ /** JSON-RPC request lifecycle: gateway contract, in-flight ledger, deadlines. */
39
+ private rpc;
40
+ /** Gateway contract — exposed for control-handler metrics/cancel. */
41
+ get rpcContract(): import("../protocol/wire/gateway-contract.js").GatewayRpcContract;
42
+ activeTurn: AbortController | null;
25
43
  /** Resolves when the active turn fully completes (including post-abort flush). */
26
44
  private turnDone;
27
- private verbose;
45
+ verbose: boolean;
28
46
  private transport;
29
47
  private readonly runtimeServices;
30
48
  private readonly runtimeSession;
31
- private agent;
32
- private lastLlmConfigKey;
33
- private currentSessionId;
34
- private currentTurnId;
35
- /** Cached LLM transport for sub-agent forks (dream) */
36
- private currentTransport;
37
- private currentApiKey;
38
- private currentModel;
39
- private currentProvider;
40
- private currentBaseUrl;
41
- /** Host-pinned per-session LLM config (session/set_config_option · set_model · /model). */
42
- private sessionLlmConfig;
43
- private sessionState;
49
+ /**
50
+ * DERIVED resolved-agent cache (Agent + LLM client snapshot). The invalidation
51
+ * invariant (full wipe on registry change vs forget-agent on session dispose)
52
+ * is localized in ResolvedAgentCache. Host-pinned sessionLlmConfig is separate
53
+ * and never touched by it.
54
+ */
55
+ private readonly resolvedAgent;
56
+ /** Active session/turn identity + lifecycle (id/turn/state/taskDomain/llmConfig/acpMeta). */
57
+ private readonly session;
44
58
  private currentMediaApiKeys;
45
- private taskStore;
59
+ taskStore: TaskStore;
46
60
  /** Unified background execution registry (agent forks + backgrounded shell commands). */
47
- private backgroundTasks;
61
+ backgroundTasks: BackgroundTaskManager;
48
62
  /** Settled-task notifications queued for injection into the next turn's context. */
49
63
  private pendingTaskNotifications;
50
64
  /** Session-scoped memory prefetch state (LRU dedup + byte limit). */
51
- private memoryPrefetchState;
65
+ memoryPrefetchState: MemoryPrefetchState;
52
66
  /** Last user message text for auto-extract hook (set at turn start, cleared at turn end). */
53
67
  private lastUserMessageForAutoExtract;
54
68
  /** Last assistant message text for implicit extraction hook (set at turn end). */
55
69
  private lastAssistantMessageForExtract;
56
70
  /** MEMDIR file-based memory (CC memdir parity). */
57
- private memdir;
58
- private readonly projectMemoryStoreFactory;
71
+ memdir: ProjectMemoryStore | null;
72
+ readonly projectMemoryStoreFactory: import("../runtime/ports/project-memory-store.js").ProjectMemoryStoreFactory;
59
73
  /** Memory write gate state (P2+P3: category gate + supersedes). */
60
74
  /** Pending ask_user requests waiting for host response */
61
- private pendingAskUser;
62
- /** Session-level task domain stickiness. Survives across turns within a session. */
63
- private sessionTaskDomain;
64
- /** ACP session-level context supplement (_meta from session/new), inherited by every prompt. */
65
- private acpSessionMeta;
75
+ pendingAskUser: Map<string, {
76
+ resolve: (answers: Record<string, string> | null) => void;
77
+ }>;
66
78
  /** Agents/solo/product handler facade. */
67
- private readonly multiAgentHandlerHost;
68
- /** ACP Server instancehandles ACP protocol alongside legacy protocol. */
69
- private acpServer;
70
- private sessionHistory;
79
+ readonly multiAgentHandlerHost: MultiAgentHandlerHost;
80
+ /** Workflow handler hostcarries toolCatalog + the lazy engine slots the multi-agent host lacks. */
81
+ readonly workflowHandlerHost: WorkflowHandlerHost;
82
+ /** ACP protocol coordinator — owns AcpServer lifecycle and ACP event mapping. */
83
+ private readonly acp;
84
+ sessionHistory: SessionHistoryCoordinator;
71
85
  private idleDreamCoordinator;
72
- private readonly petConfirmCoordinator;
86
+ private readonly sessionRuntime;
87
+ readonly petConfirmCoordinator: PetConfirmCoordinator;
73
88
  private modelRegistryHydration;
74
89
  private get registry();
75
- private get mediaClient();
76
- private get mediaPersistence();
90
+ get mediaClient(): import("@xiaozhiclaw/provider-core/media-client").MediaClient;
91
+ get mediaPersistence(): import("../runtime/infra/media-persistence.js").MediaPersistence;
77
92
  private get pathService();
78
93
  get toolCatalog(): import("../runtime/ports/tool-contracts.js").ToolCatalog;
79
- private get petRuntime();
80
- private get currentHooks();
81
- private get permissionChecker();
94
+ get petRuntime(): import("./pet-runtime.js").PetRuntime;
95
+ private get agent();
96
+ /** Cached LLM transport for sub-agent forks (dream). */
97
+ get currentTransport(): LLMTransport | null;
98
+ get currentApiKey(): string;
99
+ get currentModel(): string;
100
+ private get currentProvider();
101
+ private get currentBaseUrl();
102
+ get currentSessionId(): string;
103
+ set currentSessionId(v: string);
104
+ get currentTurnId(): string;
105
+ set currentTurnId(v: string);
106
+ get sessionState(): SessionState | null;
107
+ set sessionState(v: SessionState | null);
108
+ get sessionTaskDomain(): TaskDomain | undefined;
109
+ set sessionTaskDomain(v: TaskDomain | undefined);
110
+ get sessionLlmConfig(): SessionLlmConfig;
111
+ set sessionLlmConfig(v: SessionLlmConfig);
112
+ get acpSessionMeta(): Record<string, unknown> | null;
113
+ set acpSessionMeta(v: Record<string, unknown> | null);
114
+ get currentHooks(): import("../contracts/hooks.js").HookRegistry | null;
115
+ get permissionChecker(): AgentRuntimeSessionState["permissionChecker"];
82
116
  private set permissionChecker(value);
83
117
  private set mcpManager(value);
84
- private get memoryProvider();
85
- private set memoryProvider(value);
86
- private get memoryDreamProvider();
87
- private set memoryDreamProvider(value);
88
- private get memoryUserId();
89
- private set memoryUserId(value);
118
+ get memoryProvider(): MemoryHandlerProvider | null;
119
+ set memoryProvider(value: MemoryHandlerProvider | null);
120
+ get memoryDreamProvider(): MemoryDreamRuntimeProvider | null;
121
+ set memoryDreamProvider(value: MemoryDreamRuntimeProvider | null);
122
+ get memoryUserId(): string;
123
+ set memoryUserId(value: string);
90
124
  constructor(config: StdioServerConfig);
91
125
  /**
92
126
  * Get the active project workspace directory.
93
127
  * Reads from projectStore (single source of truth).
94
128
  */
95
- private getActiveProjectRoot;
129
+ getActiveProjectRoot(): string;
96
130
  /**
97
131
  * Drain queued background-task completion notifications.
98
132
  * Called by the turn pipeline at turn start — settled tasks are injected
@@ -107,7 +141,7 @@ export declare class StdioServer {
107
141
  * Centralizes all side-effects (bootstrap workdir, media persistence, etc.).
108
142
  * Uses projectStore as the source of truth — no private field cache.
109
143
  */
110
- private setActiveWorkdir;
144
+ setActiveWorkdir(dir: string): void;
111
145
  start(): void;
112
146
  stop(): Promise<void>;
113
147
  private readonly methodHandlers;
@@ -116,108 +150,30 @@ export declare class StdioServer {
116
150
  * Ensure a default project exists on first start.
117
151
  * Called from both legacy handleInitialize and ACP acpHandleInitialize.
118
152
  */
119
- private ensureDefaultProject;
120
- /**
121
- * `thread.create` — create a new thread (session container).
122
- * Maps threadId → sessionId for the underlying session system.
123
- */
124
- /**
125
- * `thread.list` — list available threads. Delegates to session listing.
126
- */
127
- /**
128
- * Resolve session for an inbound message.
129
- * For desktop: chatId IS the sessionId — look it up directly.
130
- * For group: look up by groupKey pattern.
131
- * If not found, create a new session and return it.
132
- */
153
+ ensureDefaultProject(): void;
133
154
  /**
134
155
  * Atomically resolve transport + model + apiKey for a given ModelPurpose.
135
156
  * If the resolved provider matches `this.currentProvider`, reuses cached transport.
136
157
  * Otherwise creates a one-shot client. Returns null if purpose is unresolvable.
137
158
  * This ensures side-ops always use fresh model from registry.
138
159
  */
139
- private resolveClientForPurpose;
160
+ resolveClientForPurpose(purpose: import("../runtime/infra/model-registry.js").ModelPurpose): {
161
+ transport: LLMTransport;
162
+ apiKey: string;
163
+ model: string;
164
+ } | null;
140
165
  /**
141
166
  * Ensure the L2 SQLite memory provider exists for read-only RPCs
142
167
  * (memory.atlas / memory.activity). These can be called before any turn has
143
168
  * run, so they cannot rely on resolveAgent() having initialized the provider.
144
169
  * Opening the DB is cheap and side-effect-free (list() does not embed).
145
170
  */
146
- private ensureMemoryProvider;
147
- private resolveAgent;
171
+ ensureMemoryProvider(): void;
172
+ resolveAgent(config: TurnConfig): Agent | null;
148
173
  private invalidateResolvedLlmCache;
149
- /**
150
- * Load LLM config from ModelRegistry (textGeneration binding).
151
- * Returns provider/model/apiKey if found, undefined otherwise.
152
- */
153
- /**
154
- * `session.getInfo` — Return session metadata, filesystem paths, and usage summary.
155
- * Aligns with Codex/Copilot session introspection capability.
156
- */
157
- /**
158
- * `memory.list` — Enumerate available memory sources (memdir + local sqlite).
159
- */
160
- /**
161
- * `memory.read` — Read memory content from memdir (INDEX.md or topic file).
162
- */
163
- /**
164
- * `memory.write` — Write memory content to memdir (INDEX.md or topic file).
165
- */
166
- /**
167
- * `tools.list` — Return available tool definitions (local + MCP + plugin).
168
- * Supports optional category filter.
169
- */
170
- /**
171
- * `media.listModels` — List available media generation models.
172
- * Desktop app uses this to populate the model selector per category.
173
- */
174
- /**
175
- * `media.cancel` — Cancel an in-progress media generation task.
176
- * Delegates to the provider's native cancellation API (e.g. Volcengine DELETE task).
177
- */
178
- /**
179
- * `media.status` — Query the status of a media generation task.
180
- * Returns provider-specific task status (e.g. queuing, running, succeeded, failed).
181
- */
182
- /** Resolve media API key for a provider from the current session config. */
183
- /**
184
- * `provider.list` — List all available LLM providers grouped by logical family.
185
- * Returns protocol variants so callers can pick which transport to use.
186
- */
187
- /**
188
- * `config.get` — Read current agent runtime configuration.
189
- * Returns merged user-level + project-level settings.
190
- */
191
- /**
192
- * `config.update` — Update agent runtime configuration (merges into settings.json).
193
- */
194
- /**
195
- * `config.tunables` — Return all tunable default values with their current overrides.
196
- */
197
- /**
198
- * `config.updateTunable` — Write a single tunable override into settings.json.tunables.
199
- * Params: { key: string, value: number | boolean | string }
200
- * Only keys that exist in TunableDefaults are accepted (validation).
201
- */
202
- /**
203
- * `todos.list` — Query current todo items and summary.
204
- * Invokes the registered todo tool's list action.
205
- */
206
- /**
207
- * `memory.search` — Search memory via local SQLite provider or memdir keyword fallback.
208
- */
209
- /**
210
- * `memory.delete` — Remove memory entry from memdir (INDEX.md line) or local store (by ID).
211
- */
212
- /**
213
- * `tasks.list` — Query running/completed infrastructure tasks.
214
- */
215
- /**
216
- * `tasks.cancel` — Cancel a running task by ID.
217
- */
218
174
  /** Emit an `agents.status` notification when a child process state changes. */
219
175
  private emitAgentStatus;
220
- private createDreamHandlerHost;
176
+ createDreamHandlerHost(): import("./handlers/dream-handler.js").DreamHandlerHost;
221
177
  private createAcpExtendedHandlerHost;
222
178
  /**
223
179
  * Handle an MCP tool call proxied from an external ACP agent via the
@@ -225,55 +181,22 @@ export declare class StdioServer {
225
181
  * system and returns the text result.
226
182
  */
227
183
  private handleMcpToolCall;
228
- /** `agents.scan` Scan for installed ACP agent CLIs. */
229
- /** `agents.list` — Return cached agent descriptors. */
230
- /** `agents.config` Register / unregister / update custom agents. */
231
- /** `agents.setConfig` Set per-agent LLM / environment / model ID config. */
232
- /** `agents.getConfig` Get per-agent configuration. */
233
- /** `agents.removeConfig` — Remove per-agent configuration. */
234
- /** `agents.setGateway` Set global gateway proxy URL. */
235
- /** `solo.start` Start a Solo Mode PK session. */
236
- /** `solo.status` — Query solo session status. */
237
- /** `solo.cancel` — Cancel a running solo session. */
238
- /** `solo.select` — Select winner and merge worktree. */
239
- /** Ensure ProductPlanner is initialized. */
240
- /** `product.plan` — Start interactive planning with leader agent. */
241
- /** `product.confirm` — User confirms the plan, transition to execution. */
242
- /** `product.message` — User sends message to leader (multi-turn planning or execution intervention). */
243
- /** `product.create` — Create a new Product Mode session. */
244
- /** `product.resume` — Resume a paused product. */
245
- /** `product.pause` — Pause a running product. */
246
- /** `product.checkpoint` — Manual checkpoint. */
247
- /** `product.status` — Query product status. */
248
- /** `product.list` — List all products. */
249
- /** `agents.getGateway` — Get the current global gateway proxy URL. */
250
- /** `agents.listConfigured` — List agents that have persisted configuration. */
251
- /** `agents.processes` — List all active child agent processes from solo/product PMs. */
252
- /** `agents.kill` — Kill a child agent process by memberId. */
253
- /** `agents.getLog` — Read stderr log for a specific agent. */
254
- /** `agents.testConnection` — Spawn an agent with a short timeout to verify connectivity. */
255
- /** `solo.list` — List all solo sessions. */
256
- /** `solo.delete` — Delete a solo session and clean up resources. */
257
- /** `solo.message` — Send follow-up message to a specific agent in solo session. */
258
- /** `solo.evaluate` — User-triggered evaluation of solo session results. */
259
- /** `product.delete` — Delete a product session and clean up resources. */
260
- /** `product.cancel` — Cancel a running product. */
261
- /** `product.rollback` — Rollback a product to a checkpoint. */
262
- private sendResponse;
263
- private sendContractError;
264
- private sendContractErrorOrResult;
265
- private scheduleRpcDeadline;
266
- private clearRpcLifecycle;
267
- private sendNotification;
184
+ sendResponse(id: string | number, result?: unknown, error?: AgentRpcError): void;
185
+ /**
186
+ * Send a JSON-RPC error response by (code, message, data) — convenience over
187
+ * sendResponse for handlers that build the error inline (e.g. session.moveToProject
188
+ * error paths call `this.sendError`).
189
+ */
190
+ sendError(id: string | number, code: AgentRpcError["code"], message: string, data?: unknown): void;
191
+ sendNotification<M extends NotificationMethod>(method: M, params: NotificationMethodMap[M]): void;
268
192
  private writeStdout;
269
- private log;
193
+ log(message: string): void;
270
194
  /**
271
195
  * Enable idle dream scheduling. Called after session setup when LLM config is available.
272
196
  */
273
197
  enableIdleDream(minutes?: number): void;
274
- private cancelIdleDreamTimer;
198
+ cancelIdleDreamTimer(): void;
275
199
  disposeSessionRuntime(): void;
276
- private closeMemoryProviders;
277
200
  /**
278
201
  * Initialize the ACP server alongside the legacy protocol.
279
202
  * Called once when the host is an ACP-compliant client.
@@ -0,0 +1,19 @@
1
+ import { type MemoryPrefetchState } from "../runtime/hooks/memory-hooks.js";
2
+ import type { MemoryDreamRuntimeProvider, MemoryHandlerProvider } from "../runtime/ports/index.js";
3
+ import type { AgentRuntimeSessionState } from "./agent-runtime-session-state.js";
4
+ import type { ResolvedAgentCache } from "./resolved-agent-cache.js";
5
+ import type { StdioRuntimeServices } from "./stdio-runtime-services.js";
6
+ export interface StdioSessionRuntimeCoordinatorDeps {
7
+ runtimeSession: AgentRuntimeSessionState;
8
+ runtimeServices: Pick<StdioRuntimeServices, "closeMemoryProviders">;
9
+ resolvedAgent: Pick<ResolvedAgentCache, "forgetAgent">;
10
+ getMemoryProvider(): MemoryHandlerProvider | null;
11
+ getMemoryDreamProvider(): MemoryDreamRuntimeProvider | null;
12
+ setMemoryPrefetchState(state: MemoryPrefetchState): void;
13
+ }
14
+ export declare class StdioSessionRuntimeCoordinator {
15
+ private readonly deps;
16
+ constructor(deps: StdioSessionRuntimeCoordinatorDeps);
17
+ dispose(): void;
18
+ closeMemoryProviders(): void;
19
+ }
@@ -0,0 +1,30 @@
1
+ import type { PortableTool } from "../skills/portable-tool.js";
2
+ import { type TaskToolHooks } from "../skills/tools/task-tool.js";
3
+ import { type AskUserQuestion } from "../skills/tools/ask-user-tool.js";
4
+ import { type ExecProgress } from "../skills/tools/exec-tool.js";
5
+ import type { BackgroundTaskManager } from "../runtime/infra/background-tasks.js";
6
+ import type { SandboxConfig } from "../skills/tools/shell/sandbox/sandbox-types.js";
7
+ import { type PathService, type RuntimeToolContract } from "../runtime/ports/index.js";
8
+ export interface LocalCoreToolRegistrationContext {
9
+ tools: PortableTool<any>[];
10
+ taskToolHooks?: TaskToolHooks;
11
+ backgroundTaskRuntime: BackgroundTaskManager | null;
12
+ askUserCallback: ((questions: AskUserQuestion[]) => Promise<Record<string, string> | null>) | null;
13
+ onExecProgress?: (progress: ExecProgress) => void;
14
+ getCwd(): string;
15
+ activeProjectRoot(): string;
16
+ resolveSandboxConfig(): SandboxConfig | undefined;
17
+ isGroupSecurityMode?(): boolean;
18
+ pathService?: PathService;
19
+ log?: {
20
+ info(message: string): void;
21
+ warn(message: string): void;
22
+ };
23
+ listToolNames(): string[];
24
+ findRegisteredTool(name: string): RuntimeToolContract | undefined;
25
+ activateRegisteredTool(name: string): boolean;
26
+ }
27
+ export declare function setGroupSecurityMode(enabled: boolean): void;
28
+ export declare const localCoreToolRegistrationModule: import("../runtime/ports/tool-contracts.js").ToolRegistrationModule<LocalCoreToolRegistrationContext>;
29
+ export declare function registerLocalCoreTools(context: LocalCoreToolRegistrationContext): void;
30
+ export declare function validateExecCommand(command: string, workdir: string, groupMode?: boolean): string | null;
@@ -0,0 +1,8 @@
1
+ import type { PortableTool } from "../skills/portable-tool.js";
2
+ export interface LocalMediaToolRegistrationContext {
3
+ tools: PortableTool<any>[];
4
+ getCwd(): string;
5
+ activeProjectRoot(): string;
6
+ }
7
+ export declare const localMediaToolRegistrationModule: import("../runtime/ports/tool-contracts.js").ToolRegistrationModule<LocalMediaToolRegistrationContext>;
8
+ export declare function registerLocalMediaTools(context: LocalMediaToolRegistrationContext): void;
@@ -0,0 +1,7 @@
1
+ export declare function resolveToolPath(input: string, cwd: string): string;
2
+ /**
3
+ * Enforce absolute, mode-independent floors. Workspace membership belongs to
4
+ * the permission pipeline; this helper only blocks device/system paths that no
5
+ * permission mode should allow through local file/media tooling.
6
+ */
7
+ export declare function enforceAbsoluteFloors(resolved: string): string | null;
@@ -0,0 +1,13 @@
1
+ import type { PortableTool } from "../skills/portable-tool.js";
2
+ import type { ModelPurpose } from "../runtime/infra/model-registry.js";
3
+ import type { LLMTransport } from "./provider-core-facade.js";
4
+ export interface LocalWebToolRegistrationContext {
5
+ tools: PortableTool<any>[];
6
+ resolveClientForPurpose?(purpose: ModelPurpose): {
7
+ transport: LLMTransport;
8
+ apiKey: string;
9
+ model: string;
10
+ } | null;
11
+ }
12
+ export declare const localWebToolRegistrationModule: import("../runtime/ports/tool-contracts.js").ToolRegistrationModule<LocalWebToolRegistrationContext>;
13
+ export declare function registerLocalWebTools(context: LocalWebToolRegistrationContext): void;
@@ -0,0 +1,7 @@
1
+ import type { PortableTool } from "../skills/portable-tool.js";
2
+ export interface LocalWorkflowToolRegistrationContext {
3
+ tools: PortableTool<any>[];
4
+ activeProjectRoot(): string;
5
+ }
6
+ export declare const localWorkflowToolRegistrationModule: import("../runtime/ports/tool-contracts.js").ToolRegistrationModule<LocalWorkflowToolRegistrationContext>;
7
+ export declare function registerLocalWorkflowTools(context: LocalWorkflowToolRegistrationContext): void;
@@ -1,16 +1,16 @@
1
1
  import type { PortableTool } from "../skills/portable-tool.js";
2
2
  import type { PermissionMode } from "../runtime/ports/permission-contracts.js";
3
- import { type TaskToolHooks } from "../skills/tools/task-tool.js";
4
- import { type ExecProgress } from "../skills/tools/exec-tool.js";
3
+ import type { TaskToolHooks } from "../skills/tools/task-tool.js";
4
+ import type { ExecProgress } from "../skills/tools/exec-tool.js";
5
5
  import type { BackgroundTaskManager } from "../runtime/infra/background-tasks.js";
6
6
  import type { ModelPurpose } from "../runtime/infra/model-registry.js";
7
7
  import type { LLMTransport } from "./provider-core-facade.js";
8
8
  import type { AgentLogger } from "../agent/types.js";
9
- import { type AskUserQuestion } from "../skills/tools/ask-user-tool.js";
9
+ import type { AskUserQuestion } from "../skills/tools/ask-user-tool.js";
10
10
  import type { PathService, ToolCatalog } from "../runtime/ports/index.js";
11
11
  export { setMediaClientConfig, setProviderToolAPI } from "./media-runtime-facade.js";
12
- /** Enable or disable group security mode (blocks sensitive file access). */
13
- export declare function setGroupSecurityMode(enabled: boolean): void;
12
+ export { setGroupSecurityMode, validateExecCommand } from "./tool-bootstrap-core-registration.js";
13
+ export { enforceAbsoluteFloors } from "./tool-bootstrap-paths.js";
14
14
  export interface SandboxPermissionSnapshot {
15
15
  mode: PermissionMode;
16
16
  workdir: string;
@@ -20,12 +20,6 @@ export interface SandboxPermissionSnapshot {
20
20
  }
21
21
  /** Wire the OS-sandbox permission source (live rule-engine snapshot), or null to clear. */
22
22
  export declare function setSandboxPermissionSource(source: (() => SandboxPermissionSnapshot | undefined) | null): void;
23
- /** Set callback invoked after LLM-driven project switch. */
24
- export declare function setProjectSwitchCallback(cb: ((project: {
25
- id: string;
26
- name: string;
27
- workspaceDir: string;
28
- }) => void) | undefined): void;
29
23
  /**
30
24
  * Set task tool lifecycle hooks. Called from stdio-server when session starts.
31
25
  * Connects planning-task events to the HookRegistry.
@@ -44,17 +38,6 @@ export declare function setBackgroundTaskRuntime(manager: BackgroundTaskManager
44
38
  */
45
39
  export declare function setAskUserCallback(callback: ((questions: AskUserQuestion[]) => Promise<Record<string, string> | null>) | null): void;
46
40
  export declare function setBootstrapWorkdir(newWorkdir: string): void;
47
- /**
48
- * Enforce absolute, mode-independent floors. Returns an error message only for
49
- * dangers that are NEVER allowed regardless of permission mode, null otherwise.
50
- *
51
- * Workspace membership is NO LONGER decided here: cross-workspace access is owned
52
- * by the permission pipeline (the `tool.before_invoke` hook), which prompts in
53
- * `default` mode and allows in `auto`/`full_access`. This function only blocks
54
- * device/system paths that no mode should ever touch via file tools.
55
- */
56
- export declare function enforceAbsoluteFloors(resolved: string): string | null;
57
- export declare function validateExecCommand(command: string, _workdir: string): string | null;
58
41
  export interface BootstrapConfig {
59
42
  workdir?: string;
60
43
  toolCatalog?: ToolCatalog;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Tunable override store — the SINGLE write/read path for settings.tunables.
3
+ *
4
+ * Shared by the config.updateTunable RPC (UI settings page) and the `config`
5
+ * tool (conversational tuning), so both go through identical validation,
6
+ * persistence, and runtime sync. Values are hot: ModelRegistry.getTunable()
7
+ * re-reads settings.json on every call, so a persisted override takes effect
8
+ * on the next read with no restart.
9
+ */
10
+ import { type TunableDefaults } from "../runtime/config/tunable-defaults.js";
11
+ /** Read the current override map from settings.json (missing file → empty). */
12
+ export declare function readTunableOverrides(settingsPath: string): Record<string, unknown>;
13
+ /**
14
+ * Validate a tunable update against the declared defaults.
15
+ * Returns an error message, or null when the update is acceptable.
16
+ * Coercible values ("3" → 3, "true" → true) are NOT accepted here —
17
+ * callers wanting leniency must coerce before validating.
18
+ */
19
+ export declare function validateTunableUpdate(key: string, value: unknown): string | null;
20
+ /** Coerce a string value toward the tunable's declared type ("3"→3, "true"→true). */
21
+ export declare function coerceTunableValue(key: string, value: unknown): unknown;
22
+ /** Persist one override into settings.json and sync live runtime state. */
23
+ export declare function writeTunableOverride(settingsPath: string, key: string, value: unknown): Promise<void>;
24
+ /** Remove one override (value falls back to the declared default). */
25
+ export declare function clearTunableOverride(settingsPath: string, key: string): Promise<void>;
26
+ export type { TunableDefaults };
@@ -0,0 +1,29 @@
1
+ import type { AgentRpcError } from "../protocol/wire/index.js";
2
+ import type { MultiAgentHandlerHost } from "./multi-agent-handler-host.js";
3
+ import type { WorkflowHandlerHost } from "./handlers/workflow-handler.js";
4
+ /**
5
+ * WorkflowHostAdapter — the host the legacy `workflow.*` JSON-RPC domain binds to.
6
+ *
7
+ * The workflow handlers (workflow.create/run/list/onImMessage/onWebhook/…) need MORE than the
8
+ * agents/solo/product sub-host provides: `toolCatalog` (workflow `tool` nodes look up real
9
+ * qlogicagent tools via `findTool`) plus the lazy engine slots that `ensureWorkflowController`
10
+ * fills (controller/store/scheduler/processManager). The multi-agent sub-host has neither, so
11
+ * binding workflow there left `this.toolCatalog` undefined — a workflow `tool` node would throw
12
+ * "Cannot read properties of undefined (reading 'findTool')" at run time. This adapter supplies
13
+ * the missing pieces explicitly, mirroring createDreamHostAdapter / createAcpExtendedHostAdapter.
14
+ *
15
+ * `acpDetector` is sourced from the multi-agent sub-host so workflow `agent` nodes resolve the same
16
+ * canonical external descriptors that the `agents.*` domain configures. The engine slots are plain
17
+ * own-properties this (per-agent singleton) adapter owns and `ensureWorkflowController` mutates once;
18
+ * keeping them here means the controller it publishes via setWorkflowController stays a singleton and
19
+ * the multi-agent sub-host is no longer polluted with workflow state.
20
+ */
21
+ export interface WorkflowHostAdapterDeps {
22
+ multiAgentHost: MultiAgentHandlerHost;
23
+ getActiveProjectRoot(): string;
24
+ getToolCatalog(): WorkflowHandlerHost["toolCatalog"];
25
+ handleMcpToolCall: WorkflowHandlerHost["handleMcpToolCall"];
26
+ sendNotification(method: string, params: Record<string, unknown>): void;
27
+ sendResponse(id: string | number, result?: unknown, error?: AgentRpcError): void;
28
+ }
29
+ export declare function createWorkflowHostAdapter(deps: WorkflowHostAdapterDeps): WorkflowHandlerHost;
@@ -170,6 +170,12 @@ export interface HookRegistration<P extends HookPoint = HookPoint> {
170
170
  priority?: number;
171
171
  /** Optional label for debugging */
172
172
  label?: string;
173
+ /**
174
+ * Critical hooks are part of the execution preflight. If they throw, the
175
+ * registry returns an abort result instead of treating the failure as a
176
+ * non-blocking observer error.
177
+ */
178
+ critical?: boolean;
173
179
  }
174
180
  /**
175
181
  * Interface for a hook registry that manages hook handlers.
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Run History Store — durable per-workflow run records (闭环 "察" 半场).
3
+ *
4
+ * The checkpoint store (run-checkpoint-store.ts) is an execution cache that is
5
+ * DELETED when a run completes — it cannot answer "what did the last run do?".
6
+ * This store keeps a bounded, append-style history per workflow so the canvas
7
+ * can show past runs and per-node outputs:
8
+ *
9
+ * `<project>/.qlogicagent/workflows/<workflowId>/runs/history.json`
10
+ *
11
+ * Recording happens in WorkflowController.run() — the single choke point every
12
+ * trigger path goes through (manual RPC, cron scheduler, IM, webhook) — so
13
+ * scheduled runs are captured identically to manual ones.
14
+ *
15
+ * Node outputs are stored as TRUNCATED JSON previews (default-port items'
16
+ * `json`), not full PortMaps: history is for inspection, the checkpoint cache
17
+ * remains the execution-fidelity layer. Bounded to the most recent
18
+ * MAX_RUN_HISTORY entries; corrupt/missing history degrades to empty (history
19
+ * must never block a run).
20
+ */
21
+ import type { RunResult } from "./workflow-runtime.js";
22
+ export declare const MAX_RUN_HISTORY = 20;
23
+ export type RunHistoryStatus = "running" | "completed" | "failed" | "paused" | "skipped";
24
+ export interface RunNodeRecord {
25
+ /** Whether the node's executor actually ran (false = checkpoint cache hit). */
26
+ executed: boolean;
27
+ /** Truncated JSON preview of the node's output items (port → items[].json). */
28
+ preview: string;
29
+ }
30
+ export interface RunHistoryEntry {
31
+ runId: string;
32
+ status: RunHistoryStatus;
33
+ triggerType: string;
34
+ startedAt: string;
35
+ finishedAt?: string;
36
+ durationMs?: number;
37
+ error?: string;
38
+ /** nodeId → output record. Present once the run settles (not while running). */
39
+ nodes?: Record<string, RunNodeRecord>;
40
+ }
41
+ /** Summary row for list views — full node outputs stay behind get(). */
42
+ export type RunHistorySummary = Omit<RunHistoryEntry, "nodes">;
43
+ /** Build per-node output previews from a settled RunResult. */
44
+ export declare function buildNodeRecords(result: RunResult): Record<string, RunNodeRecord>;
45
+ export declare class WorkflowRunHistoryStore {
46
+ private readonly cwd;
47
+ constructor(cwd: string);
48
+ /** Record a run start. Prepends a "running" entry and prunes to the bound. */
49
+ begin(workflowId: string, entry: Pick<RunHistoryEntry, "runId" | "triggerType" | "startedAt">): Promise<void>;
50
+ /** Settle a run entry (status/outputs/error). Unknown runId is a no-op (pruned entry). */
51
+ finish(workflowId: string, runId: string, patch: Partial<Pick<RunHistoryEntry, "status" | "finishedAt" | "durationMs" | "error" | "nodes">>): Promise<void>;
52
+ /** Most-recent-first run summaries (no node outputs — those stay behind get()). */
53
+ list(workflowId: string): Promise<RunHistorySummary[]>;
54
+ /** Full entry incl. per-node output previews. */
55
+ get(workflowId: string, runId: string): Promise<RunHistoryEntry | undefined>;
56
+ private read;
57
+ private write;
58
+ }