@cuylabs/agent-core 0.9.0 → 0.10.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 +33 -17
- package/dist/chunk-2O4MCSQS.js +780 -0
- package/dist/chunk-2TTOLHBT.js +198 -0
- package/dist/chunk-5FMSGQVX.js +281 -0
- package/dist/chunk-5NVVNXPQ.js +288 -0
- package/dist/{chunk-EKR6PKXU.js → chunk-6HZBHFOL.js} +3 -3
- package/dist/chunk-CJI7PVS2.js +58 -0
- package/dist/{chunk-WKHDSSXG.js → chunk-CMYN2RCB.js} +146 -46
- package/dist/chunk-FII65CN7.js +117 -0
- package/dist/{chunk-UHCJEM2E.js → chunk-ICZ66572.js} +13 -6
- package/dist/chunk-KYLPMBHD.js +316 -0
- package/dist/chunk-MXAP4UG6.js +2956 -0
- package/dist/{chunk-4QFNWPIF.js → chunk-N3VX7FEE.js} +35 -2
- package/dist/{chunk-MAZ5DY5B.js → chunk-NDZWXCBZ.js} +213 -78
- package/dist/{chunk-MHKK374K.js → chunk-Q742PSH3.js} +11 -27
- package/dist/{chunk-WGZAPU6N.js → chunk-QAL3OMI3.js} +15 -1
- package/dist/{chunk-UDCZ673N.js → chunk-RN6WZEUF.js} +27 -23
- package/dist/{chunk-ZXAKHMWH.js → chunk-ROTGCYDW.js} +22 -84
- package/dist/chunk-SPBFQXOT.js +0 -0
- package/dist/chunk-SSFBF3US.js +602 -0
- package/dist/chunk-SZ2XBPTW.js +8 -0
- package/dist/chunk-T4UIX5D7.js +115 -0
- package/dist/{chunk-IYWQOJMQ.js → chunk-TIHPYVAJ.js} +34 -34
- package/dist/{chunk-RKEW5WXI.js → chunk-TOTDGK3P.js} +1 -1
- package/dist/chunk-V4RFNEET.js +563 -0
- package/dist/chunk-VOUEJSW6.js +0 -0
- package/dist/{chunk-J4QDGZIA.js → chunk-WBPOZ7CL.js} +659 -275
- package/dist/chunk-X4VN4GIJ.js +185 -0
- package/dist/dispatch/index.d.ts +93 -0
- package/dist/dispatch/index.js +37 -0
- package/dist/events/index.d.ts +93 -0
- package/dist/events/index.js +6 -0
- package/dist/{runtime → execution}/index.d.ts +120 -35
- package/dist/{runtime → execution}/index.js +17 -11
- package/dist/index.d.ts +489 -115
- package/dist/index.js +1665 -462
- package/dist/inference/errors/index.js +1 -1
- package/dist/inference/index.d.ts +13 -21
- package/dist/inference/index.js +15 -12
- package/dist/instance-BqV2D5pc.d.ts +5723 -0
- package/dist/logger/index.d.ts +50 -0
- package/dist/logger/index.js +11 -0
- package/dist/mcp/index.d.ts +5 -9
- package/dist/mcp/index.js +2 -3
- package/dist/middleware/index.d.ts +10 -150
- package/dist/middleware/index.js +10 -2
- package/dist/model-messages-B4nK9D1-.d.ts +13 -0
- package/dist/models/index.d.ts +5 -2
- package/dist/models/index.js +2 -1
- package/dist/models/reasoning/index.js +2 -1
- package/dist/plugin/index.d.ts +55 -11
- package/dist/plugin/index.js +1 -1
- package/dist/profiles/index.d.ts +55 -0
- package/dist/{presets → profiles}/index.js +10 -10
- package/dist/prompt/index.d.ts +8 -13
- package/dist/safety/index.d.ts +109 -14
- package/dist/safety/index.js +59 -3
- package/dist/sandbox/index.d.ts +81 -0
- package/dist/sandbox/index.js +1 -0
- package/dist/skill/index.d.ts +10 -8
- package/dist/skill/index.js +2 -2
- package/dist/storage/index.d.ts +12 -4
- package/dist/storage/index.js +1 -1
- package/dist/subagents/index.d.ts +177 -0
- package/dist/subagents/index.js +78 -0
- package/dist/team/index.d.ts +544 -0
- package/dist/team/index.js +41 -0
- package/dist/tool/host/index.d.ts +41 -0
- package/dist/tool/host/index.js +10 -0
- package/dist/tool/index.d.ts +111 -21
- package/dist/tool/index.js +20 -13
- package/dist/{types-VQgymC1N.d.ts → types-Bj_J8u_W.d.ts} +44 -64
- package/dist/{types-CHiPh8U2.d.ts → types-C_LCeYNg.d.ts} +7 -7
- package/dist/types-RSCv7nQ4.d.ts +59 -0
- package/package.json +46 -47
- package/dist/builder-BgZ_j4Vs.d.ts +0 -35
- package/dist/chunk-5ARZJWD2.js +0 -259
- package/dist/chunk-DXFBQMXP.js +0 -53
- package/dist/chunk-H3FUYU52.js +0 -81
- package/dist/chunk-JLXG2SH7.js +0 -905
- package/dist/chunk-N7P4PN3O.js +0 -84
- package/dist/chunk-OFDKHNCX.js +0 -727
- package/dist/chunk-SDSBEQXG.js +0 -157
- package/dist/chunk-VEKUXUVF.js +0 -41
- package/dist/chunk-VNQBHPCT.js +0 -398
- package/dist/chunk-WWYYNWEW.js +0 -259
- package/dist/context/index.d.ts +0 -259
- package/dist/context/index.js +0 -26
- package/dist/events-CE72w8W4.d.ts +0 -149
- package/dist/host/index.d.ts +0 -45
- package/dist/host/index.js +0 -8
- package/dist/index-DQuTZ8xL.d.ts +0 -1335
- package/dist/messages-BYWGn8TY.d.ts +0 -110
- package/dist/presets/index.d.ts +0 -53
- package/dist/registry-DwYqsQkX.d.ts +0 -164
- package/dist/runner-CI-XeR16.d.ts +0 -91
- package/dist/scope/index.d.ts +0 -10
- package/dist/scope/index.js +0 -14
- package/dist/session-manager-KbYt2WUh.d.ts +0 -282
- package/dist/signal/index.d.ts +0 -28
- package/dist/signal/index.js +0 -6
- package/dist/sub-agent/index.d.ts +0 -24
- package/dist/sub-agent/index.js +0 -32
- package/dist/tool-CZWN3KbO.d.ts +0 -141
- package/dist/tool-DkhSCV2Y.d.ts +0 -145
- package/dist/tracker-DClqYqTj.d.ts +0 -96
- package/dist/tracking/index.d.ts +0 -111
- package/dist/tracking/index.js +0 -20
- package/dist/types-BfNpU8NS.d.ts +0 -270
- package/dist/types-BlOKk-Bb.d.ts +0 -330
- package/dist/types-BlZwmnuW.d.ts +0 -50
- package/dist/types-CQL-SvTn.d.ts +0 -29
- package/dist/types-CWm-7rvB.d.ts +0 -55
- package/dist/types-DTSkxakL.d.ts +0 -651
- package/dist/types-DmDwi2zI.d.ts +0 -339
- package/dist/types-YuWV4ag7.d.ts +0 -72
package/dist/tool/index.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { T as Tool } from '../
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import 'zod';
|
|
7
|
-
import '../types-CQL-SvTn.js';
|
|
8
|
-
import '../types-DTSkxakL.js';
|
|
1
|
+
import { dq as ToolReplayPolicy, F as FileOperationMeta, bN as NormalizedToolReplayPolicy, T as Tool, H as HumanInputController, a as TurnTrackerContext, b as MiddlewareRunner, A as AgentEvent, dn as ToolMetadata, dj as ToolCapabilities } from '../instance-BqV2D5pc.js';
|
|
2
|
+
export { az as CompatibleSchema, bo as InferSchemaOutput, bp as InputCheckResult, dL as getRequiredToolHost, dR as resolveCapability } from '../instance-BqV2D5pc.js';
|
|
3
|
+
import { T as ToolHost } from '../types-C_LCeYNg.js';
|
|
4
|
+
export { D as DirEntry, E as ExecOptions, a as ExecResult, F as FileStat } from '../types-C_LCeYNg.js';
|
|
5
|
+
export { ToolHostProvider, ToolHostProviderSummary, ToolHostRegistry, defaultToolHostRegistry, localHost } from './host/index.js';
|
|
9
6
|
import 'ai';
|
|
10
|
-
import '
|
|
11
|
-
import '
|
|
12
|
-
import '../messages-BYWGn8TY.js';
|
|
13
|
-
import '../types-BfNpU8NS.js';
|
|
7
|
+
import '../types-RSCv7nQ4.js';
|
|
8
|
+
import 'zod';
|
|
14
9
|
import '../types-CQaXbRsS.js';
|
|
10
|
+
import '../types-Bj_J8u_W.js';
|
|
11
|
+
import '@ai-sdk/provider-utils';
|
|
12
|
+
import '../sandbox/index.js';
|
|
13
|
+
import '../llm-error-D93FNNLY.js';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Normalize a tool replay policy into explicit, infrastructure-agnostic
|
|
@@ -98,6 +97,33 @@ declare class ToolRegistry {
|
|
|
98
97
|
hasGroup(name: string): boolean;
|
|
99
98
|
/** List all group names. */
|
|
100
99
|
listGroups(): string[];
|
|
100
|
+
/**
|
|
101
|
+
* Partition registered tools into eager and deferred sets.
|
|
102
|
+
*
|
|
103
|
+
* Eager tools have their full schemas sent to the LLM on turn 1.
|
|
104
|
+
* Deferred tools are held back — the model discovers them via a
|
|
105
|
+
* search mechanism when needed, saving context window space.
|
|
106
|
+
*
|
|
107
|
+
* @returns `{ eager, deferred }` arrays of tool infos.
|
|
108
|
+
*/
|
|
109
|
+
partition(): {
|
|
110
|
+
eager: Tool.AnyInfo[];
|
|
111
|
+
deferred: Tool.AnyInfo[];
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Search deferred tools by keyword with multi-signal weighted scoring.
|
|
115
|
+
*
|
|
116
|
+
* Scoring per term:
|
|
117
|
+
* - Exact tool ID match: +10
|
|
118
|
+
* - Partial tool ID match (substring): +5
|
|
119
|
+
* - Keyword word-boundary match: +4
|
|
120
|
+
* - Keyword substring match: +2
|
|
121
|
+
*
|
|
122
|
+
* @param query - Space-separated search terms
|
|
123
|
+
* @param maxResults - Maximum results to return (default: 5)
|
|
124
|
+
* @returns Matching deferred tools sorted by relevance (highest score first)
|
|
125
|
+
*/
|
|
126
|
+
searchDeferred(query: string, maxResults?: number): Tool.AnyInfo[];
|
|
101
127
|
/**
|
|
102
128
|
* Resolve a `ToolSpec` to an array of tools.
|
|
103
129
|
*
|
|
@@ -119,9 +145,62 @@ declare class ToolRegistry {
|
|
|
119
145
|
/**
|
|
120
146
|
* Default tool registry instance.
|
|
121
147
|
* Shared across the application — register tools here for global access.
|
|
148
|
+
*
|
|
149
|
+
* **Single-process only.** In multi-agent or multi-tenant setups where
|
|
150
|
+
* agents share a process, create a dedicated `new ToolRegistry()` per
|
|
151
|
+
* agent to avoid cross-contamination of tool registrations.
|
|
122
152
|
*/
|
|
123
153
|
declare const defaultRegistry: ToolRegistry;
|
|
124
154
|
|
|
155
|
+
/**
|
|
156
|
+
* Tool Search — lets the model discover deferred tools at runtime.
|
|
157
|
+
*
|
|
158
|
+
* When an agent has many tools, sending all schemas on turn 1 wastes
|
|
159
|
+
* context window. Tools marked `deferred: true` are held back. The
|
|
160
|
+
* model calls `tool_search` to find them by keyword, and the matching
|
|
161
|
+
* schemas are added to subsequent turns.
|
|
162
|
+
*
|
|
163
|
+
* The search tool itself is always eager (never deferred).
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Options for creating a tool_search tool.
|
|
168
|
+
*/
|
|
169
|
+
interface ToolSearchOptions {
|
|
170
|
+
/** Registry to search. Falls back to the default registry if not provided. */
|
|
171
|
+
registry: ToolRegistry;
|
|
172
|
+
/** Maximum results per search (default: 5). */
|
|
173
|
+
maxResults?: number;
|
|
174
|
+
/**
|
|
175
|
+
* Callback invoked with the matched tools after each search.
|
|
176
|
+
*
|
|
177
|
+
* The agent setup should use this to add the discovered tools
|
|
178
|
+
* to the active tool set for subsequent model calls.
|
|
179
|
+
*/
|
|
180
|
+
onMatch: (tools: Tool.AnyInfo[]) => void;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Create a `tool_search` tool that the model can call to discover
|
|
184
|
+
* deferred tools by keyword.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* import { createToolSearchTool, ToolRegistry } from "@cuylabs/agent-core";
|
|
189
|
+
*
|
|
190
|
+
* const registry = new ToolRegistry();
|
|
191
|
+
* // ... register tools including deferred ones ...
|
|
192
|
+
*
|
|
193
|
+
* const activeTools = new Map<string, Tool.AnyInfo>();
|
|
194
|
+
* const search = createToolSearchTool({
|
|
195
|
+
* registry,
|
|
196
|
+
* onMatch: (tools) => {
|
|
197
|
+
* for (const t of tools) activeTools.set(t.id, t);
|
|
198
|
+
* },
|
|
199
|
+
* });
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
declare function createToolSearchTool(options: ToolSearchOptions): Tool.Info;
|
|
203
|
+
|
|
125
204
|
/**
|
|
126
205
|
* Output truncation utilities for @cuylabs/agent-core
|
|
127
206
|
*/
|
|
@@ -129,10 +208,6 @@ declare const defaultRegistry: ToolRegistry;
|
|
|
129
208
|
declare const MAX_LINES = 2000;
|
|
130
209
|
/** Maximum bytes before truncation */
|
|
131
210
|
declare const MAX_BYTES = 100000;
|
|
132
|
-
/** Directory for storing truncated outputs */
|
|
133
|
-
declare const TRUNCATE_DIR: string;
|
|
134
|
-
/** Glob pattern for truncation directory */
|
|
135
|
-
declare const TRUNCATE_GLOB: string;
|
|
136
211
|
interface TruncateResult {
|
|
137
212
|
/** The (possibly truncated) content */
|
|
138
213
|
content: string;
|
|
@@ -151,23 +226,23 @@ declare function truncateOutput(output: string, options?: {
|
|
|
151
226
|
maxLines?: number;
|
|
152
227
|
maxBytes?: number;
|
|
153
228
|
}): TruncateResult;
|
|
154
|
-
/**
|
|
155
|
-
* Format file size for display
|
|
156
|
-
*/
|
|
157
|
-
declare function formatSize(bytes: number): string;
|
|
158
229
|
|
|
159
230
|
interface ExecuteAgentToolCallOptions {
|
|
160
231
|
toolName: string;
|
|
161
232
|
tool: Tool.Info;
|
|
233
|
+
toolCallId?: string;
|
|
162
234
|
params: unknown;
|
|
163
235
|
cwd: string;
|
|
164
236
|
abort: AbortSignal;
|
|
165
237
|
sessionID: string;
|
|
238
|
+
turnID?: string;
|
|
166
239
|
messageID: string;
|
|
167
240
|
agent?: string;
|
|
168
241
|
host?: ToolHost;
|
|
242
|
+
humanInputController?: HumanInputController;
|
|
169
243
|
turnTracker?: TurnTrackerContext;
|
|
170
244
|
middleware?: MiddlewareRunner;
|
|
245
|
+
onEvent?: (event: AgentEvent) => void | Promise<void>;
|
|
171
246
|
/**
|
|
172
247
|
* Pre-initialized tool result. When provided the executor skips
|
|
173
248
|
* `tool.init()` and uses this directly, avoiding double-init when
|
|
@@ -181,14 +256,29 @@ interface ExecuteAgentToolCallResult {
|
|
|
181
256
|
title?: string;
|
|
182
257
|
/** Tool metadata (populated when middleware preserves it). */
|
|
183
258
|
metadata?: ToolMetadata;
|
|
259
|
+
/**
|
|
260
|
+
* Capabilities declared by the tool after initialization.
|
|
261
|
+
* Exposed so callers (e.g. tool-batch dispatch) can use them
|
|
262
|
+
* for parallelism and approval decisions without re-initializing.
|
|
263
|
+
*/
|
|
264
|
+
capabilities?: ToolCapabilities;
|
|
184
265
|
}
|
|
185
266
|
/**
|
|
186
267
|
* Execute one initialized framework tool with the same semantics used by the
|
|
187
268
|
* standard AI SDK path.
|
|
188
269
|
*
|
|
270
|
+
* Execution pipeline (in order):
|
|
271
|
+
* 1. Init — resolve tool description, schema, capabilities
|
|
272
|
+
* 2. Schema validation — parse params against Zod schema (handled by Tool.define wrapper)
|
|
273
|
+
* 3. Input validation — tool-specific `validate()` check (fail-fast, no side effects)
|
|
274
|
+
* 4. Middleware pre-hook — `beforeToolCall` (approval, gating, arg rewriting)
|
|
275
|
+
* 5. Baseline capture — turn tracker snapshots files before writes
|
|
276
|
+
* 6. Execute — run the tool (with potentially rewritten args from step 4)
|
|
277
|
+
* 7. Middleware post-hook — `afterToolCall` (transform output, add supplements)
|
|
278
|
+
*
|
|
189
279
|
* This keeps middleware, baseline capture, and output normalization in one
|
|
190
280
|
* place so resumable runtimes do not need a second tool execution stack.
|
|
191
281
|
*/
|
|
192
282
|
declare function executeAgentToolCall(options: ExecuteAgentToolCallOptions): Promise<ExecuteAgentToolCallResult>;
|
|
193
283
|
|
|
194
|
-
export { type ExecuteAgentToolCallOptions, type ExecuteAgentToolCallResult, MAX_BYTES, MAX_LINES,
|
|
284
|
+
export { type ExecuteAgentToolCallOptions, type ExecuteAgentToolCallResult, MAX_BYTES, MAX_LINES, Tool, ToolCapabilities, ToolHost, ToolRegistry, type ToolSearchOptions, type ToolSpec, type TruncateResult, createToolSearchTool, defaultRegistry, executeAgentToolCall, normalizeToolReplayPolicy, truncateOutput };
|
package/dist/tool/index.js
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ToolRegistry,
|
|
3
|
+
createToolSearchTool,
|
|
3
4
|
defaultRegistry
|
|
4
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-KYLPMBHD.js";
|
|
6
|
+
import {
|
|
7
|
+
ToolHostRegistry,
|
|
8
|
+
defaultToolHostRegistry,
|
|
9
|
+
localHost
|
|
10
|
+
} from "../chunk-X4VN4GIJ.js";
|
|
5
11
|
import {
|
|
6
12
|
MAX_BYTES,
|
|
7
13
|
MAX_LINES,
|
|
8
|
-
TRUNCATE_DIR,
|
|
9
|
-
TRUNCATE_GLOB,
|
|
10
14
|
Tool,
|
|
11
|
-
defineTool,
|
|
12
|
-
formatSize,
|
|
13
15
|
normalizeToolReplayPolicy,
|
|
14
16
|
truncateOutput
|
|
15
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-Q742PSH3.js";
|
|
16
18
|
import {
|
|
17
19
|
executeAgentToolCall
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-
|
|
20
|
-
import
|
|
20
|
+
} from "../chunk-5NVVNXPQ.js";
|
|
21
|
+
import "../chunk-V4RFNEET.js";
|
|
22
|
+
import {
|
|
23
|
+
getRequiredToolHost,
|
|
24
|
+
resolveCapability
|
|
25
|
+
} from "../chunk-FII65CN7.js";
|
|
21
26
|
export {
|
|
22
27
|
MAX_BYTES,
|
|
23
28
|
MAX_LINES,
|
|
24
|
-
TRUNCATE_DIR,
|
|
25
|
-
TRUNCATE_GLOB,
|
|
26
29
|
Tool,
|
|
30
|
+
ToolHostRegistry,
|
|
27
31
|
ToolRegistry,
|
|
32
|
+
createToolSearchTool,
|
|
28
33
|
defaultRegistry,
|
|
29
|
-
|
|
34
|
+
defaultToolHostRegistry,
|
|
30
35
|
executeAgentToolCall,
|
|
31
|
-
|
|
36
|
+
getRequiredToolHost,
|
|
37
|
+
localHost,
|
|
32
38
|
normalizeToolReplayPolicy,
|
|
39
|
+
resolveCapability,
|
|
33
40
|
truncateOutput
|
|
34
41
|
};
|
|
@@ -21,35 +21,67 @@ interface StdioTransportConfig {
|
|
|
21
21
|
cwd?: string;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* HTTP transport configuration for remote MCP servers.
|
|
24
|
+
* HTTP/SSE transport configuration for remote MCP servers.
|
|
25
|
+
*
|
|
26
|
+
* Supports all options from the AI SDK's `MCPTransportConfig` so that
|
|
27
|
+
* agents can leverage OAuth, custom fetch, and redirect control.
|
|
25
28
|
*/
|
|
26
|
-
interface
|
|
27
|
-
transport: "http";
|
|
29
|
+
interface RemoteTransportConfig {
|
|
30
|
+
transport: "http" | "sse";
|
|
28
31
|
/** Server URL */
|
|
29
32
|
url: string;
|
|
30
33
|
/** HTTP headers (e.g. Authorization) */
|
|
31
34
|
headers?: Record<string, string>;
|
|
35
|
+
/**
|
|
36
|
+
* OAuth client provider for authenticated MCP servers.
|
|
37
|
+
* Pass an `OAuthClientProvider` from `@ai-sdk/mcp` when the server
|
|
38
|
+
* requires OAuth authentication.
|
|
39
|
+
*/
|
|
40
|
+
authProvider?: any;
|
|
41
|
+
/**
|
|
42
|
+
* How HTTP redirects are handled.
|
|
43
|
+
* - `'follow'` — follow automatically
|
|
44
|
+
* - `'error'` — reject redirects
|
|
45
|
+
* @default 'error'
|
|
46
|
+
*/
|
|
47
|
+
redirect?: "follow" | "error";
|
|
48
|
+
/**
|
|
49
|
+
* Custom fetch implementation (useful for runtimes with
|
|
50
|
+
* request-scoped fetch or test doubles).
|
|
51
|
+
*/
|
|
52
|
+
fetch?: any;
|
|
32
53
|
}
|
|
33
54
|
/**
|
|
34
|
-
*
|
|
55
|
+
* @deprecated Use `RemoteTransportConfig` with `transport: "http"`.
|
|
56
|
+
*/
|
|
57
|
+
type HttpTransportConfig = RemoteTransportConfig & {
|
|
58
|
+
transport: "http";
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use `RemoteTransportConfig` with `transport: "sse"`.
|
|
35
62
|
*/
|
|
36
|
-
|
|
63
|
+
type SseTransportConfig = RemoteTransportConfig & {
|
|
37
64
|
transport: "sse";
|
|
38
|
-
|
|
39
|
-
url: string;
|
|
40
|
-
/** HTTP headers (e.g. Authorization) */
|
|
41
|
-
headers?: Record<string, string>;
|
|
42
|
-
}
|
|
65
|
+
};
|
|
43
66
|
/**
|
|
44
67
|
* MCP server configuration.
|
|
45
68
|
*/
|
|
46
|
-
type MCPServerConfig = (StdioTransportConfig |
|
|
69
|
+
type MCPServerConfig = (StdioTransportConfig | RemoteTransportConfig) & {
|
|
47
70
|
/** Whether this server is enabled (default: true) */
|
|
48
71
|
enabled?: boolean;
|
|
49
72
|
/** Connection timeout in ms (default: 30000) */
|
|
50
73
|
timeout?: number;
|
|
51
74
|
/** Human-readable name for the server */
|
|
52
75
|
name?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Client capabilities to advertise during MCP initialization.
|
|
78
|
+
* Enables features like elicitation when the server supports them.
|
|
79
|
+
*/
|
|
80
|
+
capabilities?: Record<string, unknown>;
|
|
81
|
+
/**
|
|
82
|
+
* Callback for uncaught transport errors.
|
|
83
|
+
*/
|
|
84
|
+
onUncaughtError?: (error: unknown) => void;
|
|
53
85
|
};
|
|
54
86
|
/**
|
|
55
87
|
* MCP manager configuration - map of server name to config.
|
|
@@ -71,29 +103,6 @@ type MCPServerStatus = {
|
|
|
71
103
|
} | {
|
|
72
104
|
status: "disabled";
|
|
73
105
|
};
|
|
74
|
-
/**
|
|
75
|
-
* MCP resource descriptor.
|
|
76
|
-
*/
|
|
77
|
-
interface MCPResource {
|
|
78
|
-
uri: string;
|
|
79
|
-
name: string;
|
|
80
|
-
description?: string;
|
|
81
|
-
mimeType?: string;
|
|
82
|
-
server: string;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* MCP prompt descriptor.
|
|
86
|
-
*/
|
|
87
|
-
interface MCPPrompt {
|
|
88
|
-
name: string;
|
|
89
|
-
description?: string;
|
|
90
|
-
arguments?: Array<{
|
|
91
|
-
name: string;
|
|
92
|
-
description?: string;
|
|
93
|
-
required?: boolean;
|
|
94
|
-
}>;
|
|
95
|
-
server: string;
|
|
96
|
-
}
|
|
97
106
|
/**
|
|
98
107
|
* MCP manager - handles connections to multiple MCP servers.
|
|
99
108
|
*/
|
|
@@ -114,35 +123,6 @@ interface MCPManager {
|
|
|
114
123
|
* Get status of all servers.
|
|
115
124
|
*/
|
|
116
125
|
getAllStatus(): Map<string, MCPServerStatus>;
|
|
117
|
-
/**
|
|
118
|
-
* List available resources from all connected servers.
|
|
119
|
-
*/
|
|
120
|
-
listResources(): Promise<MCPResource[]>;
|
|
121
|
-
/**
|
|
122
|
-
* Read a resource by URI.
|
|
123
|
-
*/
|
|
124
|
-
readResource(uri: string): Promise<{
|
|
125
|
-
contents: Array<{
|
|
126
|
-
uri: string;
|
|
127
|
-
text?: string;
|
|
128
|
-
blob?: string;
|
|
129
|
-
mimeType?: string;
|
|
130
|
-
}>;
|
|
131
|
-
}>;
|
|
132
|
-
/**
|
|
133
|
-
* List available prompts from all connected servers.
|
|
134
|
-
*/
|
|
135
|
-
listPrompts(): Promise<MCPPrompt[]>;
|
|
136
|
-
/**
|
|
137
|
-
* Get a prompt with optional arguments.
|
|
138
|
-
*/
|
|
139
|
-
getPrompt(serverName: string, promptName: string, args?: Record<string, unknown>): Promise<{
|
|
140
|
-
description?: string;
|
|
141
|
-
messages: Array<{
|
|
142
|
-
role: string;
|
|
143
|
-
content: unknown;
|
|
144
|
-
}>;
|
|
145
|
-
}>;
|
|
146
126
|
/**
|
|
147
127
|
* Close all connections.
|
|
148
128
|
*/
|
|
@@ -153,4 +133,4 @@ interface MCPManager {
|
|
|
153
133
|
isConnected(): boolean;
|
|
154
134
|
}
|
|
155
135
|
|
|
156
|
-
export type { HttpTransportConfig as H, MCPConfig as M,
|
|
136
|
+
export type { HttpTransportConfig as H, MCPConfig as M, RemoteTransportConfig as R, SseTransportConfig as S, MCPManager as a, MCPServerConfig as b, MCPServerStatus as c, StdioTransportConfig as d };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ToolHost — execution environment abstraction for agent tools.
|
|
3
3
|
*
|
|
4
|
-
* A ToolHost defines *where* tools execute: local machine,
|
|
5
|
-
*
|
|
4
|
+
* A ToolHost defines *where* tools execute: local machine, container,
|
|
5
|
+
* remote workspace, etc. Every host provides two surfaces:
|
|
6
6
|
*
|
|
7
7
|
* 1. **File system** — read, write, stat, list, check existence
|
|
8
8
|
* 2. **Process execution** — spawn commands, kill processes
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* // Default: runs everything locally
|
|
16
16
|
* const agent = createAgent({ host: localHost() });
|
|
17
17
|
*
|
|
18
|
-
* //
|
|
19
|
-
* const agent = createAgent({ host:
|
|
18
|
+
* // Swap in a custom host package when needed
|
|
19
|
+
* const agent = createAgent({ host: workspaceHost() });
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
/** Options for spawning a process. */
|
|
@@ -69,10 +69,10 @@ interface DirEntry {
|
|
|
69
69
|
* The execution environment for agent tools.
|
|
70
70
|
*
|
|
71
71
|
* Abstracts filesystem and process operations so tools work identically
|
|
72
|
-
* whether running locally, in
|
|
72
|
+
* whether running locally, in a container, over SSH, or in any other environment.
|
|
73
73
|
*/
|
|
74
74
|
interface ToolHost {
|
|
75
|
-
/** Human-readable host identifier (e.g. "local", "
|
|
75
|
+
/** Human-readable host identifier (e.g. "local", "container:workspace"). */
|
|
76
76
|
readonly name: string;
|
|
77
77
|
/** Read a file as a UTF-8 string. Throws if the file doesn't exist. */
|
|
78
78
|
readFile(path: string): Promise<string>;
|
|
@@ -92,7 +92,7 @@ interface ToolHost {
|
|
|
92
92
|
* Execute a shell command.
|
|
93
93
|
*
|
|
94
94
|
* The host decides which shell to use (e.g. local host uses the user's
|
|
95
|
-
* `$SHELL`,
|
|
95
|
+
* `$SHELL`, a container host uses its runtime entrypoint, an SSH host uses a remote shell).
|
|
96
96
|
*/
|
|
97
97
|
exec(command: string, options?: ExecOptions): Promise<ExecResult>;
|
|
98
98
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger type definitions for @cuylabs/agent-core.
|
|
3
|
+
*
|
|
4
|
+
* The logger is intentionally minimal — four levels, optional structured
|
|
5
|
+
* metadata, and a child-logger factory for namespace scoping.
|
|
6
|
+
*
|
|
7
|
+
* By default agents use a silent (no-op) logger. Consumers opt into
|
|
8
|
+
* output by supplying a concrete logger via `createAgent({ logger })`.
|
|
9
|
+
*/
|
|
10
|
+
/** Structured metadata bag attached to log entries. */
|
|
11
|
+
type LogMeta = Record<string, unknown>;
|
|
12
|
+
/** Log severity levels, lowest to highest. */
|
|
13
|
+
type LogLevel = "debug" | "info" | "warn" | "error";
|
|
14
|
+
/**
|
|
15
|
+
* Core logger contract.
|
|
16
|
+
*
|
|
17
|
+
* Every internal module that needs to log accepts a `Logger` instance.
|
|
18
|
+
* The interface is intentionally compatible with `RuntimeLogger` from
|
|
19
|
+
* `@cuylabs/agent-runtime` so the same object can serve both roles.
|
|
20
|
+
*/
|
|
21
|
+
interface Logger {
|
|
22
|
+
debug(message: string, meta?: LogMeta): void;
|
|
23
|
+
info(message: string, meta?: LogMeta): void;
|
|
24
|
+
warn(message: string, meta?: LogMeta): void;
|
|
25
|
+
error(message: string, meta?: LogMeta): void;
|
|
26
|
+
/**
|
|
27
|
+
* Create a child logger that prepends a namespace prefix.
|
|
28
|
+
*
|
|
29
|
+
* ```ts
|
|
30
|
+
* const child = logger.child("mcp");
|
|
31
|
+
* child.warn("timeout"); // → "[mcp] timeout"
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* Implementations that don't support children can return `this`.
|
|
35
|
+
*/
|
|
36
|
+
child(namespace: string): Logger;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Options accepted by the built-in console logger factory.
|
|
40
|
+
*/
|
|
41
|
+
interface ConsoleLoggerOptions {
|
|
42
|
+
/** Minimum level to emit. Messages below this are discarded. Default: `"warn"`. */
|
|
43
|
+
level?: LogLevel;
|
|
44
|
+
/** Prefix prepended to every line. Default: `"agent-core"`. */
|
|
45
|
+
prefix?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Options for the file-backed logger factory.
|
|
49
|
+
*/
|
|
50
|
+
interface FileLoggerOptions {
|
|
51
|
+
/** Absolute path to the log file. Created (with parents) if it doesn't exist. */
|
|
52
|
+
filePath: string;
|
|
53
|
+
/** Minimum level to emit. Default: `"debug"`. */
|
|
54
|
+
level?: LogLevel;
|
|
55
|
+
/** Prefix prepended to every line. Default: `"agent-core"`. */
|
|
56
|
+
prefix?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type { ConsoleLoggerOptions as C, FileLoggerOptions as F, Logger as L, LogLevel as a, LogMeta as b };
|