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
@@ -2,6 +2,7 @@ import type { HookRegistry } from "../contracts/hooks.js";
2
2
  import type { AcpSessionMeta } from "../protocol/wire/index.js";
3
3
  import { createMemoryPrefetchState } from "../runtime/hooks/memory-hooks.js";
4
4
  import type { SessionState } from "../runtime/session/session-state.js";
5
+ import type { SessionHistoryCoordinator } from "./session-history-coordinator.js";
5
6
  /**
6
7
  * LLM config pinned on the session by the host (session/set_config_option /
7
8
  * session/set_model / the /model command). This is host-supplied INPUT — distinct
@@ -25,6 +26,7 @@ export interface AcpSessionHost {
25
26
  currentHooks: HookRegistry | null;
26
27
  currentSessionId: string;
27
28
  memoryPrefetchState: ReturnType<typeof createMemoryPrefetchState>;
29
+ sessionHistory: Pick<SessionHistoryCoordinator, "saveResumedSession" | "withResumedHistory">;
28
30
  sessionState: SessionState | null;
29
31
  sessionTaskDomain: unknown;
30
32
  cancelIdleDreamTimer(): void;
@@ -41,5 +43,6 @@ export interface AcpSessionHost {
41
43
  ensureModelRegistryHydrated?(): Promise<void>;
42
44
  getActiveProjectRoot(): string;
43
45
  log(message: string): void;
46
+ sendNotification(method: string, params: Record<string, unknown>): void;
44
47
  setActiveWorkdir(dir: string): void;
45
48
  }
@@ -2,7 +2,7 @@ import { Agent } from "../agent/agent.js";
2
2
  import type { AgentLogger, ToolInvoker } from "../agent/types.js";
3
3
  import type { HookRegistry } from "../contracts/hooks.js";
4
4
  import { type LLMTransport, type ProviderRegistry } from "./provider-core-facade.js";
5
- import type { ResolvedTextGenerationConfig } from "./model-client-resolver.js";
5
+ import { type ResolvedTextGenerationConfig } from "./model-client-resolver.js";
6
6
  export interface BuildCliAgentDeps {
7
7
  client: CliAgentClient;
8
8
  toolInvoker: ToolInvoker;
@@ -1,9 +1,5 @@
1
1
  import type { ToolCatalog } from "../../runtime/ports/index.js";
2
2
  export interface ConfigToolRegistrationDeps {
3
3
  toolCatalog: ToolCatalog;
4
- host: {
5
- readonly currentModel: string;
6
- readonly verbose: boolean;
7
- };
8
4
  }
9
- export declare function registerConfigTool({ host, toolCatalog }: ConfigToolRegistrationDeps): void;
5
+ export declare function registerConfigTool({ toolCatalog }: ConfigToolRegistrationDeps): void;
@@ -1,7 +1,11 @@
1
- import { type ConfigToolDeps } from "../../skills/tools/config-tool.js";
1
+ /**
2
+ * Config tool service — backs the `config` tool onto the REAL tunables system
3
+ * (settings.tunables.*), the same store the UI settings page manages via the
4
+ * config.updateTunable RPC. ModelRegistry.getTunable() re-reads settings.json
5
+ * per call, so every write here is hot — no restart needed.
6
+ */
7
+ import type { ConfigToolDeps } from "../../skills/tools/config-tool.js";
2
8
  export interface ConfigToolServiceOptions {
3
- currentModel: string;
4
- verbose: boolean;
5
- configFilePath?: string;
9
+ settingsPath?: string;
6
10
  }
7
- export declare function createConfigToolService(options: ConfigToolServiceOptions): ConfigToolDeps;
11
+ export declare function createConfigToolService(options?: ConfigToolServiceOptions): ConfigToolDeps;
@@ -4,6 +4,5 @@ import { type ConfigToolRegistrationDeps } from "./config-tool-bootstrap.js";
4
4
  import { type CronToolRegistrationDeps } from "./cron-tool-bootstrap.js";
5
5
  import { type MonitorToolRegistrationDeps } from "./monitor-tool-bootstrap.js";
