@cuylabs/agent-core 0.11.0 → 0.13.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-GFTW23FV.js → chunk-BGG2HVIR.js} +4 -2
  2. package/dist/{chunk-TOTDGK3P.js → chunk-CSR75JVC.js} +4 -5
  3. package/dist/{chunk-ICZ66572.js → chunk-CZ5XOVDV.js} +40 -9
  4. package/dist/{chunk-2O4MCSQS.js → chunk-FYC33XFI.js} +31 -10
  5. package/dist/{chunk-WBPOZ7CL.js → chunk-HNEI7JVE.js} +114 -38
  6. package/dist/{chunk-SPILYYDF.js → chunk-I7EJGKUP.js} +79 -7
  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-CMYN2RCB.js → chunk-NWQUZWLT.js} +13 -7
  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-US7S4FYW.js +610 -0
  18. package/dist/{chunk-RN6WZEUF.js → chunk-WI5JFEAI.js} +71 -36
  19. package/dist/{chunk-5NVVNXPQ.js → chunk-ZKEC7MFQ.js} +5 -30
  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 +119 -116
  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-DzPiv6EK.d.ts → instance-N5VhcNT2.d.ts} +45 -7
  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-CJfwfzGe.d.ts → model-messages-DnsiSiZj.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
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  buildEntryPath,
6
6
  deserializeMessage
7
- } from "./chunk-ICZ66572.js";
7
+ } from "./chunk-CZ5XOVDV.js";
8
8
 
9
9
  // src/agent/session.ts
