qlogicagent 1.1.0 → 1.2.0

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 (66) hide show
  1. package/dist/agent.js +8 -6
  2. package/dist/cli.js +258 -214
  3. package/dist/index.js +258 -214
  4. package/dist/orchestration.js +12 -9
  5. package/dist/types/agent/tool-loop.d.ts +22 -0
  6. package/dist/types/agent/types.d.ts +32 -0
  7. package/dist/types/cli/stdio-server.d.ts +96 -1
  8. package/dist/types/cli/tool-bootstrap.d.ts +8 -1
  9. package/dist/types/llm/gemini-schema-utils.d.ts +17 -0
  10. package/dist/types/llm/index.d.ts +11 -2
  11. package/dist/types/llm/media-transport.d.ts +28 -3
  12. package/dist/types/llm/model-detection.d.ts +22 -0
  13. package/dist/types/llm/provider-def.d.ts +17 -4
  14. package/dist/types/llm/transport.d.ts +60 -2
  15. package/dist/types/llm/transports/gemini-cache-api.d.ts +86 -0
  16. package/dist/types/llm/transports/gemini-file-api.d.ts +90 -0
  17. package/dist/types/llm/transports/gemini-generatecontent.d.ts +52 -0
  18. package/dist/types/llm/transports/gemini-lyria-realtime.d.ts +117 -0
  19. package/dist/types/llm/transports/gemini-media.d.ts +40 -8
  20. package/dist/types/llm/transports/minimax-media.d.ts +34 -5
  21. package/dist/types/llm/transports/openai-responses.d.ts +60 -0
  22. package/dist/types/llm/transports/qwen-media.d.ts +32 -7
  23. package/dist/types/llm/transports/realtime-transport.d.ts +1 -1
  24. package/dist/types/llm/transports/volcengine-media.d.ts +10 -2
  25. package/dist/types/llm/transports/zhipu-media.d.ts +24 -2
  26. package/dist/types/orchestration/agent-instance.d.ts +58 -0
  27. package/dist/types/orchestration/dag-scheduler.d.ts +72 -0
  28. package/dist/types/orchestration/product-budget.d.ts +56 -0
  29. package/dist/types/orchestration/product-checkpoint.d.ts +46 -0
  30. package/dist/types/orchestration/product-persistence.d.ts +40 -0
  31. package/dist/types/orchestration/product-worktree.d.ts +13 -0
  32. package/dist/types/orchestration/solo-evaluator.d.ts +59 -0
  33. package/dist/types/orchestration/subagent/fork-subagent.d.ts +2 -0
  34. package/dist/types/orchestration/subagent/task-types.d.ts +4 -0
  35. package/dist/types/orchestration/tool-cascade.d.ts +2 -2
  36. package/dist/types/protocol/methods.d.ts +92 -0
  37. package/dist/types/protocol/notifications.d.ts +162 -0
  38. package/dist/types/runtime/infra/acp-detector.d.ts +36 -0
  39. package/dist/types/runtime/infra/acp-detector.test.d.ts +1 -0
  40. package/dist/types/runtime/infra/acp-protocol-adapter.d.ts +73 -0
  41. package/dist/types/runtime/infra/acp-protocol-adapter.test.d.ts +1 -0
  42. package/dist/types/runtime/infra/acp-types.d.ts +397 -0
  43. package/dist/types/runtime/infra/acp-usage-tracker.d.ts +46 -0
  44. package/dist/types/runtime/infra/acp-usage-tracker.test.d.ts +1 -0
  45. package/dist/types/runtime/infra/agent-config-store.d.ts +30 -0
  46. package/dist/types/runtime/infra/agent-config-store.test.d.ts +1 -0
  47. package/dist/types/runtime/infra/agent-paths.d.ts +8 -0
  48. package/dist/types/runtime/infra/agent-process.d.ts +280 -0
  49. package/dist/types/runtime/infra/agent-process.test.d.ts +1 -0
  50. package/dist/types/runtime/infra/index.d.ts +10 -0
  51. package/dist/types/runtime/infra/mcp-bridge.d.ts +166 -0
  52. package/dist/types/runtime/infra/mcp-bridge.test.d.ts +1 -0
  53. package/dist/types/runtime/infra/model-id-translator.d.ts +22 -0
  54. package/dist/types/runtime/infra/model-id-translator.test.d.ts +1 -0
  55. package/dist/types/runtime/infra/skill-injector.d.ts +51 -0
  56. package/dist/types/runtime/infra/skill-injector.test.d.ts +1 -0
  57. package/dist/types/runtime/infra/worktree-backend.d.ts +1 -0
  58. package/dist/types/runtime/prompt/environment-context.d.ts +6 -0
  59. package/dist/types/runtime/session/session-persistence.d.ts +9 -8
  60. package/dist/types/runtime/session/session-state.d.ts +3 -31
  61. package/dist/types/skills/index.d.ts +2 -10
  62. package/dist/types/skills/tools/skill-tool.d.ts +101 -0
  63. package/dist/types/skills/tools/team-tool.d.ts +23 -1
  64. package/package.json +1 -1
  65. package/dist/types/runtime/session/session-memory.d.ts +0 -90
  66. package/dist/types/skills/memory/memory-extractor.d.ts +0 -64
