@aiwayds/dsh-opentui 0.18.3 → 0.18.5
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/CHANGELOG.md +49 -0
- package/README.md +2 -0
- package/bin/dsh-opentui.mjs +81 -5
- package/bin/lib/launcher.mjs +241 -4
- package/dist/client/index.js +267 -46
- package/dist/client/index.js.map +325 -0
- package/dist/locales/en.json +4 -0
- package/dist/locales/zh-CN.json +4 -0
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -931,6 +931,7 @@ async function probeHostMux(options) {
|
|
|
931
931
|
if (!validAuthority(options.authority))
|
|
932
932
|
return false;
|
|
933
933
|
const timeoutMs = options.timeoutMs ?? DEFAULT_HOST_PROBE_TIMEOUT_MS;
|
|
934
|
+
const makeSocket = options.socketFactory ?? (() => new WS(`ws://${options.authority}/api/remote.mux`, { headers: { cookie: options.cookieHeader } }));
|
|
934
935
|
return await new Promise((resolve) => {
|
|
935
936
|
let settled = false;
|
|
936
937
|
let socket;
|
|
@@ -942,14 +943,13 @@ async function probeHostMux(options) {
|
|
|
942
943
|
clearTimeout(timer);
|
|
943
944
|
try {
|
|
944
945
|
socket?.removeAllListeners();
|
|
946
|
+
socket?.on("error", () => {});
|
|
945
947
|
socket?.terminate();
|
|
946
948
|
} catch {}
|
|
947
949
|
resolve(ok);
|
|
948
950
|
}
|
|
949
951
|
try {
|
|
950
|
-
socket =
|
|
951
|
-
headers: { cookie: options.cookieHeader }
|
|
952
|
-
});
|
|
952
|
+
socket = makeSocket();
|
|
953
953
|
} catch {
|
|
954
954
|
done(false);
|
|
955
955
|
return;
|
|
@@ -1502,12 +1502,17 @@ var init_cookie_mint = __esm(() => {
|
|
|
1502
1502
|
// src/client/lifecycle.ts
|
|
1503
1503
|
var exports_lifecycle = {};
|
|
1504
1504
|
__export(exports_lifecycle, {
|
|
1505
|
+
DEFAULT_CONNECT_TIMEOUT_MS: () => DEFAULT_CONNECT_TIMEOUT_MS,
|
|
1505
1506
|
DEFAULT_IDLE_EXIT_MS: () => DEFAULT_IDLE_EXIT_MS,
|
|
1506
1507
|
DEFAULT_IDLE_EXIT_SEC: () => DEFAULT_IDLE_EXIT_SEC,
|
|
1507
1508
|
DEFAULT_PROFILE: () => DEFAULT_PROFILE,
|
|
1508
1509
|
DEFAULT_READINESS_TIMEOUT_MS: () => DEFAULT_READINESS_TIMEOUT_MS,
|
|
1510
|
+
DEFAULT_SERVE_PROBE_BUDGET_MS: () => DEFAULT_SERVE_PROBE_BUDGET_MS,
|
|
1509
1511
|
DEFAULT_STALE_PROBE_MS: () => DEFAULT_STALE_PROBE_MS,
|
|
1512
|
+
ENV_BOOT_TIMEOUT_MS: () => ENV_BOOT_TIMEOUT_MS,
|
|
1513
|
+
ENV_CONNECT_TIMEOUT_MS: () => ENV_CONNECT_TIMEOUT_MS,
|
|
1510
1514
|
ENV_IDLE_EXIT_MS: () => ENV_IDLE_EXIT_MS,
|
|
1515
|
+
ENV_MUX_TIMEOUT_MS: () => ENV_MUX_TIMEOUT_MS,
|
|
1511
1516
|
HostBootSupersededError: () => HostBootSupersededError,
|
|
1512
1517
|
HostBootTimeoutError: () => HostBootTimeoutError,
|
|
1513
1518
|
HostDiedError: () => HostDiedError,
|
|
@@ -1522,8 +1527,11 @@ __export(exports_lifecycle, {
|
|
|
1522
1527
|
ensureHost: () => ensureHost,
|
|
1523
1528
|
isListening: () => isListening,
|
|
1524
1529
|
pidAlive: () => pidAlive,
|
|
1530
|
+
resolveBootTimeoutMs: () => resolveBootTimeoutMs,
|
|
1531
|
+
resolveConnectTimeoutMs: () => resolveConnectTimeoutMs,
|
|
1525
1532
|
resolveIdleExitMs: () => resolveIdleExitMs,
|
|
1526
|
-
resolveIdleExitSec: () => resolveIdleExitSec
|
|
1533
|
+
resolveIdleExitSec: () => resolveIdleExitSec,
|
|
1534
|
+
resolveMuxTimeoutMs: () => resolveMuxTimeoutMs
|
|
1527
1535
|
});
|
|
1528
1536
|
import { spawn as spawn2 } from "child_process";
|
|
1529
1537
|
import { existsSync as existsSync3, linkSync, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync3, rmSync, writeFileSync as writeFileSync3 } from "fs";
|
|
@@ -1545,6 +1553,29 @@ function resolveIdleExitMs(explicitSec) {
|
|
|
1545
1553
|
function resolveIdleExitSec(explicitSec) {
|
|
1546
1554
|
return resolveIdleExitMs(explicitSec) / 1000;
|
|
1547
1555
|
}
|
|
1556
|
+
function validBudgetMs(value) {
|
|
1557
|
+
return Number.isFinite(value) && Number.isInteger(value) && value > 0;
|
|
1558
|
+
}
|
|
1559
|
+
function resolveBudgetMs(explicitMs, envName, defaultMs) {
|
|
1560
|
+
if (explicitMs !== undefined && validBudgetMs(explicitMs))
|
|
1561
|
+
return explicitMs;
|
|
1562
|
+
const raw = process.env[envName];
|
|
1563
|
+
if (raw !== undefined && /^\d+$/.test(raw)) {
|
|
1564
|
+
const parsed = Number(raw);
|
|
1565
|
+
if (validBudgetMs(parsed))
|
|
1566
|
+
return parsed;
|
|
1567
|
+
}
|
|
1568
|
+
return defaultMs;
|
|
1569
|
+
}
|
|
1570
|
+
function resolveBootTimeoutMs(explicitMs) {
|
|
1571
|
+
return resolveBudgetMs(explicitMs, ENV_BOOT_TIMEOUT_MS, DEFAULT_READINESS_TIMEOUT_MS);
|
|
1572
|
+
}
|
|
1573
|
+
function resolveMuxTimeoutMs(explicitMs) {
|
|
1574
|
+
return resolveBudgetMs(explicitMs, ENV_MUX_TIMEOUT_MS, DEFAULT_SERVE_PROBE_BUDGET_MS);
|
|
1575
|
+
}
|
|
1576
|
+
function resolveConnectTimeoutMs(explicitMs) {
|
|
1577
|
+
return resolveBudgetMs(explicitMs, ENV_CONNECT_TIMEOUT_MS, DEFAULT_CONNECT_TIMEOUT_MS);
|
|
1578
|
+
}
|
|
1548
1579
|
function errorTail(outputTail) {
|
|
1549
1580
|
const lines = outputTail.split(/\r?\n/).filter((line) => line.length > 0);
|
|
1550
1581
|
if (lines.length === 0)
|
|
@@ -1953,7 +1984,8 @@ function resolveOptions(opts) {
|
|
|
1953
1984
|
profile,
|
|
1954
1985
|
dshHome,
|
|
1955
1986
|
idleExitSec,
|
|
1956
|
-
readinessTimeoutMs: opts.readinessTimeoutMs
|
|
1987
|
+
readinessTimeoutMs: resolveBootTimeoutMs(opts.readinessTimeoutMs),
|
|
1988
|
+
serveProbeBudgetMs: resolveMuxTimeoutMs(opts.serveProbeBudgetMs),
|
|
1957
1989
|
...opts.bootJoinTimeoutMs !== undefined ? { bootJoinTimeoutMs: opts.bootJoinTimeoutMs } : {},
|
|
1958
1990
|
staleProbeMs: opts.staleProbeMs ?? DEFAULT_STALE_PROBE_MS,
|
|
1959
1991
|
...opts.maxAgeMs !== undefined ? { maxAgeMs: opts.maxAgeMs } : {},
|
|
@@ -2066,7 +2098,7 @@ async function bootHost(o) {
|
|
|
2066
2098
|
host.authority = ready.authority;
|
|
2067
2099
|
host.cookieHeader = await mintCookieWithRetry(host);
|
|
2068
2100
|
if (ready.via === "listener") {
|
|
2069
|
-
const deadline = Date.now() +
|
|
2101
|
+
const deadline = Date.now() + o.serveProbeBudgetMs;
|
|
2070
2102
|
let serving = false;
|
|
2071
2103
|
while (Date.now() < deadline) {
|
|
2072
2104
|
serving = await probeHostMux({
|
|
@@ -2081,7 +2113,7 @@ async function bootHost(o) {
|
|
|
2081
2113
|
await sleep(SERVE_PROBE_POLL_MS);
|
|
2082
2114
|
}
|
|
2083
2115
|
if (!serving)
|
|
2084
|
-
throw new HostNotServingError(host.outputTail);
|
|
2116
|
+
throw new HostNotServingError(host.outputTail, o.serveProbeBudgetMs);
|
|
2085
2117
|
}
|
|
2086
2118
|
if (!bootClaimIntact(o.dshHome, o.profile, claimStartedAt)) {
|
|
2087
2119
|
throw new HostBootSupersededError;
|
|
@@ -2196,7 +2228,7 @@ async function ensureHost(opts = {}) {
|
|
|
2196
2228
|
attachHost(host);
|
|
2197
2229
|
return makeHandle(host);
|
|
2198
2230
|
}
|
|
2199
|
-
var DEFAULT_PROFILE = "opentui", DEFAULT_IDLE_EXIT_MS = 5000, DEFAULT_IDLE_EXIT_SEC, ENV_IDLE_EXIT_MS = "DSH_OPENTUI_HOST_IDLE_MS", DEFAULT_READINESS_TIMEOUT_MS = 30000, DEFAULT_STALE_PROBE_MS = 8000, BOOT_JOIN_MARGIN_MS = 20000, BOOT_JOIN_POLL_MS = 200, RESPAWN_WINDOW_MS = 15000, MAX_RAPID_RESPAWNS = 3, LISTEN_PROBE_TIMEOUT_MS = 750, LISTEN_POLL_MS = 200, ADOPT_PROBE_TIMEOUT_MS = 2000, SERVE_PROBE_POLL_MS = 250,
|
|
2231
|
+
var DEFAULT_PROFILE = "opentui", DEFAULT_IDLE_EXIT_MS = 5000, DEFAULT_IDLE_EXIT_SEC, ENV_IDLE_EXIT_MS = "DSH_OPENTUI_HOST_IDLE_MS", DEFAULT_READINESS_TIMEOUT_MS = 30000, ENV_BOOT_TIMEOUT_MS = "DSH_OPENTUI_BOOT_TIMEOUT_MS", ENV_MUX_TIMEOUT_MS = "DSH_OPENTUI_MUX_TIMEOUT_MS", DEFAULT_SERVE_PROBE_BUDGET_MS = 20000, ENV_CONNECT_TIMEOUT_MS = "DSH_OPENTUI_CONNECT_TIMEOUT_MS", DEFAULT_CONNECT_TIMEOUT_MS = 30000, DEFAULT_STALE_PROBE_MS = 8000, BOOT_JOIN_MARGIN_MS = 20000, BOOT_JOIN_POLL_MS = 200, RESPAWN_WINDOW_MS = 15000, MAX_RAPID_RESPAWNS = 3, LISTEN_PROBE_TIMEOUT_MS = 750, LISTEN_POLL_MS = 200, ADOPT_PROBE_TIMEOUT_MS = 2000, SERVE_PROBE_POLL_MS = 250, ERROR_TAIL_LINES = 12, KILL_GRACE_MS = 5000, KILL_ESCALATE_MS = 2000, OUTPUT_TAIL_CAP = 8000, URL_LINE, HostLifecycleError, HostBootTimeoutError, HostDiedError, HostNotServingError, HostSpawnError, HostRespawnLoopError, HostBootSupersededError, ProfileMissingError, MintUnavailableError, registry, pendingBoots, respawnHistory, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), realMintPromise = null, RETRYABLE_MINT_ERRORS, MINT_RETRY_BUDGET_MS = 15000, MINT_RETRY_INTERVAL_MS = 250, FFI_FLAG = "--experimental-ffi", __internals;
|
|
2200
2232
|
var init_lifecycle = __esm(() => {
|
|
2201
2233
|
init_host_probe();
|
|
2202
2234
|
init_append_system();
|
|
@@ -2232,9 +2264,11 @@ var init_lifecycle = __esm(() => {
|
|
|
2232
2264
|
};
|
|
2233
2265
|
HostNotServingError = class HostNotServingError extends HostLifecycleError {
|
|
2234
2266
|
outputTail;
|
|
2235
|
-
|
|
2236
|
-
|
|
2267
|
+
budgetMs;
|
|
2268
|
+
constructor(outputTail, budgetMs = DEFAULT_SERVE_PROBE_BUDGET_MS) {
|
|
2269
|
+
super("host-not-serving", `dsh host is listening but never served the client mux (${budgetMs}ms budget)${errorTail(outputTail)}`);
|
|
2237
2270
|
this.outputTail = outputTail;
|
|
2271
|
+
this.budgetMs = budgetMs;
|
|
2238
2272
|
}
|
|
2239
2273
|
};
|
|
2240
2274
|
HostSpawnError = class HostSpawnError extends HostLifecycleError {
|
|
@@ -4332,7 +4366,7 @@ class ClientConnection {
|
|
|
4332
4366
|
};
|
|
4333
4367
|
this.#recovery = options.recovery;
|
|
4334
4368
|
this.#maxConnectAttempts = Math.max(0, options.maxConnectAttempts ?? DEFAULT_MAX_CONNECT_ATTEMPTS);
|
|
4335
|
-
this.#connectBudgetMs =
|
|
4369
|
+
this.#connectBudgetMs = resolveConnectTimeoutMs(options.connectBudgetMs);
|
|
4336
4370
|
this.#diagnostics = options.diagnostics;
|
|
4337
4371
|
this.#pumpCallbacks = {
|
|
4338
4372
|
onReady: (info) => {
|
|
@@ -4487,10 +4521,11 @@ class ClientConnection {
|
|
|
4487
4521
|
}
|
|
4488
4522
|
}
|
|
4489
4523
|
}
|
|
4490
|
-
var RemoteRpcError, RpcTransportError, ConnectionClosedError, ConnectionRetryExhaustedError, DEFAULT_MAX_CONNECT_ATTEMPTS = 3
|
|
4524
|
+
var RemoteRpcError, RpcTransportError, ConnectionClosedError, ConnectionRetryExhaustedError, DEFAULT_MAX_CONNECT_ATTEMPTS = 3;
|
|
4491
4525
|
var init_transport = __esm(() => {
|
|
4492
4526
|
init_lib2();
|
|
4493
4527
|
init_events_source();
|
|
4528
|
+
init_lifecycle();
|
|
4494
4529
|
RemoteRpcError = class RemoteRpcError extends Error {
|
|
4495
4530
|
code;
|
|
4496
4531
|
details;
|
|
@@ -21840,6 +21875,7 @@ var init_keybind = __esm(() => {
|
|
|
21840
21875
|
"session.toggle.exploration_grouping": keybind("none", "Toggle related tool call grouping"),
|
|
21841
21876
|
"session.verbosity.cycle": keybind("none", "Cycle transcript verbosity"),
|
|
21842
21877
|
"session.child.first": keybind("down", "Toggle subagent picker"),
|
|
21878
|
+
"session.subagents": keybind("ctrl+g", "Open the subagents activity panel"),
|
|
21843
21879
|
"session.child.next": keybind("right", "Go to next child session"),
|
|
21844
21880
|
"session.child.previous": keybind("left", "Go to previous child session"),
|
|
21845
21881
|
"session.parent": keybind("up", "Go to parent session"),
|
|
@@ -21886,7 +21922,7 @@ var init_keybind = __esm(() => {
|
|
|
21886
21922
|
"session.line.down": keybind("ctrl+alt+e", "Scroll messages down by one line"),
|
|
21887
21923
|
"session.half.page.up": keybind("ctrl+alt+u", "Scroll messages up by half page"),
|
|
21888
21924
|
"session.half.page.down": keybind("ctrl+alt+d", "Scroll messages down by half page"),
|
|
21889
|
-
"session.first": keybind("ctrl+
|
|
21925
|
+
"session.first": keybind("ctrl+home,home,alt+home", "Navigate to first message"),
|
|
21890
21926
|
"session.last": keybind("ctrl+alt+g,end", "Navigate to last message"),
|
|
21891
21927
|
"session.message.next": keybind("none", "Navigate to next message"),
|
|
21892
21928
|
"session.message.previous": keybind("none", "Navigate to previous message"),
|
|
@@ -43098,6 +43134,25 @@ function truncate(str, len) {
|
|
|
43098
43134
|
return str;
|
|
43099
43135
|
return str.slice(0, len - 1) + "\u2026";
|
|
43100
43136
|
}
|
|
43137
|
+
function graphemes(str) {
|
|
43138
|
+
return Array.from(graphemeSegmenter.segment(str), (item) => item.segment);
|
|
43139
|
+
}
|
|
43140
|
+
function takeWidth(str, width) {
|
|
43141
|
+
if (width <= 0)
|
|
43142
|
+
return "";
|
|
43143
|
+
if (stringWidth(str) <= width)
|
|
43144
|
+
return str;
|
|
43145
|
+
const result = [];
|
|
43146
|
+
let used = 0;
|
|
43147
|
+
for (const segment of graphemes(str)) {
|
|
43148
|
+
const next = stringWidth(segment);
|
|
43149
|
+
if (used + next > width)
|
|
43150
|
+
break;
|
|
43151
|
+
result.push(segment);
|
|
43152
|
+
used += next;
|
|
43153
|
+
}
|
|
43154
|
+
return result.join("");
|
|
43155
|
+
}
|
|
43101
43156
|
function truncateLeft2(str, len) {
|
|
43102
43157
|
if (str.length <= len)
|
|
43103
43158
|
return str;
|
|
@@ -45111,12 +45166,12 @@ import {
|
|
|
45111
45166
|
function toColor(value) {
|
|
45112
45167
|
return typeof value === "function" ? value : parseColor2(value);
|
|
45113
45168
|
}
|
|
45114
|
-
var
|
|
45169
|
+
var graphemes2, SpinnerRenderable;
|
|
45115
45170
|
var init_spinner_renderable = __esm(() => {
|
|
45116
45171
|
init_index_bun();
|
|
45117
45172
|
init_string_width();
|
|
45118
45173
|
init_spinner_frames();
|
|
45119
|
-
|
|
45174
|
+
graphemes2 = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
45120
45175
|
SpinnerRenderable = class SpinnerRenderable extends Renderable5 {
|
|
45121
45176
|
frameTexts = [];
|
|
45122
45177
|
glyphs = [];
|
|
@@ -45139,7 +45194,7 @@ var init_spinner_renderable = __esm(() => {
|
|
|
45139
45194
|
if (value.length === this.frameTexts.length && value.every((frame, index) => frame === this.frameTexts[index]))
|
|
45140
45195
|
return;
|
|
45141
45196
|
this.frameTexts = value;
|
|
45142
|
-
this.glyphs = value.map((frame) => Array.from(
|
|
45197
|
+
this.glyphs = value.map((frame) => Array.from(graphemes2.segment(frame), (part) => ({ char: part.segment, width: stringWidth(part.segment) })));
|
|
45143
45198
|
this.index = 0;
|
|
45144
45199
|
const width = Math.max(0, ...this.glyphs.map((glyphs) => glyphs.reduce((sum, glyph) => sum + glyph.width, 0)));
|
|
45145
45200
|
if (width !== this.frameWidth) {
|
|
@@ -46823,6 +46878,33 @@ var init_seam_rows = __esm(() => {
|
|
|
46823
46878
|
init_motion();
|
|
46824
46879
|
});
|
|
46825
46880
|
|
|
46881
|
+
// ../tui-base/src/routes/session/footer-refresh.ts
|
|
46882
|
+
function shouldRefreshFooter(remoteInfo, sessionId, inFlight) {
|
|
46883
|
+
return !inFlight && remoteInfo === undefined && sessionId !== undefined;
|
|
46884
|
+
}
|
|
46885
|
+
function initialFooterProbeState() {
|
|
46886
|
+
return { inFlight: false, attempts: 0, lastAttemptAt: 0 };
|
|
46887
|
+
}
|
|
46888
|
+
function shouldStartFooterProbe(remoteInfo, sessionId, state, now, budget = {}) {
|
|
46889
|
+
if (!shouldRefreshFooter(remoteInfo, sessionId, state.inFlight))
|
|
46890
|
+
return false;
|
|
46891
|
+
if (state.attempts >= (budget.maxAttempts ?? FOOTER_PROBE_MAX_ATTEMPTS))
|
|
46892
|
+
return false;
|
|
46893
|
+
if (state.lastAttemptAt !== 0 && now - state.lastAttemptAt < (budget.minIntervalMs ?? FOOTER_PROBE_MIN_INTERVAL_MS)) {
|
|
46894
|
+
return false;
|
|
46895
|
+
}
|
|
46896
|
+
return true;
|
|
46897
|
+
}
|
|
46898
|
+
function markFooterProbeStarted(state, now) {
|
|
46899
|
+
return { ...state, inFlight: true, attempts: state.attempts + 1, lastAttemptAt: now };
|
|
46900
|
+
}
|
|
46901
|
+
function settleFooterProbe(state, infoObtained) {
|
|
46902
|
+
if (infoObtained)
|
|
46903
|
+
return initialFooterProbeState();
|
|
46904
|
+
return { ...state, inFlight: false };
|
|
46905
|
+
}
|
|
46906
|
+
var FOOTER_PROBE_MAX_ATTEMPTS = 3, FOOTER_PROBE_MIN_INTERVAL_MS = 400;
|
|
46907
|
+
|
|
46826
46908
|
// ../tui-base/src/routes/session/ask-options.ts
|
|
46827
46909
|
function splitRecommended(raw) {
|
|
46828
46910
|
const trimmed = raw.trim();
|
|
@@ -48255,7 +48337,7 @@ function WidgetsDock(props) {
|
|
|
48255
48337
|
children: (line) => (() => {
|
|
48256
48338
|
var _el$4 = createElement("text");
|
|
48257
48339
|
setProp(_el$4, "wrapMode", "none");
|
|
48258
|
-
insert(_el$4, () =>
|
|
48340
|
+
insert(_el$4, () => takeWidth(line.text, tableWidth()));
|
|
48259
48341
|
effect((_$p) => setProp(_el$4, "fg", fgFor(line.tone), _$p));
|
|
48260
48342
|
return _el$4;
|
|
48261
48343
|
})()
|
|
@@ -48422,6 +48504,7 @@ var init_widgets_dock = __esm(() => {
|
|
|
48422
48504
|
init_terminal_size();
|
|
48423
48505
|
init_tool_summarize();
|
|
48424
48506
|
init_todo();
|
|
48507
|
+
init_locale();
|
|
48425
48508
|
init_string_width();
|
|
48426
48509
|
init_theme3();
|
|
48427
48510
|
init_i18n();
|
|
@@ -49175,25 +49258,63 @@ function hintLabel(id, busy) {
|
|
|
49175
49258
|
function hintInState(id, busy) {
|
|
49176
49259
|
return hintLabel(id, busy) !== "";
|
|
49177
49260
|
}
|
|
49178
|
-
function
|
|
49261
|
+
function hintParts(busy, shown, subagentsLive, hints) {
|
|
49179
49262
|
if (!shown)
|
|
49180
|
-
return
|
|
49263
|
+
return [];
|
|
49181
49264
|
const parts = [];
|
|
49182
49265
|
for (const id of FOOTER_HINT_IDS) {
|
|
49183
49266
|
if (id === "subagents") {
|
|
49184
|
-
if (subagentsLive && hints.subagents)
|
|
49185
|
-
|
|
49267
|
+
if (subagentsLive && hints.subagents) {
|
|
49268
|
+
const label = hintLabel("subagents", busy);
|
|
49269
|
+
if (label)
|
|
49270
|
+
parts.push({
|
|
49271
|
+
id,
|
|
49272
|
+
label
|
|
49273
|
+
});
|
|
49274
|
+
}
|
|
49186
49275
|
continue;
|
|
49187
49276
|
}
|
|
49188
49277
|
if (!hints[id])
|
|
49189
49278
|
continue;
|
|
49190
49279
|
const label = hintLabel(id, busy);
|
|
49191
49280
|
if (label)
|
|
49192
|
-
parts.push(
|
|
49281
|
+
parts.push({
|
|
49282
|
+
id,
|
|
49283
|
+
label
|
|
49284
|
+
});
|
|
49193
49285
|
}
|
|
49286
|
+
return parts;
|
|
49287
|
+
}
|
|
49288
|
+
function joinHintParts(parts) {
|
|
49194
49289
|
if (parts.length === 0)
|
|
49195
49290
|
return "";
|
|
49196
|
-
return `\u2328 ${parts.join(" \xB7 ")}`;
|
|
49291
|
+
return `\u2328 ${parts.map((p) => p.label).join(" \xB7 ")}`;
|
|
49292
|
+
}
|
|
49293
|
+
function hintsTextAtWidth(busy, shown, subagentsLive, columns, hints = footerHints()) {
|
|
49294
|
+
const parts = hintParts(busy, shown, subagentsLive, hints);
|
|
49295
|
+
const full = joinHintParts(parts);
|
|
49296
|
+
if (!full)
|
|
49297
|
+
return "";
|
|
49298
|
+
const usable = Math.max(8, columns - 2);
|
|
49299
|
+
if (stringWidth(full) <= usable)
|
|
49300
|
+
return full;
|
|
49301
|
+
const ranked = parts.map((part, index) => ({
|
|
49302
|
+
part,
|
|
49303
|
+
index
|
|
49304
|
+
})).sort((a, b) => HINT_SEGMENT_PRIORITY[a.part.id] - HINT_SEGMENT_PRIORITY[b.part.id] || a.index - b.index);
|
|
49305
|
+
const kept = [];
|
|
49306
|
+
let width = 0;
|
|
49307
|
+
for (const candidate of ranked) {
|
|
49308
|
+
const added = stringWidth(candidate.part.label) + (kept.length > 0 ? stringWidth(" \xB7 ") : stringWidth("\u2328 "));
|
|
49309
|
+
if (width + added > usable)
|
|
49310
|
+
break;
|
|
49311
|
+
width += added;
|
|
49312
|
+
kept.push(candidate);
|
|
49313
|
+
}
|
|
49314
|
+
if (kept.length === 0)
|
|
49315
|
+
return clipToWidth(full, usable);
|
|
49316
|
+
kept.sort((a, b) => a.index - b.index);
|
|
49317
|
+
return joinHintParts(kept.map((k) => k.part));
|
|
49197
49318
|
}
|
|
49198
49319
|
function transcriptHintsText(shown = true) {
|
|
49199
49320
|
if (!shown)
|
|
@@ -49204,7 +49325,10 @@ function transcriptHintsText(shown = true) {
|
|
|
49204
49325
|
function HintsLine(props) {
|
|
49205
49326
|
const dimensions = useTerminalSize();
|
|
49206
49327
|
const theme = useThemeOptional();
|
|
49207
|
-
const row = () =>
|
|
49328
|
+
const row = () => {
|
|
49329
|
+
const columns = dimensions().width;
|
|
49330
|
+
return props.pane?.() === "transcript" ? clipToWidth(transcriptHintsText(hintsShown()), Math.max(8, columns - 2)) : hintsTextAtWidth(props.busy, hintsShown(), subagentMarkerViews().some((v) => v.status === "running"), columns);
|
|
49331
|
+
};
|
|
49208
49332
|
return createComponent2(Show, {
|
|
49209
49333
|
get when() {
|
|
49210
49334
|
return memo2(() => !!hintsShown())() && row().length > 0;
|
|
@@ -49223,7 +49347,7 @@ function HintsLine(props) {
|
|
|
49223
49347
|
}
|
|
49224
49348
|
});
|
|
49225
49349
|
}
|
|
49226
|
-
var hintsShown, setHintsShown, DEFAULT_FOOTER_HINTS, FOOTER_HINT_IDS, HINT_LOCALES, HINT_LABEL_KEYS, footerHints, setFooterHints, hintsLocale, setHintsLocale, TRANSCRIPT_HINT_KEY = "footer.hint.transcript";
|
|
49350
|
+
var hintsShown, setHintsShown, DEFAULT_FOOTER_HINTS, FOOTER_HINT_IDS, HINT_SEGMENT_PRIORITY, HINT_LOCALES, HINT_LABEL_KEYS, footerHints, setFooterHints, hintsLocale, setHintsLocale, TRANSCRIPT_HINT_KEY = "footer.hint.transcript";
|
|
49227
49351
|
var init_hints_line = __esm(() => {
|
|
49228
49352
|
init_index_bun();
|
|
49229
49353
|
init_index_bun();
|
|
@@ -49236,6 +49360,7 @@ var init_hints_line = __esm(() => {
|
|
|
49236
49360
|
init_i18n();
|
|
49237
49361
|
init_terminal_size();
|
|
49238
49362
|
init_tool_summarize();
|
|
49363
|
+
init_string_width();
|
|
49239
49364
|
init_theme3();
|
|
49240
49365
|
init_subagent_markers();
|
|
49241
49366
|
[hintsShown, setHintsShown] = createSignal(true);
|
|
@@ -49244,12 +49369,24 @@ var init_hints_line = __esm(() => {
|
|
|
49244
49369
|
newline: true,
|
|
49245
49370
|
history: true,
|
|
49246
49371
|
stop: true,
|
|
49372
|
+
subagentPanel: true,
|
|
49247
49373
|
quit: true,
|
|
49248
49374
|
scroll: true,
|
|
49249
49375
|
search: true,
|
|
49250
49376
|
subagents: true
|
|
49251
49377
|
});
|
|
49252
|
-
FOOTER_HINT_IDS = ["send", "newline", "history", "stop", "subagents", "search", "scroll", "quit"];
|
|
49378
|
+
FOOTER_HINT_IDS = ["send", "newline", "history", "stop", "subagentPanel", "subagents", "search", "scroll", "quit"];
|
|
49379
|
+
HINT_SEGMENT_PRIORITY = Object.freeze({
|
|
49380
|
+
send: 10,
|
|
49381
|
+
stop: 10,
|
|
49382
|
+
quit: 10,
|
|
49383
|
+
history: 20,
|
|
49384
|
+
newline: 30,
|
|
49385
|
+
subagents: 40,
|
|
49386
|
+
subagentPanel: 50,
|
|
49387
|
+
search: 60,
|
|
49388
|
+
scroll: 70
|
|
49389
|
+
});
|
|
49253
49390
|
HINT_LOCALES = ["en", "zh-CN", "ja", "ko"];
|
|
49254
49391
|
HINT_LABEL_KEYS = {
|
|
49255
49392
|
send: {
|
|
@@ -49268,6 +49405,10 @@ var init_hints_line = __esm(() => {
|
|
|
49268
49405
|
idle: null,
|
|
49269
49406
|
busy: "footer.hint.stop.busy"
|
|
49270
49407
|
},
|
|
49408
|
+
subagentPanel: {
|
|
49409
|
+
idle: "footer.hint.subagentPanel",
|
|
49410
|
+
busy: "footer.hint.subagentPanel"
|
|
49411
|
+
},
|
|
49271
49412
|
quit: {
|
|
49272
49413
|
idle: "footer.hint.quit",
|
|
49273
49414
|
busy: "footer.hint.quit"
|
|
@@ -49893,6 +50034,24 @@ var init_turn_cancel = __esm(() => {
|
|
|
49893
50034
|
init_i18n();
|
|
49894
50035
|
});
|
|
49895
50036
|
|
|
50037
|
+
// ../tui-base/src/routes/session/stop-all.ts
|
|
50038
|
+
async function stopEverything(seam) {
|
|
50039
|
+
const turn = seam.status?.().turn;
|
|
50040
|
+
const parent = turn !== undefined && turn !== "idle";
|
|
50041
|
+
if (parent)
|
|
50042
|
+
seam.interrupt();
|
|
50043
|
+
let children = 0;
|
|
50044
|
+
for (const view of seam.subagentViews?.() ?? []) {
|
|
50045
|
+
if (view.status !== "running" || !seam.interruptChild)
|
|
50046
|
+
continue;
|
|
50047
|
+
try {
|
|
50048
|
+
await seam.interruptChild(view.id);
|
|
50049
|
+
children++;
|
|
50050
|
+
} catch {}
|
|
50051
|
+
}
|
|
50052
|
+
return { parent, children };
|
|
50053
|
+
}
|
|
50054
|
+
|
|
49896
50055
|
// ../tui-base/src/routes/session/turn-overlay-controller.ts
|
|
49897
50056
|
class TurnOverlayController {
|
|
49898
50057
|
#approvals = [];
|
|
@@ -52773,6 +52932,22 @@ function coreCommands() {
|
|
|
52773
52932
|
ctx.say(t("command.preset.set", { name: target.name }));
|
|
52774
52933
|
await ctx.reload();
|
|
52775
52934
|
}
|
|
52935
|
+
},
|
|
52936
|
+
{
|
|
52937
|
+
name: "/stop",
|
|
52938
|
+
description: t("command.stop.description"),
|
|
52939
|
+
async run(ctx) {
|
|
52940
|
+
const { parent, children } = await stopEverything(ctx.seam);
|
|
52941
|
+
if (!parent && children === 0) {
|
|
52942
|
+
ctx.say(t("command.stop.nothingRunning"));
|
|
52943
|
+
return;
|
|
52944
|
+
}
|
|
52945
|
+
const parts = [
|
|
52946
|
+
...parent ? [t("turn.stop.confirmMain")] : [],
|
|
52947
|
+
...children === 1 ? [t("turn.stop.confirmChildrenOne")] : children > 0 ? [t("turn.stop.confirmChildrenMany", { count: String(children) })] : []
|
|
52948
|
+
];
|
|
52949
|
+
ctx.say(t("command.stop.done", { parts: parts.join(", ") }));
|
|
52950
|
+
}
|
|
52776
52951
|
}
|
|
52777
52952
|
];
|
|
52778
52953
|
}
|
|
@@ -55587,7 +55762,7 @@ var init_string_width2 = __esm(() => {
|
|
|
55587
55762
|
});
|
|
55588
55763
|
|
|
55589
55764
|
// ../panel-kit/src/text.ts
|
|
55590
|
-
function
|
|
55765
|
+
function graphemes3(value) {
|
|
55591
55766
|
return Array.from(segmenter2.segment(value), (part) => part.segment);
|
|
55592
55767
|
}
|
|
55593
55768
|
function takeCells(value, width) {
|
|
@@ -55597,7 +55772,7 @@ function takeCells(value, width) {
|
|
|
55597
55772
|
return value;
|
|
55598
55773
|
const parts = [];
|
|
55599
55774
|
let used = 0;
|
|
55600
|
-
for (const part of
|
|
55775
|
+
for (const part of graphemes3(value)) {
|
|
55601
55776
|
const cells = stringWidth2(part);
|
|
55602
55777
|
if (used + cells > width)
|
|
55603
55778
|
break;
|
|
@@ -55974,7 +56149,7 @@ var init_panel = __esm(() => {
|
|
|
55974
56149
|
function useControlTheme() {
|
|
55975
56150
|
return usePanelTheme();
|
|
55976
56151
|
}
|
|
55977
|
-
function
|
|
56152
|
+
function graphemes4(text) {
|
|
55978
56153
|
return Array.from(graphemeSegmenter2.segment(text), (part) => part.segment);
|
|
55979
56154
|
}
|
|
55980
56155
|
function truncateCells(text, width, keep = "tail") {
|
|
@@ -55985,7 +56160,7 @@ function truncateCells(text, width, keep = "tail") {
|
|
|
55985
56160
|
if (width === 1)
|
|
55986
56161
|
return "\u2026";
|
|
55987
56162
|
const budget = width - 1;
|
|
55988
|
-
const parts =
|
|
56163
|
+
const parts = graphemes4(text);
|
|
55989
56164
|
const picked = [];
|
|
55990
56165
|
let used = 0;
|
|
55991
56166
|
if (keep === "tail") {
|
|
@@ -60505,7 +60680,7 @@ function SubagentsViewer(props) {
|
|
|
60505
60680
|
const [scrollOffset, setScrollOffset] = createSignal(0);
|
|
60506
60681
|
const [status, setStatus] = createSignal(undefined);
|
|
60507
60682
|
let handle;
|
|
60508
|
-
|
|
60683
|
+
const [transcriptHandle, setTranscriptHandle] = createSignal(undefined);
|
|
60509
60684
|
let sequence = 0;
|
|
60510
60685
|
let lastXPress = 0;
|
|
60511
60686
|
let tickTimer;
|
|
@@ -60598,15 +60773,15 @@ function SubagentsViewer(props) {
|
|
|
60598
60773
|
setScrollOffset(Number.MAX_SAFE_INTEGER);
|
|
60599
60774
|
lastXPress = 0;
|
|
60600
60775
|
setStatus(undefined);
|
|
60601
|
-
|
|
60776
|
+
setTranscriptHandle(panels.open(() => renderTranscript(), {
|
|
60602
60777
|
id: `subagents-transcript-${++sequence}`,
|
|
60603
60778
|
title: t("panel.subagents.title.transcript"),
|
|
60604
60779
|
size: "xlarge",
|
|
60605
60780
|
onClose: () => {
|
|
60606
|
-
|
|
60781
|
+
setTranscriptHandle(undefined);
|
|
60607
60782
|
stopTicking();
|
|
60608
60783
|
}
|
|
60609
|
-
});
|
|
60784
|
+
}));
|
|
60610
60785
|
startTicking();
|
|
60611
60786
|
}
|
|
60612
60787
|
function openSteer() {
|
|
@@ -60697,14 +60872,14 @@ function SubagentsViewer(props) {
|
|
|
60697
60872
|
size: "xlarge",
|
|
60698
60873
|
onClose: () => {
|
|
60699
60874
|
handle = undefined;
|
|
60700
|
-
if (transcriptHandle === undefined)
|
|
60875
|
+
if (transcriptHandle() === undefined)
|
|
60701
60876
|
finish();
|
|
60702
60877
|
}
|
|
60703
60878
|
});
|
|
60704
60879
|
});
|
|
60705
60880
|
Keymap2.createLayer(() => ({
|
|
60706
60881
|
mode: "global",
|
|
60707
|
-
enabled: open() && transcriptHandle === undefined && handle?.ownsInput() === true && dialog.stack.length === 0,
|
|
60882
|
+
enabled: open() && transcriptHandle() === undefined && handle?.ownsInput() === true && dialog.stack.length === 0,
|
|
60708
60883
|
priority: 2,
|
|
60709
60884
|
commands: [{
|
|
60710
60885
|
bind: "up,k",
|
|
@@ -60743,7 +60918,7 @@ function SubagentsViewer(props) {
|
|
|
60743
60918
|
}));
|
|
60744
60919
|
Keymap2.createLayer(() => ({
|
|
60745
60920
|
mode: "global",
|
|
60746
|
-
enabled: open() && transcriptHandle?.ownsInput() === true && dialog.stack.length === 0,
|
|
60921
|
+
enabled: open() && transcriptHandle()?.ownsInput() === true && dialog.stack.length === 0,
|
|
60747
60922
|
priority: 2,
|
|
60748
60923
|
commands: [{
|
|
60749
60924
|
bind: "up,k",
|
|
@@ -60987,7 +61162,7 @@ var init_subagents_viewer = __esm(() => {
|
|
|
60987
61162
|
import { TextAttributes as TextAttributes12 } from "@opentui/core";
|
|
60988
61163
|
function resolveVersion() {
|
|
60989
61164
|
try {
|
|
60990
|
-
return "0.18.
|
|
61165
|
+
return "0.18.5";
|
|
60991
61166
|
} catch {
|
|
60992
61167
|
return "dev";
|
|
60993
61168
|
}
|
|
@@ -63499,10 +63674,25 @@ function V2SessionPage(props) {
|
|
|
63499
63674
|
}
|
|
63500
63675
|
function V2SessionPageBody(props) {
|
|
63501
63676
|
const seam = props.seam;
|
|
63677
|
+
const rawTurn = seam.turn.bind(seam);
|
|
63678
|
+
seam.turn = (userText, cb) => rawTurn(userText, {
|
|
63679
|
+
...cb,
|
|
63680
|
+
onThinkingDelta: (text) => {
|
|
63681
|
+
refreshFooterIfUnknown();
|
|
63682
|
+
cb.onThinkingDelta?.(text);
|
|
63683
|
+
},
|
|
63684
|
+
onContentDelta: (text) => {
|
|
63685
|
+
refreshFooterIfUnknown();
|
|
63686
|
+
cb.onContentDelta?.(text);
|
|
63687
|
+
}
|
|
63688
|
+
});
|
|
63502
63689
|
const projection = createSeamRows(seam, () => seam.currentSessionId() ?? "", {
|
|
63503
63690
|
onApprove: (name, args) => overlays.requestApproval(name, args),
|
|
63504
63691
|
onError: (message) => showNotice(`error: ${message}`, undefined, "error"),
|
|
63505
|
-
onToolRun: () =>
|
|
63692
|
+
onToolRun: () => {
|
|
63693
|
+
setTools((n) => n + 1);
|
|
63694
|
+
refreshFooterIfUnknown();
|
|
63695
|
+
}
|
|
63506
63696
|
});
|
|
63507
63697
|
const dialog = useDialog();
|
|
63508
63698
|
const pageOwns = useIsPageOwner();
|
|
@@ -63608,12 +63798,7 @@ function V2SessionPageBody(props) {
|
|
|
63608
63798
|
label: { confirm: t("turn.stop.confirmLabel"), cancel: t("turn.stop.cancelLabel") },
|
|
63609
63799
|
onConfirm: () => {
|
|
63610
63800
|
turnAborted = true;
|
|
63611
|
-
seam
|
|
63612
|
-
for (const view of seam.subagentViews?.() ?? []) {
|
|
63613
|
-
if (view.status !== "running")
|
|
63614
|
-
continue;
|
|
63615
|
-
seam.interruptChild?.(view.id).catch(() => {});
|
|
63616
|
-
}
|
|
63801
|
+
stopEverything(seam);
|
|
63617
63802
|
}
|
|
63618
63803
|
}, undefined, false, undefined, this), undefined, { tone: "warning" });
|
|
63619
63804
|
};
|
|
@@ -63628,7 +63813,24 @@ function V2SessionPageBody(props) {
|
|
|
63628
63813
|
};
|
|
63629
63814
|
const ctxWindow = () => seam.contextWindow?.() ?? null;
|
|
63630
63815
|
let footerRefreshSeq = 0;
|
|
63631
|
-
|
|
63816
|
+
let footerProbe = initialFooterProbeState();
|
|
63817
|
+
const resetFooterProbe = () => {
|
|
63818
|
+
footerProbe = initialFooterProbeState();
|
|
63819
|
+
};
|
|
63820
|
+
function refreshFooterIfUnknown() {
|
|
63821
|
+
const now = Date.now();
|
|
63822
|
+
if (!shouldStartFooterProbe(remoteInfo(), seam.currentSessionId(), footerProbe, now))
|
|
63823
|
+
return;
|
|
63824
|
+
footerProbe = markFooterProbeStarted(footerProbe, now);
|
|
63825
|
+
refreshFooterData((infoObtained) => {
|
|
63826
|
+
footerProbe = settleFooterProbe(footerProbe, infoObtained);
|
|
63827
|
+
});
|
|
63828
|
+
}
|
|
63829
|
+
createEffect(() => {
|
|
63830
|
+
if (remoteInfo() !== undefined)
|
|
63831
|
+
resetFooterProbe();
|
|
63832
|
+
});
|
|
63833
|
+
const refreshFooterData = (onSettled) => {
|
|
63632
63834
|
const seq = ++footerRefreshSeq;
|
|
63633
63835
|
let currentEffortWord;
|
|
63634
63836
|
let labelEffortWord;
|
|
@@ -63667,6 +63869,7 @@ function V2SessionPageBody(props) {
|
|
|
63667
63869
|
return;
|
|
63668
63870
|
});
|
|
63669
63871
|
Promise.resolve(seam.sessionInfo?.()).then((info) => {
|
|
63872
|
+
onSettled?.(!!info);
|
|
63670
63873
|
if (seq !== footerRefreshSeq)
|
|
63671
63874
|
return;
|
|
63672
63875
|
if (!info) {
|
|
@@ -63678,6 +63881,7 @@ function V2SessionPageBody(props) {
|
|
|
63678
63881
|
labelEffortWord = effortFromModelLabel(info.model);
|
|
63679
63882
|
settleEffort();
|
|
63680
63883
|
}).catch(() => {
|
|
63884
|
+
onSettled?.(false);
|
|
63681
63885
|
if (seq !== footerRefreshSeq)
|
|
63682
63886
|
return;
|
|
63683
63887
|
settleEffort();
|
|
@@ -63685,6 +63889,7 @@ function V2SessionPageBody(props) {
|
|
|
63685
63889
|
};
|
|
63686
63890
|
createEffect(() => {
|
|
63687
63891
|
if (!turnBusy()) {
|
|
63892
|
+
resetFooterProbe();
|
|
63688
63893
|
refreshFooterData();
|
|
63689
63894
|
refreshPresetLabel();
|
|
63690
63895
|
}
|
|
@@ -63818,6 +64023,7 @@ function V2SessionPageBody(props) {
|
|
|
63818
64023
|
resetSkinLineFades();
|
|
63819
64024
|
const settled = projection.load(sessionId);
|
|
63820
64025
|
seam.currentModelSelection().then(setModel);
|
|
64026
|
+
resetFooterProbe();
|
|
63821
64027
|
refreshFooterData();
|
|
63822
64028
|
refreshPresetLabel();
|
|
63823
64029
|
setSkillRows(props.skills ?? []);
|
|
@@ -63840,6 +64046,7 @@ function V2SessionPageBody(props) {
|
|
|
63840
64046
|
composerRef?.resetDeliveries();
|
|
63841
64047
|
setComposerPending([]);
|
|
63842
64048
|
setTools(0);
|
|
64049
|
+
resetFooterProbe();
|
|
63843
64050
|
refreshFooterData();
|
|
63844
64051
|
resetSkinLineFades();
|
|
63845
64052
|
setSkillRows(props.skills ?? []);
|
|
@@ -63865,6 +64072,17 @@ function V2SessionPageBody(props) {
|
|
|
63865
64072
|
themes: themeFace,
|
|
63866
64073
|
flushQueue: () => composerRef?.flushQueue() ?? { kind: "empty", started: 0, remaining: 0 }
|
|
63867
64074
|
}));
|
|
64075
|
+
Keymap2.createLayer(() => ({
|
|
64076
|
+
enabled: () => pageOwns(),
|
|
64077
|
+
commands: [
|
|
64078
|
+
{
|
|
64079
|
+
id: "session.subagents",
|
|
64080
|
+
title: "Subagents activity panel",
|
|
64081
|
+
group: "Session",
|
|
64082
|
+
run: () => slash.interceptSubmit("/subagents")
|
|
64083
|
+
}
|
|
64084
|
+
]
|
|
64085
|
+
}));
|
|
63868
64086
|
const overlayHost = createComponent2(TurnOverlayHost, {
|
|
63869
64087
|
controller: overlays,
|
|
63870
64088
|
reclaimFocus: () => {
|
|
@@ -64492,3 +64710,6 @@ export {
|
|
|
64492
64710
|
spawnIdleReaper,
|
|
64493
64711
|
themeNameFromConfig
|
|
64494
64712
|
};
|
|
64713
|
+
|
|
64714
|
+
//# debugId=8659A77903C3FF2F64756E2164756E21
|
|
64715
|
+
//# sourceMappingURL=index.js.map
|