@dexto/core 1.16.4 → 1.16.6

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 (37) hide show
  1. package/dist/context/manager.cjs +50 -36
  2. package/dist/context/manager.d.ts +18 -0
  3. package/dist/context/manager.d.ts.map +1 -1
  4. package/dist/context/manager.js +50 -36
  5. package/dist/llm/auth/index.d.ts +1 -1
  6. package/dist/llm/auth/index.d.ts.map +1 -1
  7. package/dist/llm/auth/types.d.ts +14 -0
  8. package/dist/llm/auth/types.d.ts.map +1 -1
  9. package/dist/llm/error-codes.cjs +2 -0
  10. package/dist/llm/error-codes.d.ts +2 -0
  11. package/dist/llm/error-codes.d.ts.map +1 -1
  12. package/dist/llm/error-codes.js +2 -0
  13. package/dist/llm/errors.cjs +27 -0
  14. package/dist/llm/errors.d.ts +9 -0
  15. package/dist/llm/errors.d.ts.map +1 -1
  16. package/dist/llm/errors.js +27 -0
  17. package/dist/llm/executor/stream-processor.cjs +7 -0
  18. package/dist/llm/executor/stream-processor.d.ts +1 -0
  19. package/dist/llm/executor/stream-processor.d.ts.map +1 -1
  20. package/dist/llm/executor/stream-processor.js +7 -0
  21. package/dist/llm/executor/tool-output-spill.cjs +46 -14
  22. package/dist/llm/executor/tool-output-spill.d.ts.map +1 -1
  23. package/dist/llm/executor/tool-output-spill.js +46 -14
  24. package/dist/llm/index.d.ts +1 -1
  25. package/dist/llm/index.d.ts.map +1 -1
  26. package/dist/llm/services/factory.cjs +204 -14
  27. package/dist/llm/services/factory.d.ts +1 -1
  28. package/dist/llm/services/factory.d.ts.map +1 -1
  29. package/dist/llm/services/factory.js +204 -14
  30. package/dist/tools/tool-output-read.cjs +4 -3
  31. package/dist/tools/tool-output-read.d.ts.map +1 -1
  32. package/dist/tools/tool-output-read.js +4 -3
  33. package/dist/utils/text-boundary.cjs +32 -0
  34. package/dist/utils/text-boundary.d.ts +3 -0
  35. package/dist/utils/text-boundary.d.ts.map +1 -0
  36. package/dist/utils/text-boundary.js +9 -0
  37. package/package.json +2 -2
@@ -1,6 +1,7 @@
1
1
  import "../../chunk-C6A6W6XS.js";
2
2
  import { LLMError } from "../errors.js";
3
3
  import { VercelLLMService } from "./vercel.js";
4
+ import { APICallError } from "ai";
4
5
  import {
5
6
  ANTHROPIC_BETA_HEADER,
6
7
  ANTHROPIC_INTERLEAVED_THINKING_BETA,
@@ -70,13 +71,111 @@ function logRuntimeAuthResolution(input) {
70
71
  model,
71
72
  auth,
72
73
  runtime: {
73
- hasRuntimeFetch: Boolean(runtimeAuth?.fetch),
74
+ hasRuntimeFetch: Boolean(runtimeAuth?.fetch || runtimeAuth?.requestAuth),
74
75
  hasRuntimeHeaders: Boolean(runtimeAuth?.headers),
75
76
  hasRuntimeBaseURL: Boolean(runtimeAuth?.baseURL),
76
77
  hasEffectiveBaseURL: Boolean(effectiveBaseURL)
77
78
  }
78
79
  });
79
80
  }
