orion-super-agent-dev 0.1.25 → 0.1.26

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.
Binary file
Binary file
Binary file
Binary file
package/out/main.js CHANGED
@@ -25969,9 +25969,9 @@ var require_semver = __commonJS({
25969
25969
  } else {
25970
25970
  this.prerelease = m2[4].split(".").map(function(id) {
25971
25971
  if (/^[0-9]+$/.test(id)) {
25972
- var num = +id;
25973
- if (num >= 0 && num < MAX_SAFE_INTEGER) {
25974
- return num;
25972
+ var num2 = +id;
25973
+ if (num2 >= 0 && num2 < MAX_SAFE_INTEGER) {
25974
+ return num2;
25975
25975
  }
25976
25976
  }
25977
25977
  return id;
@@ -29600,11 +29600,11 @@ var require_duetRouterModel = __commonJS({
29600
29600
  const dim = r2.dim;
29601
29601
  if (typeof dim !== "number" || !Number.isInteger(dim) || dim <= 0)
29602
29602
  return null;
29603
- const num = (v2) => typeof v2 === "number" && Number.isFinite(v2) ? v2 : null;
29604
- const temperature = num(r2.temperature);
29605
- const threshold = num(r2.threshold);
29606
- const headChars = num(r2.head_chars);
29607
- const maxTokens = num(r2.max_tokens);
29603
+ const num2 = (v2) => typeof v2 === "number" && Number.isFinite(v2) ? v2 : null;
29604
+ const temperature = num2(r2.temperature);
29605
+ const threshold = num2(r2.threshold);
29606
+ const headChars = num2(r2.head_chars);
29607
+ const maxTokens = num2(r2.max_tokens);
29608
29608
  if (temperature === null || temperature <= 0)
29609
29609
  return null;
29610
29610
  if (threshold === null || threshold < 0 || threshold > 1)
@@ -29631,10 +29631,10 @@ var require_duetRouterModel = __commonJS({
29631
29631
  if (weight.length === 0 || bias.length !== weight.length)
29632
29632
  return null;
29633
29633
  for (const row of weight) {
29634
- if (!Array.isArray(row) || row.length !== dim || row.some((x2) => num(x2) === null))
29634
+ if (!Array.isArray(row) || row.length !== dim || row.some((x2) => num2(x2) === null))
29635
29635
  return null;
29636
29636
  }
29637
- if (bias.some((x2) => num(x2) === null))
29637
+ if (bias.some((x2) => num2(x2) === null))
29638
29638
  return null;
29639
29639
  return { weight, bias };
29640
29640
  };
@@ -40030,29 +40030,29 @@ var require_agentDefs = __commonJS({
40030
40030
  return false;
40031
40031
  }
40032
40032
  function defFromMeta(meta, fallbackName, system) {
40033
- const name2 = str(meta.name) || fallbackName;
40033
+ const name2 = str2(meta.name) || fallbackName;
40034
40034
  if (!name2.trim())
40035
40035
  return null;
40036
40036
  return {
40037
40037
  name: name2.trim(),
40038
- description: collapse(str(meta.description) || str(meta.when_to_use) || ""),
40038
+ description: collapse(str2(meta.description) || str2(meta.when_to_use) || ""),
40039
40039
  system,
40040
40040
  toolsAllow: list(meta.tools_allow ?? meta.tools),
40041
40041
  toolsDeny: list(meta.tools_deny ?? meta.deny),
40042
- model: str(meta.model_preference) || str(meta.model) || void 0,
40043
- permissionMode: str(meta.permission_mode) || void 0,
40044
- maxIterations: num(meta.max_iterations),
40045
- effort: str(meta.thinking) || str(meta.effort) || void 0,
40042
+ model: str2(meta.model_preference) || str2(meta.model) || void 0,
40043
+ permissionMode: str2(meta.permission_mode) || void 0,
40044
+ maxIterations: num2(meta.max_iterations),
40045
+ effort: str2(meta.thinking) || str2(meta.effort) || void 0,
40046
40046
  background: bool(meta.background),
40047
40047
  oneShot: bool(meta.one_shot),
40048
- color: str(meta.color) || void 0,
40049
- isolation: str(meta.isolation) || void 0
40048
+ color: str2(meta.color) || void 0,
40049
+ isolation: str2(meta.isolation) || void 0
40050
40050
  };
40051
40051
  }
40052
- function str(v2) {
40052
+ function str2(v2) {
40053
40053
  return typeof v2 === "string" ? v2 : typeof v2 === "number" || typeof v2 === "boolean" ? String(v2) : "";
40054
40054
  }
40055
- function num(v2) {
40055
+ function num2(v2) {
40056
40056
  if (typeof v2 === "number" && Number.isFinite(v2))
40057
40057
  return Math.trunc(v2);
40058
40058
  if (typeof v2 === "string" && /^\d+$/.test(v2.trim()))
@@ -40068,7 +40068,7 @@ var require_agentDefs = __commonJS({
40068
40068
  }
40069
40069
  function list(v2) {
40070
40070
  if (Array.isArray(v2)) {
40071
- const items = v2.map(str).map((s) => s.trim()).filter(Boolean);
40071
+ const items = v2.map(str2).map((s) => s.trim()).filter(Boolean);
40072
40072
  return items.length > 0 ? items : void 0;
40073
40073
  }
40074
40074
  if (typeof v2 === "string") {
@@ -40465,7 +40465,7 @@ var require_agentManager = __commonJS({
40465
40465
  if (isolation === "worktree") {
40466
40466
  worktree = await this.createWorktree(parentSessionId, agentId);
40467
40467
  }
40468
- const model = str(params.model) || resolveModelPreference(def.model, routing.model) || routing.model;
40468
+ const model = str2(params.model) || resolveModelPreference(def.model, routing.model) || routing.model;
40469
40469
  const readOnly = routing.mode === "plan" || routing.mode === "ask" || routing.mode === "duet";
40470
40470
  const sessionId = await this.transport.startSession({
40471
40471
  provider: routing.provider,
@@ -40480,8 +40480,8 @@ var require_agentManager = __commonJS({
40480
40480
  sessionId,
40481
40481
  type,
40482
40482
  brief,
40483
- name: str(params.name) || void 0,
40484
- team: str(params.team) || void 0,
40483
+ name: str2(params.name) || void 0,
40484
+ team: str2(params.team) || void 0,
40485
40485
  status: "running",
40486
40486
  outputTokens: 0,
40487
40487
  inputTokens: 0,
@@ -40544,9 +40544,9 @@ var require_agentManager = __commonJS({
40544
40544
  * report to disk); a running child answers with a status line, plus its
40545
40545
  * output-so-far under `detail: true`. */
40546
40546
  async check(parentSessionId, params) {
40547
- const entry = this.resolve(parentSessionId, str(params.agent_id));
40547
+ const entry = this.resolve(parentSessionId, str2(params.agent_id));
40548
40548
  if (!entry)
40549
- return this.unknownAgent(parentSessionId, str(params.agent_id));
40549
+ return this.unknownAgent(parentSessionId, str2(params.agent_id));
40550
40550
  if (entry.status !== "running" && entry.reportText)
40551
40551
  return entry.reportText;
40552
40552
  const progress = entry.progress ? `
@@ -40575,7 +40575,7 @@ ${(0, agentNarration_2.lastChars)(entry.partialText.trim(), 4e3)}`;
40575
40575
  if (targets.length === 0) {
40576
40576
  return "(no matching sub-agents to await \u2014 check agent ids, or spawn first)";
40577
40577
  }
40578
- const timeoutS = clamp3(num(params.timeout_s) ?? exports2.AWAIT_DEFAULT_TIMEOUT_S, 1, exports2.AWAIT_MAX_TIMEOUT_S);
40578
+ const timeoutS = clamp3(num2(params.timeout_s) ?? exports2.AWAIT_DEFAULT_TIMEOUT_S, 1, exports2.AWAIT_MAX_TIMEOUT_S);
40579
40579
  const hooks = this.parents.get(parentSessionId);
40580
40580
  const running = targets.filter((t) => t.status === "running");
40581
40581
  if (running.length > 0) {
@@ -40615,8 +40615,8 @@ ${(0, agentNarration_2.lastChars)(entry.partialText.trim(), 4e3)}`;
40615
40615
  * Identified by `_agent_id`, which the manager stamps on every child tool call. A call
40616
40616
  * without one is a call from something that is not a child, and there is nothing to record. */
40617
40617
  async progress(params) {
40618
- const note = str(params.note).trim();
40619
- const agentId = str(params._agent_id).trim();
40618
+ const note = str2(params.note).trim();
40619
+ const agentId = str2(params._agent_id).trim();
40620
40620
  if (!note)
40621
40621
  return "(no note \u2014 pass a short line describing what you are doing)";
40622
40622
  const entry = agentId ? this.entries.get(agentId) : void 0;
@@ -40628,9 +40628,9 @@ ${(0, agentNarration_2.lastChars)(entry.partialText.trim(), 4e3)}`;
40628
40628
  }
40629
40629
  /** `agent_stop` — cancel a running child; it still reports partial results. */
40630
40630
  async stop(parentSessionId, params) {
40631
- const entry = this.resolve(parentSessionId, str(params.agent_id));
40631
+ const entry = this.resolve(parentSessionId, str2(params.agent_id));
40632
40632
  if (!entry)
40633
- return this.unknownAgent(parentSessionId, str(params.agent_id));
40633
+ return this.unknownAgent(parentSessionId, str2(params.agent_id));
40634
40634
  if (entry.status !== "running") {
40635
40635
  return `Sub-agent ${entry.agentId} is already ${entry.status}.`;
40636
40636
  }
@@ -40661,9 +40661,9 @@ ${(0, agentNarration_2.lastChars)(entry.partialText.trim(), 4e3)}`;
40661
40661
  return this.entries.get(entry.agentId) ?? entry;
40662
40662
  }
40663
40663
  async message(parentSessionId, params) {
40664
- const entry = this.resolve(parentSessionId, str(params.agent_id));
40664
+ const entry = this.resolve(parentSessionId, str2(params.agent_id));
40665
40665
  if (!entry)
40666
- return this.unknownAgent(parentSessionId, str(params.agent_id));
40666
+ return this.unknownAgent(parentSessionId, str2(params.agent_id));
40667
40667
  const text = String(params.message ?? "").trim();
40668
40668
  if (!text)
40669
40669
  throw new Error("agent_message requires a non-empty 'message'");
@@ -41100,10 +41100,10 @@ Worktree kept (it has changes): ${wt.path} on branch ${wt.branch}. Apply or disc
41100
41100
  function fallbackDef(type) {
41101
41101
  return { name: type, description: "", system: "", background: false, oneShot: false };
41102
41102
  }
41103
- function str(v2) {
41103
+ function str2(v2) {
41104
41104
  return typeof v2 === "string" ? v2.trim() : "";
41105
41105
  }
41106
- function num(v2) {
41106
+ function num2(v2) {
41107
41107
  return typeof v2 === "number" && Number.isFinite(v2) ? v2 : void 0;
41108
41108
  }
41109
41109
  function clamp3(v2, lo, hi) {
@@ -42852,7 +42852,7 @@ var require_normalize = __commonJS({
42852
42852
  "use strict";
42853
42853
  Object.defineProperty(exports2, "__esModule", { value: true });
42854
42854
  exports2.normalizePlan = normalizePlan;
42855
- function str(v2) {
42855
+ function str2(v2) {
42856
42856
  return typeof v2 === "string" ? v2 : void 0;
42857
42857
  }
42858
42858
  function pick(obj, ...keys) {
@@ -42865,12 +42865,12 @@ var require_normalize = __commonJS({
42865
42865
  function normalizeFile(raw) {
42866
42866
  const f = raw ?? {};
42867
42867
  const out2 = {
42868
- relPath: str(pick(f, "relPath", "rel_path")) ?? ""
42868
+ relPath: str2(pick(f, "relPath", "rel_path")) ?? ""
42869
42869
  };
42870
- const content = str(f.content);
42870
+ const content = str2(f.content);
42871
42871
  if (content !== void 0)
42872
42872
  out2.content = content;
42873
- const fromPath = str(pick(f, "fromPath", "from_path"));
42873
+ const fromPath = str2(pick(f, "fromPath", "from_path"));
42874
42874
  if (fromPath !== void 0)
42875
42875
  out2.fromPath = fromPath;
42876
42876
  if (typeof f.mode === "number")
@@ -42880,21 +42880,21 @@ var require_normalize = __commonJS({
42880
42880
  function normalizeItem(raw) {
42881
42881
  const i2 = raw ?? {};
42882
42882
  const item = {
42883
- category: str(i2.category) ?? "",
42884
- name: str(i2.name) ?? "",
42885
- scope: str(i2.scope) ?? "global",
42886
- onCollision: str(pick(i2, "onCollision", "on_collision", "collision")) ?? "skip",
42887
- source: str(i2.source) ?? "unknown"
42883
+ category: str2(i2.category) ?? "",
42884
+ name: str2(i2.name) ?? "",
42885
+ scope: str2(i2.scope) ?? "global",
42886
+ onCollision: str2(pick(i2, "onCollision", "on_collision", "collision")) ?? "skip",
42887
+ source: str2(i2.source) ?? "unknown"
42888
42888
  };
42889
42889
  if (Array.isArray(i2.files))
42890
42890
  item.files = i2.files.map(normalizeFile);
42891
42891
  if (i2.server !== void 0 && typeof i2.server === "object" && i2.server !== null) {
42892
42892
  item.server = i2.server;
42893
42893
  }
42894
- const rulesTarget = str(pick(i2, "rulesTarget", "rules_target"));
42894
+ const rulesTarget = str2(pick(i2, "rulesTarget", "rules_target"));
42895
42895
  if (rulesTarget !== void 0)
42896
42896
  item.rulesTarget = rulesTarget;
42897
- const content = str(i2.content);
42897
+ const content = str2(i2.content);
42898
42898
  if (content !== void 0)
42899
42899
  item.content = content;
42900
42900
  if (i2.memory !== void 0 && typeof i2.memory === "object" && i2.memory !== null) {
@@ -42906,7 +42906,7 @@ var require_normalize = __commonJS({
42906
42906
  const p = raw ?? {};
42907
42907
  const rootsRaw = pick(p, "sourceRoots", "source_roots");
42908
42908
  return {
42909
- summary: str(p.summary) ?? "",
42909
+ summary: str2(p.summary) ?? "",
42910
42910
  sourceRoots: Array.isArray(rootsRaw) ? rootsRaw.map(String) : [],
42911
42911
  items: Array.isArray(p.items) ? p.items.map(normalizeItem) : []
42912
42912
  };
@@ -43394,8 +43394,8 @@ var require_manifest = __commonJS({
43394
43394
  let id = manifestId;
43395
43395
  if (id === void 0) {
43396
43396
  for (const candidate of ids) {
43397
- const rec = await readManifest(path14.join(importHistoryDir(home), candidate));
43398
- if (rec && !rec.undoneAt) {
43397
+ const rec2 = await readManifest(path14.join(importHistoryDir(home), candidate));
43398
+ if (rec2 && !rec2.undoneAt) {
43399
43399
  id = candidate;
43400
43400
  break;
43401
43401
  }
@@ -64723,26 +64723,26 @@ exit $__orion_rc`;
64723
64723
  const proc = (0, child_process_1.spawn)(bgInv.file, bgInv.args, { ...processHardening_1.HIDDEN_WINDOW_SPAWN_OPTIONS, cwd: root2 });
64724
64724
  (0, processHardening_1.trackChild)(proc);
64725
64725
  const handle2 = `bg-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
64726
- const rec = { proc, command, output: "" };
64727
- this.background.set(handle2, rec);
64726
+ const rec2 = { proc, command, output: "" };
64727
+ this.background.set(handle2, rec2);
64728
64728
  proc.stdout?.on("data", (c3) => {
64729
- rec.output += c3.toString();
64729
+ rec2.output += c3.toString();
64730
64730
  });
64731
64731
  proc.stderr?.on("data", (c3) => {
64732
- rec.output += c3.toString();
64732
+ rec2.output += c3.toString();
64733
64733
  });
64734
64734
  return handle2;
64735
64735
  }
64736
64736
  /** `bash_check` */
64737
64737
  async toolBashCheck(req, params, sessionId, context) {
64738
- const rec = this.background.get(String(params.handle));
64739
- if (!rec)
64738
+ const rec2 = this.background.get(String(params.handle));
64739
+ if (!rec2)
64740
64740
  throw new Error("unknown background handle");
64741
- const exitCode = rec.proc.exitCode;
64741
+ const exitCode = rec2.proc.exitCode;
64742
64742
  const outputTail = (0, terminalOutputCompression_1.compressTerminalOutputWithMetrics)({
64743
64743
  toolName: req.name,
64744
- command: rec.command,
64745
- output: rec.output.slice(-4e3),
64744
+ command: rec2.command,
64745
+ output: rec2.output.slice(-4e3),
64746
64746
  tokenSaving: context.tokenSaving,
64747
64747
  exitCode,
64748
64748
  complete: exitCode !== null
@@ -64758,10 +64758,10 @@ exit $__orion_rc`;
64758
64758
  }
64759
64759
  /** `bash_stop` */
64760
64760
  async toolBashStop(req, params, sessionId, context) {
64761
- const rec = this.background.get(String(params.handle));
64762
- if (!rec)
64761
+ const rec2 = this.background.get(String(params.handle));
64762
+ if (!rec2)
64763
64763
  throw new Error("unknown background handle");
64764
- await (0, processHardening_1.terminateChildTree)(rec.proc);
64764
+ await (0, processHardening_1.terminateChildTree)(rec2.proc);
64765
64765
  this.background.delete(String(params.handle));
64766
64766
  return "stopped";
64767
64767
  }
@@ -69517,7 +69517,7 @@ var require_loopDecl = __commonJS({
69517
69517
  return { decl: null, problems: ["the file must contain a JSON object"] };
69518
69518
  }
69519
69519
  meta = parsed;
69520
- body2 = str(meta.prompt);
69520
+ body2 = str2(meta.prompt);
69521
69521
  } catch (error) {
69522
69522
  return { decl: null, problems: [`invalid JSON (${errorText(error)})`] };
69523
69523
  }
@@ -69529,19 +69529,19 @@ var require_loopDecl = __commonJS({
69529
69529
  return { decl: null, problems: ["no frontmatter block (--- \u2026 ---) was found"] };
69530
69530
  }
69531
69531
  }
69532
- const name2 = (str(meta.name) || stem).trim();
69532
+ const name2 = (str2(meta.name) || stem).trim();
69533
69533
  if (!name2)
69534
69534
  problems.push("a loop needs a name");
69535
- const persona = str(meta.persona).trim();
69535
+ const persona = str2(meta.persona).trim();
69536
69536
  if (!persona)
69537
69537
  problems.push("`persona` is required (which sub-agent type runs this loop)");
69538
- const trigger = str(meta.trigger).trim();
69538
+ const trigger = str2(meta.trigger).trim();
69539
69539
  if (!trigger)
69540
69540
  problems.push("`trigger` is required (a 5-field cron expression)");
69541
69541
  else if (!(0, cronExpression_js_1.parseCronExpression)(trigger)) {
69542
69542
  problems.push(`\`trigger\` is not a valid 5-field cron expression: '${trigger}'`);
69543
69543
  }
69544
- const skill = str(meta.skill).trim();
69544
+ const skill = str2(meta.skill).trim();
69545
69545
  if (skill && body2) {
69546
69546
  problems.push("declare either `skill` or a prompt body, not both");
69547
69547
  }
@@ -69572,7 +69572,7 @@ var require_loopDecl = __commonJS({
69572
69572
  };
69573
69573
  }
69574
69574
  function parseEnvelope(meta, problems) {
69575
- const rawMode = str(meta.envelope_mode).trim().toLowerCase();
69575
+ const rawMode = str2(meta.envelope_mode).trim().toLowerCase();
69576
69576
  let mode = DEFAULT_ENVELOPE.mode;
69577
69577
  if (rawMode) {
69578
69578
  if (rawMode === "full_access") {
@@ -69678,7 +69678,7 @@ var require_loopDecl = __commonJS({
69678
69678
  issues.push({ path: filePath, problem });
69679
69679
  }
69680
69680
  }
69681
- function str(v2) {
69681
+ function str2(v2) {
69682
69682
  return typeof v2 === "string" ? v2 : typeof v2 === "number" || typeof v2 === "boolean" ? String(v2) : "";
69683
69683
  }
69684
69684
  function bool(v2) {
@@ -69690,7 +69690,7 @@ var require_loopDecl = __commonJS({
69690
69690
  }
69691
69691
  function list(v2) {
69692
69692
  if (Array.isArray(v2)) {
69693
- const items = v2.map(str).map((s) => s.trim()).filter(Boolean);
69693
+ const items = v2.map(str2).map((s) => s.trim()).filter(Boolean);
69694
69694
  return items.length > 0 ? items : void 0;
69695
69695
  }
69696
69696
  if (typeof v2 === "string" && v2.trim()) {
@@ -69702,7 +69702,7 @@ var require_loopDecl = __commonJS({
69702
69702
  function clampNumber(raw, fallback, max, field2, problems) {
69703
69703
  if (raw === void 0 || raw === "")
69704
69704
  return fallback;
69705
- const value = typeof raw === "number" ? raw : Number(str(raw));
69705
+ const value = typeof raw === "number" ? raw : Number(str2(raw));
69706
69706
  if (!Number.isFinite(value) || value <= 0) {
69707
69707
  problems.push(`\`${field2}\` must be a positive number`);
69708
69708
  return fallback;
@@ -72479,13 +72479,13 @@ var require_feedbackPolicy = __commonJS({
72479
72479
  return emptyFeedbackPolicyState(now2, seedFallback);
72480
72480
  }
72481
72481
  const r2 = raw;
72482
- const num = (value, fallback) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
72482
+ const num2 = (value, fallback) => typeof value === "number" && Number.isFinite(value) && value >= 0 ? value : fallback;
72483
72483
  const outcome = r2.lastOutcome === "submitted" || r2.lastOutcome === "dismissed" ? r2.lastOutcome : "";
72484
72484
  return {
72485
- firstSeenAt: num(r2.firstSeenAt, now2) || now2,
72486
- lastShownAt: num(r2.lastShownAt, 0),
72485
+ firstSeenAt: num2(r2.firstSeenAt, now2) || now2,
72486
+ lastShownAt: num2(r2.lastShownAt, 0),
72487
72487
  lastOutcome: outcome,
72488
- dismissStreak: Math.min(exports2.FEEDBACK_STOP_AFTER_DISMISSALS, Math.trunc(num(r2.dismissStreak, 0))),
72488
+ dismissStreak: Math.min(exports2.FEEDBACK_STOP_AFTER_DISMISSALS, Math.trunc(num2(r2.dismissStreak, 0))),
72489
72489
  stopped: r2.stopped === true,
72490
72490
  seed: typeof r2.seed === "number" && Number.isFinite(r2.seed) ? r2.seed : Number.isFinite(seedFallback) ? seedFallback : 0
72491
72491
  };
@@ -76768,13 +76768,13 @@ function getGraphemeSegmenter() {
76768
76768
 
76769
76769
  // src/vendor/ink/stringWidth.ts
76770
76770
  var EMOJI_REGEX = (0, import_emoji_regex.default)();
76771
- function stringWidthJavaScript(str) {
76772
- if (typeof str !== "string" || str.length === 0) {
76771
+ function stringWidthJavaScript(str2) {
76772
+ if (typeof str2 !== "string" || str2.length === 0) {
76773
76773
  return 0;
76774
76774
  }
76775
76775
  let isPureAscii = true;
76776
- for (let i2 = 0; i2 < str.length; i2++) {
76777
- const code = str.charCodeAt(i2);
76776
+ for (let i2 = 0; i2 < str2.length; i2++) {
76777
+ const code = str2.charCodeAt(i2);
76778
76778
  if (code >= 127 || code === 27) {
76779
76779
  isPureAscii = false;
76780
76780
  break;
@@ -76782,23 +76782,23 @@ function stringWidthJavaScript(str) {
76782
76782
  }
76783
76783
  if (isPureAscii) {
76784
76784
  let width2 = 0;
76785
- for (let i2 = 0; i2 < str.length; i2++) {
76786
- const code = str.charCodeAt(i2);
76785
+ for (let i2 = 0; i2 < str2.length; i2++) {
76786
+ const code = str2.charCodeAt(i2);
76787
76787
  if (code > 31) {
76788
76788
  width2++;
76789
76789
  }
76790
76790
  }
76791
76791
  return width2;
76792
76792
  }
76793
- if (str.includes("\x1B")) {
76794
- str = (0, import_strip_ansi.default)(str);
76795
- if (str.length === 0) {
76793
+ if (str2.includes("\x1B")) {
76794
+ str2 = (0, import_strip_ansi.default)(str2);
76795
+ if (str2.length === 0) {
76796
76796
  return 0;
76797
76797
  }
76798
76798
  }
76799
- if (!needsSegmentation(str)) {
76799
+ if (!needsSegmentation(str2)) {
76800
76800
  let width2 = 0;
76801
- for (const char of str) {
76801
+ for (const char of str2) {
76802
76802
  const codePoint = char.codePointAt(0);
76803
76803
  if (!isZeroWidth(codePoint)) {
76804
76804
  width2 += eastAsianWidth(codePoint, { ambiguousAsWide: false });
@@ -76807,7 +76807,7 @@ function stringWidthJavaScript(str) {
76807
76807
  return width2;
76808
76808
  }
76809
76809
  let width = 0;
76810
- for (const { segment: grapheme } of getGraphemeSegmenter().segment(str)) {
76810
+ for (const { segment: grapheme } of getGraphemeSegmenter().segment(str2)) {
76811
76811
  EMOJI_REGEX.lastIndex = 0;
76812
76812
  if (EMOJI_REGEX.test(grapheme)) {
76813
76813
  width += getEmojiWidth(grapheme);
@@ -76823,8 +76823,8 @@ function stringWidthJavaScript(str) {
76823
76823
  }
76824
76824
  return width;
76825
76825
  }
76826
- function needsSegmentation(str) {
76827
- for (const char of str) {
76826
+ function needsSegmentation(str2) {
76827
+ for (const char of str2) {
76828
76828
  const cp = char.codePointAt(0);
76829
76829
  if (cp >= 127744 && cp <= 129791) return true;
76830
76830
  if (cp >= 9728 && cp <= 10175) return true;
@@ -76888,7 +76888,7 @@ function isZeroWidth(codePoint) {
76888
76888
  }
76889
76889
  var bunStringWidth = typeof Bun !== "undefined" && typeof Bun.stringWidth === "function" ? Bun.stringWidth : null;
76890
76890
  var BUN_STRING_WIDTH_OPTS = { ambiguousIsNarrow: true };
76891
- var stringWidth = bunStringWidth ? (str) => bunStringWidth(str, BUN_STRING_WIDTH_OPTS) : stringWidthJavaScript;
76891
+ var stringWidth = bunStringWidth ? (str2) => bunStringWidth(str2, BUN_STRING_WIDTH_OPTS) : stringWidthJavaScript;
76892
76892
 
76893
76893
  // src/vendor/ink/line-width-cache.ts
76894
76894
  var cache = /* @__PURE__ */ new Map();
@@ -77763,9 +77763,9 @@ function isFullwidthCodePoint(codePoint) {
77763
77763
  }
77764
77764
 
77765
77765
  // ../node_modules/@alcalzone/ansi-tokenize/build/tokenize.js
77766
- function findNumberIndex(str) {
77767
- for (let index = 0; index < str.length; index++) {
77768
- const charCode = str.charCodeAt(index);
77766
+ function findNumberIndex(str2) {
77767
+ for (let index = 0; index < str2.length; index++) {
77768
+ const charCode = str2.charCodeAt(index);
77769
77769
  if (charCode >= 48 && charCode <= 57) {
77770
77770
  return index;
77771
77771
  }
@@ -77795,14 +77795,14 @@ function parseAnsiCode(string, offset) {
77795
77795
  return string.slice(0, endIndex + 1);
77796
77796
  }
77797
77797
  }
77798
- function tokenize2(str, endChar = Number.POSITIVE_INFINITY) {
77798
+ function tokenize2(str2, endChar = Number.POSITIVE_INFINITY) {
77799
77799
  const ret = [];
77800
77800
  let index = 0;
77801
77801
  let visible = 0;
77802
- while (index < str.length) {
77803
- const codePoint = str.codePointAt(index);
77802
+ while (index < str2.length) {
77803
+ const codePoint = str2.codePointAt(index);
77804
77804
  if (ESCAPES.has(codePoint)) {
77805
- const code = parseLinkCode(str, index) || parseAnsiCode(str, index);
77805
+ const code = parseLinkCode(str2, index) || parseAnsiCode(str2, index);
77806
77806
  if (code) {
77807
77807
  ret.push({
77808
77808
  type: "ansi",
@@ -77836,8 +77836,8 @@ function isEndCode(code) {
77836
77836
  function filterStartCodes(codes) {
77837
77837
  return codes.filter((c3) => !isEndCode(c3));
77838
77838
  }
77839
- function sliceAnsi(str, start2, end) {
77840
- const tokens = tokenize2(str);
77839
+ function sliceAnsi(str2, start2, end) {
77840
+ const tokens = tokenize2(str2);
77841
77841
  let activeCodes = [];
77842
77842
  let position = 0;
77843
77843
  let result = "";
@@ -80293,16 +80293,16 @@ var UNDERLINE_STYLES = [
80293
80293
  "dotted",
80294
80294
  "dashed"
80295
80295
  ];
80296
- function parseParams(str) {
80297
- if (str === "") return [{ value: 0, subparams: [], colon: false }];
80296
+ function parseParams(str2) {
80297
+ if (str2 === "") return [{ value: 0, subparams: [], colon: false }];
80298
80298
  const result = [];
80299
80299
  let current2 = { value: null, subparams: [], colon: false };
80300
- let num = "";
80300
+ let num2 = "";
80301
80301
  let inSub = false;
80302
- for (let i2 = 0; i2 <= str.length; i2++) {
80303
- const c3 = str[i2];
80302
+ for (let i2 = 0; i2 <= str2.length; i2++) {
80303
+ const c3 = str2[i2];
80304
80304
  if (c3 === ";" || c3 === void 0) {
80305
- const n = num === "" ? null : parseInt(num, 10);
80305
+ const n = num2 === "" ? null : parseInt(num2, 10);
80306
80306
  if (inSub) {
80307
80307
  if (n !== null) current2.subparams.push(n);
80308
80308
  } else {
@@ -80310,10 +80310,10 @@ function parseParams(str) {
80310
80310
  }
80311
80311
  result.push(current2);
80312
80312
  current2 = { value: null, subparams: [], colon: false };
80313
- num = "";
80313
+ num2 = "";
80314
80314
  inSub = false;
80315
80315
  } else if (c3 === ":") {
80316
- const n = num === "" ? null : parseInt(num, 10);
80316
+ const n = num2 === "" ? null : parseInt(num2, 10);
80317
80317
  if (!inSub) {
80318
80318
  current2.value = n;
80319
80319
  current2.colon = true;
@@ -80321,9 +80321,9 @@ function parseParams(str) {
80321
80321
  } else {
80322
80322
  if (n !== null) current2.subparams.push(n);
80323
80323
  }
80324
- num = "";
80324
+ num2 = "";
80325
80325
  } else if (c3 >= "0" && c3 <= "9") {
80326
- num += c3;
80326
+ num2 += c3;
80327
80327
  }
80328
80328
  }
80329
80329
  return result;
@@ -80533,9 +80533,9 @@ function isEmoji(codePoint) {
80533
80533
  function isEastAsianWide(codePoint) {
80534
80534
  return codePoint >= 4352 && codePoint <= 4447 || codePoint >= 11904 && codePoint <= 40959 || codePoint >= 44032 && codePoint <= 55203 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 65040 && codePoint <= 65055 || codePoint >= 65072 && codePoint <= 65135 || codePoint >= 65280 && codePoint <= 65376 || codePoint >= 65504 && codePoint <= 65510 || codePoint >= 131072 && codePoint <= 196605 || codePoint >= 196608 && codePoint <= 262141;
80535
80535
  }
80536
- function hasMultipleCodepoints(str) {
80536
+ function hasMultipleCodepoints(str2) {
80537
80537
  let count = 0;
80538
- for (const _2 of str) {
80538
+ for (const _2 of str2) {
80539
80539
  count++;
80540
80540
  if (count > 1) return true;
80541
80541
  }
@@ -80548,8 +80548,8 @@ function graphemeWidth(grapheme) {
80548
80548
  if (isEmoji(codePoint) || isEastAsianWide(codePoint)) return 2;
80549
80549
  return 1;
80550
80550
  }
80551
- function* segmentGraphemes(str) {
80552
- for (const { segment } of getGraphemeSegmenter().segment(str)) {
80551
+ function* segmentGraphemes(str2) {
80552
+ for (const { segment } of getGraphemeSegmenter().segment(str2)) {
80553
80553
  yield { value: segment, width: graphemeWidth(segment) };
80554
80554
  }
80555
80555
  }
@@ -81706,69 +81706,69 @@ var CHALK_BOOSTED_FOR_XTERMJS = boostChalkLevelForXtermJs();
81706
81706
  var CHALK_CLAMPED_FOR_TMUX = clampChalkLevelForTmux();
81707
81707
  var RGB_REGEX = /^rgb\(\s?(\d+),\s?(\d+),\s?(\d+)\s?\)$/;
81708
81708
  var ANSI_REGEX = /^ansi256\(\s?(\d+)\s?\)$/;
81709
- var colorize = (str, color, type) => {
81709
+ var colorize = (str2, color, type) => {
81710
81710
  if (!color) {
81711
- return str;
81711
+ return str2;
81712
81712
  }
81713
81713
  if (color.startsWith("ansi:")) {
81714
81714
  const value = color.substring("ansi:".length);
81715
81715
  switch (value) {
81716
81716
  case "black":
81717
- return type === "foreground" ? import_chalk.default.black(str) : import_chalk.default.bgBlack(str);
81717
+ return type === "foreground" ? import_chalk.default.black(str2) : import_chalk.default.bgBlack(str2);
81718
81718
  case "red":
81719
- return type === "foreground" ? import_chalk.default.red(str) : import_chalk.default.bgRed(str);
81719
+ return type === "foreground" ? import_chalk.default.red(str2) : import_chalk.default.bgRed(str2);
81720
81720
  case "green":
81721
- return type === "foreground" ? import_chalk.default.green(str) : import_chalk.default.bgGreen(str);
81721
+ return type === "foreground" ? import_chalk.default.green(str2) : import_chalk.default.bgGreen(str2);
81722
81722
  case "yellow":
81723
- return type === "foreground" ? import_chalk.default.yellow(str) : import_chalk.default.bgYellow(str);
81723
+ return type === "foreground" ? import_chalk.default.yellow(str2) : import_chalk.default.bgYellow(str2);
81724
81724
  case "blue":
81725
- return type === "foreground" ? import_chalk.default.blue(str) : import_chalk.default.bgBlue(str);
81725
+ return type === "foreground" ? import_chalk.default.blue(str2) : import_chalk.default.bgBlue(str2);
81726
81726
  case "magenta":
81727
- return type === "foreground" ? import_chalk.default.magenta(str) : import_chalk.default.bgMagenta(str);
81727
+ return type === "foreground" ? import_chalk.default.magenta(str2) : import_chalk.default.bgMagenta(str2);
81728
81728
  case "cyan":
81729
- return type === "foreground" ? import_chalk.default.cyan(str) : import_chalk.default.bgCyan(str);
81729
+ return type === "foreground" ? import_chalk.default.cyan(str2) : import_chalk.default.bgCyan(str2);
81730
81730
  case "white":
81731
- return type === "foreground" ? import_chalk.default.white(str) : import_chalk.default.bgWhite(str);
81731
+ return type === "foreground" ? import_chalk.default.white(str2) : import_chalk.default.bgWhite(str2);
81732
81732
  case "blackBright":
81733
- return type === "foreground" ? import_chalk.default.blackBright(str) : import_chalk.default.bgBlackBright(str);
81733
+ return type === "foreground" ? import_chalk.default.blackBright(str2) : import_chalk.default.bgBlackBright(str2);
81734
81734
  case "redBright":
81735
- return type === "foreground" ? import_chalk.default.redBright(str) : import_chalk.default.bgRedBright(str);
81735
+ return type === "foreground" ? import_chalk.default.redBright(str2) : import_chalk.default.bgRedBright(str2);
81736
81736
  case "greenBright":
81737
- return type === "foreground" ? import_chalk.default.greenBright(str) : import_chalk.default.bgGreenBright(str);
81737
+ return type === "foreground" ? import_chalk.default.greenBright(str2) : import_chalk.default.bgGreenBright(str2);
81738
81738
  case "yellowBright":
81739
- return type === "foreground" ? import_chalk.default.yellowBright(str) : import_chalk.default.bgYellowBright(str);
81739
+ return type === "foreground" ? import_chalk.default.yellowBright(str2) : import_chalk.default.bgYellowBright(str2);
81740
81740
  case "blueBright":
81741
- return type === "foreground" ? import_chalk.default.blueBright(str) : import_chalk.default.bgBlueBright(str);
81741
+ return type === "foreground" ? import_chalk.default.blueBright(str2) : import_chalk.default.bgBlueBright(str2);
81742
81742
  case "magentaBright":
81743
- return type === "foreground" ? import_chalk.default.magentaBright(str) : import_chalk.default.bgMagentaBright(str);
81743
+ return type === "foreground" ? import_chalk.default.magentaBright(str2) : import_chalk.default.bgMagentaBright(str2);
81744
81744
  case "cyanBright":
81745
- return type === "foreground" ? import_chalk.default.cyanBright(str) : import_chalk.default.bgCyanBright(str);
81745
+ return type === "foreground" ? import_chalk.default.cyanBright(str2) : import_chalk.default.bgCyanBright(str2);
81746
81746
  case "whiteBright":
81747
- return type === "foreground" ? import_chalk.default.whiteBright(str) : import_chalk.default.bgWhiteBright(str);
81747
+ return type === "foreground" ? import_chalk.default.whiteBright(str2) : import_chalk.default.bgWhiteBright(str2);
81748
81748
  }
81749
81749
  }
81750
81750
  if (color.startsWith("#")) {
81751
- return type === "foreground" ? import_chalk.default.hex(color)(str) : import_chalk.default.bgHex(color)(str);
81751
+ return type === "foreground" ? import_chalk.default.hex(color)(str2) : import_chalk.default.bgHex(color)(str2);
81752
81752
  }
81753
81753
  if (color.startsWith("ansi256")) {
81754
81754
  const matches = ANSI_REGEX.exec(color);
81755
81755
  if (!matches) {
81756
- return str;
81756
+ return str2;
81757
81757
  }
81758
81758
  const value = Number(matches[1]);
81759
- return type === "foreground" ? import_chalk.default.ansi256(value)(str) : import_chalk.default.bgAnsi256(value)(str);
81759
+ return type === "foreground" ? import_chalk.default.ansi256(value)(str2) : import_chalk.default.bgAnsi256(value)(str2);
81760
81760
  }
81761
81761
  if (color.startsWith("rgb")) {
81762
81762
  const matches = RGB_REGEX.exec(color);
81763
81763
  if (!matches) {
81764
- return str;
81764
+ return str2;
81765
81765
  }
81766
81766
  const firstValue = Number(matches[1]);
81767
81767
  const secondValue = Number(matches[2]);
81768
81768
  const thirdValue = Number(matches[3]);
81769
- return type === "foreground" ? import_chalk.default.rgb(firstValue, secondValue, thirdValue)(str) : import_chalk.default.bgRgb(firstValue, secondValue, thirdValue)(str);
81769
+ return type === "foreground" ? import_chalk.default.rgb(firstValue, secondValue, thirdValue)(str2) : import_chalk.default.bgRgb(firstValue, secondValue, thirdValue)(str2);
81770
81770
  }
81771
- return str;
81771
+ return str2;
81772
81772
  };
81773
81773
  function applyTextStyles(text, styles3) {
81774
81774
  let result = text;
@@ -82572,12 +82572,12 @@ var StylePool = class {
82572
82572
  transition(fromId, toId) {
82573
82573
  if (fromId === toId) return "";
82574
82574
  const key = fromId * 1048576 + toId;
82575
- let str = this.transitionCache.get(key);
82576
- if (str === void 0) {
82577
- str = ansiCodesToString(diffAnsiCodes(this.get(fromId), this.get(toId)));
82578
- this.transitionCache.set(key, str);
82575
+ let str2 = this.transitionCache.get(key);
82576
+ if (str2 === void 0) {
82577
+ str2 = ansiCodesToString(diffAnsiCodes(this.get(fromId), this.get(toId)));
82578
+ this.transitionCache.set(key, str2);
82579
82579
  }
82580
- return str;
82580
+ return str2;
82581
82581
  }
82582
82582
  /**
82583
82583
  * Intern a style that is `base + inverse`. Cached by base ID so
@@ -85062,9 +85062,9 @@ function transitionHyperlink(diff3, current2, target) {
85062
85062
  return current2;
85063
85063
  }
85064
85064
  function transitionStyle(diff3, stylePool, currentId, targetId) {
85065
- const str = stylePool.transition(currentId, targetId);
85066
- if (str.length > 0) {
85067
- diff3.push({ type: "styleStr", str });
85065
+ const str2 = stylePool.transition(currentId, targetId);
85066
+ if (str2.length > 0) {
85067
+ diff3.push({ type: "styleStr", str: str2 });
85068
85068
  }
85069
85069
  return targetId;
85070
85070
  }
@@ -89836,6 +89836,40 @@ function projectMessages(messages) {
89836
89836
  }
89837
89837
  return groupToolRuns(out2);
89838
89838
  }
89839
+ var str = (v2) => typeof v2 === "string";
89840
+ var num = (v2) => typeof v2 === "number" && Number.isFinite(v2);
89841
+ var rec = (v2) => !!v2 && typeof v2 === "object" && !Array.isArray(v2);
89842
+ var REVIVE_CHECKS = {
89843
+ user: (x2) => str(x2.text),
89844
+ command: (x2) => str(x2.name) && str(x2.args),
89845
+ assistant: (x2) => str(x2.text),
89846
+ thinking: (x2) => str(x2.text) && (x2.durationMs === void 0 || num(x2.durationMs)),
89847
+ tool: (x2) => str(x2.name) && str(x2.args) && (x2.status === "ok" || x2.status === "error"),
89848
+ toolgroup: (x2) => Array.isArray(x2.tools) && x2.tools.length > 0 && x2.tools.every((t) => isRevivableItem(t) && t.kind === "tool"),
89849
+ diff: (x2) => str(x2.path) && (x2.diff === null || str(x2.diff)) && num(x2.insertions) && num(x2.deletions) && typeof x2.deleted === "boolean" && // Optional decorations, validated when present: DiffCard maps/joins these
89850
+ // unconditionally once they exist, so a malformed shape would throw.
89851
+ (x2.affectedFiles === void 0 || Array.isArray(x2.affectedFiles) && x2.affectedFiles.every(str)) && (x2.trust === void 0 || rec(x2.trust) && Array.isArray(x2.trust.findings)),
89852
+ terminal: (x2) => str(x2.command) && str(x2.output) && (x2.exitCode === null || num(x2.exitCode)),
89853
+ note: (x2) => str(x2.text) && (x2.stats === void 0 || rec(x2.stats) && num(x2.stats.insertions) && num(x2.stats.deletions)),
89854
+ goalEnd: (x2) => rec(x2.row),
89855
+ subagents: (x2) => Array.isArray(x2.agents) && x2.agents.every(rec),
89856
+ websearch: (x2) => str(x2.query) && Array.isArray(x2.results) && x2.results.every(str),
89857
+ inputguard: (x2) => rec(x2.card),
89858
+ compaction: (x2) => rec(x2.card),
89859
+ quota: (x2) => rec(x2.refusal),
89860
+ context: (x2) => str(x2.modelLabel) && str(x2.modelId) && num(x2.tokens) && num(x2.window) && rec(x2.breakdown),
89861
+ info: (x2) => str(x2.title) && Array.isArray(x2.rows) && x2.rows.every((r2) => Array.isArray(r2) || rec(r2))
89862
+ };
89863
+ function isRevivableItem(v2) {
89864
+ if (!rec(v2) || !str(v2.id)) return false;
89865
+ const check2 = REVIVE_CHECKS[v2.kind];
89866
+ return check2 !== void 0 && check2(v2);
89867
+ }
89868
+ function reviveTranscript(raw) {
89869
+ if (!Array.isArray(raw)) return null;
89870
+ const items = raw.filter(isRevivableItem);
89871
+ return items.length > 0 ? items : null;
89872
+ }
89839
89873
 
89840
89874
  // src/state/transcriptStore.ts
89841
89875
  var import_client_core12 = __toESM(require_dist(), 1);
@@ -90092,9 +90126,9 @@ function applyTurnInterrupted(s, prompt, partialReply = "") {
90092
90126
  live: null
90093
90127
  };
90094
90128
  }
90095
- function hydrate(sessionId, messages, clientState) {
90129
+ function hydrate(sessionId, messages, clientState, transcript) {
90096
90130
  const msgs = Array.isArray(messages) ? messages : [];
90097
- const settled = projectMessages(msgs);
90131
+ const settled = reviveTranscript(transcript) ?? projectMessages(msgs);
90098
90132
  return {
90099
90133
  sessionId,
90100
90134
  messages: msgs,
@@ -94379,13 +94413,13 @@ function writeAtomic(file, data) {
94379
94413
  fs11.renameSync(tmp, file);
94380
94414
  }
94381
94415
  var saveFailureWarned = false;
94382
- function saveSession(rec) {
94416
+ function saveSession(rec2) {
94383
94417
  try {
94384
94418
  ensureDirs();
94385
- writeAtomic(sessionFile(rec.sessionId), `${JSON.stringify(rec, null, 2)}
94419
+ writeAtomic(sessionFile(rec2.sessionId), `${JSON.stringify(rec2, null, 2)}
94386
94420
  `);
94387
- const idx = loadIndex().filter((e) => e.sessionId !== rec.sessionId);
94388
- idx.unshift({ sessionId: rec.sessionId, title: rec.title, updatedAt: rec.updatedAt });
94421
+ const idx = loadIndex().filter((e) => e.sessionId !== rec2.sessionId);
94422
+ idx.unshift({ sessionId: rec2.sessionId, title: rec2.title, updatedAt: rec2.updatedAt });
94389
94423
  writeAtomic(indexFile(), `${JSON.stringify(idx.slice(0, 100), null, 2)}
94390
94424
  `);
94391
94425
  return true;
@@ -94407,9 +94441,9 @@ function loadSession(sessionId) {
94407
94441
  }
94408
94442
  }
94409
94443
  function renameSession(sessionId, title) {
94410
- const rec = loadSession(sessionId);
94411
- if (!rec) return false;
94412
- return saveSession({ ...rec, title, updatedAt: Date.now() });
94444
+ const rec2 = loadSession(sessionId);
94445
+ if (!rec2) return false;
94446
+ return saveSession({ ...rec2, title, updatedAt: Date.now() });
94413
94447
  }
94414
94448
  var pendingModelTitles = /* @__PURE__ */ new Map();
94415
94449
  function applyModelSessionTitle(sessionId, title) {
@@ -111545,7 +111579,7 @@ function StructuredDiff({
111545
111579
  isAdd ? "add" : isDel ? "del" : "context"
111546
111580
  );
111547
111581
  const marker = isAdd ? "+" : isDel ? "-" : " ";
111548
- const num = isDel ? l3.oldNo : l3.newNo;
111582
+ const num2 = isDel ? l3.oldNo : l3.newNo;
111549
111583
  const raw = expandTabs2(l3.text ?? "");
111550
111584
  const shown = (raw.length > textWidth ? raw.slice(0, textWidth) : raw) || " ";
111551
111585
  const pad = bg ? " ".repeat(Math.max(0, textWidth - shown.length)) : "";
@@ -111563,7 +111597,7 @@ function StructuredDiff({
111563
111597
  const body2 = changed ? wordRuns(shown, lang, changed, bg, wordBg, isAdd, text, theme) : isDel ? /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Text2, { color: text, children: shown }) : (highlightCode(shown, lang)[0] ?? []).map((sp, k) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Text2, { color: synColor(theme, sp.kind) ?? text, children: sp.text }, k));
111564
111598
  return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Text2, { backgroundColor: bg, children: [
111565
111599
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Text2, { color: accent, children: [
111566
- gutter(num),
111600
+ gutter(num2),
111567
111601
  " "
111568
111602
  ] }),
111569
111603
  /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Text2, { color: accent, children: [
@@ -112068,7 +112102,7 @@ function OrionRing() {
112068
112102
 
112069
112103
  // src/services/version.ts
112070
112104
  function tuiVersion() {
112071
- return "0.1.25".length > 0 ? "0.1.25" : null;
112105
+ return "0.1.26".length > 0 ? "0.1.26" : null;
112072
112106
  }
112073
112107
 
112074
112108
  // src/components/layout/WelcomeCard.tsx
@@ -118204,6 +118238,68 @@ function SignInCard({
118204
118238
  ] });
118205
118239
  }
118206
118240
 
118241
+ // src/services/sessionAutosave.ts
118242
+ var DISPLAY_SAVE_INTERVAL_MS = 1e3;
118243
+ function createSessionAutosave(deps2) {
118244
+ const save = deps2.save ?? saveSession;
118245
+ const intervalMs = deps2.intervalMs ?? DISPLAY_SAVE_INTERVAL_MS;
118246
+ let pending = null;
118247
+ let timer = null;
118248
+ const persistable = (s) => !!s.sessionId && s.messages.length > 0;
118249
+ const write = (s, opts) => {
118250
+ if (!s.sessionId) return;
118251
+ try {
118252
+ const title = resolveTitle(s.sessionId, s.messages);
118253
+ if (opts.title) deps2.onTitle?.(title);
118254
+ save({
118255
+ sessionId: s.sessionId,
118256
+ title,
118257
+ updatedAt: Date.now(),
118258
+ messages: s.messages,
118259
+ clientState: s.clientState,
118260
+ transcript: s.settled,
118261
+ config: deps2.buildConfig()
118262
+ });
118263
+ } catch {
118264
+ }
118265
+ };
118266
+ const cancel = () => {
118267
+ if (timer !== null) {
118268
+ clearTimeout(timer);
118269
+ timer = null;
118270
+ }
118271
+ pending = null;
118272
+ };
118273
+ const fire = () => {
118274
+ timer = null;
118275
+ const s = pending;
118276
+ pending = null;
118277
+ if (s) write(s, { title: false });
118278
+ };
118279
+ return {
118280
+ onChange: (next, prev) => {
118281
+ if (next.messages !== prev.messages) {
118282
+ if (!persistable(next)) return;
118283
+ cancel();
118284
+ write(next, { title: true });
118285
+ } else if (next.settled !== prev.settled) {
118286
+ if (!persistable(next)) return;
118287
+ pending = next;
118288
+ if (timer === null) {
118289
+ timer = setTimeout(fire, intervalMs);
118290
+ timer.unref?.();
118291
+ }
118292
+ }
118293
+ },
118294
+ flush: () => {
118295
+ const s = pending;
118296
+ cancel();
118297
+ if (s) write(s, { title: false });
118298
+ },
118299
+ dispose: cancel
118300
+ };
118301
+ }
118302
+
118207
118303
  // src/services/presenceHost.ts
118208
118304
  var import_client_core42 = __toESM(require_dist(), 1);
118209
118305
  function startTuiPresence(opts) {
@@ -119263,25 +119359,14 @@ async function main() {
119263
119359
  const setSessionTitle = (title) => {
119264
119360
  appStore.setState((s) => s.sessionTitle === title ? s : { ...s, sessionTitle: title });
119265
119361
  };
119266
- const transcriptStore = createTranscriptStore((next, prev) => {
119267
- if (next.sessionId && next.messages !== prev.messages && next.messages.length > 0) {
119268
- try {
119269
- const title = resolveTitle(next.sessionId, next.messages);
119270
- setSessionTitle(title);
119271
- saveSession({
119272
- sessionId: next.sessionId,
119273
- title,
119274
- updatedAt: Date.now(),
119275
- messages: next.messages,
119276
- clientState: next.clientState,
119277
- // The LIVE routing config (not a frozen startup snapshot), so a
119278
- // mid-session /model or /persona change is what a later resume reuses.
119279
- config: sessionRoutingFromApp(appStore.getState())
119280
- });
119281
- } catch {
119282
- }
119283
- }
119362
+ const autosave = createSessionAutosave({
119363
+ // The LIVE routing config (not a frozen startup snapshot), so a
119364
+ // mid-session /model or /persona change is what a later resume reuses.
119365
+ buildConfig: () => sessionRoutingFromApp(appStore.getState()),
119366
+ onTitle: setSessionTitle
119367
+ // keep the terminal-tab title in step with the save
119284
119368
  });
119369
+ const transcriptStore = createTranscriptStore(autosave.onChange);
119285
119370
  const secrets = createSecretStore();
119286
119371
  const session = (0, import_client_core49.createAgentSession)(secrets, config, {
119287
119372
  // Renewal/refresh breadcrumbs (step outcomes + timings, never tokens) — the evidence
@@ -119474,7 +119559,9 @@ async function main() {
119474
119559
  if (resumeId) {
119475
119560
  const saved = loadSession(resumeId);
119476
119561
  if (saved) {
119477
- transcriptStore.setState(() => hydrate(saved.sessionId, saved.messages, saved.clientState));
119562
+ transcriptStore.setState(
119563
+ () => hydrate(saved.sessionId, saved.messages, saved.clientState, saved.transcript)
119564
+ );
119478
119565
  appStore.setState((s) => ({ ...s, ...resumedRouting(s, saved.config) }));
119479
119566
  setSessionTitle(saved.title ?? "");
119480
119567
  }
@@ -119645,7 +119732,9 @@ async function main() {
119645
119732
  await bridge.closeSession(sessionId).catch(() => void 0);
119646
119733
  let restoredRouting = sessionRoutingFromApp(appStore.getState());
119647
119734
  if (saved) {
119648
- transcriptStore.setState(() => hydrate(saved.sessionId, saved.messages, saved.clientState));
119735
+ transcriptStore.setState(
119736
+ () => hydrate(saved.sessionId, saved.messages, saved.clientState, saved.transcript)
119737
+ );
119649
119738
  const restored = resumedRouting(appStore.getState(), saved.config);
119650
119739
  appStore.setState((s) => ({ ...s, ...restored }));
119651
119740
  restoredRouting = { ...saved.config, ...restored };
@@ -119809,6 +119898,7 @@ async function main() {
119809
119898
  let app = null;
119810
119899
  let stopSignInWatch = null;
119811
119900
  const exit = () => {
119901
+ autosave.flush();
119812
119902
  stopSignInWatch?.();
119813
119903
  presence.dispose();
119814
119904
  void rc?.dispose();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orion-super-agent-dev",
3
- "version": "0.1.25",
3
+ "version": "0.1.26",
4
4
  "description": "[dev] Orion \u2014 a terminal AI super-agent, strongest at coding. Local brain, local disk: the agent loop runs on your machine; only the metered model call leaves it.",
5
5
  "license": "MIT",
6
6
  "type": "module",