@demicodes/agent 0.13.0 → 0.14.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.
Files changed (2) hide show
  1. package/dist/index.mjs +7 -5
  2. package/package.json +5 -5
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as cloneBlocks, i as applyTranscriptPatches, n as createWebSocketServerTransport, o as ProviderStreamError, r as AgentClient, s as isContextLengthExceeded, t as createWebSocketClientTransport } from "./websocket-transport-BjSj3U0I.mjs";
2
- import { AbortError, abortable, asError, asRecord, asString, bytesToBase64, createId, delay, isAbortError, isRecord, noop, parseJsonOrString, safeJsonStringify, throwIfAborted, truncate } from "@demicodes/utils";
2
+ import { AbortError, abortable, asError, asRecord, asString, bytesToBase64, createId, delay, isAbortError, isRecord, noop, parseJsonOrString, safeJsonStringify, sliceHead, sliceTail, throwIfAborted, toWellFormedText, truncate } from "@demicodes/utils";
3
3
  import { BashEnvironment, CommandRegistry, MAX_TIMEOUT_MS, heredocDelimiter, shellQuote } from "@demicodes/shell";
4
4
  import { providerRuntime } from "@demicodes/provider";
5
5
  import { modelAcceptsMediaType, sniffModelMediaType } from "@demicodes/core";
@@ -587,9 +587,11 @@ function boundToolResultContent(content, headChars, tailChars) {
587
587
  }
588
588
  function boundText(text, headChars, tailChars) {
589
589
  const maxChars = headChars + tailChars;
590
- if (text.length <= maxChars) return text;
591
- const omitted = text.length - maxChars;
592
- return `${text.slice(0, headChars)}\n\n[... truncated ${omitted} characters ...]\n\n${text.slice(-tailChars)}`;
590
+ if (text.length <= maxChars) return toWellFormedText(text);
591
+ const head = sliceHead(text, headChars);
592
+ const tail = sliceTail(text, tailChars);
593
+ const omitted = text.length - head.length - tail.length;
594
+ return toWellFormedText(`${head}\n\n[... truncated ${omitted} characters ...]\n\n${tail}`);
593
595
  }
594
596
  //#endregion
595
597
  //#region src/retry-policy.ts
@@ -2557,7 +2559,7 @@ function boundedPreview(text, budgetTokens) {
2557
2559
  truncated: false
2558
2560
  };
2559
2561
  return {
2560
- text: text.slice(0, maxChars),
2562
+ text: sliceHead(text, maxChars),
2561
2563
  truncated: true
2562
2564
  };
2563
2565
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@demicodes/agent",
3
3
  "description": "Session runtime and transport-neutral client and server protocol for Demi.",
4
- "version": "0.13.0",
4
+ "version": "0.14.1",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "exports": {
@@ -19,10 +19,10 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@demicodes/core": "^0.13.0",
23
- "@demicodes/provider": "^0.13.0",
24
- "@demicodes/shell": "^0.13.0",
25
- "@demicodes/utils": "^0.13.0"
22
+ "@demicodes/core": "^0.14.1",
23
+ "@demicodes/provider": "^0.14.1",
24
+ "@demicodes/shell": "^0.14.1",
25
+ "@demicodes/utils": "^0.14.1"
26
26
  },
27
27
  "license": "Apache-2.0",
28
28
  "main": "./dist/index.mjs",