qlogicagent 0.5.2 → 0.5.3

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 (173) hide show
  1. package/README.md +402 -402
  2. package/dist/agent.js +18 -0
  3. package/dist/cli.js +360 -0
  4. package/dist/contracts.js +1 -0
  5. package/dist/index.js +22 -0
  6. package/dist/orchestration.js +125 -0
  7. package/dist/types/agent/agent.d.ts +43 -0
  8. package/dist/types/agent/constants.d.ts +47 -0
  9. package/dist/types/agent/tool-loop.d.ts +96 -0
  10. package/dist/types/agent/types.d.ts +250 -0
  11. package/dist/types/cli/main.d.ts +11 -0
  12. package/dist/types/cli/stdio-server.d.ts +56 -0
  13. package/dist/types/cli/tool-bootstrap.d.ts +21 -0
  14. package/dist/types/config/config.d.ts +17 -0
  15. package/dist/types/contracts/hooks.d.ts +175 -0
  16. package/dist/types/contracts/index.d.ts +10 -0
  17. package/dist/types/contracts/planner.d.ts +35 -0
  18. package/dist/types/contracts/skill-candidate.d.ts +63 -0
  19. package/dist/types/contracts/todo.d.ts +14 -0
  20. package/dist/types/index.d.ts +13 -0
  21. package/dist/types/llm/builtin-providers.d.ts +10 -0
  22. package/dist/types/llm/debug-transport.d.ts +12 -0
  23. package/dist/types/llm/index.d.ts +16 -0
  24. package/dist/types/llm/llm-client.d.ts +43 -0
  25. package/dist/types/llm/model-catalog.d.ts +53 -0
  26. package/dist/types/llm/provider-def.d.ts +59 -0
  27. package/dist/types/llm/provider-registry.d.ts +54 -0
  28. package/dist/types/llm/transport.d.ts +62 -0
  29. package/dist/types/llm/transports/anthropic-messages.d.ts +31 -0
  30. package/dist/types/llm/transports/openai-chat.d.ts +36 -0
  31. package/dist/types/orchestration/agent-registry.d.ts +46 -0
  32. package/dist/types/orchestration/context-collapse.d.ts +58 -0
  33. package/dist/types/orchestration/context-compression.d.ts +301 -0
  34. package/dist/types/orchestration/conversation-repair.d.ts +61 -0
  35. package/dist/types/orchestration/curator-scheduler.d.ts +119 -0
  36. package/dist/types/orchestration/error-classification.d.ts +12 -0
  37. package/dist/types/orchestration/failover-classification.d.ts +8 -0
  38. package/dist/types/orchestration/failover-error.d.ts +33 -0
  39. package/dist/types/orchestration/fork-subagent.d.ts +100 -0
  40. package/dist/types/orchestration/index.d.ts +113 -0
  41. package/dist/types/orchestration/memory-provider.d.ts +14 -0
  42. package/dist/types/orchestration/reactive-compact.d.ts +73 -0
  43. package/dist/types/orchestration/retry-loop.d.ts +69 -0
  44. package/dist/types/orchestration/skill-candidate.d.ts +52 -0
  45. package/dist/types/orchestration/skill-consolidation.d.ts +123 -0
  46. package/dist/types/orchestration/skill-improvement.d.ts +59 -0
  47. package/dist/types/orchestration/skill-similarity.d.ts +98 -0
  48. package/dist/types/orchestration/task-types.d.ts +142 -0
  49. package/dist/types/orchestration/team-orchestration.d.ts +195 -0
  50. package/dist/types/orchestration/team-tool-loop-wiring.d.ts +92 -0
  51. package/dist/types/orchestration/tool-choice-policy.d.ts +54 -0
  52. package/dist/types/orchestration/tool-loop-state.d.ts +50 -0
  53. package/dist/types/orchestration/tool-schema.d.ts +39 -0
  54. package/dist/types/orchestration/turn-loop-guard.d.ts +86 -0
  55. package/dist/types/runtime/execution/dream-agent.d.ts +199 -0
  56. package/dist/types/runtime/execution/forked-agent.d.ts +111 -0
  57. package/dist/types/runtime/execution/index.d.ts +6 -0
  58. package/dist/types/runtime/execution/progress-tracker.d.ts +78 -0
  59. package/dist/types/runtime/execution/remote-agent.d.ts +63 -0
  60. package/dist/types/runtime/execution/streaming-tool-executor.d.ts +100 -0
  61. package/dist/types/runtime/execution/tool-eligibility.d.ts +59 -0
  62. package/dist/types/runtime/execution/tool-result-storage.d.ts +87 -0
  63. package/dist/types/runtime/hooks/context-compression.d.ts +61 -0
  64. package/dist/types/runtime/hooks/hook-registry.d.ts +12 -0
  65. package/dist/types/runtime/hooks/index.d.ts +3 -0
  66. package/dist/types/runtime/hooks/memory-hooks.d.ts +49 -0
  67. package/dist/types/runtime/index.d.ts +5 -0
  68. package/dist/types/runtime/infra/cleanup-registry.d.ts +23 -0
  69. package/dist/types/runtime/infra/file-watcher.d.ts +72 -0
  70. package/dist/types/runtime/infra/index.d.ts +6 -0
  71. package/dist/types/runtime/infra/secure-storage.d.ts +81 -0
  72. package/dist/types/runtime/infra/task-runtime.d.ts +108 -0
  73. package/dist/types/runtime/infra/token-budget.d.ts +92 -0
  74. package/dist/types/runtime/infra/worktree-backend.d.ts +85 -0
  75. package/dist/types/runtime/prompt/environment-context.d.ts +23 -0
  76. package/dist/types/runtime/prompt/index.d.ts +3 -0
  77. package/dist/types/runtime/prompt/instruction-loader.d.ts +64 -0
  78. package/dist/types/runtime/prompt/system-prompt-sections.d.ts +63 -0
  79. package/dist/types/runtime/session/index.d.ts +2 -0
  80. package/dist/types/runtime/session/session-memory.d.ts +91 -0
  81. package/dist/types/runtime/session/session-persistence.d.ts +94 -0
  82. package/dist/types/runtime/session/session-state.d.ts +117 -0
  83. package/dist/types/skills/index.d.ts +125 -0
  84. package/dist/types/skills/mcp/index.d.ts +3 -0
  85. package/dist/types/skills/mcp/mcp-http-client.d.ts +66 -0
  86. package/dist/types/skills/mcp/mcp-manager.d.ts +84 -0
  87. package/dist/types/skills/mcp/mcp-stdio-client.d.ts +84 -0
  88. package/dist/types/skills/memory-extractor.d.ts +64 -0
  89. package/dist/types/skills/memory-query-tool.d.ts +43 -0
  90. package/dist/types/skills/memory-store.d.ts +66 -0
  91. package/dist/types/skills/memory-tool.d.ts +67 -0
  92. package/dist/types/skills/permissions/bash-classifier.d.ts +30 -0
  93. package/dist/types/skills/permissions/classifier-cache.d.ts +51 -0
  94. package/dist/types/skills/permissions/denial-tracking.d.ts +42 -0
  95. package/dist/types/skills/permissions/hook-runner.d.ts +85 -0
  96. package/dist/types/skills/permissions/index.d.ts +12 -0
  97. package/dist/types/skills/permissions/permission-classifier.d.ts +41 -0
  98. package/dist/types/skills/permissions/rule-engine.d.ts +41 -0
  99. package/dist/types/skills/permissions/settings-watcher.d.ts +46 -0
  100. package/dist/types/skills/permissions/types.d.ts +113 -0
  101. package/dist/types/skills/plugins/index.d.ts +2 -0
  102. package/dist/types/skills/plugins/plugin-api.d.ts +38 -0
  103. package/dist/types/skills/plugins/plugin-loader.d.ts +45 -0
  104. package/dist/types/skills/plugins/plugin-marketplace.d.ts +61 -0
  105. package/dist/types/skills/portable-tool.d.ts +71 -0
  106. package/dist/types/skills/qmemory-adapter.d.ts +42 -0
  107. package/dist/types/skills/skill-frontmatter.d.ts +19 -0
  108. package/dist/types/skills/skill-guard.d.ts +23 -0
  109. package/dist/types/skills/skill-loader.d.ts +16 -0
  110. package/dist/types/skills/skill-source.d.ts +119 -0
  111. package/dist/types/skills/skill-types.d.ts +199 -0
  112. package/dist/types/skills/think-tool.d.ts +16 -0
  113. package/dist/types/skills/todo-tool.d.ts +63 -0
  114. package/dist/types/skills/tool-registry.d.ts +29 -0
  115. package/dist/types/skills/tools/agent-tool.d.ts +91 -0
  116. package/dist/types/skills/tools/apply-patch-tool.d.ts +29 -0
  117. package/dist/types/skills/tools/ask-user-tool.d.ts +80 -0
  118. package/dist/types/skills/tools/brief-tool.d.ts +74 -0
  119. package/dist/types/skills/tools/browser-tool.d.ts +114 -0
  120. package/dist/types/skills/tools/checkpoint-tool.d.ts +66 -0
  121. package/dist/types/skills/tools/config-tool.d.ts +63 -0
  122. package/dist/types/skills/tools/cron-tool.d.ts +116 -0
  123. package/dist/types/skills/tools/edit-tool.d.ts +43 -0
  124. package/dist/types/skills/tools/exec-tool.d.ts +97 -0
  125. package/dist/types/skills/tools/image-generate-tool.d.ts +62 -0
  126. package/dist/types/skills/tools/instructions-tool.d.ts +103 -0
  127. package/dist/types/skills/tools/lsp-tool.d.ts +153 -0
  128. package/dist/types/skills/tools/mcp-client-types.d.ts +269 -0
  129. package/dist/types/skills/tools/mcp-resource-tools.d.ts +14 -0
  130. package/dist/types/skills/tools/mcp-tool.d.ts +249 -0
  131. package/dist/types/skills/tools/memory-tool.d.ts +74 -0
  132. package/dist/types/skills/tools/monitor-tool.d.ts +113 -0
  133. package/dist/types/skills/tools/music-generate-tool.d.ts +55 -0
  134. package/dist/types/skills/tools/notebook-edit-tool.d.ts +15 -0
  135. package/dist/types/skills/tools/notify-tool.d.ts +53 -0
  136. package/dist/types/skills/tools/patch-tool.d.ts +45 -0
  137. package/dist/types/skills/tools/pdf-tool.d.ts +66 -0
  138. package/dist/types/skills/tools/plan-mode-tool.d.ts +98 -0
  139. package/dist/types/skills/tools/read-tool.d.ts +51 -0
  140. package/dist/types/skills/tools/repl-tool.d.ts +70 -0
  141. package/dist/types/skills/tools/search-tool.d.ts +112 -0
  142. package/dist/types/skills/tools/send-message-tool.d.ts +51 -0
  143. package/dist/types/skills/tools/shell/bash-provider.d.ts +26 -0
  144. package/dist/types/skills/tools/shell/command-classification.d.ts +44 -0
  145. package/dist/types/skills/tools/shell/command-semantics.d.ts +14 -0
  146. package/dist/types/skills/tools/shell/destructive-command-warning.d.ts +10 -0
  147. package/dist/types/skills/tools/shell/exec-permissions.d.ts +52 -0
  148. package/dist/types/skills/tools/shell/index.d.ts +17 -0
  149. package/dist/types/skills/tools/shell/powershell-provider.d.ts +15 -0
  150. package/dist/types/skills/tools/shell/shell-command.d.ts +54 -0
  151. package/dist/types/skills/tools/shell/shell-exec.d.ts +33 -0
  152. package/dist/types/skills/tools/shell/shell-provider.d.ts +85 -0
  153. package/dist/types/skills/tools/shell/task-output.d.ts +45 -0
  154. package/dist/types/skills/tools/skill-invoke-tool.d.ts +46 -0
  155. package/dist/types/skills/tools/skill-list-tool.d.ts +33 -0
  156. package/dist/types/skills/tools/skill-manage-tool.d.ts +73 -0
  157. package/dist/types/skills/tools/skill-view-tool.d.ts +37 -0
  158. package/dist/types/skills/tools/sleep-tool.d.ts +49 -0
  159. package/dist/types/skills/tools/structured-output-tool.d.ts +116 -0
  160. package/dist/types/skills/tools/task-tool.d.ts +104 -0
  161. package/dist/types/skills/tools/team-tool.d.ts +89 -0
  162. package/dist/types/skills/tools/tool-search-tool.d.ts +51 -0
  163. package/dist/types/skills/tools/tts-tool.d.ts +38 -0
  164. package/dist/types/skills/tools/video-edit-tool.d.ts +69 -0
  165. package/dist/types/skills/tools/video-generate-tool.d.ts +62 -0
  166. package/dist/types/skills/tools/video-merge-tool.d.ts +105 -0
  167. package/dist/types/skills/tools/video-upscale-tool.d.ts +45 -0
  168. package/dist/types/skills/tools/web-fetch-tool.d.ts +78 -0
  169. package/dist/types/skills/tools/web-search-tool.d.ts +57 -0
  170. package/dist/types/skills/tools/workflow-tool.d.ts +44 -0
  171. package/dist/types/skills/tools/worktree-tool.d.ts +69 -0
  172. package/dist/types/skills/tools/write-tool.d.ts +45 -0
  173. package/package.json +3 -2
