@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.
Files changed (116) hide show
  1. package/README.md +33 -17
  2. package/dist/chunk-2O4MCSQS.js +780 -0
  3. package/dist/chunk-2TTOLHBT.js +198 -0
  4. package/dist/chunk-5FMSGQVX.js +281 -0
  5. package/dist/chunk-5NVVNXPQ.js +288 -0
  6. package/dist/{chunk-EKR6PKXU.js → chunk-6HZBHFOL.js} +3 -3
  7. package/dist/chunk-CJI7PVS2.js +58 -0
  8. package/dist/{chunk-WKHDSSXG.js → chunk-CMYN2RCB.js} +146 -46
  9. package/dist/chunk-FII65CN7.js +117 -0
  10. package/dist/{chunk-UHCJEM2E.js → chunk-ICZ66572.js} +13 -6
  11. package/dist/chunk-KYLPMBHD.js +316 -0
  12. package/dist/chunk-MXAP4UG6.js +2956 -0
  13. package/dist/{chunk-4QFNWPIF.js → chunk-N3VX7FEE.js} +35 -2
  14. package/dist/{chunk-MAZ5DY5B.js → chunk-NDZWXCBZ.js} +213 -78
  15. package/dist/{chunk-MHKK374K.js → chunk-Q742PSH3.js} +11 -27
  16. package/dist/{chunk-WGZAPU6N.js → chunk-QAL3OMI3.js} +15 -1
  17. package/dist/{chunk-UDCZ673N.js → chunk-RN6WZEUF.js} +27 -23
  18. package/dist/{chunk-ZXAKHMWH.js → chunk-ROTGCYDW.js} +22 -84
  19. package/dist/chunk-SPBFQXOT.js +0 -0
  20. package/dist/chunk-SSFBF3US.js +602 -0
  21. package/dist/chunk-SZ2XBPTW.js +8 -0
  22. package/dist/chunk-T4UIX5D7.js +115 -0
  23. package/dist/{chunk-IYWQOJMQ.js → chunk-TIHPYVAJ.js} +34 -34
  24. package/dist/{chunk-RKEW5WXI.js → chunk-TOTDGK3P.js} +1 -1
  25. package/dist/chunk-V4RFNEET.js +563 -0
  26. package/dist/chunk-VOUEJSW6.js +0 -0
  27. package/dist/{chunk-J4QDGZIA.js → chunk-WBPOZ7CL.js} +659 -275
  28. package/dist/chunk-X4VN4GIJ.js +185 -0
  29. package/dist/dispatch/index.d.ts +93 -0
  30. package/dist/dispatch/index.js +37 -0
  31. package/dist/events/index.d.ts +93 -0
  32. package/dist/events/index.js +6 -0
  33. package/dist/{runtime → execution}/index.d.ts +120 -35
  34. package/dist/{runtime → execution}/index.js +17 -11
  35. package/dist/index.d.ts +489 -115
  36. package/dist/index.js +1665 -462
  37. package/dist/inference/errors/index.js +1 -1
  38. package/dist/inference/index.d.ts +13 -21
  39. package/dist/inference/index.js +15 -12
  40. package/dist/instance-BqV2D5pc.d.ts +5723 -0
  41. package/dist/logger/index.d.ts +50 -0
  42. package/dist/logger/index.js +11 -0
  43. package/dist/mcp/index.d.ts +5 -9
  44. package/dist/mcp/index.js +2 -3
  45. package/dist/middleware/index.d.ts +10 -150
  46. package/dist/middleware/index.js +10 -2
  47. package/dist/model-messages-B4nK9D1-.d.ts +13 -0
  48. package/dist/models/index.d.ts +5 -2
  49. package/dist/models/index.js +2 -1
  50. package/dist/models/reasoning/index.js +2 -1
  51. package/dist/plugin/index.d.ts +55 -11
  52. package/dist/plugin/index.js +1 -1
  53. package/dist/profiles/index.d.ts +55 -0
  54. package/dist/{presets → profiles}/index.js +10 -10
  55. package/dist/prompt/index.d.ts +8 -13
  56. package/dist/safety/index.d.ts +109 -14
  57. package/dist/safety/index.js +59 -3
  58. package/dist/sandbox/index.d.ts +81 -0
  59. package/dist/sandbox/index.js +1 -0
  60. package/dist/skill/index.d.ts +10 -8
  61. package/dist/skill/index.js +2 -2
  62. package/dist/storage/index.d.ts +12 -4
  63. package/dist/storage/index.js +1 -1
  64. package/dist/subagents/index.d.ts +177 -0
  65. package/dist/subagents/index.js +78 -0
  66. package/dist/team/index.d.ts +544 -0
  67. package/dist/team/index.js +41 -0
  68. package/dist/tool/host/index.d.ts +41 -0
  69. package/dist/tool/host/index.js +10 -0
  70. package/dist/tool/index.d.ts +111 -21
  71. package/dist/tool/index.js +20 -13
  72. package/dist/{types-VQgymC1N.d.ts → types-Bj_J8u_W.d.ts} +44 -64
  73. package/dist/{types-CHiPh8U2.d.ts → types-C_LCeYNg.d.ts} +7 -7
  74. package/dist/types-RSCv7nQ4.d.ts +59 -0
  75. package/package.json +46 -47
  76. package/dist/builder-BgZ_j4Vs.d.ts +0 -35
  77. package/dist/chunk-5ARZJWD2.js +0 -259
  78. package/dist/chunk-DXFBQMXP.js +0 -53
  79. package/dist/chunk-H3FUYU52.js +0 -81
  80. package/dist/chunk-JLXG2SH7.js +0 -905
  81. package/dist/chunk-N7P4PN3O.js +0 -84
  82. package/dist/chunk-OFDKHNCX.js +0 -727
  83. package/dist/chunk-SDSBEQXG.js +0 -157
  84. package/dist/chunk-VEKUXUVF.js +0 -41
  85. package/dist/chunk-VNQBHPCT.js +0 -398
  86. package/dist/chunk-WWYYNWEW.js +0 -259
  87. package/dist/context/index.d.ts +0 -259
  88. package/dist/context/index.js +0 -26
  89. package/dist/events-CE72w8W4.d.ts +0 -149
  90. package/dist/host/index.d.ts +0 -45
  91. package/dist/host/index.js +0 -8
  92. package/dist/index-DQuTZ8xL.d.ts +0 -1335
  93. package/dist/messages-BYWGn8TY.d.ts +0 -110
  94. package/dist/presets/index.d.ts +0 -53
  95. package/dist/registry-DwYqsQkX.d.ts +0 -164
  96. package/dist/runner-CI-XeR16.d.ts +0 -91
  97. package/dist/scope/index.d.ts +0 -10
  98. package/dist/scope/index.js +0 -14
  99. package/dist/session-manager-KbYt2WUh.d.ts +0 -282
  100. package/dist/signal/index.d.ts +0 -28
  101. package/dist/signal/index.js +0 -6
  102. package/dist/sub-agent/index.d.ts +0 -24
  103. package/dist/sub-agent/index.js +0 -32
  104. package/dist/tool-CZWN3KbO.d.ts +0 -141
  105. package/dist/tool-DkhSCV2Y.d.ts +0 -145
  106. package/dist/tracker-DClqYqTj.d.ts +0 -96
  107. package/dist/tracking/index.d.ts +0 -111
  108. package/dist/tracking/index.js +0 -20
  109. package/dist/types-BfNpU8NS.d.ts +0 -270
  110. package/dist/types-BlOKk-Bb.d.ts +0 -330
  111. package/dist/types-BlZwmnuW.d.ts +0 -50
  112. package/dist/types-CQL-SvTn.d.ts +0 -29
  113. package/dist/types-CWm-7rvB.d.ts +0 -55
  114. package/dist/types-DTSkxakL.d.ts +0 -651
  115. package/dist/types-DmDwi2zI.d.ts +0 -339
  116. package/dist/types-YuWV4ag7.d.ts +0 -72
