@aiwayds/dsh-opentui 0.25.0 → 0.26.1

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.
@@ -47683,6 +47683,11 @@ var init_subagent_markers = __esm(() => {
47683
47683
  subagentMarkerViews = subagentViews;
47684
47684
  });
47685
47685
 
47686
+ // ../tui-base/src/routes/session/subagent-name.ts
47687
+ function subagentNamePrefix(name, label) {
47688
+ return name !== undefined && name !== "" && name !== label ? `${name}: ` : "";
47689
+ }
47690
+
47686
47691
  // ../tui-base/src/routes/session/subagents-picker.tsx
47687
47692
  function SubagentsPicker(props) {
47688
47693
  const theme = useThemeOptional();
@@ -47847,7 +47852,8 @@ function pickerLineText(entries, selected, showAll) {
47847
47852
  }
47848
47853
  const glyph = subagentHardStopGlyph(entry);
47849
47854
  const suffix = subagentMarkerSuffix(entry);
47850
- const label = `${glyph ? `${glyph} ` : ""}${titlecase(entry.label)}`;
47855
+ const namePrefix = subagentNamePrefix(entry.name, entry.label);
47856
+ const label = `${glyph ? `${glyph} ` : ""}${namePrefix}${titlecase(entry.label)}`;
47851
47857
  const status = entry.status === "running" ? t("overlay.picker.statusRunning") : "";
47852
47858
  return t("overlay.picker.row", {
47853
47859
  label,
@@ -49369,13 +49375,15 @@ function agentLine(agent, position, count, parentIndex, now = Date.now()) {
49369
49375
  const indent = parentIndex === undefined ? "" : " ".repeat(stringWidth(`${TODO_STATUS_GLYPHS.in_progress} ${parentIndex} `));
49370
49376
  const elapsed = secsFrom(agent.startedAt, agent.elapsedSec, now);
49371
49377
  const tail = widthTail(agent.lastLine ?? "", 32);
49378
+ const namePrefix = subagentNamePrefix(agent.name, agent.label);
49372
49379
  const content = `${agent.label} \xB7 ${elapsed} \xB7 round ${agent.rounds} \xB7 ${tail}`;
49373
49380
  return {
49374
49381
  kind: "agent",
49375
49382
  index: parentIndex,
49376
49383
  segments: [
49377
49384
  { text: `${indent}${branch}`, tone: "muted" },
49378
- { text: content, tone: "running" }
49385
+ ...namePrefix !== "" ? [{ text: namePrefix, tone: "muted" }] : [],
49386
+ { text: content, tone: "running", accent: "agent" }
49379
49387
  ]
49380
49388
  };
49381
49389
  }
@@ -49723,7 +49731,8 @@ function todoTreeLines(todos) {
49723
49731
  done,
49724
49732
  total: todos.length
49725
49733
  }),
49726
- tone: "running"
49734
+ tone: "running",
49735
+ accent: "todo"
49727
49736
  }]
49728
49737
  }];
49729
49738
  todos.forEach((todo, i) => {
@@ -49733,7 +49742,8 @@ function todoTreeLines(todos) {
49733
49742
  kind: "todo",
49734
49743
  segments: [{
49735
49744
  text: `${branch}${glyph} ${todo.content}`,
49736
- tone: "running"
49745
+ tone: "running",
49746
+ accent: "todo"
49737
49747
  }]
49738
49748
  });
49739
49749
  });
@@ -49994,6 +50004,11 @@ function activityFrameBorderColor(theme) {
49994
50004
  }
49995
50005
  function dockAccentColor(theme, accent) {
49996
50006
  const background = theme?.background?.base;
50007
+ const validatedFallback = (bg) => {
50008
+ const fallback = DOCK_ACCENT_FALLBACK[accent];
50009
+ const darkSurface = relativeLuminance(bg) < 0.5;
50010
+ return boostUntilContrast(darkSurface ? fallback.dark : fallback.light, bg, DOCK_ACCENT_MIN_CONTRAST).color;
50011
+ };
49997
50012
  const hues = theme?.hue;
49998
50013
  for (const name of DOCK_ACCENT_HUES[accent]) {
49999
50014
  const ramp = hues?.[name];
@@ -50004,14 +50019,12 @@ function dockAccentColor(theme, accent) {
50004
50019
  continue;
50005
50020
  if (background === undefined)
50006
50021
  return candidates[0];
50007
- const preferred = candidates.find((value) => contrastRatio(value, background) >= 4.5);
50022
+ const preferred = candidates.find((value) => contrastRatio(value, background) >= DOCK_ACCENT_MIN_CONTRAST);
50008
50023
  if (preferred !== undefined)
50009
50024
  return preferred;
50010
- return candidates.reduce((a, b) => contrastRatio(b, background) > contrastRatio(a, background) ? b : a);
50025
+ return validatedFallback(background);
50011
50026
  }
50012
- const fallback = DOCK_ACCENT_FALLBACK[accent];
50013
- const darkSurface = background === undefined || relativeLuminance(background) < 0.5;
50014
- return darkSurface ? fallback.dark : fallback.light;
50027
+ return background === undefined ? DOCK_ACCENT_FALLBACK[accent].dark : validatedFallback(background);
50015
50028
  }
50016
50029
  function dockNeedsClock(rows) {
50017
50030
  if (untrack(() => dockLines(rows)).length > 0)
@@ -50441,7 +50454,7 @@ function dockLineNode(line, width, ctx, fgFor, accentFg) {
50441
50454
  return _el$8;
50442
50455
  })();
50443
50456
  }
