qlogicagent 0.5.2 → 0.6.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.
- package/README.md +403 -402
- package/dist/agent.js +18 -0
- package/dist/cli.js +384 -0
- package/dist/contracts.js +1 -0
- package/dist/index.js +383 -0
- package/dist/orchestration.js +34 -0
- package/dist/types/agent/agent.d.ts +43 -0
- package/dist/types/agent/constants.d.ts +47 -0
- package/dist/types/agent/tool-access.d.ts +30 -0
- package/dist/types/agent/tool-loop.d.ts +94 -0
- package/dist/types/agent/types.d.ts +238 -0
- package/dist/types/cli/main.d.ts +11 -0
- package/dist/types/cli/stdio-server.d.ts +78 -0
- package/dist/types/cli/tool-bootstrap.d.ts +40 -0
- package/dist/types/cli/transport.d.ts +40 -0
- package/dist/types/config/config.d.ts +17 -0
- package/dist/types/contracts/hooks.d.ts +175 -0
- package/dist/types/contracts/index.d.ts +9 -0
- package/dist/types/contracts/planner.d.ts +35 -0
- package/dist/types/contracts/todo.d.ts +23 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/llm/builtin-providers.d.ts +10 -0
- package/dist/types/llm/debug-transport.d.ts +12 -0
- package/dist/types/llm/index.d.ts +16 -0
- package/dist/types/llm/llm-client.d.ts +43 -0
- package/dist/types/llm/model-catalog.d.ts +53 -0
- package/dist/types/llm/provider-def.d.ts +59 -0
- package/dist/types/llm/provider-registry.d.ts +54 -0
- package/dist/types/llm/transport.d.ts +62 -0
- package/dist/types/llm/transports/anthropic-messages.d.ts +31 -0
- package/dist/types/llm/transports/openai-chat.d.ts +36 -0
- package/dist/types/orchestration/context/context-collapse.d.ts +58 -0
- package/dist/types/orchestration/context/context-compression.d.ts +301 -0
- package/dist/types/orchestration/context/reactive-compact.d.ts +73 -0
- package/dist/types/orchestration/context/turn-loop-guard.d.ts +86 -0
- package/dist/types/orchestration/error-handling/error-classification.d.ts +12 -0
- package/dist/types/orchestration/error-handling/failover-classification.d.ts +8 -0
- package/dist/types/orchestration/error-handling/failover-error.d.ts +33 -0
- package/dist/types/orchestration/error-handling/retry-loop.d.ts +69 -0
- package/dist/types/orchestration/index.d.ts +15 -0
- package/dist/types/orchestration/skill-improvement.d.ts +59 -0
- package/dist/types/orchestration/subagent/agent-registry.d.ts +46 -0
- package/dist/types/orchestration/subagent/fork-subagent.d.ts +98 -0
- package/dist/types/orchestration/subagent/task-types.d.ts +142 -0
- package/dist/types/orchestration/tool-loop/conversation-repair.d.ts +61 -0
- package/dist/types/orchestration/tool-loop/tool-choice-policy.d.ts +54 -0
- package/dist/types/orchestration/tool-loop/tool-loop-state.d.ts +50 -0
- package/dist/types/orchestration/tool-loop/tool-schema.d.ts +39 -0
- package/dist/types/runtime/execution/dream-agent.d.ts +199 -0
- package/dist/types/runtime/execution/forked-agent.d.ts +109 -0
- package/dist/types/runtime/execution/index.d.ts +6 -0
- package/dist/types/runtime/execution/progress-tracker.d.ts +78 -0
- package/dist/types/runtime/execution/remote-agent.d.ts +63 -0
- package/dist/types/runtime/execution/streaming-tool-executor.d.ts +100 -0
- package/dist/types/runtime/execution/tool-eligibility.d.ts +59 -0
- package/dist/types/runtime/execution/tool-result-storage.d.ts +87 -0
- package/dist/types/runtime/hooks/context-compression.d.ts +61 -0
- package/dist/types/runtime/hooks/hook-registry.d.ts +12 -0
- package/dist/types/runtime/hooks/index.d.ts +3 -0
- package/dist/types/runtime/hooks/memory-hooks.d.ts +49 -0
- package/dist/types/runtime/index.d.ts +5 -0
- package/dist/types/runtime/infra/agent-paths.d.ts +57 -0
- package/dist/types/runtime/infra/checkpoint-backend.d.ts +8 -0
- package/dist/types/runtime/infra/cleanup-registry.d.ts +23 -0
- package/dist/types/runtime/infra/disk-storage.d.ts +36 -0
- package/dist/types/runtime/infra/file-watcher.d.ts +72 -0
- package/dist/types/runtime/infra/index.d.ts +8 -0
- package/dist/types/runtime/infra/secure-storage.d.ts +81 -0
- package/dist/types/runtime/infra/task-runtime.d.ts +108 -0
- package/dist/types/runtime/infra/token-budget.d.ts +92 -0
- package/dist/types/runtime/infra/worktree-backend.d.ts +85 -0
- package/dist/types/runtime/prompt/environment-context.d.ts +23 -0
- package/dist/types/runtime/prompt/index.d.ts +3 -0
- package/dist/types/runtime/prompt/instruction-loader.d.ts +64 -0
- package/dist/types/runtime/prompt/system-prompt-sections.d.ts +63 -0
- package/dist/types/runtime/session/index.d.ts +2 -0
- package/dist/types/runtime/session/session-memory.d.ts +90 -0
- package/dist/types/runtime/session/session-persistence.d.ts +94 -0
- package/dist/types/runtime/session/session-state.d.ts +117 -0
- package/dist/types/skills/index.d.ts +119 -0
- package/dist/types/skills/mcp/index.d.ts +3 -0
- package/dist/types/skills/mcp/mcp-http-client.d.ts +66 -0
- package/dist/types/skills/mcp/mcp-manager.d.ts +83 -0
- package/dist/types/skills/mcp/mcp-stdio-client.d.ts +84 -0
- package/dist/types/skills/memory/memory-extractor.d.ts +64 -0
- package/dist/types/skills/memory/memory-store.d.ts +86 -0
- package/dist/types/skills/memory/memory-tool.d.ts +87 -0
- package/dist/types/skills/memory/qmemory-adapter.d.ts +42 -0
- package/dist/types/skills/permissions/bash-classifier.d.ts +30 -0
- package/dist/types/skills/permissions/classifier-cache.d.ts +51 -0
- package/dist/types/skills/permissions/denial-tracking.d.ts +42 -0
- package/dist/types/skills/permissions/hook-runner.d.ts +85 -0
- package/dist/types/skills/permissions/index.d.ts +12 -0
- package/dist/types/skills/permissions/permission-classifier.d.ts +41 -0
- package/dist/types/skills/permissions/rule-engine.d.ts +41 -0
- package/dist/types/skills/permissions/settings-watcher.d.ts +46 -0
- package/dist/types/skills/permissions/types.d.ts +113 -0
- package/dist/types/skills/plugins/index.d.ts +2 -0
- package/dist/types/skills/plugins/plugin-api.d.ts +38 -0
- package/dist/types/skills/plugins/plugin-loader.d.ts +42 -0
- package/dist/types/skills/plugins/plugin-marketplace.d.ts +61 -0
- package/dist/types/skills/portable-tool.d.ts +104 -0
- package/dist/types/skills/skill-system/skill-frontmatter.d.ts +19 -0
- package/dist/types/skills/skill-system/skill-guard.d.ts +23 -0
- package/dist/types/skills/skill-system/skill-loader.d.ts +16 -0
- package/dist/types/skills/skill-system/skill-source.d.ts +119 -0
- package/dist/types/skills/skill-system/skill-types.d.ts +199 -0
- package/dist/types/skills/think-tool.d.ts +16 -0
- package/dist/types/skills/todo-tool.d.ts +72 -0
- package/dist/types/skills/tools/agent-tool.d.ts +91 -0
- package/dist/types/skills/tools/apply-patch-tool.d.ts +29 -0
- package/dist/types/skills/tools/ask-user-tool.d.ts +80 -0
- package/dist/types/skills/tools/brief-tool.d.ts +74 -0
- package/dist/types/skills/tools/browser-tool.d.ts +114 -0
- package/dist/types/skills/tools/checkpoint-tool.d.ts +66 -0
- package/dist/types/skills/tools/config-tool.d.ts +63 -0
- package/dist/types/skills/tools/cron-tool.d.ts +116 -0
- package/dist/types/skills/tools/edit-tool.d.ts +43 -0
- package/dist/types/skills/tools/exec-tool.d.ts +97 -0
- package/dist/types/skills/tools/image-generate-tool.d.ts +62 -0
- package/dist/types/skills/tools/instructions-tool.d.ts +65 -0
- package/dist/types/skills/tools/lsp-tool.d.ts +153 -0
- package/dist/types/skills/tools/mcp-client-types.d.ts +269 -0
- package/dist/types/skills/tools/mcp-resource-tools.d.ts +14 -0
- package/dist/types/skills/tools/mcp-tool.d.ts +249 -0
- package/dist/types/skills/tools/monitor-tool.d.ts +113 -0
- package/dist/types/skills/tools/music-generate-tool.d.ts +55 -0
- package/dist/types/skills/tools/notebook-edit-tool.d.ts +15 -0
- package/dist/types/skills/tools/notify-tool.d.ts +53 -0
- package/dist/types/skills/tools/patch-tool.d.ts +45 -0
- package/dist/types/skills/tools/plan-mode-tool.d.ts +98 -0
- package/dist/types/skills/tools/read-tool.d.ts +51 -0
- package/dist/types/skills/tools/repl-tool.d.ts +70 -0
- package/dist/types/skills/tools/search-tool.d.ts +112 -0
- package/dist/types/skills/tools/send-message-tool.d.ts +51 -0
- package/dist/types/skills/tools/shell/bash-provider.d.ts +26 -0
- package/dist/types/skills/tools/shell/command-classification.d.ts +44 -0
- package/dist/types/skills/tools/shell/command-semantics.d.ts +14 -0
- package/dist/types/skills/tools/shell/destructive-command-warning.d.ts +10 -0
- package/dist/types/skills/tools/shell/exec-permissions.d.ts +52 -0
- package/dist/types/skills/tools/shell/index.d.ts +17 -0
- package/dist/types/skills/tools/shell/powershell-provider.d.ts +15 -0
- package/dist/types/skills/tools/shell/shell-command.d.ts +54 -0
- package/dist/types/skills/tools/shell/shell-exec.d.ts +33 -0
- package/dist/types/skills/tools/shell/shell-provider.d.ts +85 -0
- package/dist/types/skills/tools/shell/task-output.d.ts +45 -0
- package/dist/types/skills/tools/skill-invoke-tool.d.ts +46 -0
- package/dist/types/skills/tools/skill-list-tool.d.ts +33 -0
- package/dist/types/skills/tools/skill-manage-tool.d.ts +73 -0
- package/dist/types/skills/tools/skill-view-tool.d.ts +37 -0
- package/dist/types/skills/tools/sleep-tool.d.ts +49 -0
- package/dist/types/skills/tools/structured-output-tool.d.ts +116 -0
- package/dist/types/skills/tools/task-tool.d.ts +104 -0
- package/dist/types/skills/tools/team-tool.d.ts +89 -0
- package/dist/types/skills/tools/tool-search-tool.d.ts +51 -0
- package/dist/types/skills/tools/tts-tool.d.ts +38 -0
- package/dist/types/skills/tools/video-edit-tool.d.ts +69 -0
- package/dist/types/skills/tools/video-generate-tool.d.ts +62 -0
- package/dist/types/skills/tools/video-merge-tool.d.ts +105 -0
- package/dist/types/skills/tools/video-upscale-tool.d.ts +45 -0
- package/dist/types/skills/tools/web-fetch-tool.d.ts +78 -0
- package/dist/types/skills/tools/web-search-tool.d.ts +57 -0
- package/dist/types/skills/tools/workflow-tool.d.ts +44 -0
- package/dist/types/skills/tools/worktree-tool.d.ts +69 -0
- package/dist/types/skills/tools/write-tool.d.ts +45 -0
- package/dist/types/skills/tools.d.ts +65 -0
- package/package.json +4 -3
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/** Supported MCP transport types */
|
|
2
|
+
export type McpTransportType = "stdio" | "sse" | "http" | "ws" | "in-process";
|
|
3
|
+
/** Stdio transport configuration */
|
|
4
|
+
export interface McpStdioConfig {
|
|
5
|
+
type: "stdio";
|
|
6
|
+
command: string;
|
|
7
|
+
args?: string[];
|
|
8
|
+
env?: Record<string, string>;
|
|
9
|
+
cwd?: string;
|
|
10
|
+
}
|
|
11
|
+
/** SSE transport configuration */
|
|
12
|
+
export interface McpSseConfig {
|
|
13
|
+
type: "sse";
|
|
14
|
+
url: string;
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
/** OAuth config for auth-required SSE servers */
|
|
17
|
+
oauth?: McpOAuthConfig;
|
|
18
|
+
}
|
|
19
|
+
/** Streamable HTTP transport configuration (MCP 2025-03-26) */
|
|
20
|
+
export interface McpHttpConfig {
|
|
21
|
+
type: "http";
|
|
22
|
+
url: string;
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
/** OAuth config for auth-required HTTP servers */
|
|
25
|
+
oauth?: McpOAuthConfig;
|
|
26
|
+
}
|
|
27
|
+
/** WebSocket transport configuration */
|
|
28
|
+
export interface McpWsConfig {
|
|
29
|
+
type: "ws";
|
|
30
|
+
url: string;
|
|
31
|
+
headers?: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
/** In-process transport (bundled MCP servers) */
|
|
34
|
+
export interface McpInProcessConfig {
|
|
35
|
+
type: "in-process";
|
|
36
|
+
/** Module identifier to load */
|
|
37
|
+
moduleId: string;
|
|
38
|
+
/** Init args passed to the in-process server */
|
|
39
|
+
initArgs?: Record<string, unknown>;
|
|
40
|
+
}
|
|
41
|
+
/** Union of all transport configurations */
|
|
42
|
+
export type McpServerConfig = McpStdioConfig | McpSseConfig | McpHttpConfig | McpWsConfig | McpInProcessConfig;
|
|
43
|
+
/** OAuth configuration for remote MCP servers */
|
|
44
|
+
export interface McpOAuthConfig {
|
|
45
|
+
/** Client ID (or URL-based client_id per CIMD/SEP-991) */
|
|
46
|
+
clientId?: string;
|
|
47
|
+
/** Client secret (optional, for confidential clients) */
|
|
48
|
+
clientSecret?: string;
|
|
49
|
+
/** Override authorization endpoint (otherwise discovered via RFC 8414) */
|
|
50
|
+
authorizationEndpoint?: string;
|
|
51
|
+
/** Override token endpoint */
|
|
52
|
+
tokenEndpoint?: string;
|
|
53
|
+
/** Requested scopes */
|
|
54
|
+
scopes?: string[];
|
|
55
|
+
/** Fixed callback port (otherwise picks random available port) */
|
|
56
|
+
callbackPort?: number;
|
|
57
|
+
/** Audience for token exchange (RFC 8693) */
|
|
58
|
+
audience?: string;
|
|
59
|
+
}
|
|
60
|
+
/** OAuth token set */
|
|
61
|
+
export interface McpOAuthTokens {
|
|
62
|
+
accessToken: string;
|
|
63
|
+
tokenType: string;
|
|
64
|
+
refreshToken?: string;
|
|
65
|
+
expiresAt?: number;
|
|
66
|
+
scope?: string;
|
|
67
|
+
}
|
|
68
|
+
/** Authentication state of a server */
|
|
69
|
+
export type McpAuthState = {
|
|
70
|
+
status: "authenticated";
|
|
71
|
+
tokens: McpOAuthTokens;
|
|
72
|
+
} | {
|
|
73
|
+
status: "needs-auth";
|
|
74
|
+
authUrl?: string;
|
|
75
|
+
message?: string;
|
|
76
|
+
} | {
|
|
77
|
+
status: "refreshing";
|
|
78
|
+
} | {
|
|
79
|
+
status: "step-up-required";
|
|
80
|
+
scope: string;
|
|
81
|
+
authUrl?: string;
|
|
82
|
+
} | {
|
|
83
|
+
status: "not-applicable";
|
|
84
|
+
};
|
|
85
|
+
/** Server connection status */
|
|
86
|
+
export type McpConnectionStatus = "connected" | "connecting" | "disconnected" | "failed" | "needs-auth" | "disabled";
|
|
87
|
+
/** Server capabilities (as reported by initialize) */
|
|
88
|
+
export interface McpServerCapabilities {
|
|
89
|
+
tools?: {
|
|
90
|
+
listChanged?: boolean;
|
|
91
|
+
};
|
|
92
|
+
resources?: {
|
|
93
|
+
subscribe?: boolean;
|
|
94
|
+
listChanged?: boolean;
|
|
95
|
+
};
|
|
96
|
+
prompts?: {
|
|
97
|
+
listChanged?: boolean;
|
|
98
|
+
};
|
|
99
|
+
logging?: Record<string, unknown>;
|
|
100
|
+
experimental?: Record<string, unknown>;
|
|
101
|
+
}
|
|
102
|
+
/** Full server connection state */
|
|
103
|
+
export interface McpServerState {
|
|
104
|
+
name: string;
|
|
105
|
+
config: McpServerConfig;
|
|
106
|
+
status: McpConnectionStatus;
|
|
107
|
+
capabilities?: McpServerCapabilities;
|
|
108
|
+
serverVersion?: string;
|
|
109
|
+
serverInstructions?: string;
|
|
110
|
+
error?: string;
|
|
111
|
+
/** Timestamp of last successful connection */
|
|
112
|
+
connectedAt?: number;
|
|
113
|
+
/** Number of reconnect attempts since last disconnect */
|
|
114
|
+
reconnectAttempts?: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* An MCP tool definition as reported by tools/list.
|
|
118
|
+
* The host converts these into PortableTool entries for the LLM.
|
|
119
|
+
*/
|
|
120
|
+
export interface McpExternalTool {
|
|
121
|
+
/** Tool name on the MCP server (original) */
|
|
122
|
+
name: string;
|
|
123
|
+
/** Tool description */
|
|
124
|
+
description?: string;
|
|
125
|
+
/** JSON Schema for input parameters */
|
|
126
|
+
inputSchema?: Record<string, unknown>;
|
|
127
|
+
/** Annotations from the server (readOnlyHint, destructiveHint, etc.) */
|
|
128
|
+
annotations?: McpToolAnnotations;
|
|
129
|
+
}
|
|
130
|
+
/** Tool behavior annotations (MCP 2025-03-26 spec) */
|
|
131
|
+
export interface McpToolAnnotations {
|
|
132
|
+
/** Hints that the tool performs only reads */
|
|
133
|
+
readOnlyHint?: boolean;
|
|
134
|
+
/** Hints that the tool may be destructive */
|
|
135
|
+
destructiveHint?: boolean;
|
|
136
|
+
/** Hints that the tool is idempotent */
|
|
137
|
+
idempotentHint?: boolean;
|
|
138
|
+
/** Hints about concurrency safety */
|
|
139
|
+
openWorldHint?: boolean;
|
|
140
|
+
/** Human-readable title for UI display */
|
|
141
|
+
title?: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Prefixed tool name format: mcp__{normalizedServer}__{normalizedTool}
|
|
145
|
+
* This ensures no collisions with built-in tools.
|
|
146
|
+
*/
|
|
147
|
+
export interface McpToolIdentifier {
|
|
148
|
+
serverName: string;
|
|
149
|
+
toolName: string;
|
|
150
|
+
/** Full prefixed name: mcp__{server}__{tool} */
|
|
151
|
+
prefixedName: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Notification payload when a server's tool list changes.
|
|
155
|
+
* The host should re-fetch tools/list and hot-swap the tool set.
|
|
156
|
+
*/
|
|
157
|
+
export interface McpToolsChangedEvent {
|
|
158
|
+
serverName: string;
|
|
159
|
+
/** Previous tool names (for diff-based cleanup) */
|
|
160
|
+
previousTools: string[];
|
|
161
|
+
/** Updated tool list */
|
|
162
|
+
currentTools: McpExternalTool[];
|
|
163
|
+
}
|
|
164
|
+
/** MCP Resource definition */
|
|
165
|
+
export interface McpResourceDefinition {
|
|
166
|
+
uri: string;
|
|
167
|
+
name: string;
|
|
168
|
+
mimeType?: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
/** Size in bytes (if known) */
|
|
171
|
+
size?: number;
|
|
172
|
+
}
|
|
173
|
+
/** Resource template (parameterized URI) */
|
|
174
|
+
export interface McpResourceTemplate {
|
|
175
|
+
uriTemplate: string;
|
|
176
|
+
name: string;
|
|
177
|
+
mimeType?: string;
|
|
178
|
+
description?: string;
|
|
179
|
+
}
|
|
180
|
+
/** Content of a read resource */
|
|
181
|
+
export interface McpResourceContentItem {
|
|
182
|
+
uri: string;
|
|
183
|
+
mimeType?: string;
|
|
184
|
+
/** Text content (mutually exclusive with blob) */
|
|
185
|
+
text?: string;
|
|
186
|
+
/** Base64-encoded binary (mutually exclusive with text) */
|
|
187
|
+
blob?: string;
|
|
188
|
+
}
|
|
189
|
+
/** Persisted resource content (after binary blob handling) */
|
|
190
|
+
export interface McpPersistedResourceContent {
|
|
191
|
+
uri: string;
|
|
192
|
+
mimeType?: string;
|
|
193
|
+
text?: string;
|
|
194
|
+
/** Path where binary was saved to disk */
|
|
195
|
+
blobSavedTo?: string;
|
|
196
|
+
/** Size of persisted binary in bytes */
|
|
197
|
+
blobSize?: number;
|
|
198
|
+
}
|
|
199
|
+
/** MCP Prompt definition from prompts/list */
|
|
200
|
+
export interface McpPromptDefinition {
|
|
201
|
+
name: string;
|
|
202
|
+
description?: string;
|
|
203
|
+
arguments?: McpPromptArgument[];
|
|
204
|
+
}
|
|
205
|
+
/** Argument for an MCP prompt */
|
|
206
|
+
export interface McpPromptArgument {
|
|
207
|
+
name: string;
|
|
208
|
+
description?: string;
|
|
209
|
+
required?: boolean;
|
|
210
|
+
}
|
|
211
|
+
/** Result of prompts/get — prompt content messages */
|
|
212
|
+
export interface McpPromptMessage {
|
|
213
|
+
role: "user" | "assistant";
|
|
214
|
+
content: McpPromptContent;
|
|
215
|
+
}
|
|
216
|
+
export type McpPromptContent = {
|
|
217
|
+
type: "text";
|
|
218
|
+
text: string;
|
|
219
|
+
} | {
|
|
220
|
+
type: "image";
|
|
221
|
+
data: string;
|
|
222
|
+
mimeType: string;
|
|
223
|
+
} | {
|
|
224
|
+
type: "resource";
|
|
225
|
+
resource: {
|
|
226
|
+
uri: string;
|
|
227
|
+
text?: string;
|
|
228
|
+
blob?: string;
|
|
229
|
+
mimeType?: string;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
/** MCP Elicitation request (server asks user for input) */
|
|
233
|
+
export interface McpElicitRequest {
|
|
234
|
+
message: string;
|
|
235
|
+
requestedSchema?: Record<string, unknown>;
|
|
236
|
+
}
|
|
237
|
+
/** Elicitation response */
|
|
238
|
+
export interface McpElicitResult {
|
|
239
|
+
action: "accept" | "deny" | "cancel";
|
|
240
|
+
content?: Record<string, unknown>;
|
|
241
|
+
}
|
|
242
|
+
export type McpLogLevel = "debug" | "info" | "warning" | "error" | "critical";
|
|
243
|
+
export interface McpLogEntry {
|
|
244
|
+
serverName: string;
|
|
245
|
+
level: McpLogLevel;
|
|
246
|
+
logger?: string;
|
|
247
|
+
data: unknown;
|
|
248
|
+
timestamp: number;
|
|
249
|
+
}
|
|
250
|
+
export declare const MCP_CONNECTION_TIMEOUT_MS = 30000;
|
|
251
|
+
export declare const MCP_REQUEST_TIMEOUT_MS = 60000;
|
|
252
|
+
export declare const MCP_TOOL_CALL_TIMEOUT_MS = 100000;
|
|
253
|
+
export declare const MCP_MAX_RECONNECT_ATTEMPTS = 5;
|
|
254
|
+
export declare const MCP_RECONNECT_BASE_DELAY_MS = 1000;
|
|
255
|
+
export declare const MCP_RECONNECT_MAX_DELAY_MS = 30000;
|
|
256
|
+
export declare const MCP_MAX_DESCRIPTION_LENGTH = 2048;
|
|
257
|
+
export declare const MCP_AUTH_CACHE_TTL_MS: number;
|
|
258
|
+
export declare const MCP_BATCH_SIZE_LOCAL = 3;
|
|
259
|
+
export declare const MCP_BATCH_SIZE_REMOTE = 20;
|
|
260
|
+
/** Normalize a name for use in the prefixed tool name format */
|
|
261
|
+
export declare function normalizeNameForMcp(name: string): string;
|
|
262
|
+
/** Build a prefixed tool name: mcp__{server}__{tool} */
|
|
263
|
+
export declare function buildMcpToolName(serverName: string, toolName: string): string;
|
|
264
|
+
/** Get the prefix for a server (for batch removal) */
|
|
265
|
+
export declare function getMcpServerPrefix(serverName: string): string;
|
|
266
|
+
/** Parse a prefixed tool name back into server + tool */
|
|
267
|
+
export declare function parseMcpToolName(prefixedName: string): McpToolIdentifier | null;
|
|
268
|
+
/** Check if a tool name is an MCP-injected tool */
|
|
269
|
+
export declare function isMcpToolName(name: string): boolean;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
import type { McpManager } from "../mcp/mcp-manager.js";
|
|
3
|
+
export interface ListMcpResourcesParams {
|
|
4
|
+
/** Filter by MCP server name (optional — omit to list from all servers) */
|
|
5
|
+
server?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function createListMcpResourcesTool(getMcpManager: () => McpManager | null): PortableTool<ListMcpResourcesParams>;
|
|
8
|
+
export interface ReadMcpResourceParams {
|
|
9
|
+
/** MCP server name */
|
|
10
|
+
server: string;
|
|
11
|
+
/** Resource URI to read */
|
|
12
|
+
uri: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function createReadMcpResourceTool(getMcpManager: () => McpManager | null): PortableTool<ReadMcpResourceParams>;
|
|
@@ -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,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>;
|