@cuylabs/agent-core 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/{chunk-CMYN2RCB.js → chunk-33UIM3QS.js} +13 -7
  2. package/dist/{chunk-SPILYYDF.js → chunk-BERMUFZA.js} +22 -5
  3. package/dist/{chunk-TOTDGK3P.js → chunk-CSR75JVC.js} +4 -5
  4. package/dist/{chunk-ICZ66572.js → chunk-CZ5XOVDV.js} +40 -9
  5. package/dist/{chunk-2O4MCSQS.js → chunk-FYC33XFI.js} +31 -10
  6. package/dist/{chunk-WBPOZ7CL.js → chunk-JNN3RUIL.js} +86 -36
  7. package/dist/{chunk-SSFBF3US.js → chunk-JPBFAQNS.js} +7 -12
  8. package/dist/{chunk-5FMSGQVX.js → chunk-JZRLCTSD.js} +8 -2
  9. package/dist/{chunk-V4RFNEET.js → chunk-MLTJHUVG.js} +34 -16
  10. package/dist/{chunk-QAL3OMI3.js → chunk-MO3N6M32.js} +4 -1
  11. package/dist/{chunk-5NVVNXPQ.js → chunk-QEE5CBPM.js} +5 -2
  12. package/dist/{chunk-MXAP4UG6.js → chunk-QJV5XPPS.js} +238 -86
  13. package/dist/{chunk-T4UIX5D7.js → chunk-S6AKEPAX.js} +9 -3
  14. package/dist/{chunk-N3VX7FEE.js → chunk-STDJYXYK.js} +1 -4
  15. package/dist/{chunk-6HZBHFOL.js → chunk-TPZ37IWI.js} +10 -1
  16. package/dist/{chunk-NDZWXCBZ.js → chunk-TZ4VA4VX.js} +33 -11
  17. package/dist/{chunk-GFTW23FV.js → chunk-UECLINZM.js} +4 -2
  18. package/dist/chunk-US7S4FYW.js +610 -0
  19. package/dist/{chunk-RN6WZEUF.js → chunk-WI5JFEAI.js} +71 -36
  20. package/dist/dispatch/index.d.ts +5 -3
  21. package/dist/dispatch/index.js +3 -3
  22. package/dist/execution/index.d.ts +6 -4
  23. package/dist/execution/index.js +7 -7
  24. package/dist/index.d.ts +8 -5
  25. package/dist/index.js +117 -114
  26. package/dist/inference/errors/index.js +1 -1
  27. package/dist/inference/index.d.ts +6 -4
  28. package/dist/inference/index.js +6 -6
  29. package/dist/{instance-BqV2D5pc.d.ts → instance-CP24g3Le.d.ts} +2 -2
  30. package/dist/logger/index.js +1 -1
  31. package/dist/mcp/index.d.ts +116 -3
  32. package/dist/mcp/index.js +6 -2
  33. package/dist/middleware/index.d.ts +5 -3
  34. package/dist/middleware/index.js +3 -3
  35. package/dist/{model-messages-B4nK9D1-.d.ts → model-messages-B_MCHyiX.d.ts} +1 -1
  36. package/dist/models/index.js +2 -2
  37. package/dist/models/reasoning/index.js +2 -2
  38. package/dist/plugin/index.d.ts +4 -2
  39. package/dist/plugin/index.js +1 -1
  40. package/dist/profiles/index.d.ts +4 -2
  41. package/dist/profiles/index.js +1 -1
  42. package/dist/prompt/index.d.ts +5 -3
  43. package/dist/prompt/index.js +2 -2
  44. package/dist/safety/index.d.ts +5 -3
  45. package/dist/safety/index.js +1 -1
  46. package/dist/skill/index.d.ts +5 -3
  47. package/dist/skill/index.js +2 -2
  48. package/dist/storage/index.d.ts +5 -3
  49. package/dist/storage/index.js +1 -1
  50. package/dist/subagents/index.d.ts +4 -2
  51. package/dist/subagents/index.js +4 -4
  52. package/dist/team/index.d.ts +5 -3
  53. package/dist/team/index.js +1 -1
  54. package/dist/tool/index.d.ts +5 -3
  55. package/dist/tool/index.js +2 -2
  56. package/dist/{types-Bj_J8u_W.d.ts → types-DMjoFKKv.d.ts} +55 -7
  57. package/package.json +1 -6
  58. package/dist/chunk-ROTGCYDW.js +0 -221