6
6
  import { type TeamToolRegistrationDeps } from "./team-tool-bootstrap.js";
7
- import { type UtilityToolRegistrationDeps } from "./utility-tool-bootstrap.js";
8
- export type CoreToolSetRegistrationDeps = AgentToolRegistrationDeps & CheckpointToolRegistrationDeps & ConfigToolRegistrationDeps & CronToolRegistrationDeps & MonitorToolRegistrationDeps & Omit<TeamToolRegistrationDeps, "teamRegistry"> & Omit<UtilityToolRegistrationDeps, "teamRegistry">;
7
+ export type CoreToolSetRegistrationDeps = AgentToolRegistrationDeps & CheckpointToolRegistrationDeps & ConfigToolRegistrationDeps & CronToolRegistrationDeps & MonitorToolRegistrationDeps & Omit<TeamToolRegistrationDeps, "teamRegistry">;
9
8
  export declare function registerCoreToolSet(deps: CoreToolSetRegistrationDeps): void;
@@ -0,0 +1,12 @@
1
+ import type { CapabilityCategory } from "../../skills/portable-tool.js";
2
+ export interface SessionToolManifestEntry {
3
+ name: string;
4
+ label: string;
5
+ description: string;
6
+ category: CapabilityCategory;
7
+ /** Registered per-session by the runtime bootstrap, not in the static catalog. */
8
+ sessionScoped: true;
9
+ /** The live registration is deferred (loaded on demand via tool_search). */
10
+ deferred?: true;
11
+ }
12
+ export declare const SESSION_TOOL_MANIFEST: SessionToolManifestEntry[];
@@ -1,14 +1,14 @@
1
1
  /**
2
- * TeamRegistry — session-scoped roster shared by the team tool (producer)
3
- * and the send_message tool (consumer).
2
+ * TeamRegistry — session-scoped roster for the team tool: create registers
3
+ * members (producer), the send action routes messages to them (consumer).
4
4
  *
5
5
  * The team tool spawns each member as a real subprocess agent
6
- * (AgentProcessManager) and registers a delivery closure here. send_message
7
- * looks the target up by name or full member id and routes the message into
8
- * the member's process via that closure, returning the member's reply.
6
+ * (AgentProcessManager) and registers a delivery closure here. The send
7
+ * action looks the target up by name or full member id and routes the message
8
+ * into the member's process via that closure, returning the member's reply.
9
9
  *
10
- * This is the ONLY bridge between the two tools send_message has no other
11
- * way to reach team members, so an unregistered/dead target fails loud.
10
+ * This registry is the ONLY routing path to team members, so an
11
+ * unregistered/dead target fails loud.
12
12
  */
