@cuylabs/agent-core 5.0.0 → 5.0.1

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.
@@ -49,6 +49,11 @@ export interface EventPrinterOptions {
49
49
  * @default false
50
50
  */
51
51
  team?: boolean;
52
+ /**
53
+ * Maximum characters to show for each tool result.
54
+ * @default 200
55
+ */
56
+ toolResultMaxChars?: number;
52
57
  /**
53
58
  * Writable stream for text output.
54
59
  * @default process.stdout
@@ -1 +1 @@
1
- {"version":3,"file":"event-printer.d.ts","sourceRoot":"","sources":["../../src/agent/event-printer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOrD,2DAA2D;AAC3D,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAE/B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAChC;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,mBAAwB,GAChC,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAkJ7B"}
1
+ {"version":3,"file":"event-printer.d.ts","sourceRoot":"","sources":["../../src/agent/event-printer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAOrD,2DAA2D;AAC3D,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;IAE/B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,cAAc,CAAC;CAChC;AAqCD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,mBAAwB,GAChC,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAsJ7B"}
package/dist/index.js CHANGED
@@ -3188,12 +3188,6 @@ async function* runChatLoop(deps) {
3188
3188
  return;
3189
3189
  }
3190
3190
  const planSnapshot = isPlanMode && stepResult.finishReason === "tool-calls" ? turnEngine.createStepCommitSnapshot() : void 0;
3191
- yield* commitStep({
3192
- step,
3193
- finishReason: stepResult.finishReason,
3194
- turnEngine,
3195
- applyCommitBatch
3196
- });
3197
3191
  if (stepResult.finishReason === "tool-calls") {
3198
3192
  if (step >= config.maxSteps) {
3199
3193
  const maxStepsError = new Error(
@@ -3238,6 +3232,13 @@ async function* runChatLoop(deps) {
3238
3232
  turnEngine,
3239
3233
  applyCommitBatch
3240
3234
  });
3235
+ } else {
3236
+ yield* commitStep({
3237
+ step,
3238
+ finishReason: stepResult.finishReason,
3239
+ turnEngine,
3240
+ applyCommitBatch
3241
+ });
3241
3242
  }
3242
3243
  step += 1;
3243
3244
  continue;
@@ -3903,6 +3904,22 @@ function formatContextCompactionEvent(event) {
3903
3904
  return `\u{1F4E6} Context compaction (${event.phase}): removed ${event.removedCount} message(s), ${event.tokensRemoved} tokens${cutReason}${trigger}${runReason}
3904
3905
  `;
3905
3906
  }
3907
+ function formatToolResult(result, maxChars) {
3908
+ let text;
3909
+ if (typeof result === "string") {
3910
+ text = result;
3911
+ } else {
3912
+ try {
3913
+ text = JSON.stringify(result);
3914
+ } catch {
3915
+ text = String(result);
3916
+ }
3917
+ }
3918
+ if (text.length <= maxChars) {
3919
+ return text;
3920
+ }
3921
+ return `${text.slice(0, Math.max(0, maxChars - 1))}\u2026`;
3922
+ }
3906
3923
  function createEventPrinter(options = {}) {
3907
3924
  const {
3908
3925
  tools = true,
@@ -3911,6 +3928,7 @@ function createEventPrinter(options = {}) {
3911
3928
  safety = true,
3912
3929
  completion = true,
3913
3930
  team = false,
3931
+ toolResultMaxChars = 200,
3914
3932
  stdout = process.stdout,
3915
3933
  stderr = process.stderr
3916
3934
  } = options;
@@ -3965,8 +3983,11 @@ function createEventPrinter(options = {}) {
3965
3983
  );
3966
3984
  break;
3967
3985
  case "tool-result":
3968
- if (tools) stderr.write(` \u2713 ${String(event.result).slice(0, 200)}
3969
- `);
3986
+ if (tools)
3987
+ stderr.write(
3988
+ ` \u2713 ${formatToolResult(event.result, toolResultMaxChars)}
3989
+ `
3990
+ );
3970
3991
  break;
3971
3992
  case "tool-error":
3972
3993
  if (tools) stderr.write(` \u2717 ${event.error}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuylabs/agent-core",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "Embeddable AI agent infrastructure — execution, sessions, tools, skills, dispatch, tracing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",