50444
- var SKIN_FADE_IN_MS = 400, SKIN_NOTICE_FADE_MS = 500, SKIN_PULSE_MS = 1200, SKIN_PULSE_CYCLES = 3, SKIN_PULSE_DIM = 0.45, SKIN_FAINT_MIX = 0.78, ACTIVITY_PANEL_GEARS, ACTIVITY_PANEL_ALL_LINES = 10, activityPanelGear, setActivityPanelGear, DOCK_HEIGHT_ANIM_MS = 200, dockHeightTween, setDockHeightTween, dockHeightSettled = undefined, dockFrameNow = 0, LINE_FIRST_SEEN_MAX = 512, lineFirstSeen, dockSpin, setDockSpin, mergedDockCursor, setMergedDockCursor, todoSetSignature = (todos) => todos.map((todo) => todo.content).sort().join("\x01"), todoSetFirstSeen, TODO_TOOL_NAMES, ACTIVITY_FRAME_BORDER_FALLBACK = "#7aa2f7", ACTIVITY_FRAME_MIN_CONTRAST = 6, ACTIVITY_BLUE_STEPS, BLUE_HUE_MIN = 190, BLUE_HUE_MAX = 250, BLUE_MIN_SATURATION = 0.25, AUTO_POLE_LIGHT = "#ffffff", AUTO_POLE_DARK = "#000000", DOCK_ACCENT_STEPS, DOCK_ACCENT_HUES, DOCK_ACCENT_FALLBACK, ACTIVITY_FRAME_DEFER_MS = 60, activityFrameLatch, COMPACT_TREE_MAX_LINES = 8;
50457
+ var SKIN_FADE_IN_MS = 400, SKIN_NOTICE_FADE_MS = 500, SKIN_PULSE_MS = 1200, SKIN_PULSE_CYCLES = 3, SKIN_PULSE_DIM = 0.45, SKIN_FAINT_MIX = 0.78, ACTIVITY_PANEL_GEARS, ACTIVITY_PANEL_ALL_LINES = 10, activityPanelGear, setActivityPanelGear, DOCK_HEIGHT_ANIM_MS = 200, dockHeightTween, setDockHeightTween, dockHeightSettled = undefined, dockFrameNow = 0, LINE_FIRST_SEEN_MAX = 512, lineFirstSeen, dockSpin, setDockSpin, mergedDockCursor, setMergedDockCursor, todoSetSignature = (todos) => todos.map((todo) => todo.content).sort().join("\x01"), todoSetFirstSeen, TODO_TOOL_NAMES, ACTIVITY_FRAME_BORDER_FALLBACK = "#7aa2f7", ACTIVITY_FRAME_MIN_CONTRAST = 6, ACTIVITY_BLUE_STEPS, BLUE_HUE_MIN = 190, BLUE_HUE_MAX = 250, BLUE_MIN_SATURATION = 0.25, AUTO_POLE_LIGHT = "#ffffff", AUTO_POLE_DARK = "#000000", DOCK_ACCENT_STEPS, DOCK_ACCENT_HUES, DOCK_ACCENT_MIN_CONTRAST = 4.5, DOCK_ACCENT_FALLBACK, ACTIVITY_FRAME_DEFER_MS = 60, activityFrameLatch, COMPACT_TREE_MAX_LINES = 8;
50445
50458
  var init_widgets_dock = __esm(() => {
50446
50459
  init_index_bun();
50447
50460
  init_index_bun();
@@ -50475,11 +50488,15 @@ var init_widgets_dock = __esm(() => {
50475
50488
  ACTIVITY_BLUE_STEPS = [200, 100, 300, 400, 500, 600, 700];
50476
50489
  DOCK_ACCENT_STEPS = {
50477
50490
  think: [200, 300, 100, 400, 500, 600, 700, 800, 900],
50478
- tool: [300, 200, 100, 400, 500, 600, 700, 800, 900]
50491
+ tool: [300, 200, 100, 400, 500, 600, 700, 800, 900],
50492
+ todo: [200, 300, 100, 400, 500, 600, 700, 800, 900],
50493
+ agent: [300, 200, 100, 400, 500, 600, 700, 800, 900]
50479
50494
  };
50480
50495
  DOCK_ACCENT_HUES = {
50481
50496
  think: ["purple", "violet", "accent"],
50482
- tool: ["cyan", "teal", "interactive"]
50497
+ tool: ["cyan", "teal", "interactive"],
50498
+ todo: ["green"],
50499
+ agent: ["blue"]
50483
50500
  };
50484
50501
  DOCK_ACCENT_FALLBACK = {
50485
50502
  think: {
@@ -50489,6 +50506,14 @@ var init_widgets_dock = __esm(() => {
50489
50506
  tool: {
50490
50507
  dark: "#449da7",
50491
50508
  light: "#077786"
50509
+ },
50510
+ todo: {
50511
+ dark: "#7fd88f",
50512
+ light: "#187a3b"
50513
+ },
50514
+ agent: {
50515
+ dark: "#6b82fe",
50516
+ light: "#2b44b8"
50492
50517
  }
50493
50518
  };
50494
50519
  activityFrameLatch = createFrameLatch();
@@ -51794,7 +51819,7 @@ var init_hints_line = __esm(() => {
51794
51819
  },
51795
51820
  quit: {
51796
51821
  idle: "footer.hint.quit",
51797
- busy: "footer.hint.quit"
51822
+ busy: "footer.hint.quit.busy"
51798
51823
  },
51799
51824
  scroll: {
51800
51825
  idle: "footer.hint.scroll",
@@ -54385,6 +54410,10 @@ class TurnOverlayController {
54385
54410
  const asks = (this.#pendingAsks?.() ?? []).filter((ask) => ask.kind === "approval");
54386
54411
  if (asks.length === 0)
54387
54412
  return;
54413
+ const eventId = typeof args.eventId === "string" ? args.eventId : undefined;
54414
+ if (eventId !== undefined) {
54415
+ return asks.find((ask) => ask.eventId === eventId);
54416
+ }
54388
54417
  const callId = typeof args.callId === "string" ? args.callId : undefined;
54389
54418
  if (callId !== undefined) {
54390
54419
  const byCall = asks.filter((ask) => ask.callId === callId);
@@ -55154,6 +55183,29 @@ function presetLabelFor(rows, currentId) {
55154
55183
  const marked = rows.find((row) => row.isDefault) ?? rows.find((row) => row.id === "standard");
55155
55184
  return (marked ?? rows[0])?.name;
55156
55185
  }
55186
+ function isRiskPermissionPreset(value, name) {
55187
+ return /danger-full-access|full.?access|auto/i.test(`${value} ${name ?? ""}`);
55188
+ }
55189
+ function cwdBasename(cwd) {
55190
+ if (cwd === undefined || cwd === "")
55191
+ return;
55192
+ const trimmed = cwd.replace(/[\\/]+$/, "");
55193
+ if (trimmed === "")
55194
+ return cwd;
55195
+ const parts = trimmed.split(/[\\/]/);
55196
+ return parts[parts.length - 1] || trimmed;
55197
+ }
55198
+ function permissionCatalogLines(catalog) {
55199
+ const names = catalog.options.map((option) => option.value).join(", ");
55200
+ const lines = [`available presets: ${names}`];
55201
+ for (const option of catalog.options) {
55202
+ const detail = option.description === undefined || option.description === "" ? "" : ` \u2014 ${option.description}`;
55203
+ lines.push(`${option.value}${detail}`);
55204
+ }
55205
+ lines.push(`default preset: ${catalog.defaultPreset}`);
55206
+ lines.push("current session preset is host-authoritative (not readable here); use /permission <preset> to set it");
55207
+ return lines;
55208
+ }
55157
55209
  function loginStepTitle(stepTitle, error) {
55158
55210
  return error ? `${stepTitle} \u2014 ${error}` : stepTitle;
55159
55211
  }
@@ -56160,6 +56212,87 @@ function coreCommands() {
56160
56212
  ctx.say(t("command.account.failed", { reason: seamFailureReason(error) }));
56161
56213
  }
56162
56214
  }
56215
+ },
56216
+ {
56217
+ name: "/permission",
56218
+ description: t("command.permission.description"),
56219
+ async run(ctx, argText) {
56220
+ const face = ctx.seam.permission;
56221
+ if (!face) {
56222
+ ctx.say(t("command.permission.unavailable"));
56223
+ return;
56224
+ }
56225
+ let catalog;
56226
+ try {
56227
+ catalog = await face.catalog();
56228
+ } catch {
56229
+ catalog = undefined;
56230
+ }
56231
+ if (catalog === undefined) {
56232
+ ctx.say(t("command.permission.catalogUnavailable"));
56233
+ return;
56234
+ }
56235
+ const arg = argText.trim();
56236
+ if (arg === "") {
56237
+ for (const line of permissionCatalogLines(catalog))
56238
+ ctx.say(line);
56239
+ return;
56240
+ }
56241
+ const target = catalog.options.find((option) => option.value === arg || option.name === arg);
56242
+ if (target === undefined) {
56243
+ const names = catalog.options.map((option) => option.value).join(", ");
56244
+ ctx.say(t("command.permission.unknown", { name: arg, available: names }));
56245
+ return;
56246
+ }
56247
+ if (isRiskPermissionPreset(target.value, target.name)) {
56248
+ const verdict = await ctx.pickOne(t("command.permission.riskTitle", { name: target.value }), [
56249
+ { title: t("command.permission.riskAck"), value: "ack" },
56250
+ { title: t("command.permission.cancel"), value: "cancel" }
56251
+ ]);
56252
+ if (verdict !== "ack") {
56253
+ ctx.say(t("command.permission.cancelled"));
56254
+ return;
56255
+ }
56256
+ }
56257
+ try {
56258
+ const result = await face.switch(target.value);
56259
+ if (!result.matched) {
56260
+ ctx.say(t("command.permission.noCommand"));
56261
+ return;
56262
+ }
56263
+ if (!result.ok) {
56264
+ ctx.say(t("command.permission.failed", { reason: result.text || "error" }));
56265
+ return;
56266
+ }
56267
+ ctx.say(t("command.permission.set", { name: target.value }));
56268
+ if (result.text !== "")
56269
+ ctx.say(result.text);
56270
+ await ctx.reload();
56271
+ } catch (error) {
56272
+ ctx.say(t("command.permission.failed", { reason: seamFailureReason(error) }));
56273
+ }
56274
+ }
56275
+ },
56276
+ {
56277
+ name: "/cwd",
56278
+ description: t("command.cwd.description"),
56279
+ async run(ctx) {
56280
+ if (!ctx.seam.cwd) {
56281
+ ctx.say(t("command.cwd.unavailable"));
56282
+ return;
56283
+ }
56284
+ try {
56285
+ const cwd = await ctx.seam.cwd();
56286
+ const label = cwdBasename(cwd);
56287
+ if (label === undefined) {
56288
+ ctx.say(t("command.cwd.none"));
56289
+ return;
56290
+ }
56291
+ ctx.say(t("command.cwd.current", { cwd: label }));
56292
+ } catch (error) {
56293
+ ctx.say(t("command.cwd.failed", { reason: seamFailureReason(error) }));
56294
+ }
56295
+ }
56163
56296
  }
56164
56297
  ];
56165
56298
  }
@@ -64123,7 +64256,8 @@ function viewerRows(views) {
64123
64256
  function viewerRowText(view, roundCap, elapsedText) {
64124
64257
  const glyph = view.status === "running" ? "\u280B" : view.status === "completed" ? "\u2713" : view.status === "failed" ? "\u2717" : view.status === "interrupted" ? "\u2298" : "\u2014";
64125
64258
  const stop = subagentHardStopGlyph(view);
64126
- const label = `${stop ? `${stop} ` : ""}${titlecase(view.label)}`;
64259
+ const namePrefix = subagentNamePrefix(view.name, view.label);
64260
+ const label = `${stop ? `${stop} ` : ""}${namePrefix}${titlecase(view.label)}`;
64127
64261
  const suffix = subagentMarkerSuffix(view);
64128
64262
  const cap = roundCap !== undefined && roundCap > 0 ? `/${roundCap}` : "";
64129
64263
  const elapsed = elapsedText !== undefined && elapsedText !== "" ? ` \xB7 ${elapsedText}` : "";
@@ -64257,10 +64391,10 @@ function SubagentsViewer(props) {
64257
64391
  const id = browsingId();
64258
64392
  if (id === undefined)
64259
64393
  return [];
64260
- const face = props.seam.subagentTranscript;
64261
- if (face === undefined)
64394
+ const seam = props.seam;
64395
+ if (seam.subagentTranscript === undefined)
64262
64396
  return [];
64263
- return face(id);
64397
+ return seam.subagentTranscript(id);
64264
64398
  });
64265
64399
  const window = createMemo(() => transcriptWindow(transcript().length, scrollOffset(), TRANSCRIPT_ROWS));
64266
64400
  function startTicking() {
@@ -64346,12 +64480,12 @@ function SubagentsViewer(props) {
64346
64480
  flash(t("panel.subagents.status.nothingToStop"));
64347
64481
  return;
64348
64482
  }
64349
- const face = props.seam.interruptChild;
64350
- if (face === undefined) {
64483
+ const seam = props.seam;
64484
+ if (seam.interruptChild === undefined) {
64351
64485
  flash(t("panel.subagents.status.stopUnavailable"));
64352
64486
  return;
64353
64487
  }
64354
- face(id).then(() => flash(t("panel.subagents.status.stopRequested", {
64488
+ seam.interruptChild(id).then(() => flash(t("panel.subagents.status.stopRequested", {
64355
64489
  name: titlecase(view.label)
64356
64490
  }))).catch((error) => {
64357
64491
  flash(t("panel.subagents.status.stopFailed", {
@@ -64674,7 +64808,7 @@ var init_subagents_viewer = __esm(() => {
64674
64808
  import { TextAttributes as TextAttributes12 } from "@opentui/core";
64675
64809
  function resolveVersion() {
64676
64810
  try {
64677
- return "0.25.0";
64811
+ return "0.26.1";
64678
64812
  } catch {
64679
64813
  return "dev";
64680
64814
  }
@@ -67755,6 +67889,39 @@ var init_bridge_goals = __esm(() => {
67755
67889
  ACTIVATIONS = ["armed", "disarmed"];
67756
67890
  });
67757
67891
 
67892
+ // src/client/bridge-permission.ts
67893
+ function asRecord10(value) {
67894
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
67895
+ }
67896
+ function unwrapWireValue3(raw) {
67897
+ const rec = asRecord10(raw);
67898
+ if (Object.prototype.hasOwnProperty.call(rec, "value"))
67899
+ return rec.value;
67900
+ return raw;
67901
+ }
67902
+ function cleanText(value, max = MAX_TEXT4) {
67903
+ if (typeof value !== "string")
67904
+ return;
67905
+ return value.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").slice(0, max);
67906
+ }
67907
+ function projectPermissionSwitch(raw) {
67908
+ const value = unwrapWireValue3(raw);
67909
+ if (value === null || value === undefined) {
67910
+ return { ok: false, matched: false, text: "" };
67911
+ }
67912
+ const rec = asRecord10(value);
67913
+ const empty = Object.keys(rec).length === 0;
67914
+ if (empty)
67915
+ return { ok: false, matched: false, text: "" };
67916
+ const result = asRecord10(rec.result);
67917
+ const kind = cleanText(result.kind, MAX_SHORT4) ?? cleanText(rec.kind, MAX_SHORT4);
67918
+ const text = cleanText(result.text, MAX_TEXT4) ?? cleanText(rec.text, MAX_TEXT4) ?? "";
67919
+ if (kind === undefined && text === "")
67920
+ return { ok: false, matched: false, text: "" };
67921
+ return { ok: kind !== "error", matched: true, text };
67922
+ }
67923
+ var MAX_TEXT4 = 4096, MAX_SHORT4 = 240;
67924
+
67758
67925
  // src/client/bridge-session-seam.ts
67759
67926
  import { existsSync as existsSync13, readFileSync as readFileSync14, readdirSync as readdirSync4 } from "fs";
67760
67927
  import { join as join16 } from "path";
@@ -67771,7 +67938,7 @@ function optionalStringField(row, key) {
67771
67938
  return typeof value === "string" && value !== "" ? value : undefined;
67772
67939
  }
67773
67940
  function parseAskRequest(value) {
67774
- const row = asRecord10(value);
67941
+ const row = asRecord11(value);
67775
67942
  const eventId = optionalStringField(row, "eventId");
67776
67943
  const sessionId = optionalStringField(row, "sessionId");
67777
67944
  const kind = row.kind;
@@ -67779,7 +67946,7 @@ function parseAskRequest(value) {
67779
67946
  return;
67780
67947
  }
67781
67948
  const out = { eventId, sessionId, kind };
67782
- for (const key of ["toolName", "callId", "reason"]) {
67949
+ for (const key of ["toolName", "callId", "reason", "childSessionId", "parentSessionId"]) {
67783
67950
  const v = optionalStringField(row, key);
67784
67951
  if (v !== undefined)
67785
67952
  out[key] = v;
@@ -67794,14 +67961,14 @@ function parseAskRequest(value) {
67794
67961
  if (Array.isArray(row.questions)) {
67795
67962
  const questions = [];
67796
67963
  for (const raw of row.questions) {
67797
- const q = asRecord10(raw);
67964
+ const q = asRecord11(raw);
67798
67965
  const id = optionalStringField(q, "id");
67799
67966
  const prompt = optionalStringField(q, "prompt");
67800
67967
  if (id === undefined || prompt === undefined || !Array.isArray(q.options))
67801
67968
  continue;
67802
67969
  const options = [];
67803
67970
  for (const rawOpt of q.options) {
67804
- const opt = asRecord10(rawOpt);
67971
+ const opt = asRecord11(rawOpt);
67805
67972
  const label = optionalStringField(opt, "label");
67806
67973
  if (label === undefined)
67807
67974
  continue;
@@ -67828,7 +67995,8 @@ function parseAskRequest(value) {
67828
67995
  function approvalArgs(request) {
67829
67996
  return {
67830
67997
  ...request.callId !== undefined ? { callId: request.callId } : {},
67831
- ...request.reason !== undefined ? { reason: request.reason } : {}
67998
+ ...request.reason !== undefined ? { reason: request.reason } : {},
67999
+ ...request.parentSessionId !== undefined ? { eventId: request.eventId } : {}
67832
68000
  };
67833
68001
  }
67834
68002
  function approvalQuestion(request) {
@@ -67871,11 +68039,11 @@ function answersFor(request, picks) {
67871
68039
  function unavailableResponse(request) {
67872
68040
  return request.kind === "questions" ? { eventId: request.eventId, kind: "questions", verdict: "unavailable", answers: answersFor(request, []) } : { eventId: request.eventId, kind: "approval", verdict: "unavailable" };
67873
68041
  }
67874
- function asRecord10(value) {
68042
+ function asRecord11(value) {
67875
68043
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
67876
68044
  }
67877
68045
  function projectSeamAccountView(value) {
67878
- const v = asRecord10(value);
68046
+ const v = asRecord11(value);
67879
68047
  return {
67880
68048
  status: typeof v.status === "string" && ACCOUNT_STATUSES.has(v.status) ? v.status : null,
67881
68049
  attemptPhase: typeof v.attemptPhase === "string" && ACCOUNT_PHASES.has(v.attemptPhase) ? v.attemptPhase : null,
@@ -67897,14 +68065,14 @@ function projectBridgeSessionList(items, limit = 12) {
67897
68065
  const rows = Array.isArray(items) ? items : [];
67898
68066
  const out = [];
67899
68067
  for (const item of rows) {
67900
- const row = asRecord10(item);
68068
+ const row = asRecord11(item);
67901
68069
  if (row.origin === "subagent")
67902
68070
  continue;
67903
68071
  const id = typeof row.sessionId === "string" ? row.sessionId : "";
67904
68072
  if (!id)
67905
68073
  continue;
67906
68074
  const updatedAt = typeof row.updatedAt === "number" ? String(row.updatedAt) : "";
67907
- const values = asRecord10(asRecord10(row.projections).values);
68075
+ const values = asRecord11(asRecord11(row.projections).values);
67908
68076
  const title = typeof values.title === "string" ? values.title : "";
67909
68077
  out.push({
67910
68078
  id,
@@ -67917,12 +68085,23 @@ function projectBridgeSessionList(items, limit = 12) {
67917
68085
  }
67918
68086
  return out.sort((a, b) => String(b.updatedAt ?? "").localeCompare(String(a.updatedAt ?? ""))).slice(0, limit);
67919
68087
  }
68088
+ function projectCurrentCwd(items, sessionId) {
68089
+ if (sessionId === undefined || sessionId === "" || !Array.isArray(items))
68090
+ return;
68091
+ for (const item of items) {
68092
+ const row = asRecord11(item);
68093
+ if (row.sessionId !== sessionId)
68094
+ continue;
68095
+ return typeof row.cwd === "string" && row.cwd !== "" ? row.cwd : undefined;
68096
+ }
68097
+ return;
68098
+ }
67920
68099
  function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
67921
68100
  const entries = rows.map((row) => ({
67922
68101
  type: row.type,
67923
68102
  seq: row.seq,
67924
68103
  time: 0,
67925
- data: asRecord10(row.payload)
68104
+ data: asRecord11(row.payload)
67926
68105
  }));
67927
68106
  const durable = journalToTranscriptRows(entries, skip);
67928
68107
  return durable.map((row) => {
@@ -67936,8 +68115,8 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
67936
68115
  });
67937
68116
  }
67938
68117
  function seamReplayEventKey(event) {
67939
- const details = asRecord10(event.details);
67940
- return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord10(details.part).id ?? "")}`;
68118
+ const details = asRecord11(event.details);
68119
+ return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord11(details.part).id ?? "")}`;
67941
68120
  }
67942
68121
  function bridgeReplayRowsToSeamEvents(rows, sessionId) {
67943
68122
  const events = [];
@@ -67951,7 +68130,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
67951
68130
  };
67952
68131
  const toolCalls = new Map;
67953
68132
  for (const row of rows) {
67954
- const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord10(row.payload) };
68133
+ const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord11(row.payload) };
67955
68134
  for (const event of projectJournalRecord(entry, sessionId))
67956
68135
  push(event);
67957
68136
  const data = entry.data;
@@ -67965,7 +68144,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
67965
68144
  });
67966
68145
  }
67967
68146
  } else if (row.type === "tool/result") {
67968
- const message = asRecord10(data.message);
68147
+ const message = asRecord11(data.message);
67969
68148
  const callId = data.callId !== undefined ? String(data.callId) : message.toolCallId !== undefined ? String(message.toolCallId) : "";
67970
68149
  const call = callId ? toolCalls.get(callId) : undefined;
67971
68150
  if (call !== undefined) {
@@ -68006,6 +68185,7 @@ function bridgeSettleChild(existing, outcome, startedAt, now) {
68006
68185
  return {
68007
68186
  id: existing.id,
68008
68187
  label: existing.label,
68188
+ ...existing.name !== undefined ? { name: existing.name } : {},
68009
68189
  ...existing.model !== undefined ? { model: existing.model } : {},
68010
68190
  status: bridgeSettledStatus(outcome),
68011
68191
  rounds: existing.rounds,
@@ -68018,8 +68198,9 @@ function bridgeSettleChild(existing, outcome, startedAt, now) {
68018
68198
  };
68019
68199
  }
68020
68200
  function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, live) {
68201
+ const name = typeof data.name === "string" && data.name !== "" ? data.name : undefined;
68021
68202
  if (type === "user/message") {
68022
- const source = asRecord10(data.source);
68203
+ const source = asRecord11(data.source);
68023
68204
  if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
68024
68205
  return false;
68025
68206
  const childId = typeof source.senderSessionId === "string" ? source.senderSessionId : "";
@@ -68040,9 +68221,11 @@ function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, li
68040
68221
  const existing = children.get(childId);
68041
68222
  if (existing !== undefined && existing.status !== "running") {
68042
68223
  runSeq.set(bridgeAgentRunKey(`${BRIDGE_CATALOG_RUN_PREFIX}${childId}`, 0), childId);
68224
+ const revivedName = name ?? existing.name;
68043
68225
  children.set(childId, {
68044
68226
  id: existing.id,
68045
68227
  label: label || existing.label,
68228
+ ...revivedName !== undefined ? { name: revivedName } : {},
68046
68229
  status: "running",
68047
68230
  rounds: 0,
68048
68231
  startedAt: childCreatedAt ?? now,
@@ -68057,6 +68240,7 @@ function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, li
68057
68240
  label,
68058
68241
  runId: `${BRIDGE_CATALOG_RUN_PREFIX}${childId}`,
68059
68242
  seq: 0,
68243
+ ...name !== undefined ? { name } : {},
68060
68244
  ...childCreatedAt !== undefined ? { childCreatedAt } : {},
68061
68245
  viaCatalog: true
68062
68246
  }, now, live);
@@ -68075,12 +68259,14 @@ function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, li
68075
68259
  if (existing !== undefined) {
68076
68260
  const newLabel = typeof data.label === "string" ? data.label : "";
68077
68261
  const labelChanged = newLabel !== "" && newLabel !== existing.label;
68262
+ const nameChanged = name !== undefined && name !== existing.name;
68078
68263
  const upgradeStart = live && existing.status === "running" && !liveStarts.has(childId);
68079
- if (!labelChanged && !upgradeStart)
68264
+ if (!labelChanged && !nameChanged && !upgradeStart)
68080
68265
  return false;
68081
68266
  children.set(childId, {
68082
68267
  ...existing,
68083
68268
  ...labelChanged ? { label: newLabel } : {},
68269
+ ...nameChanged ? { name } : {},
68084
68270
  ...upgradeStart ? { startedAt: childCreatedAt ?? now } : {}
68085
68271
  });
68086
68272
  if (upgradeStart)
@@ -68088,7 +68274,14 @@ function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, li
68088
68274
  return true;
68089
68275
  }
68090
68276
  const label = typeof data.label === "string" && data.label ? data.label : `subagent ${childId.slice(0, 8)}`;
68091
- children.set(childId, { id: childId, label, status: "running", rounds: 0, startedAt: childCreatedAt ?? now });
68277
+ children.set(childId, {
68278
+ id: childId,
68279
+ label,
68280
+ status: "running",
68281
+ rounds: 0,
68282
+ startedAt: childCreatedAt ?? now,
68283
+ ...name !== undefined ? { name } : {}
68284
+ });
68092
68285
  if (live)
68093
68286
  liveStarts.add(childId);
68094
68287
  return true;
@@ -68114,7 +68307,7 @@ function bridgeSweepSettledChildIds(rows, parentId, locallyRunning) {
68114
68307
  return [];
68115
68308
  const settled = [];
68116
68309
  for (const raw of rows) {
68117
- const row = asRecord10(raw);
68310
+ const row = asRecord11(raw);
68118
68311
  if (row.origin !== "subagent")
68119
68312
  continue;
68120
68313
  if (row.parentSessionId !== parentId)
@@ -68164,16 +68357,16 @@ function bridgeChildJournalMeta(rows) {
68164
68357
  let contextModel;
68165
68358
  let descriptorModel;
68166
68359
  for (const row of rows) {
68167
- const data = asRecord10(row.payload);
68360
+ const data = asRecord11(row.payload);
68168
68361
  if (row.type === "assistant/message") {
68169
68362
  rounds += 1;
68170
- const message = asRecord10(data.message);
68363
+ const message = asRecord11(data.message);
68171
68364
  const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
68172
68365
  if (tail !== undefined)
68173
68366
  lastLine = tail;
68174
68367
  } else if (row.type === "tool/result") {
68175
68368
  if (data.isError !== true) {
68176
- const message = asRecord10(data.message);
68369
+ const message = asRecord11(data.message);
68177
68370
  const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
68178
68371
  if (tail !== undefined)
68179
68372
  lastLine = tail;
@@ -68211,7 +68404,7 @@ function bridgeChildStopReason(rows) {
68211
68404
  const row = rows[i];
68212
68405
  if (row.type !== "user/message")
68213
68406
  continue;
68214
- const source = asRecord10(asRecord10(row.payload).source);
68407
+ const source = asRecord11(asRecord11(row.payload).source);
68215
68408
  if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
68216
68409
  continue;
68217
68410
  const reason = source.stopReason;
@@ -68222,7 +68415,7 @@ function bridgeChildStopReason(rows) {
68222
68415
  const row = rows[i];
68223
68416
  if (row.type !== "turn/end")
68224
68417
  continue;
68225
- const reason = asRecord10(asRecord10(row.payload).reason);
68418
+ const reason = asRecord11(asRecord11(row.payload).reason);
68226
68419
  const kind = reason.kind;
68227
68420
  if (typeof kind === "string" && kind !== "")
68228
68421
  return kind;
@@ -68280,7 +68473,7 @@ function lastJournalTurnTerminal(rows, startOutsideWindow = false) {
68280
68473
  return latest;
68281
68474
  }
68282
68475
  function journalTurnId(row) {
68283
- const payload = asRecord10(row.payload);
68476
+ const payload = asRecord11(row.payload);
68284
68477
  if (typeof payload.turn === "number" && Number.isFinite(payload.turn))
68285
68478
  return payload.turn;
68286
68479
  if (typeof payload.turnId === "string" && payload.turnId !== "")
@@ -68288,7 +68481,7 @@ function journalTurnId(row) {
68288
68481
  return;
68289
68482
  }
68290
68483
  function projectBridgeEvent(frame, sessionId) {
68291
- const payload = asRecord10(frame.payload);
68484
+ const payload = asRecord11(frame.payload);
68292
68485
  const turnId = typeof payload.turnId === "string" ? payload.turnId : "";
68293
68486
  if (frame.type === "turn.start") {
68294
68487
  return [{ type: "session.updated", details: { sessionID: sessionId, turnId, turn: "starting" } }];
@@ -68310,7 +68503,7 @@ function projectBridgeEvent(frame, sessionId) {
68310
68503
  return [];
68311
68504
  }
68312
68505
  function parseUsage(value) {
68313
- const u = asRecord10(value);
68506
+ const u = asRecord11(value);
68314
68507
  const num = (...aliases) => {
68315
68508
  let present = false;
68316
68509
  let best = 0;
@@ -68339,7 +68532,7 @@ function parseUsage(value) {
68339
68532
  return out;
68340
68533
  }
68341
68534
  function journalUsage(payload) {
68342
- const usage = asRecord10(asRecord10(payload).usage);
68535
+ const usage = asRecord11(asRecord11(payload).usage);
68343
68536
  const parsed = parseUsage(usage);
68344
68537
  if (Object.keys(parsed).length === 0)
68345
68538
  return;
@@ -68349,7 +68542,7 @@ function journalUsage(payload) {
68349
68542
  return { ...parsed, total };
68350
68543
  }
68351
68544
  function asDeadCause(value) {
68352
- const r = asRecord10(value);
68545
+ const r = asRecord11(value);
68353
68546
  const stage = r.stage;
68354
68547
  const stages = ["spawn", "handshake", "runtime", "closed"];
68355
68548
  return {
@@ -68381,6 +68574,10 @@ class BridgeSessionSeam {
68381
68574
  identity: () => ({ profile: this.#profile, dshHome: this.#dshHome }),
68382
68575
  permissionCatalog: () => this.#readPermissionCatalog()
68383
68576
  };
68577
+ permission = {
68578
+ catalog: () => this.#readPermissionCatalog(),
68579
+ switch: (preset) => this.#permissionSwitch(preset)
68580
+ };
68384
68581
  providerDirectory = {
68385
68582
  registered: () => this.#directoryRequest("llm.listProviders", projectLlmProviders),
68386
68583
  configurable: () => this.#directoryRequest("llm.listConfigurableProviders", projectConfigurableProviders),
@@ -68433,7 +68630,7 @@ class BridgeSessionSeam {
68433
68630
  cancelSignIn: async (attemptId) => projectSeamAccountView(await this.#transport.request("account.cancelSignIn", { attemptId })),
68434
68631
  signOut: async () => projectSeamAccountView(await this.#transport.request("account.signOut", { client: accountClientMeta() })),
68435
68632
  hasRunningAccountTasks: async () => {
68436
- const value = asRecord10(await this.#transport.request("account.hasRunningAccountTasks"));
68633
+ const value = asRecord11(await this.#transport.request("account.hasRunningAccountTasks"));
68437
68634
  return value.running === true;
68438
68635
  }
68439
68636
  };
@@ -68495,6 +68692,19 @@ class BridgeSessionSeam {
68495
68692
  return;
68496
68693
  }
68497
68694
  }
68695
+ async#permissionSwitch(preset) {
68696
+ const agentId = this.currentSessionId();
68697
+ if (agentId === undefined || agentId === "") {
68698
+ throw new BridgeProtocolError("UNSUPPORTED", "permission.switch: no active session (agentId unavailable)");
68699
+ }
68700
+ const line = `/permission ${preset}`;
68701
+ const reply = await this.#transport.request("commands.execute", {
68702
+ agentId,
68703
+ line,
68704
+ submittedAttachments: []
68705
+ });
68706
+ return projectPermissionSwitch(reply);
68707
+ }
68498
68708
  async#goalsRequest(method, extraParams, project) {
68499
68709
  const agentId = this.currentSessionId();
68500
68710
  if (agentId === undefined || agentId === "") {
@@ -68595,7 +68805,7 @@ class BridgeSessionSeam {
68595
68805
  effortsFor: (providerID, modelID) => this.#catalogEfforts(providerID, modelID),
68596
68806
  currentEffort: async () => {
68597
68807
  const selection = await this.#transport.request("model.currentSelection");
68598
- const value = asRecord10(selection).reasoningEffort;
68808
+ const value = asRecord11(selection).reasoningEffort;
68599
68809
  return typeof value === "string" && value !== "" ? value : undefined;
68600
68810
  },
68601
68811
  selectEffort: async (effort) => {
@@ -68631,7 +68841,7 @@ class BridgeSessionSeam {
68631
68841
  return [];
68632
68842
  const out = [];
68633
68843
  for (const e of efforts) {
68634
- const row = asRecord10(e);
68844
+ const row = asRecord11(e);
68635
68845
  const id = typeof row.id === "string" ? row.id : "";
68636
68846
  const name = typeof row.name === "string" ? row.name : "";
68637
68847
  if (!id)
@@ -68728,7 +68938,7 @@ class BridgeSessionSeam {
68728
68938
  }
68729
68939
  async connect() {
68730
68940
  try {
68731
- const reply = asRecord10(await this.#transport.request("bridge.ping"));
68941
+ const reply = asRecord11(await this.#transport.request("bridge.ping"));
68732
68942
  this.#recordBridgeCapabilities(reply.capabilities);
68733
68943
  this.#connection = "connected";
68734
68944
  } catch (err) {
@@ -68815,7 +69025,7 @@ class BridgeSessionSeam {
68815
69025
  this.#replayDrainPending = true;
68816
69026
  let opened;
68817
69027
  try {
68818
- opened = asRecord10(await this.#transport.request("session.open", { mode: "resume", id: sessionId }));
69028
+ opened = asRecord11(await this.#transport.request("session.open", { mode: "resume", id: sessionId }));
68819
69029
  } catch (err) {
68820
69030
  const code = err instanceof BridgeProtocolError ? err.code : "SESSION_OPEN_FAILED";
68821
69031
  const message = err instanceof Error ? err.message : String(err);
@@ -68825,7 +69035,7 @@ class BridgeSessionSeam {
68825
69035
  this.#bufferedPendingSnapshot = undefined;
68826
69036
  this.#replayDrainPending = false;
68827
69037
  this.#settleSuspendedTurn();
68828
- const errorDetail = err instanceof BridgeProtocolError ? asRecord10(err.detail) : {};
69038
+ const errorDetail = err instanceof BridgeProtocolError ? asRecord11(err.detail) : {};
68829
69039
  const holder = typeof errorDetail.holder === "string" && errorDetail.holder.trim() !== "" ? errorDetail.holder : undefined;
68830
69040
  const result = {
68831
69041
  state: "locked",
@@ -68900,7 +69110,7 @@ class BridgeSessionSeam {
68900
69110
  turnId: dead.turnId,
68901
69111
  seq: terminal.seq,
68902
69112
  terminalType: terminal.type,
68903
- reason: asRecord10(terminal.payload).reason,
69113
+ reason: asRecord11(terminal.payload).reason,
68904
69114
  payload: terminal.payload,
68905
69115
  source: "journal"
68906
69116
  }
@@ -68958,7 +69168,7 @@ class BridgeSessionSeam {
68958
69168
  const seen = new Set;
68959
69169
  const collected = [];
68960
69170
  for (;; ) {
68961
- const value = asRecord10(await this.#transport.request("journal.replay", { sessionId, from }));
69171
+ const value = asRecord11(await this.#transport.request("journal.replay", { sessionId, from }));
68962
69172
  const rawRows = Array.isArray(value.rows) ? value.rows : [];
68963
69173
  if (typeof value.cursor === "number" && Number.isFinite(value.cursor))
68964
69174
  cursor = value.cursor;
@@ -68971,7 +69181,7 @@ class BridgeSessionSeam {
68971
69181
  let added = 0;
68972
69182
  let pageMax = from - 1;
68973
69183
  for (const raw of rawRows) {
68974
- const row = asRecord10(raw);
69184
+ const row = asRecord11(raw);
68975
69185
  const seq = row.seq;
68976
69186
  if (typeof seq !== "number" || !Number.isFinite(seq) || seq < floor || seen.has(seq))
68977
69187
  continue;
@@ -69020,7 +69230,7 @@ class BridgeSessionSeam {
69020
69230
  };
69021
69231
  const attempt = (remaining) => {
69022
69232
  this.#transport.request("turn.abort", { turnId }).then((result) => {
69023
- if (asRecord10(result).noop === true) {
69233
+ if (asRecord11(result).noop === true) {
69024
69234
  fail(`turn.abort was a noop for turn ${turnId}; turn may still be running`, "TURN_ABORT_NOOP");
69025
69235
  }
69026
69236
  }).catch((err) => {
@@ -69156,7 +69366,7 @@ class BridgeSessionSeam {
69156
69366
  stats.contextTokens = usage.total;
69157
69367
  }
69158
69368
  } else if (row.type === "request/context") {
69159
- const data = asRecord10(row.payload);
69369
+ const data = asRecord11(row.payload);
69160
69370
  const window = data.contextWindow;
69161
69371
  if (typeof window === "number" && Number.isFinite(window) && window > 0) {
69162
69372
  const provider = typeof data.provider === "string" ? data.provider : "";
@@ -69290,7 +69500,7 @@ class BridgeSessionSeam {
69290
69500
  this.#interruptInFlight.set(childId, generation);
69291
69501
  let value;
69292
69502
  try {
69293
- value = asRecord10(await this.#transport.request("subagents.interrupt", { parentSessionId, childId }));
69503
+ value = asRecord11(await this.#transport.request("subagents.interrupt", { parentSessionId, childId }));
69294
69504
  } catch (err) {
69295
69505
  if (this.#interruptInFlight.get(childId) === generation)
69296
69506
  this.#interruptInFlight.delete(childId);
@@ -69316,13 +69526,13 @@ class BridgeSessionSeam {
69316
69526
  if (parentSessionId === undefined || parentSessionId === "") {
69317
69527
  throw new BridgeProtocolError("NO_SESSION", "cannot stop children: no session is bound to this bridge connection");
69318
69528
  }
69319
- const value = asRecord10(await this.#transport.request("subagents.stopChildren", { parentSessionId }));
69529
+ const value = asRecord11(await this.#transport.request("subagents.stopChildren", { parentSessionId }));
69320
69530
  const children = value.children;
69321
69531
  if (!Array.isArray(children))
69322
69532
  return [];
69323
69533
  const sessionAtStart = this.#subagentSessionId;
69324
69534
  const rows = children.map((row) => {
69325
- const r = asRecord10(row);
69535
+ const r = asRecord11(row);
69326
69536
  return {
69327
69537
  childId: typeof r.childId === "string" ? r.childId : "",
69328
69538
  disposition: typeof r.disposition === "string" ? r.disposition : "failed"
@@ -69348,10 +69558,10 @@ class BridgeSessionSeam {
69348
69558
  return;
69349
69559
  let stopped = false;
69350
69560
  try {
69351
- const items = asRecord10(await this.#transport.request("session.list", { _request: {} })).items;
69561
+ const items = asRecord11(await this.#transport.request("session.list", { _request: {} })).items;
69352
69562
  if (Array.isArray(items)) {
69353
69563
  stopped = items.some((row) => {
69354
- const item = asRecord10(row);
69564
+ const item = asRecord11(row);
69355
69565
  return item.sessionId === childId && item.running === false;
69356
69566
  });
69357
69567
  }
@@ -69361,7 +69571,7 @@ class BridgeSessionSeam {
69361
69571
  if (stopped) {
69362
69572
  let reason = "aborted";
69363
69573
  try {
69364
- const rows = asRecord10(await this.#transport.request("journal.replay", { sessionId: childId })).rows;
69574
+ const rows = asRecord11(await this.#transport.request("journal.replay", { sessionId: childId })).rows;
69365
69575
  if (Array.isArray(rows)) {
69366
69576
  const clean = rows.filter((row) => row !== null && typeof row === "object" && !Array.isArray(row));
69367
69577
  reason = bridgeChildStopReason(clean) ?? "aborted";
@@ -69420,7 +69630,7 @@ class BridgeSessionSeam {
69420
69630
  } catch {
69421
69631
  return;
69422
69632
  }
69423
- const items = asRecord10(value).items;
69633
+ const items = asRecord11(value).items;
69424
69634
  if (!Array.isArray(items))
69425
69635
  return;
69426
69636
  const locallyRunning = new Set;
@@ -69465,7 +69675,7 @@ class BridgeSessionSeam {
69465
69675
  this.#subagentJournalLoaded.add(key);
69466
69676
  const sessionAtStart = this.#subagentSessionId;
69467
69677
  try {
69468
- const value = asRecord10(await this.#transport.request("journal.replay", { sessionId: childId }));
69678
+ const value = asRecord11(await this.#transport.request("journal.replay", { sessionId: childId }));
69469
69679
  const rows = value.rows;
69470
69680
  if (!Array.isArray(rows))
69471
69681
  return;
@@ -69572,7 +69782,7 @@ class BridgeSessionSeam {
69572
69782
  }
69573
69783
  }
69574
69784
  #foldAgentFrame(frame) {
69575
- const payload = asRecord10(frame.payload);
69785
+ const payload = asRecord11(frame.payload);
69576
69786
  const frameSession = typeof payload.sessionId === "string" ? payload.sessionId : "";
69577
69787
  if (this.#subagentSessionId !== undefined && frameSession !== "" && frameSession !== this.#subagentSessionId)
69578
69788
  return;
@@ -69609,7 +69819,7 @@ class BridgeSessionSeam {
69609
69819
  let changed = false;
69610
69820
  const now = Date.now();
69611
69821
  for (const row of rows) {
69612
- if (this.#foldWithFrozenSettle(row.type, asRecord10(row.payload), now, false))
69822
+ if (this.#foldWithFrozenSettle(row.type, asRecord11(row.payload), now, false))
69613
69823
  changed = true;
69614
69824
  }
69615
69825
  if (rosterReset || changed) {
@@ -69643,27 +69853,34 @@ class BridgeSessionSeam {
69643
69853
  }
69644
69854
  async listSessions(limit) {
69645
69855
  const value = await this.#transport.request("session.list");
69646
- return projectBridgeSessionList(asRecord10(value).items, limit);
69856
+ return projectBridgeSessionList(asRecord11(value).items, limit);
69857
+ }
69858
+ async cwd() {
69859
+ const sessionId = this.currentSessionId();
69860
+ if (sessionId === undefined || sessionId === "")
69861
+ return;
69862
+ const value = await this.#transport.request("session.list");
69863
+ return projectCurrentCwd(asRecord11(value).items, sessionId);
69647
69864
  }
69648
69865
  async storedTranscript(id, skip = 0) {
69649
69866
  const value = await this.#transport.request("journal.replay", { sessionId: id });
69650
- const rows = Array.isArray(asRecord10(value).rows) ? asRecord10(value).rows : [];
69867
+ const rows = Array.isArray(asRecord11(value).rows) ? asRecord11(value).rows : [];
69651
69868
  this.#foldAgentReplayRows(rows, id);
69652
69869
  this.#sweepSubagents(id);
69653
69870
  return bridgeReplayRowsToSeamTranscript(rows, skip);
69654
69871
  }
69655
69872
  async sessionJournal(id) {
69656
69873
  const value = await this.#transport.request("journal.replay", { sessionId: id });
69657
- const rows = Array.isArray(asRecord10(value).rows) ? asRecord10(value).rows : [];
69874
+ const rows = Array.isArray(asRecord11(value).rows) ? asRecord11(value).rows : [];
69658
69875
  return rows.map((row) => ({
69659
69876
  type: row.type,
69660
69877
  seq: row.seq,
69661
69878
  time: 0,
69662
- data: asRecord10(row.payload)
69879
+ data: asRecord11(row.payload)
69663
69880
  }));
69664
69881
  }
69665
69882
  async forkSession(sessionId, seqEnd) {
69666
- const value = asRecord10(await this.#transport.request("session.fork", {
69883
+ const value = asRecord11(await this.#transport.request("session.fork", {
69667
69884
  sessionId,
69668
69885
  ...seqEnd !== undefined ? { atSeq: seqEnd } : {}
69669
69886
  }));
@@ -69677,7 +69894,7 @@ class BridgeSessionSeam {
69677
69894
  const selection = await this.#transport.request("model.currentSelection");
69678
69895
  if (selection === undefined || selection === null)
69679
69896
  return;
69680
- const s = asRecord10(selection);
69897
+ const s = asRecord11(selection);
69681
69898
  const providerID = typeof s.provider === "string" ? s.provider : "";
69682
69899
  const modelID = typeof s.model === "string" ? s.model : "";
69683
69900
  if (!providerID || !modelID)
@@ -69714,7 +69931,7 @@ class BridgeSessionSeam {
69714
69931
  this.#pendingOpen = undefined;
69715
69932
  const params = pending.mode === "resume" ? { mode: "resume", id: pending.id, ...this.#sessionAttached ? { replace: true } : {} } : { mode: "new", ...this.#sessionAttached ? { replace: true } : {} };
69716
69933
  try {
69717
- const opened = asRecord10(await this.#transport.request("session.open", params));
69934
+ const opened = asRecord11(await this.#transport.request("session.open", params));
69718
69935
  if (typeof opened.sessionId === "string")
69719
69936
  this.#currentSessionId = opened.sessionId;
69720
69937
  if (this.#lastAppliedSessionId !== this.#currentSessionId) {
@@ -69731,7 +69948,7 @@ class BridgeSessionSeam {
69731
69948
  const done = new Promise((resolve) => {
69732
69949
  this.#turnDone = resolve;
69733
69950
  });
69734
- const sent = asRecord10(await this.#transport.request("session.send", { text: userText }));
69951
+ const sent = asRecord11(await this.#transport.request("session.send", { text: userText }));
69735
69952
  if (typeof sent.turnId === "string") {
69736
69953
  this.#inFlightTurnId = sent.turnId;
69737
69954
  this.#emitEvent({
@@ -69824,10 +70041,10 @@ class BridgeSessionSeam {
69824
70041
  }
69825
70042
  }
69826
70043
  async searchSessions(query) {
69827
- const value = asRecord10(await this.#transport.request("session.search", { query }));
70044
+ const value = asRecord11(await this.#transport.request("session.search", { query }));
69828
70045
  const rows = Array.isArray(value.items) ? value.items : [];
69829
70046
  return rows.map((row) => {
69830
- const r = asRecord10(row);
70047
+ const r = asRecord11(row);
69831
70048
  return {
69832
70049
  id: typeof r.id === "string" ? r.id : "",
69833
70050
  snippet: typeof r.snippet === "string" ? r.snippet : ""
@@ -70007,15 +70224,22 @@ class BridgeSessionSeam {
70007
70224
  for (const eventId of [...this.#pendingAsks.keys()])
70008
70225
  this.#settlePendingAsk(eventId);
70009
70226
  }
70227
+ #mountAskOnParentTrajectory(request) {
70228
+ const parent = request.parentSessionId;
70229
+ if (parent === undefined || parent === request.sessionId)
70230
+ return request;
70231
+ return { ...request, sessionId: parent };
70232
+ }
70010
70233
  #onAskEvent(frame) {
70011
- const payload = asRecord10(frame.payload);
70234
+ const payload = asRecord11(frame.payload);
70012
70235
  if (frame.type === "ask.request" || frame.type === "ask.pending")
70013
70236
  this.#askFrameSeen = true;
70014
70237
  switch (frame.type) {
70015
70238
  case "ask.request": {
70016
70239
  const request = parseAskRequest(frame.payload);
70017
- if (request !== undefined)
70018
- this.#enqueueAsk(request);
70240
+ if (request !== undefined) {
70241
+ this.#enqueueAsk(this.#mountAskOnParentTrajectory(request));
70242
+ }
70019
70243
  return true;
70020
70244
  }
70021
70245
  case "ask.cancel": {
@@ -70068,7 +70292,7 @@ class BridgeSessionSeam {
70068
70292
  #onCapPushEvent(frame) {
70069
70293
  if (frame.type !== "cap.event" && frame.type !== "cap.end")
70070
70294
  return false;
70071
- const payload = asRecord10(frame.payload);
70295
+ const payload = asRecord11(frame.payload);
70072
70296
  const sessionId = optionalStringField(payload, "sessionId");
70073
70297
  if (sessionId === undefined || sessionId === "")
70074
70298
  return true;
@@ -70142,7 +70366,7 @@ class BridgeSessionSeam {
70142
70366
  }
70143
70367
  return;
70144
70368
  }
70145
- const payload = asRecord10(frame.payload);
70369
+ const payload = asRecord11(frame.payload);
70146
70370
  if (frame.type === "turn.start") {
70147
70371
  this.#turn = "starting";
70148
70372
  this.#decodeWindowStart = undefined;
@@ -70361,11 +70585,11 @@ function toBridgeBootstrapError(err, fallbackCode = "BRIDGE_HANDSHAKE_FAILED") {
70361
70585
  const message = err instanceof Error ? err.message : String(err);
70362
70586
  return new BridgeBootstrapError({ code: fallbackCode, diagnosis: `bridge handshake failed: ${message}` });
70363
70587
  }
70364
- function asRecord11(value) {
70588
+ function asRecord12(value) {
70365
70589
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
70366
70590
  }
70367
70591
  function verifyBridgeFingerprint(hello, expectedProtocolVersion = BRIDGE_PROTOCOL_VERSION) {
70368
- const h = asRecord11(hello);
70592
+ const h = asRecord12(hello);
70369
70593
  const protocolVersion = h.protocolVersion;
70370
70594
  if (protocolVersion !== expectedProtocolVersion) {
70371
70595
  throw new BridgeBootstrapError({
@@ -71518,7 +71742,7 @@ function recoveryCause(err, phase) {
71518
71742
  };
71519
71743
  }
71520
71744
  if (err instanceof BridgeProtocolError && err.code === "BRIDGE_DEAD") {
71521
- const detail = asRecord12(err.detail);
71745
+ const detail = asRecord13(err.detail);
71522
71746
  return {
71523
71747
  stage: phase,
71524
71748
  code: typeof detail.code === "number" ? detail.code : null,
@@ -71633,7 +71857,7 @@ class StdioBridgeTransport {
71633
71857
  } catch {
71634
71858
  return;
71635
71859
  }
71636
- const rec = asRecord12(frame);
71860
+ const rec = asRecord13(frame);
71637
71861
  if (typeof rec.id === "number") {
71638
71862
  const pending = this.#pending.get(rec.id);
71639
71863
  if (pending === undefined)
@@ -71645,7 +71869,7 @@ class StdioBridgeTransport {
71645
71869
  this.#setState("ready");
71646
71870
  pending.resolve(rec.result);
71647
71871
  } else {
71648
- const error = asRecord12(rec.error);
71872
+ const error = asRecord13(rec.error);
71649
71873
  pending.reject(new BridgeProtocolError(typeof error.code === "string" ? error.code : "BRIDGE_ERROR", typeof error.message === "string" ? error.message : "bridge request failed", error.detail));
71650
71874
  }
71651
71875
  return;
@@ -71777,7 +72001,7 @@ class StdioBridgeTransport {
71777
72001
  } catch {}
71778
72002
  }
71779
72003
  }
71780
- var asRecord12 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
72004
+ var asRecord13 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
71781
72005
  var init_bridge_transport = __esm(() => {
71782
72006
  init_bridge_session_seam();
71783
72007
  init_seam_bootstrap();
@@ -71970,5 +72194,5 @@ export {
71970
72194
  themeNameFromConfig
71971
72195
  };
71972
72196
 
71973
- //# debugId=D9F1F54DB3A9E37E64756E2164756E21
72197
+ //# debugId=A3B3AF093DA737C264756E2164756E21
71974
72198
  //# sourceMappingURL=index.js.map