@tangle-network/agent-app 0.60.134 → 0.60.136

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 (33) hide show
  1. package/dist/assistant/index.js +5 -5
  2. package/dist/chat-react/index.js +3 -3
  3. package/dist/chat-routes/index.js +17 -7
  4. package/dist/chat-routes/index.js.map +1 -1
  5. package/dist/chat-routes/wire.d.ts +2 -0
  6. package/dist/chat-store/index.js +2 -2
  7. package/dist/{chunk-XZ4M2ZPO.js → chunk-2ZGB4V7I.js} +54 -16
  8. package/dist/chunk-2ZGB4V7I.js.map +1 -0
  9. package/dist/{chunk-JEM4BKR4.js → chunk-JTBPQEGM.js} +3 -3
  10. package/dist/{chunk-2GP6JOWE.js → chunk-N5M7YT6P.js} +3 -3
  11. package/dist/{chunk-ZBPOWSYN.js → chunk-NFAOHX4Z.js} +2 -2
  12. package/dist/{chunk-NNNAC3DV.js → chunk-WAMJU3G4.js} +2 -2
  13. package/dist/{chunk-D52LB6UQ.js → chunk-WTC6AOPL.js} +2 -2
  14. package/dist/{chunk-2NHJNINW.js → chunk-YHRWZZJN.js} +1 -1
  15. package/dist/chunk-YHRWZZJN.js.map +1 -0
  16. package/dist/{chunk-VXWEJ7F2.js → chunk-YR6TZ777.js} +2 -2
  17. package/dist/public-consultation/index.js +3 -3
  18. package/dist/runtime/index.js +2 -2
  19. package/dist/runtime/router-turn.d.ts +22 -0
  20. package/dist/runtime/router-turn.js +1 -1
  21. package/dist/web-react/index.js +5 -5
  22. package/dist/workspace-export/index.js +11 -2
  23. package/dist/workspace-export/index.js.map +1 -1
  24. package/dist/workspace-export/types.d.ts +2 -0
  25. package/package.json +1 -1
  26. package/dist/chunk-2NHJNINW.js.map +0 -1
  27. package/dist/chunk-XZ4M2ZPO.js.map +0 -1
  28. /package/dist/{chunk-JEM4BKR4.js.map → chunk-JTBPQEGM.js.map} +0 -0
  29. /package/dist/{chunk-2GP6JOWE.js.map → chunk-N5M7YT6P.js.map} +0 -0
  30. /package/dist/{chunk-ZBPOWSYN.js.map → chunk-NFAOHX4Z.js.map} +0 -0
  31. /package/dist/{chunk-NNNAC3DV.js.map → chunk-WAMJU3G4.js.map} +0 -0
  32. /package/dist/{chunk-D52LB6UQ.js.map → chunk-WTC6AOPL.js.map} +0 -0
  33. /package/dist/{chunk-VXWEJ7F2.js.map → chunk-YR6TZ777.js.map} +0 -0
