@dexto/core 1.19.3 → 1.19.4

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.
@@ -72,6 +72,29 @@ function blockSeparator(previousBlockId, blockId, accumulated, delta) {
72
72
  if (accumulated.endsWith("\n\n")) return "";
73
73
  return accumulated.endsWith("\n") ? "\n" : "\n\n";
74
74
  }
75
+ function isRecord(value) {
76
+ return typeof value === "object" && value !== null && !Array.isArray(value);
77
+ }
78
+ function readOpenRouterReasoningDetails(providerMetadata) {
79
+ if (!isRecord(providerMetadata)) return [];
80
+ const openRouter = providerMetadata["openrouter"];
81
+ if (!isRecord(openRouter)) return [];
82
+ const details = openRouter["reasoning_details"];
83
+ return Array.isArray(details) ? details : [];
84
+ }
85
+ function isEncryptedReasoningPlaceholder(text, providerMetadata) {
86
+ if (text !== "[REDACTED]") return false;
87
+ const details = readOpenRouterReasoningDetails(providerMetadata);
88
+ return details.length > 0 && details.every((detail) => isRecord(detail) && detail["type"] === "reasoning.encrypted");
89
+ }
90
+ function toolCallProviderOptions(provider, providerMetadata) {
91
+ if (provider === "google" || provider === "vertex") {
92
+ return providerMetadata ? { ...providerMetadata } : void 0;
93
+ }
94
+ if (provider !== "dexto-nova") return void 0;
95
+ const details = readOpenRouterReasoningDetails(providerMetadata);
96
+ return details.length === 0 ? void 0 : { openrouter: { reasoning_details: details } };
97
+ }
75
98
  class StreamProcessor {
76
99
  /**
77
100
  * @param contextManager Context manager for message persistence
@@ -258,13 +281,17 @@ class StreamProcessor {
258
281
  lastDeltaReceivedAtMs = lastReasoningDeltaReceivedAtMs;
259
282
  setStreamAttribute("last_delta_received_ms", lastDeltaReceivedAtMs);
260
283
  setStreamAttribute("last_delta_kind", "reasoning");
284
+ const text = isEncryptedReasoningPlaceholder(
285
+ event.text,
286
+ event.providerMetadata
287
+ ) ? "" : event.text;
261
288
  const reasoning = blockSeparator(
262
289
  this.lastReasoningBlockId,
263
290
  event.id,
264
291
  this.reasoningText,
265
- event.text
266
- ) + event.text;
267
- if (event.text !== "") this.lastReasoningBlockId = event.id;
292
+ text
293
+ ) + text;
294
+ if (text !== "") this.lastReasoningBlockId = event.id;
268
295
  this.reasoningText += reasoning;
269
296
  if (event.providerMetadata) {
270
297
  this.mergeReasoningMetadata(event.providerMetadata);
@@ -302,12 +329,11 @@ class StreamProcessor {
302
329
  arguments: JSON.stringify(event.input)
303
330
  }
304
331
  };
305
- const shouldPersistProviderMetadata = this.config.provider === "google" || this.config.provider === "vertex";
306
- if (shouldPersistProviderMetadata && event.providerMetadata) {
307
- toolCall.providerOptions = {
308
- ...event.providerMetadata
309
- };
310
- }
332
+ const providerOptions = toolCallProviderOptions(
333
+ this.config.provider,
334
+ event.providerMetadata
335
+ );
336
+ if (providerOptions) toolCall.providerOptions = providerOptions;
311
337
  await this.contextManager.addToolCall(this.assistantMessageId, toolCall);
312
338
  this.modelToolCalls.push({
313
339
  toolCallId: event.toolCallId,
@@ -673,7 +699,6 @@ class StreamProcessor {
673
699
  this.reasoningMetadata = providerMetadata;
674
700
  return;
675
701
  }
676
- const isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
677
702
  const previous = this.reasoningMetadata;
678
703
  const merged = { ...previous, ...providerMetadata };
679
704
  const previousOpenRouter = previous["openrouter"];
@@ -1 +1 @@
1
- {"version":3,"file":"stream-processor.d.ts","sourceRoot":"","sources":["../../../src/llm/executor/stream-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,IAAI,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAmB,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAKvD,OAAO,KAAK,EAAE,WAAW,EAAoB,gBAAgB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AW,KAAK,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,GACjF,OAAO,CAAC,qBAAqB,CAAC;YASnB,aAAa;IA6jB3B,OAAO,CAAC,kCAAkC;IAoB1C,OAAO,CAAC,cAAc;IA4CtB,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,eAAe;YA8BT,gCAAgC;IA+B9C,OAAO,CAAC,sBAAsB;YAqChB,eAAe;YA4Bf,sBAAsB;IAMpC;;;;OAIG;YACW,2BAA2B;IAQzC;;OAEG;YACW,wBAAwB;YAQxB,yBAAyB;CAuC1C"}
@@ -49,6 +49,29 @@ function blockSeparator(previousBlockId, blockId, accumulated, delta) {
49
49
  if (accumulated.endsWith("\n\n")) return "";
50
50
  return accumulated.endsWith("\n") ? "\n" : "\n\n";
51
51
  }
52
+ function isRecord(value) {
53
+ return typeof value === "object" && value !== null && !Array.isArray(value);
54
+ }
55
+ function readOpenRouterReasoningDetails(providerMetadata) {
56
+ if (!isRecord(providerMetadata)) return [];
57
+ const openRouter = providerMetadata["openrouter"];
58
+ if (!isRecord(openRouter)) return [];
59
+ const details = openRouter["reasoning_details"];
60
+ return Array.isArray(details) ? details : [];
61
+ }
62
+ function isEncryptedReasoningPlaceholder(text, providerMetadata) {
63
+ if (text !== "[REDACTED]") return false;
64
+ const details = readOpenRouterReasoningDetails(providerMetadata);
65
+ return details.length > 0 && details.every((detail) => isRecord(detail) && detail["type"] === "reasoning.encrypted");
66
+ }
67
+ function toolCallProviderOptions(provider, providerMetadata) {
68
+ if (provider === "google" || provider === "vertex") {
69
+ return providerMetadata ? { ...providerMetadata } : void 0;
70
+ }
71
+ if (provider !== "dexto-nova") return void 0;
72
+ const details = readOpenRouterReasoningDetails(providerMetadata);
73
+ return details.length === 0 ? void 0 : { openrouter: { reasoning_details: details } };
74
+ }
52
75
  class StreamProcessor {
53
76
  /**
54
77
  * @param contextManager Context manager for message persistence
@@ -235,13 +258,17 @@ class StreamProcessor {
235
258
  lastDeltaReceivedAtMs = lastReasoningDeltaReceivedAtMs;
236
259
  setStreamAttribute("last_delta_received_ms", lastDeltaReceivedAtMs);
237
260
  setStreamAttribute("last_delta_kind", "reasoning");
261
+ const text = isEncryptedReasoningPlaceholder(
262
+ event.text,
263
+ event.providerMetadata
264
+ ) ? "" : event.text;
238
265
  const reasoning = blockSeparator(
239
266
  this.lastReasoningBlockId,
240
267
  event.id,
241
268
  this.reasoningText,
242
- event.text
243
- ) + event.text;
244
- if (event.text !== "") this.lastReasoningBlockId = event.id;
269
+ text
270
+ ) + text;
271
+ if (text !== "") this.lastReasoningBlockId = event.id;
245
272
  this.reasoningText += reasoning;
246
273
  if (event.providerMetadata) {
247
274
  this.mergeReasoningMetadata(event.providerMetadata);
@@ -279,12 +306,11 @@ class StreamProcessor {
279
306
  arguments: JSON.stringify(event.input)
280
307
  }
281
308
  };
282
- const shouldPersistProviderMetadata = this.config.provider === "google" || this.config.provider === "vertex";
283
- if (shouldPersistProviderMetadata && event.providerMetadata) {
284
- toolCall.providerOptions = {
285
- ...event.providerMetadata
286
- };
287
- }
309
+ const providerOptions = toolCallProviderOptions(
310
+ this.config.provider,
311
+ event.providerMetadata
312
+ );
313
+ if (providerOptions) toolCall.providerOptions = providerOptions;
288
314
  await this.contextManager.addToolCall(this.assistantMessageId, toolCall);
289
315
  this.modelToolCalls.push({
290
316
  toolCallId: event.toolCallId,
@@ -650,7 +676,6 @@ class StreamProcessor {
650
676
  this.reasoningMetadata = providerMetadata;
651
677
  return;
652
678
  }
653
- const isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
654
679
  const previous = this.reasoningMetadata;
655
680
  const merged = { ...previous, ...providerMetadata };
656
681
  const previousOpenRouter = previous["openrouter"];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dexto/core",
3
- "version": "1.19.3",
3
+ "version": "1.19.4",
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.19.3"
177
+ "@dexto/llm": "1.19.4"
178
178
  },
179
179
  "devDependencies": {
180
180
  "@opentelemetry/context-async-hooks": "^2.12.0",