@aiwayds/dsh-opentui 0.29.1 → 0.29.2
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.
- package/dist/client/index.js +397 -377
- package/dist/client/index.js.map +14 -7
- package/package.json +1 -1
- package/scripts/lib/inproc-companions.mjs +2 -2
package/dist/client/index.js
CHANGED
|
@@ -38310,6 +38310,94 @@ function subagentNamePrefix(name, label) {
|
|
|
38310
38310
|
return name !== undefined && name !== "" && name !== label ? `${name}: ` : "";
|
|
38311
38311
|
}
|
|
38312
38312
|
|
|
38313
|
+
// ../tui-base/src/routes/session/dock-line-primitives.ts
|
|
38314
|
+
function skinStopAt(row) {
|
|
38315
|
+
return row.startedAt !== undefined && row.elapsedSec !== undefined ? row.startedAt + row.elapsedSec * 1000 : undefined;
|
|
38316
|
+
}
|
|
38317
|
+
function todoTreeLines(todos) {
|
|
38318
|
+
if (todos.length === 0)
|
|
38319
|
+
return [];
|
|
38320
|
+
const done = todos.filter((todo) => todo.status === "completed").length;
|
|
38321
|
+
if (done === todos.length)
|
|
38322
|
+
return [];
|
|
38323
|
+
const lines = [
|
|
38324
|
+
{ kind: "todo", segments: [{ text: t("overlay.widgets.todosHeader", { done, total: todos.length }), tone: "running", accent: "todo" }] }
|
|
38325
|
+
];
|
|
38326
|
+
todos.forEach((todo, i) => {
|
|
38327
|
+
const branch = i === todos.length - 1 ? "\u2514\u2500 " : "\u251C\u2500 ";
|
|
38328
|
+
const glyph = TODO_STATUS_GLYPHS[todo.status] ?? TODO_STATUS_GLYPHS.pending;
|
|
38329
|
+
lines.push({ kind: "todo", segments: [{ text: `${branch}${glyph} ${todo.content}`, tone: "running", accent: "todo" }] });
|
|
38330
|
+
});
|
|
38331
|
+
return lines;
|
|
38332
|
+
}
|
|
38333
|
+
function todoSetStartedAt(todos, now = Date.now()) {
|
|
38334
|
+
const sig = todoSetSignature(todos);
|
|
38335
|
+
const first = todoSetFirstSeen.get(sig);
|
|
38336
|
+
if (first !== undefined)
|
|
38337
|
+
return first;
|
|
38338
|
+
todoSetFirstSeen.set(sig, now);
|
|
38339
|
+
return now;
|
|
38340
|
+
}
|
|
38341
|
+
function todoBriefLine(todos, now = Date.now(), startedAt) {
|
|
38342
|
+
if (todos.length === 0)
|
|
38343
|
+
return "";
|
|
38344
|
+
const done = todos.filter((todo) => todo.status === "completed").length;
|
|
38345
|
+
const anchor = startedAt ?? todoSetStartedAt(todos, now);
|
|
38346
|
+
const secs = Math.max(0, Math.floor((now - anchor) / 1000));
|
|
38347
|
+
return t("overlay.widgets.todosBrief", { done, total: todos.length, secs });
|
|
38348
|
+
}
|
|
38349
|
+
function resetTodoBriefClock() {
|
|
38350
|
+
todoSetFirstSeen.clear();
|
|
38351
|
+
}
|
|
38352
|
+
function toolMarker(status) {
|
|
38353
|
+
return status === "running" ? "\u2699" : status === "failed" ? "\u2718" : "\u2714";
|
|
38354
|
+
}
|
|
38355
|
+
function toolLineText(row, spin, now = Date.now()) {
|
|
38356
|
+
const subject = toolSubject(row.args);
|
|
38357
|
+
const title = subject === "" ? row.name : `${row.name} ${subject}`;
|
|
38358
|
+
const elapsed = row.status === "running" ? row.startedAt !== undefined ? ` \xB7 ${((now - row.startedAt) / 1000).toFixed(1)}s` : "" : row.elapsedSec !== undefined ? ` \xB7 ${row.elapsedSec.toFixed(1)}s` : "";
|
|
38359
|
+
const marker = toolMarker(row.status);
|
|
38360
|
+
spin();
|
|
38361
|
+
const tail = row.status === "running" ? toolDetail(row.args) : toolResultLine(row.output);
|
|
38362
|
+
const body = `${title}${elapsed}${tail !== "" ? ` \xB7 ${tail}` : ""}`;
|
|
38363
|
+
return `${marker} ${body}`;
|
|
38364
|
+
}
|
|
38365
|
+
function thinkBlockLines(row, spin, maxLines = DOCK_WIDGET_MAX_LINES, now = Date.now()) {
|
|
38366
|
+
const lines = row.text.replace(/\r/g, "").split(`
|
|
38367
|
+
`).filter((line) => line.trim() !== "");
|
|
38368
|
+
const n = Math.max(1, Math.floor(maxLines));
|
|
38369
|
+
if (row.streaming === true) {
|
|
38370
|
+
const secs = row.startedAt !== undefined ? `${((now - row.startedAt) / 1000).toFixed(1)}s` : "0.0s";
|
|
38371
|
+
spin();
|
|
38372
|
+
const picked = lines.length === 0 ? [""] : lines.slice(-n);
|
|
38373
|
+
return picked.map((line, index) => index === 0 ? t("overlay.widgets.thinkStreaming", { secs, line }) : ` ${line}`);
|
|
38374
|
+
}
|
|
38375
|
+
if (row.elapsedSec !== undefined) {
|
|
38376
|
+
const secs = `${row.elapsedSec.toFixed(1)}s`;
|
|
38377
|
+
const picked = lines.length === 0 ? [""] : lines.slice(-n);
|
|
38378
|
+
return picked.map((line, index) => index === 0 ? t("overlay.widgets.thinkCollapsed", { secs, line }) : ` ${line}`);
|
|
38379
|
+
}
|
|
38380
|
+
return [];
|
|
38381
|
+
}
|
|
38382
|
+
function activityScene(hasRunningSubagent, hasVisibleThink) {
|
|
38383
|
+
if (hasRunningSubagent)
|
|
38384
|
+
return "A";
|
|
38385
|
+
return hasVisibleThink ? "B" : "C";
|
|
38386
|
+
}
|
|
38387
|
+
var TODO_STATUS_GLYPHS, todoSetSignature = (todos) => todos.map((todo) => todo.content).sort().join("\x01"), todoSetFirstSeen;
|
|
38388
|
+
var init_dock_line_primitives = __esm(() => {
|
|
38389
|
+
init_i18n();
|
|
38390
|
+
init_tool_summarize();
|
|
38391
|
+
init_dock_visibility();
|
|
38392
|
+
TODO_STATUS_GLYPHS = {
|
|
38393
|
+
pending: "\u25CB",
|
|
38394
|
+
in_progress: "\u25CF",
|
|
38395
|
+
completed: "\u2713",
|
|
38396
|
+
cancelled: "\u2298"
|
|
38397
|
+
};
|
|
38398
|
+
todoSetFirstSeen = new Map;
|
|
38399
|
+
});
|
|
38400
|
+
|
|
38313
38401
|
// ../tui-base/src/routes/session/merged-dock.ts
|
|
38314
38402
|
function attributeAgents(todos, agents) {
|
|
38315
38403
|
let parent = null;
|
|
@@ -38582,17 +38670,12 @@ function assembleZones(upperLines, lowerRaw, totalLines, cursor) {
|
|
|
38582
38670
|
function fitAll(lines, innerWidth) {
|
|
38583
38671
|
return lines.map((line) => fitLine(line, innerWidth));
|
|
38584
38672
|
}
|
|
38585
|
-
var MERGED_DOCK_TOTAL_LINES = 10, MERGED_DOCK_TOOL_ONLY_MAX = 3
|
|
38673
|
+
var MERGED_DOCK_TOTAL_LINES = 10, MERGED_DOCK_TOOL_ONLY_MAX = 3;
|
|
38586
38674
|
var init_merged_dock = __esm(() => {
|
|
38587
38675
|
init_locale();
|
|
38588
38676
|
init_string_width();
|
|
38589
|
-
|
|
38590
|
-
|
|
38591
|
-
pending: "\u25CB",
|
|
38592
|
-
in_progress: "\u25CF",
|
|
38593
|
-
completed: "\u2713",
|
|
38594
|
-
cancelled: "\u2298"
|
|
38595
|
-
};
|
|
38677
|
+
init_dock_line_primitives();
|
|
38678
|
+
init_dock_line_primitives();
|
|
38596
38679
|
});
|
|
38597
38680
|
|
|
38598
38681
|
// ../tui-base/src/routes/session/widgets-dock.tsx
|
|
@@ -38725,9 +38808,6 @@ function skinPulseBrightness(elapsedMs) {
|
|
|
38725
38808
|
const phase = elapsedMs % cycle / cycle;
|
|
38726
38809
|
return 1 - SKIN_PULSE_DIM * (1 - Math.abs(2 * phase - 1));
|
|
38727
38810
|
}
|
|
38728
|
-
function skinStopAt(row) {
|
|
38729
|
-
return row.startedAt !== undefined && row.elapsedSec !== undefined ? row.startedAt + row.elapsedSec * 1000 : undefined;
|
|
38730
|
-
}
|
|
38731
38811
|
function skinLineFadeT(id, now = Date.now()) {
|
|
38732
38812
|
let seen = lineFirstSeen.get(id);
|
|
38733
38813
|
if (seen === undefined) {
|
|
@@ -38823,37 +38903,6 @@ function todosSummaryFromTodos(todos) {
|
|
|
38823
38903
|
});
|
|
38824
38904
|
return active ? `${head} \xB7 ${active.content}` : head;
|
|
38825
38905
|
}
|
|
38826
|
-
function todoTreeLines(todos) {
|
|
38827
|
-
if (todos.length === 0)
|
|
38828
|
-
return [];
|
|
38829
|
-
const done = todos.filter((todo) => todo.status === "completed").length;
|
|
38830
|
-
if (done === todos.length)
|
|
38831
|
-
return [];
|
|
38832
|
-
const lines = [{
|
|
38833
|
-
kind: "todo",
|
|
38834
|
-
segments: [{
|
|
38835
|
-
text: t("overlay.widgets.todosHeader", {
|
|
38836
|
-
done,
|
|
38837
|
-
total: todos.length
|
|
38838
|
-
}),
|
|
38839
|
-
tone: "running",
|
|
38840
|
-
accent: "todo"
|
|
38841
|
-
}]
|
|
38842
|
-
}];
|
|
38843
|
-
todos.forEach((todo, i) => {
|
|
38844
|
-
const branch = i === todos.length - 1 ? "\u2514\u2500 " : "\u251C\u2500 ";
|
|
38845
|
-
const glyph = TODO_STATUS_GLYPHS[todo.status] ?? TODO_STATUS_GLYPHS.pending;
|
|
38846
|
-
lines.push({
|
|
38847
|
-
kind: "todo",
|
|
38848
|
-
segments: [{
|
|
38849
|
-
text: `${branch}${glyph} ${todo.content}`,
|
|
38850
|
-
tone: "running",
|
|
38851
|
-
accent: "todo"
|
|
38852
|
-
}]
|
|
38853
|
-
});
|
|
38854
|
-
});
|
|
38855
|
-
return lines;
|
|
38856
|
-
}
|
|
38857
38906
|
function todoTabLines(rows, innerWidth, cursor = 0) {
|
|
38858
38907
|
const data = {
|
|
38859
38908
|
tools: [],
|
|
@@ -38989,29 +39038,6 @@ function DockTabStripView(props) {
|
|
|
38989
39038
|
return _el$;
|
|
38990
39039
|
})();
|
|
38991
39040
|
}
|
|
38992
|
-
function todoSetStartedAt(todos, now = Date.now()) {
|
|
38993
|
-
const sig = todoSetSignature(todos);
|
|
38994
|
-
const first = todoSetFirstSeen.get(sig);
|
|
38995
|
-
if (first !== undefined)
|
|
38996
|
-
return first;
|
|
38997
|
-
todoSetFirstSeen.set(sig, now);
|
|
38998
|
-
return now;
|
|
38999
|
-
}
|
|
39000
|
-
function todoBriefLine(todos, now = Date.now(), startedAt) {
|
|
39001
|
-
if (todos.length === 0)
|
|
39002
|
-
return "";
|
|
39003
|
-
const done = todos.filter((todo) => todo.status === "completed").length;
|
|
39004
|
-
const anchor = startedAt ?? todoSetStartedAt(todos, now);
|
|
39005
|
-
const secs = Math.max(0, Math.floor((now - anchor) / 1000));
|
|
39006
|
-
return t("overlay.widgets.todosBrief", {
|
|
39007
|
-
done,
|
|
39008
|
-
total: todos.length,
|
|
39009
|
-
secs
|
|
39010
|
-
});
|
|
39011
|
-
}
|
|
39012
|
-
function resetTodoBriefClock() {
|
|
39013
|
-
todoSetFirstSeen.clear();
|
|
39014
|
-
}
|
|
39015
39041
|
function subagentBatchAnchor(running, now = Date.now()) {
|
|
39016
39042
|
if (running === 0) {
|
|
39017
39043
|
subagentBatchStartedAt = undefined;
|
|
@@ -39040,47 +39066,6 @@ function subagentBriefLine(running, now = Date.now()) {
|
|
|
39040
39066
|
const elapsedSec = Math.max(0, Math.floor((now - anchor) / 1000));
|
|
39041
39067
|
return subagentBriefText(running, elapsedSec);
|
|
39042
39068
|
}
|
|
39043
|
-
function toolMarker(status) {
|
|
39044
|
-
return status === "running" ? "\u2699" : status === "failed" ? "\u2718" : "\u2714";
|
|
39045
|
-
}
|
|
39046
|
-
function toolLineText(row, spin, now = Date.now()) {
|
|
39047
|
-
const subject = toolSubject(row.args);
|
|
39048
|
-
const title = subject === "" ? row.name : `${row.name} ${subject}`;
|
|
39049
|
-
const elapsed = row.status === "running" ? row.startedAt !== undefined ? ` \xB7 ${((now - row.startedAt) / 1000).toFixed(1)}s` : "" : row.elapsedSec !== undefined ? ` \xB7 ${row.elapsedSec.toFixed(1)}s` : "";
|
|
39050
|
-
const marker = toolMarker(row.status);
|
|
39051
|
-
spin();
|
|
39052
|
-
const tail = row.status === "running" ? toolDetail(row.args) : toolResultLine(row.output);
|
|
39053
|
-
const body = `${title}${elapsed}${tail !== "" ? ` \xB7 ${tail}` : ""}`;
|
|
39054
|
-
return `${marker} ${body}`;
|
|
39055
|
-
}
|
|
39056
|
-
function thinkBlockLines(row, spin, maxLines = DOCK_WIDGET_MAX_LINES, now = Date.now()) {
|
|
39057
|
-
const lines = row.text.replace(/\r/g, "").split(`
|
|
39058
|
-
`).filter((line) => line.trim() !== "");
|
|
39059
|
-
const n = Math.max(1, Math.floor(maxLines));
|
|
39060
|
-
if (row.streaming === true) {
|
|
39061
|
-
const secs = row.startedAt !== undefined ? `${((now - row.startedAt) / 1000).toFixed(1)}s` : "0.0s";
|
|
39062
|
-
spin();
|
|
39063
|
-
const picked = lines.length === 0 ? [""] : lines.slice(-n);
|
|
39064
|
-
return picked.map((line, index) => index === 0 ? t("overlay.widgets.thinkStreaming", {
|
|
39065
|
-
secs,
|
|
39066
|
-
line
|
|
39067
|
-
}) : ` ${line}`);
|
|
39068
|
-
}
|
|
39069
|
-
if (row.elapsedSec !== undefined) {
|
|
39070
|
-
const secs = `${row.elapsedSec.toFixed(1)}s`;
|
|
39071
|
-
const picked = lines.length === 0 ? [""] : lines.slice(-n);
|
|
39072
|
-
return picked.map((line, index) => index === 0 ? t("overlay.widgets.thinkCollapsed", {
|
|
39073
|
-
secs,
|
|
39074
|
-
line
|
|
39075
|
-
}) : ` ${line}`);
|
|
39076
|
-
}
|
|
39077
|
-
return [];
|
|
39078
|
-
}
|
|
39079
|
-
function activityScene(hasRunningSubagent, hasVisibleThink) {
|
|
39080
|
-
if (hasRunningSubagent)
|
|
39081
|
-
return "A";
|
|
39082
|
-
return hasVisibleThink ? "B" : "C";
|
|
39083
|
-
}
|
|
39084
39069
|
function dockBlocks(rows, options = {}) {
|
|
39085
39070
|
dockSpin();
|
|
39086
39071
|
const now = options.now ?? Date.now();
|
|
@@ -39765,7 +39750,7 @@ function dockLineNode(line, width, ctx, fgFor, accentFg) {
|
|
|
39765
39750
|
return _el$0;
|
|
39766
39751
|
})();
|
|
39767
39752
|
}
|
|
39768
|
-
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, DEFAULT_ACTIVITY_PANEL_GEAR = "5", 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, activityDockTab, setActivityDockTab, DOCK_TAB_ICON, DOCK_TAB_PADDING_STEPS, dockTabDigit = (label) => label.match(/^\d+/)?.[0] ?? "",
|
|
39753
|
+
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, DEFAULT_ACTIVITY_PANEL_GEAR = "5", 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, activityDockTab, setActivityDockTab, DOCK_TAB_ICON, DOCK_TAB_PADDING_STEPS, dockTabDigit = (label) => label.match(/^\d+/)?.[0] ?? "", subagentBatchStartedAt, prevSubagentRunning = 0, TODO_TOOL_NAMES, 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;
|
|
39769
39754
|
var init_widgets_dock = __esm(() => {
|
|
39770
39755
|
init_index_bun();
|
|
39771
39756
|
init_index_bun();
|
|
@@ -39790,8 +39775,10 @@ var init_widgets_dock = __esm(() => {
|
|
|
39790
39775
|
init_dock_visibility();
|
|
39791
39776
|
init_powerline();
|
|
39792
39777
|
init_merged_dock();
|
|
39778
|
+
init_dock_line_primitives();
|
|
39793
39779
|
init_keymap();
|
|
39794
39780
|
init_input_ownership();
|
|
39781
|
+
init_dock_line_primitives();
|
|
39795
39782
|
ACTIVITY_PANEL_GEARS = ["1", "5", "7", "10", "all"];
|
|
39796
39783
|
[activityPanelGear, setActivityPanelGear] = createSignal(undefined);
|
|
39797
39784
|
[dockHeightTween, setDockHeightTween] = createSignal(undefined);
|
|
@@ -39804,7 +39791,6 @@ var init_widgets_dock = __esm(() => {
|
|
|
39804
39791
|
todo: "\uD83D\uDCCB"
|
|
39805
39792
|
};
|
|
39806
39793
|
DOCK_TAB_PADDING_STEPS = [2, 1, 0];
|
|
39807
|
-
todoSetFirstSeen = new Map;
|
|
39808
39794
|
TODO_TOOL_NAMES = new Set(["todowrite", "todo_write"]);
|
|
39809
39795
|
DOCK_ACCENT_STEPS = {
|
|
39810
39796
|
think: [200, 300, 100, 400, 500, 600, 700, 800, 900],
|
|
@@ -44462,26 +44448,7 @@ function journalToJSONL(entries) {
|
|
|
44462
44448
|
}
|
|
44463
44449
|
var init_export = () => {};
|
|
44464
44450
|
|
|
44465
|
-
// ../tui-base/src/routes/session/
|
|
44466
|
-
import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
|
|
44467
|
-
import { dirname as dirname2 } from "path";
|
|
44468
|
-
function persistHints(seam) {
|
|
44469
|
-
try {
|
|
44470
|
-
seam.configSave?.({ footerHints: footerHints(), lang: hintsLocale() });
|
|
44471
|
-
} catch (error) {
|
|
44472
|
-
console.error("[commands] hints persist failed:", error);
|
|
44473
|
-
}
|
|
44474
|
-
}
|
|
44475
|
-
function persistLang(seam, lang) {
|
|
44476
|
-
try {
|
|
44477
|
-
seam.configSave?.({ lang });
|
|
44478
|
-
} catch (error) {
|
|
44479
|
-
console.error("[commands] language persist failed:", error);
|
|
44480
|
-
}
|
|
44481
|
-
}
|
|
44482
|
-
function seamFailureReason(error) {
|
|
44483
|
-
return String(error instanceof Error ? error.message : error).slice(0, 150);
|
|
44484
|
-
}
|
|
44451
|
+
// ../tui-base/src/routes/session/command-families/prune.ts
|
|
44485
44452
|
function pruneReasonLabel(reason) {
|
|
44486
44453
|
const key = PRUNE_REASON_KEYS[reason];
|
|
44487
44454
|
return key === undefined ? t("command.prune.reason.other", { reason }) : t(key);
|
|
@@ -44567,6 +44534,34 @@ function formatRestoreListRows(list) {
|
|
|
44567
44534
|
}
|
|
44568
44535
|
return rows;
|
|
44569
44536
|
}
|
|
44537
|
+
var PRUNE_REASON_KEYS;
|
|
44538
|
+
var init_prune = __esm(() => {
|
|
44539
|
+
init_i18n();
|
|
44540
|
+
PRUNE_REASON_KEYS = {
|
|
44541
|
+
"retention-disabled": "command.prune.reason.retentionDisabled",
|
|
44542
|
+
"field-anomaly": "command.prune.reason.fieldAnomaly",
|
|
44543
|
+
current: "command.prune.reason.current",
|
|
44544
|
+
staged: "command.prune.reason.staged",
|
|
44545
|
+
"agent-available": "command.prune.reason.agentAvailable",
|
|
44546
|
+
running: "command.prune.reason.running",
|
|
44547
|
+
"missing-time": "command.prune.reason.missingTime",
|
|
44548
|
+
"future-time": "command.prune.reason.futureTime",
|
|
44549
|
+
"subtree-running": "command.prune.reason.subtreeRunning",
|
|
44550
|
+
unknown: "command.prune.reason.unknown",
|
|
44551
|
+
"no-location": "command.prune.reason.noLocation",
|
|
44552
|
+
"header-mismatch": "command.prune.reason.headerMismatch",
|
|
44553
|
+
"basename-mismatch": "command.prune.reason.basenameMismatch",
|
|
44554
|
+
"not-directory": "command.prune.reason.notDirectory",
|
|
44555
|
+
"escaped-root": "command.prune.reason.escapedRoot",
|
|
44556
|
+
"lock-fresh": "command.prune.reason.lockFresh",
|
|
44557
|
+
"lock-held": "command.prune.reason.lockHeld",
|
|
44558
|
+
"fresh-mtime": "command.prune.reason.freshMtime",
|
|
44559
|
+
"blank-grace": "command.prune.reason.blankGrace",
|
|
44560
|
+
"within-retention": "command.prune.reason.withinRetention"
|
|
44561
|
+
};
|
|
44562
|
+
});
|
|
44563
|
+
|
|
44564
|
+
// ../tui-base/src/routes/session/command-families/preset.ts
|
|
44570
44565
|
function presetNextRow(rows, currentId) {
|
|
44571
44566
|
if (rows.length <= 1)
|
|
44572
44567
|
return;
|
|
@@ -44590,6 +44585,8 @@ function presetLabelFor(rows, currentId) {
|
|
|
44590
44585
|
const marked = rows.find((row) => row.isDefault) ?? rows.find((row) => row.id === "standard");
|
|
44591
44586
|
return (marked ?? rows[0])?.name;
|
|
44592
44587
|
}
|
|
44588
|
+
|
|
44589
|
+
// ../tui-base/src/routes/session/command-families/permission-cwd.ts
|
|
44593
44590
|
function isRiskPermissionPreset(value, name) {
|
|
44594
44591
|
return /danger-full-access|full.?access|auto/i.test(`${value} ${name ?? ""}`);
|
|
44595
44592
|
}
|
|
@@ -44602,6 +44599,27 @@ function cwdBasename(cwd) {
|
|
|
44602
44599
|
const parts = trimmed.split(/[\\/]/);
|
|
44603
44600
|
return parts[parts.length - 1] || trimmed;
|
|
44604
44601
|
}
|
|
44602
|
+
|
|
44603
|
+
// ../tui-base/src/routes/session/commands.ts
|
|
44604
|
+
import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
|
|
44605
|
+
import { dirname as dirname2 } from "path";
|
|
44606
|
+
function persistHints(seam) {
|
|
44607
|
+
try {
|
|
44608
|
+
seam.configSave?.({ footerHints: footerHints(), lang: hintsLocale() });
|
|
44609
|
+
} catch (error) {
|
|
44610
|
+
console.error("[commands] hints persist failed:", error);
|
|
44611
|
+
}
|
|
44612
|
+
}
|
|
44613
|
+
function persistLang(seam, lang) {
|
|
44614
|
+
try {
|
|
44615
|
+
seam.configSave?.({ lang });
|
|
44616
|
+
} catch (error) {
|
|
44617
|
+
console.error("[commands] language persist failed:", error);
|
|
44618
|
+
}
|
|
44619
|
+
}
|
|
44620
|
+
function seamFailureReason(error) {
|
|
44621
|
+
return String(error instanceof Error ? error.message : error).slice(0, 150);
|
|
44622
|
+
}
|
|
44605
44623
|
async function applyRoutePlan(plan, settings, onFailure) {
|
|
44606
44624
|
if (plan.kind === "invalid") {
|
|
44607
44625
|
onFailure(plan.reason);
|
|
@@ -45964,7 +45982,7 @@ function dispatchLine(commands, line) {
|
|
|
45964
45982
|
function unknownCommandRow(name) {
|
|
45965
45983
|
return `unknown command: ${name} (try /help)`;
|
|
45966
45984
|
}
|
|
45967
|
-
var MODEL_DEFAULT_EFFORT_PICK = "__model_default__"
|
|
45985
|
+
var MODEL_DEFAULT_EFFORT_PICK = "__model_default__";
|
|
45968
45986
|
var init_commands = __esm(() => {
|
|
45969
45987
|
init_i18n();
|
|
45970
45988
|
init_hotkeys();
|
|
@@ -45973,28 +45991,8 @@ var init_commands = __esm(() => {
|
|
|
45973
45991
|
init_hints_line();
|
|
45974
45992
|
init_motion();
|
|
45975
45993
|
init_export();
|
|
45976
|
-
|
|
45977
|
-
|
|
45978
|
-
"field-anomaly": "command.prune.reason.fieldAnomaly",
|
|
45979
|
-
current: "command.prune.reason.current",
|
|
45980
|
-
staged: "command.prune.reason.staged",
|
|
45981
|
-
"agent-available": "command.prune.reason.agentAvailable",
|
|
45982
|
-
running: "command.prune.reason.running",
|
|
45983
|
-
"missing-time": "command.prune.reason.missingTime",
|
|
45984
|
-
"future-time": "command.prune.reason.futureTime",
|
|
45985
|
-
"subtree-running": "command.prune.reason.subtreeRunning",
|
|
45986
|
-
unknown: "command.prune.reason.unknown",
|
|
45987
|
-
"no-location": "command.prune.reason.noLocation",
|
|
45988
|
-
"header-mismatch": "command.prune.reason.headerMismatch",
|
|
45989
|
-
"basename-mismatch": "command.prune.reason.basenameMismatch",
|
|
45990
|
-
"not-directory": "command.prune.reason.notDirectory",
|
|
45991
|
-
"escaped-root": "command.prune.reason.escapedRoot",
|
|
45992
|
-
"lock-fresh": "command.prune.reason.lockFresh",
|
|
45993
|
-
"lock-held": "command.prune.reason.lockHeld",
|
|
45994
|
-
"fresh-mtime": "command.prune.reason.freshMtime",
|
|
45995
|
-
"blank-grace": "command.prune.reason.blankGrace",
|
|
45996
|
-
"within-retention": "command.prune.reason.withinRetention"
|
|
45997
|
-
};
|
|
45994
|
+
init_prune();
|
|
45995
|
+
init_prune();
|
|
45998
45996
|
});
|
|
45999
45997
|
|
|
46000
45998
|
// ../tui-base/src/routes/session/slash-complete.ts
|
|
@@ -55648,7 +55646,7 @@ var init_subagents_viewer = __esm(() => {
|
|
|
55648
55646
|
import { TextAttributes as TextAttributes12 } from "@opentui/core";
|
|
55649
55647
|
function resolveVersion() {
|
|
55650
55648
|
try {
|
|
55651
|
-
return "0.29.
|
|
55649
|
+
return "0.29.2";
|
|
55652
55650
|
} catch {
|
|
55653
55651
|
return "dev";
|
|
55654
55652
|
}
|
|
@@ -60260,142 +60258,26 @@ var init_subagent_policy = __esm(() => {
|
|
|
60260
60258
|
DEFAULT_SUBAGENT_ROUND_LIMITS = { maxRounds: DEFAULT_MAX_ROUNDS2, maxRoundsGrace: 0 };
|
|
60261
60259
|
});
|
|
60262
60260
|
|
|
60263
|
-
// src/client/bridge-
|
|
60264
|
-
|
|
60265
|
-
|
|
60266
|
-
|
|
60267
|
-
|
|
60268
|
-
|
|
60269
|
-
|
|
60270
|
-
|
|
60271
|
-
|
|
60272
|
-
|
|
60273
|
-
|
|
60274
|
-
|
|
60275
|
-
const value = row[key];
|
|
60276
|
-
return typeof value === "string" && value !== "" ? value : undefined;
|
|
60277
|
-
}
|
|
60278
|
-
function parseAskRequest(value) {
|
|
60279
|
-
const row = asRecord12(value);
|
|
60280
|
-
const eventId = optionalStringField(row, "eventId");
|
|
60281
|
-
const sessionId = optionalStringField(row, "sessionId");
|
|
60282
|
-
const kind = row.kind;
|
|
60283
|
-
if (eventId === undefined || sessionId === undefined || kind !== "approval" && kind !== "questions") {
|
|
60284
|
-
return;
|
|
60285
|
-
}
|
|
60286
|
-
const out = { eventId, sessionId, kind };
|
|
60287
|
-
for (const key of ["toolName", "callId", "reason", "childSessionId", "parentSessionId"]) {
|
|
60288
|
-
const v = optionalStringField(row, key);
|
|
60289
|
-
if (v !== undefined)
|
|
60290
|
-
out[key] = v;
|
|
60291
|
-
}
|
|
60292
|
-
for (const key of ["deadlineAt", "detachGraceMs"]) {
|
|
60293
|
-
const v = row[key];
|
|
60294
|
-
if (typeof v === "number" && Number.isFinite(v))
|
|
60295
|
-
out[key] = v;
|
|
60296
|
-
}
|
|
60297
|
-
if (row.escalation === true)
|
|
60298
|
-
out.escalation = true;
|
|
60299
|
-
if (Array.isArray(row.questions)) {
|
|
60300
|
-
const questions = [];
|
|
60301
|
-
for (const raw of row.questions) {
|
|
60302
|
-
const q = asRecord12(raw);
|
|
60303
|
-
const id = optionalStringField(q, "id");
|
|
60304
|
-
const prompt = optionalStringField(q, "prompt");
|
|
60305
|
-
if (id === undefined || prompt === undefined || !Array.isArray(q.options))
|
|
60306
|
-
continue;
|
|
60307
|
-
const options = [];
|
|
60308
|
-
for (const rawOpt of q.options) {
|
|
60309
|
-
const opt = asRecord12(rawOpt);
|
|
60310
|
-
const label = optionalStringField(opt, "label");
|
|
60311
|
-
if (label === undefined)
|
|
60312
|
-
continue;
|
|
60313
|
-
const description = optionalStringField(opt, "description");
|
|
60314
|
-
options.push({ label, ...description !== undefined ? { description } : {} });
|
|
60315
|
-
}
|
|
60316
|
-
if (options.length === 0)
|
|
60317
|
-
continue;
|
|
60318
|
-
const question = { id, prompt, options };
|
|
60319
|
-
for (const key of ["header", "description", "detail"]) {
|
|
60320
|
-
const v = optionalStringField(q, key);
|
|
60321
|
-
if (v !== undefined)
|
|
60322
|
-
question[key] = v;
|
|
60323
|
-
}
|
|
60324
|
-
if (q.multiSelect === true)
|
|
60325
|
-
question.multiSelect = true;
|
|
60326
|
-
questions.push(question);
|
|
60261
|
+
// src/client/seam-projections/bridge-protocol-error.ts
|
|
60262
|
+
var BridgeProtocolError;
|
|
60263
|
+
var init_bridge_protocol_error = __esm(() => {
|
|
60264
|
+
BridgeProtocolError = class BridgeProtocolError extends Error {
|
|
60265
|
+
code;
|
|
60266
|
+
detail;
|
|
60267
|
+
constructor(code, message, detail) {
|
|
60268
|
+
super(message);
|
|
60269
|
+
this.name = "BridgeProtocolError";
|
|
60270
|
+
this.code = code;
|
|
60271
|
+
if (detail !== undefined)
|
|
60272
|
+
this.detail = detail;
|
|
60327
60273
|
}
|
|
60328
|
-
if (questions.length > 0)
|
|
60329
|
-
out.questions = questions;
|
|
60330
|
-
}
|
|
60331
|
-
return out;
|
|
60332
|
-
}
|
|
60333
|
-
function approvalArgs(request) {
|
|
60334
|
-
return {
|
|
60335
|
-
...request.callId !== undefined ? { callId: request.callId } : {},
|
|
60336
|
-
...request.reason !== undefined ? { reason: request.reason } : {},
|
|
60337
|
-
...request.parentSessionId !== undefined ? { eventId: request.eventId } : {}
|
|
60338
|
-
};
|
|
60339
|
-
}
|
|
60340
|
-
function approvalQuestion(request) {
|
|
60341
|
-
const toolName = request.toolName ?? "tool";
|
|
60342
|
-
return {
|
|
60343
|
-
id: request.eventId,
|
|
60344
|
-
prompt: request.reason ?? `Allow ${toolName}?`,
|
|
60345
|
-
options: [{ label: "allow" }, { label: "deny" }],
|
|
60346
|
-
header: "Approval",
|
|
60347
|
-
...request.callId !== undefined ? { detail: `callId: ${request.callId}` } : {}
|
|
60348
60274
|
};
|
|
60349
|
-
}
|
|
60350
|
-
|
|
60351
|
-
|
|
60352
|
-
const choice = pick?.custom ?? pick?.selections?.[0] ?? pick?.selected ?? "";
|
|
60353
|
-
return /^(allow|allowed-once|yes|approve)$/i.test(choice) ? "allowed-once" : "rejected";
|
|
60354
|
-
}
|
|
60355
|
-
function answersFor(request, picks) {
|
|
60356
|
-
const questions = request.questions ?? [];
|
|
60357
|
-
if (questions.length === 0) {
|
|
60358
|
-
return picks.map((pick) => ({
|
|
60359
|
-
id: pick.questionId,
|
|
60360
|
-
selected: pick.selections?.length ? [...pick.selections] : [pick.selected],
|
|
60361
|
-
...pick.custom !== undefined && pick.custom !== "" ? { custom: pick.custom } : {}
|
|
60362
|
-
}));
|
|
60363
|
-
}
|
|
60364
|
-
return questions.map((q) => {
|
|
60365
|
-
const pick = picks.find((p) => p.questionId === q.id);
|
|
60366
|
-
if (pick?.custom !== undefined && pick.custom !== "")
|
|
60367
|
-
return { id: q.id, selected: [], custom: pick.custom };
|
|
60368
|
-
if (pick === undefined || pick.selected === "" && (pick.custom ?? "") === "") {
|
|
60369
|
-
return { id: q.id, selected: [], custom: "declined" };
|
|
60370
|
-
}
|
|
60371
|
-
return {
|
|
60372
|
-
id: q.id,
|
|
60373
|
-
selected: pick.selections?.length ? [...pick.selections] : [pick.selected]
|
|
60374
|
-
};
|
|
60375
|
-
});
|
|
60376
|
-
}
|
|
60377
|
-
function unavailableResponse(request) {
|
|
60378
|
-
return request.kind === "questions" ? { eventId: request.eventId, kind: "questions", verdict: "unavailable", answers: answersFor(request, []) } : { eventId: request.eventId, kind: "approval", verdict: "unavailable" };
|
|
60379
|
-
}
|
|
60275
|
+
});
|
|
60276
|
+
|
|
60277
|
+
// src/client/seam-projections/prune-purge.ts
|
|
60380
60278
|
function asRecord12(value) {
|
|
60381
60279
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
60382
60280
|
}
|
|
60383
|
-
function projectSeamAccountView(value) {
|
|
60384
|
-
const v = asRecord12(value);
|
|
60385
|
-
return {
|
|
60386
|
-
status: typeof v.status === "string" && ACCOUNT_STATUSES.has(v.status) ? v.status : null,
|
|
60387
|
-
attemptPhase: typeof v.attemptPhase === "string" && ACCOUNT_PHASES.has(v.attemptPhase) ? v.attemptPhase : null,
|
|
60388
|
-
authorizeUrlReady: v.authorizeUrlReady === true,
|
|
60389
|
-
linksPresent: v.linksPresent === true
|
|
60390
|
-
};
|
|
60391
|
-
}
|
|
60392
|
-
function accountClientMeta() {
|
|
60393
|
-
return {
|
|
60394
|
-
version: "0.25-w1b",
|
|
60395
|
-
locale: typeof Intl !== "undefined" ? Intl.DateTimeFormat().resolvedOptions().locale : "en",
|
|
60396
|
-
timezoneOffsetSeconds: -new Date().getTimezoneOffset() * 60
|
|
60397
|
-
};
|
|
60398
|
-
}
|
|
60399
60281
|
function projectBridgePrunePlan(value) {
|
|
60400
60282
|
const record = asRecord12(value);
|
|
60401
60283
|
if (!Array.isArray(record.entries)) {
|
|
@@ -60567,21 +60449,26 @@ function projectBridgePruneRestore(value) {
|
|
|
60567
60449
|
}
|
|
60568
60450
|
return { id: record.id, restored: true, opId: record.opId };
|
|
60569
60451
|
}
|
|
60570
|
-
|
|
60571
|
-
|
|
60452
|
+
var init_prune_purge = __esm(() => {
|
|
60453
|
+
init_bridge_protocol_error();
|
|
60454
|
+
});
|
|
60455
|
+
|
|
60456
|
+
// src/client/seam-projections/session-list.ts
|
|
60457
|
+
function asRecord13(value) {
|
|
60458
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
60572
60459
|
}
|
|
60573
60460
|
function projectBridgeSessionList(items, limit = 12) {
|
|
60574
60461
|
const rows = Array.isArray(items) ? items : [];
|
|
60575
60462
|
const out = [];
|
|
60576
60463
|
for (const item of rows) {
|
|
60577
|
-
const row =
|
|
60464
|
+
const row = asRecord13(item);
|
|
60578
60465
|
if (row.origin === "subagent")
|
|
60579
60466
|
continue;
|
|
60580
60467
|
const id = typeof row.sessionId === "string" ? row.sessionId : "";
|
|
60581
60468
|
if (!id)
|
|
60582
60469
|
continue;
|
|
60583
60470
|
const updatedAt = typeof row.updatedAt === "number" ? String(row.updatedAt) : "";
|
|
60584
|
-
const values =
|
|
60471
|
+
const values = asRecord13(asRecord13(row.projections).values);
|
|
60585
60472
|
const title = typeof values.title === "string" ? values.title : "";
|
|
60586
60473
|
out.push({
|
|
60587
60474
|
id,
|
|
@@ -60598,15 +60485,155 @@ function projectCurrentCwd(items, sessionId) {
|
|
|
60598
60485
|
if (sessionId === undefined || sessionId === "" || !Array.isArray(items))
|
|
60599
60486
|
return;
|
|
60600
60487
|
for (const item of items) {
|
|
60601
|
-
const row =
|
|
60488
|
+
const row = asRecord13(item);
|
|
60602
60489
|
if (row.sessionId !== sessionId)
|
|
60603
60490
|
continue;
|
|
60604
60491
|
return typeof row.cwd === "string" && row.cwd !== "" ? row.cwd : undefined;
|
|
60605
60492
|
}
|
|
60606
60493
|
return;
|
|
60607
60494
|
}
|
|
60495
|
+
|
|
60496
|
+
// src/client/bridge-session-seam.ts
|
|
60497
|
+
import { existsSync as existsSync8, readFileSync as readFileSync9, readdirSync as readdirSync4 } from "fs";
|
|
60498
|
+
import { join as join10 } from "path";
|
|
60499
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
60500
|
+
function writeConfirmed(confirm) {
|
|
60501
|
+
return typeof confirm === "object" && confirm !== null && confirm.__pluginWriteConfirm === true && typeof confirm.operation === "string";
|
|
60502
|
+
}
|
|
60503
|
+
function askTurnId(eventId) {
|
|
60504
|
+
const i = eventId.lastIndexOf(":ask-");
|
|
60505
|
+
return i === -1 ? "" : eventId.slice(0, i);
|
|
60506
|
+
}
|
|
60507
|
+
function optionalStringField(row, key) {
|
|
60508
|
+
const value = row[key];
|
|
60509
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
60510
|
+
}
|
|
60511
|
+
function parseAskRequest(value) {
|
|
60512
|
+
const row = asRecord14(value);
|
|
60513
|
+
const eventId = optionalStringField(row, "eventId");
|
|
60514
|
+
const sessionId = optionalStringField(row, "sessionId");
|
|
60515
|
+
const kind = row.kind;
|
|
60516
|
+
if (eventId === undefined || sessionId === undefined || kind !== "approval" && kind !== "questions") {
|
|
60517
|
+
return;
|
|
60518
|
+
}
|
|
60519
|
+
const out = { eventId, sessionId, kind };
|
|
60520
|
+
for (const key of ["toolName", "callId", "reason", "childSessionId", "parentSessionId"]) {
|
|
60521
|
+
const v = optionalStringField(row, key);
|
|
60522
|
+
if (v !== undefined)
|
|
60523
|
+
out[key] = v;
|
|
60524
|
+
}
|
|
60525
|
+
for (const key of ["deadlineAt", "detachGraceMs"]) {
|
|
60526
|
+
const v = row[key];
|
|
60527
|
+
if (typeof v === "number" && Number.isFinite(v))
|
|
60528
|
+
out[key] = v;
|
|
60529
|
+
}
|
|
60530
|
+
if (row.escalation === true)
|
|
60531
|
+
out.escalation = true;
|
|
60532
|
+
if (Array.isArray(row.questions)) {
|
|
60533
|
+
const questions = [];
|
|
60534
|
+
for (const raw of row.questions) {
|
|
60535
|
+
const q = asRecord14(raw);
|
|
60536
|
+
const id = optionalStringField(q, "id");
|
|
60537
|
+
const prompt = optionalStringField(q, "prompt");
|
|
60538
|
+
if (id === undefined || prompt === undefined || !Array.isArray(q.options))
|
|
60539
|
+
continue;
|
|
60540
|
+
const options = [];
|
|
60541
|
+
for (const rawOpt of q.options) {
|
|
60542
|
+
const opt = asRecord14(rawOpt);
|
|
60543
|
+
const label = optionalStringField(opt, "label");
|
|
60544
|
+
if (label === undefined)
|
|
60545
|
+
continue;
|
|
60546
|
+
const description = optionalStringField(opt, "description");
|
|
60547
|
+
options.push({ label, ...description !== undefined ? { description } : {} });
|
|
60548
|
+
}
|
|
60549
|
+
if (options.length === 0)
|
|
60550
|
+
continue;
|
|
60551
|
+
const question = { id, prompt, options };
|
|
60552
|
+
for (const key of ["header", "description", "detail"]) {
|
|
60553
|
+
const v = optionalStringField(q, key);
|
|
60554
|
+
if (v !== undefined)
|
|
60555
|
+
question[key] = v;
|
|
60556
|
+
}
|
|
60557
|
+
if (q.multiSelect === true)
|
|
60558
|
+
question.multiSelect = true;
|
|
60559
|
+
questions.push(question);
|
|
60560
|
+
}
|
|
60561
|
+
if (questions.length > 0)
|
|
60562
|
+
out.questions = questions;
|
|
60563
|
+
}
|
|
60564
|
+
return out;
|
|
60565
|
+
}
|
|
60566
|
+
function approvalArgs(request) {
|
|
60567
|
+
return {
|
|
60568
|
+
...request.callId !== undefined ? { callId: request.callId } : {},
|
|
60569
|
+
...request.reason !== undefined ? { reason: request.reason } : {},
|
|
60570
|
+
...request.parentSessionId !== undefined ? { eventId: request.eventId } : {}
|
|
60571
|
+
};
|
|
60572
|
+
}
|
|
60573
|
+
function approvalQuestion(request) {
|
|
60574
|
+
const toolName = request.toolName ?? "tool";
|
|
60575
|
+
return {
|
|
60576
|
+
id: request.eventId,
|
|
60577
|
+
prompt: request.reason ?? `Allow ${toolName}?`,
|
|
60578
|
+
options: [{ label: "allow" }, { label: "deny" }],
|
|
60579
|
+
header: "Approval",
|
|
60580
|
+
...request.callId !== undefined ? { detail: `callId: ${request.callId}` } : {}
|
|
60581
|
+
};
|
|
60582
|
+
}
|
|
60583
|
+
function approvalVerdictFromPicks(request, picks) {
|
|
60584
|
+
const pick = picks.find((p) => p.questionId === request.eventId);
|
|
60585
|
+
const choice = pick?.custom ?? pick?.selections?.[0] ?? pick?.selected ?? "";
|
|
60586
|
+
return /^(allow|allowed-once|yes|approve)$/i.test(choice) ? "allowed-once" : "rejected";
|
|
60587
|
+
}
|
|
60588
|
+
function answersFor(request, picks) {
|
|
60589
|
+
const questions = request.questions ?? [];
|
|
60590
|
+
if (questions.length === 0) {
|
|
60591
|
+
return picks.map((pick) => ({
|
|
60592
|
+
id: pick.questionId,
|
|
60593
|
+
selected: pick.selections?.length ? [...pick.selections] : [pick.selected],
|
|
60594
|
+
...pick.custom !== undefined && pick.custom !== "" ? { custom: pick.custom } : {}
|
|
60595
|
+
}));
|
|
60596
|
+
}
|
|
60597
|
+
return questions.map((q) => {
|
|
60598
|
+
const pick = picks.find((p) => p.questionId === q.id);
|
|
60599
|
+
if (pick?.custom !== undefined && pick.custom !== "")
|
|
60600
|
+
return { id: q.id, selected: [], custom: pick.custom };
|
|
60601
|
+
if (pick === undefined || pick.selected === "" && (pick.custom ?? "") === "") {
|
|
60602
|
+
return { id: q.id, selected: [], custom: "declined" };
|
|
60603
|
+
}
|
|
60604
|
+
return {
|
|
60605
|
+
id: q.id,
|
|
60606
|
+
selected: pick.selections?.length ? [...pick.selections] : [pick.selected]
|
|
60607
|
+
};
|
|
60608
|
+
});
|
|
60609
|
+
}
|
|
60610
|
+
function unavailableResponse(request) {
|
|
60611
|
+
return request.kind === "questions" ? { eventId: request.eventId, kind: "questions", verdict: "unavailable", answers: answersFor(request, []) } : { eventId: request.eventId, kind: "approval", verdict: "unavailable" };
|
|
60612
|
+
}
|
|
60613
|
+
function asRecord14(value) {
|
|
60614
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
60615
|
+
}
|
|
60616
|
+
function projectSeamAccountView(value) {
|
|
60617
|
+
const v = asRecord14(value);
|
|
60618
|
+
return {
|
|
60619
|
+
status: typeof v.status === "string" && ACCOUNT_STATUSES.has(v.status) ? v.status : null,
|
|
60620
|
+
attemptPhase: typeof v.attemptPhase === "string" && ACCOUNT_PHASES.has(v.attemptPhase) ? v.attemptPhase : null,
|
|
60621
|
+
authorizeUrlReady: v.authorizeUrlReady === true,
|
|
60622
|
+
linksPresent: v.linksPresent === true
|
|
60623
|
+
};
|
|
60624
|
+
}
|
|
60625
|
+
function accountClientMeta() {
|
|
60626
|
+
return {
|
|
60627
|
+
version: "0.25-w1b",
|
|
60628
|
+
locale: typeof Intl !== "undefined" ? Intl.DateTimeFormat().resolvedOptions().locale : "en",
|
|
60629
|
+
timezoneOffsetSeconds: -new Date().getTimezoneOffset() * 60
|
|
60630
|
+
};
|
|
60631
|
+
}
|
|
60632
|
+
function unsupported(capability) {
|
|
60633
|
+
throw new BridgeProtocolError("UNSUPPORTED", `${capability} is not backed by the in-process bridge`, { capability });
|
|
60634
|
+
}
|
|
60608
60635
|
function routeFromSelection(value) {
|
|
60609
|
-
const row =
|
|
60636
|
+
const row = asRecord14(value);
|
|
60610
60637
|
const providerID = typeof row.providerID === "string" ? row.providerID : typeof row.provider === "string" ? row.provider : "";
|
|
60611
60638
|
const modelID = typeof row.modelID === "string" ? row.modelID : typeof row.model === "string" ? row.model : "";
|
|
60612
60639
|
if (!providerID || !modelID)
|
|
@@ -60615,15 +60642,15 @@ function routeFromSelection(value) {
|
|
|
60615
60642
|
return { providerID, modelID, ...reasoningEffort !== undefined ? { reasoningEffort } : {} };
|
|
60616
60643
|
}
|
|
60617
60644
|
function routeFromSelectionEvent(payload) {
|
|
60618
|
-
const data =
|
|
60619
|
-
const nested =
|
|
60645
|
+
const data = asRecord14(payload);
|
|
60646
|
+
const nested = asRecord14(data.data);
|
|
60620
60647
|
return routeFromSelection(data.selection) ?? routeFromSelection(data) ?? routeFromSelection(nested.selection) ?? routeFromSelection(nested);
|
|
60621
60648
|
}
|
|
60622
60649
|
function routeFromHeader(payload) {
|
|
60623
|
-
const data =
|
|
60624
|
-
const header =
|
|
60625
|
-
const nested =
|
|
60626
|
-
const nestedHeader =
|
|
60650
|
+
const data = asRecord14(payload);
|
|
60651
|
+
const header = asRecord14(data.header);
|
|
60652
|
+
const nested = asRecord14(data.data);
|
|
60653
|
+
const nestedHeader = asRecord14(nested.header);
|
|
60627
60654
|
for (const candidate of [header.config, nestedHeader.config, data.config, header, nestedHeader]) {
|
|
60628
60655
|
const route = routeFromSelection(candidate);
|
|
60629
60656
|
if (route !== undefined)
|
|
@@ -60632,7 +60659,7 @@ function routeFromHeader(payload) {
|
|
|
60632
60659
|
return;
|
|
60633
60660
|
}
|
|
60634
60661
|
function routeFromContext(payload) {
|
|
60635
|
-
const data =
|
|
60662
|
+
const data = asRecord14(payload);
|
|
60636
60663
|
const providerID = optionalStringField(data, "provider");
|
|
60637
60664
|
const modelID = optionalStringField(data, "model");
|
|
60638
60665
|
if (providerID === undefined || modelID === undefined)
|
|
@@ -60694,7 +60721,7 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0, sessionId) {
|
|
|
60694
60721
|
type: row.type,
|
|
60695
60722
|
seq: row.seq,
|
|
60696
60723
|
time: 0,
|
|
60697
|
-
data:
|
|
60724
|
+
data: asRecord14(row.payload)
|
|
60698
60725
|
}));
|
|
60699
60726
|
const durable = journalToTranscriptRows(entries, skip);
|
|
60700
60727
|
const stored = durable.map((row) => {
|
|
@@ -60737,8 +60764,8 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0, sessionId) {
|
|
|
60737
60764
|
return merged;
|
|
60738
60765
|
}
|
|
60739
60766
|
function seamReplayEventKey(event) {
|
|
60740
|
-
const details =
|
|
60741
|
-
return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(
|
|
60767
|
+
const details = asRecord14(event.details);
|
|
60768
|
+
return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord14(details.part).id ?? "")}`;
|
|
60742
60769
|
}
|
|
60743
60770
|
function askJournalKind(row, data) {
|
|
60744
60771
|
if (typeof data.kind === "string" && data.kind !== "")
|
|
@@ -60752,7 +60779,7 @@ function deriveAskOutcomeNoticeViews(rows, sessionId) {
|
|
|
60752
60779
|
const out = [];
|
|
60753
60780
|
const terminals = new Map;
|
|
60754
60781
|
for (const row of rows) {
|
|
60755
|
-
const data =
|
|
60782
|
+
const data = asRecord14(row.payload);
|
|
60756
60783
|
const kind = askJournalKind(row, data);
|
|
60757
60784
|
if (kind !== "ask.responded" && kind !== "ask.cancelled")
|
|
60758
60785
|
continue;
|
|
@@ -60769,7 +60796,7 @@ function deriveAskOutcomeNoticeViews(rows, sessionId) {
|
|
|
60769
60796
|
const ordered = [...group].sort((a, b) => a.seq - b.seq);
|
|
60770
60797
|
const canonical = ordered[ordered.length - 1];
|
|
60771
60798
|
const noticeOf = (row) => {
|
|
60772
|
-
const data =
|
|
60799
|
+
const data = asRecord14(row.payload);
|
|
60773
60800
|
return deriveAskOutcomeNotice({
|
|
60774
60801
|
eventId,
|
|
60775
60802
|
sessionId,
|
|
@@ -60786,7 +60813,7 @@ function deriveAskOutcomeNoticeViews(rows, sessionId) {
|
|
|
60786
60813
|
const canonicalNotice = noticeOf(canonical);
|
|
60787
60814
|
if (canonicalNotice === undefined)
|
|
60788
60815
|
continue;
|
|
60789
|
-
const canonicalChild = optionalStringField(
|
|
60816
|
+
const canonicalChild = optionalStringField(asRecord14(canonical.payload), "childSessionId");
|
|
60790
60817
|
out.push({
|
|
60791
60818
|
id: canonicalNotice.id,
|
|
60792
60819
|
text: canonicalNotice.text,
|
|
@@ -60802,7 +60829,7 @@ function deriveAskOutcomeNoticeViews(rows, sessionId) {
|
|
|
60802
60829
|
if (other === undefined || seenText.has(other.text))
|
|
60803
60830
|
continue;
|
|
60804
60831
|
seenText.add(other.text);
|
|
60805
|
-
const childSessionId = optionalStringField(
|
|
60832
|
+
const childSessionId = optionalStringField(asRecord14(row.payload), "childSessionId");
|
|
60806
60833
|
out.push({
|
|
60807
60834
|
id: `${other.id}:seq-${row.seq}`,
|
|
60808
60835
|
text: `\u3010\u65E5\u5FD7\u7ED3\u5C40\u51B2\u7A81\u3011${other.text}`,
|
|
@@ -60817,7 +60844,7 @@ function deriveAskOutcomeNoticeViews(rows, sessionId) {
|
|
|
60817
60844
|
for (const row of rows) {
|
|
60818
60845
|
if (row.type !== "turn/end")
|
|
60819
60846
|
continue;
|
|
60820
|
-
const data =
|
|
60847
|
+
const data = asRecord14(row.payload);
|
|
60821
60848
|
const keys = [optionalStringField(data, "turnId")];
|
|
60822
60849
|
if (typeof data.turn === "number" && Number.isFinite(data.turn))
|
|
60823
60850
|
keys.push(String(data.turn));
|
|
@@ -60830,7 +60857,7 @@ function deriveAskOutcomeNoticeViews(rows, sessionId) {
|
|
|
60830
60857
|
}
|
|
60831
60858
|
}
|
|
60832
60859
|
for (const row of rows) {
|
|
60833
|
-
const data =
|
|
60860
|
+
const data = asRecord14(row.payload);
|
|
60834
60861
|
if (askJournalKind(row, data) !== "ask.requested")
|
|
60835
60862
|
continue;
|
|
60836
60863
|
const eventId = optionalStringField(data, "eventId");
|
|
@@ -60897,7 +60924,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
|
60897
60924
|
};
|
|
60898
60925
|
const toolCalls = new Map;
|
|
60899
60926
|
for (const row of rows) {
|
|
60900
|
-
const entry = { type: row.type, seq: row.seq, time: 0, data:
|
|
60927
|
+
const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord14(row.payload) };
|
|
60901
60928
|
for (const event of projectJournalRecord(entry, sessionId))
|
|
60902
60929
|
push(event);
|
|
60903
60930
|
const data = entry.data;
|
|
@@ -60911,7 +60938,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
|
60911
60938
|
});
|
|
60912
60939
|
}
|
|
60913
60940
|
} else if (row.type === "tool/result") {
|
|
60914
|
-
const message =
|
|
60941
|
+
const message = asRecord14(data.message);
|
|
60915
60942
|
const callId = data.callId !== undefined ? String(data.callId) : message.toolCallId !== undefined ? String(message.toolCallId) : "";
|
|
60916
60943
|
const call = callId ? toolCalls.get(callId) : undefined;
|
|
60917
60944
|
if (call !== undefined) {
|
|
@@ -60969,7 +60996,7 @@ function bridgeSettleChild(existing, outcome, startedAt, now) {
|
|
|
60969
60996
|
function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, live) {
|
|
60970
60997
|
const name = typeof data.name === "string" && data.name !== "" ? data.name : undefined;
|
|
60971
60998
|
if (type === "user/message") {
|
|
60972
|
-
const source =
|
|
60999
|
+
const source = asRecord14(data.source);
|
|
60973
61000
|
if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
|
|
60974
61001
|
return false;
|
|
60975
61002
|
const childId = typeof source.senderSessionId === "string" ? source.senderSessionId : "";
|
|
@@ -61076,7 +61103,7 @@ function bridgeSweepSettledChildIds(rows, parentId, locallyRunning) {
|
|
|
61076
61103
|
return [];
|
|
61077
61104
|
const settled = [];
|
|
61078
61105
|
for (const raw of rows) {
|
|
61079
|
-
const row =
|
|
61106
|
+
const row = asRecord14(raw);
|
|
61080
61107
|
if (row.origin !== "subagent")
|
|
61081
61108
|
continue;
|
|
61082
61109
|
if (row.parentSessionId !== parentId)
|
|
@@ -61126,16 +61153,16 @@ function bridgeChildJournalMeta(rows) {
|
|
|
61126
61153
|
let contextModel;
|
|
61127
61154
|
let descriptorModel;
|
|
61128
61155
|
for (const row of rows) {
|
|
61129
|
-
const data =
|
|
61156
|
+
const data = asRecord14(row.payload);
|
|
61130
61157
|
if (row.type === "assistant/message") {
|
|
61131
61158
|
rounds += 1;
|
|
61132
|
-
const message =
|
|
61159
|
+
const message = asRecord14(data.message);
|
|
61133
61160
|
const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
|
|
61134
61161
|
if (tail !== undefined)
|
|
61135
61162
|
lastLine = tail;
|
|
61136
61163
|
} else if (row.type === "tool/result") {
|
|
61137
61164
|
if (data.isError !== true) {
|
|
61138
|
-
const message =
|
|
61165
|
+
const message = asRecord14(data.message);
|
|
61139
61166
|
const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
|
|
61140
61167
|
if (tail !== undefined)
|
|
61141
61168
|
lastLine = tail;
|
|
@@ -61193,7 +61220,7 @@ function capChildLog(lines) {
|
|
|
61193
61220
|
return out;
|
|
61194
61221
|
}
|
|
61195
61222
|
function childTranscriptRowToLine(row) {
|
|
61196
|
-
const r =
|
|
61223
|
+
const r = asRecord14(row);
|
|
61197
61224
|
if (r.kind !== "assistant" && r.kind !== "tool")
|
|
61198
61225
|
return "";
|
|
61199
61226
|
const text = typeof r.text === "string" ? r.text : "";
|
|
@@ -61219,7 +61246,7 @@ function bridgeChildStopReason(rows) {
|
|
|
61219
61246
|
const row = rows[i];
|
|
61220
61247
|
if (row.type !== "user/message")
|
|
61221
61248
|
continue;
|
|
61222
|
-
const source =
|
|
61249
|
+
const source = asRecord14(asRecord14(row.payload).source);
|
|
61223
61250
|
if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
|
|
61224
61251
|
continue;
|
|
61225
61252
|
const reason = source.stopReason;
|
|
@@ -61230,7 +61257,7 @@ function bridgeChildStopReason(rows) {
|
|
|
61230
61257
|
const row = rows[i];
|
|
61231
61258
|
if (row.type !== "turn/end")
|
|
61232
61259
|
continue;
|
|
61233
|
-
const reason =
|
|
61260
|
+
const reason = asRecord14(asRecord14(row.payload).reason);
|
|
61234
61261
|
const kind = reason.kind;
|
|
61235
61262
|
if (typeof kind === "string" && kind !== "")
|
|
61236
61263
|
return kind;
|
|
@@ -61288,7 +61315,7 @@ function lastJournalTurnTerminal(rows, startOutsideWindow = false) {
|
|
|
61288
61315
|
return latest;
|
|
61289
61316
|
}
|
|
61290
61317
|
function journalTurnId(row) {
|
|
61291
|
-
const payload =
|
|
61318
|
+
const payload = asRecord14(row.payload);
|
|
61292
61319
|
if (typeof payload.turn === "number" && Number.isFinite(payload.turn))
|
|
61293
61320
|
return payload.turn;
|
|
61294
61321
|
if (typeof payload.turnId === "string" && payload.turnId !== "")
|
|
@@ -61296,7 +61323,7 @@ function journalTurnId(row) {
|
|
|
61296
61323
|
return;
|
|
61297
61324
|
}
|
|
61298
61325
|
function projectBridgeEvent(frame, sessionId) {
|
|
61299
|
-
const payload =
|
|
61326
|
+
const payload = asRecord14(frame.payload);
|
|
61300
61327
|
const turnId = typeof payload.turnId === "string" ? payload.turnId : "";
|
|
61301
61328
|
if (frame.type === "turn.start") {
|
|
61302
61329
|
return [{ type: "session.updated", details: { sessionID: sessionId, turnId, turn: "starting" } }];
|
|
@@ -61318,7 +61345,7 @@ function projectBridgeEvent(frame, sessionId) {
|
|
|
61318
61345
|
return [];
|
|
61319
61346
|
}
|
|
61320
61347
|
function parseUsage(value) {
|
|
61321
|
-
const u =
|
|
61348
|
+
const u = asRecord14(value);
|
|
61322
61349
|
const num = (...aliases) => {
|
|
61323
61350
|
let present = false;
|
|
61324
61351
|
let best = 0;
|
|
@@ -61347,7 +61374,7 @@ function parseUsage(value) {
|
|
|
61347
61374
|
return out;
|
|
61348
61375
|
}
|
|
61349
61376
|
function journalUsage(payload) {
|
|
61350
|
-
const usage =
|
|
61377
|
+
const usage = asRecord14(asRecord14(payload).usage);
|
|
61351
61378
|
const parsed = parseUsage(usage);
|
|
61352
61379
|
if (Object.keys(parsed).length === 0)
|
|
61353
61380
|
return;
|
|
@@ -61357,7 +61384,7 @@ function journalUsage(payload) {
|
|
|
61357
61384
|
return { ...parsed, total };
|
|
61358
61385
|
}
|
|
61359
61386
|
function asDeadCause(value) {
|
|
61360
|
-
const r =
|
|
61387
|
+
const r = asRecord14(value);
|
|
61361
61388
|
const stage = r.stage;
|
|
61362
61389
|
const stages = ["spawn", "handshake", "runtime", "closed"];
|
|
61363
61390
|
return {
|
|
@@ -61477,7 +61504,7 @@ class BridgeSessionSeam {
|
|
|
61477
61504
|
cancelSignIn: async (attemptId) => projectSeamAccountView(await this.#transport.request("account.cancelSignIn", { attemptId })),
|
|
61478
61505
|
signOut: async () => projectSeamAccountView(await this.#transport.request("account.signOut", { client: accountClientMeta() })),
|
|
61479
61506
|
hasRunningAccountTasks: async () => {
|
|
61480
|
-
const value =
|
|
61507
|
+
const value = asRecord14(await this.#transport.request("account.hasRunningAccountTasks"));
|
|
61481
61508
|
return value.running === true;
|
|
61482
61509
|
}
|
|
61483
61510
|
};
|
|
@@ -61702,7 +61729,7 @@ class BridgeSessionSeam {
|
|
|
61702
61729
|
return [];
|
|
61703
61730
|
const out = [];
|
|
61704
61731
|
for (const e of efforts) {
|
|
61705
|
-
const row =
|
|
61732
|
+
const row = asRecord14(e);
|
|
61706
61733
|
const id = typeof row.id === "string" ? row.id : "";
|
|
61707
61734
|
const name = typeof row.name === "string" ? row.name : "";
|
|
61708
61735
|
if (!id)
|
|
@@ -61824,7 +61851,7 @@ class BridgeSessionSeam {
|
|
|
61824
61851
|
}
|
|
61825
61852
|
async connect() {
|
|
61826
61853
|
try {
|
|
61827
|
-
const reply =
|
|
61854
|
+
const reply = asRecord14(await this.#transport.request("bridge.ping"));
|
|
61828
61855
|
this.#recordBridgeCapabilities(reply.capabilities);
|
|
61829
61856
|
this.#connection = "connected";
|
|
61830
61857
|
} catch (err) {
|
|
@@ -61913,7 +61940,7 @@ class BridgeSessionSeam {
|
|
|
61913
61940
|
this.#replayDrainPending = true;
|
|
61914
61941
|
let opened;
|
|
61915
61942
|
try {
|
|
61916
|
-
opened =
|
|
61943
|
+
opened = asRecord14(await this.#transport.request("session.open", { mode: "resume", id: sessionId }));
|
|
61917
61944
|
} catch (err) {
|
|
61918
61945
|
const code = err instanceof BridgeProtocolError ? err.code : "SESSION_OPEN_FAILED";
|
|
61919
61946
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -61923,7 +61950,7 @@ class BridgeSessionSeam {
|
|
|
61923
61950
|
this.#bufferedPendingSnapshot = undefined;
|
|
61924
61951
|
this.#replayDrainPending = false;
|
|
61925
61952
|
this.#settleSuspendedTurn();
|
|
61926
|
-
const errorDetail = err instanceof BridgeProtocolError ?
|
|
61953
|
+
const errorDetail = err instanceof BridgeProtocolError ? asRecord14(err.detail) : {};
|
|
61927
61954
|
const holder = typeof errorDetail.holder === "string" && errorDetail.holder.trim() !== "" ? errorDetail.holder : undefined;
|
|
61928
61955
|
const result = {
|
|
61929
61956
|
state: "locked",
|
|
@@ -62001,7 +62028,7 @@ class BridgeSessionSeam {
|
|
|
62001
62028
|
turnId: dead.turnId,
|
|
62002
62029
|
seq: terminal.seq,
|
|
62003
62030
|
terminalType: terminal.type,
|
|
62004
|
-
reason:
|
|
62031
|
+
reason: asRecord14(terminal.payload).reason,
|
|
62005
62032
|
payload: terminal.payload,
|
|
62006
62033
|
source: "journal"
|
|
62007
62034
|
}
|
|
@@ -62059,7 +62086,7 @@ class BridgeSessionSeam {
|
|
|
62059
62086
|
const seen = new Set;
|
|
62060
62087
|
const collected = [];
|
|
62061
62088
|
for (;; ) {
|
|
62062
|
-
const value =
|
|
62089
|
+
const value = asRecord14(await this.#transport.request("journal.replay", { sessionId, from }));
|
|
62063
62090
|
const rawRows = Array.isArray(value.rows) ? value.rows : [];
|
|
62064
62091
|
if (typeof value.cursor === "number" && Number.isFinite(value.cursor))
|
|
62065
62092
|
cursor = value.cursor;
|
|
@@ -62072,7 +62099,7 @@ class BridgeSessionSeam {
|
|
|
62072
62099
|
let added = 0;
|
|
62073
62100
|
let pageMax = from - 1;
|
|
62074
62101
|
for (const raw of rawRows) {
|
|
62075
|
-
const row =
|
|
62102
|
+
const row = asRecord14(raw);
|
|
62076
62103
|
const seq = row.seq;
|
|
62077
62104
|
if (typeof seq !== "number" || !Number.isFinite(seq) || seq < floor || seen.has(seq))
|
|
62078
62105
|
continue;
|
|
@@ -62121,7 +62148,7 @@ class BridgeSessionSeam {
|
|
|
62121
62148
|
};
|
|
62122
62149
|
const attempt = (remaining) => {
|
|
62123
62150
|
this.#transport.request("turn.abort", { turnId }).then((result) => {
|
|
62124
|
-
if (
|
|
62151
|
+
if (asRecord14(result).noop === true) {
|
|
62125
62152
|
fail(`turn.abort was a noop for turn ${turnId}; turn may still be running`, "TURN_ABORT_NOOP");
|
|
62126
62153
|
}
|
|
62127
62154
|
}).catch((err) => {
|
|
@@ -62259,7 +62286,7 @@ class BridgeSessionSeam {
|
|
|
62259
62286
|
stats.contextTokens = usage.total;
|
|
62260
62287
|
}
|
|
62261
62288
|
} else if (row.type === "request/context") {
|
|
62262
|
-
const data =
|
|
62289
|
+
const data = asRecord14(row.payload);
|
|
62263
62290
|
const window = data.contextWindow;
|
|
62264
62291
|
if (typeof window === "number" && Number.isFinite(window) && window > 0) {
|
|
62265
62292
|
const provider = typeof data.provider === "string" ? data.provider : "";
|
|
@@ -62404,7 +62431,7 @@ class BridgeSessionSeam {
|
|
|
62404
62431
|
this.#interruptInFlight.set(childId, generation);
|
|
62405
62432
|
let value;
|
|
62406
62433
|
try {
|
|
62407
|
-
value =
|
|
62434
|
+
value = asRecord14(await this.#transport.request("subagents.interrupt", { parentSessionId, childId }));
|
|
62408
62435
|
} catch (err) {
|
|
62409
62436
|
if (this.#interruptInFlight.get(childId) === generation)
|
|
62410
62437
|
this.#interruptInFlight.delete(childId);
|
|
@@ -62430,13 +62457,13 @@ class BridgeSessionSeam {
|
|
|
62430
62457
|
if (parentSessionId === undefined || parentSessionId === "") {
|
|
62431
62458
|
throw new BridgeProtocolError("NO_SESSION", "cannot stop children: no session is bound to this bridge connection");
|
|
62432
62459
|
}
|
|
62433
|
-
const value =
|
|
62460
|
+
const value = asRecord14(await this.#transport.request("subagents.stopChildren", { parentSessionId }));
|
|
62434
62461
|
const children = value.children;
|
|
62435
62462
|
if (!Array.isArray(children))
|
|
62436
62463
|
return [];
|
|
62437
62464
|
const sessionAtStart = this.#subagentSessionId;
|
|
62438
62465
|
const rows = children.map((row) => {
|
|
62439
|
-
const r =
|
|
62466
|
+
const r = asRecord14(row);
|
|
62440
62467
|
return {
|
|
62441
62468
|
childId: typeof r.childId === "string" ? r.childId : "",
|
|
62442
62469
|
disposition: typeof r.disposition === "string" ? r.disposition : "failed"
|
|
@@ -62462,10 +62489,10 @@ class BridgeSessionSeam {
|
|
|
62462
62489
|
return;
|
|
62463
62490
|
let stopped = false;
|
|
62464
62491
|
try {
|
|
62465
|
-
const items =
|
|
62492
|
+
const items = asRecord14(await this.#transport.request("session.list", { _request: {} })).items;
|
|
62466
62493
|
if (Array.isArray(items)) {
|
|
62467
62494
|
stopped = items.some((row) => {
|
|
62468
|
-
const item =
|
|
62495
|
+
const item = asRecord14(row);
|
|
62469
62496
|
return item.sessionId === childId && item.running === false;
|
|
62470
62497
|
});
|
|
62471
62498
|
}
|
|
@@ -62475,7 +62502,7 @@ class BridgeSessionSeam {
|
|
|
62475
62502
|
if (stopped) {
|
|
62476
62503
|
let reason = "aborted";
|
|
62477
62504
|
try {
|
|
62478
|
-
const rows =
|
|
62505
|
+
const rows = asRecord14(await this.#transport.request("journal.replay", { sessionId: childId })).rows;
|
|
62479
62506
|
if (Array.isArray(rows)) {
|
|
62480
62507
|
const clean = rows.filter((row) => row !== null && typeof row === "object" && !Array.isArray(row));
|
|
62481
62508
|
reason = bridgeChildStopReason(clean) ?? "aborted";
|
|
@@ -62535,7 +62562,7 @@ class BridgeSessionSeam {
|
|
|
62535
62562
|
} catch {
|
|
62536
62563
|
return;
|
|
62537
62564
|
}
|
|
62538
|
-
const items =
|
|
62565
|
+
const items = asRecord14(value).items;
|
|
62539
62566
|
if (!Array.isArray(items))
|
|
62540
62567
|
return;
|
|
62541
62568
|
const locallyRunning = new Set;
|
|
@@ -62580,7 +62607,7 @@ class BridgeSessionSeam {
|
|
|
62580
62607
|
this.#subagentJournalLoaded.add(key);
|
|
62581
62608
|
const sessionAtStart = this.#subagentSessionId;
|
|
62582
62609
|
try {
|
|
62583
|
-
const value =
|
|
62610
|
+
const value = asRecord14(await this.#transport.request("journal.replay", { sessionId: childId }));
|
|
62584
62611
|
const rows = value.rows;
|
|
62585
62612
|
if (!Array.isArray(rows)) {
|
|
62586
62613
|
this.#subagentTranscriptReadFailed.add(childId);
|
|
@@ -62698,7 +62725,7 @@ class BridgeSessionSeam {
|
|
|
62698
62725
|
}
|
|
62699
62726
|
}
|
|
62700
62727
|
#foldAgentFrame(frame) {
|
|
62701
|
-
const payload =
|
|
62728
|
+
const payload = asRecord14(frame.payload);
|
|
62702
62729
|
const frameSession = typeof payload.sessionId === "string" ? payload.sessionId : "";
|
|
62703
62730
|
if (this.#subagentSessionId !== undefined && frameSession !== "" && frameSession !== this.#subagentSessionId)
|
|
62704
62731
|
return;
|
|
@@ -62771,7 +62798,7 @@ class BridgeSessionSeam {
|
|
|
62771
62798
|
this.#emitSubagentViews();
|
|
62772
62799
|
}
|
|
62773
62800
|
#foldAgentProgress(frame) {
|
|
62774
|
-
const payload =
|
|
62801
|
+
const payload = asRecord14(frame.payload);
|
|
62775
62802
|
const frameSession = typeof payload.sessionId === "string" ? payload.sessionId : "";
|
|
62776
62803
|
if (this.#subagentSessionId !== undefined && frameSession !== "" && frameSession !== this.#subagentSessionId)
|
|
62777
62804
|
return;
|
|
@@ -62798,7 +62825,7 @@ class BridgeSessionSeam {
|
|
|
62798
62825
|
this.#emitSubagentViews();
|
|
62799
62826
|
}
|
|
62800
62827
|
#foldAgentTranscript(frame) {
|
|
62801
|
-
const payload =
|
|
62828
|
+
const payload = asRecord14(frame.payload);
|
|
62802
62829
|
const frameSession = typeof payload.sessionId === "string" ? payload.sessionId : "";
|
|
62803
62830
|
const childId = typeof payload.childId === "string" ? payload.childId : "";
|
|
62804
62831
|
const turnId = typeof payload.turnId === "string" ? payload.turnId : "";
|
|
@@ -62859,7 +62886,7 @@ class BridgeSessionSeam {
|
|
|
62859
62886
|
let changed = false;
|
|
62860
62887
|
const now = Date.now();
|
|
62861
62888
|
for (const row of rows) {
|
|
62862
|
-
if (this.#foldWithFrozenSettle(row.type,
|
|
62889
|
+
if (this.#foldWithFrozenSettle(row.type, asRecord14(row.payload), now, false))
|
|
62863
62890
|
changed = true;
|
|
62864
62891
|
}
|
|
62865
62892
|
if (rosterReset || changed) {
|
|
@@ -62894,7 +62921,7 @@ class BridgeSessionSeam {
|
|
|
62894
62921
|
}
|
|
62895
62922
|
async listSessions(limit) {
|
|
62896
62923
|
const value = await this.#transport.request("session.list");
|
|
62897
|
-
return projectBridgeSessionList(
|
|
62924
|
+
return projectBridgeSessionList(asRecord14(value).items, limit);
|
|
62898
62925
|
}
|
|
62899
62926
|
async planPrune(params) {
|
|
62900
62927
|
const staged = this.stagedSessionId();
|
|
@@ -62939,27 +62966,27 @@ class BridgeSessionSeam {
|
|
|
62939
62966
|
if (sessionId === undefined || sessionId === "")
|
|
62940
62967
|
return;
|
|
62941
62968
|
const value = await this.#transport.request("session.list");
|
|
62942
|
-
return projectCurrentCwd(
|
|
62969
|
+
return projectCurrentCwd(asRecord14(value).items, sessionId);
|
|
62943
62970
|
}
|
|
62944
62971
|
async storedTranscript(id, skip = 0) {
|
|
62945
62972
|
const value = await this.#transport.request("journal.replay", { sessionId: id });
|
|
62946
|
-
const rows = Array.isArray(
|
|
62973
|
+
const rows = Array.isArray(asRecord14(value).rows) ? asRecord14(value).rows : [];
|
|
62947
62974
|
this.#foldAgentReplayRows(rows, id);
|
|
62948
62975
|
this.#sweepSubagents(id);
|
|
62949
62976
|
return bridgeReplayRowsToSeamTranscript(rows, skip, id);
|
|
62950
62977
|
}
|
|
62951
62978
|
async sessionJournal(id) {
|
|
62952
62979
|
const value = await this.#transport.request("journal.replay", { sessionId: id });
|
|
62953
|
-
const rows = Array.isArray(
|
|
62980
|
+
const rows = Array.isArray(asRecord14(value).rows) ? asRecord14(value).rows : [];
|
|
62954
62981
|
return rows.map((row) => ({
|
|
62955
62982
|
type: row.type,
|
|
62956
62983
|
seq: row.seq,
|
|
62957
62984
|
time: 0,
|
|
62958
|
-
data:
|
|
62985
|
+
data: asRecord14(row.payload)
|
|
62959
62986
|
}));
|
|
62960
62987
|
}
|
|
62961
62988
|
async forkSession(sessionId, seqEnd) {
|
|
62962
|
-
const value =
|
|
62989
|
+
const value = asRecord14(await this.#transport.request("session.fork", {
|
|
62963
62990
|
sessionId,
|
|
62964
62991
|
...seqEnd !== undefined ? { atSeq: seqEnd } : {}
|
|
62965
62992
|
}));
|
|
@@ -63064,7 +63091,7 @@ class BridgeSessionSeam {
|
|
|
63064
63091
|
cache.complete = true;
|
|
63065
63092
|
}
|
|
63066
63093
|
#writeModelRouteReply(reply, expectedSessionId) {
|
|
63067
|
-
const route = routeFromSelection(
|
|
63094
|
+
const route = routeFromSelection(asRecord14(reply).selected);
|
|
63068
63095
|
if (route === undefined)
|
|
63069
63096
|
return;
|
|
63070
63097
|
const sessionId = this.#currentSessionId ?? this.stagedSessionId();
|
|
@@ -63144,7 +63171,7 @@ class BridgeSessionSeam {
|
|
|
63144
63171
|
}
|
|
63145
63172
|
const params = pending.mode === "resume" ? { mode: "resume", id: pending.id, ...this.#sessionAttached ? { replace: true } : {} } : { mode: "new" };
|
|
63146
63173
|
try {
|
|
63147
|
-
const opened =
|
|
63174
|
+
const opened = asRecord14(await this.#transport.request("session.open", params));
|
|
63148
63175
|
if (typeof opened.sessionId === "string")
|
|
63149
63176
|
this.#currentSessionId = opened.sessionId;
|
|
63150
63177
|
if (this.#lastAppliedSessionId !== this.#currentSessionId) {
|
|
@@ -63162,7 +63189,7 @@ class BridgeSessionSeam {
|
|
|
63162
63189
|
const done = new Promise((resolve) => {
|
|
63163
63190
|
this.#turnDone = resolve;
|
|
63164
63191
|
});
|
|
63165
|
-
const sent =
|
|
63192
|
+
const sent = asRecord14(await this.#transport.request("session.send", { text: userText }));
|
|
63166
63193
|
if (typeof sent.turnId === "string") {
|
|
63167
63194
|
this.#inFlightTurnId = sent.turnId;
|
|
63168
63195
|
this.#emitEvent({
|
|
@@ -63262,10 +63289,10 @@ class BridgeSessionSeam {
|
|
|
63262
63289
|
}
|
|
63263
63290
|
}
|
|
63264
63291
|
async searchSessions(query) {
|
|
63265
|
-
const value =
|
|
63292
|
+
const value = asRecord14(await this.#transport.request("session.search", { query }));
|
|
63266
63293
|
const rows = Array.isArray(value.items) ? value.items : [];
|
|
63267
63294
|
return rows.map((row) => {
|
|
63268
|
-
const r =
|
|
63295
|
+
const r = asRecord14(row);
|
|
63269
63296
|
return {
|
|
63270
63297
|
id: typeof r.id === "string" ? r.id : "",
|
|
63271
63298
|
snippet: typeof r.snippet === "string" ? r.snippet : ""
|
|
@@ -63284,7 +63311,7 @@ class BridgeSessionSeam {
|
|
|
63284
63311
|
reply = await this.#transport.request("session.steer", { text });
|
|
63285
63312
|
} catch (err) {
|
|
63286
63313
|
if (err instanceof BridgeProtocolError && STEER_REJECTION_CODES.has(err.code)) {
|
|
63287
|
-
const detail =
|
|
63314
|
+
const detail = asRecord14(err.detail);
|
|
63288
63315
|
return {
|
|
63289
63316
|
accepted: false,
|
|
63290
63317
|
reason: err.code,
|
|
@@ -63293,7 +63320,7 @@ class BridgeSessionSeam {
|
|
|
63293
63320
|
}
|
|
63294
63321
|
throw err;
|
|
63295
63322
|
}
|
|
63296
|
-
const result =
|
|
63323
|
+
const result = asRecord14(reply);
|
|
63297
63324
|
if (result.accepted !== true || typeof result.turnId !== "string") {
|
|
63298
63325
|
throw new BridgeProtocolError("INTERNAL", "session.steer reply has no accepted:true turnId");
|
|
63299
63326
|
}
|
|
@@ -63474,7 +63501,7 @@ class BridgeSessionSeam {
|
|
|
63474
63501
|
return { ...request, sessionId: parent };
|
|
63475
63502
|
}
|
|
63476
63503
|
#onAskEvent(frame) {
|
|
63477
|
-
const payload =
|
|
63504
|
+
const payload = asRecord14(frame.payload);
|
|
63478
63505
|
if (frame.type === "ask.request" || frame.type === "ask.pending")
|
|
63479
63506
|
this.#askFrameSeen = true;
|
|
63480
63507
|
switch (frame.type) {
|
|
@@ -63562,7 +63589,7 @@ class BridgeSessionSeam {
|
|
|
63562
63589
|
#onCapPushEvent(frame) {
|
|
63563
63590
|
if (frame.type !== "cap.event" && frame.type !== "cap.end")
|
|
63564
63591
|
return false;
|
|
63565
|
-
const payload =
|
|
63592
|
+
const payload = asRecord14(frame.payload);
|
|
63566
63593
|
const sessionId = optionalStringField(payload, "sessionId");
|
|
63567
63594
|
if (sessionId === undefined || sessionId === "")
|
|
63568
63595
|
return true;
|
|
@@ -63644,7 +63671,7 @@ class BridgeSessionSeam {
|
|
|
63644
63671
|
}
|
|
63645
63672
|
return;
|
|
63646
63673
|
}
|
|
63647
|
-
const payload =
|
|
63674
|
+
const payload = asRecord14(frame.payload);
|
|
63648
63675
|
if (frame.type === "turn.start") {
|
|
63649
63676
|
this.#turn = "starting";
|
|
63650
63677
|
this.#decodeWindowStart = undefined;
|
|
@@ -63725,7 +63752,7 @@ class BridgeSessionSeam {
|
|
|
63725
63752
|
}
|
|
63726
63753
|
}
|
|
63727
63754
|
}
|
|
63728
|
-
var CONFIRM_REQUIRED = (method) => new BridgeProtocolError("CONFIRM_REQUIRED", `${method}: write requires a confirmed TUI modal token`),
|
|
63755
|
+
var CONFIRM_REQUIRED = (method) => new BridgeProtocolError("CONFIRM_REQUIRED", `${method}: write requires a confirmed TUI modal token`), ACCOUNT_STATUSES, ACCOUNT_PHASES, STEER_REJECTION_CODES, ROUTE_ROW_TYPES, BRIDGE_AGENT_START = "tool-workflow/agent-start", BRIDGE_AGENT_END = "tool-workflow/agent-end", BRIDGE_SUBAGENT_CATALOG = "subagent/catalog", BRIDGE_SUBAGENT_SETTLED = "subagent-settled", BRIDGE_CATALOG_RUN_PREFIX = "catalog:", CHILD_TRANSCRIPT_MAX_LINES = 500, CHILD_TRANSCRIPT_MAX_BYTES, childTextEncoder, childStrictTextDecoder, CHILD_TRANSCRIPT_LINE_BUDGET, CHILD_TRANSCRIPT_TRUNCATION_MARKER = "\u2026", CHILD_TRANSCRIPT_TRUNCATION_MARKER_BYTES, CONFIRM_POLL_INITIAL_MS = 250, CONFIRM_POLL_MAX_MS = 1000, CONFIRM_TIMEOUT_MS = 45000, fmtTokens = (n) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`;
|
|
63729
63756
|
var init_bridge_session_seam = __esm(() => {
|
|
63730
63757
|
init_remote_session_ops();
|
|
63731
63758
|
init_journal_projection();
|
|
@@ -63738,17 +63765,10 @@ var init_bridge_session_seam = __esm(() => {
|
|
|
63738
63765
|
init_bridge_goals();
|
|
63739
63766
|
init_bridge_settings_route();
|
|
63740
63767
|
init_subagent_policy();
|
|
63741
|
-
|
|
63742
|
-
|
|
63743
|
-
|
|
63744
|
-
|
|
63745
|
-
super(message);
|
|
63746
|
-
this.name = "BridgeProtocolError";
|
|
63747
|
-
this.code = code;
|
|
63748
|
-
if (detail !== undefined)
|
|
63749
|
-
this.detail = detail;
|
|
63750
|
-
}
|
|
63751
|
-
};
|
|
63768
|
+
init_bridge_protocol_error();
|
|
63769
|
+
init_prune_purge();
|
|
63770
|
+
init_bridge_protocol_error();
|
|
63771
|
+
init_prune_purge();
|
|
63752
63772
|
ACCOUNT_STATUSES = new Set(["signed-out", "credential-stored"]);
|
|
63753
63773
|
ACCOUNT_PHASES = new Set([
|
|
63754
63774
|
"initializing",
|
|
@@ -63880,11 +63900,11 @@ function toBridgeBootstrapError(err, fallbackCode = "BRIDGE_HANDSHAKE_FAILED") {
|
|
|
63880
63900
|
const message = err instanceof Error ? err.message : String(err);
|
|
63881
63901
|
return new BridgeBootstrapError({ code: fallbackCode, diagnosis: `bridge handshake failed: ${message}` });
|
|
63882
63902
|
}
|
|
63883
|
-
function
|
|
63903
|
+
function asRecord15(value) {
|
|
63884
63904
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
63885
63905
|
}
|
|
63886
63906
|
function verifyBridgeFingerprint(hello, expectedProtocolVersion = BRIDGE_PROTOCOL_VERSION) {
|
|
63887
|
-
const h =
|
|
63907
|
+
const h = asRecord15(hello);
|
|
63888
63908
|
const protocolVersion = h.protocolVersion;
|
|
63889
63909
|
if (protocolVersion !== expectedProtocolVersion) {
|
|
63890
63910
|
throw new BridgeBootstrapError({
|
|
@@ -65012,7 +65032,7 @@ function recoveryCause(err, phase) {
|
|
|
65012
65032
|
};
|
|
65013
65033
|
}
|
|
65014
65034
|
if (err instanceof BridgeProtocolError && err.code === "BRIDGE_DEAD") {
|
|
65015
|
-
const detail =
|
|
65035
|
+
const detail = asRecord16(err.detail);
|
|
65016
65036
|
return {
|
|
65017
65037
|
stage: phase,
|
|
65018
65038
|
code: typeof detail.code === "number" ? detail.code : null,
|
|
@@ -65130,7 +65150,7 @@ class StdioBridgeTransport {
|
|
|
65130
65150
|
} catch {
|
|
65131
65151
|
return;
|
|
65132
65152
|
}
|
|
65133
|
-
const rec =
|
|
65153
|
+
const rec = asRecord16(frame);
|
|
65134
65154
|
if (typeof rec.id === "number") {
|
|
65135
65155
|
const pending = this.#pending.get(rec.id);
|
|
65136
65156
|
if (pending === undefined)
|
|
@@ -65142,7 +65162,7 @@ class StdioBridgeTransport {
|
|
|
65142
65162
|
this.#setState("ready");
|
|
65143
65163
|
pending.resolve(rec.result);
|
|
65144
65164
|
} else {
|
|
65145
|
-
const error =
|
|
65165
|
+
const error = asRecord16(rec.error);
|
|
65146
65166
|
pending.reject(new BridgeProtocolError(typeof error.code === "string" ? error.code : "BRIDGE_ERROR", typeof error.message === "string" ? error.message : "bridge request failed", error.detail));
|
|
65147
65167
|
}
|
|
65148
65168
|
return;
|
|
@@ -65274,7 +65294,7 @@ class StdioBridgeTransport {
|
|
|
65274
65294
|
} catch {}
|
|
65275
65295
|
}
|
|
65276
65296
|
}
|
|
65277
|
-
var
|
|
65297
|
+
var asRecord16 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
65278
65298
|
var init_bridge_transport = __esm(() => {
|
|
65279
65299
|
init_bridge_session_seam();
|
|
65280
65300
|
init_profile_constants();
|
|
@@ -65307,5 +65327,5 @@ if (import.meta.main) {
|
|
|
65307
65327
|
main();
|
|
65308
65328
|
}
|
|
65309
65329
|
|
|
65310
|
-
//# debugId=
|
|
65330
|
+
//# debugId=24C78C0222CA1F8B64756E2164756E21
|
|
65311
65331
|
//# sourceMappingURL=index.js.map
|