@@ -2,7 +2,7 @@ import {
2
2
  ProtectedModelSettlementError,
3
3
  createRouterProtectedModelPort,
4
4
  runProtectedRouterTurn
5
- } from "../chunk-ZBPOWSYN.js";
5
+ } from "../chunk-NFAOHX4Z.js";
6
6
  import {
7
7
  DURABLE_HOP_BUDGET_MS,
8
8
  asksForLanguage,
@@ -21,7 +21,7 @@ import {
21
21
  turnKnowledgeInstructions,
22
22
  workspaceKnowledgeForTurn,
23
23
  workspaceTurnCheckpoints
24
- } from "../chunk-XZ4M2ZPO.js";
24
+ } from "../chunk-2ZGB4V7I.js";
25
25
  import {
26
26
  DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
27
27
  DEFAULT_TANGLE_ROUTER_BASE_URL,
@@ -56,6 +56,11 @@ export type RouterTurnEvent = {
56
56
  type: 'text';
57
57
  segment: number;
58
58
  delta: string;
59
+ }
60
+ /** Hidden reasoning the model streamed (`reasoning_content` / `thinking`), for a thinking view. Never part of the answer. */
61
+ | {
62
+ type: 'reasoning';
63
+ delta: string;
59
64
  } | {
60
65
  type: 'tool';
61
66
  callId: string;
@@ -96,6 +101,9 @@ export interface RouterTurnFailure {
96
101
  code: string;
97
102
  status?: number;
98
103
  message: string;
104
+ /** The model service's own error text, at most 200 characters (e.g. `key_budget_exhausted`), so an app can
105
+ * tell a spend cap from a missing balance. Never a credential. */
106
+ detail?: string;
99
107
  }
100
108
  export interface RouterTurnOutcome {
101
109
  /** Every text segment the model wrote, joined by blank lines. */
@@ -222,6 +230,20 @@ export interface RouterTurnOptions {
222
230
  * with `placement` and failure `placement_sandbox`, so the app runs it there instead.
223
231
  */
224
232
  placement?: Omit<RouterTurnPlacementInput, 'toolNames'>;
233
+ temperature?: number;
234
+ /** Models tried in order when a model call fails before any word or tool, or answers blank. Without it,
235
+ * that safe repeat uses `model` again. `repeat: false` turns both off. */
236
+ fallbackModels?: readonly string[];
237
+ /** Resend one model request that answered 408, 425, 429 or 5xx, or failed to connect, before its stream
238
+ * began, with exponential backoff (a `retry-after` up to 8 s is honoured). `attempts` counts the first
239
+ * send (default 1). `timeoutMs` bounds each attempt, stream included. */
240
+ retry?: {
241
+ attempts?: number;
242
+ timeoutMs?: number;
243
+ baseDelayMs?: number;
244
+ };
245
+ /** Characters of one tool result the model reads when no `renderToolResult` is given. Default 12 000. */
246
+ toolResultLimit?: number;
225
247
  }
226
248
  /** OpenAI-compatible function names allow only `[A-Za-z0-9_-]{1,64}`; app tool names often use dots. */
227
249
  export declare function routerFunctionName(name: string): string;
@@ -11,7 +11,7 @@ import {
11
11
  turnKnowledgeInstructions,
12
12
  workspaceKnowledgeForTurn,
13
13
  workspaceTurnCheckpoints
14
- } from "../chunk-XZ4M2ZPO.js";
14
+ } from "../chunk-2ZGB4V7I.js";
15
15
  import "../chunk-D6UJEOZQ.js";
16
16
  import "../chunk-AMUXRAUO.js";
17
17
  export {
@@ -138,7 +138,7 @@ import {
138
138
  withoutRecordGridCreated,
139
139
  withoutRecordGridRemoved,
140
140
  withoutRecordGridUpdate
141
- } from "../chunk-JEM4BKR4.js";
141
+ } from "../chunk-JTBPQEGM.js";
142
142
  import {
143
143
  SessionHistoryPanel,
144
144
  formatSessionTimestamp,
@@ -192,7 +192,7 @@ import {
192
192
  preloadWhenIdle,
193
193
  useComposerAttachments,
194
194
  useDictation
195
- } from "../chunk-NNNAC3DV.js";
195
+ } from "../chunk-WAMJU3G4.js";
196
196
  import "../chunk-L7MB2LLM.js";
197
197
  import "../chunk-SJWIZT7B.js";
198
198
  import {
@@ -231,7 +231,7 @@ import "../chunk-LSUELMHY.js";
231
231
  import "../chunk-FQYAJYPW.js";
232
232
  import {
233
233
  ATTACHMENT_ACCEPT
234
- } from "../chunk-D52LB6UQ.js";
234
+ } from "../chunk-WTC6AOPL.js";
235
235
  import "../chunk-WVESWAJJ.js";
236
236
  import "../chunk-B7CL7ENS.js";
237
237
  import "../chunk-PV33JZKV.js";
@@ -243,7 +243,7 @@ import {
243
243
  isChatAttachmentPart,
244
244
  mentionInputToPart,
245
245
  mentionPartsFromMessageParts
246
- } from "../chunk-VXWEJ7F2.js";
246
+ } from "../chunk-YR6TZ777.js";
247
247
  import "../chunk-ZVEEWGDK.js";
248
248
  import {
249
249
  DISPATCH_MAX_MEDIA_PARTS,
@@ -267,7 +267,7 @@ import {
267
267
  mediaTypeForMentionPath,
268
268
  mentionKindForPath,
269
269
  settleTurnResponse
270
- } from "../chunk-2NHJNINW.js";
270
+ } from "../chunk-YHRWZZJN.js";
271
271
  import "../chunk-TXD5HXLE.js";
272
272
  import {
273
273
  attachmentPartKey
@@ -533,6 +533,7 @@ var LeaseLost = class extends Error {
533
533
  var ExportRetryLater = class extends Error {
534
534
  retryLater = true;
535
535
  };
536
+ var DEFER_MS = 3e4;
536
537
  var MAX_DEFERRALS = 20;
537
538
  function isRetryLater(err) {
538
539
  return typeof err === "object" && err !== null && err.retryLater === true;
@@ -979,10 +980,11 @@ function createExportEngine(options) {
979
980
  save().catch(() => {
980
981
  });
981
982
  }, HEARTBEAT_MS);
982
- const plan = await options.plan({ workspaceId });
983
+ const pending = job.units.flatMap((unit, index) => unit.status === "pending" && !(unit.retryAt && unit.retryAt > now()) ? [{ unit, index }] : []);
984
+ const finishing = job.units.every((u) => u.status === "done" || u.status === "empty");
985
+ const plan = pending.length || finishing ? await options.plan({ workspaceId }) : { sources: [] };
983
986
  const scanner = createSecretScanner({ knownSecrets: await options.knownSecrets?.({ workspaceId }) ?? [] });
984
987
  const sources = new Map(plan.sources.map((s) => [s.name, s]));
985
- const pending = job.units.flatMap((unit, index) => unit.status === "pending" ? [{ unit, index }] : []);
986
988
  let next = 0;
987
989
  while (next < pending.length) {
988
990
  if (now() > deadline) break;
@@ -1012,11 +1014,13 @@ function createExportEngine(options) {
1012
1014
  }
1013
1015
  await runUnit(job, unit2, index, source, scanner, deadline);
1014
1016
  unit2.error = void 0;
1017
+ unit2.retryAt = void 0;
1015
1018
  return false;
1016
1019
  } catch (err) {
1017
1020
  unit2.error = errorText(scanner, err);
1018
1021
  if (isRetryLater(err) && (unit2.deferrals ?? 0) < MAX_DEFERRALS) {
1019
1022
  unit2.deferrals = (unit2.deferrals ?? 0) + 1;
1023
+ unit2.retryAt = now() + DEFER_MS;
1020
1024
  unit2.attempts -= 1;
1021
1025
  if (unit2.cursor === void 0) unit2.entries = [];
1022
1026
  return "deferred";
@@ -1506,6 +1510,10 @@ function kvFiles(args) {
1506
1510
  // src/workspace-export/sandbox.ts
1507
1511
  var GONE = /* @__PURE__ */ new Set(["deleted", "expired", "failed"]);
1508
1512
  var DEFAULT_SANDBOX_EXCLUDE = ["node_modules", ".sidecar"];
1513
+ function isServerFailure(err) {
1514
+ const status = err?.status;
1515
+ return typeof status === "number" && status >= 500;
1516
+ }
1509
1517
  function isLifecycleBusy(err) {
1510
1518
  const e = err;
1511
1519
  return typeof e === "object" && e !== null && e.status === 409 && e.code === "SANDBOX_LIFECYCLE_IN_PROGRESS";
@@ -1519,6 +1527,7 @@ async function openRunning(getBox, timeoutMs) {
1519
1527
  if (box.status !== "running" || wasStopped) await box.waitFor("running", { timeoutMs });
1520
1528
  } catch (err) {
1521
1529
  if (isLifecycleBusy(err)) throw new ExportRetryLater("the sandbox is busy with another operation; retrying shortly");
1530
+ if (isServerFailure(err)) throw new ExportRetryLater("the sandbox could not be started; retrying shortly");
1522
1531
  throw err;
1523
1532
  }
1524
1533
  const restore = async () => {