@@ -0,0 +1,249 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ import type { McpServerConfig, McpConnectionStatus, McpServerCapabilities, McpToolAnnotations, McpToolsChangedEvent, McpPromptDefinition, McpPromptMessage, McpElicitResult, McpAuthState, McpLogEntry, McpLogLevel } from "./mcp-client-types.js";
3
+ export type { McpServerConfig, McpStdioConfig, McpSseConfig, McpHttpConfig, McpWsConfig, McpInProcessConfig, McpServerState, McpConnectionStatus, McpServerCapabilities, McpExternalTool, McpToolAnnotations, McpToolIdentifier, McpToolsChangedEvent, McpResourceDefinition, McpResourceTemplate, McpPersistedResourceContent, McpResourceContentItem, McpPromptDefinition, McpPromptArgument, McpPromptMessage, McpPromptContent, McpElicitResult, McpElicitRequest, McpOAuthConfig, McpOAuthTokens, McpAuthState, McpLogEntry, McpLogLevel, McpTransportType, } from "./mcp-client-types.js";
4
+ export { normalizeNameForMcp, buildMcpToolName, getMcpServerPrefix, parseMcpToolName, isMcpToolName, MCP_CONNECTION_TIMEOUT_MS, MCP_REQUEST_TIMEOUT_MS, MCP_TOOL_CALL_TIMEOUT_MS, MCP_MAX_RECONNECT_ATTEMPTS, MCP_MAX_DESCRIPTION_LENGTH, } from "./mcp-client-types.js";
5
+ export declare const MCP_TOOL_NAME: "mcp";
6
+ export type McpAction = "list_servers" | "list_tools" | "call_tool" | "list_resources" | "read_resource" | "list_prompts" | "get_prompt" | "authenticate" | "manage_server";
7
+ export interface McpToolParams {
8
+ action: McpAction;
9
+ /** Server name (required for most actions) */
10
+ server?: string;
11
+ /** Tool name on the MCP server (for call_tool) */
12
+ toolName?: string;
13
+ /** Arguments for the MCP tool call or prompt arguments */
14
+ arguments?: Record<string, unknown>;
15
+ /** Resource URI (for read_resource) */
16
+ uri?: string;
17
+ /** Prompt name (for get_prompt) */
18
+ promptName?: string;
19
+ /** Server management sub-action */
20
+ manageAction?: McpManageAction;
21
+ /** Server config (for manage_server add) */
22
+ config?: McpServerConfig;
23
+ }
24
+ export type McpManageAction = "add" | "remove" | "restart" | "health_check" | "enable" | "disable";
25
+ export declare const MCP_TOOL_SCHEMA: {
26
+ readonly type: "object";
27
+ readonly properties: {
28
+ readonly action: {
29
+ readonly type: "string";
30
+ readonly enum: readonly ["list_servers", "list_tools", "call_tool", "list_resources", "read_resource", "list_prompts", "get_prompt", "authenticate", "manage_server"];
31
+ readonly description: string;
32
+ };
33
+ readonly server: {
34
+ readonly type: "string";
35
+ readonly description: "MCP server name. Required for all actions except list_servers.";
36
+ };
37
+ readonly toolName: {
38
+ readonly type: "string";
39
+ readonly description: "Tool name on the MCP server. Required for call_tool.";
40
+ };
41
+ readonly arguments: {
42
+ readonly type: "object";
43
+ readonly description: "Arguments for the tool call or prompt. Used with call_tool and get_prompt.";
44
+ };
45
+ readonly uri: {
46
+ readonly type: "string";
47
+ readonly description: "Resource URI. Required for read_resource.";
48
+ };
49
+ readonly promptName: {
50
+ readonly type: "string";
51
+ readonly description: "Prompt name. Required for get_prompt.";
52
+ };
53
+ readonly manageAction: {
54
+ readonly type: "string";
55
+ readonly enum: readonly ["add", "remove", "restart", "health_check", "enable", "disable"];
56
+ readonly description: "Sub-action for manage_server.";
57
+ };
58
+ readonly config: {
59
+ readonly type: "object";
60
+ readonly description: "Server configuration. Required for manage_server add.";
61
+ };
62
+ };
63
+ readonly required: readonly ["action"];
64
+ };
65
+ export interface McpServer {
66
+ name: string;
67
+ status: McpConnectionStatus;
68
+ transport: string;
69
+ toolCount: number;
70
+ resourceCount: number;
71
+ promptCount: number;
72
+ capabilities?: McpServerCapabilities;
73
+ serverVersion?: string;
74
+ error?: string;
75
+ connectedAt?: number;
76
+ }
77
+ export interface McpToolInfo {
78
+ name: string;
79
+ description?: string;
80
+ inputSchema?: Record<string, unknown>;
81
+ annotations?: McpToolAnnotations;
82
+ /** Prefixed name used in tool list */
83
+ prefixedName?: string;
84
+ }
85
+ export interface McpResource {
86
+ uri: string;
87
+ name: string;
88
+ mimeType?: string;
89
+ description?: string;
90
+ server?: string;
91
+ }
92
+ export interface McpResourceContent {
93
+ uri: string;
94
+ mimeType?: string;
95
+ text?: string;
96
+ blobSavedTo?: string;
97
+ blobSize?: number;
98
+ }
99
+ export interface McpCallResult {
100
+ success: boolean;
101
+ content?: string;
102
+ error?: string;
103
+ isError?: boolean;
104
+ /** Structured content blocks (images, resources) */
105
+ contentBlocks?: Array<{
106
+ type: "text" | "image" | "resource";
107
+ text?: string;
108
+ data?: string;
109
+ mimeType?: string;
110
+ }>;
111
+ }
112
+ export interface McpAuthResult {
113
+ status: "auth_url" | "already_authenticated" | "unsupported" | "step_up_required" | "error";
114
+ authUrl?: string;
115
+ message?: string;
116
+ /** Required scopes for step-up auth */
117
+ requiredScopes?: string[];
118
+ }
119
+ export interface McpPromptResult {
120
+ description?: string;
121
+ messages: McpPromptMessage[];
122
+ }
123
+ export interface McpManageResult {
124
+ success: boolean;
125
+ message: string;
126
+ /** Updated server state after the operation */
127
+ serverState?: McpServer;
128
+ }
129
+ /**
130
+ * Host-provided MCP client backend — full lifecycle management.
131
+ *
132
+ * Implements the complete MCP client SDK contract:
133
+ * - Transport abstraction (stdio/SSE/HTTP/WS/in-process)
134
+ * - Connection lifecycle (connect/disconnect/reconnect/health)
135
+ * - OAuth authentication with PKCE + token refresh
136
+ * - Dynamic tool injection (tools/list_changed notification)
137
+ * - Resource management with binary blob persistence
138
+ * - Prompt support
139
+ * - Server configuration CRUD
140
+ */
141
+ export interface McpToolDeps {
142
+ /** List all configured MCP servers with full state */
143
+ listServers(): Promise<McpServer[]>;
144
+ /**
145
+ * List tools from a specific server.
146
+ * Results are cached; invalidated on tools/list_changed notification.
147
+ */
148
+ listTools(server: string): Promise<McpToolInfo[]>;
149
+ /**
150
+ * Call a tool on an MCP server.
151
+ * Handles: connection ensure → permission check → execute → parse result.
152
+ */
153
+ callTool(server: string, toolName: string, args?: Record<string, unknown>, signal?: AbortSignal): Promise<McpCallResult>;
154
+ /**
155
+ * List resources from a server (or all servers if not specified).
156
+ * Uses LRU cache; invalidated on resources/list_changed.
157
+ */
158
+ listResources(server?: string): Promise<McpResource[]>;
159
+ /**
160
+ * Read a specific resource by URI.
161
+ * Handles binary blob persistence: base64 → disk file → returns path.
162
+ */
163
+ readResource(server: string, uri: string): Promise<McpResourceContent[]>;
164
+ /**
165
+ * List prompts available from a server.
166
+ * Prompts are reusable templates that servers expose.
167
+ */
168
+ listPrompts?(server: string): Promise<McpPromptDefinition[]>;
169
+ /**
170
+ * Get a specific prompt with arguments expanded.
171
+ * Returns the prompt messages ready for injection into conversation.
172
+ */
173
+ getPrompt?(server: string, promptName: string, args?: Record<string, string>): Promise<McpPromptResult>;
174
+ /**
175
+ * Initiate OAuth authentication with a server.
176
+ * Supports: PKCE flow, token refresh, step-up auth.
177
+ *
178
+ * For stdio servers: returns "not_applicable".
179
+ * For SSE/HTTP servers: returns auth_url or triggers silent auth.
180
+ */
181
+ authenticate(server: string): Promise<McpAuthResult>;
182
+ /**
183
+ * Check current auth state of a server (without initiating a flow).
184
+ * Optional — host may not track auth state for all servers.
185
+ */
186
+ getAuthState?(server: string): Promise<McpAuthState>;
187
+ /**
188
+ * Add a new MCP server configuration.
189
+ * Optionally auto-connects after adding.
190
+ */
191
+ addServer?(name: string, config: McpServerConfig): Promise<McpManageResult>;
192
+ /**
193
+ * Remove an MCP server (disconnect + delete config).
194
+ * Also removes all injected tools with the server's prefix.
195
+ */
196
+ removeServer?(name: string): Promise<McpManageResult>;
197
+ /**
198
+ * Restart (disconnect + reconnect) a server.
199
+ * Clears caches and re-fetches tools/resources/prompts.
200
+ */
201
+ restartServer?(name: string): Promise<McpManageResult>;
202
+ /**
203
+ * Health check a server's connection.
204
+ * Returns the updated server state with latency info.
205
+ */
206
+ healthCheck?(server: string): Promise<McpManageResult>;
207
+ /**
208
+ * Enable/disable a server (disabled servers don't auto-connect).
209
+ */
210
+ setServerEnabled?(name: string, enabled: boolean): Promise<McpManageResult>;
211
+ /**
212
+ * Register a callback for when a server's tool list changes.
213
+ * The host calls this when it receives tools/list_changed notifications.
214
+ *
215
+ * The callback receives the event with previous and current tool lists,
216
+ * enabling the orchestration layer to hot-swap injected tools.
217
+ */
218
+ onToolsChanged?(callback: (event: McpToolsChangedEvent) => void): void;
219
+ /**
220
+ * Get all currently injected MCP tools across all servers.
221
+ * Returns the flattened list of tools with their prefixed names.
222
+ */
223
+ getInjectedTools?(): Promise<McpToolInfo[]>;
224
+ /**
225
+ * Handle an elicitation request from an MCP server.
226
+ * The server asks the user for input/consent; the host presents UI.
227
+ * Optional — defaults to deny if not implemented.
228
+ */
229
+ handleElicitation?(server: string, message: string, schema?: Record<string, unknown>): Promise<McpElicitResult>;
230
+ /**
231
+ * Get recent log entries from MCP servers.
232
+ * Optional — useful for debugging server-side issues.
233
+ */
234
+ getServerLogs?(server: string, level?: McpLogLevel, limit?: number): Promise<McpLogEntry[]>;
235
+ }
236
+ export declare function createMcpTool(deps: McpToolDeps): PortableTool<McpToolParams>;
237
+ export interface McpAuthProxyDeps {
238
+ /** Initiate OAuth for the specified server */
239
+ authenticate(server: string): Promise<McpAuthResult>;
240
+ /** Optional callback after successful auth — e.g. reconnect, refresh tools */
241
+ onAuthComplete?(server: string): Promise<void>;
242
+ }
243
+ /**
244
+ * Create a dynamic per-server authentication proxy tool.
245
+ * One instance per unauthenticated MCP server.
246
+ *
247
+ * Tool name follows CC convention: `mcp__<normalizedServer>__authenticate`
248
+ */
249
+ export declare function createMcpAuthProxy(serverName: string, deps: McpAuthProxyDeps): PortableTool<Record<string, never>>;
@@ -0,0 +1,74 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ export declare const MEMORY_SEARCH_TOOL_NAME: "memory_search";
3
+ export type MemorySource = "memory" | "sessions" | "all";
4
+ export interface MemorySearchToolParams {
5
+ /** Search query */
6
+ query: string;
7
+ /** Source to search in */
8
+ source?: MemorySource;
9
+ /** Maximum results to return */
10
+ maxResults?: number;
11
+ /** Filter by time range (ISO date string, sessions only) */
12
+ after?: string;
13
+ /** Filter by time range (ISO date string, sessions only) */
14
+ before?: string;
15
+ }
16
+ export declare const MEMORY_SEARCH_TOOL_SCHEMA: {
17
+ readonly type: "object";
18
+ readonly properties: {
19
+ readonly query: {
20
+ readonly type: "string";
21
+ readonly description: "Search query. Supports natural language and keywords.";
22
+ };
23
+ readonly source: {
24
+ readonly type: "string";
25
+ readonly enum: readonly ["memory", "sessions", "all"];
26
+ readonly description: string;
27
+ };
28
+ readonly maxResults: {
29
+ readonly type: "number";
30
+ readonly description: "Maximum results to return (default: 5).";
31
+ };
32
+ readonly after: {
33
+ readonly type: "string";
34
+ readonly description: "Only return sessions after this date (ISO format). Sessions source only.";
35
+ };
36
+ readonly before: {
37
+ readonly type: "string";
38
+ readonly description: "Only return sessions before this date (ISO format). Sessions source only.";
39
+ };
40
+ };
41
+ readonly required: readonly ["query"];
42
+ };
43
+ export interface MemoryEntry {
44
+ content: string;
45
+ source: "memory" | "session";
46
+ relevance: number;
47
+ metadata?: {
48
+ sessionId?: string;
49
+ timestamp?: string;
50
+ summary?: string;
51
+ };
52
+ }
53
+ export interface MemoryQueryOutput {
54
+ results: MemoryEntry[];
55
+ query: string;
56
+ sources: MemorySource[];
57
+ }
58
+ /**
59
+ * Host-provided memory search backend.
60
+ */
61
+ export interface MemorySearchToolDeps {
62
+ /**
63
+ * Search memory/sessions.
64
+ * The host routes to QMemory vector search, FTS session search, or both.
65
+ */
66
+ searchMemory(params: {
67
+ query: string;
68
+ source: MemorySource;
69
+ maxResults: number;
70
+ after?: string;
71
+ before?: string;
72
+ }): Promise<MemoryQueryOutput>;
73
+ }
74
+ export declare function createMemorySearchTool(deps: MemorySearchToolDeps): PortableTool<MemorySearchToolParams>;
@@ -0,0 +1,113 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ export declare const MONITOR_TOOL_NAME: "monitor";
3
+ /** The kind of event source the agent can monitor. */
4
+ export type MonitorSource = "process" | "file" | "task" | "custom";
5
+ export type MonitorAction = "start" | "stop" | "list";
6
+ export interface MonitorToolParams {
7
+ action: MonitorAction;
8
+ /** Required for start/stop — identifies the monitor instance. */
9
+ monitorId?: string;
10
+ /** Required for start — what kind of event source to watch. */
11
+ source?: MonitorSource;
12
+ /** Required for start — selector for the target (pid, path, taskId, custom key). */
13
+ target?: string;
14
+ /** Optional for start — conditions that should trigger wake-up. */
15
+ conditions?: MonitorCondition[];
16
+ /** Optional for start — max time to monitor in seconds before auto-stop. */
17
+ timeoutSeconds?: number;
18
+ }
19
+ export interface MonitorCondition {
20
+ /** What to check: exit code, stdout pattern, file modification, task status. */
21
+ type: "exit" | "output_match" | "file_changed" | "task_status";
22
+ /** Pattern or value to match (regex for output_match, status name for task_status). */
23
+ value?: string;
24
+ }
25
+ export declare const MONITOR_TOOL_SCHEMA: {
26
+ readonly type: "object";
27
+ readonly properties: {
28
+ readonly action: {
29
+ readonly type: "string";
30
+ readonly enum: readonly ["start", "stop", "list"];
31
+ readonly description: "Action to perform: start a new monitor, stop an existing one, or list active monitors.";
32
+ };
33
+ readonly monitorId: {
34
+ readonly type: "string";
35
+ readonly description: "Identifier for the monitor instance. Required for start/stop.";
36
+ };
37
+ readonly source: {
38
+ readonly type: "string";
39
+ readonly enum: readonly ["process", "file", "task", "custom"];
40
+ readonly description: "Type of event source to watch.";
41
+ };
42
+ readonly target: {
43
+ readonly type: "string";
44
+ readonly description: string;
45
+ };
46
+ readonly conditions: {
47
+ readonly type: "array";
48
+ readonly items: {
49
+ readonly type: "object";
50
+ readonly properties: {
51
+ readonly type: {
52
+ readonly type: "string";
53
+ readonly enum: readonly ["exit", "output_match", "file_changed", "task_status"];
54
+ };
55
+ readonly value: {
56
+ readonly type: "string";
57
+ };
58
+ };
59
+ readonly required: readonly ["type"];
60
+ };
61
+ readonly description: "Conditions that trigger a wake-up notification.";
62
+ };
63
+ readonly timeoutSeconds: {
64
+ readonly type: "number";
65
+ readonly description: "Auto-stop after this many seconds (default: 3600).";
66
+ readonly minimum: 1;
67
+ readonly maximum: 86400;
68
+ };
69
+ };
70
+ readonly required: readonly ["action"];
71
+ };
72
+ /** Info about an active monitor. */
73
+ export interface MonitorInfo {
74
+ monitorId: string;
75
+ source: MonitorSource;
76
+ target: string;
77
+ conditions: MonitorCondition[];
78
+ startedAt: number;
79
+ timeoutSeconds: number;
80
+ /** Events received so far. */
81
+ eventCount: number;
82
+ }
83
+ /** Result of monitor operations. */
84
+ export interface MonitorResult {
85
+ action: MonitorAction;
86
+ success: boolean;
87
+ monitorId?: string;
88
+ monitors?: MonitorInfo[];
89
+ error?: string;
90
+ }
91
+ /**
92
+ * Runtime dependencies injected by the host.
93
+ *
94
+ * The host is responsible for:
95
+ * 1. Actually watching the event source (polling, inotify, process hooks, etc.)
96
+ * 2. Delivering notifications back to the agent loop (via tick or wake-up)
97
+ * 3. Cleaning up monitors when they time out or are stopped.
98
+ */
99
+ export interface MonitorToolDeps {
100
+ /** Start monitoring a target. Returns the created monitor info. */
101
+ startMonitor(params: {
102
+ monitorId: string;
103
+ source: MonitorSource;
104
+ target: string;
105
+ conditions: MonitorCondition[];
106
+ timeoutSeconds: number;
107
+ }): Promise<MonitorResult>;
108
+ /** Stop an active monitor. */
109
+ stopMonitor(monitorId: string): Promise<MonitorResult>;
110
+ /** List all active monitors for this session. */
111
+ listMonitors(): Promise<MonitorInfo[]>;
112
+ }
113
+ export declare function createMonitorTool(deps: MonitorToolDeps): PortableTool<MonitorToolParams>;
@@ -0,0 +1,55 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ export declare const MUSIC_GENERATE_TOOL_NAME: "music_generate";
3
+ export interface MusicGenerateToolParams {
4
+ prompt: string;
5
+ purpose?: string;
6
+ style?: string;
7
+ lyrics?: string;
8
+ duration?: number;
9
+ }
10
+ export declare const MUSIC_GENERATE_TOOL_SCHEMA: {
11
+ readonly type: "object";
12
+ readonly properties: {
13
+ readonly prompt: {
14
+ readonly type: "string";
15
+ readonly description: string;
16
+ };
17
+ readonly purpose: {
18
+ readonly type: "string";
19
+ readonly description: "Intended use: 'background-music', 'ringtone', 'short-video-bgm', 'full-song', 'notification-sound', etc.";
20
+ };
21
+ readonly style: {
22
+ readonly type: "string";
23
+ readonly description: "Musical style/genre: 'lo-fi', 'pop', 'rock', 'jazz', 'classical', 'electronic', 'ambient', etc.";
24
+ };
25
+ readonly lyrics: {
26
+ readonly type: "string";
27
+ readonly description: "Optional lyrics for vocal music. Structure with [verse], [chorus], [bridge] tags if desired.";
28
+ };
29
+ readonly duration: {
30
+ readonly type: "number";
31
+ readonly description: "Duration in seconds (5-300). Infer from purpose: ringtone 15-30s, BGM 30-60s, full song 120-180s.";
32
+ };
33
+ };
34
+ readonly required: readonly ["prompt"];
35
+ };
36
+ export interface MusicGenerateResult {
37
+ mediaUrls: string[];
38
+ model?: string;
39
+ durationMs?: number;
40
+ }
41
+ /** Deps injected by the host runtime for music generation. */
42
+ export interface MusicGenerateToolDeps {
43
+ /**
44
+ * Generate music via the configured backend.
45
+ * The host handles model selection, failover, and storage.
46
+ */
47
+ generateMusic(params: {
48
+ prompt: string;
49
+ purpose?: string;
50
+ style?: string;
51
+ lyrics?: string;
52
+ duration?: number;
53
+ }): Promise<MusicGenerateResult>;
54
+ }
55
+ export declare function createMusicGenerateTool(deps: MusicGenerateToolDeps): PortableTool<MusicGenerateToolParams>;
@@ -0,0 +1,15 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ export type NotebookEditMode = "replace" | "insert" | "delete";
3
+ export interface NotebookEditParams {
4
+ /** Absolute path to the .ipynb file */
5
+ notebook_path: string;
6
+ /** Cell number (1-based) to operate on */
7
+ cell_number: number;
8
+ /** New cell source content (required for replace/insert) */
9
+ new_source?: string;
10
+ /** Cell type for insert (default: "code") */
11
+ cell_type?: "code" | "markdown";
12
+ /** Edit mode (default: "replace") */
13
+ edit_mode?: NotebookEditMode;
14
+ }
15
+ export declare function createNotebookEditTool(): PortableTool<NotebookEditParams>;
@@ -0,0 +1,53 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ export declare const NOTIFY_TOOL_NAME: "notify";
3
+ export interface NotifyToolParams {
4
+ /** Notification message */
5
+ message: string;
6
+ /** Optional title/subject */
7
+ title?: string;
8
+ /** Priority level */
9
+ priority?: "low" | "normal" | "high";
10
+ /** Target channel override (default: user's primary channel) */
11
+ channel?: string;
12
+ }
13
+ export declare const NOTIFY_TOOL_SCHEMA: {
14
+ readonly type: "object";
15
+ readonly properties: {
16
+ readonly message: {
17
+ readonly type: "string";
18
+ readonly description: "Notification content to send to the user.";
19
+ };
20
+ readonly title: {
21
+ readonly type: "string";
22
+ readonly description: "Optional notification title/subject line.";
23
+ };
24
+ readonly priority: {
25
+ readonly type: "string";
26
+ readonly enum: readonly ["low", "normal", "high"];
27
+ readonly description: "Notification priority (default: normal). High may trigger sound/vibration.";
28
+ };
29
+ readonly channel: {
30
+ readonly type: "string";
31
+ readonly description: "Target delivery channel (e.g. 'wechat', 'feishu', 'discord'). Default: user's primary.";
32
+ };
33
+ };
34
+ readonly required: readonly ["message"];
35
+ };
36
+ export interface NotifyResult {
37
+ delivered: boolean;
38
+ channel: string;
39
+ error?: string;
40
+ }
41
+ /**
42
+ * Host-provided notification delivery backend.
43
+ */
44
+ export interface NotifyToolDeps {
45
+ /** Send notification to user. Host routes to correct platform. */
46
+ sendNotification(params: {
47
+ message: string;
48
+ title?: string;
49
+ priority?: string;
50
+ channel?: string;
51
+ }): Promise<NotifyResult>;
52
+ }
53
+ export declare function createNotifyTool(deps: NotifyToolDeps): PortableTool<NotifyToolParams>;
@@ -0,0 +1,45 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ export declare const PATCH_TOOL_NAME: "patch";
3
+ export interface PatchToolParams {
4
+ /** V4A unified diff or simple find-replace */
5
+ input: string;
6
+ /** When true, replace all occurrences in each file (default: false) */
7
+ replaceAll?: boolean;
8
+ }
9
+ export declare const PATCH_TOOL_SCHEMA: {
10
+ readonly type: "object";
11
+ readonly properties: {
12
+ readonly input: {
13
+ readonly type: "string";
14
+ readonly description: string;
15
+ };
16
+ readonly replaceAll: {
17
+ readonly type: "boolean";
18
+ readonly description: "Replace all occurrences instead of first only (default: false).";
19
+ };
20
+ };
21
+ readonly required: readonly ["input"];
22
+ };
23
+ export interface PatchResult {
24
+ filesModified: string[];
25
+ filesAdded: string[];
26
+ filesDeleted: string[];
27
+ strategies: Record<string, string>;
28
+ errors: string[];
29
+ }
30
+ export interface PatchToolDeps {
31
+ readFile(path: string): Promise<string>;
32
+ writeFile(path: string, content: string): Promise<void>;
33
+ deleteFile(path: string): Promise<void>;
34
+ fileExists(path: string): Promise<boolean>;
35
+ resolvePath(input: string): string;
36
+ }
37
+ export type MatchStrategy = "exact" | "line_trimmed" | "whitespace_normalized" | "indentation_flexible" | "escape_normalized" | "trimmed_boundary" | "unicode_normalized" | "block_anchor" | "context_aware";
38
+ interface MatchResult {
39
+ start: number;
40
+ end: number;
41
+ strategy: MatchStrategy;
42
+ }
43
+ declare function fuzzyFind(content: string, search: string, replaceAll: boolean): MatchResult[];
44
+ export declare function createPatchTool(deps: PatchToolDeps): PortableTool<PatchToolParams>;
45
+ export { fuzzyFind, type MatchResult };
@@ -0,0 +1,66 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ export declare const PDF_TOOL_NAME: "pdf";
3
+ export interface PdfToolParams {
4
+ prompt?: string;
5
+ pdf?: string;
6
+ pdfs?: string[];
7
+ pages?: string;
8
+ }
9
+ export declare const PDF_TOOL_SCHEMA: {
10
+ readonly type: "object";
11
+ readonly properties: {
12
+ readonly prompt: {
13
+ readonly type: "string";
14
+ readonly description: "Describe what to analyze or extract from the PDF(s).";
15
+ };
16
+ readonly pdf: {
17
+ readonly type: "string";
18
+ readonly description: "Single PDF path or URL.";
19
+ };
20
+ readonly pdfs: {
21
+ readonly type: "array";
22
+ readonly items: {
23
+ readonly type: "string";
24
+ };
25
+ readonly description: "Multiple PDF paths or URLs (up to 10).";
26
+ };
27
+ readonly pages: {
28
+ readonly type: "string";
29
+ readonly description: "Page range to process, e.g. \"1-5\", \"1,3,5-7\". Defaults to all pages.";
30
+ };
31
+ };
32
+ readonly required: readonly [];
33
+ };
34
+ /** Deps injected by the host runtime for PDF analysis. */
35
+ export interface PdfToolDeps {
36
+ /**
37
+ * Extract text and/or page images from a PDF.
38
+ * The host decides how to load (local FS, HTTP, etc.).
39
+ */
40
+ extractPdf(source: string, options?: {
41
+ pages?: string;
42
+ }): Promise<{
43
+ text: string;
44
+ pageImages?: Array<{
45
+ page: number;
46
+ base64: string;
47
+ mimeType: string;
48
+ }>;
49
+ }>;
50
+ /**
51
+ * Optional: analyze extracted content via LLM.
52
+ * If not provided, the tool returns raw extracted text.
53
+ */
54
+ analyzePdfContent?(prompt: string, content: {
55
+ text: string;
56
+ images?: Array<{
57
+ base64: string;
58
+ mimeType: string;
59
+ }>;
60
+ }): Promise<{
61
+ text: string;
62
+ model?: string;
63
+ provider?: string;
64
+ }>;
65
+ }
66
+ export declare function createPdfTool(deps: PdfToolDeps): PortableTool<PdfToolParams>;