@aiwayds/dsh-opentui 0.25.0 → 0.26.0

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.
@@ -55154,6 +55154,29 @@ function presetLabelFor(rows, currentId) {
55154
55154
  const marked = rows.find((row) => row.isDefault) ?? rows.find((row) => row.id === "standard");
55155
55155
  return (marked ?? rows[0])?.name;
55156
55156
  }
55157
+ function isRiskPermissionPreset(value, name) {
55158
+ return /danger-full-access|full.?access|auto/i.test(`${value} ${name ?? ""}`);
55159
+ }
55160
+ function cwdBasename(cwd) {
55161
+ if (cwd === undefined || cwd === "")
55162
+ return;
55163
+ const trimmed = cwd.replace(/[\\/]+$/, "");
55164
+ if (trimmed === "")
55165
+ return cwd;
55166
+ const parts = trimmed.split(/[\\/]/);
55167
+ return parts[parts.length - 1] || trimmed;
55168
+ }
55169
+ function permissionCatalogLines(catalog) {
55170
+ const names = catalog.options.map((option) => option.value).join(", ");
55171
+ const lines = [`available presets: ${names}`];
55172
+ for (const option of catalog.options) {
55173
+ const detail = option.description === undefined || option.description === "" ? "" : ` \u2014 ${option.description}`;
55174
+ lines.push(`${option.value}${detail}`);
55175
+ }
55176
+ lines.push(`default preset: ${catalog.defaultPreset}`);
55177
+ lines.push("current session preset is host-authoritative (not readable here); use /permission <preset> to set it");
55178
+ return lines;
55179
+ }
55157
55180
  function loginStepTitle(stepTitle, error) {
55158
55181
  return error ? `${stepTitle} \u2014 ${error}` : stepTitle;
55159
55182
  }
@@ -56160,6 +56183,87 @@ function coreCommands() {
56160
56183
  ctx.say(t("command.account.failed", { reason: seamFailureReason(error) }));
56161
56184
  }
56162
56185
  }
56186
+ },
56187
+ {
56188
+ name: "/permission",
56189
+ description: t("command.permission.description"),
56190
+ async run(ctx, argText) {
56191
+ const face = ctx.seam.permission;
56192
+ if (!face) {
56193
+ ctx.say(t("command.permission.unavailable"));
56194
+ return;
56195
+ }
56196
+ let catalog;
56197
+ try {
56198
+ catalog = await face.catalog();
56199
+ } catch {
56200
+ catalog = undefined;
56201
+ }
56202
+ if (catalog === undefined) {
56203
+ ctx.say(t("command.permission.catalogUnavailable"));
56204
+ return;
56205
+ }
56206
+ const arg = argText.trim();
56207
+ if (arg === "") {
56208
+ for (const line of permissionCatalogLines(catalog))
56209
+ ctx.say(line);
56210
+ return;
56211
+ }
56212
+ const target = catalog.options.find((option) => option.value === arg || option.name === arg);
56213
+ if (target === undefined) {
56214
+ const names = catalog.options.map((option) => option.value).join(", ");
56215
+ ctx.say(t("command.permission.unknown", { name: arg, available: names }));
56216
+ return;
56217
+ }
56218
+ if (isRiskPermissionPreset(target.value, target.name)) {
56219
+ const verdict = await ctx.pickOne(t("command.permission.riskTitle", { name: target.value }), [
56220
+ { title: t("command.permission.riskAck"), value: "ack" },
56221
+ { title: t("command.permission.cancel"), value: "cancel" }
56222
+ ]);
56223
+ if (verdict !== "ack") {
56224
+ ctx.say(t("command.permission.cancelled"));
56225
+ return;
56226
+ }
56227
+ }
56228
+ try {
56229
+ const result = await face.switch(target.value);
56230
+ if (!result.matched) {
56231
+ ctx.say(t("command.permission.noCommand"));
56232
+ return;
56233
+ }
56234
+ if (!result.ok) {
56235
+ ctx.say(t("command.permission.failed", { reason: result.text || "error" }));
56236
+ return;
56237
+ }
56238
+ ctx.say(t("command.permission.set", { name: target.value }));
56239
+ if (result.text !== "")
56240
+ ctx.say(result.text);
56241
+ await ctx.reload();
56242
+ } catch (error) {
56243
+ ctx.say(t("command.permission.failed", { reason: seamFailureReason(error) }));
56244
+ }
56245
+ }
56246
+ },
56247
+ {
56248
+ name: "/cwd",
56249
+ description: t("command.cwd.description"),
56250
+ async run(ctx) {
56251
+ if (!ctx.seam.cwd) {
56252
+ ctx.say(t("command.cwd.unavailable"));
56253
+ return;
56254
+ }
56255
+ try {
56256
+ const cwd = await ctx.seam.cwd();
56257
+ const label = cwdBasename(cwd);
56258
+ if (label === undefined) {
56259
+ ctx.say(t("command.cwd.none"));
56260
+ return;
56261
+ }
56262
+ ctx.say(t("command.cwd.current", { cwd: label }));
56263
+ } catch (error) {
56264
+ ctx.say(t("command.cwd.failed", { reason: seamFailureReason(error) }));
56265
+ }
56266
+ }
56163
56267
  }