@@ -871,7 +871,9 @@ function mergePluginManifest(manifest, definition) {
871
871
  name: definition.name ?? manifest.name,
872
872
  description: definition.description ?? manifest.description,
873
873
  version: definition.version ?? manifest.version,
874
- compatibility: mergeCompatibility(manifest.compatibility, definition.compatibility) ?? manifest.compatibility
874
+ compatibility: mergeCompatibility(manifest.compatibility, definition.compatibility) ?? manifest.compatibility,
875
+ capabilities: mergeCapabilityTags(manifest.capabilities, definition.capabilities),
876
+ surfaces: mergeSurfaceContract(manifest.surfaces, definition.surfaces)
875
877
  };
876
878
  }
877
879
  function mergeCompatibility(manifest, definition) {
@@ -879,6 +881,18 @@ function mergeCompatibility(manifest, definition) {
879
881
  if (!definition) return manifest;
880
882
  return { ...manifest, ...definition };
881
883
  }
884
+ function mergeCapabilityTags(manifest, definition) {
885
+ const merged = [...manifest ?? [], ...definition ?? []].map((tag) => tag.trim()).filter(Boolean);
886
+ if (merged.length === 0) {
887
+ return void 0;
888
+ }
889
+ return [...new Set(merged)];
890
+ }
891
+ function mergeSurfaceContract(manifest, definition) {
892
+ if (!manifest) return definition;
893
+ if (!definition) return manifest;
894
+ return { ...manifest, ...definition };
895
+ }
882
896
  function normalizeCommandToken(token) {
883
897
  return token.trim().replace(/^\//, "").toLowerCase();
884
898
  }
@@ -5,6 +5,9 @@ import {
5
5
  extractProvider,
6
6
  likelySupportsReasoning
7
7
  } from "./chunk-I6PKJ7XQ.js";
8
+ import {
9
+ silentLogger
10
+ } from "./chunk-T4UIX5D7.js";
8
11
 
9
12
  // src/models/resolver.ts
10
13
  function parseKey(input) {
@@ -217,9 +220,6 @@ function applyCapabilityOverride(entry, override) {
217
220
  }
218
221
 
219
222
  // src/models/cache/adapters.ts
220
- function logLocalStorageWarning(error) {
221
- console.warn("[agent-core] Failed to write to localStorage:", error);
222
- }
223
223
  function isNodeEnvironment() {
224
224
  return typeof process !== "undefined" && process.versions != null && process.versions.node != null;
225
225
  }
@@ -271,6 +271,10 @@ var FileSystemAdapter = class {
271
271
  };
272
272
  var LocalStorageAdapter = class {
273
273
  key = "agent-core:model-capabilities";
274
+ log;
275
+ constructor(logger) {
276
+ this.log = logger;
277
+ }
274
278
  async read() {
275
279
  try {
276
280
  const content = localStorage.getItem(this.key);
@@ -284,7 +288,9 @@ var LocalStorageAdapter = class {
284
288
  try {
285
289
  localStorage.setItem(this.key, JSON.stringify(data));
286
290
  } catch (error) {
287
- logLocalStorageWarning(error);
291
+ this.log.warn("Failed to write to localStorage", {
292
+ error: error instanceof Error ? error.message : String(error)
293
+ });
288
294
  }
289
295
  }
290
296
  async clear() {
@@ -306,12 +312,12 @@ var MemoryAdapter = class {
306
312
  this.data = void 0;
307
313
  }
308
314
  };
309
- function createCapabilityCacheAdapter(cachePath) {
315
+ function createCapabilityCacheAdapter(cachePath, logger) {
310
316
  if (isNodeEnvironment()) {
311
317
  return new FileSystemAdapter(cachePath);
312
318
  }
313
319
  if (hasLocalStorage()) {
314
- return new LocalStorageAdapter();
320
+ return new LocalStorageAdapter(logger ?? silentLogger);
315
321
  }
316
322
  return new MemoryAdapter();
317
323
  }
@@ -326,18 +332,17 @@ function isExpired(data) {
326
332
  }
327
333
 
328
334
  // src/models/cache/manager.ts
329
- function logCapabilityCacheWarning(error) {
330
- console.warn("[agent-core] Failed to load capability cache:", error);
331
- }
332
335
  var CapabilityCache = class {
333
336
  adapter;
334
337
  memoryCache = /* @__PURE__ */ new Map();
335
338
  ttlMs;
336
339
  loaded = false;
337
- constructor(options = {}) {
340
+ log;
341
+ constructor(options = {}, logger) {
338
342
  const opts = { ...DEFAULT_RESOLVER_OPTIONS, ...options };
339
343
  this.ttlMs = opts.cacheTtlMs;
340
344
  this.adapter = createCapabilityCacheAdapter(opts.cachePath);
345
+ this.log = logger?.child("cache") ?? silentLogger;
341
346
  }
342
347
  async load() {
343
348
  if (this.loaded) return;
@@ -349,7 +354,9 @@ var CapabilityCache = class {
349
354
  }
350
355
  }
351
356
  } catch (error) {
352
- logCapabilityCacheWarning(error);
357
+ this.log.warn("Failed to load capability cache", {
358
+ error: error instanceof Error ? error.message : String(error)
359
+ });
353
360
  }
354
361
  this.loaded = true;
355
362
  }
@@ -654,18 +661,17 @@ var RemoteCapabilitySource = class {
654
661
  };
655
662
 
656
663
  // src/models/capability-resolver.ts
657
- function logCapabilityResolverWarning(message, error) {
658
- console.warn(message, error);
659
- }
660
664
  var ModelCapabilityResolver = class {
661
665
  options;
662
666
  cache;
663
667
  sources;
664
668
  initialized = false;
665
669
  initPromise;
666
- constructor(options = {}) {
670
+ log;
671
+ constructor(options = {}, logger) {
667
672
  this.options = { ...DEFAULT_RESOLVER_OPTIONS, ...options };
668
673
  this.cache = new CapabilityCache(this.options);
674
+ this.log = logger?.child("models") ?? silentLogger;
669
675
  this.sources = [
670
676
  new CacheCapabilitySource(this.cache),
671
677
  new PatternCapabilitySource()
@@ -688,10 +694,9 @@ var ModelCapabilityResolver = class {
688
694
  );
689
695
  if (remoteSource) {
690
696
  remoteSource.refresh().catch((err) => {
691
- logCapabilityResolverWarning(
692
- "[agent-core] Background refresh failed:",
693
- err
694
- );
697
+ this.log.warn("Background refresh failed", {
698
+ error: err instanceof Error ? err.message : String(err)
699
+ });
695
700
  });
696
701
  }
697
702
  }
@@ -722,10 +727,9 @@ var ModelCapabilityResolver = class {
722
727
  }
723
728
  }
724
729
  } catch (error) {
725
- logCapabilityResolverWarning(
726
- `[agent-core] Source ${source.name} failed:`,
727
- error
728
- );
730
+ this.log.warn(`Source ${source.name} failed`, {
731
+ error: error instanceof Error ? error.message : String(error)
732
+ });
729
733
  }
730
734
  }
731
735
  if (!bestResult?.entry) {
@@ -1,3 +1,7 @@
1
+ import {
2
+ silentLogger
3
+ } from "./chunk-T4UIX5D7.js";
4
+
1
5
  // src/mcp/modules.ts
2
6
  var mcpModule;
3
7
  var stdioModule;
@@ -30,9 +34,11 @@ async function getStdioClientModule() {
30
34
  var DefaultMCPManager = class {
31
35
  config;
32
36
  connections = /* @__PURE__ */ new Map();
37
+ log;
33
38
  toolCache;
34
- constructor(config) {
39
+ constructor(config, logger) {
35
40
  this.config = config;
41
+ this.log = logger?.child("mcp") ?? silentLogger;
36
42
  }
37
43
  async connect() {
38
44
  const results = /* @__PURE__ */ new Map();
@@ -80,7 +86,7 @@ var DefaultMCPManager = class {
80
86
  const allTools = {};
81
87
  const toolPromises = Array.from(this.connections.entries()).map(
82
88
  async ([serverName, connection]) => {
83
- if (connection.status.status !== "connected") {
89
+ if (connection.status.status !== "connected" || !connection.client) {
84
90
  return;
85
91
  }
86
92
  try {
@@ -89,7 +95,9 @@ var DefaultMCPManager = class {
89
95
  allTools[`${serverName}__${toolName}`] = tool;
90
96
  }
91
97
  } catch (error) {
92
- console.warn(`[mcp] Failed to get tools from ${serverName}:`, error);
98
+ this.log.warn(`Failed to get tools from ${serverName}`, {
99
+ error: error instanceof Error ? error.message : String(error)
100
+ });
93
101
  }
94
102
  }
95
103
  );
@@ -108,77 +116,6 @@ var DefaultMCPManager = class {
108
116
  }
109
117
  return status;
110
118
  }
111
- async listResources() {
112
- const resources = [];
113
- const promises = Array.from(this.connections.entries()).map(
114
- async ([serverName, connection]) => {
115
- if (connection.status.status !== "connected") {
116
- return;
117
- }
118
- try {
119
- const result = await connection.client.listResources();
120
- for (const resource of result.resources) {
121
- resources.push({
122
- uri: resource.uri,
123
- name: resource.name,
124
- description: resource.description,
125
- mimeType: resource.mimeType,
126
- server: serverName
127
- });
128
- }
129
- } catch {
130
- }
131
- }
132
- );
133
- await Promise.all(promises);
134
- return resources;
135
- }
136
- async readResource(uri) {
137
- for (const [, connection] of this.connections) {
138
- if (connection.status.status !== "connected") {
139
- continue;
140
- }
141
- try {
142
- return await connection.client.readResource({ uri });
143
- } catch {
144
- }
145
- }
146
- throw new Error(`Resource not found: ${uri}`);
147
- }
148
- async listPrompts() {
149
- const prompts = [];
150
- const promises = Array.from(this.connections.entries()).map(
151
- async ([serverName, connection]) => {
152
- if (connection.status.status !== "connected") {
153
- return;
154
- }
155
- try {
156
- const result = await connection.client.experimental_listPrompts();
157
- for (const prompt of result.prompts) {
158
- prompts.push({
159
- name: prompt.name,
160
- description: prompt.description,
161
- arguments: prompt.arguments,
162
- server: serverName
163
- });
164
- }
165
- } catch {
166
- }
167
- }
168
- );
169
- await Promise.all(promises);
170
- return prompts;
171
- }
172
- async getPrompt(serverName, promptName, args) {
173
- const connection = this.connections.get(serverName);
174
- if (!connection || connection.status.status !== "connected") {
175
- throw new Error(`Server not connected: ${serverName}`);
176
- }
177
- return await connection.client.experimental_getPrompt({
178
- name: promptName,
179
- arguments: args
180
- });
181
- }
182
119
  async close() {
183
120
  const closePromises = Array.from(this.connections.values()).map(
184
121
  async (connection) => {
@@ -216,6 +153,11 @@ var DefaultMCPManager = class {
216
153
  )
217
154
  ]);
218
155
  };
156
+ const clientOptions = {
157
+ name: config.name ?? name,
158
+ ...config.onUncaughtError ? { onUncaughtError: config.onUncaughtError } : {},
159
+ ...config.capabilities ? { capabilities: config.capabilities } : {}
160
+ };
219
161
  if (config.transport === "stdio") {
220
162
  const { StdioClientTransport } = await getStdioClientModule();
221
163
  const transport = new StdioClientTransport({
@@ -224,10 +166,7 @@ var DefaultMCPManager = class {
224
166
  env: config.env,
225
167
  cwd: config.cwd
226
168
  });
227
- const client2 = await createMCPClient({
228
- transport,
229
- name: config.name ?? name
230
- });
169
+ const client2 = await createMCPClient({ transport, ...clientOptions });
231
170
  const tools2 = await withTimeout(client2.tools(), timeout);
232
171
  return { client: client2, toolCount: Object.keys(tools2).length };
233
172
  }
@@ -235,9 +174,12 @@ var DefaultMCPManager = class {
235
174
  transport: {
236
175
  type: config.transport,
237
176
  url: config.url,
238
- headers: config.headers
177
+ headers: config.headers,
178
+ ...config.authProvider ? { authProvider: config.authProvider } : {},
179
+ ...config.redirect ? { redirect: config.redirect } : {},
180
+ ...config.fetch ? { fetch: config.fetch } : {}
239
181
  },
240
- name: config.name ?? name
182
+ ...clientOptions
241
183
  });
242
184
  const tools = await withTimeout(client.tools(), timeout);
243
185
  return { client, toolCount: Object.keys(tools).length };
@@ -248,9 +190,6 @@ var DefaultMCPManager = class {
248
190
  function createMCPManager(config) {
249
191
  return new DefaultMCPManager(config);
250
192
  }
251
- function defineServer(config) {
252
- return config;
253
- }
254
193
  function stdioServer(command, args, options) {
255
194
  return {
256
195
  transport: "stdio",
@@ -276,7 +215,6 @@ function sseServer(url, options) {
276
215
 
277
216
  export {
278
217
  createMCPManager,
279
- defineServer,
280
218
  stdioServer,
281
219
  httpServer,
282
220
  sseServer
File without changes