@@ -0,0 +1,280 @@
1
+ /**
2
+ * Agent Process Manager — CC tmux-aligned subprocess isolation.
3
+ *
4
+ * Spawns team member agents as independent child processes, each with:
5
+ * - Own cwd (set to worktree path for git isolation)
6
+ * - Own stdin/stdout JSON-RPC transport
7
+ * - Own memory + tool context (no shared process.cwd)
8
+ * - Lifecycle tracking (PID, health, abort)
9
+ *
10
+ * CC does this via tmux split-pane + `claude --agent-id ...` commands.
11
+ * We spawn `node dist/cli.js` as child processes with JSON-RPC stdio.
12
+ *
13
+ * Reference: claude-code-haha/src/utils/swarm/spawnMultiAgent.ts
14
+ * Reference: claude-code-haha/src/utils/swarm/spawnUtils.ts
15
+ */
16
+ import type { ExternalAgentDescriptor, McpServerConfig } from "./acp-types.js";
17
+ import type { AgentConfig } from "./acp-types.js";
18
+ import { AcpUsageTracker } from "./acp-usage-tracker.js";
19
+ export interface AgentProcessConfig {
20
+ /** Unique member ID (e.g. "team-research-coder"). */
21
+ memberId: string;
22
+ /** Display name. */
23
+ name: string;
24
+ /** Working directory for this agent (worktree path). */
25
+ cwd: string;
26
+ /** Initial task prompt sent after handshake. */
27
+ prompt: string;
28
+ /** Environment variables to forward (subset of parent env). */
29
+ env?: Record<string, string>;
30
+ /** Agent type hint for the child (sets system prompt behavior). */
31
+ agentType?: string;
32
+ /** Model override for the child. */
33
+ model?: string;
34
+ /** API key (forwarded via env). */
35
+ apiKey?: string;
36
+ /** Base URL for LLM API. */
37
+ baseUrl?: string;
38
+ /** Enable verbose logging in child. */
39
+ verbose?: boolean;
40
+ /** External ACP agent descriptor (if set, spawn via ACP protocol). */
41
+ external?: ExternalAgentDescriptor;
42
+ /** MCP server configs to inject into ACP session (only for external agents). */
43
+ mcpServers?: McpServerConfig[];
44
+ /** System prompt to inject into ACP session. */
45
+ systemPrompt?: string;
46
+ }
47
+ /** Snapshot of ongoing media generation progress reported by a child agent. */
48
+ export interface MediaProgressSnapshot {
49
+ /** Provider-specific task ID (e.g. volcengine job id). */
50
+ taskId: string;
51
+ /** Media type ("video" | "image" | "tts" | "3d"). */
52
+ mediaType: string;
53
+ /** Estimated completion 0-100. */
54
+ percent: number;
55
+ /** Provider status label (e.g. "queuing", "running", "processing"). */
56
+ status: string;
57
+ /** Which provider. */
58
+ provider?: string;
59
+ /** When this snapshot was last updated. */
60
+ updatedAt: number;
61
+ }
62
+ export interface AgentProcessHandle {
63
+ /** Process identifier for this agent. */
64
+ memberId: string;
65
+ /** Display name. */
66
+ name: string;
67
+ /** OS process ID (-1 if not spawned). */
68
+ pid: number;
69
+ /** Working directory. */
70
+ cwd: string;
71
+ /** Current lifecycle state. */
72
+ state: "starting" | "ready" | "running" | "completed" | "failed" | "killed";
73
+ /** Session ID assigned by the child (after initialize). */
74
+ sessionId?: string;
75
+ /** Final result text (after turn completes). */
76
+ resultText?: string;
77
+ /** Error message if failed. */
78
+ error?: string;
79
+ /** Spawn timestamp. */
80
+ startedAt: number;
81
+ /** End timestamp. */
82
+ endedAt?: number;
83
+ /** Latest media generation progress (auto-captured from child turn.media_progress). */
84
+ mediaProgress?: MediaProgressSnapshot;
85
+ /** Last tool call name seen from child (from turn.tool_call notification). */
86
+ lastToolCall?: string;
87
+ /** Last status text from child (from turn.delta notification). */
88
+ lastDelta?: string;
89
+ /** Last delta timestamp. */
90
+ lastActivityAt?: number;
91
+ /** Whether the ACP agent supports session/resume (D-1). */
92
+ supportsResume?: boolean;
93
+ }
94
+ /** Callbacks for process lifecycle events. */
95
+ export interface AgentProcessCallbacks {
96
+ /** Called when child emits a JSON-RPC notification. */
97
+ onNotification?: (memberId: string, method: string, params: unknown) => void;
98
+ /** Called when child process state changes. */
99
+ onStateChange?: (memberId: string, state: AgentProcessHandle["state"]) => void;
100
+ /** Called when child process exits. */
101
+ onExit?: (memberId: string, code: number | null, signal: string | null) => void;
102
+ /** Called when MCP bridge server proxies a tool call from an external agent. */
103
+ onMcpToolCall?: (memberId: string, tool: string, args: Record<string, unknown>) => Promise<unknown>;
104
+ /** Logger. */
105
+ log?: {
106
+ info(msg: string): void;
107
+ warn(msg: string): void;
108
+ debug?(msg: string): void;
109
+ };
110
+ /** Session directory for stderr logs. If set, ACP agent stderr is written to {sessionDir}/{agentId}.stderr.log. */
111
+ sessionDir?: string;
112
+ }
113
+ /**
114
+ * Build LLM-related environment variables for an external ACP teammate.
115
+ *
116
+ * Priority chain:
117
+ * 1. Per-agent override (AgentConfig.apiKey / baseUrl)
118
+ * 2. Gateway proxy mode (all requests through shared gateway)
119
+ * 3. Inherit from qlogicagent's own env
120
+ *
121
+ * Handles the asymmetry between agents that support base URL override
122
+ * (can redirect to gateway) vs those that don't (only API key forwarding).
123
+ */
124
+ export declare function buildLlmEnvForTeammate(agentId: string, agentConfig: AgentConfig | null, gatewayUrl: string | undefined): Record<string, string>;
125
+ /** Fault severity levels for ACP agent errors. */
126
+ export declare const ACP_FAULT_LEVEL: {
127
+ /** Unrecoverable — agent binary missing, permission denied, etc. */
128
+ readonly FATAL: "fatal";
129
+ /** Retriable — spawn timeout, handshake timeout, transient crash. */
130
+ readonly RETRIABLE: "retriable";
131
+ /** Warning — non-critical issue (e.g. degraded capabilities). */
132
+ readonly WARN: "warn";
133
+ };
134
+ export type AcpFaultLevel = (typeof ACP_FAULT_LEVEL)[keyof typeof ACP_FAULT_LEVEL];
135
+ /**
136
+ * Manages a pool of child agent processes.
137
+ * Each child is a `qlogicagent` subprocess using JSON-RPC over stdio.
138
+ */
139
+ export declare class AgentProcessManager {
140
+ private processes;
141
+ private callbacks;
142
+ private cliBinaryPath;
143
+ private mcpBridgeScriptPath;
144
+ constructor(callbacks?: AgentProcessCallbacks);
145
+ /** Format: [ISO] [level] [agent:id] [phase] message */
146
+ private slog;
147
+ /** Spawn a child agent process in the given cwd. */
148
+ spawn(config: AgentProcessConfig): Promise<AgentProcessHandle>;
149
+ /**
150
+ * Send a task to a child agent (e.g. thread.turn).
151
+ * Returns the JSON-RPC result.
152
+ */
153
+ sendTask(memberId: string, prompt: string, options?: {
154
+ model?: string;
155
+ apiKey?: string;
156
+ baseUrl?: string;
157
+ sessionId?: string;
158
+ timeout?: number;
159
+ }): Promise<unknown>;
160
+ /** Send a raw JSON-RPC request to a child. */
161
+ sendRpc(memberId: string, method: string, params?: unknown, timeoutMs?: number): Promise<unknown>;
162
+ /**
163
+ * Send a long-running task to a child agent with heartbeat keepalive.
164
+ *
165
+ * Unlike `sendTask()` (which blocks for up to 5 minutes), this method:
166
+ * 1. Dispatches the task via `thread.turn`
167
+ * 2. Periodically sends `ping` RPCs to detect child liveness
168
+ * 3. Supports very long execution times (hours/days) for async work
169
+ * like video generation, batch processing, etc.
170
+ *
171
+ * The child is expected to emit `turn.delta` / `turn.progress`
172
+ * notifications during long work. If no response to ping within
173
+ * `pingTimeout`, the task is considered failed.
174
+ */
175
+ sendTaskAsync(memberId: string, prompt: string, options?: {
176
+ model?: string;
177
+ apiKey?: string;
178
+ baseUrl?: string;
179
+ sessionId?: string;
180
+ /** Total timeout for the task (default: unlimited, 0 = no timeout) */
181
+ timeout?: number;
182
+ /** Ping interval in ms (default: 60_000 = 1 minute) */
183
+ pingInterval?: number;
184
+ /** Ping response timeout in ms (default: 10_000) */
185
+ pingTimeout?: number;
186
+ }): Promise<unknown>;
187
+ /**
188
+ * Ping a child agent to check liveness.
189
+ *
190
+ * Q-2 protocol alignment:
191
+ * - Internal agents: JSON-RPC `ping` request (guaranteed to respond).
192
+ * - ACP agents: Send `notifications/ping` notification, then wait for
193
+ * `$/alive` notification back. Falls back to `sendRpc("ping")` if
194
+ * `$/alive` is not received (some ACP agents may support RPC ping).
195
+ */
196
+ ping(memberId: string, timeoutMs?: number): Promise<boolean>;
197
+ /**
198
+ * Get the runtime status of a child agent process.
199
+ * Includes real-time media generation progress if available.
200
+ */
201
+ getStatus(memberId: string): {
202
+ alive: boolean;
203
+ state: AgentProcessHandle["state"];
204
+ runningFor?: number;
205
+ resultText?: string;
206
+ error?: string;
207
+ /** Current media generation progress (from child's turn.media_progress). */
208
+ mediaProgress?: MediaProgressSnapshot;
209
+ /** Last tool the child invoked. */
210
+ lastToolCall?: string;
211
+ /** Seconds since last activity from child. */
212
+ idleFor?: number;
213
+ } | null;
214
+ /**
215
+ * Auto-capture structured progress from child notifications.
216
+ * This is the key mechanism that allows the parent to know:
217
+ * - Which provider task ID the child is polling (for video/3D/TTS)
218
+ * - Real progress percentage
219
+ * - What the child is currently doing (which tool, what delta text)
220
+ */
221
+ private captureChildProgress;
222
+ /**
223
+ * Spawn an external ACP agent with retry logic.
224
+ * Retries up to MAX_SPAWN_RETRIES times with exponential backoff.
225
+ */
226
+ private spawnAcpAgentWithRetry;
227
+ /**
228
+ * Spawn an external ACP agent process.
229
+ * Uses the ACP protocol adapter for lifecycle management.
230
+ */
231
+ private spawnAcpAgent;
232
+ /** Kill a specific child agent process. */
233
+ kill(memberId: string): void;
234
+ /** Kill all child processes and clean up. */
235
+ killAll(): void;
236
+ /** Get the handle for a specific member. */
237
+ getHandle(memberId: string): AgentProcessHandle | undefined;
238
+ /** Get all handles. */
239
+ getAllHandles(): AgentProcessHandle[];
240
+ /** Get usage tracker for an ACP agent (returns null for internal agents). */
241
+ getUsageTracker(memberId: string): AcpUsageTracker | null;
242
+ /**
243
+ * Create a named-pipe IPC server for MCP bridge tool-call proxying.
244
+ * External agents' MCP bridge servers connect here to proxy tool calls
245
+ * back to qlogicagent.
246
+ */
247
+ private createMcpIpcServer;
248
+ /** Handle a single JSON-RPC message from the MCP bridge IPC connection. */
249
+ private handleMcpIpcMessage;
250
+ /**
251
+ * Attempt to restart a crashed ACP agent.
252
+ * Re-spawns the child process prepping the same config and env,
253
+ * then re-runs ACP handshake.
254
+ */
255
+ private attemptRuntimeRestart;
256
+ /** Get IPC pipe path for a member's MCP bridge. */
257
+ getMcpIpcPath(memberId: string): string | undefined;
258
+ private heartbeatTimers;
259
+ private missedBeats;
260
+ /** Heartbeat interval (ms). */
261
+ private static readonly HEARTBEAT_INTERVAL;
262
+ /** Number of missed heartbeats before force-kill. */
263
+ private static readonly MAX_MISSED_BEATS;
264
+ /**
265
+ * Start heartbeat monitoring for a running agent.
266
+ * Sends periodic ping RPCs; after MAX_MISSED_BEATS consecutive failures,
267
+ * the agent is force-killed and marked as "hang".
268
+ */
269
+ startHeartbeat(memberId: string, onHang?: (memberId: string) => void): void;
270
+ /** Stop heartbeat monitoring for an agent. */
271
+ stopHeartbeat(memberId: string): void;
272
+ /** Get missed heartbeat count for an agent. */
273
+ getMissedBeats(memberId: string): number;
274
+ /** Get count of active (non-terminal) processes. */
275
+ activeCount(): number;
276
+ /** Remove a terminated process from tracking. */
277
+ remove(memberId: string): void;
278
+ /** Clean up all processes. */
279
+ dispose(): void;
280
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -6,3 +6,13 @@ export { TaskStore } from "./task-runtime.js";
6
6
  export { createWorktreeBackend } from "./worktree-backend.js";
7
7
  export { registerCleanup, runCleanupFunctions } from "./cleanup-registry.js";
8
8
  export { atomicWriteFile, readJsonFile, writeJsonFile, loadPersistedMemory, savePersistedMemory, getMemoryFilePath, type PersistedMemory, } from "./disk-storage.js";
9
+ export { AcpDetector, ACP_BACKENDS } from "./acp-detector.js";
10
+ export { AcpProtocolAdapter, type TranslatedNotification } from "./acp-protocol-adapter.js";
11
+ export { AcpUsageTracker, type AccumulatedUsage } from "./acp-usage-tracker.js";
12
+ export { AgentConfigStore } from "./agent-config-store.js";
13
+ export { ModelIdTranslator } from "./model-id-translator.js";
14
+ export { SkillInjector } from "./skill-injector.js";
15
+ export { ACP_FAULT_LEVEL, type AcpFaultLevel, buildLlmEnvForTeammate } from "./agent-process.js";
16
+ export { McpBridge, MCP_BRIDGE_TOOLS } from "./mcp-bridge.js";
17
+ export type { AgentCategory, AgentProtocol, AgentStatus, AcpBackendConfig, AgentDescriptor, ExternalAgentDescriptor, CustomAgentDef, AgentConfig, AgentConfigStoreData, AgentCapabilities, AcpInitializeResult, AcpSessionResult, AcpPromptResponse, AcpContentItem, AcpPromptResponseUsage, AcpUsageUpdatePayload, McpServerConfig, AgentsScanParams, AgentsConfigParams, AgentsSetConfigParams, AgentsGetConfigParams, AgentsRemoveConfigParams, AgentsSetGatewayParams, SoloState, SoloAgentState, SoloAgentResult, SoloEvaluation, SoloStatus, SoloStartParams, SoloIdParams, SoloSelectParams, ProductPhase, ProductInstanceState, ProductTaskStatus, ProductBudget, ProductInstanceDef, ProductTaskDef, ProductCreateParams, ProductIdParams, ProductInstanceStatus, ProductTaskState, ProductStatus, ProductSummary, AgentsGetGatewayResult, AgentsListConfiguredItem, AgentsProcessInfo, AgentsKillParams, AgentsGetLogParams, AgentsGetLogResult, AgentsTestConnectionParams, AgentsTestConnectionResult, SoloDeleteParams, ProductDeleteParams, AgentSource, } from "./acp-types.js";
18
+ export type { AgentsStatusNotification, AgentsErrorNotification, SoloProgressNotification, SoloEvaluationNotification, SoloAgentDeltaNotification, ProductTaskStartedNotification, ProductTaskCompletedNotification, ProductTaskFailedNotification, ProductCheckpointedNotification, ProductBudgetWarningNotification, ProductCompletedNotification, } from "../../protocol/notifications.js";
@@ -0,0 +1,166 @@
1
+ /**
2
+ * MCP Bridge — exports qlogicagent tools as MCP (Model Context Protocol) servers
3
+ * for injection into external ACP agent sessions.
4
+ *
5
+ * When an ACP agent's session is created, we inject MCP servers that expose
6
+ * qlogicagent's native tools (media_generate, memory_*, web_search, etc.)
7
+ * so external agents can call them.
8
+ *
9
+ * Architecture:
10
+ * qlogicagent ─── ACP ───→ external agent
11
+ * └── MCP bridge server ◄── tools/call ── external agent
12
+ *
13
+ * The bridge server runs as a stdio child process. Each external agent
14
+ * session gets its own MCP bridge server instance.
15
+ */
16
+ import type { McpServerConfig, AgentCapabilities } from "./acp-types.js";
17
+ /**
18
+ * Tools exported via MCP bridge.
19
+ * These represent qlogicagent capabilities that external agents can call.
20
+ */
21
+ export declare const MCP_BRIDGE_TOOLS: readonly [{
22
+ readonly name: "media_generate";
23
+ readonly description: "Generate images or videos using AI models.";
24
+ readonly inputSchema: {
25
+ readonly type: "object";
26
+ readonly properties: {
27
+ readonly prompt: {
28
+ readonly type: "string";
29
+ readonly description: "Generation prompt";
30
+ };
31
+ readonly type: {
32
+ readonly type: "string";
33
+ readonly enum: readonly ["image", "video"];
34
+ readonly description: "Media type";
35
+ };
36
+ };
37
+ readonly required: readonly ["prompt"];
38
+ };
39
+ }, {
40
+ readonly name: "media_status";
41
+ readonly description: "Check status of an async media generation job.";
42
+ readonly inputSchema: {
43
+ readonly type: "object";
44
+ readonly properties: {
45
+ readonly jobId: {
46
+ readonly type: "string";
47
+ readonly description: "Job ID to check";
48
+ };
49
+ };
50
+ readonly required: readonly ["jobId"];
51
+ };
52
+ }, {
53
+ readonly name: "memory_read";
54
+ readonly description: "Read from persistent memory.";
55
+ readonly inputSchema: {
56
+ readonly type: "object";
57
+ readonly properties: {
58
+ readonly key: {
59
+ readonly type: "string";
60
+ readonly description: "Memory key to read";
61
+ };
62
+ };
63
+ readonly required: readonly ["key"];
64
+ };
65
+ }, {
66
+ readonly name: "memory_write";
67
+ readonly description: "Write to persistent memory.";
68
+ readonly inputSchema: {
69
+ readonly type: "object";
70
+ readonly properties: {
71
+ readonly key: {
72
+ readonly type: "string";
73
+ readonly description: "Memory key";
74
+ };
75
+ readonly value: {
76
+ readonly type: "string";
77
+ readonly description: "Value to store";
78
+ };
79
+ };
80
+ readonly required: readonly ["key", "value"];
81
+ };
82
+ }, {
83
+ readonly name: "memory_search";
84
+ readonly description: "Search persistent memory by query.";
85
+ readonly inputSchema: {
86
+ readonly type: "object";
87
+ readonly properties: {
88
+ readonly query: {
89
+ readonly type: "string";
90
+ readonly description: "Search query";
91
+ };
92
+ };
93
+ readonly required: readonly ["query"];
94
+ };
95
+ }, {
96
+ readonly name: "web_search";
97
+ readonly description: "Search the web for information.";
98
+ readonly inputSchema: {
99
+ readonly type: "object";
100
+ readonly properties: {
101
+ readonly query: {
102
+ readonly type: "string";
103
+ readonly description: "Search query";
104
+ };
105
+ };
106
+ readonly required: readonly ["query"];
107
+ };
108
+ }, {
109
+ readonly name: "web_fetch";
110
+ readonly description: "Fetch content from a URL.";
111
+ readonly inputSchema: {
112
+ readonly type: "object";
113
+ readonly properties: {
114
+ readonly url: {
115
+ readonly type: "string";
116
+ readonly description: "URL to fetch";
117
+ };
118
+ };
119
+ readonly required: readonly ["url"];
120
+ };
121
+ }, {
122
+ readonly name: "team_status";
123
+ readonly description: "Get status of all agent team members.";
124
+ readonly inputSchema: {
125
+ readonly type: "object";
126
+ readonly properties: {};
127
+ };
128
+ }, {
129
+ readonly name: "team_message";
130
+ readonly description: "Send a message to another team member agent.";
131
+ readonly inputSchema: {
132
+ readonly type: "object";
133
+ readonly properties: {
134
+ readonly targetAgentId: {
135
+ readonly type: "string";
136
+ readonly description: "Target agent ID";
137
+ };
138
+ readonly message: {
139
+ readonly type: "string";
140
+ readonly description: "Message to send";
141
+ };
142
+ };
143
+ readonly required: readonly ["targetAgentId", "message"];
144
+ };
145
+ }];
146
+ export declare class McpBridge {
147
+ private bridgeScriptPath;
148
+ constructor(distDir: string);
149
+ /**
150
+ * Check whether an ACP agent supports MCP server injection.
151
+ */
152
+ canInjectMcp(capabilities?: AgentCapabilities): boolean;
153
+ /**
154
+ * Generate the MCP server config to inject into an ACP session.
155
+ * This config tells the ACP agent how to spawn our MCP bridge server.
156
+ *
157
+ * @param parentRpcPort - Port/path for the bridge to call back to qlogicagent
158
+ * @param sessionId - Current session ID for scoping
159
+ */
160
+ getMcpServerConfig(parentRpcPort: string, sessionId: string): McpServerConfig;
161
+ /**
162
+ * Get the list of tools that the MCP bridge will expose.
163
+ * Can be used for display or capability checking.
164
+ */
165
+ getExportedTools(): typeof MCP_BRIDGE_TOOLS;
166
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Model ID Translator — converts qlogicagent internal model IDs
3
+ * to external agent-specific model IDs.
4
+ *
5
+ * Lookup order:
6
+ * 1. Per-agent custom override (from AgentConfig.modelIdMap)
7
+ * 2. Pre-built translation table (covers mainstream agents)
8
+ * 3. Pass-through (unknown IDs forwarded as-is, never blocked)
9
+ */
10
+ export declare class ModelIdTranslator {
11
+ /**
12
+ * Translate a model ID for a specific agent.
13
+ *
14
+ * @param agentId - Target agent (e.g. "claude", "codex")
15
+ * @param internalModelId - qlogicagent's internal model ID
16
+ * @param customMap - Per-agent override from AgentConfig.modelIdMap
17
+ * @returns The translated model ID (or original if no mapping exists)
18
+ */
19
+ translate(agentId: string, internalModelId: string, customMap?: Record<string, string>): string;
20
+ /** Get all available mappings for an agent (defaults + custom overlay). */
21
+ getMappings(agentId: string, customMap?: Record<string, string>): Record<string, string>;
22
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Skill Injector — shares qlogicagent skills with external ACP agents.
3
+ *
4
+ * Two injection methods:
5
+ *
6
+ * 1. **Native skill directory sync**: For agents that support a `skillsDirs`
7
+ * convention (e.g. `.claude/skills/`), create symlinks or copies of
8
+ * qlogicagent's optional skills into the agent's native directory.
9
+ *
10
+ * 2. **First-message prompt injection**: For agents without native skill
11
+ * directory support, prepend skill instructions text to the first prompt.
12
+ */
13
+ import type { AgentCapabilities } from "./acp-types.js";
14
+ export declare class SkillInjector {
15
+ /**
16
+ * Synchronize skills to an agent's native skill directory.
17
+ * Creates symlinks where possible; falls back to file copy.
18
+ *
19
+ * @param targetDir - Agent's native skill directory (e.g. `<cwd>/.claude/skills/`)
20
+ * @param cwd - Project working directory (for project-level skills)
21
+ */
22
+ syncSkillsToDir(targetDir: string, cwd?: string): void;
23
+ /**
24
+ * Build a skill description block to prepend to the first message
25
+ * for agents that don't support native skill directories.
26
+ *
27
+ * @param cwd - Project working directory (for project-level skills)
28
+ * @returns Markdown text with skill instructions, or empty string if no skills.
29
+ */
30
+ buildPromptWithSkills(cwd?: string): string;
31
+ /**
32
+ * Determine the injection method for an agent.
33
+ *
34
+ * @param capabilities - Agent's discovered capabilities
35
+ * @returns "native" if agent has skillsDirs, "prompt" otherwise
36
+ */
37
+ getInjectionMethod(capabilities?: AgentCapabilities): "native" | "prompt";
38
+ /**
39
+ * Apply skills to an agent based on its capabilities.
40
+ *
41
+ * @param capabilities - Agent's discovered capabilities
42
+ * @param cwd - Project working directory
43
+ * @returns Skill prompt text (for "prompt" method) or empty string (for "native" method)
44
+ */
45
+ applySkills(capabilities?: AgentCapabilities, cwd?: string): string;
46
+ /**
47
+ * Collect all skill file paths from user-level and project-level dirs.
48
+ * Only `.md` files are treated as skills.
49
+ */
50
+ private collectSkillPaths;
51
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -36,6 +36,7 @@ interface WorktreeSession {
36
36
  export declare function getCurrentWorktreeSession(): WorktreeSession | null;
37
37
  /** Restore session on resume (CC restoreWorktreeSession parity). */
38
38
  export declare function restoreWorktreeSession(session: WorktreeSession | null): void;
39
+ export declare function findGitRoot(cwd?: string): Promise<string | null>;
39
40
  /** Check whether tmux is available on the system. */
40
41
  export declare function isTmuxAvailable(): Promise<boolean>;
41
42
  /** Generate a tmux session name from repo path and branch (CC parity). */
@@ -21,3 +21,9 @@ export type ShellType = "bash" | "powershell" | "zsh" | "cmd" | "fish" | "unknow
21
21
  * Memoized — computed once per session (environment doesn't change mid-session).
22
22
  */
23
23
  export declare function createEnvironmentContextSection(cwdOverride?: string): SystemPromptSection;
24
+ /**
25
+ * Create a system prompt section that provides tool usage guidance.
26
+ * CC parity: matches claude-code's AgentTool prompt guidance patterns.
27
+ * Tells the LLM when to use specialized tools vs. primitives.
28
+ */
29
+ export declare function createToolGuidanceSection(): SystemPromptSection;
@@ -7,7 +7,8 @@
7
7
  * 3. Session metadata (model, cwd, agent mode)
8
8
  *
9
9
  * Storage layout:
10
- * ~/.qlogicagent/sessions/<session-id>/
10
+ * <project>/.qlogicagent/sessions/<session-id>/ (when projectRoot provided)
11
+ * ~/.qlogicagent/sessions/<session-id>/ (fallback)
11
12
  * transcript.jsonl — append-only message log
12
13
  * state.json — cost snapshot + metadata
13
14
  *
@@ -52,31 +53,31 @@ export interface SessionListEntry {
52
53
  * Append a message to the session transcript.
53
54
  * Creates the session directory if it doesn't exist.
54
55
  */
55
- export declare function appendMessage(sessionId: string, message: ChatMessage): Promise<void>;
56
+ export declare function appendMessage(sessionId: string, message: ChatMessage, projectRoot?: string): Promise<void>;
56
57
  /**
57
58
  * Save session state (cost + metadata) atomically.
58
59
  */
59
- export declare function saveSessionState(sessionId: string, costSnapshot: SessionCostSnapshot, metadata: Partial<SessionMetadata>): Promise<void>;
60
+ export declare function saveSessionState(sessionId: string, costSnapshot: SessionCostSnapshot, metadata: Partial<SessionMetadata>, projectRoot?: string): Promise<void>;
60
61
  /**
61
62
  * Load a persisted session for resume — CC loadConversationForResume parity.
62
63
  *
63
64
  * Returns null if the session doesn't exist or is corrupted.
64
65
  */
65
- export declare function loadSessionForResume(sessionId: string): Promise<PersistedSession | null>;
66
+ export declare function loadSessionForResume(sessionId: string, projectRoot?: string): Promise<PersistedSession | null>;
66
67
  /**
67
68
  * List available sessions for resume — CC ResumeConversation picker.
68
69
  * Returns most-recent-first, up to `limit` entries.
69
70
  */
70
- export declare function listSessions(limit?: number): Promise<SessionListEntry[]>;
71
+ export declare function listSessions(limit?: number, projectRoot?: string): Promise<SessionListEntry[]>;
71
72
  /**
72
73
  * Delete a session (cleanup).
73
74
  */
74
- export declare function deleteSession(sessionId: string): Promise<void>;
75
+ export declare function deleteSession(sessionId: string, projectRoot?: string): Promise<void>;
75
76
  /**
76
77
  * Prune old sessions beyond MAX_SESSIONS limit.
77
78
  * Deletes oldest sessions first.
78
79
  */
79
- export declare function pruneOldSessions(): Promise<number>;
80
+ export declare function pruneOldSessions(projectRoot?: string): Promise<number>;
80
81
  export interface TaskSummaryDeps {
81
82
  transport: import("../../llm/transport.js").LLMTransport;
82
83
  apiKey: string;
@@ -91,4 +92,4 @@ export declare function shouldGenerateTaskSummary(metadata: SessionMetadata): bo
91
92
  * Generate and persist a task summary for a long session.
92
93
  * Fire-and-forget — errors are swallowed.
93
94
  */
94
- export declare function maybeGenerateTaskSummary(sessionId: string, metadata: SessionMetadata, recentMessages: ChatMessage[], deps: TaskSummaryDeps): Promise<string | null>;
95
+ export declare function maybeGenerateTaskSummary(sessionId: string, metadata: SessionMetadata, recentMessages: ChatMessage[], deps: TaskSummaryDeps, projectRoot?: string): Promise<string | null>;