@@ -1,221 +0,0 @@
1
- import {
2
- silentLogger
3
- } from "./chunk-T4UIX5D7.js";
4
-
5
- // src/mcp/modules.ts
6
- var mcpModule;
7
- var stdioModule;
8
- async function getMcpSdkModule() {
9
- if (!mcpModule) {
10
- try {
11
- mcpModule = await import("@ai-sdk/mcp");
12
- } catch {
13
- throw new Error(
14
- "MCP support requires @ai-sdk/mcp. Install it with: npm install @ai-sdk/mcp"
15
- );
16
- }
17
- }
18
- return mcpModule;
19
- }
20
- async function getStdioClientModule() {
21
- if (!stdioModule) {
22
- try {
23
- stdioModule = await import("@modelcontextprotocol/sdk/client/stdio.js");
24
- } catch {
25
- throw new Error(
26
- "Stdio MCP transport requires @modelcontextprotocol/sdk. Install it with: npm install @modelcontextprotocol/sdk"
27
- );
28
- }
29
- }
30
- return stdioModule;
31
- }
32
-
33
- // src/mcp/manager.ts
34
- var DefaultMCPManager = class {
35
- config;
36
- connections = /* @__PURE__ */ new Map();
37
- log;
38
- toolCache;
39
- constructor(config, logger) {
40
- this.config = config;
41
- this.log = logger?.child("mcp") ?? silentLogger;
42
- }
43
- async connect() {
44
- const results = /* @__PURE__ */ new Map();
45
- const connectPromises = Object.entries(this.config).map(
46
- async ([name, serverConfig]) => {
47
- if (serverConfig.enabled === false) {
48
- const status = { status: "disabled" };
49
- this.connections.set(name, {
50
- client: void 0,
51
- config: serverConfig,
52
- status
53
- });
54
- results.set(name, status);
55
- return;
56
- }
57
- results.set(name, { status: "connecting" });
58
- try {
59
- const { client, toolCount } = await this.createClient(name, serverConfig);
60
- const status = { status: "connected", toolCount };
61
- this.connections.set(name, { client, config: serverConfig, status });
62
- results.set(name, status);
63
- } catch (error) {
64
- const errorMessage = error instanceof Error ? error.message : String(error);
65
- const status = {
66
- status: "error",
67
- error: errorMessage
68
- };
69
- results.set(name, status);
70
- this.connections.set(name, {
71
- client: void 0,
72
- config: serverConfig,
73
- status
74
- });
75
- }
76
- }
77
- );
78
- await Promise.all(connectPromises);
79
- this.toolCache = void 0;
80
- return results;
81
- }
82
- async getTools() {
83
- if (this.toolCache) {
84
- return this.toolCache;
85
- }
86
- const allTools = {};
87
- const toolPromises = Array.from(this.connections.entries()).map(
88
- async ([serverName, connection]) => {
89
- if (connection.status.status !== "connected" || !connection.client) {
90
- return;
91
- }
92
- try {
93
- const tools = await connection.client.tools();
94
- for (const [toolName, tool] of Object.entries(tools)) {
95
- allTools[`${serverName}__${toolName}`] = tool;
96
- }
97
- } catch (error) {
98
- this.log.warn(`Failed to get tools from ${serverName}`, {
99
- error: error instanceof Error ? error.message : String(error)
100
- });
101
- }
102
- }
103
- );
104
- await Promise.all(toolPromises);
105
- this.toolCache = allTools;
106
- return allTools;
107
- }
108
- getStatus(serverName) {
109
- const connection = this.connections.get(serverName);
110
- return connection?.status ?? { status: "disconnected" };
111
- }
112
- getAllStatus() {
113
- const status = /* @__PURE__ */ new Map();
114
- for (const [name, connection] of this.connections) {
115
- status.set(name, connection.status);
116
- }
117
- return status;
118
- }
119
- async close() {
120
- const closePromises = Array.from(this.connections.values()).map(
121
- async (connection) => {
122
- if (connection.client) {
123
- try {
124
- await connection.client.close();
125
- } catch {
126
- }
127
- }
128
- }
129
- );
130
- await Promise.all(closePromises);
131
- this.connections.clear();
132
- this.toolCache = void 0;
133
- }
134
- isConnected() {
135
- for (const connection of this.connections.values()) {
136
- if (connection.status.status === "connected") {
137
- return true;
138
- }
139
- }
140
- return false;
141
- }
142
- async createClient(name, config) {
143
- const { createMCPClient } = await getMcpSdkModule();
144
- const timeout = config.timeout ?? 3e4;
145
- const withTimeout = (promise, ms) => {
146
- return Promise.race([
147
- promise,
148
- new Promise(
149
- (_, reject) => setTimeout(
150
- () => reject(new Error(`MCP connection timeout after ${ms}ms`)),
151
- ms
152
- )
153
- )
154
- ]);
155
- };
156
- const clientOptions = {
157
- name: config.name ?? name,
158
- ...config.onUncaughtError ? { onUncaughtError: config.onUncaughtError } : {},
159
- ...config.capabilities ? { capabilities: config.capabilities } : {}
160
- };
161
- if (config.transport === "stdio") {
162
- const { StdioClientTransport } = await getStdioClientModule();
163
- const transport = new StdioClientTransport({
164
- command: config.command,
165
- args: config.args,
166
- env: config.env,
167
- cwd: config.cwd
168
- });
169
- const client2 = await createMCPClient({ transport, ...clientOptions });
170
- const tools2 = await withTimeout(client2.tools(), timeout);
171
- return { client: client2, toolCount: Object.keys(tools2).length };
172
- }
173
- const client = await createMCPClient({
174
- transport: {
175
- type: config.transport,
176
- url: config.url,
177
- headers: config.headers,
178
- ...config.authProvider ? { authProvider: config.authProvider } : {},
179
- ...config.redirect ? { redirect: config.redirect } : {},
180
- ...config.fetch ? { fetch: config.fetch } : {}
181
- },
182
- ...clientOptions
183
- });
184
- const tools = await withTimeout(client.tools(), timeout);
185
- return { client, toolCount: Object.keys(tools).length };
186
- }
187
- };
188
-
189
- // src/mcp/factories.ts
190
- function createMCPManager(config) {
191
- return new DefaultMCPManager(config);
192
- }
193
- function stdioServer(command, args, options) {
194
- return {
195
- transport: "stdio",
196
- command,
197
- args,
198
- ...options
199
- };
200
- }
201
- function httpServer(url, options) {
202
- return {
203
- transport: "http",
204
- url,
205
- ...options
206
- };
207
- }
208
- function sseServer(url, options) {
209
- return {
210
- transport: "sse",
211
- url,
212
- ...options
213
- };
214
- }
215
-
216
- export {
217
- createMCPManager,
218
- stdioServer,
219
- httpServer,
220
- sseServer
221
- };