@tangle-network/agent-app 0.60.131 → 0.60.133

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 (58) hide show
  1. package/dist/app-auth/index.js +3 -3
  2. package/dist/assistant/index.js +10 -10
  3. package/dist/billing/index.js +1 -1
  4. package/dist/chat-react/index.js +2 -2
  5. package/dist/chat-routes/index.js +11 -11
  6. package/dist/chat-routes/turn-routes.d.ts +6 -2
  7. package/dist/chat-store/index.js +3 -3
  8. package/dist/{chunk-JZUSVGRJ.js → chunk-2GP6JOWE.js} +15 -2
  9. package/dist/chunk-2GP6JOWE.js.map +1 -0
  10. package/dist/chunk-4JUEOVQS.js +134 -0
  11. package/dist/chunk-4JUEOVQS.js.map +1 -0
  12. package/dist/{chunk-5S5ANZBS.js → chunk-HZGKPWVA.js} +6 -6
  13. package/dist/{chunk-NRG2YHGY.js → chunk-IMTU5LCF.js} +1 -1
  14. package/dist/{chunk-XPP653RG.js → chunk-JEM4BKR4.js} +10 -10
  15. package/dist/{chunk-JGLK5RDK.js → chunk-JIXM57JM.js} +28 -14
  16. package/dist/{chunk-JGLK5RDK.js.map → chunk-JIXM57JM.js.map} +1 -1
  17. package/dist/{chunk-4DEI6QC5.js → chunk-NNNAC3DV.js} +4 -4
  18. package/dist/{chunk-GU7OZFU7.js → chunk-VXWEJ7F2.js} +4 -4
  19. package/dist/{chunk-ZGUXI5SI.js → chunk-XNKLQG26.js} +5 -5
  20. package/dist/{chunk-LJDMPYGA.js → chunk-YJHE73TF.js} +8 -2
  21. package/dist/chunk-YJHE73TF.js.map +1 -0
  22. package/dist/design-canvas-react/index.js +4 -4
  23. package/dist/design-canvas-react/lazy.js +1 -1
  24. package/dist/journeys/index.js +11 -5
  25. package/dist/journeys/index.js.map +1 -1
  26. package/dist/journeys/send.d.ts +10 -0
  27. package/dist/platform/delegated-keys.d.ts +226 -0
  28. package/dist/platform/index.d.ts +1 -0
  29. package/dist/platform/index.js +315 -0
  30. package/dist/platform/index.js.map +1 -1
  31. package/dist/preset-cloudflare/index.js +1 -1
  32. package/dist/public-consultation/index.d.ts +1 -1
  33. package/dist/public-consultation/index.js +5 -5
  34. package/dist/rollout/cli.d.ts +25 -0
  35. package/dist/rollout/cli.js +121 -0
  36. package/dist/rollout/cli.js.map +1 -0
  37. package/dist/rollout/d1.d.ts +62 -0
  38. package/dist/rollout/d1.js +89 -0
  39. package/dist/rollout/d1.js.map +1 -0
  40. package/dist/rollout/index.d.ts +116 -0
  41. package/dist/rollout/index.js +19 -0
  42. package/dist/rollout/index.js.map +1 -0
  43. package/dist/sandbox/index.js +1 -1
  44. package/dist/sandbox/sandbox-exec-tool.d.ts +5 -3
  45. package/dist/sandbox/sandbox-run-tool.d.ts +12 -5
  46. package/dist/stream/index.js +2 -2
  47. package/dist/studio-react/index.js +2 -2
  48. package/dist/web-react/index.js +16 -16
  49. package/dist/workspace-react/index.js +5 -5
  50. package/package.json +12 -1
  51. package/dist/chunk-JZUSVGRJ.js.map +0 -1
  52. package/dist/chunk-LJDMPYGA.js.map +0 -1
  53. /package/dist/{chunk-5S5ANZBS.js.map → chunk-HZGKPWVA.js.map} +0 -0
  54. /package/dist/{chunk-NRG2YHGY.js.map → chunk-IMTU5LCF.js.map} +0 -0
  55. /package/dist/{chunk-XPP653RG.js.map → chunk-JEM4BKR4.js.map} +0 -0
  56. /package/dist/{chunk-4DEI6QC5.js.map → chunk-NNNAC3DV.js.map} +0 -0
  57. /package/dist/{chunk-GU7OZFU7.js.map → chunk-VXWEJ7F2.js.map} +0 -0
  58. /package/dist/{chunk-ZGUXI5SI.js.map → chunk-XNKLQG26.js.map} +0 -0