13
13
  export interface TeamRegistryMember {
14
14
  /** Full member id, e.g. "team-research-coder". */
@@ -48,7 +48,7 @@ export declare class TeamRegistry {
48
48
  /** Live roster (alive flag reflects the underlying process). */
49
49
  list(): TeamRegistryListEntry[];
50
50
  /**
51
- * Resolve a send_message `to` token to concrete members.
51
+ * Resolve a send `to` token to concrete members.
52
52
  * Accepts a member name ("coder"), a full member id ("team-x-coder"),
53
53
  * or "*" for broadcast to all alive members.
54
54
  * Returns [] when nothing matches (caller fails loud).
@@ -1,7 +1,6 @@
1
1
  import { createLspTool } from "../../skills/tools/lsp-tool.js";
2
- import { createReplTool } from "../../skills/tools/repl-tool.js";
3
2
  export interface DevToolRegistryOptions {
4
3
  workdir: string;
5
4
  }
6
- export type DevTool = ReturnType<typeof createReplTool> | ReturnType<typeof createLspTool>;
5
+ export type DevTool = ReturnType<typeof createLspTool>;
7
6
  export declare function buildDevTools(options: DevToolRegistryOptions): DevTool[];
@@ -0,0 +1,50 @@
1
+ /**
2
+ * GatewayRpcConnection — the JSON-RPC request lifecycle for the gateway contract.
3
+ *
4
+ * Owns the per-request bookkeeping: the gateway contract (dedup/settle/expire), the
5
+ * in-flight request ledger (id → meta), and the deadline timers; plus the wire-side
6
+ * response builders. Extracted from StdioServer to separate its "protocol routing"
7
+ * concern from its "runtime state container" concern — StdioServer keeps the
8
+ * transport, message dispatch, and ACP routing, and delegates the request-lifecycle
9
+ * mechanics here through thin sendResponse/sendError methods.
10
+ *
11
+ * It does NOT own the transport: the raw frame writer is injected via `write`, so the
12
+ * server stays in charge of transport ownership / start / close / ACP routing.
13
+ *
14
+ * Covered by stdio-server.contract.test.ts (contract gate, dedup, deadline expiry,
15
+ * late-response drop).
16
+ */
17
+ import { GatewayRpcContract, type AgentRpcError, type AgentRpcRequest } from "../protocol/wire/index.js";
18
+ export interface GatewayRpcConnectionDeps {
19
+ /** Raw transport send — writes one JSON-RPC frame to the wire. */
20
+ write: (msg: unknown) => void;
21
+ log: (message: string) => void;
22
+ }
23
+ export declare class GatewayRpcConnection {
24
+ private readonly contract;
25
+ private readonly inflight;
26
+ private readonly deadlineTimers;
27
+ private readonly write;
28
+ private readonly log;
29
+ constructor(deps: GatewayRpcConnectionDeps);
30
+ /** The gateway contract — exposed for control-handler metrics/cancel. */
31
+ get rpcContract(): GatewayRpcContract;
32
+ /** True while a request id is in flight (no response settled yet). */
33
+ hasInFlight(id: string | number): boolean;
34
+ /**
35
+ * Run the gateway contract gate for an inbound request (caller guarantees the
36
+ * id is present and the method is not meta-optional). Returns true if the caller
37
+ * should dispatch; false if the request was rejected/deduped — in which case a
38
+ * response has already been written.
39
+ */
40
+ begin(id: string | number, msg: AgentRpcRequest): boolean;
41
+ sendResponse(id: string | number, result?: unknown, error?: AgentRpcError): void;
42
+ /** Convenience over sendResponse for handlers that build the error inline. */
43
+ sendError(id: string | number, code: AgentRpcError["code"], message: string, data?: unknown): void;
44
+ /** Clear the in-flight ledger + deadline timers (server shutdown). */
45
+ dispose(): void;
46
+ private clearLifecycle;
47
+ private sendContractError;
48
+ private sendContractErrorOrResult;
49
+ private scheduleDeadline;
50
+ }
@@ -14,11 +14,12 @@ import { SessionState } from "../../runtime/session/session-state.js";
14
14
  import { createMemoryPrefetchState } from "../../runtime/hooks/memory-hooks.js";
15
15
  import { type AgentRpcError, type AgentRpcErrorCode, type AgentRpcRequest } from "../../protocol/wire/index.js";
16
16
  import type { SessionHistoryCoordinator } from "../session-history-coordinator.js";
17
+ import type { TaskDomain } from "../../runtime/prompt/task-domain.js";
17
18
  export interface SessionHandlerHost {
18
19
  currentSessionId?: string;
19
20
  currentModel?: string;
20
21
  sessionState?: SessionState | null;
21
- sessionTaskDomain?: unknown;
22
+ sessionTaskDomain?: TaskDomain;
22
23
  memoryPrefetchState?: ReturnType<typeof createMemoryPrefetchState>;
23
24
  sessionHistory: Pick<SessionHistoryCoordinator, "saveResumedSession">;
24
25
  log(message: string): void;
@@ -11,6 +11,7 @@ import type { AcpDetector } from "../../runtime/infra/acp-detector.js";
11
11
  import { type AgentRpcError, type AgentRpcRequest } from "../../protocol/wire/index.js";
12
12
  import { WorkflowController } from "../../orchestration/workflow/workflow-controller.js";
13
13
  import { WorkflowStore } from "../../orchestration/workflow/workflow-store.js";
14
+ import { WorkflowRunHistoryStore } from "../../orchestration/workflow/run-history-store.js";
14
15
  import { WorkflowScheduler } from "../../orchestration/workflow/workflow-scheduler.js";
15
16
  import type { ToolCatalog } from "../../runtime/ports/index.js";
16
17
  export interface WorkflowCoordinatorHost {
@@ -23,6 +24,7 @@ export interface WorkflowCoordinatorHost {
23
24
  workflowStore: WorkflowStore | null;
24
25
  workflowProcessManager: AgentProcessManager | null;
25
26
  workflowScheduler: WorkflowScheduler | null;
27
+ workflowRunHistory: WorkflowRunHistoryStore | null;
26
28
  }
27
29
  export interface WorkflowHandlerHost extends WorkflowCoordinatorHost {
28
30
  sendResponse(id: string | number, result?: unknown, error?: AgentRpcError): void;
@@ -39,3 +41,11 @@ export declare function handleWorkflowList(this: WorkflowHandlerHost, msg: Agent
39
41
  export declare function handleWorkflowDelete(this: WorkflowHandlerHost, msg: AgentRpcRequest): Promise<void>;
40
42
  export declare function handleWorkflowOnImMessage(this: WorkflowHandlerHost, msg: AgentRpcRequest): Promise<void>;
41
43
  export declare function handleWorkflowOnWebhook(this: WorkflowHandlerHost, msg: AgentRpcRequest): Promise<void>;
44
+ /** `workflow.revisions` — newest-first def-revision summaries for the undo/history UI. */
45
+ export declare function handleWorkflowRevisions(this: WorkflowHandlerHost, msg: AgentRpcRequest): Promise<void>;
46
+ /** `workflow.revert` — re-apply a stored revision as a NEW rev (git-revert semantics). */
47
+ export declare function handleWorkflowRevert(this: WorkflowHandlerHost, msg: AgentRpcRequest): Promise<void>;
48
+ /** `workflow.runs` — newest-first run summaries (status/trigger/timing; outputs stay behind runDetail). */
49
+ export declare function handleWorkflowRuns(this: WorkflowHandlerHost, msg: AgentRpcRequest): Promise<void>;
50
+ /** `workflow.runDetail` — one run incl. per-node output previews (画布点节点看产出). */
51
+ export declare function handleWorkflowRunDetail(this: WorkflowHandlerHost, msg: AgentRpcRequest): Promise<void>;
@@ -1,3 +1,4 @@
1
+ import type { KeyHandle } from "../runtime/infra/key-pool.js";
1
2
  import type { ModelPurpose } from "../runtime/infra/model-registry.js";
2
3
  import type { TurnConfig } from "../agent/types.js";
3
4
  import { type LLMTransport, type ProviderRegistry } from "./provider-core-facade.js";
@@ -13,10 +14,18 @@ export interface ResolvedTextGenerationConfig {
13
14
  baseUrl?: string;
14
15
  configKey: string;
15
16
  }
16
- export declare function resolveTextGenerationConfig(config: TurnConfig, log?: (message: string) => void): ResolvedTextGenerationConfig | null;
17
- export declare function resolveModelClientForPurpose(deps: {
17
+ export type KeyHandleProvider = () => KeyHandle | null | undefined;
18
+ type ModelClientResolverDeps = {
18
19
  purpose: ModelPurpose;
19
20
  providerRegistry: ProviderRegistry;
20
21
  currentProvider: string;
21
22
  currentTransport: LLMTransport | null;
22
- }): ResolvedModelClient | null;
23
+ };
24
+ export declare function wrapTransportWithKeyHandleProvider(transport: LLMTransport, acquireKeyHandle: KeyHandleProvider): LLMTransport;
25
+ export declare function wrapTransportWithKeyHandle(transport: LLMTransport, keyHandle?: KeyHandle): LLMTransport;
26
+ export declare function takeTextGenerationKeyHandleProvider(config: ResolvedTextGenerationConfig): KeyHandleProvider;
27
+ export declare function releaseUnusedTextGenerationKeyHandle(config: ResolvedTextGenerationConfig): void;
28
+ export declare function resolveTextGenerationConfig(config: TurnConfig, log?: (message: string) => void): ResolvedTextGenerationConfig | null;
29
+ export declare function resolveModelClientForPurpose(deps: ModelClientResolverDeps): ResolvedModelClient | null;
30
+ export declare function withResolvedModelClient<T>(deps: ModelClientResolverDeps, fn: (client: ResolvedModelClient) => T | Promise<T>): Promise<T | null>;
31
+ export {};
@@ -0,0 +1,47 @@
1
+ /**
2
+ * ResolvedAgentCache — the DERIVED resolved-agent state for a turn.
3
+ *
4
+ * Holds the Agent plus the LLM client snapshot (transport + apiKey/model/provider/
5
+ * baseUrl) that resolveAgent() produced for the current textGeneration config,
6
+ * keyed by the resolved config key. Extracted from StdioServer to localize the
7
+ * one subtle invariant the god-object carried inline:
8
+ *
9
+ * - invalidate(): wipe EVERYTHING. Called on a ModelRegistry change — the resolved
10
+ * LLM client is now stale, so the next turn must re-resolve from scratch.
11
+ * - forgetAgent(): drop only the Agent + its config key, forcing a re-resolve on
12
+ * the next turn while leaving the last client snapshot readable. Called on
13
+ * session dispose (matches the prior `agent = null; lastLlmConfigKey = ""`).
14
+ *
15
+ * This is DERIVED state ONLY. Host-pinned per-session LLM config (sessionLlmConfig)
16
+ * lives on the server and is NEVER touched here — a background catalog hydration
17
+ * finishing between a member's set_config pin and its first prompt must not strip
18
+ * its provider.
19
+ */
20
+ import type { Agent } from "../agent/agent.js";
21
+ import type { LLMTransport } from "./provider-core-facade.js";
22
+ export interface ResolvedAgentSnapshot {
23
+ agent: Agent;
24
+ transport: LLMTransport;
25
+ apiKey: string;
26
+ model: string;
27
+ provider: string;
28
+ baseUrl: string;
29
+ configKey: string;
30
+ }
31
+ export declare class ResolvedAgentCache {
32
+ agent: Agent | null;
33
+ transport: LLMTransport | null;
34
+ apiKey: string;
35
+ model: string;
36
+ provider: string;
37
+ baseUrl: string;
38
+ private configKey;
39
+ /** True when a cached Agent matches the given resolved config key. */
40
+ matches(configKey: string): boolean;
41
+ /** Store the freshly resolved Agent + LLM client snapshot. */
42
+ store(snapshot: ResolvedAgentSnapshot): void;
43
+ /** Drop only the Agent + config key — force re-resolve, keep the last snapshot. */
44
+ forgetAgent(): void;
45
+ /** Wipe ALL derived state — the resolved client is stale (registry change). */
46
+ invalidate(): void;
47
+ }
@@ -1,8 +1,62 @@
1
1
  import type { AgentRpcRequest } from "../protocol/wire/index.js";
2
+ import { type CommunityHandlerHost } from "./handlers/community-handler.js";
3
+ import { type ConfigHandlerHost } from "./handlers/config-handler.js";
4
+ import { type ControlHandlerHost } from "./handlers/control-handler.js";
5
+ import { type FilesHandlerHost } from "./handlers/files-handler.js";
6
+ import { type MediaHandlerHost } from "./handlers/media-handler.js";
7
+ import { type MemoryHandlerHost } from "./handlers/memory-handler.js";
8
+ import { type PetConfirmHandlerHost } from "./handlers/pet-confirm-handler.js";
9
+ import { type PetHandlerHost } from "./handlers/pet-handler.js";
10
+ import { type WorkflowHandlerHost } from "./handlers/workflow-handler.js";
11
+ import { type ProjectHandlerHost } from "./handlers/project-handler.js";
12
+ import { type SessionHandlerHost } from "./handlers/session-handler.js";
13
+ import { type SettingsHandlerHost } from "./handlers/settings-handler.js";
14
+ import { type SkillsHandlerHost } from "./handlers/skills-handler.js";
15
+ import { type TurnControlHandlerHost } from "./handlers/turn-handler.js";
16
+ import { type DreamHandlerHost } from "./handlers/dream-handler.js";
2
17
  import type { MultiAgentHandlerHost } from "./multi-agent-handler-host.js";
3
18
  export type RpcMethodHandler = (msg: AgentRpcRequest) => void;
4
- type RpcRegistryHost = Record<string, unknown> & {
5
- multiAgentHandlerHost?: MultiAgentHandlerHost;
6
- };
7
- export declare function createRpcMethodRegistry(host: RpcRegistryHost): ReadonlyMap<string, RpcMethodHandler>;
8
- export {};
19
+ /**
20
+ * Per-domain host adapters the RPC registry binds handlers to. Each field is
21
+ * typed to exactly ONE handler's narrow contract, so the host (StdioServer)
22
+ * builds the bundle under COMPILER CHECK: for every domain it passes `this`
23
+ * directly, tsc verifies StdioServer satisfies that interface — if a member a
24
+ * handler needs ever disappears, the build breaks at the bundle literal instead
25
+ * of failing at runtime.
26
+ *
27
+ * A few domains' contracts are deliberately divergent views of shared state
28
+ * (e.g. `memoryProvider` is `MemoryHandlerProvider` for memory but
29
+ * `PetMemoryProviderLike` for pet; `sessionState` differs likewise). Those can't
30
+ * be one structural type, so the host supplies them via a localized cast at the
31
+ * bundle literal — the cast surface is one member-domain, not the whole host.
32
+ *
33
+ * The pattern mirrors the existing createDreamHandlerHost / createMultiAgentHandlerHost
34
+ * adapters, just applied uniformly across every RPC domain.
35
+ */
36
+ export interface RpcHandlerHosts {
37
+ config: ConfigHandlerHost;
38
+ control: ControlHandlerHost;
39
+ session: SessionHandlerHost;
40
+ memory: MemoryHandlerHost;
41
+ files: FilesHandlerHost;
42
+ media: MediaHandlerHost;
43
+ skills: SkillsHandlerHost;
44
+ pet: PetHandlerHost;
45
+ petConfirm: PetConfirmHandlerHost;
46
+ project: ProjectHandlerHost;
47
+ community: CommunityHandlerHost;
48
+ settings: SettingsHandlerHost;
49
+ dream: DreamHandlerHost;
50
+ turn: TurnControlHandlerHost;
51
+ /** agents/solo/product are served by the multi-agent sub-host. */
52
+ multiAgent: MultiAgentHandlerHost;
53
+ /**
54
+ * workflow.* binds to its own host: it needs `toolCatalog` plus the lazy engine slots
55
+ * (controller/store/scheduler/processManager) that the multi-agent sub-host lacks. The host
56
+ * (StdioServer) supplies a dedicated WorkflowHostAdapter that sources acpDetector from the
57
+ * multi-agent sub-host and toolCatalog from the runtime — so this binding is compiler-checked
58
+ * like every other domain, with no cast.
59
+ */
60
+ workflow: WorkflowHandlerHost;
61
+ }
62
+ export declare function createRpcMethodRegistry(host: RpcHandlerHosts): ReadonlyMap<string, RpcMethodHandler>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * SessionContext — the active session/turn identity + lifecycle state.
3
+ *
4
+ * The "who/what is running right now" the server tracks across the current session
5
+ * and turn: the session id, the in-flight turn id, the session cost/state snapshot,
6
+ * sticky task domain, host-pinned LLM config, and the ACP session _meta supplement.
7
+ *
8
+ * Extracted from StdioServer so its runtime-state-container concern is one named
9
+ * holder rather than six loose fields on the god-object. It is a plain mutable
10
+ * holder (no invariant beyond field cohesion); the server exposes same-named
11
+ * get/set accessors that delegate here, so every existing reader AND writer —
12
+ * including handlers bound via the RPC host cast (session.create, thread.turn,
13
+ * set_config) — keeps working unchanged.
14
+ */
15
+ import type { SessionState } from "../runtime/session/session-state.js";
16
+ import type { SessionLlmConfig } from "./acp-session-host.js";
17
+ import type { TaskDomain } from "../runtime/prompt/task-domain.js";
18
+ export declare class SessionContext {
19
+ /** Active session id (chatId for desktop; group key pattern for groups). */
20
+ sessionId: string;
21
+ /** In-flight turn id. */
22
+ turnId: string;
23
+ /** Session cost/state snapshot (null until a session is resolved). */
24
+ state: SessionState | null;
25
+ /** Session-level task domain stickiness — survives across turns within a session. */
26
+ taskDomain: TaskDomain | undefined;
27
+ /** Host-pinned per-session LLM config (session/set_config_option · set_model · /model).
28
+ * NEVER wiped by ModelRegistry churn — distinct from the DERIVED ResolvedAgentCache. */
29
+ llmConfig: SessionLlmConfig;
30
+ /** ACP session-level context supplement (_meta from session/new), inherited by every prompt. */
31
+ acpMeta: Record<string, unknown> | null;
32
+ }
@@ -25,3 +25,10 @@ export interface SkillMetaToolRegistrationContext extends SkillMetaToolBootstrap
25
25
  }
26
26
  export declare const skillMetaToolRegistrationModule: import("../runtime/ports/tool-contracts.js").ToolRegistrationModule<SkillMetaToolRegistrationContext>;
27
27
  export declare function configureSkillMetaToolBootstrap(host: SkillMetaToolHost, deps: SkillMetaToolBootstrapDeps): void;
28
+ /**
29
+ * Resolve a supporting-file path inside a skill folder.
30
+ * Returns the absolute target, or null when the path escapes the skill dir
31
+ * or targets SKILL.md itself (SKILL.md must go through the validated
32
+ * content path, never the raw supporting-file write).
33
+ */
34
+ export declare function resolveSupportingFilePath(skillDir: string, filePath: string): string | null;
@@ -0,0 +1,18 @@
1
+ import type { NotificationMethod, NotificationMethodMap } from "../protocol/notifications.js";
2
+ import { AcpServer, type AcpRequestHandler } from "../transport/acp-server.js";
3
+ import type { Transport } from "./transport.js";
4
+ export declare class StdioAcpProtocolCoordinator {
5
+ private server;
6
+ get active(): boolean;
7
+ init(transport: Transport, handler: AcpRequestHandler, options: {
8
+ verbose: boolean;
9
+ }): void;
10
+ getServer(): AcpServer | null;
11
+ dispatchMessage(message: unknown): void;
12
+ hasSession(sessionId: string): boolean;
13
+ getPermissionSession(sessionId: string): {
14
+ sessionId: string;
15
+ requestPermission: AcpServer["requestPermission"];
16
+ } | undefined;
17
+ emitUpdate<M extends NotificationMethod>(sessionId: string, method: M, params: NotificationMethodMap[M]): boolean;
18
+ }
@@ -0,0 +1,3 @@
1
+ import type { CliAcpRequestHandlerHost } from "./cli-acp-request-handler.js";
2
+ export type StdioAcpRequestHostSource = Pick<CliAcpRequestHandlerHost, "activeTurn" | "acpSessionMeta" | "currentHooks" | "currentSessionId" | "currentTurnId" | "memoryPrefetchState" | "permissionChecker" | "sessionHistory" | "sessionLlmConfig" | "sessionState" | "sessionTaskDomain" | "cancelIdleDreamTimer" | "disposeSessionRuntime" | "enableIdleDream" | "ensureDefaultProject" | "ensureModelRegistryHydrated" | "getActiveProjectRoot" | "log" | "sendNotification" | "setActiveWorkdir">;
3
+ export declare function createStdioAcpRequestHandlerHost(host: StdioAcpRequestHostSource): CliAcpRequestHandlerHost;
@@ -0,0 +1,50 @@
1
+ import type { LLMRequest } from "../agent/types.js";
2
+ import type { ModelPurpose } from "../runtime/infra/model-registry.js";
3
+ import type { RpcHandlerHosts } from "./rpc-registry.js";
4
+ type DirectStdioRpcHost = RpcHandlerHosts["config"] & RpcHandlerHosts["control"] & RpcHandlerHosts["files"] & RpcHandlerHosts["skills"] & RpcHandlerHosts["project"] & RpcHandlerHosts["community"] & RpcHandlerHosts["settings"] & RpcHandlerHosts["petConfirm"] & {
5
+ readonly multiAgentHandlerHost: RpcHandlerHosts["multiAgent"];
6
+ readonly workflowHandlerHost: RpcHandlerHosts["workflow"];
7
+ };
8
+ type StdioRpcAdapterSource = DirectStdioRpcHost & {
9
+ activeTurn: RpcHandlerHosts["turn"]["activeTurn"];
10
+ currentSessionId: NonNullable<RpcHandlerHosts["session"]["currentSessionId"]>;
11
+ currentModel: NonNullable<RpcHandlerHosts["session"]["currentModel"]>;
12
+ sessionState: RpcHandlerHosts["session"]["sessionState"];
13
+ sessionTaskDomain: RpcHandlerHosts["session"]["sessionTaskDomain"];
14
+ memoryPrefetchState: NonNullable<RpcHandlerHosts["session"]["memoryPrefetchState"]>;
15
+ sessionHistory: RpcHandlerHosts["session"]["sessionHistory"];
16
+ currentHooks: RpcHandlerHosts["dream"]["currentHooks"];
17
+ permissionChecker: RpcHandlerHosts["turn"]["permissionChecker"];
18
+ mediaClient: RpcHandlerHosts["media"]["mediaClient"];
19
+ memoryProvider: RpcHandlerHosts["memory"]["memoryProvider"];
20
+ memoryDreamProvider: RpcHandlerHosts["dream"]["memoryProvider"];
21
+ memoryUserId: NonNullable<RpcHandlerHosts["memory"]["memoryUserId"]>;
22
+ pendingAskUser: RpcHandlerHosts["turn"]["pendingAskUser"];
23
+ petRuntime: RpcHandlerHosts["pet"]["petRuntime"];
24
+ verbose: NonNullable<RpcHandlerHosts["dream"]["verbose"]>;
25
+ resolveClientForPurpose(purpose: ModelPurpose): {
26
+ transport: {
27
+ stream(request: LLMRequest, apiKey: string): AsyncIterable<{
28
+ type: string;
29
+ text?: string;
30
+ }>;
31
+ };
32
+ apiKey: string;
33
+ model: string;
34
+ } | null;
35
+ ensureMemoryProvider: NonNullable<RpcHandlerHosts["memory"]["ensureMemoryProvider"]>;
36
+ ensureModelRegistryHydrated: NonNullable<RpcHandlerHosts["pet"]["ensureModelRegistryHydrated"]>;
37
+ enableIdleDream: NonNullable<RpcHandlerHosts["session"]["enableIdleDream"]>;
38
+ configureTurnMedia: NonNullable<RpcHandlerHosts["pet"]["configureTurnMedia"]>;
39
+ sendError: NonNullable<RpcHandlerHosts["session"]["sendError"]>;
40
+ createDreamHandlerHost(): RpcHandlerHosts["dream"];
41
+ };
42
+ /**
43
+ * Build the per-domain handler-host bundle the RPC registry binds to.
44
+ *
45
+ * Domains whose contracts StdioServer satisfies directly stay compiler-checked
46
+ * through DirectStdioRpcHost. Stateful domains receive explicit adapters so
47
+ * handler contracts stay narrow without domain-level casts.
48
+ */
49
+ export declare function createStdioRpcHandlerHosts<Host extends StdioRpcAdapterSource>(host: Host): RpcHandlerHosts;
50
+ export {};