10
10
  async function ensureSessionLoaded(options) {
@@ -25,7 +25,9 @@ async function repairOrphanedToolCalls(sessions) {
25
25
  for (const message of messages) {
26
26
  if (message.role === "assistant" && message.toolCalls) {
27
27
  for (const toolCall of message.toolCalls) {
28
- pendingCallIds.set(toolCall.toolCallId, { toolName: toolCall.toolName });
28
+ pendingCallIds.set(toolCall.toolCallId, {
29
+ toolName: toolCall.toolName
30
+ });
29
31
  }
30
32
  }
31
33
  if (message.role === "tool" && message.toolCallId) {
@@ -60,10 +62,7 @@ function getVisibleSessionMessages(sessions) {
60
62
  if (!leafId) {
61
63
  return [];
62
64
  }
63
- const path = buildEntryPath(
64
- sessions.getEntries(),
65
- leafId
66
- );
65
+ const path = buildEntryPath(sessions.getEntries(), leafId);
67
66
  const visible = [];
68
67
  let skipUntilId;
69
68
  for (const entry of path) {
@@ -520,9 +519,7 @@ function createLocalDispatchRuntime(options) {
520
519
  if (active.record.status === "running" && options2?.waitMs) {
521
520
  await Promise.race([
522
521
  active.promise,
523
- new Promise(
524
- (resolve) => setTimeout(resolve, options2.waitMs)
525
- )
522
+ new Promise((resolve) => setTimeout(resolve, options2.waitMs))
526
523
  ]);
527
524
  }
528
525
  return { ...active.record };
@@ -563,9 +560,7 @@ function createLocalDispatchRuntime(options) {
563
560
  let records = [...dispatches.values()].map((d) => ({ ...d.record }));
564
561
  if (options2?.status) {
565
562
  const statuses = Array.isArray(options2.status) ? options2.status : [options2.status];
566
- records = records.filter(
567
- (r) => statuses.includes(r.status)
568
- );
563
+ records = records.filter((r) => statuses.includes(r.status));
569
564
  }
570
565
  if (options2?.targetType) {
571
566
  records = records.filter((r) => r.targetType === options2.targetType);
@@ -137,7 +137,10 @@ function createDispatchTaskExecutor(options) {
137
137
  const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
138
138
  return async (input) => {
139
139
  const targetName = options.resolveTargetName?.(input) ?? input.runtime.member.role;
140
- const target = requireTarget(targets, ensureNonEmpty(targetName, "targetName"));
140
+ const target = requireTarget(
141
+ targets,
142
+ ensureNonEmpty(targetName, "targetName")
143
+ );
141
144
  const startedAt = now();
142
145
  const dispatchId = input.task.runId ?? input.task.id;
143
146
  const startResult = await target.start({
@@ -237,7 +240,10 @@ function createDispatchExternalTaskControl(options) {
237
240
  const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
238
241
  function resolveRecord(task, runtime) {
239
242
  const targetName = options.resolveTargetName?.({ task, runtime }) ?? runtime.role.name;
240
- const target = requireTarget(targets, ensureNonEmpty(targetName, "targetName"));
243
+ const target = requireTarget(
244
+ targets,
245
+ ensureNonEmpty(targetName, "targetName")
246
+ );
241
247
  const dispatchId = task.runId ?? task.id;
242
248
  const startedAt = now();
243
249
  const record = options.createRecord?.({
@@ -60,7 +60,9 @@ function anyApprovalConditions(...conditions) {
60
60
  return (context) => conditions.some((condition) => condition(context));
61
61
  }
62
62
  function matchApprovalSessions(...sessionIds) {
63
- const allowed = new Set(sessionIds.map((sessionId) => sessionId.trim()).filter(Boolean));
63
+ const allowed = new Set(
64
+ sessionIds.map((sessionId) => sessionId.trim()).filter(Boolean)
65
+ );
64
66
  return (context) => allowed.has(context.sessionId);
65
67
  }
66
68
  function matchApprovalRisks(...risks) {
@@ -118,7 +120,11 @@ function normalizeApprovalCascadePolicy(input) {
118
120
  };
119
121
  }
120
122
  function normalizeRememberScopes(scopes) {
121
- const allowed = /* @__PURE__ */ new Set(["session", "project", "user"]);
123
+ const allowed = /* @__PURE__ */ new Set([
124
+ "session",
125
+ "project",
126
+ "user"
127
+ ]);
122
128
  const normalized = (scopes ?? [DEFAULT_REMEMBER_SCOPE]).filter(
123
129
  (scope) => allowed.has(scope)
124
130
  );
@@ -283,24 +289,34 @@ function createApprovalHandler(config = {}) {
283
289
  if (defaultAction === "deny") {
284
290
  throw new ApprovalDeniedError(tool, args);
285
291
  }
286
- throw new ApprovalDeniedError(tool, args, "No approval handler configured");
292
+ throw new ApprovalDeniedError(
293
+ tool,
294
+ args,
295
+ "No approval handler configured"
296
+ );
287
297
  }
288
298
  const ac = new AbortController();
289
299
  activeRequests.add(ac);
290
300
  let timeoutId;
291
301
  try {
292
- const resolution = normalizeApprovalDecision(await Promise.race([
293
- onRequest(evaluation.request),
294
- new Promise((_, reject) => {
295
- timeoutId = setTimeout(() => {
296
- reject(new ApprovalTimeoutError(tool, timeout));
297
- }, timeout);
298
- ac.signal.addEventListener("abort", () => {
299
- clearTimeout(timeoutId);
300
- reject(new Error("Cancelled"));
301
- }, { once: true });
302
- })
303
- ]));
302
+ const resolution = normalizeApprovalDecision(
303
+ await Promise.race([
304
+ onRequest(evaluation.request),
305
+ new Promise((_, reject) => {
306
+ timeoutId = setTimeout(() => {
307
+ reject(new ApprovalTimeoutError(tool, timeout));
308
+ }, timeout);
309
+ ac.signal.addEventListener(
310
+ "abort",
311
+ () => {
312
+ clearTimeout(timeoutId);
313
+ reject(new Error("Cancelled"));
314
+ },
315
+ { once: true }
316
+ );
317
+ })
318
+ ])
319
+ );
304
320
  switch (resolution.action) {
305
321
  case "allow":
306
322
  return;
@@ -527,7 +543,9 @@ function createApprovalPolicyPreset(name, options = {}) {
527
543
  case "dangerously-allow-all":
528
544
  return createDangerouslyAllowAllApprovalPolicy(options);
529
545
  case "risk-tier":
530
- return createRiskTierApprovalPolicy(options);
546
+ return createRiskTierApprovalPolicy(
547
+ options
548
+ );
531
549
  }
532
550
  }
533
551
 
@@ -872,7 +872,10 @@ function mergePluginManifest(manifest, definition) {
872
872
  description: definition.description ?? manifest.description,
873
873
  version: definition.version ?? manifest.version,
874
874
  compatibility: mergeCompatibility(manifest.compatibility, definition.compatibility) ?? manifest.compatibility,
875
- capabilities: mergeCapabilityTags(manifest.capabilities, definition.capabilities),
875
+ capabilities: mergeCapabilityTags(
876
+ manifest.capabilities,
877
+ definition.capabilities
878
+ ),
876
879
  surfaces: mergeSurfaceContract(manifest.surfaces, definition.surfaces)
877
880
  };
878
881
  }
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  executeAgentToolCall,
3
3
  snapshotScope
4
- } from "./chunk-5NVVNXPQ.js";
4
+ } from "./chunk-ZKEC7MFQ.js";
5
5
  import {
6
6
  LLMError,
7
7
  isRetryable
8
- } from "./chunk-N3VX7FEE.js";
8
+ } from "./chunk-STDJYXYK.js";
9
9
  import {
10
10
  buildReasoningOptionsSync,
11
11
  supportsReasoningSync
12
- } from "./chunk-RN6WZEUF.js";
12
+ } from "./chunk-WI5JFEAI.js";
13
13
  import {
14
14
  DEFAULT_MAX_STEPS,
15
15
  DEFAULT_MAX_TOKENS,
@@ -17,7 +17,7 @@ import {
17
17
  } from "./chunk-CJI7PVS2.js";
18
18
  import {
19
19
  formatApprovalDeniedReason
20
- } from "./chunk-V4RFNEET.js";
20
+ } from "./chunk-MLTJHUVG.js";
21
21
 
22
22
  // src/inference/toolset.ts
23
23
  import { tool, zodSchema } from "ai";
@@ -27,8 +27,10 @@ async function buildToolSet(options) {
27
27
  for (const [id, info] of Object.entries(options.tools)) {
28
28
  const initialized = await info.init({ cwd: options.cwd });
29
29
  const sdkPassthrough = {};
30
- if (initialized.title !== void 0) sdkPassthrough.title = initialized.title;
31
- if (initialized.strict !== void 0) sdkPassthrough.strict = initialized.strict;
30
+ if (initialized.title !== void 0)
31
+ sdkPassthrough.title = initialized.title;
32
+ if (initialized.strict !== void 0)
33
+ sdkPassthrough.strict = initialized.strict;
32
34
  if (initialized.inputExamples !== void 0) {
33
35
  sdkPassthrough.inputExamples = initialized.inputExamples;
34
36
  }
@@ -605,7 +607,11 @@ function convertAgentMessagesToModelMessages(messages) {
605
607
  }
606
608
  ]
607
609
  },
608
- ...message.metadata?.approvalCorrection ? [buildApprovalCorrectionPrompt(message.metadata.approvalCorrection)] : []
610
+ ...message.metadata?.approvalCorrection ? [
611
+ buildApprovalCorrectionPrompt(
612
+ message.metadata.approvalCorrection
613
+ )
614
+ ] : []
609
615
  ];
610
616
  case "system":
611
617
  return [{ role: "system", content: message.content }];