56164
56268
  ];
56165
56269
  }
@@ -64674,7 +64778,7 @@ var init_subagents_viewer = __esm(() => {
64674
64778
  import { TextAttributes as TextAttributes12 } from "@opentui/core";
64675
64779
  function resolveVersion() {
64676
64780
  try {
64677
- return "0.25.0";
64781
+ return "0.26.0";
64678
64782
  } catch {
64679
64783
  return "dev";
64680
64784
  }
@@ -67755,6 +67859,39 @@ var init_bridge_goals = __esm(() => {
67755
67859
  ACTIVATIONS = ["armed", "disarmed"];
67756
67860
  });
67757
67861
 
67862
+ // src/client/bridge-permission.ts
67863
+ function asRecord10(value) {
67864
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
67865
+ }
67866
+ function unwrapWireValue3(raw) {
67867
+ const rec = asRecord10(raw);
67868
+ if (Object.prototype.hasOwnProperty.call(rec, "value"))
67869
+ return rec.value;
67870
+ return raw;
67871
+ }
67872
+ function cleanText(value, max = MAX_TEXT4) {
67873
+ if (typeof value !== "string")
67874
+ return;
67875
+ return value.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").slice(0, max);
67876
+ }
67877
+ function projectPermissionSwitch(raw) {
67878
+ const value = unwrapWireValue3(raw);
67879
+ if (value === null || value === undefined) {
67880
+ return { ok: false, matched: false, text: "" };
67881
+ }
67882
+ const rec = asRecord10(value);
67883
+ const empty = Object.keys(rec).length === 0;
67884
+ if (empty)
67885
+ return { ok: false, matched: false, text: "" };
67886
+ const result = asRecord10(rec.result);
67887
+ const kind = cleanText(result.kind, MAX_SHORT4) ?? cleanText(rec.kind, MAX_SHORT4);
67888
+ const text = cleanText(result.text, MAX_TEXT4) ?? cleanText(rec.text, MAX_TEXT4) ?? "";
67889
+ if (kind === undefined && text === "")
67890
+ return { ok: false, matched: false, text: "" };
67891
+ return { ok: kind !== "error", matched: true, text };
67892
+ }
67893
+ var MAX_TEXT4 = 4096, MAX_SHORT4 = 240;
67894
+
67758
67895
  // src/client/bridge-session-seam.ts
67759
67896
  import { existsSync as existsSync13, readFileSync as readFileSync14, readdirSync as readdirSync4 } from "fs";
67760
67897
  import { join as join16 } from "path";
@@ -67771,7 +67908,7 @@ function optionalStringField(row, key) {
67771
67908
  return typeof value === "string" && value !== "" ? value : undefined;
67772
67909
  }
67773
67910
  function parseAskRequest(value) {
67774
- const row = asRecord10(value);
67911
+ const row = asRecord11(value);
67775
67912
  const eventId = optionalStringField(row, "eventId");
67776
67913
  const sessionId = optionalStringField(row, "sessionId");
67777
67914
  const kind = row.kind;
@@ -67794,14 +67931,14 @@ function parseAskRequest(value) {
67794
67931
  if (Array.isArray(row.questions)) {
67795
67932
  const questions = [];
67796
67933
  for (const raw of row.questions) {
67797
- const q = asRecord10(raw);
67934
+ const q = asRecord11(raw);
67798
67935
  const id = optionalStringField(q, "id");
67799
67936
  const prompt = optionalStringField(q, "prompt");
67800
67937
  if (id === undefined || prompt === undefined || !Array.isArray(q.options))
67801
67938
  continue;
67802
67939
  const options = [];
67803
67940
  for (const rawOpt of q.options) {
67804
- const opt = asRecord10(rawOpt);
67941
+ const opt = asRecord11(rawOpt);
67805
67942
  const label = optionalStringField(opt, "label");
67806
67943
  if (label === undefined)
67807
67944
  continue;
@@ -67871,11 +68008,11 @@ function answersFor(request, picks) {
67871
68008
  function unavailableResponse(request) {
67872
68009
  return request.kind === "questions" ? { eventId: request.eventId, kind: "questions", verdict: "unavailable", answers: answersFor(request, []) } : { eventId: request.eventId, kind: "approval", verdict: "unavailable" };
67873
68010
  }
67874
- function asRecord10(value) {
68011
+ function asRecord11(value) {
67875
68012
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
67876
68013
  }
67877
68014
  function projectSeamAccountView(value) {
67878
- const v = asRecord10(value);
68015
+ const v = asRecord11(value);
67879
68016
  return {
67880
68017
  status: typeof v.status === "string" && ACCOUNT_STATUSES.has(v.status) ? v.status : null,
67881
68018
  attemptPhase: typeof v.attemptPhase === "string" && ACCOUNT_PHASES.has(v.attemptPhase) ? v.attemptPhase : null,
@@ -67897,14 +68034,14 @@ function projectBridgeSessionList(items, limit = 12) {
67897
68034
  const rows = Array.isArray(items) ? items : [];
67898
68035
  const out = [];
67899
68036
  for (const item of rows) {
67900
- const row = asRecord10(item);
68037
+ const row = asRecord11(item);
67901
68038
  if (row.origin === "subagent")
67902
68039
  continue;
67903
68040
  const id = typeof row.sessionId === "string" ? row.sessionId : "";
67904
68041
  if (!id)
67905
68042
  continue;
67906
68043
  const updatedAt = typeof row.updatedAt === "number" ? String(row.updatedAt) : "";
67907
- const values = asRecord10(asRecord10(row.projections).values);
68044
+ const values = asRecord11(asRecord11(row.projections).values);
67908
68045
  const title = typeof values.title === "string" ? values.title : "";
67909
68046
  out.push({
67910
68047
  id,
@@ -67917,12 +68054,23 @@ function projectBridgeSessionList(items, limit = 12) {
67917
68054
  }
67918
68055
  return out.sort((a, b) => String(b.updatedAt ?? "").localeCompare(String(a.updatedAt ?? ""))).slice(0, limit);
67919
68056
  }
68057
+ function projectCurrentCwd(items, sessionId) {
68058
+ if (sessionId === undefined || sessionId === "" || !Array.isArray(items))
68059
+ return;
68060
+ for (const item of items) {
68061
+ const row = asRecord11(item);
68062
+ if (row.sessionId !== sessionId)
68063
+ continue;
68064
+ return typeof row.cwd === "string" && row.cwd !== "" ? row.cwd : undefined;
68065
+ }
68066
+ return;
68067
+ }
67920
68068
  function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
67921
68069
  const entries = rows.map((row) => ({
67922
68070
  type: row.type,
67923
68071
  seq: row.seq,
67924
68072
  time: 0,
67925
- data: asRecord10(row.payload)
68073
+ data: asRecord11(row.payload)
67926
68074
  }));
67927
68075
  const durable = journalToTranscriptRows(entries, skip);
67928
68076
  return durable.map((row) => {
@@ -67936,8 +68084,8 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
67936
68084
  });
67937
68085
  }
67938
68086
  function seamReplayEventKey(event) {
67939
- const details = asRecord10(event.details);
67940
- return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord10(details.part).id ?? "")}`;
68087
+ const details = asRecord11(event.details);
68088
+ return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord11(details.part).id ?? "")}`;
67941
68089
  }
67942
68090
  function bridgeReplayRowsToSeamEvents(rows, sessionId) {
67943
68091
  const events = [];
@@ -67951,7 +68099,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
67951
68099
  };
67952
68100
  const toolCalls = new Map;
67953
68101
  for (const row of rows) {
67954
- const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord10(row.payload) };
68102
+ const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord11(row.payload) };
67955
68103
  for (const event of projectJournalRecord(entry, sessionId))
67956
68104
  push(event);
67957
68105
  const data = entry.data;
@@ -67965,7 +68113,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
67965
68113
  });
67966
68114
  }
67967
68115
  } else if (row.type === "tool/result") {
67968
- const message = asRecord10(data.message);
68116
+ const message = asRecord11(data.message);
67969
68117
  const callId = data.callId !== undefined ? String(data.callId) : message.toolCallId !== undefined ? String(message.toolCallId) : "";
67970
68118
  const call = callId ? toolCalls.get(callId) : undefined;
67971
68119
  if (call !== undefined) {
@@ -68019,7 +68167,7 @@ function bridgeSettleChild(existing, outcome, startedAt, now) {
68019
68167
  }
68020
68168
  function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, live) {
68021
68169
  if (type === "user/message") {
68022
- const source = asRecord10(data.source);
68170
+ const source = asRecord11(data.source);
68023
68171
  if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
68024
68172
  return false;
68025
68173
  const childId = typeof source.senderSessionId === "string" ? source.senderSessionId : "";
@@ -68114,7 +68262,7 @@ function bridgeSweepSettledChildIds(rows, parentId, locallyRunning) {
68114
68262
  return [];
68115
68263
  const settled = [];
68116
68264
  for (const raw of rows) {
68117
- const row = asRecord10(raw);
68265
+ const row = asRecord11(raw);
68118
68266
  if (row.origin !== "subagent")
68119
68267
  continue;
68120
68268
  if (row.parentSessionId !== parentId)
@@ -68164,16 +68312,16 @@ function bridgeChildJournalMeta(rows) {
68164
68312
  let contextModel;
68165
68313
  let descriptorModel;
68166
68314
  for (const row of rows) {
68167
- const data = asRecord10(row.payload);
68315
+ const data = asRecord11(row.payload);
68168
68316
  if (row.type === "assistant/message") {
68169
68317
  rounds += 1;
68170
- const message = asRecord10(data.message);
68318
+ const message = asRecord11(data.message);
68171
68319
  const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
68172
68320
  if (tail !== undefined)
68173
68321
  lastLine = tail;
68174
68322
  } else if (row.type === "tool/result") {
68175
68323
  if (data.isError !== true) {
68176
- const message = asRecord10(data.message);
68324
+ const message = asRecord11(data.message);
68177
68325
  const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
68178
68326
  if (tail !== undefined)
68179
68327
  lastLine = tail;
@@ -68211,7 +68359,7 @@ function bridgeChildStopReason(rows) {
68211
68359
  const row = rows[i];
68212
68360
  if (row.type !== "user/message")
68213
68361
  continue;
68214
- const source = asRecord10(asRecord10(row.payload).source);
68362
+ const source = asRecord11(asRecord11(row.payload).source);
68215
68363
  if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
68216
68364
  continue;
68217
68365
  const reason = source.stopReason;
@@ -68222,7 +68370,7 @@ function bridgeChildStopReason(rows) {
68222
68370
  const row = rows[i];
68223
68371
  if (row.type !== "turn/end")
68224
68372
  continue;
68225
- const reason = asRecord10(asRecord10(row.payload).reason);
68373
+ const reason = asRecord11(asRecord11(row.payload).reason);
68226
68374
  const kind = reason.kind;
68227
68375
  if (typeof kind === "string" && kind !== "")
68228
68376
  return kind;
@@ -68280,7 +68428,7 @@ function lastJournalTurnTerminal(rows, startOutsideWindow = false) {
68280
68428
  return latest;
68281
68429
  }
68282
68430
  function journalTurnId(row) {
68283
- const payload = asRecord10(row.payload);
68431
+ const payload = asRecord11(row.payload);
68284
68432
  if (typeof payload.turn === "number" && Number.isFinite(payload.turn))
68285
68433
  return payload.turn;
68286
68434
  if (typeof payload.turnId === "string" && payload.turnId !== "")
@@ -68288,7 +68436,7 @@ function journalTurnId(row) {
68288
68436
  return;
68289
68437
  }
68290
68438
  function projectBridgeEvent(frame, sessionId) {
68291
- const payload = asRecord10(frame.payload);
68439
+ const payload = asRecord11(frame.payload);
68292
68440
  const turnId = typeof payload.turnId === "string" ? payload.turnId : "";
68293
68441
  if (frame.type === "turn.start") {
68294
68442
  return [{ type: "session.updated", details: { sessionID: sessionId, turnId, turn: "starting" } }];
@@ -68310,7 +68458,7 @@ function projectBridgeEvent(frame, sessionId) {
68310
68458
  return [];
68311
68459
  }
68312
68460
  function parseUsage(value) {
68313
- const u = asRecord10(value);
68461
+ const u = asRecord11(value);
68314
68462
  const num = (...aliases) => {
68315
68463
  let present = false;
68316
68464
  let best = 0;
@@ -68339,7 +68487,7 @@ function parseUsage(value) {
68339
68487
  return out;
68340
68488
  }
68341
68489
  function journalUsage(payload) {
68342
- const usage = asRecord10(asRecord10(payload).usage);
68490
+ const usage = asRecord11(asRecord11(payload).usage);
68343
68491
  const parsed = parseUsage(usage);
68344
68492
  if (Object.keys(parsed).length === 0)
68345
68493
  return;
@@ -68349,7 +68497,7 @@ function journalUsage(payload) {
68349
68497
  return { ...parsed, total };
68350
68498
  }
68351
68499
  function asDeadCause(value) {
68352
- const r = asRecord10(value);
68500
+ const r = asRecord11(value);
68353
68501
  const stage = r.stage;
68354
68502
  const stages = ["spawn", "handshake", "runtime", "closed"];
68355
68503
  return {
@@ -68381,6 +68529,10 @@ class BridgeSessionSeam {
68381
68529
  identity: () => ({ profile: this.#profile, dshHome: this.#dshHome }),
68382
68530
  permissionCatalog: () => this.#readPermissionCatalog()
68383
68531
  };
68532
+ permission = {
68533
+ catalog: () => this.#readPermissionCatalog(),
68534
+ switch: (preset) => this.#permissionSwitch(preset)
68535
+ };
68384
68536
  providerDirectory = {
68385
68537
  registered: () => this.#directoryRequest("llm.listProviders", projectLlmProviders),
68386
68538
  configurable: () => this.#directoryRequest("llm.listConfigurableProviders", projectConfigurableProviders),
@@ -68433,7 +68585,7 @@ class BridgeSessionSeam {
68433
68585
  cancelSignIn: async (attemptId) => projectSeamAccountView(await this.#transport.request("account.cancelSignIn", { attemptId })),
68434
68586
  signOut: async () => projectSeamAccountView(await this.#transport.request("account.signOut", { client: accountClientMeta() })),
68435
68587
  hasRunningAccountTasks: async () => {
68436
- const value = asRecord10(await this.#transport.request("account.hasRunningAccountTasks"));
68588
+ const value = asRecord11(await this.#transport.request("account.hasRunningAccountTasks"));
68437
68589
  return value.running === true;
68438
68590
  }
68439
68591
  };
@@ -68495,6 +68647,19 @@ class BridgeSessionSeam {
68495
68647
  return;
68496
68648
  }
68497
68649
  }
68650
+ async#permissionSwitch(preset) {
68651
+ const agentId = this.currentSessionId();
68652
+ if (agentId === undefined || agentId === "") {
68653
+ throw new BridgeProtocolError("UNSUPPORTED", "permission.switch: no active session (agentId unavailable)");
68654
+ }
68655
+ const line = `/permission ${preset}`;
68656
+ const reply = await this.#transport.request("commands.execute", {
68657
+ agentId,
68658
+ line,
68659
+ submittedAttachments: []
68660
+ });
68661
+ return projectPermissionSwitch(reply);
68662
+ }
68498
68663
  async#goalsRequest(method, extraParams, project) {
68499
68664
  const agentId = this.currentSessionId();
68500
68665
  if (agentId === undefined || agentId === "") {
@@ -68595,7 +68760,7 @@ class BridgeSessionSeam {
68595
68760
  effortsFor: (providerID, modelID) => this.#catalogEfforts(providerID, modelID),
68596
68761
  currentEffort: async () => {
68597
68762
  const selection = await this.#transport.request("model.currentSelection");
68598
- const value = asRecord10(selection).reasoningEffort;
68763
+ const value = asRecord11(selection).reasoningEffort;
68599
68764
  return typeof value === "string" && value !== "" ? value : undefined;
68600
68765
  },
68601
68766
  selectEffort: async (effort) => {
@@ -68631,7 +68796,7 @@ class BridgeSessionSeam {
68631
68796
  return [];
68632
68797
  const out = [];
68633
68798
  for (const e of efforts) {
68634
- const row = asRecord10(e);
68799
+ const row = asRecord11(e);
68635
68800
  const id = typeof row.id === "string" ? row.id : "";
68636
68801
  const name = typeof row.name === "string" ? row.name : "";
68637
68802
  if (!id)
@@ -68728,7 +68893,7 @@ class BridgeSessionSeam {
68728
68893
  }
68729
68894
  async connect() {
68730
68895
  try {
68731
- const reply = asRecord10(await this.#transport.request("bridge.ping"));
68896
+ const reply = asRecord11(await this.#transport.request("bridge.ping"));
68732
68897
  this.#recordBridgeCapabilities(reply.capabilities);
68733
68898
  this.#connection = "connected";
68734
68899
  } catch (err) {
@@ -68815,7 +68980,7 @@ class BridgeSessionSeam {
68815
68980
  this.#replayDrainPending = true;
68816
68981
  let opened;
68817
68982
  try {
68818
- opened = asRecord10(await this.#transport.request("session.open", { mode: "resume", id: sessionId }));
68983
+ opened = asRecord11(await this.#transport.request("session.open", { mode: "resume", id: sessionId }));
68819
68984
  } catch (err) {
68820
68985
  const code = err instanceof BridgeProtocolError ? err.code : "SESSION_OPEN_FAILED";
68821
68986
  const message = err instanceof Error ? err.message : String(err);
@@ -68825,7 +68990,7 @@ class BridgeSessionSeam {
68825
68990
  this.#bufferedPendingSnapshot = undefined;
68826
68991
  this.#replayDrainPending = false;
68827
68992
  this.#settleSuspendedTurn();
68828
- const errorDetail = err instanceof BridgeProtocolError ? asRecord10(err.detail) : {};
68993
+ const errorDetail = err instanceof BridgeProtocolError ? asRecord11(err.detail) : {};
68829
68994
  const holder = typeof errorDetail.holder === "string" && errorDetail.holder.trim() !== "" ? errorDetail.holder : undefined;
68830
68995
  const result = {
68831
68996
  state: "locked",
@@ -68900,7 +69065,7 @@ class BridgeSessionSeam {
68900
69065
  turnId: dead.turnId,
68901
69066
  seq: terminal.seq,
68902
69067
  terminalType: terminal.type,
68903
- reason: asRecord10(terminal.payload).reason,
69068
+ reason: asRecord11(terminal.payload).reason,
68904
69069
  payload: terminal.payload,
68905
69070
  source: "journal"
68906
69071
  }
@@ -68958,7 +69123,7 @@ class BridgeSessionSeam {
68958
69123
  const seen = new Set;
68959
69124
  const collected = [];
68960
69125
  for (;; ) {
68961
- const value = asRecord10(await this.#transport.request("journal.replay", { sessionId, from }));
69126
+ const value = asRecord11(await this.#transport.request("journal.replay", { sessionId, from }));
68962
69127
  const rawRows = Array.isArray(value.rows) ? value.rows : [];
68963
69128
  if (typeof value.cursor === "number" && Number.isFinite(value.cursor))
68964
69129
  cursor = value.cursor;
@@ -68971,7 +69136,7 @@ class BridgeSessionSeam {
68971
69136
  let added = 0;
68972
69137
  let pageMax = from - 1;
68973
69138
  for (const raw of rawRows) {
68974
- const row = asRecord10(raw);
69139
+ const row = asRecord11(raw);
68975
69140
  const seq = row.seq;
68976
69141
  if (typeof seq !== "number" || !Number.isFinite(seq) || seq < floor || seen.has(seq))
68977
69142
  continue;
@@ -69020,7 +69185,7 @@ class BridgeSessionSeam {
69020
69185
  };
69021
69186
  const attempt = (remaining) => {
69022
69187
  this.#transport.request("turn.abort", { turnId }).then((result) => {
69023
- if (asRecord10(result).noop === true) {
69188
+ if (asRecord11(result).noop === true) {
69024
69189
  fail(`turn.abort was a noop for turn ${turnId}; turn may still be running`, "TURN_ABORT_NOOP");
69025
69190
  }
69026
69191
  }).catch((err) => {
@@ -69156,7 +69321,7 @@ class BridgeSessionSeam {
69156
69321
  stats.contextTokens = usage.total;
69157
69322
  }
69158
69323
  } else if (row.type === "request/context") {
69159
- const data = asRecord10(row.payload);
69324
+ const data = asRecord11(row.payload);
69160
69325
  const window = data.contextWindow;
69161
69326
  if (typeof window === "number" && Number.isFinite(window) && window > 0) {
69162
69327
  const provider = typeof data.provider === "string" ? data.provider : "";
@@ -69290,7 +69455,7 @@ class BridgeSessionSeam {
69290
69455
  this.#interruptInFlight.set(childId, generation);
69291
69456
  let value;
69292
69457
  try {
69293
- value = asRecord10(await this.#transport.request("subagents.interrupt", { parentSessionId, childId }));
69458
+ value = asRecord11(await this.#transport.request("subagents.interrupt", { parentSessionId, childId }));
69294
69459
  } catch (err) {
69295
69460
  if (this.#interruptInFlight.get(childId) === generation)
69296
69461
  this.#interruptInFlight.delete(childId);
@@ -69316,13 +69481,13 @@ class BridgeSessionSeam {
69316
69481
  if (parentSessionId === undefined || parentSessionId === "") {
69317
69482
  throw new BridgeProtocolError("NO_SESSION", "cannot stop children: no session is bound to this bridge connection");
69318
69483
  }
69319
- const value = asRecord10(await this.#transport.request("subagents.stopChildren", { parentSessionId }));
69484
+ const value = asRecord11(await this.#transport.request("subagents.stopChildren", { parentSessionId }));
69320
69485
  const children = value.children;
69321
69486
  if (!Array.isArray(children))
69322
69487
  return [];
69323
69488
  const sessionAtStart = this.#subagentSessionId;
69324
69489
  const rows = children.map((row) => {
69325
- const r = asRecord10(row);
69490
+ const r = asRecord11(row);
69326
69491
  return {
69327
69492
  childId: typeof r.childId === "string" ? r.childId : "",
69328
69493
  disposition: typeof r.disposition === "string" ? r.disposition : "failed"
@@ -69348,10 +69513,10 @@ class BridgeSessionSeam {
69348
69513
  return;
69349
69514
  let stopped = false;
69350
69515
  try {
69351
- const items = asRecord10(await this.#transport.request("session.list", { _request: {} })).items;
69516
+ const items = asRecord11(await this.#transport.request("session.list", { _request: {} })).items;
69352
69517
  if (Array.isArray(items)) {
69353
69518
  stopped = items.some((row) => {
69354
- const item = asRecord10(row);
69519
+ const item = asRecord11(row);
69355
69520
  return item.sessionId === childId && item.running === false;
69356
69521
  });
69357
69522
  }
@@ -69361,7 +69526,7 @@ class BridgeSessionSeam {
69361
69526
  if (stopped) {
69362
69527
  let reason = "aborted";
69363
69528
  try {
69364
- const rows = asRecord10(await this.#transport.request("journal.replay", { sessionId: childId })).rows;
69529
+ const rows = asRecord11(await this.#transport.request("journal.replay", { sessionId: childId })).rows;
69365
69530
  if (Array.isArray(rows)) {
69366
69531
  const clean = rows.filter((row) => row !== null && typeof row === "object" && !Array.isArray(row));
69367
69532
  reason = bridgeChildStopReason(clean) ?? "aborted";
@@ -69420,7 +69585,7 @@ class BridgeSessionSeam {
69420
69585
  } catch {
69421
69586
  return;
69422
69587
  }
69423
- const items = asRecord10(value).items;
69588
+ const items = asRecord11(value).items;
69424
69589
  if (!Array.isArray(items))
69425
69590
  return;
69426
69591
  const locallyRunning = new Set;
@@ -69465,7 +69630,7 @@ class BridgeSessionSeam {
69465
69630
  this.#subagentJournalLoaded.add(key);
69466
69631
  const sessionAtStart = this.#subagentSessionId;
69467
69632
  try {
69468
- const value = asRecord10(await this.#transport.request("journal.replay", { sessionId: childId }));
69633
+ const value = asRecord11(await this.#transport.request("journal.replay", { sessionId: childId }));
69469
69634
  const rows = value.rows;
69470
69635
  if (!Array.isArray(rows))
69471
69636
  return;
@@ -69572,7 +69737,7 @@ class BridgeSessionSeam {
69572
69737
  }
69573
69738
  }
69574
69739
  #foldAgentFrame(frame) {
69575
- const payload = asRecord10(frame.payload);
69740
+ const payload = asRecord11(frame.payload);
69576
69741
  const frameSession = typeof payload.sessionId === "string" ? payload.sessionId : "";
69577
69742
  if (this.#subagentSessionId !== undefined && frameSession !== "" && frameSession !== this.#subagentSessionId)
69578
69743
  return;
@@ -69609,7 +69774,7 @@ class BridgeSessionSeam {
69609
69774
  let changed = false;
69610
69775
  const now = Date.now();
69611
69776
  for (const row of rows) {
69612
- if (this.#foldWithFrozenSettle(row.type, asRecord10(row.payload), now, false))
69777
+ if (this.#foldWithFrozenSettle(row.type, asRecord11(row.payload), now, false))
69613
69778
  changed = true;
69614
69779
  }
69615
69780
  if (rosterReset || changed) {
@@ -69643,27 +69808,34 @@ class BridgeSessionSeam {
69643
69808
  }
69644
69809
  async listSessions(limit) {
69645
69810
  const value = await this.#transport.request("session.list");
69646
- return projectBridgeSessionList(asRecord10(value).items, limit);
69811
+ return projectBridgeSessionList(asRecord11(value).items, limit);
69812
+ }
69813
+ async cwd() {
69814
+ const sessionId = this.currentSessionId();
69815
+ if (sessionId === undefined || sessionId === "")
69816
+ return;
69817
+ const value = await this.#transport.request("session.list");
69818
+ return projectCurrentCwd(asRecord11(value).items, sessionId);
69647
69819
  }
69648
69820
  async storedTranscript(id, skip = 0) {
69649
69821
  const value = await this.#transport.request("journal.replay", { sessionId: id });
69650
- const rows = Array.isArray(asRecord10(value).rows) ? asRecord10(value).rows : [];
69822
+ const rows = Array.isArray(asRecord11(value).rows) ? asRecord11(value).rows : [];
69651
69823
  this.#foldAgentReplayRows(rows, id);
69652
69824
  this.#sweepSubagents(id);
69653
69825
  return bridgeReplayRowsToSeamTranscript(rows, skip);
69654
69826
  }
69655
69827
  async sessionJournal(id) {
69656
69828
  const value = await this.#transport.request("journal.replay", { sessionId: id });
69657
- const rows = Array.isArray(asRecord10(value).rows) ? asRecord10(value).rows : [];
69829
+ const rows = Array.isArray(asRecord11(value).rows) ? asRecord11(value).rows : [];
69658
69830
  return rows.map((row) => ({
69659
69831
  type: row.type,
69660
69832
  seq: row.seq,
69661
69833
  time: 0,
69662
- data: asRecord10(row.payload)
69834
+ data: asRecord11(row.payload)
69663
69835
  }));
69664
69836
  }
69665
69837
  async forkSession(sessionId, seqEnd) {
69666
- const value = asRecord10(await this.#transport.request("session.fork", {
69838
+ const value = asRecord11(await this.#transport.request("session.fork", {
69667
69839
  sessionId,
69668
69840
  ...seqEnd !== undefined ? { atSeq: seqEnd } : {}
69669
69841
  }));
@@ -69677,7 +69849,7 @@ class BridgeSessionSeam {
69677
69849
  const selection = await this.#transport.request("model.currentSelection");
69678
69850
  if (selection === undefined || selection === null)
69679
69851
  return;
69680
- const s = asRecord10(selection);
69852
+ const s = asRecord11(selection);
69681
69853
  const providerID = typeof s.provider === "string" ? s.provider : "";
69682
69854
  const modelID = typeof s.model === "string" ? s.model : "";
69683
69855
  if (!providerID || !modelID)
@@ -69714,7 +69886,7 @@ class BridgeSessionSeam {
69714
69886
  this.#pendingOpen = undefined;
69715
69887
  const params = pending.mode === "resume" ? { mode: "resume", id: pending.id, ...this.#sessionAttached ? { replace: true } : {} } : { mode: "new", ...this.#sessionAttached ? { replace: true } : {} };
69716
69888
  try {
69717
- const opened = asRecord10(await this.#transport.request("session.open", params));
69889
+ const opened = asRecord11(await this.#transport.request("session.open", params));
69718
69890
  if (typeof opened.sessionId === "string")
69719
69891
  this.#currentSessionId = opened.sessionId;
69720
69892
  if (this.#lastAppliedSessionId !== this.#currentSessionId) {
@@ -69731,7 +69903,7 @@ class BridgeSessionSeam {
69731
69903
  const done = new Promise((resolve) => {
69732
69904
  this.#turnDone = resolve;
69733
69905
  });
69734
- const sent = asRecord10(await this.#transport.request("session.send", { text: userText }));
69906
+ const sent = asRecord11(await this.#transport.request("session.send", { text: userText }));
69735
69907
  if (typeof sent.turnId === "string") {
69736
69908
  this.#inFlightTurnId = sent.turnId;
69737
69909
  this.#emitEvent({
@@ -69824,10 +69996,10 @@ class BridgeSessionSeam {
69824
69996
  }
69825
69997
  }
69826
69998
  async searchSessions(query) {
69827
- const value = asRecord10(await this.#transport.request("session.search", { query }));
69999
+ const value = asRecord11(await this.#transport.request("session.search", { query }));
69828
70000
  const rows = Array.isArray(value.items) ? value.items : [];
69829
70001
  return rows.map((row) => {
69830
- const r = asRecord10(row);
70002
+ const r = asRecord11(row);
69831
70003
  return {
69832
70004
  id: typeof r.id === "string" ? r.id : "",
69833
70005
  snippet: typeof r.snippet === "string" ? r.snippet : ""
@@ -70008,7 +70180,7 @@ class BridgeSessionSeam {
70008
70180
  this.#settlePendingAsk(eventId);
70009
70181
  }
70010
70182
  #onAskEvent(frame) {
70011
- const payload = asRecord10(frame.payload);
70183
+ const payload = asRecord11(frame.payload);
70012
70184
  if (frame.type === "ask.request" || frame.type === "ask.pending")
70013
70185
  this.#askFrameSeen = true;
70014
70186
  switch (frame.type) {
@@ -70068,7 +70240,7 @@ class BridgeSessionSeam {
70068
70240
  #onCapPushEvent(frame) {
70069
70241
  if (frame.type !== "cap.event" && frame.type !== "cap.end")
70070
70242
  return false;
70071
- const payload = asRecord10(frame.payload);
70243
+ const payload = asRecord11(frame.payload);
70072
70244
  const sessionId = optionalStringField(payload, "sessionId");
70073
70245
  if (sessionId === undefined || sessionId === "")
70074
70246
  return true;
@@ -70142,7 +70314,7 @@ class BridgeSessionSeam {
70142
70314
  }
70143
70315
  return;
70144
70316
  }
70145
- const payload = asRecord10(frame.payload);
70317
+ const payload = asRecord11(frame.payload);
70146
70318
  if (frame.type === "turn.start") {
70147
70319
  this.#turn = "starting";
70148
70320
  this.#decodeWindowStart = undefined;
@@ -70361,11 +70533,11 @@ function toBridgeBootstrapError(err, fallbackCode = "BRIDGE_HANDSHAKE_FAILED") {
70361
70533
  const message = err instanceof Error ? err.message : String(err);
70362
70534
  return new BridgeBootstrapError({ code: fallbackCode, diagnosis: `bridge handshake failed: ${message}` });
70363
70535
  }
70364
- function asRecord11(value) {
70536
+ function asRecord12(value) {
70365
70537
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
70366
70538
  }
70367
70539
  function verifyBridgeFingerprint(hello, expectedProtocolVersion = BRIDGE_PROTOCOL_VERSION) {
70368
- const h = asRecord11(hello);
70540
+ const h = asRecord12(hello);
70369
70541
  const protocolVersion = h.protocolVersion;
70370
70542
  if (protocolVersion !== expectedProtocolVersion) {
70371
70543
  throw new BridgeBootstrapError({
@@ -71518,7 +71690,7 @@ function recoveryCause(err, phase) {
71518
71690
  };
71519
71691
  }
71520
71692
  if (err instanceof BridgeProtocolError && err.code === "BRIDGE_DEAD") {
71521
- const detail = asRecord12(err.detail);
71693
+ const detail = asRecord13(err.detail);
71522
71694
  return {
71523
71695
  stage: phase,
71524
71696
  code: typeof detail.code === "number" ? detail.code : null,
@@ -71633,7 +71805,7 @@ class StdioBridgeTransport {
71633
71805
  } catch {
71634
71806
  return;
71635
71807
  }
71636
- const rec = asRecord12(frame);
71808
+ const rec = asRecord13(frame);
71637
71809
  if (typeof rec.id === "number") {
71638
71810
  const pending = this.#pending.get(rec.id);
71639
71811
  if (pending === undefined)
@@ -71645,7 +71817,7 @@ class StdioBridgeTransport {
71645
71817
  this.#setState("ready");
71646
71818
  pending.resolve(rec.result);
71647
71819
  } else {
71648
- const error = asRecord12(rec.error);
71820
+ const error = asRecord13(rec.error);
71649
71821
  pending.reject(new BridgeProtocolError(typeof error.code === "string" ? error.code : "BRIDGE_ERROR", typeof error.message === "string" ? error.message : "bridge request failed", error.detail));
71650
71822
  }
71651
71823
  return;
@@ -71777,7 +71949,7 @@ class StdioBridgeTransport {
71777
71949
  } catch {}
71778
71950
  }
71779
71951
  }
71780
- var asRecord12 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
71952
+ var asRecord13 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
71781
71953
  var init_bridge_transport = __esm(() => {
71782
71954
  init_bridge_session_seam();
71783
71955
  init_seam_bootstrap();
@@ -71970,5 +72142,5 @@ export {
71970
72142
  themeNameFromConfig
71971
72143
  };
71972
72144
 
71973
- //# debugId=D9F1F54DB3A9E37E64756E2164756E21
72145
+ //# debugId=1280DDFA8B58FE3F64756E2164756E21
71974
72146
  //# sourceMappingURL=index.js.map