81
+ const MAX_RETRY_ERROR_BODY_BYTES = 64 * 1024;
82
+ function boundedClassificationResponse(response) {
83
+ const clone = response.clone();
84
+ if (!clone.body) return { view: clone, cancel: () => {
85
+ } };
86
+ const reader = clone.body.getReader();
87
+ let remaining = MAX_RETRY_ERROR_BODY_BYTES;
88
+ const body = new globalThis.ReadableStream({
89
+ async pull(controller) {
90
+ try {
91
+ const chunk = await reader.read();
92
+ if (chunk.done) {
93
+ controller.close();
94
+ return;
95
+ }
96
+ const part = chunk.value.subarray(0, remaining);
97
+ remaining -= part.byteLength;
98
+ if (part.byteLength) controller.enqueue(part);
99
+ if (remaining === 0) {
100
+ void reader.cancel().catch(() => {
101
+ });
102
+ controller.close();
103
+ }
104
+ } catch (error) {
105
+ controller.error(error);
106
+ }
107
+ },
108
+ cancel() {
109
+ void reader.cancel().catch(() => {
110
+ });
111
+ }
112
+ });
113
+ const view = new globalThis.Response(body, {
114
+ status: clone.status,
115
+ statusText: clone.statusText,
116
+ headers: clone.headers
117
+ });
118
+ Object.defineProperties(view, {
119
+ url: { value: response.url },
120
+ redirected: { value: response.redirected }
121
+ });
122
+ return {
123
+ view,
124
+ cancel: () => {
125
+ void reader.cancel().catch(() => {
126
+ });
127
+ }
128
+ };
129
+ }
130
+ function rethrowAbort(error, signal) {
131
+ if (signal?.aborted || error instanceof Error && error.name === "AbortError") throw error;
132
+ }
133
+ async function readRetryErrorBody(response, signal) {
134
+ if (signal?.aborted) {
135
+ void response.body?.cancel().catch(() => {
136
+ });
137
+ throw new globalThis.DOMException("Request aborted", "AbortError");
138
+ }
139
+ if (!response.body) return "";
140
+ const reader = response.body.getReader();
141
+ const decoder = new globalThis.TextDecoder();
142
+ let body = "";
143
+ let bytes = 0;
144
+ let onAbort;
145
+ const aborted = signal ? new Promise((_, reject) => {
146
+ onAbort = () => {
147
+ reject(new globalThis.DOMException("Request aborted", "AbortError"));
148
+ void reader.cancel().catch(() => {
149
+ });
150
+ };
151
+ if (signal.aborted) onAbort();
152
+ else signal.addEventListener("abort", onAbort, { once: true });
153
+ }) : void 0;
154
+ void aborted?.catch(() => {
155
+ });
156
+ try {
157
+ for (; ; ) {
158
+ if (signal?.aborted) throw new globalThis.DOMException("Request aborted", "AbortError");
159
+ const read = reader.read();
160
+ const chunk = aborted ? await Promise.race([read, aborted]) : await read;
161
+ if (chunk.done) break;
162
+ const remaining = MAX_RETRY_ERROR_BODY_BYTES - bytes;
163
+ body += decoder.decode(chunk.value.subarray(0, remaining), { stream: true });
164
+ bytes += chunk.value.byteLength;
165
+ if (bytes >= MAX_RETRY_ERROR_BODY_BYTES) {
166
+ void reader.cancel().catch(() => {
167
+ });
168
+ break;
169
+ }
170
+ }
171
+ body += decoder.decode();
172
+ } catch (error) {
173
+ rethrowAbort(error, signal);
174
+ } finally {
175
+ if (signal && onAbort) signal.removeEventListener("abort", onAbort);
176
+ }
177
+ return body;
178
+ }
80
179
  async function createVercelModel(llmConfig, context) {
81
180
  const { provider, model, baseURL } = llmConfig;
82
181
  const runtimeAuth = context?.authResolver?.resolveRuntimeAuth({
@@ -89,9 +188,68 @@ async function createVercelModel(llmConfig, context) {
89
188
  const apiKey = runtimeAuth?.apiKey || llmConfig.apiKey || resolvedProviderApiKey;
90
189
  const runtimeBaseURL = runtimeAuth?.baseURL;
91
190
  const runtimeHeaders = runtimeAuth?.headers;
92
- const runtimeFetch = runtimeAuth?.fetch;
93
- const effectiveBaseURL = runtimeBaseURL?.replace(/\/$/, "") || baseURL?.replace(/\/$/, "");
191
+ if (runtimeBaseURL !== void 0 && !runtimeBaseURL.trim()) {
192
+ throw LLMError.invalidRuntimeBaseURL(provider);
193
+ }
194
+ const requestAuth = runtimeAuth?.requestAuth;
195
+ if (requestAuth && runtimeAuth?.fetch) {
196
+ throw LLMError.runtimeAuthConflict(provider);
197
+ }
198
+ const runtimeFetch = requestAuth ? async (input, init) => {
199
+ const { response, provenance } = await requestAuth.fetch(input, init);
200
+ if (response.ok) return response;
201
+ const signal = init?.signal ?? (input instanceof globalThis.Request ? input.signal : void 0);
202
+ const classification = boundedClassificationResponse(response);
203
+ let retryable;
204
+ let onAbort;
205
+ try {
206
+ const decision = requestAuth.isRetryableResponse({
207
+ response: classification.view,
208
+ provenance,
209
+ ...signal ? { signal } : {}
210
+ });
211
+ if (signal) {
212
+ const aborted = new Promise((_, reject) => {
213
+ onAbort = () => reject(new globalThis.DOMException("Request aborted", "AbortError"));
214
+ if (signal.aborted) onAbort();
215
+ else signal.addEventListener("abort", onAbort, { once: true });
216
+ });
217
+ retryable = await Promise.race([decision, aborted]);
218
+ } else retryable = await decision;
219
+ } catch (error) {
220
+ if (signal?.aborted || error instanceof Error && error.name === "AbortError") {
221
+ void response.body?.cancel().catch(() => {
222
+ });
223
+ }
224
+ rethrowAbort(error, signal);
225
+ return response;
226
+ } finally {
227
+ if (signal && onAbort) signal.removeEventListener("abort", onAbort);
228
+ classification.cancel();
229
+ }
230
+ if (!retryable) return response;
231
+ const responseHeaders = {};
232
+ response.headers.forEach((value, key) => {
233
+ responseHeaders[key] = value;
234
+ });
235
+ throw new APICallError({
236
+ message: "Host classified model request failure as retryable",
237
+ url: typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url,
238
+ requestBodyValues: {},
239
+ statusCode: response.status,
240
+ responseHeaders,
241
+ responseBody: await readRetryErrorBody(response, signal),
242
+ isRetryable: true
243
+ });
244
+ } : runtimeAuth?.fetch;
245
+ const effectiveBaseURL = runtimeBaseURL?.trim().replace(/\/$/, "") || baseURL?.trim().replace(/\/$/, "");
94
246
  const usesCodexRuntimeAuth = runtimeBaseURL ? isCodexBaseURL(runtimeBaseURL) : false;
247
+ if ((provider === "bedrock" || provider === "local") && (runtimeBaseURL !== void 0 || runtimeHeaders !== void 0 || runtimeAuth?.fetch || requestAuth)) {
248
+ throw LLMError.runtimeAuthUnsupported(provider);
249
+ }
250
+ if (usesCodexRuntimeAuth && (runtimeHeaders !== void 0 || runtimeAuth?.fetch || requestAuth)) {
251
+ throw LLMError.runtimeAuthUnsupported(provider);
252
+ }
95
253
  logRuntimeAuthResolution({
96
254
  context,
97
255
  provider,
@@ -101,7 +259,7 @@ async function createVercelModel(llmConfig, context) {
101
259
  runtimeAuth,
102
260
  effectiveBaseURL
103
261
  });
104
- if (requiresApiKey(provider) && !usesCodexRuntimeAuth && !apiKey?.trim()) {
262
+ if (requiresApiKey(provider) && !usesCodexRuntimeAuth && !apiKey?.trim() && !requestAuth) {
105
263
  const envVar = getPrimaryApiKeyEnvVar(provider);
106
264
  throw LLMError.apiKeyMissing(provider, envVar);
107
265
  }
@@ -140,12 +298,14 @@ async function createVercelModel(llmConfig, context) {
140
298
  return provider2.chatModel(model);
141
299
  }
142
300
  case "openrouter": {
143
- const orBaseURL = baseURL || "https://openrouter.ai/api/v1";
301
+ const orBaseURL = effectiveBaseURL || "https://openrouter.ai/api/v1";
144
302
  const { createOpenRouter } = await import("@openrouter/ai-sdk-provider");
145
303
  const provider2 = createOpenRouter({
146
304
  apiKey: apiKey ?? "",
147
305
  baseURL: orBaseURL,
148
- compatibility: "strict"
306
+ compatibility: "strict",
307
+ ...runtimeHeaders ? { headers: runtimeHeaders } : {},
308
+ ...runtimeFetch ? { fetch: runtimeFetch } : {}
149
309
  });
150
310
  const chatModel = provider2.chat(model);
151
311
  if (!isLanguageModel(chatModel)) {
@@ -200,7 +360,9 @@ async function createVercelModel(llmConfig, context) {
200
360
  }).chat(model);
201
361
  }
202
362
  case "dexto-nova": {
203
- const dextoBaseURL = resolveDextoGatewayBaseURL(baseURL);
363
+ const dextoBaseURL = resolveDextoGatewayBaseURL(
364
+ runtimeBaseURL?.trim() ? runtimeBaseURL : baseURL
365
+ );
204
366
  const headers = {
205
367
  ...runtimeHeaders ?? {},
206
368
  [DEXTO_GATEWAY_HEADERS.CLIENT_SOURCE]: context?.clientSource ?? "cli"
@@ -216,7 +378,7 @@ async function createVercelModel(llmConfig, context) {
216
378
  baseURL: dextoBaseURL,
217
379
  compatibility: "strict",
218
380
  headers,
219
- ...apiKey?.trim() ? { apiKey } : {},
381
+ ...apiKey?.trim() ? { apiKey } : requestAuth ? { apiKey: "" } : {},
220
382
  ...runtimeFetch ? { fetch: runtimeFetch } : {}
221
383
  });
222
384
  const chatModel = provider2.chat(model);
@@ -246,18 +408,26 @@ async function createVercelModel(llmConfig, context) {
246
408
  }
247
409
  const location = process.env.GOOGLE_VERTEX_LOCATION;
248
410
  if (model.includes("claude")) {
249
- const headers = supportsAnthropicInterleavedThinking(model) ? { [ANTHROPIC_BETA_HEADER]: ANTHROPIC_INTERLEAVED_THINKING_BETA } : void 0;
411
+ const headers = mergeHeaders(
412
+ supportsAnthropicInterleavedThinking(model) ? { [ANTHROPIC_BETA_HEADER]: ANTHROPIC_INTERLEAVED_THINKING_BETA } : void 0,
413
+ runtimeHeaders
414
+ );
250
415
  const { createVertexAnthropic } = await import("@ai-sdk/google-vertex/anthropic");
251
416
  return createVertexAnthropic({
252
417
  project: projectId,
253
418
  location: location || "us-east5",
419
+ ...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
420
+ ...runtimeFetch ? { fetch: runtimeFetch } : {},
254
421
  ...headers ? { headers } : {}
255
422
  })(model);
256
423
  }
257
424
  const { createVertex } = await import("@ai-sdk/google-vertex");
258
425
  return createVertex({
259
426
  project: projectId,
260
- location: location || "us-central1"
427
+ location: location || "us-central1",
428
+ ...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
429
+ ...runtimeHeaders ? { headers: runtimeHeaders } : {},
430
+ ...runtimeFetch ? { fetch: runtimeFetch } : {}
261
431
  })(model);
262
432
  }
263
433
  case "bedrock": {
@@ -292,19 +462,39 @@ async function createVercelModel(llmConfig, context) {
292
462
  }
293
463
  case "google": {
294
464
  const { createGoogleGenerativeAI } = await import("@ai-sdk/google");
295
- return createGoogleGenerativeAI({ apiKey: apiKey ?? "" })(model);
465
+ return createGoogleGenerativeAI({
466
+ apiKey: apiKey ?? "",
467
+ ...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
468
+ ...runtimeHeaders ? { headers: runtimeHeaders } : {},
469
+ ...runtimeFetch ? { fetch: runtimeFetch } : {}
470
+ })(model);
296
471
  }
297
472
  case "groq": {
298
473
  const { createGroq } = await import("@ai-sdk/groq");
299
- return createGroq({ apiKey: apiKey ?? "" })(model);
474
+ return createGroq({
475
+ apiKey: apiKey ?? "",
476
+ ...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
477
+ ...runtimeHeaders ? { headers: runtimeHeaders } : {},
478
+ ...runtimeFetch ? { fetch: runtimeFetch } : {}
479
+ })(model);
300
480
  }
301
481
  case "xai": {
302
482
  const { createXai } = await import("@ai-sdk/xai");
303
- return createXai({ apiKey: apiKey ?? "" })(model);
483
+ return createXai({
484
+ apiKey: apiKey ?? "",
485
+ ...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
486
+ ...runtimeHeaders ? { headers: runtimeHeaders } : {},
487
+ ...runtimeFetch ? { fetch: runtimeFetch } : {}
488
+ })(model);
304
489
  }
305
490
  case "cohere": {
306
491
  const { createCohere } = await import("@ai-sdk/cohere");
307
- return createCohere({ apiKey: apiKey ?? "" })(model);
492
+ return createCohere({
493
+ apiKey: apiKey ?? "",
494
+ ...effectiveBaseURL ? { baseURL: effectiveBaseURL } : {},
495
+ ...runtimeHeaders ? { headers: runtimeHeaders } : {},
496
+ ...runtimeFetch ? { fetch: runtimeFetch } : {}
497
+ })(model);
308
498
  }
309
499
  case "ollama": {
310
500
  const ollamaBaseURL = effectiveBaseURL || "http://localhost:11434/v1";
@@ -22,6 +22,7 @@ __export(tool_output_read_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(tool_output_read_exports);
24
24
  var import_zod = require("zod");
25
+ var import_text_boundary = require("../utils/text-boundary.js");
25
26
  var import_tool_output_spill = require("../llm/executor/tool-output-spill.js");
26
27
  var import_activity = require("./activity.js");
27
28
  var import_errors = require("./errors.js");
@@ -91,8 +92,8 @@ function readLines(text, input) {
91
92
  const room = MAX_READ_CHARS - chars - prefix.length;
92
93
  if (room <= 0) break;
93
94
  const full = lines[line - 1] ?? "";
94
- const from = line === start ? Math.min(input.charOffset ?? 0, full.length) : 0;
95
- const piece = full.slice(from, from + room);
95
+ const from = line === start ? (0, import_text_boundary.safeTextBoundary)(full, Math.min(input.charOffset ?? 0, full.length)) : 0;
96
+ const piece = full.slice(from, (0, import_text_boundary.safeTextBoundary)(full, Math.min(from + room, full.length)));
96
97
  selected.push(`${prefix}${piece}`);
97
98
  chars += prefix.length + piece.length + 1;
98
99
  if (from + piece.length < full.length) {
@@ -119,7 +120,7 @@ function searchLines(text, pattern, maxMatches) {
119
120
  if (!line.toLowerCase().includes(needle)) return;
120
121
  total += 1;
121
122
  if (outOfRoom || found.length >= maxMatches) return;
122
- const match = `${index + 1}: ${line.slice(0, MAX_MATCH_LINE_CHARS)}`;
123
+ const match = `${index + 1}: ${line.slice(0, (0, import_text_boundary.safeTextBoundary)(line, MAX_MATCH_LINE_CHARS))}`;
123
124
  if (chars + match.length > MAX_READ_CHARS) {
124
125
  outOfRoom = true;
125
126
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"tool-output-read.d.ts","sourceRoot":"","sources":["../../src/tools/tool-output-read.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAMxE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAYvC,QAAA,MAAM,yBAAyB;;;;;;;kBA0ClB,CAAC;AAId,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC7C,YAAY,EAAE,iBAAiB,CAAC;IAChC,WAAW,EAAE,eAAe,CAAC;CAChC,GAAG,IAAI,CAAC,OAAO,yBAAyB,CAAC,CAkCzC"}
1
+ {"version":3,"file":"tool-output-read.d.ts","sourceRoot":"","sources":["../../src/tools/tool-output-read.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAMxE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAYvC,QAAA,MAAM,yBAAyB;;;;;;;kBA0ClB,CAAC;AAId,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAC7C,YAAY,EAAE,iBAAiB,CAAC;IAChC,WAAW,EAAE,eAAe,CAAC;CAChC,GAAG,IAAI,CAAC,OAAO,yBAAyB,CAAC,CAkCzC"}
@@ -1,5 +1,6 @@
1
1
  import "../chunk-C6A6W6XS.js";
2
2
  import { z } from "zod";
3
+ import { safeTextBoundary } from "../utils/text-boundary.js";
3
4
  import { TOOL_OUTPUT_READ_TOOL_NAME } from "../llm/executor/tool-output-spill.js";
4
5
  import { TOOL_ACTIVITY } from "./activity.js";
5
6
  import { ToolError } from "./errors.js";
@@ -69,8 +70,8 @@ function readLines(text, input) {
69
70
  const room = MAX_READ_CHARS - chars - prefix.length;
70
71
  if (room <= 0) break;
71
72
  const full = lines[line - 1] ?? "";
72
- const from = line === start ? Math.min(input.charOffset ?? 0, full.length) : 0;
73
- const piece = full.slice(from, from + room);
73
+ const from = line === start ? safeTextBoundary(full, Math.min(input.charOffset ?? 0, full.length)) : 0;
74
+ const piece = full.slice(from, safeTextBoundary(full, Math.min(from + room, full.length)));
74
75
  selected.push(`${prefix}${piece}`);
75
76
  chars += prefix.length + piece.length + 1;
76
77
  if (from + piece.length < full.length) {
@@ -97,7 +98,7 @@ function searchLines(text, pattern, maxMatches) {
97
98
  if (!line.toLowerCase().includes(needle)) return;
98
99
  total += 1;
99
100
  if (outOfRoom || found.length >= maxMatches) return;
100
- const match = `${index + 1}: ${line.slice(0, MAX_MATCH_LINE_CHARS)}`;
101
+ const match = `${index + 1}: ${line.slice(0, safeTextBoundary(line, MAX_MATCH_LINE_CHARS))}`;
101
102
  if (chars + match.length > MAX_READ_CHARS) {
102
103
  outOfRoom = true;
103
104
  return;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var text_boundary_exports = {};
20
+ __export(text_boundary_exports, {
21
+ safeTextBoundary: () => safeTextBoundary
22
+ });
23
+ module.exports = __toCommonJS(text_boundary_exports);
24
+ function safeTextBoundary(text, offset) {
25
+ const before = text.charCodeAt(offset - 1);
26
+ const after = text.charCodeAt(offset);
27
+ return before >= 55296 && before <= 56319 && after >= 56320 && after <= 57343 ? offset - 1 : offset;
28
+ }
29
+ // Annotate the CommonJS export names for ESM import in node:
30
+ 0 && (module.exports = {
31
+ safeTextBoundary
32
+ });
@@ -0,0 +1,3 @@
1
+ /** Move a UTF-16 boundary back when it falls between a surrogate pair. */
2
+ export declare function safeTextBoundary(text: string, offset: number): number;
3
+ //# sourceMappingURL=text-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-boundary.d.ts","sourceRoot":"","sources":["../../src/utils/text-boundary.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMrE"}
@@ -0,0 +1,9 @@
1
+ import "../chunk-C6A6W6XS.js";
2
+ function safeTextBoundary(text, offset) {
3
+ const before = text.charCodeAt(offset - 1);
4
+ const after = text.charCodeAt(offset);
5
+ return before >= 55296 && before <= 56319 && after >= 56320 && after <= 57343 ? offset - 1 : offset;
6
+ }
7
+ export {
8
+ safeTextBoundary
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexto/core",
3
- "version": "1.16.4",
3
+ "version": "1.16.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -174,7 +174,7 @@
174
174
  "nanoid": "^5.1.16",
175
175
  "winston": "^3.17.0",
176
176
  "yaml": "^2.8.3",
177
- "@dexto/llm": "1.16.4"
177
+ "@dexto/llm": "1.16.6"
178
178
  },
179
179
  "devDependencies": {
180
180
  "@opentelemetry/context-async-hooks": "^2.12.0",