@@ -0,0 +1,134 @@
1
+ // src/rollout/index.ts
2
+ function parseRolloutList(value) {
3
+ const ids = /* @__PURE__ */ new Set();
4
+ const excluded = /* @__PURE__ */ new Set();
5
+ const newSince = [];
6
+ let all = false;
7
+ for (const raw of (value ?? "").split(",")) {
8
+ const entry = raw.trim();
9
+ if (!entry) continue;
10
+ if (entry === "*") all = true;
11
+ else if (entry.startsWith("!")) excluded.add(entry.slice(1).trim());
12
+ else if (entry.startsWith("new-since:")) {
13
+ const at = Date.parse(entry.slice("new-since:".length));
14
+ if (!Number.isFinite(at)) throw new Error(`rollout list entry ${entry} is not a valid time`);
15
+ newSince.push(at);
16
+ } else ids.add(entry);
17
+ }
18
+ return { all, ids, excluded, newSince };
19
+ }
20
+ function rolloutAdmits(value, workspace) {
21
+ const list = typeof value === "string" ? parseRolloutList(value) : value;
22
+ if (list.excluded.has(workspace.id)) return false;
23
+ if (list.all || list.ids.has(workspace.id)) return true;
24
+ return workspace.createdAt !== void 0 && list.newSince.some((at) => workspace.createdAt >= at);
25
+ }
26
+ function rolloutWidens(fromValue, toValue) {
27
+ const from = parseRolloutList(fromValue);
28
+ const to = parseRolloutList(toValue);
29
+ if (to.all) {
30
+ if (!from.all) return true;
31
+ return [...from.excluded].some((id) => !to.excluded.has(id));
32
+ }
33
+ if ([...to.ids].some((id) => !rolloutAdmits(from, { id }))) return true;
34
+ const earliest = (list) => list.newSince.length ? Math.min(...list.newSince) : Infinity;
35
+ if (to.newSince.length && !from.all && earliest(to) < earliest(from)) return true;
36
+ return false;
37
+ }
38
+ function normalizeRolloutValue(value) {
39
+ return value.split(",").map((entry) => entry.trim()).filter(Boolean).sort().join(",");
40
+ }
41
+ function stageOf(plan, value) {
42
+ const key = normalizeRolloutValue(value);
43
+ return plan.stages.find((stage) => normalizeRolloutValue(stage.value) === key) ?? null;
44
+ }
45
+ function killLineBreaches(stage, measured) {
46
+ if (!measured) return [`stage ${stage.name} has no measurement`];
47
+ if (measured.stage !== stage.name) return [`measurement is for stage ${measured.stage}, not ${stage.name}`];
48
+ const reasons = [];
49
+ if (!(measured.samples >= stage.minSamples)) {
50
+ reasons.push(`stage ${stage.name} has ${measured.samples} measured turns, under its minimum of ${stage.minSamples}`);
51
+ }
52
+ for (const [metric, line] of Object.entries(stage.kill)) {
53
+ const value = measured.metrics[metric];
54
+ if (typeof value !== "number" || !Number.isFinite(value)) {
55
+ reasons.push(`${metric} was not measured`);
56
+ continue;
57
+ }
58
+ if (line.max !== void 0 && value > line.max) reasons.push(`${metric} ${value} over kill line ${line.max}`);
59
+ if (line.min !== void 0 && value < line.min) reasons.push(`${metric} ${value} under kill line ${line.min}`);
60
+ }
61
+ return reasons;
62
+ }
63
+ function validateRolloutPlan(plan) {
64
+ if (!plan.name || !plan.variable) throw new Error("a rollout plan needs a name and a variable");
65
+ if (!plan.stages.length) throw new Error(`rollout ${plan.name} declares no stages`);
66
+ const names = /* @__PURE__ */ new Set();
67
+ const values = /* @__PURE__ */ new Set();
68
+ for (const stage of plan.stages) {
69
+ if (names.has(stage.name)) throw new Error(`rollout ${plan.name} repeats stage ${stage.name}`);
70
+ names.add(stage.name);
71
+ const value = normalizeRolloutValue(stage.value);
72
+ if (values.has(value)) throw new Error(`rollout ${plan.name} gives two stages the value ${stage.value}`);
73
+ values.add(value);
74
+ parseRolloutList(stage.value);
75
+ if (!Number.isInteger(stage.minSamples) || stage.minSamples < 1) {
76
+ throw new Error(`stage ${stage.name} needs minSamples of at least 1`);
77
+ }
78
+ if (!Object.keys(stage.kill).length) throw new Error(`stage ${stage.name} declares no kill lines`);
79
+ }
80
+ for (let index = 1; index < plan.stages.length; index++) {
81
+ const previous = plan.stages[index - 1];
82
+ const stage = plan.stages[index];
83
+ if (!rolloutWidens(previous.value, stage.value)) {
84
+ throw new Error(`stage ${stage.name} does not widen stage ${previous.name}`);
85
+ }
86
+ }
87
+ }
88
+ async function decideRollout(input) {
89
+ const { plan, fromValue, toValue } = input;
90
+ validateRolloutPlan(plan);
91
+ const fromStage = stageOf(plan, fromValue);
92
+ const toStage = stageOf(plan, toValue);
93
+ const widens = rolloutWidens(fromValue, toValue);
94
+ const record = (reasons, measured2) => ({
95
+ rollout: plan.name,
96
+ variable: plan.variable,
97
+ from: { value: fromValue, stage: fromStage?.name ?? null },
98
+ to: { value: toValue, stage: toStage?.name ?? null },
99
+ widens,
100
+ decision: reasons.length ? "refused" : "allowed",
101
+ reasons,
102
+ measured: measured2,
103
+ at: (input.now?.() ?? /* @__PURE__ */ new Date()).toISOString()
104
+ });
105
+ if (!widens) return record([], null);
106
+ if (!toStage) return record([`${toValue} is not a declared stage of ${plan.name}`], null);
107
+ const target = plan.stages.indexOf(toStage);
108
+ if (!fromStage) {
109
+ const empty = !normalizeRolloutValue(fromValue);
110
+ return record(empty && target === 0 ? [] : [`the current value ${fromValue || "(empty)"} is not a declared stage of ${plan.name}`], null);
111
+ }
112
+ const current = plan.stages.indexOf(fromStage);
113
+ if (target > current + 1) {
114
+ return record([`${toStage.name} skips ${plan.stages.slice(current + 1, target).map((stage) => stage.name).join(", ")}`], null);
115
+ }
116
+ let measured;
117
+ try {
118
+ measured = await input.measure(fromStage);
119
+ } catch (error) {
120
+ return record([`measuring stage ${fromStage.name} failed: ${error instanceof Error ? error.message : String(error)}`], null);
121
+ }
122
+ return record(killLineBreaches(fromStage, measured), measured);
123
+ }
124
+
125
+ export {
126
+ parseRolloutList,
127
+ rolloutAdmits,
128
+ rolloutWidens,
129
+ normalizeRolloutValue,
130
+ killLineBreaches,
131
+ validateRolloutPlan,
132
+ decideRollout
133
+ };
134
+ //# sourceMappingURL=chunk-4JUEOVQS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/rollout/index.ts"],"sourcesContent":["/**\n * Rollout guard: a staged rollout widens only when the stage it leaves met\n * that stage's kill lines on measured production numbers.\n *\n * WHY. Hospitality's routed lane widened from two QA workspaces to `*` at a\n * first-words p50 of 3.54 s, past kill lines of 2.5 s and 3.0 s\n * (hospitality-agent #382, 2026-10-11). The numbers existed; nothing read them\n * before the list changed. This module is the one place that reads them.\n *\n * THE LIST. A rollout is one comma-separated value, usually a deploy variable\n * such as `HOSPITALITY_ROUTED_BUSINESS_IDS`: workspace ids, `*` for every\n * workspace, `!<id>` to keep one out whatever else matches, and\n * `new-since:<ISO time>` for workspaces created at or after that time.\n * {@link rolloutAdmits} is the reference reading of that grammar.\n *\n * THE RULE ({@link decideRollout}).\n * - A change that admits no workspace the current value did not (a narrowing,\n * a rollback, the same stage) is always allowed: a guard that can block a\n * rollback is worse than none.\n * - A widening must land on a declared stage, the next one after the current\n * value's stage, never past it.\n * - The stage being left must have at least `minSamples` measured turns and\n * every kill line met. A metric that was not measured fails its line.\n * - A refusal names each reason (`first_words_p50_ms 3540 over kill line 2500`).\n *\n * Every decision, allowed or refused, is returned as one record the caller\n * persists (the CLI appends it to a JSONL ledger and hands it to the\n * config's `record`).\n */\n\n/** A kill line: the measured value must stay at or under `max` and at or over `min`. */\nexport interface RolloutKillLine {\n max?: number\n min?: number\n}\n\nexport interface RolloutStage {\n /** Short name used in refusals and records, e.g. `qa`, `all-but-recenter`. */\n name: string\n /** The exact list value that defines this stage. */\n value: string\n /** Turns the stage must have served, measured, before the rollout may leave it. */\n minSamples: number\n /** Metric name → line. Metric names are the product's, e.g. `first_words_p50_ms`, `failure_rate`. */\n kill: Record<string, RolloutKillLine>\n}\n\nexport interface RolloutPlan {\n /** e.g. `hospitality-routed-chat`. */\n name: string\n /** The deploy variable that carries the list, e.g. `HOSPITALITY_ROUTED_BUSINESS_IDS`. */\n variable: string\n /** In widening order. */\n stages: RolloutStage[]\n}\n\n/** Production numbers for one stage, from the product's own instrument. */\nexport interface StageMeasurement {\n stage: string\n samples: number\n metrics: Record<string, number | null | undefined>\n /** Where the numbers came from (ledger, query, soak), for the record. */\n source?: string\n window?: { from: string; to: string }\n}\n\nexport interface RolloutDecision {\n rollout: string\n variable: string\n from: { value: string; stage: string | null }\n to: { value: string; stage: string | null }\n widens: boolean\n decision: 'allowed' | 'refused'\n /** Empty when allowed; each refusal reason otherwise. */\n reasons: string[]\n measured: StageMeasurement | null\n at: string\n}\n\nexport interface ParsedRolloutList {\n all: boolean\n ids: ReadonlySet<string>\n excluded: ReadonlySet<string>\n /** Epoch ms of each `new-since:` entry. */\n newSince: readonly number[]\n}\n\nexport function parseRolloutList(value: string | null | undefined): ParsedRolloutList {\n const ids = new Set<string>()\n const excluded = new Set<string>()\n const newSince: number[] = []\n let all = false\n for (const raw of (value ?? '').split(',')) {\n const entry = raw.trim()\n if (!entry) continue\n if (entry === '*') all = true\n else if (entry.startsWith('!')) excluded.add(entry.slice(1).trim())\n else if (entry.startsWith('new-since:')) {\n const at = Date.parse(entry.slice('new-since:'.length))\n if (!Number.isFinite(at)) throw new Error(`rollout list entry ${entry} is not a valid time`)\n newSince.push(at)\n } else ids.add(entry)\n }\n return { all, ids, excluded, newSince }\n}\n\n/** Whether a list admits one workspace. `createdAt` (epoch ms) is needed only for `new-since:` entries. */\nexport function rolloutAdmits(value: string | ParsedRolloutList, workspace: { id: string; createdAt?: number }): boolean {\n const list = typeof value === 'string' ? parseRolloutList(value) : value\n if (list.excluded.has(workspace.id)) return false\n if (list.all || list.ids.has(workspace.id)) return true\n return workspace.createdAt !== undefined && list.newSince.some(at => workspace.createdAt! >= at)\n}\n\n/**\n * Whether `to` may admit a workspace `from` does not. Conservative: a change it\n * cannot prove narrower counts as a widening.\n */\nexport function rolloutWidens(fromValue: string, toValue: string): boolean {\n const from = parseRolloutList(fromValue)\n const to = parseRolloutList(toValue)\n if (to.all) {\n if (!from.all) return true\n // Under `*` on both sides, only a dropped exclusion widens.\n return [...from.excluded].some(id => !to.excluded.has(id))\n }\n if ([...to.ids].some(id => !rolloutAdmits(from, { id }))) return true\n // An id `from` admitted only because it was listed, which `to` now excludes, narrows; nothing else here widens.\n const earliest = (list: ParsedRolloutList) => list.newSince.length ? Math.min(...list.newSince) : Infinity\n if (to.newSince.length && !from.all && earliest(to) < earliest(from)) return true\n return false\n}\n\n/** Canonical form for matching a value to a stage: entries trimmed and sorted. */\nexport function normalizeRolloutValue(value: string): string {\n return value.split(',').map(entry => entry.trim()).filter(Boolean).sort().join(',')\n}\n\nfunction stageOf(plan: RolloutPlan, value: string): RolloutStage | null {\n const key = normalizeRolloutValue(value)\n return plan.stages.find(stage => normalizeRolloutValue(stage.value) === key) ?? null\n}\n\n/** Each kill line the measurement misses, as a reason. Empty when every line holds. */\nexport function killLineBreaches(stage: RolloutStage, measured: StageMeasurement | null): string[] {\n if (!measured) return [`stage ${stage.name} has no measurement`]\n if (measured.stage !== stage.name) return [`measurement is for stage ${measured.stage}, not ${stage.name}`]\n const reasons: string[] = []\n if (!(measured.samples >= stage.minSamples)) {\n reasons.push(`stage ${stage.name} has ${measured.samples} measured turns, under its minimum of ${stage.minSamples}`)\n }\n for (const [metric, line] of Object.entries(stage.kill)) {\n const value = measured.metrics[metric]\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n reasons.push(`${metric} was not measured`)\n continue\n }\n if (line.max !== undefined && value > line.max) reasons.push(`${metric} ${value} over kill line ${line.max}`)\n if (line.min !== undefined && value < line.min) reasons.push(`${metric} ${value} under kill line ${line.min}`)\n }\n return reasons\n}\n\nexport function validateRolloutPlan(plan: RolloutPlan): void {\n if (!plan.name || !plan.variable) throw new Error('a rollout plan needs a name and a variable')\n if (!plan.stages.length) throw new Error(`rollout ${plan.name} declares no stages`)\n const names = new Set<string>()\n const values = new Set<string>()\n for (const stage of plan.stages) {\n if (names.has(stage.name)) throw new Error(`rollout ${plan.name} repeats stage ${stage.name}`)\n names.add(stage.name)\n const value = normalizeRolloutValue(stage.value)\n if (values.has(value)) throw new Error(`rollout ${plan.name} gives two stages the value ${stage.value}`)\n values.add(value)\n parseRolloutList(stage.value)\n if (!Number.isInteger(stage.minSamples) || stage.minSamples < 1) {\n throw new Error(`stage ${stage.name} needs minSamples of at least 1`)\n }\n if (!Object.keys(stage.kill).length) throw new Error(`stage ${stage.name} declares no kill lines`)\n }\n for (let index = 1; index < plan.stages.length; index++) {\n const previous = plan.stages[index - 1]!\n const stage = plan.stages[index]!\n if (!rolloutWidens(previous.value, stage.value)) {\n throw new Error(`stage ${stage.name} does not widen stage ${previous.name}`)\n }\n }\n}\n\n/**\n * Decide one change of the list. `measure` is called only for a widening, and\n * only for the stage being left.\n */\nexport async function decideRollout(input: {\n plan: RolloutPlan\n fromValue: string\n toValue: string\n measure(stage: RolloutStage): Promise<StageMeasurement | null>\n now?: () => Date\n}): Promise<RolloutDecision> {\n const { plan, fromValue, toValue } = input\n validateRolloutPlan(plan)\n const fromStage = stageOf(plan, fromValue)\n const toStage = stageOf(plan, toValue)\n const widens = rolloutWidens(fromValue, toValue)\n const record = (reasons: string[], measured: StageMeasurement | null): RolloutDecision => ({\n rollout: plan.name,\n variable: plan.variable,\n from: { value: fromValue, stage: fromStage?.name ?? null },\n to: { value: toValue, stage: toStage?.name ?? null },\n widens,\n decision: reasons.length ? 'refused' : 'allowed',\n reasons,\n measured,\n at: (input.now?.() ?? new Date()).toISOString(),\n })\n if (!widens) return record([], null)\n if (!toStage) return record([`${toValue} is not a declared stage of ${plan.name}`], null)\n const target = plan.stages.indexOf(toStage)\n // An empty list admits nobody, so the first stage is the only widening it may take without numbers.\n if (!fromStage) {\n const empty = !normalizeRolloutValue(fromValue)\n return record(empty && target === 0 ? [] : [`the current value ${fromValue || '(empty)'} is not a declared stage of ${plan.name}`], null)\n }\n const current = plan.stages.indexOf(fromStage)\n if (target > current + 1) {\n return record([`${toStage.name} skips ${plan.stages.slice(current + 1, target).map(stage => stage.name).join(', ')}`], null)\n }\n let measured: StageMeasurement | null\n try {\n measured = await input.measure(fromStage)\n } catch (error) {\n return record([`measuring stage ${fromStage.name} failed: ${error instanceof Error ? error.message : String(error)}`], null)\n }\n return record(killLineBreaches(fromStage, measured), measured)\n}\n"],"mappings":";AAuFO,SAAS,iBAAiB,OAAqD;AACpF,QAAM,MAAM,oBAAI,IAAY;AAC5B,QAAM,WAAW,oBAAI,IAAY;AACjC,QAAM,WAAqB,CAAC;AAC5B,MAAI,MAAM;AACV,aAAW,QAAQ,SAAS,IAAI,MAAM,GAAG,GAAG;AAC1C,UAAM,QAAQ,IAAI,KAAK;AACvB,QAAI,CAAC,MAAO;AACZ,QAAI,UAAU,IAAK,OAAM;AAAA,aAChB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WAAW,QAAQ,GAAG,QAAQ;AAC/D;","names":["measured"]}
@@ -2,16 +2,16 @@ import {
2
2
  ActionDialog,
3
3
  ActionDialogButton
4
4
  } from "./chunk-NTSZGBHZ.js";
5
- import {
6
- OVERLAY_SHADOW,
7
- PopoverSurface,
8
- usePopover
9
- } from "./chunk-GE7Y7ODP.js";
10
5
  import {
11
6
  UNTITLED_SESSION_LABEL,
12
7
  mergeSessionPages,
13
8
  sessionLabel
14
9
  } from "./chunk-SJWIZT7B.js";
10
+ import {
11
+ OVERLAY_SHADOW,
12
+ PopoverSurface,
13
+ usePopover
14
+ } from "./chunk-GE7Y7ODP.js";
15
15
 
16
16
  // src/web-react/session-history.tsx
17
17
  import {
@@ -745,4 +745,4 @@ export {
745
745
  formatSessionTimestamp,
746
746
  SessionHistoryPanel
747
747
  };
748
- //# sourceMappingURL=chunk-5S5ANZBS.js.map
748
+ //# sourceMappingURL=chunk-HZGKPWVA.js.map
@@ -11,4 +11,4 @@ export {
11
11
  DesignCanvasLazy,
12
12
  DesignCanvasChromeLazy
13
13
  };
14
- //# sourceMappingURL=chunk-NRG2YHGY.js.map
14
+ //# sourceMappingURL=chunk-IMTU5LCF.js.map
@@ -14,6 +14,10 @@ import {
14
14
  import {
15
15
  joinClasses
16
16
  } from "./chunk-L7MB2LLM.js";
17
+ import {
18
+ filterCommandPaletteItems,
19
+ groupCommandPaletteItems
20
+ } from "./chunk-SJWIZT7B.js";
17
21
  import {
18
22
  BrainGlyph,
19
23
  ChevronDown,
@@ -24,16 +28,12 @@ import {
24
28
  usePending,
25
29
  usePopover
26
30
  } from "./chunk-GE7Y7ODP.js";
27
- import {
28
- filterCommandPaletteItems,
29
- groupCommandPaletteItems
30
- } from "./chunk-SJWIZT7B.js";
31
31
  import {
32
32
  AsyncView
33
33
  } from "./chunk-LSUELMHY.js";
34
34
  import {
35
35
  attachmentPartsFromMessageParts
36
- } from "./chunk-GU7OZFU7.js";
36
+ } from "./chunk-VXWEJ7F2.js";
37
37
  import {
38
38
  TURN_INTENT_EVENT,
39
39
  TURN_PHASE_EVENT,
@@ -41,6 +41,10 @@ import {
41
41
  isTurnPhaseEvent,
42
42
  settleTurnResponse
43
43
  } from "./chunk-2NHJNINW.js";
44
+ import {
45
+ parsePlanSubmittedEvent,
46
+ persistedPartToPlan
47
+ } from "./chunk-LQYIBL3G.js";
44
48
  import {
45
49
  cancelStatusFor,
46
50
  fieldAcceptsFreeText,
@@ -51,10 +55,6 @@ import {
51
55
  persistedPartToInteraction,
52
56
  questionInteractionContentSignature
53
57
  } from "./chunk-6VQCFJWP.js";
54
- import {
55
- parsePlanSubmittedEvent,
56
- persistedPartToPlan
57
- } from "./chunk-LQYIBL3G.js";
58
58
 
59
59
  // src/web-react/index.tsx
60
60
  import { useEffect as useEffect14, useMemo as useMemo7, useRef as useRef12, useState as useState19, memo } from "react";
@@ -6804,4 +6804,4 @@ export {
6804
6804
  useThinkingSeconds,
6805
6805
  ChatMessages
6806
6806
  };
6807
- //# sourceMappingURL=chunk-XPP653RG.js.map
6807
+ //# sourceMappingURL=chunk-JEM4BKR4.js.map
@@ -425,7 +425,7 @@ var DEFAULT_TIMEOUT_MS = 5 * 6e4;
425
425
  var TASK_LIMIT = 2e4;
426
426
  var SANDBOX_RUN_DESCRIPTION = "Run work that needs a computer in this workspace's sandbox: executing code or scripts, reading or converting PDFs, spreadsheets and archives, filling forms with the installed toolkits, or editing many files. Describe the whole task and the result you need; the sandbox agent does it and returns its answer. Takes seconds to minutes, so use it only when the answer needs the computer.";
427
427
  function sandboxPromptRunner(shell, prompt = {}) {
428
- return (box, task, run) => runSandboxPrompt(shell, box, task, { ...prompt, ...run, disallowQuestions: true });
428
+ return (box, task, { signal, timeoutMs }) => runSandboxPrompt(shell, box, task, { ...prompt, signal, timeoutMs, disallowQuestions: true });
429
429
  }
430
430
  function createSandboxRunTool(options) {
431
431
  const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
@@ -444,7 +444,13 @@ function createSandboxRunTool(options) {
444
444
  required: ["task"],
445
445
  additionalProperties: false
446
446
  },
447
- async run(args) {
447
+ async run(args, context) {
448
+ const emit = (kind, data) => {
449
+ try {
450
+ context?.emit(kind, data);
451
+ } catch {
452
+ }
453
+ };
448
454
  const task = typeof args.task === "string" ? args.task.trim() : "";
449
455
  if (!task || task.length > TASK_LIMIT) {
450
456
  return fail2("invalid_arguments", `task must be 1 to ${TASK_LIMIT} characters`);
@@ -453,22 +459,21 @@ function createSandboxRunTool(options) {
453
459
  const signal = AbortSignal.any([AbortSignal.timeout(timeoutMs), ...options.signal ? [options.signal] : []]);
454
460
  if (options.warm) await options.warm.leases.turn(options.warm.key).catch(() => {
455
461
  });
462
+ const capped = (work) => Promise.race([work, new Promise((_, reject) => {
463
+ if (signal.aborted) reject(signal.reason);
464
+ signal.addEventListener("abort", () => reject(signal.reason), { once: true });
465
+ })]);
456
466
  let box;
457
467
  try {
458
- box = await options.box(signal);
468
+ box = await capped(options.box(signal));
459
469
  } catch (error) {
460
470
  if (error instanceof SandboxRunError) return fail2(error.code, error.message, error.cause);
461
471
  return fail2("sandbox_unavailable", "The sandbox for this workspace could not start, so this work was not done.", error);
462
472
  }
473
+ emit("box_ready", { ms: Date.now() - started });
463
474
  let answer;
464
475
  try {
465
- answer = await Promise.race([
466
- runTask(box, task, { signal, timeoutMs: Math.max(1, timeoutMs - (Date.now() - started)) }),
467
- new Promise((_, reject) => {
468
- if (signal.aborted) reject(signal.reason);
469
- signal.addEventListener("abort", () => reject(signal.reason), { once: true });
470
- })
471
- ]);
476
+ answer = await capped(runTask(box, task, { signal, timeoutMs: Math.max(1, timeoutMs - (Date.now() - started)), emit }));
472
477
  } catch (error) {
473
478
  const timedOut = signal.aborted && !options.signal?.aborted;
474
479
  return fail2("sandbox_failed", timedOut ? `The sandbox did not finish within ${Math.round(timeoutMs / 1e3)} s, so this work was not done.` : "The sandbox run failed, so this work was not done.", error);
@@ -481,7 +486,7 @@ function createSandboxRunTool(options) {
481
486
 
482
487
  // src/sandbox/sandbox-exec-tool.ts
483
488
  var DEFAULT_TIMEOUT_MS2 = 2 * 6e4;
484
- var DEFAULT_OUTPUT_CHARS = 2e4;
489
+ var DEFAULT_OUTPUT_CHARS = 4e3;
485
490
  var COMMAND_LIMIT = 1e4;
486
491
  var SANDBOX_EXEC_DESCRIPTION = "Run one shell command in this workspace's sandbox and get its exit code, stdout and stderr. Use it for the installed toolkits and scripts, file conversion and checks. A non-zero exit code is a result to read and fix, not a reason to stop.";
487
492
  function tail(text, limit) {
@@ -535,7 +540,13 @@ function createSandboxExecTool(options) {
535
540
  required: ["command"],
536
541
  additionalProperties: false
537
542
  },
538
- async run(args) {
543
+ async run(args, context) {
544
+ const emit = (kind, data) => {
545
+ try {
546
+ context?.emit(kind, data);
547
+ } catch {
548
+ }
549
+ };
539
550
  const command = typeof args.command === "string" ? args.command.trim() : "";
540
551
  if (!command || command.length > COMMAND_LIMIT) return fail2("invalid_arguments", `command must be 1 to ${COMMAND_LIMIT} characters`);
541
552
  const refusal = options.allow?.(command);
@@ -546,15 +557,18 @@ function createSandboxExecTool(options) {
546
557
  if (options.warm) await options.warm.leases.turn(options.warm.key).catch(() => {
547
558
  });
548
559
  let box;
560
+ const starting = place(signal);
549
561
  try {
550
- box = await raceAbort(place(signal), signal);
562
+ box = await raceAbort(starting, signal);
551
563
  } catch (error) {
564
+ if (ready === starting) ready = null;
552
565
  if (error instanceof SandboxRunError) {
553
566
  options.onFailure?.(error);
554
567
  throw error;
555
568
  }
556
569
  return fail2("sandbox_unavailable", "The sandbox did not start in time, so the command did not run.", error);
557
570
  }
571
+ emit("box_ready", { ms: Date.now() - started });
558
572
  let result;
559
573
  try {
560
574
  result = await raceAbort(box.exec(command, {
@@ -3305,4 +3319,4 @@ export {
3305
3319
  isTerminalPromptEvent,
3306
3320
  detectInteractiveQuestion
3307
3321
  };
3308
- //# sourceMappingURL=chunk-JGLK5RDK.js.map
3322
+ //# sourceMappingURL=chunk-JIXM57JM.js.map