@aiwayds/dsh-opentui 0.12.2 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/client/index.js +3195 -303
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -630,8 +630,10 @@ __export(exports_boot_shared, {
|
|
|
630
630
|
SKIN_MIGRATION_NOTICE: () => SKIN_MIGRATION_NOTICE,
|
|
631
631
|
SKIN_MIGRATION_THEME: () => SKIN_MIGRATION_THEME,
|
|
632
632
|
bootCallOrder: () => bootCallOrder,
|
|
633
|
+
clientErrorLogPath: () => clientErrorLogPath,
|
|
633
634
|
defaultSpawnReaper: () => defaultSpawnReaper,
|
|
634
635
|
hostLockPath: () => hostLockPath,
|
|
636
|
+
installClientErrorLog: () => installClientErrorLog,
|
|
635
637
|
installExitPaths: () => installExitPaths,
|
|
636
638
|
motionFromConfig: () => motionFromConfig,
|
|
637
639
|
resolveReaperScript: () => resolveReaperScript,
|
|
@@ -641,7 +643,7 @@ __export(exports_boot_shared, {
|
|
|
641
643
|
themeNameFromConfig: () => themeNameFromConfig
|
|
642
644
|
});
|
|
643
645
|
import { join as join2 } from "path";
|
|
644
|
-
import { existsSync as existsSync2 } from "fs";
|
|
646
|
+
import { appendFileSync, existsSync as existsSync2 } from "fs";
|
|
645
647
|
import { spawn } from "child_process";
|
|
646
648
|
function installExitPaths(shutdown, target = process, graceMs = SHUTDOWN_GRACE_MS) {
|
|
647
649
|
const realExit = target.exit.bind(target);
|
|
@@ -659,6 +661,34 @@ function installExitPaths(shutdown, target = process, graceMs = SHUTDOWN_GRACE_M
|
|
|
659
661
|
function hostLockPath(dshHome, profile) {
|
|
660
662
|
return join2(dshHome, `opentui-host.${profile}.json`);
|
|
661
663
|
}
|
|
664
|
+
function clientErrorLogPath(dshHome) {
|
|
665
|
+
return join2(dshHome, "opentui-client.errors.log");
|
|
666
|
+
}
|
|
667
|
+
function installClientErrorLog(dshHome, target = process) {
|
|
668
|
+
const logPath = clientErrorLogPath(dshHome);
|
|
669
|
+
const record = (kind, error) => {
|
|
670
|
+
const message = error instanceof Error ? error.stack ?? error.message : String(error);
|
|
671
|
+
const line = `${new Date().toISOString()} kind=${kind} pid=${process.pid}
|
|
672
|
+
${message}
|
|
673
|
+
|
|
674
|
+
`;
|
|
675
|
+
try {
|
|
676
|
+
appendFileSync(logPath, line);
|
|
677
|
+
} catch {}
|
|
678
|
+
try {
|
|
679
|
+
process.stderr.write(`[dsh-opentui] ${kind}: ${message.split(`
|
|
680
|
+
`)[0]}
|
|
681
|
+
`);
|
|
682
|
+
} catch {}
|
|
683
|
+
};
|
|
684
|
+
target.on("unhandledRejection", (reason) => {
|
|
685
|
+
record("unhandledRejection", reason);
|
|
686
|
+
});
|
|
687
|
+
target.on("uncaughtException", (error) => {
|
|
688
|
+
record("uncaughtException", error);
|
|
689
|
+
target.exit(1);
|
|
690
|
+
});
|
|
691
|
+
}
|
|
662
692
|
function resolveReaperScript() {
|
|
663
693
|
const candidates = [
|
|
664
694
|
join2(import.meta.dir, "..", "scripts", "idle-reaper.mjs"),
|
|
@@ -4966,38 +4996,34 @@ class RemoteSessionOps {
|
|
|
4966
4996
|
}
|
|
4967
4997
|
async listSessions(options = {}) {
|
|
4968
4998
|
const limit = options.limit ?? 12;
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
});
|
|
4996
|
-
}
|
|
4997
|
-
return out.sort((a, b) => String(b.updatedAt ?? "").localeCompare(String(a.updatedAt ?? ""))).slice(0, limit);
|
|
4998
|
-
} catch {
|
|
4999
|
-
return [];
|
|
4999
|
+
const value = await this.#rpc("session/list", { _request: {} });
|
|
5000
|
+
const items = Array.isArray(value.items) ? value.items : [];
|
|
5001
|
+
const retentionDays = Number(options.retentionDays ?? 0);
|
|
5002
|
+
const cutoff = retentionDays > 0 ? Date.now() - retentionDays * 86400000 : 0;
|
|
5003
|
+
const out = [];
|
|
5004
|
+
for (const item of items) {
|
|
5005
|
+
const row = typeof item === "object" && item !== null ? item : {};
|
|
5006
|
+
if (row.origin === "subagent")
|
|
5007
|
+
continue;
|
|
5008
|
+
const id = typeof row.sessionId === "string" ? row.sessionId : "";
|
|
5009
|
+
if (!id)
|
|
5010
|
+
continue;
|
|
5011
|
+
const updatedAt = typeof row.updatedAt === "number" ? String(row.updatedAt) : "";
|
|
5012
|
+
if (cutoff > 0 && updatedAt && Number(updatedAt) < cutoff)
|
|
5013
|
+
continue;
|
|
5014
|
+
const projections = row.projections ?? {};
|
|
5015
|
+
const values = projections.values ?? {};
|
|
5016
|
+
const title = typeof values.title === "string" ? values.title : "";
|
|
5017
|
+
out.push({
|
|
5018
|
+
id,
|
|
5019
|
+
title: title.slice(0, 40),
|
|
5020
|
+
...updatedAt ? { updatedAt } : {},
|
|
5021
|
+
...typeof row.cwd === "string" && row.cwd ? { cwd: row.cwd } : {},
|
|
5022
|
+
...typeof row.sizeBytes === "number" && Number.isFinite(row.sizeBytes) ? { sizeBytes: row.sizeBytes } : {},
|
|
5023
|
+
...typeof row.blank === "boolean" ? { blank: row.blank } : {}
|
|
5024
|
+
});
|
|
5000
5025
|
}
|
|
5026
|
+
return out.sort((a, b) => String(b.updatedAt ?? "").localeCompare(String(a.updatedAt ?? ""))).slice(0, limit);
|
|
5001
5027
|
}
|
|
5002
5028
|
async fetchJournal(sessionId, options = {}) {
|
|
5003
5029
|
const opening = await this.#followSnapshot(sessionId);
|
|
@@ -5618,9 +5644,22 @@ class WaterfallAnswerer {
|
|
|
5618
5644
|
}
|
|
5619
5645
|
|
|
5620
5646
|
// src/client/remote-local-fs.ts
|
|
5621
|
-
import {
|
|
5647
|
+
import {
|
|
5648
|
+
chmodSync as chmodSync2,
|
|
5649
|
+
closeSync,
|
|
5650
|
+
existsSync as existsSync4,
|
|
5651
|
+
openSync,
|
|
5652
|
+
readFileSync as readFileSync4,
|
|
5653
|
+
readdirSync,
|
|
5654
|
+
readSync,
|
|
5655
|
+
renameSync as renameSync3,
|
|
5656
|
+
statSync as statSync3,
|
|
5657
|
+
unlinkSync as unlinkSync2,
|
|
5658
|
+
writeFileSync as writeFileSync3
|
|
5659
|
+
} from "fs";
|
|
5622
5660
|
import { homedir as homedir2 } from "os";
|
|
5623
|
-
import { basename, join as join5 } from "path";
|
|
5661
|
+
import { basename, dirname, join as join5 } from "path";
|
|
5662
|
+
import * as nodeZlib from "zlib";
|
|
5624
5663
|
function resolveDshHome(explicit) {
|
|
5625
5664
|
return explicit ?? (process.env.DSH_HOME || join5(homedir2(), ".dsh"));
|
|
5626
5665
|
}
|
|
@@ -5839,45 +5878,14 @@ function repairScanSessions(explicitHome) {
|
|
|
5839
5878
|
let total = 0;
|
|
5840
5879
|
let ok = 0;
|
|
5841
5880
|
const broken = [];
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
}
|
|
5851
|
-
if (!(name.startsWith("session.") && (name.endsWith(".zstd") || name.endsWith(".jsonl"))))
|
|
5852
|
-
continue;
|
|
5853
|
-
total += 1;
|
|
5854
|
-
const size = statSync3(full).size;
|
|
5855
|
-
if (size === 0) {
|
|
5856
|
-
broken.push(`${name} (0 bytes)`);
|
|
5857
|
-
continue;
|
|
5858
|
-
}
|
|
5859
|
-
if (name.endsWith(".zstd")) {
|
|
5860
|
-
const buf = readFileSync4(full);
|
|
5861
|
-
const magicOk = buf[0] === 40 && buf[1] === 181 && buf[2] === 47 && buf[3] === 253;
|
|
5862
|
-
if (!magicOk) {
|
|
5863
|
-
broken.push(`${name} (not a zstd frame)`);
|
|
5864
|
-
continue;
|
|
5865
|
-
}
|
|
5866
|
-
ok += 1;
|
|
5867
|
-
continue;
|
|
5868
|
-
}
|
|
5869
|
-
try {
|
|
5870
|
-
const text = readFileSync4(full, "utf8").trim();
|
|
5871
|
-
const last = text.split(`
|
|
5872
|
-
`).filter((l) => l.trim()).pop() ?? "{}";
|
|
5873
|
-
JSON.parse(last);
|
|
5874
|
-
ok += 1;
|
|
5875
|
-
} catch {
|
|
5876
|
-
broken.push(`${name} (invalid jsonl tail)`);
|
|
5877
|
-
}
|
|
5878
|
-
}
|
|
5879
|
-
};
|
|
5880
|
-
visit(root, 0);
|
|
5881
|
+
visitSessionLogs(root, 0, (full, name) => {
|
|
5882
|
+
total += 1;
|
|
5883
|
+
const verdict = probeSessionLog(full, name);
|
|
5884
|
+
if (verdict.broken)
|
|
5885
|
+
broken.push(`${name} (${verdict.reason})`);
|
|
5886
|
+
else
|
|
5887
|
+
ok += 1;
|
|
5888
|
+
});
|
|
5881
5889
|
out.push(`sessions: ${total} logs scanned, ${ok} healthy`);
|
|
5882
5890
|
if (broken.length === 0)
|
|
5883
5891
|
out.push("no broken logs found");
|
|
@@ -5893,14 +5901,254 @@ function repairScanSessions(explicitHome) {
|
|
|
5893
5901
|
}
|
|
5894
5902
|
return out;
|
|
5895
5903
|
}
|
|
5896
|
-
|
|
5904
|
+
function scanBrokenSessionLogs(explicitHome) {
|
|
5905
|
+
const broken = [];
|
|
5906
|
+
try {
|
|
5907
|
+
const home = resolveDshHome(explicitHome);
|
|
5908
|
+
const root = join5(home, "sessions");
|
|
5909
|
+
if (!existsSync4(root))
|
|
5910
|
+
return broken;
|
|
5911
|
+
visitSessionLogs(root, 0, (full, name) => {
|
|
5912
|
+
const sessionId = /^session-(.+)$/.exec(basename(dirname(full)))?.[1];
|
|
5913
|
+
const verdict = probeSessionLog(full, name);
|
|
5914
|
+
if (verdict.broken)
|
|
5915
|
+
broken.push({ path: full, name, reason: verdict.reason, sessionId });
|
|
5916
|
+
});
|
|
5917
|
+
} catch (e) {
|
|
5918
|
+
broken.push({
|
|
5919
|
+
path: "",
|
|
5920
|
+
name: "",
|
|
5921
|
+
reason: `scan failed: ${String(e instanceof Error ? e.message : e).slice(0, 150)}`
|
|
5922
|
+
});
|
|
5923
|
+
}
|
|
5924
|
+
return broken;
|
|
5925
|
+
}
|
|
5926
|
+
function visitSessionLogs(dir, depth, onLog) {
|
|
5927
|
+
if (depth > 4)
|
|
5928
|
+
return;
|
|
5929
|
+
let entries;
|
|
5930
|
+
try {
|
|
5931
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
5932
|
+
} catch {
|
|
5933
|
+
return;
|
|
5934
|
+
}
|
|
5935
|
+
for (const entry of entries) {
|
|
5936
|
+
const full = join5(dir, entry.name);
|
|
5937
|
+
if (entry.isDirectory()) {
|
|
5938
|
+
visitSessionLogs(full, depth + 1, onLog);
|
|
5939
|
+
continue;
|
|
5940
|
+
}
|
|
5941
|
+
if (!(entry.name.startsWith("session.") && (entry.name.endsWith(".zstd") || entry.name.endsWith(".jsonl"))))
|
|
5942
|
+
continue;
|
|
5943
|
+
try {
|
|
5944
|
+
onLog(full, entry.name);
|
|
5945
|
+
} catch {
|
|
5946
|
+
continue;
|
|
5947
|
+
}
|
|
5948
|
+
}
|
|
5949
|
+
}
|
|
5950
|
+
function zstdVerifyFn() {
|
|
5951
|
+
if (typeof Bun !== "undefined" && typeof Bun.zstdDecompressSync === "function") {
|
|
5952
|
+
return Bun.zstdDecompressSync.bind(Bun);
|
|
5953
|
+
}
|
|
5954
|
+
if (typeof nodeZlib.zstdDecompressSync === "function")
|
|
5955
|
+
return nodeZlib.zstdDecompressSync;
|
|
5956
|
+
return;
|
|
5957
|
+
}
|
|
5958
|
+
function probeSessionLog(path, name) {
|
|
5959
|
+
let size;
|
|
5960
|
+
let mtimeMs;
|
|
5961
|
+
try {
|
|
5962
|
+
const st = statSync3(path);
|
|
5963
|
+
size = st.size;
|
|
5964
|
+
mtimeMs = st.mtimeMs;
|
|
5965
|
+
} catch {
|
|
5966
|
+
return { broken: false };
|
|
5967
|
+
}
|
|
5968
|
+
const cached = logVerdictCache.get(path);
|
|
5969
|
+
if (cached && cached.mtimeMs === mtimeMs && cached.size === size)
|
|
5970
|
+
return cached.verdict;
|
|
5971
|
+
let verdict;
|
|
5972
|
+
try {
|
|
5973
|
+
if (size === 0) {
|
|
5974
|
+
verdict = { broken: true, reason: "0 bytes" };
|
|
5975
|
+
} else if (name.endsWith(".zstd")) {
|
|
5976
|
+
verdict = probeZstdFrame(path);
|
|
5977
|
+
} else {
|
|
5978
|
+
verdict = jsonlTailParses(path, size) ? { broken: false } : { broken: true, reason: "invalid jsonl tail" };
|
|
5979
|
+
}
|
|
5980
|
+
} catch (e) {
|
|
5981
|
+
verdict = { broken: true, reason: `unreadable: ${String(e instanceof Error ? e.message : e).slice(0, 100)}` };
|
|
5982
|
+
}
|
|
5983
|
+
logVerdictCache.set(path, { mtimeMs, size, verdict });
|
|
5984
|
+
return verdict;
|
|
5985
|
+
}
|
|
5986
|
+
function probeZstdFrame(path) {
|
|
5987
|
+
const notRepairable = " \u2014 not repairable client-side (only plain jsonl tails are)";
|
|
5988
|
+
const fd = openSync(path, "r");
|
|
5989
|
+
try {
|
|
5990
|
+
const magic = Buffer.alloc(4);
|
|
5991
|
+
const read = readSync(fd, magic, 0, 4, 0);
|
|
5992
|
+
if (read < 4 || magic[0] !== 40 || magic[1] !== 181 || magic[2] !== 47 || magic[3] !== 253) {
|
|
5993
|
+
return { broken: true, reason: `not a zstd frame${notRepairable}` };
|
|
5994
|
+
}
|
|
5995
|
+
} finally {
|
|
5996
|
+
closeSync(fd);
|
|
5997
|
+
}
|
|
5998
|
+
const verify = zstdVerifyFn();
|
|
5999
|
+
if (verify === undefined)
|
|
6000
|
+
return { broken: false };
|
|
6001
|
+
try {
|
|
6002
|
+
verify(readFileSync4(path));
|
|
6003
|
+
return { broken: false };
|
|
6004
|
+
} catch {
|
|
6005
|
+
return { broken: true, reason: `truncated or corrupt zstd frame${notRepairable}` };
|
|
6006
|
+
}
|
|
6007
|
+
}
|
|
6008
|
+
function jsonlTailParses(path, size) {
|
|
6009
|
+
const fd = openSync(path, "r");
|
|
6010
|
+
try {
|
|
6011
|
+
let window = Math.min(size, 64 * 1024);
|
|
6012
|
+
for (;; ) {
|
|
6013
|
+
const buf = Buffer.alloc(window);
|
|
6014
|
+
const read = readSync(fd, buf, 0, window, size - window);
|
|
6015
|
+
const lines = buf.toString("utf8", 0, read).split(`
|
|
6016
|
+
`);
|
|
6017
|
+
let last = "";
|
|
6018
|
+
let lastIdx = -1;
|
|
6019
|
+
for (let i = lines.length - 1;i >= 0; i--) {
|
|
6020
|
+
if (lines[i].trim() !== "") {
|
|
6021
|
+
last = lines[i];
|
|
6022
|
+
lastIdx = i;
|
|
6023
|
+
break;
|
|
6024
|
+
}
|
|
6025
|
+
}
|
|
6026
|
+
if (last === "")
|
|
6027
|
+
return true;
|
|
6028
|
+
try {
|
|
6029
|
+
JSON.parse(last);
|
|
6030
|
+
return true;
|
|
6031
|
+
} catch {
|
|
6032
|
+
if (lastIdx === 0 && window < size) {
|
|
6033
|
+
window = Math.min(size, window * 4);
|
|
6034
|
+
continue;
|
|
6035
|
+
}
|
|
6036
|
+
return false;
|
|
6037
|
+
}
|
|
6038
|
+
}
|
|
6039
|
+
} finally {
|
|
6040
|
+
closeSync(fd);
|
|
6041
|
+
}
|
|
6042
|
+
}
|
|
6043
|
+
function sleepSync2(ms) {
|
|
6044
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
|
|
6045
|
+
}
|
|
6046
|
+
function repairSessionLogTail(path, options = {}) {
|
|
6047
|
+
const delayFn = options.delayFn ?? sleepSync2;
|
|
6048
|
+
const writeFn = options.writeFn ?? writeFileSync3;
|
|
6049
|
+
const renameFn = options.renameFn ?? renameSync3;
|
|
6050
|
+
if (!path.endsWith(".jsonl")) {
|
|
6051
|
+
return { kind: "failed", detail: "not a plain jsonl log \u2014 client-side repair only truncates invalid jsonl tails" };
|
|
6052
|
+
}
|
|
6053
|
+
let text;
|
|
6054
|
+
try {
|
|
6055
|
+
text = readFileSync4(path, "utf8");
|
|
6056
|
+
} catch (e) {
|
|
6057
|
+
return { kind: "failed", detail: `cannot read ${basename(path)}: ${String(e instanceof Error ? e.message : e)}` };
|
|
6058
|
+
}
|
|
6059
|
+
const lines = text.split(`
|
|
6060
|
+
`);
|
|
6061
|
+
let end = lines.length;
|
|
6062
|
+
while (end > 0 && lines[end - 1].trim() === "")
|
|
6063
|
+
end--;
|
|
6064
|
+
let kept = end;
|
|
6065
|
+
while (kept > 0) {
|
|
6066
|
+
try {
|
|
6067
|
+
JSON.parse(lines[kept - 1]);
|
|
6068
|
+
break;
|
|
6069
|
+
} catch {
|
|
6070
|
+
kept--;
|
|
6071
|
+
}
|
|
6072
|
+
}
|
|
6073
|
+
if (kept === 0) {
|
|
6074
|
+
return { kind: "failed", detail: "no parseable jsonl line remains \u2014 refusing to empty the log" };
|
|
6075
|
+
}
|
|
6076
|
+
if (kept === end)
|
|
6077
|
+
return { kind: "clean" };
|
|
6078
|
+
try {
|
|
6079
|
+
const before = statSync3(path);
|
|
6080
|
+
delayFn(ACTIVE_WRITER_PROBE_MS);
|
|
6081
|
+
const after = statSync3(path);
|
|
6082
|
+
if (before.size !== after.size || before.mtimeMs !== after.mtimeMs) {
|
|
6083
|
+
return { kind: "failed", detail: "log is still being written \u2014 repair abandoned, nothing was touched" };
|
|
6084
|
+
}
|
|
6085
|
+
} catch (e) {
|
|
6086
|
+
return { kind: "failed", detail: `cannot stat ${basename(path)}: ${String(e instanceof Error ? e.message : e)}` };
|
|
6087
|
+
}
|
|
6088
|
+
const repaired = lines.slice(0, kept).join(`
|
|
6089
|
+
`) + `
|
|
6090
|
+
`;
|
|
6091
|
+
const tmpPath = `${path}.repair-tmp-${Date.now()}`;
|
|
6092
|
+
try {
|
|
6093
|
+
writeFn(tmpPath, repaired, { mode: 384 });
|
|
6094
|
+
} catch (e) {
|
|
6095
|
+
return { kind: "failed", detail: `cannot write the repaired copy: ${String(e instanceof Error ? e.message : e)}` };
|
|
6096
|
+
}
|
|
6097
|
+
try {
|
|
6098
|
+
if (readFileSync4(tmpPath, "utf8") !== repaired)
|
|
6099
|
+
throw new Error("repaired copy content mismatch");
|
|
6100
|
+
} catch (e) {
|
|
6101
|
+
try {
|
|
6102
|
+
unlinkSync2(tmpPath);
|
|
6103
|
+
} catch {}
|
|
6104
|
+
return {
|
|
6105
|
+
kind: "failed",
|
|
6106
|
+
detail: `repaired copy failed verification: ${String(e instanceof Error ? e.message : e)}`
|
|
6107
|
+
};
|
|
6108
|
+
}
|
|
6109
|
+
let backupPath = `${path}.corrupt-bak`;
|
|
6110
|
+
try {
|
|
6111
|
+
statSync3(backupPath);
|
|
6112
|
+
backupPath = `${backupPath}.${Date.now()}`;
|
|
6113
|
+
} catch {}
|
|
6114
|
+
try {
|
|
6115
|
+
renameFn(path, backupPath);
|
|
6116
|
+
} catch (e) {
|
|
6117
|
+
try {
|
|
6118
|
+
unlinkSync2(tmpPath);
|
|
6119
|
+
} catch {}
|
|
6120
|
+
return { kind: "failed", detail: `cannot back up the original: ${String(e instanceof Error ? e.message : e)}` };
|
|
6121
|
+
}
|
|
6122
|
+
try {
|
|
6123
|
+
renameFn(tmpPath, path);
|
|
6124
|
+
} catch (e) {
|
|
6125
|
+
try {
|
|
6126
|
+
unlinkSync2(tmpPath);
|
|
6127
|
+
} catch {}
|
|
6128
|
+
let restored = false;
|
|
6129
|
+
try {
|
|
6130
|
+
renameFn(backupPath, path);
|
|
6131
|
+
restored = true;
|
|
6132
|
+
} catch {}
|
|
6133
|
+
return {
|
|
6134
|
+
kind: "failed",
|
|
6135
|
+
detail: `swap failed: ${String(e instanceof Error ? e.message : e)} \u2014 the original is at ${backupPath}${restored ? " (restored in place)" : " (restore failed; the backup copy is the only remaining data)"}`
|
|
6136
|
+
};
|
|
6137
|
+
}
|
|
6138
|
+
try {
|
|
6139
|
+
chmodSync2(path, 384);
|
|
6140
|
+
} catch {}
|
|
6141
|
+
return { kind: "repaired", backupPath };
|
|
6142
|
+
}
|
|
6143
|
+
var FRONTMATTER_FENCE = "---", KEY_LINE, logVerdictCache, ACTIVE_WRITER_PROBE_MS = 25;
|
|
5897
6144
|
var init_remote_local_fs = __esm(() => {
|
|
5898
6145
|
KEY_LINE = /^([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/;
|
|
6146
|
+
logVerdictCache = new Map;
|
|
5899
6147
|
});
|
|
5900
6148
|
|
|
5901
6149
|
// src/client/remote-agent-profiles.ts
|
|
5902
|
-
import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync5, renameSync as
|
|
5903
|
-
import { dirname, join as join6, resolve } from "path";
|
|
6150
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync5, renameSync as renameSync4, rmSync as rmSync2, writeFileSync as writeFileSync4 } from "fs";
|
|
6151
|
+
import { dirname as dirname2, join as join6, resolve } from "path";
|
|
5904
6152
|
function modelProfilesPath(home) {
|
|
5905
6153
|
return join6(home, "model-profiles.json");
|
|
5906
6154
|
}
|
|
@@ -5994,7 +6242,7 @@ function readNearestProfilePin(startDir) {
|
|
|
5994
6242
|
return name;
|
|
5995
6243
|
}
|
|
5996
6244
|
} catch {}
|
|
5997
|
-
const parent =
|
|
6245
|
+
const parent = dirname2(current);
|
|
5998
6246
|
if (parent === current)
|
|
5999
6247
|
break;
|
|
6000
6248
|
current = parent;
|
|
@@ -6091,12 +6339,12 @@ function saveProfileAgentOverrides(home, profileName, agentName, edit) {
|
|
|
6091
6339
|
profile.agents = agents;
|
|
6092
6340
|
profiles[index] = profile;
|
|
6093
6341
|
const body = JSON.stringify(raw);
|
|
6094
|
-
const dir =
|
|
6342
|
+
const dir = dirname2(path);
|
|
6095
6343
|
const tmp = join6(dir, `.model-profiles.json.tmp-${process.pid}`);
|
|
6096
6344
|
try {
|
|
6097
6345
|
mkdirSync3(dir, { recursive: true });
|
|
6098
6346
|
writeFileSync4(tmp, body);
|
|
6099
|
-
|
|
6347
|
+
renameSync4(tmp, path);
|
|
6100
6348
|
return;
|
|
6101
6349
|
} catch (e) {
|
|
6102
6350
|
try {
|
|
@@ -6219,19 +6467,19 @@ async function readImageAttachment(path) {
|
|
|
6219
6467
|
function imagePromptPart(file) {
|
|
6220
6468
|
return { type: "image", mediaType: file.mediaType, data: file.data, ...file.name ? { name: file.name } : {} };
|
|
6221
6469
|
}
|
|
6222
|
-
function
|
|
6223
|
-
const
|
|
6470
|
+
function attachmentRefsOfPromptContent(content) {
|
|
6471
|
+
const refs = [];
|
|
6224
6472
|
if (!Array.isArray(content))
|
|
6225
|
-
return
|
|
6473
|
+
return refs;
|
|
6226
6474
|
for (const block of content) {
|
|
6227
6475
|
const typed = block;
|
|
6228
6476
|
if (typed?.type !== "image" || typeof typed.attachment !== "object" || typed.attachment === null)
|
|
6229
6477
|
continue;
|
|
6230
|
-
const
|
|
6231
|
-
if (typeof attachmentId === "string" && attachmentId)
|
|
6232
|
-
|
|
6478
|
+
const ref = typed.attachment;
|
|
6479
|
+
if (typeof ref.attachmentId === "string" && ref.attachmentId)
|
|
6480
|
+
refs.push(ref);
|
|
6233
6481
|
}
|
|
6234
|
-
return
|
|
6482
|
+
return refs;
|
|
6235
6483
|
}
|
|
6236
6484
|
async function fetchHostFile(baseUrl, cookieHeader, path) {
|
|
6237
6485
|
const url = `${baseUrl.replace(/\/$/, "")}/api/file?path=${encodeURIComponent(path)}`;
|
|
@@ -6247,8 +6495,8 @@ async function fetchHostFile(baseUrl, cookieHeader, path) {
|
|
|
6247
6495
|
throw new HostFileError(`GET /api/file ${path}: HTTP ${response.status}`);
|
|
6248
6496
|
return new Uint8Array(await response.arrayBuffer());
|
|
6249
6497
|
}
|
|
6250
|
-
async function readSessionAttachment(rpc, sessionId,
|
|
6251
|
-
const value = await rpc("session/attachment", { request: { sessionId,
|
|
6498
|
+
async function readSessionAttachment(rpc, sessionId, attachment) {
|
|
6499
|
+
const value = await rpc("session/attachment", { request: { sessionId, attachment } });
|
|
6252
6500
|
const ref = typeof value.attachment === "object" && value.attachment !== null ? value.attachment : {};
|
|
6253
6501
|
return {
|
|
6254
6502
|
data: typeof value.data === "string" ? value.data : "",
|
|
@@ -6501,19 +6749,26 @@ class SubagentRoundPolicy {
|
|
|
6501
6749
|
});
|
|
6502
6750
|
if (spinAction === "force-stop-early") {
|
|
6503
6751
|
this.#hardStopped.add(childId);
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
} catch {
|
|
6508
|
-
stoppedEarly = false;
|
|
6509
|
-
}
|
|
6510
|
-
if (stoppedEarly) {
|
|
6752
|
+
const reportEarlyStop = (stopped) => {
|
|
6753
|
+
if (!stopped)
|
|
6754
|
+
return;
|
|
6511
6755
|
try {
|
|
6512
6756
|
this.#options.onHardStop?.({ childId, round: count, cap: caps.cap, grace: caps.grace, early: true });
|
|
6513
6757
|
} catch {}
|
|
6514
6758
|
try {
|
|
6515
6759
|
this.#options.onSpinStop?.(childId, count);
|
|
6516
6760
|
} catch {}
|
|
6761
|
+
};
|
|
6762
|
+
let stoppedEarly = false;
|
|
6763
|
+
try {
|
|
6764
|
+
stoppedEarly = this.#options.forceStop(childId);
|
|
6765
|
+
} catch {
|
|
6766
|
+
stoppedEarly = false;
|
|
6767
|
+
}
|
|
6768
|
+
if (stoppedEarly instanceof Promise) {
|
|
6769
|
+
stoppedEarly.then(reportEarlyStop, () => {});
|
|
6770
|
+
} else {
|
|
6771
|
+
reportEarlyStop(stoppedEarly);
|
|
6517
6772
|
}
|
|
6518
6773
|
return;
|
|
6519
6774
|
}
|
|
@@ -6565,19 +6820,26 @@ class SubagentRoundPolicy {
|
|
|
6565
6820
|
return;
|
|
6566
6821
|
}
|
|
6567
6822
|
this.#hardStopped.add(childId);
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
|
|
6571
|
-
} catch {
|
|
6572
|
-
stopped = false;
|
|
6573
|
-
}
|
|
6574
|
-
if (stopped) {
|
|
6823
|
+
const reportStop = (stopped) => {
|
|
6824
|
+
if (!stopped)
|
|
6825
|
+
return;
|
|
6575
6826
|
try {
|
|
6576
6827
|
this.#options.onHardStop?.({ childId, round: count, cap: caps.cap, grace: caps.grace });
|
|
6577
6828
|
} catch {}
|
|
6578
6829
|
try {
|
|
6579
6830
|
this.#options.onForceStop?.(childId, count);
|
|
6580
6831
|
} catch {}
|
|
6832
|
+
};
|
|
6833
|
+
let stopped = false;
|
|
6834
|
+
try {
|
|
6835
|
+
stopped = this.#options.forceStop(childId);
|
|
6836
|
+
} catch {
|
|
6837
|
+
stopped = false;
|
|
6838
|
+
}
|
|
6839
|
+
if (stopped instanceof Promise) {
|
|
6840
|
+
stopped.then(reportStop, () => {});
|
|
6841
|
+
} else {
|
|
6842
|
+
reportStop(stopped);
|
|
6581
6843
|
}
|
|
6582
6844
|
}
|
|
6583
6845
|
#resolveCaps(childId, label) {
|
|
@@ -6767,10 +7029,14 @@ class RemoteSubagentPanel {
|
|
|
6767
7029
|
},
|
|
6768
7030
|
forceStop: (id) => {
|
|
6769
7031
|
if (!this.#children.has(id))
|
|
7032
|
+
return Promise.resolve(false);
|
|
7033
|
+
return this.interrupt(id).then(() => {
|
|
7034
|
+
this.#settle(id, "cancelled");
|
|
7035
|
+
return true;
|
|
7036
|
+
}).catch((error) => {
|
|
7037
|
+
console.error("[remote-subagents] force-stop failed:", describeError(error));
|
|
6770
7038
|
return false;
|
|
6771
|
-
|
|
6772
|
-
this.#settle(id, "cancelled");
|
|
6773
|
-
return true;
|
|
7039
|
+
});
|
|
6774
7040
|
},
|
|
6775
7041
|
onHardStop: (record) => this.#options.onHardStop?.(record),
|
|
6776
7042
|
onWrapUp: (id, round) => {
|
|
@@ -6826,7 +7092,7 @@ class RemoteSubagentPanel {
|
|
|
6826
7092
|
if (!view)
|
|
6827
7093
|
return;
|
|
6828
7094
|
if (!running && view.status === "running") {
|
|
6829
|
-
this.#children.set(sessionId, { ...view, status: "completed" });
|
|
7095
|
+
this.#children.set(sessionId, { ...view, status: "completed", endedAt: Date.now() });
|
|
6830
7096
|
this.#emit();
|
|
6831
7097
|
}
|
|
6832
7098
|
}
|
|
@@ -6861,7 +7127,7 @@ class RemoteSubagentPanel {
|
|
|
6861
7127
|
this.#adopt(id, `subagent ${id.slice(0, 8)}`);
|
|
6862
7128
|
changed = true;
|
|
6863
7129
|
} else if (row.running === false && existing.status === "running") {
|
|
6864
|
-
this.#children.set(id, { ...existing, status: "completed" });
|
|
7130
|
+
this.#children.set(id, { ...existing, status: "completed", endedAt: Date.now() });
|
|
6865
7131
|
changed = true;
|
|
6866
7132
|
}
|
|
6867
7133
|
}
|
|
@@ -6878,6 +7144,7 @@ class RemoteSubagentPanel {
|
|
|
6878
7144
|
status: v.status,
|
|
6879
7145
|
rounds: v.rounds,
|
|
6880
7146
|
startedAt: v.startedAt,
|
|
7147
|
+
...v.status !== "running" ? { endedAt: v.endedAt ?? Date.now() } : {},
|
|
6881
7148
|
...v.tokens !== undefined ? { tokens: v.tokens } : {},
|
|
6882
7149
|
elapsed: Math.max(0, Math.floor((Date.now() - v.startedAt) / 1000)),
|
|
6883
7150
|
...v.lastLine ? { lastLine: clamp(v.lastLine) } : {},
|
|
@@ -6947,11 +7214,23 @@ class RemoteSubagentPanel {
|
|
|
6947
7214
|
const parent = this.#options.parentId();
|
|
6948
7215
|
if (parent === undefined)
|
|
6949
7216
|
throw new Error("no live parent session");
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
7217
|
+
try {
|
|
7218
|
+
await this.#options.rpc("subagents/interruptByParent", {
|
|
7219
|
+
childSessionId: id,
|
|
7220
|
+
parentSessionId: parent,
|
|
7221
|
+
mode: "continuable"
|
|
7222
|
+
});
|
|
7223
|
+
return;
|
|
7224
|
+
} catch (dedicatedError) {
|
|
7225
|
+
const dedicated = describeError(dedicatedError);
|
|
7226
|
+
try {
|
|
7227
|
+
await this.#options.rpc("session/cancel", { sessionId: id });
|
|
7228
|
+
console.warn(`[remote-subagents] interruptByParent failed (${dedicated}) \u2014 stopped the child via session/cancel`);
|
|
7229
|
+
return;
|
|
7230
|
+
} catch (fallbackError) {
|
|
7231
|
+
throw new Error(`interrupt failed \u2014 interruptByParent: ${dedicated}; session/cancel fallback: ${describeError(fallbackError)}`);
|
|
7232
|
+
}
|
|
7233
|
+
}
|
|
6955
7234
|
}
|
|
6956
7235
|
stop() {
|
|
6957
7236
|
this.#stopped = true;
|
|
@@ -6977,7 +7256,7 @@ class RemoteSubagentPanel {
|
|
|
6977
7256
|
#settle(childId, outcome) {
|
|
6978
7257
|
const existing = this.#children.get(childId);
|
|
6979
7258
|
if (existing !== undefined && existing.status === "running") {
|
|
6980
|
-
this.#children.set(childId, { ...existing, status: outcome });
|
|
7259
|
+
this.#children.set(childId, { ...existing, status: outcome, endedAt: Date.now() });
|
|
6981
7260
|
this.#emit();
|
|
6982
7261
|
}
|
|
6983
7262
|
}
|
|
@@ -7113,7 +7392,7 @@ class RemoteSubagentPanel {
|
|
|
7113
7392
|
changed = true;
|
|
7114
7393
|
}
|
|
7115
7394
|
} else if (type === "turn/end" && view.status === "running") {
|
|
7116
|
-
this.#children.set(id, { ...view, status: "completed" });
|
|
7395
|
+
this.#children.set(id, { ...view, status: "completed", endedAt: Date.now() });
|
|
7117
7396
|
changed = true;
|
|
7118
7397
|
}
|
|
7119
7398
|
while (log.length > 200)
|
|
@@ -7141,6 +7420,11 @@ class RemoteSubagentPanel {
|
|
|
7141
7420
|
}
|
|
7142
7421
|
}
|
|
7143
7422
|
}
|
|
7423
|
+
function describeError(error) {
|
|
7424
|
+
if (error instanceof RemoteRpcError)
|
|
7425
|
+
return `${error.code}: ${error.message}`;
|
|
7426
|
+
return String(error instanceof Error ? error.message : error);
|
|
7427
|
+
}
|
|
7144
7428
|
function lastContentLine(text) {
|
|
7145
7429
|
if (text === undefined)
|
|
7146
7430
|
return;
|
|
@@ -7188,7 +7472,7 @@ var init_remote_subagents = __esm(() => {
|
|
|
7188
7472
|
|
|
7189
7473
|
// src/client/remote-restart.ts
|
|
7190
7474
|
import { spawn as spawn3 } from "child_process";
|
|
7191
|
-
import { existsSync as existsSync6, readFileSync as readFileSync6, renameSync as
|
|
7475
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, renameSync as renameSync5, rmSync as rmSync3, unlinkSync as unlinkSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
7192
7476
|
import { join as join7 } from "path";
|
|
7193
7477
|
function defaultSpawnDsh2(argv, options) {
|
|
7194
7478
|
const child = spawn3("dsh", argv, {
|
|
@@ -7215,7 +7499,7 @@ function writeRestartedLock(home, profile, host) {
|
|
|
7215
7499
|
const tmp = `${path}.tmp`;
|
|
7216
7500
|
writeFileSync5(tmp, JSON.stringify(payload, null, 2) + `
|
|
7217
7501
|
`);
|
|
7218
|
-
|
|
7502
|
+
renameSync5(tmp, path);
|
|
7219
7503
|
}
|
|
7220
7504
|
async function restartSamePortHost(options = {}) {
|
|
7221
7505
|
const profile = options.profile ?? "opentui";
|
|
@@ -7264,7 +7548,7 @@ async function restartSamePortHost(options = {}) {
|
|
|
7264
7548
|
rmSync3(lockPath, { force: true });
|
|
7265
7549
|
} catch {
|
|
7266
7550
|
try {
|
|
7267
|
-
|
|
7551
|
+
unlinkSync3(lockPath);
|
|
7268
7552
|
} catch {}
|
|
7269
7553
|
}
|
|
7270
7554
|
const quietDeadline = deadline(KILL_GRACE_MS2 + KILL_ESCALATE_MS2 + LISTEN_RELEASE_GRACE_MS);
|
|
@@ -7343,7 +7627,7 @@ __export(exports_remote_host_session, {
|
|
|
7343
7627
|
openRemoteStream: () => openRemoteStream
|
|
7344
7628
|
});
|
|
7345
7629
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
7346
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync7, renameSync as
|
|
7630
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync7, renameSync as renameSync6, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "fs";
|
|
7347
7631
|
import { join as joinPath } from "path";
|
|
7348
7632
|
import WS3 from "ws";
|
|
7349
7633
|
function trace(message) {
|
|
@@ -7422,6 +7706,7 @@ class RemoteHostSession {
|
|
|
7422
7706
|
#turnArmSeq = -1;
|
|
7423
7707
|
#tail;
|
|
7424
7708
|
#pluginsCache = [];
|
|
7709
|
+
#bundlesCache = [];
|
|
7425
7710
|
#skillsCache = [];
|
|
7426
7711
|
#skillListeners = [];
|
|
7427
7712
|
#skillsRefreshedFor;
|
|
@@ -8011,7 +8296,7 @@ class RemoteHostSession {
|
|
|
8011
8296
|
try {
|
|
8012
8297
|
writeFileSync6(tmp, JSON.stringify(merged, null, 2) + `
|
|
8013
8298
|
`);
|
|
8014
|
-
|
|
8299
|
+
renameSync6(tmp, path);
|
|
8015
8300
|
} catch (error) {
|
|
8016
8301
|
try {
|
|
8017
8302
|
rmSync4(tmp, { force: true });
|
|
@@ -8173,13 +8458,16 @@ class RemoteHostSession {
|
|
|
8173
8458
|
})
|
|
8174
8459
|
]);
|
|
8175
8460
|
const versions = new Map;
|
|
8176
|
-
|
|
8461
|
+
const nextBundles = Array.isArray(bundles) ? bundles.map(normalizeBundleRow).filter((row) => row.name !== "") : undefined;
|
|
8462
|
+
const bundlesChanged = nextBundles !== undefined && JSON.stringify(nextBundles) !== JSON.stringify(this.#bundlesCache);
|
|
8463
|
+
if (nextBundles !== undefined) {
|
|
8177
8464
|
for (const b of bundles) {
|
|
8178
8465
|
const moduleName = typeof b?.moduleName === "string" ? b.moduleName : typeof b?.name === "string" ? b.name : "";
|
|
8179
8466
|
const version = typeof b?.version === "string" ? b.version : "";
|
|
8180
8467
|
if (moduleName && version)
|
|
8181
8468
|
versions.set(moduleName, version);
|
|
8182
8469
|
}
|
|
8470
|
+
this.#bundlesCache = nextBundles;
|
|
8183
8471
|
}
|
|
8184
8472
|
this.#pluginsCache = (Array.isArray(plugins) ? plugins : []).map((p) => {
|
|
8185
8473
|
const row = typeof p === "object" && p !== null ? p : {};
|
|
@@ -8188,7 +8476,7 @@ class RemoteHostSession {
|
|
|
8188
8476
|
const title = typeof meta.title === "string" ? meta.title : moduleName;
|
|
8189
8477
|
return { name: title, moduleName, version: versions.get(moduleName) ?? "" };
|
|
8190
8478
|
}).filter((p) => p.name && !p.moduleName.startsWith("@deepseek-ai/")).map(({ name, version }) => ({ name, version }));
|
|
8191
|
-
if (this.#pluginsCache.length !== before || before === 0) {
|
|
8479
|
+
if (this.#pluginsCache.length !== before || before === 0 || bundlesChanged) {
|
|
8192
8480
|
for (const listener of this.#pushListeners) {
|
|
8193
8481
|
try {
|
|
8194
8482
|
listener.onPluginsChanged?.();
|
|
@@ -8198,6 +8486,39 @@ class RemoteHostSession {
|
|
|
8198
8486
|
} catch {}
|
|
8199
8487
|
return [...this.#pluginsCache];
|
|
8200
8488
|
}
|
|
8489
|
+
listBundles() {
|
|
8490
|
+
return [...this.#bundlesCache];
|
|
8491
|
+
}
|
|
8492
|
+
async setBundleEnabled(name, enabled) {
|
|
8493
|
+
try {
|
|
8494
|
+
const change = normalizeChangeResult(await this.#rpc("pluginManager/setBundleEnabled", { name, enabled }));
|
|
8495
|
+
this.refreshPlugins().catch(() => {});
|
|
8496
|
+
return change;
|
|
8497
|
+
} catch (cause) {
|
|
8498
|
+
return failedChange(name, cause);
|
|
8499
|
+
}
|
|
8500
|
+
}
|
|
8501
|
+
async removeBundle(name) {
|
|
8502
|
+
try {
|
|
8503
|
+
const change = normalizeChangeResult(await this.#rpc("pluginManager/removeBundle", { name }));
|
|
8504
|
+
this.refreshPlugins().catch(() => {});
|
|
8505
|
+
return change;
|
|
8506
|
+
} catch (cause) {
|
|
8507
|
+
return failedChange(name, cause);
|
|
8508
|
+
}
|
|
8509
|
+
}
|
|
8510
|
+
async inspectBundle(spec) {
|
|
8511
|
+
return normalizeInspection(await this.#rpc("pluginManager/inspect", { spec }));
|
|
8512
|
+
}
|
|
8513
|
+
async installBundle(spec) {
|
|
8514
|
+
try {
|
|
8515
|
+
const change = normalizeChangeResult(await this.#rpc("pluginManager/installBundle", { spec, options: { enabled: true } }));
|
|
8516
|
+
this.refreshPlugins().catch(() => {});
|
|
8517
|
+
return change;
|
|
8518
|
+
} catch (cause) {
|
|
8519
|
+
return failedChange(spec, cause);
|
|
8520
|
+
}
|
|
8521
|
+
}
|
|
8201
8522
|
executionMode() {
|
|
8202
8523
|
return this.#executionMode;
|
|
8203
8524
|
}
|
|
@@ -8215,9 +8536,21 @@ class RemoteHostSession {
|
|
|
8215
8536
|
repairScan() {
|
|
8216
8537
|
return repairScanSessions(this.#dshHome);
|
|
8217
8538
|
}
|
|
8539
|
+
repairScanBroken() {
|
|
8540
|
+
return scanBrokenSessionLogs(this.#dshHome);
|
|
8541
|
+
}
|
|
8542
|
+
repairSessionLog(path) {
|
|
8543
|
+
return repairSessionLogTail(path);
|
|
8544
|
+
}
|
|
8218
8545
|
async searchSessions(query) {
|
|
8219
8546
|
return this.#opsClient().searchSessions(query);
|
|
8220
8547
|
}
|
|
8548
|
+
async sessionJournal(sessionId) {
|
|
8549
|
+
return this.#opsClient().fetchJournal(sessionId);
|
|
8550
|
+
}
|
|
8551
|
+
async forkSession(sessionId, atSeq) {
|
|
8552
|
+
return this.#opsClient().fork(sessionId, atSeq);
|
|
8553
|
+
}
|
|
8221
8554
|
historyTurns() {
|
|
8222
8555
|
return groupTurns(this.#journal);
|
|
8223
8556
|
}
|
|
@@ -8267,22 +8600,27 @@ class RemoteHostSession {
|
|
|
8267
8600
|
fetchHostFile(path) {
|
|
8268
8601
|
return fetchHostFile(this.#baseUrl, this.#cookieHeader, path);
|
|
8269
8602
|
}
|
|
8270
|
-
|
|
8603
|
+
#attachmentRefsOfLastPrompt() {
|
|
8271
8604
|
for (let i = this.#journal.length - 1;i >= 0; i--) {
|
|
8272
8605
|
const entry = this.#journal[i];
|
|
8273
8606
|
if (entry.type !== "user/message")
|
|
8274
8607
|
continue;
|
|
8275
|
-
const
|
|
8276
|
-
if (
|
|
8277
|
-
return
|
|
8608
|
+
const refs = attachmentRefsOfPromptContent(entry.data.content ?? entry.data.message?.content);
|
|
8609
|
+
if (refs.length > 0)
|
|
8610
|
+
return refs;
|
|
8278
8611
|
}
|
|
8279
8612
|
return [];
|
|
8280
8613
|
}
|
|
8614
|
+
lastAttachmentIds() {
|
|
8615
|
+
return this.#attachmentRefsOfLastPrompt().map((ref) => ref.attachmentId);
|
|
8616
|
+
}
|
|
8281
8617
|
readSessionAttachment(attachmentId) {
|
|
8282
8618
|
const sessionId = this.#sessionId;
|
|
8283
8619
|
if (sessionId === undefined)
|
|
8284
8620
|
throw new Error("no live session to read attachments from");
|
|
8285
|
-
|
|
8621
|
+
const known = this.#attachmentRefsOfLastPrompt().find((ref) => ref.attachmentId === attachmentId);
|
|
8622
|
+
const attachment = known ?? { attachmentId, mediaType: "", bytes: 0, width: 0, height: 0 };
|
|
8623
|
+
return readSessionAttachment((method, args) => this.#rpc(method, args), sessionId, attachment);
|
|
8286
8624
|
}
|
|
8287
8625
|
gitBranch(cwd = this.#cwd) {
|
|
8288
8626
|
return probeGitBranch(cwd);
|
|
@@ -8898,6 +9236,57 @@ function asPermissionOptions(value) {
|
|
|
8898
9236
|
];
|
|
8899
9237
|
});
|
|
8900
9238
|
}
|
|
9239
|
+
function normalizeBundleRow(raw) {
|
|
9240
|
+
const name = typeof raw.name === "string" ? raw.name : "";
|
|
9241
|
+
const error = raw.error;
|
|
9242
|
+
return {
|
|
9243
|
+
name,
|
|
9244
|
+
version: typeof raw.version === "string" ? raw.version : "",
|
|
9245
|
+
description: typeof raw.description === "string" ? raw.description : "",
|
|
9246
|
+
enabled: raw.enabled === true,
|
|
9247
|
+
installed: raw.installed === true,
|
|
9248
|
+
optional: raw.optional === true,
|
|
9249
|
+
removable: raw.removable === true,
|
|
9250
|
+
readOnlyReason: typeof raw.readOnlyReason === "string" ? raw.readOnlyReason : undefined,
|
|
9251
|
+
error: typeof error === "object" && error !== null ? typeof error.diagnostic === "string" ? error.diagnostic : typeof error.message === "string" ? error.message : undefined : typeof error === "string" ? error : undefined
|
|
9252
|
+
};
|
|
9253
|
+
}
|
|
9254
|
+
function normalizeChangeResult(raw) {
|
|
9255
|
+
const row = typeof raw === "object" && raw !== null ? raw : {};
|
|
9256
|
+
const application = row.application;
|
|
9257
|
+
const error = row.error;
|
|
9258
|
+
return {
|
|
9259
|
+
changed: row.changed === true,
|
|
9260
|
+
application: application === "applied" || application === "restart-required" || application === "overridden" || application === "cancelled" ? application : "failed",
|
|
9261
|
+
target: typeof row.target === "string" ? row.target : "",
|
|
9262
|
+
error: typeof error === "object" && error !== null ? typeof error.diagnostic === "string" ? error.diagnostic : typeof error.code === "string" ? error.code : undefined : undefined
|
|
9263
|
+
};
|
|
9264
|
+
}
|
|
9265
|
+
function normalizeInspection(raw) {
|
|
9266
|
+
const row = typeof raw === "object" && raw !== null ? raw : {};
|
|
9267
|
+
if (row.status === "accepted") {
|
|
9268
|
+
return {
|
|
9269
|
+
status: "accepted",
|
|
9270
|
+
name: typeof row.name === "string" ? row.name : undefined,
|
|
9271
|
+
version: typeof row.version === "string" ? row.version : undefined,
|
|
9272
|
+
description: typeof row.description === "string" ? row.description : undefined,
|
|
9273
|
+
bundle: row.bundle === true ? true : row.bundle === false ? false : null
|
|
9274
|
+
};
|
|
9275
|
+
}
|
|
9276
|
+
return {
|
|
9277
|
+
status: "refused",
|
|
9278
|
+
problem: typeof row.problem === "string" ? row.problem : "unknown",
|
|
9279
|
+
reason: typeof row.reason === "string" ? row.reason : ""
|
|
9280
|
+
};
|
|
9281
|
+
}
|
|
9282
|
+
function failedChange(target, cause) {
|
|
9283
|
+
return {
|
|
9284
|
+
changed: false,
|
|
9285
|
+
application: "failed",
|
|
9286
|
+
target,
|
|
9287
|
+
error: cause instanceof Error ? cause.message : String(cause)
|
|
9288
|
+
};
|
|
9289
|
+
}
|
|
8901
9290
|
var REATTACH_RETRY_MS = 1000, REATTACH_MAX_ATTEMPTS = 30, SPIN_REFRESH_TTL_MS = 5000, PRESET_ENGLISH_NAMES;
|
|
8902
9291
|
var init_remote_host_session = __esm(() => {
|
|
8903
9292
|
init_loop();
|
|
@@ -43173,18 +43562,44 @@ function fitColumn(header, cells) {
|
|
|
43173
43562
|
function padCell(cell, width) {
|
|
43174
43563
|
return cell.length >= width ? cell : cell + " ".repeat(width - cell.length);
|
|
43175
43564
|
}
|
|
43176
|
-
function resumePickerOptions(rows, now = Date.now()) {
|
|
43565
|
+
function resumePickerOptions(rows, now = Date.now(), corruptIds) {
|
|
43177
43566
|
const updatedCells = rows.map((row) => relativeTime(row.updatedAt, now));
|
|
43178
43567
|
const dirCells = rows.map((row) => resumeDirLabel(row.cwd));
|
|
43179
43568
|
const updated = fitColumn("UPDATED", updatedCells);
|
|
43180
43569
|
const dir = fitColumn("DIR", dirCells);
|
|
43181
43570
|
const header = `${padCell(updated.header, updated.width)} ${padCell(dir.header, dir.width)} SESSION`;
|
|
43182
43571
|
const options = rows.map((row, index) => ({
|
|
43183
|
-
title: `${padCell(updatedCells[index], updated.width)} ${padCell(dirCells[index], dir.width)} ${row.title}`,
|
|
43572
|
+
title: `${padCell(updatedCells[index], updated.width)} ${padCell(dirCells[index], dir.width)} ${resumeRowTitle(row.title, corruptIds?.has(row.id) ?? false)}`,
|
|
43184
43573
|
value: row.id
|
|
43185
43574
|
}));
|
|
43186
43575
|
return { header, options };
|
|
43187
43576
|
}
|
|
43577
|
+
function resumeRowTitle(title, corrupt) {
|
|
43578
|
+
return corrupt ? `\u26A0 ${title}` : title;
|
|
43579
|
+
}
|
|
43580
|
+
function corruptSessionIds(broken) {
|
|
43581
|
+
const ids = new Set;
|
|
43582
|
+
for (const row of broken) {
|
|
43583
|
+
if (row.sessionId !== undefined && row.sessionId !== "")
|
|
43584
|
+
ids.add(row.sessionId);
|
|
43585
|
+
}
|
|
43586
|
+
return ids;
|
|
43587
|
+
}
|
|
43588
|
+
function brokenLogsForSession(broken, sessionId) {
|
|
43589
|
+
return broken.filter((row) => row.sessionId === sessionId);
|
|
43590
|
+
}
|
|
43591
|
+
function isRepairableLogRow(row) {
|
|
43592
|
+
return row.path.endsWith(".jsonl") && row.reason !== "0 bytes";
|
|
43593
|
+
}
|
|
43594
|
+
function repairConfirmOptions() {
|
|
43595
|
+
return [
|
|
43596
|
+
{ title: "Repair & resume", value: "repair", description: "back up the log, truncate the broken tail" },
|
|
43597
|
+
{ title: "Cancel", value: "cancel", description: "leave the log untouched" }
|
|
43598
|
+
];
|
|
43599
|
+
}
|
|
43600
|
+
function repairConfirmBody(broken) {
|
|
43601
|
+
return broken.map((row) => `${row.name} \u2014 ${row.reason}`);
|
|
43602
|
+
}
|
|
43188
43603
|
var SESSIONS_MIN_BYTES = 1024, SESSIONS_DIR_CAP = 32;
|
|
43189
43604
|
|
|
43190
43605
|
// ../tui-base/src/routes/session/auto-resume.ts
|
|
@@ -45168,10 +45583,12 @@ function createSeamRows(seam, sessionID, options) {
|
|
|
45168
45583
|
return seam.storedTranscript(id).then((stored) => {
|
|
45169
45584
|
if (sessionIdOverride !== undefined || sessionID() === id)
|
|
45170
45585
|
hydrate(stored);
|
|
45171
|
-
}).catch(() => {
|
|
45586
|
+
}).catch((error) => {
|
|
45172
45587
|
console.warn(`[seam-rows] transcript read failed for ${id}`);
|
|
45173
|
-
if (!hydrated())
|
|
45174
|
-
|
|
45588
|
+
if (!hydrated()) {
|
|
45589
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
45590
|
+
hydrate([{ kind: "assistant", text: `error: transcript read failed (${message})`, final: true }]);
|
|
45591
|
+
}
|
|
45175
45592
|
});
|
|
45176
45593
|
}
|
|
45177
45594
|
function upsert(row) {
|
|
@@ -48095,6 +48512,7 @@ var init_search_overlay = __esm(() => {
|
|
|
48095
48512
|
|
|
48096
48513
|
// ../tui-base/src/routes/session/transcript-scroll.tsx
|
|
48097
48514
|
function TranscriptScrollKeys(props) {
|
|
48515
|
+
const renderer = useRenderer();
|
|
48098
48516
|
const page = (delta) => {
|
|
48099
48517
|
const scroll = props.scroll();
|
|
48100
48518
|
if (!scroll || scroll.isDestroyed)
|
|
@@ -48117,6 +48535,34 @@ function TranscriptScrollKeys(props) {
|
|
|
48117
48535
|
}],
|
|
48118
48536
|
bindings: ["session.page.up", "session.page.down"]
|
|
48119
48537
|
}));
|
|
48538
|
+
const first = () => {
|
|
48539
|
+
const scroll = props.scroll();
|
|
48540
|
+
if (!scroll || scroll.isDestroyed)
|
|
48541
|
+
return;
|
|
48542
|
+
scroll.stickyScroll = false;
|
|
48543
|
+
scroll.scrollTo(0);
|
|
48544
|
+
};
|
|
48545
|
+
const last = () => {
|
|
48546
|
+
const scroll = props.scroll();
|
|
48547
|
+
if (!scroll || scroll.isDestroyed)
|
|
48548
|
+
return;
|
|
48549
|
+
scroll.scrollTo(Infinity);
|
|
48550
|
+
};
|
|
48551
|
+
Keymap2.createLayer(() => ({
|
|
48552
|
+
enabled: () => props.enabled() && renderer.currentFocusedEditor === null,
|
|
48553
|
+
commands: [{
|
|
48554
|
+
id: "session.first",
|
|
48555
|
+
title: "First message",
|
|
48556
|
+
group: "Session",
|
|
48557
|
+
run: first
|
|
48558
|
+
}, {
|
|
48559
|
+
id: "session.last",
|
|
48560
|
+
title: "Last message",
|
|
48561
|
+
group: "Session",
|
|
48562
|
+
run: last
|
|
48563
|
+
}],
|
|
48564
|
+
bindings: ["session.first", "session.last"]
|
|
48565
|
+
}));
|
|
48120
48566
|
return createComponent2(Show, {
|
|
48121
48567
|
when: false,
|
|
48122
48568
|
children: null
|
|
@@ -48125,6 +48571,7 @@ function TranscriptScrollKeys(props) {
|
|
|
48125
48571
|
var init_transcript_scroll = __esm(() => {
|
|
48126
48572
|
init_index_bun();
|
|
48127
48573
|
init_server();
|
|
48574
|
+
init_index_bun();
|
|
48128
48575
|
init_keymap();
|
|
48129
48576
|
});
|
|
48130
48577
|
|
|
@@ -49129,6 +49576,37 @@ function formatSessionInfoPanel(rows) {
|
|
|
49129
49576
|
return rows.map((row) => `${row.field.padEnd(width)} ${row.value}`);
|
|
49130
49577
|
}
|
|
49131
49578
|
|
|
49579
|
+
// ../tui-base/src/routes/session/model-picker.ts
|
|
49580
|
+
function modelKey(providerID, modelID) {
|
|
49581
|
+
return `${providerID}/${modelID}`;
|
|
49582
|
+
}
|
|
49583
|
+
function toggleStringList(list, key) {
|
|
49584
|
+
return list.includes(key) ? list.filter((entry) => entry !== key) : [...list, key];
|
|
49585
|
+
}
|
|
49586
|
+
function narrowStringList(value) {
|
|
49587
|
+
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
49588
|
+
}
|
|
49589
|
+
function readModelPrefsFromConfig(config) {
|
|
49590
|
+
return {
|
|
49591
|
+
favoriteModels: narrowStringList(config?.favoriteModels),
|
|
49592
|
+
hiddenModels: narrowStringList(config?.hiddenModels)
|
|
49593
|
+
};
|
|
49594
|
+
}
|
|
49595
|
+
function buildModelPickerRows(entries, favorites, hidden, current) {
|
|
49596
|
+
const byKey = new Map(entries.map((entry) => [modelKey(entry.providerID, entry.modelID), entry]));
|
|
49597
|
+
const hiddenSet = new Set(hidden);
|
|
49598
|
+
const row = (entry, category, star = false) => ({
|
|
49599
|
+
title: `${star ? "\u2605 " : ""}${entry.providerID}/${entry.modelID}`,
|
|
49600
|
+
value: modelKey(entry.providerID, entry.modelID),
|
|
49601
|
+
description: current !== undefined && current.providerID === entry.providerID && current.modelID === entry.modelID ? "current" : undefined,
|
|
49602
|
+
...category !== undefined ? { category } : {}
|
|
49603
|
+
});
|
|
49604
|
+
const favoriteRows = favorites.map((key) => byKey.get(key)).filter((entry) => entry !== undefined).map((entry) => row(entry, "Favorites", true));
|
|
49605
|
+
const normalRows = entries.filter((entry) => !favorites.includes(modelKey(entry.providerID, entry.modelID)) && !hiddenSet.has(modelKey(entry.providerID, entry.modelID))).map((entry) => row(entry));
|
|
49606
|
+
const hiddenRows = entries.filter((entry) => hiddenSet.has(modelKey(entry.providerID, entry.modelID)) && !favorites.includes(modelKey(entry.providerID, entry.modelID))).map((entry) => row(entry, "Hidden"));
|
|
49607
|
+
return [...favoriteRows, ...normalRows, ...hiddenRows];
|
|
49608
|
+
}
|
|
49609
|
+
|
|
49132
49610
|
// ../tui-base/src/routes/session/login.ts
|
|
49133
49611
|
function deriveKeyRef(provider) {
|
|
49134
49612
|
return `${provider.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_API_KEY`;
|
|
@@ -49284,6 +49762,39 @@ async function commitLoginRoute(say, face, entry, key) {
|
|
|
49284
49762
|
}
|
|
49285
49763
|
say(`${entry.name} subscribed \u2014 key stored, route registered (in /model next session)`);
|
|
49286
49764
|
}
|
|
49765
|
+
async function offerCorruptedLogRepair(ctx, sessionId, broken) {
|
|
49766
|
+
if (broken.length === 0) {
|
|
49767
|
+
ctx.say(`cannot repair ${sessionId}: no broken log found on disk`);
|
|
49768
|
+
return false;
|
|
49769
|
+
}
|
|
49770
|
+
if (!ctx.seam.repairSessionLog) {
|
|
49771
|
+
ctx.say("/resume repair unavailable in this session \u2014 the log was left untouched");
|
|
49772
|
+
return false;
|
|
49773
|
+
}
|
|
49774
|
+
const unrepairable = broken.filter((row) => !isRepairableLogRow(row));
|
|
49775
|
+
if (unrepairable.length > 0) {
|
|
49776
|
+
ctx.say(`cannot repair ${sessionId} client-side \u2014 ${repairConfirmBody(unrepairable).join("; ")}; only plain jsonl tails are repairable. The log was left untouched.`);
|
|
49777
|
+
return false;
|
|
49778
|
+
}
|
|
49779
|
+
const confirm = await ctx.pickOne(`Session ${sessionId} has a broken log (${repairConfirmBody(broken).join("; ")}) \u2014 repair it?`, repairConfirmOptions());
|
|
49780
|
+
if (confirm !== "repair") {
|
|
49781
|
+
ctx.say(`resume cancelled \u2014 the log was left untouched (${repairConfirmBody(broken).join("; ")})`);
|
|
49782
|
+
return false;
|
|
49783
|
+
}
|
|
49784
|
+
for (const row of broken) {
|
|
49785
|
+
const result = ctx.seam.repairSessionLog(row.path);
|
|
49786
|
+
if (result.kind === "failed") {
|
|
49787
|
+
ctx.say(`repair failed \u2014 ${row.name}: ${result.detail} (the log was left untouched or restored)`);
|
|
49788
|
+
return false;
|
|
49789
|
+
}
|
|
49790
|
+
if (result.kind === "clean") {
|
|
49791
|
+
ctx.say(`${row.name} needs no repair \u2014 the last line already parses; resuming`);
|
|
49792
|
+
} else {
|
|
49793
|
+
ctx.say(`repaired ${row.name} \u2014 the original was kept at ${result.backupPath}`);
|
|
49794
|
+
}
|
|
49795
|
+
}
|
|
49796
|
+
return true;
|
|
49797
|
+
}
|
|
49287
49798
|
async function commitCatalogLogin(ctx, face, entry) {
|
|
49288
49799
|
const key = await ctx.promptText?.(`API key for ${entry.name} (${deriveKeyRef(entry.id)})`, { mask: true });
|
|
49289
49800
|
if (key === undefined)
|
|
@@ -49336,6 +49847,17 @@ async function runCustomLoginChain(ctx, face, existingRoutes) {
|
|
|
49336
49847
|
}
|
|
49337
49848
|
}
|
|
49338
49849
|
}
|
|
49850
|
+
function logoutTargets(routes) {
|
|
49851
|
+
return routes.map((route) => {
|
|
49852
|
+
const entry = PROVIDER_CATALOG.find((e) => e.id === route.id);
|
|
49853
|
+
return {
|
|
49854
|
+
id: route.id,
|
|
49855
|
+
name: route.displayName ? route.displayName : entry?.name ?? route.id,
|
|
49856
|
+
ref: route.apiKeyEnv ?? deriveKeyRef(route.id),
|
|
49857
|
+
custom: route.declared === true || entry === undefined
|
|
49858
|
+
};
|
|
49859
|
+
});
|
|
49860
|
+
}
|
|
49339
49861
|
function coreCommands() {
|
|
49340
49862
|
return [
|
|
49341
49863
|
{
|
|
@@ -49387,11 +49909,45 @@ function coreCommands() {
|
|
|
49387
49909
|
return;
|
|
49388
49910
|
}
|
|
49389
49911
|
const current = await ctx.seam.currentModelSelection();
|
|
49390
|
-
const
|
|
49391
|
-
|
|
49392
|
-
|
|
49393
|
-
|
|
49394
|
-
|
|
49912
|
+
const prefs = readModelPrefsFromConfig(ctx.seam.configLoad?.());
|
|
49913
|
+
let favorites = prefs.favoriteModels;
|
|
49914
|
+
let hidden = prefs.hiddenModels;
|
|
49915
|
+
const persistPrefs = () => {
|
|
49916
|
+
try {
|
|
49917
|
+
ctx.seam.configSave?.({ favoriteModels: [...favorites], hiddenModels: [...hidden] });
|
|
49918
|
+
} catch (error) {
|
|
49919
|
+
console.error("[commands] model prefs persist failed:", error);
|
|
49920
|
+
}
|
|
49921
|
+
};
|
|
49922
|
+
const currentKey = current ? modelKey(current.providerID, current.modelID) : undefined;
|
|
49923
|
+
const picked = await ctx.pickOne("Select model", buildModelPickerRows(catalog, favorites, hidden, current), undefined, currentKey, {
|
|
49924
|
+
actions: [
|
|
49925
|
+
{
|
|
49926
|
+
command: "model.picker.favorite",
|
|
49927
|
+
title: (value) => value !== undefined && favorites.includes(value) ? "unfavorite" : "favorite",
|
|
49928
|
+
bind: "f"
|
|
49929
|
+
},
|
|
49930
|
+
{
|
|
49931
|
+
command: "model.picker.hide",
|
|
49932
|
+
title: "hide",
|
|
49933
|
+
bind: "h",
|
|
49934
|
+
disabled: (value) => favorites.includes(value)
|
|
49935
|
+
}
|
|
49936
|
+
],
|
|
49937
|
+
getOptions: () => buildModelPickerRows(catalog, favorites, hidden, current),
|
|
49938
|
+
onAction: (command, value) => {
|
|
49939
|
+
if (command === "model.picker.favorite") {
|
|
49940
|
+
favorites = toggleStringList(favorites, value);
|
|
49941
|
+
} else if (command === "model.picker.hide") {
|
|
49942
|
+
if (favorites.includes(value))
|
|
49943
|
+
return;
|
|
49944
|
+
hidden = toggleStringList(hidden, value);
|
|
49945
|
+
} else {
|
|
49946
|
+
return;
|
|
49947
|
+
}
|
|
49948
|
+
persistPrefs();
|
|
49949
|
+
}
|
|
49950
|
+
});
|
|
49395
49951
|
if (!picked)
|
|
49396
49952
|
return;
|
|
49397
49953
|
const [providerID, modelID] = picked.split("/");
|
|
@@ -49480,7 +50036,7 @@ function coreCommands() {
|
|
|
49480
50036
|
if (!picked)
|
|
49481
50037
|
return;
|
|
49482
50038
|
if (picked === CUSTOM_ENTRY.id) {
|
|
49483
|
-
const routes = await face.routes().catch(() => []);
|
|
50039
|
+
const routes = (await face.routes().catch(() => [])).map((route) => route.id);
|
|
49484
50040
|
await runCustomLoginChain(ctx, face, routes);
|
|
49485
50041
|
return;
|
|
49486
50042
|
}
|
|
@@ -49490,6 +50046,61 @@ function coreCommands() {
|
|
|
49490
50046
|
await commitCatalogLogin(ctx, face, entry);
|
|
49491
50047
|
}
|
|
49492
50048
|
},
|
|
50049
|
+
{
|
|
50050
|
+
name: "/logout",
|
|
50051
|
+
description: "log out a provider (drops the stored key)",
|
|
50052
|
+
async run(ctx, argText) {
|
|
50053
|
+
const face = ctx.seam.login;
|
|
50054
|
+
if (!face) {
|
|
50055
|
+
ctx.say("/logout unavailable in this session");
|
|
50056
|
+
return;
|
|
50057
|
+
}
|
|
50058
|
+
let routes;
|
|
50059
|
+
try {
|
|
50060
|
+
routes = await face.routes();
|
|
50061
|
+
} catch (error) {
|
|
50062
|
+
ctx.say(`logout failed \u2014 ${seamFailureReason(error)}`);
|
|
50063
|
+
return;
|
|
50064
|
+
}
|
|
50065
|
+
const loggedIn = [];
|
|
50066
|
+
for (const target of logoutTargets(routes)) {
|
|
50067
|
+
try {
|
|
50068
|
+
if ((await face.credentialStatus(target.ref)).configured)
|
|
50069
|
+
loggedIn.push(target);
|
|
50070
|
+
} catch {}
|
|
50071
|
+
}
|
|
50072
|
+
if (loggedIn.length === 0) {
|
|
50073
|
+
ctx.say("no logged-in providers");
|
|
50074
|
+
return;
|
|
50075
|
+
}
|
|
50076
|
+
const arg = argText.trim();
|
|
50077
|
+
let target = arg ? loggedIn.find((t) => t.id === arg) : undefined;
|
|
50078
|
+
if (arg && !target) {
|
|
50079
|
+
ctx.say(`not logged in: ${arg}`);
|
|
50080
|
+
return;
|
|
50081
|
+
}
|
|
50082
|
+
if (!target) {
|
|
50083
|
+
const picked = await ctx.pickOne("Log out provider", loggedIn.map((t) => ({ title: t.name, value: t.id, description: t.ref })));
|
|
50084
|
+
if (!picked)
|
|
50085
|
+
return;
|
|
50086
|
+
target = loggedIn.find((t) => t.id === picked);
|
|
50087
|
+
}
|
|
50088
|
+
if (!target)
|
|
50089
|
+
return;
|
|
50090
|
+
try {
|
|
50091
|
+
await face.logout(target.ref);
|
|
50092
|
+
} catch (error) {
|
|
50093
|
+
ctx.say(`${target.id}: logout failed \u2014 ${seamFailureReason(error)}`);
|
|
50094
|
+
return;
|
|
50095
|
+
}
|
|
50096
|
+
if (target.custom) {
|
|
50097
|
+
ctx.say(`${target.name} logged out \u2014 key removed (route kept)`);
|
|
50098
|
+
return;
|
|
50099
|
+
}
|
|
50100
|
+
const cleared = await face.registerRoute(target.id, undefined).catch(() => false);
|
|
50101
|
+
ctx.say(cleared ? `${target.name} logged out \u2014 key + route removed (leaves /model next session)` : `${target.name} logged out \u2014 key removed, route removal failed`);
|
|
50102
|
+
}
|
|
50103
|
+
},
|
|
49493
50104
|
{
|
|
49494
50105
|
name: "/quit",
|
|
49495
50106
|
description: "exit the app",
|
|
@@ -49501,7 +50112,13 @@ function coreCommands() {
|
|
|
49501
50112
|
name: "/resume",
|
|
49502
50113
|
description: "resume a persisted session",
|
|
49503
50114
|
async run(ctx) {
|
|
49504
|
-
|
|
50115
|
+
let sessions;
|
|
50116
|
+
try {
|
|
50117
|
+
sessions = await ctx.seam.listSessions();
|
|
50118
|
+
} catch (error) {
|
|
50119
|
+
ctx.say(`resume unavailable \u2014 ${seamFailureReason(error)}`);
|
|
50120
|
+
return;
|
|
50121
|
+
}
|
|
49505
50122
|
if (sessions.length === 0) {
|
|
49506
50123
|
ctx.say("no stored sessions");
|
|
49507
50124
|
return;
|
|
@@ -49511,10 +50128,17 @@ function coreCommands() {
|
|
|
49511
50128
|
ctx.say(emptyFilteredCopy(sessions.length));
|
|
49512
50129
|
return;
|
|
49513
50130
|
}
|
|
49514
|
-
const
|
|
50131
|
+
const broken = ctx.seam.repairScanBroken?.() ?? [];
|
|
50132
|
+
const corruptIds = corruptSessionIds(broken);
|
|
50133
|
+
const { header, options } = resumePickerOptions(visible, Date.now(), corruptIds);
|
|
49515
50134
|
const picked = await ctx.pickOne("Resume session", options, header);
|
|
49516
50135
|
if (!picked)
|
|
49517
50136
|
return;
|
|
50137
|
+
if (corruptIds.has(picked)) {
|
|
50138
|
+
const ok = await offerCorruptedLogRepair(ctx, picked, brokenLogsForSession(broken, picked));
|
|
50139
|
+
if (!ok)
|
|
50140
|
+
return;
|
|
50141
|
+
}
|
|
49518
50142
|
ctx.seam.resumeSession(picked);
|
|
49519
50143
|
await ctx.reload(picked);
|
|
49520
50144
|
ctx.say(`resumed ${picked}`);
|
|
@@ -49597,6 +50221,17 @@ function coreCommands() {
|
|
|
49597
50221
|
ctx.say(`\u25CF ${plugin.name}@${plugin.version}`);
|
|
49598
50222
|
}
|
|
49599
50223
|
},
|
|
50224
|
+
{
|
|
50225
|
+
name: "/skills",
|
|
50226
|
+
description: "manage skills (opens the panel)",
|
|
50227
|
+
run(ctx) {
|
|
50228
|
+
if (!ctx.openSkills) {
|
|
50229
|
+
ctx.say("/skills unavailable in this session");
|
|
50230
|
+
return;
|
|
50231
|
+
}
|
|
50232
|
+
ctx.openSkills();
|
|
50233
|
+
}
|
|
50234
|
+
},
|
|
49600
50235
|
{
|
|
49601
50236
|
name: "/search",
|
|
49602
50237
|
description: "full-text search over stored sessions",
|
|
@@ -49635,6 +50270,33 @@ function coreCommands() {
|
|
|
49635
50270
|
ctx.openSettings();
|
|
49636
50271
|
}
|
|
49637
50272
|
},
|
|
50273
|
+
{
|
|
50274
|
+
name: "/history",
|
|
50275
|
+
description: "browse completed turns of the session (refill, switch, fork)",
|
|
50276
|
+
run(ctx) {
|
|
50277
|
+
if (!ctx.openHistory) {
|
|
50278
|
+
ctx.say("/history: the browser panel is not mounted in this entry");
|
|
50279
|
+
return;
|
|
50280
|
+
}
|
|
50281
|
+
ctx.openHistory();
|
|
50282
|
+
}
|
|
50283
|
+
},
|
|
50284
|
+
{
|
|
50285
|
+
name: "/subagents",
|
|
50286
|
+
description: "view live subagent transcripts (list, steer, stop)",
|
|
50287
|
+
run(ctx) {
|
|
50288
|
+
if (!ctx.openSubagents) {
|
|
50289
|
+
ctx.say("/subagents: the transcript viewer is not mounted in this entry");
|
|
50290
|
+
return;
|
|
50291
|
+
}
|
|
50292
|
+
const views = ctx.seam.subagentViews?.() ?? [];
|
|
50293
|
+
if (views.length === 0) {
|
|
50294
|
+
ctx.say("no subagents in this session \u2014 spawn one and run /subagents again");
|
|
50295
|
+
return;
|
|
50296
|
+
}
|
|
50297
|
+
ctx.openSubagents();
|
|
50298
|
+
}
|
|
50299
|
+
},
|
|
49638
50300
|
{
|
|
49639
50301
|
name: "/think",
|
|
49640
50302
|
description: "set reasoning effort (opens the picker)",
|
|
@@ -49934,8 +50596,11 @@ function buildSlashDeps(base, hooks) {
|
|
|
49934
50596
|
themes: hooks.themes,
|
|
49935
50597
|
openSearch: hooks.openSearch,
|
|
49936
50598
|
openPlugins: hooks.openPlugins,
|
|
50599
|
+
openSkills: hooks.openSkills,
|
|
49937
50600
|
openAgents: hooks.openAgents,
|
|
49938
50601
|
openSettings: hooks.openSettings,
|
|
50602
|
+
openHistory: hooks.openHistory,
|
|
50603
|
+
openSubagents: hooks.openSubagents,
|
|
49939
50604
|
refreshFooter: hooks.refreshFooter,
|
|
49940
50605
|
invalidateFooter: hooks.invalidateFooter,
|
|
49941
50606
|
flushQueue: hooks.flushQueue
|
|
@@ -49958,8 +50623,11 @@ var init_slash_deps = __esm(() => {
|
|
|
49958
50623
|
"themes",
|
|
49959
50624
|
"openSearch",
|
|
49960
50625
|
"openPlugins",
|
|
50626
|
+
"openSkills",
|
|
49961
50627
|
"openAgents",
|
|
49962
50628
|
"openSettings",
|
|
50629
|
+
"openHistory",
|
|
50630
|
+
"openSubagents",
|
|
49963
50631
|
"refreshFooter",
|
|
49964
50632
|
"invalidateFooter",
|
|
49965
50633
|
"flushQueue"
|
|
@@ -50075,14 +50743,14 @@ var init_slash_usage = __esm(() => {
|
|
|
50075
50743
|
// ../tui-base/src/routes/session/skills-source.ts
|
|
50076
50744
|
import { existsSync as existsSync8, readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync4 } from "fs";
|
|
50077
50745
|
import { homedir as homedir4 } from "os";
|
|
50078
|
-
import { dirname as
|
|
50746
|
+
import { dirname as dirname3, join as join8, resolve as resolve5 } from "path";
|
|
50079
50747
|
import { TextAttributes as TextAttributes8 } from "@opentui/core";
|
|
50080
50748
|
function findProjectRoot(cwd) {
|
|
50081
50749
|
let dir = resolve5(cwd);
|
|
50082
50750
|
for (let depth = 0;depth < 64; depth++) {
|
|
50083
50751
|
if (existsSync8(join8(dir, ".git")))
|
|
50084
50752
|
return dir;
|
|
50085
|
-
const parent =
|
|
50753
|
+
const parent = dirname3(dir);
|
|
50086
50754
|
if (parent === dir)
|
|
50087
50755
|
break;
|
|
50088
50756
|
dir = parent;
|
|
@@ -50594,18 +51262,578 @@ var init_slash_palette = __esm(() => {
|
|
|
50594
51262
|
PALETTE_ROWS = MAX_ROWS + 1;
|
|
50595
51263
|
});
|
|
50596
51264
|
|
|
51265
|
+
// ../tui-base/src/routes/session/skills-manage.ts
|
|
51266
|
+
import { existsSync as existsSync9 } from "fs";
|
|
51267
|
+
import { lstat, mkdir as mkdir2, readFile as readFile3, readdir, realpath, symlink, unlink } from "fs/promises";
|
|
51268
|
+
import { join as join9 } from "path";
|
|
51269
|
+
function skillSymlinkPaths(publicDir, curatedDir, name) {
|
|
51270
|
+
const srcMd = join9(publicDir, `${name}.md`);
|
|
51271
|
+
if (existsSync9(srcMd))
|
|
51272
|
+
return { src: srcMd, dest: join9(curatedDir, `${name}.md`) };
|
|
51273
|
+
const srcBundle = join9(publicDir, name);
|
|
51274
|
+
if (existsSync9(srcBundle))
|
|
51275
|
+
return { src: srcBundle, dest: join9(curatedDir, name) };
|
|
51276
|
+
return;
|
|
51277
|
+
}
|
|
51278
|
+
async function installSkillSymlink(src, dest) {
|
|
51279
|
+
const srcReal = await realpath(src).catch((error) => {
|
|
51280
|
+
const code = error.code;
|
|
51281
|
+
throw new Error(`skill source vanished: "${src}"${code === undefined ? "" : ` (${code})`}`);
|
|
51282
|
+
});
|
|
51283
|
+
const destStat = await lstat(dest).catch(() => {
|
|
51284
|
+
return;
|
|
51285
|
+
});
|
|
51286
|
+
if (destStat === undefined) {
|
|
51287
|
+
await symlink(src, dest);
|
|
51288
|
+
return;
|
|
51289
|
+
}
|
|
51290
|
+
if (!destStat.isSymbolicLink()) {
|
|
51291
|
+
throw new Error(`refusing to overwrite "${dest}": not a symlink`);
|
|
51292
|
+
}
|
|
51293
|
+
const destReal = await realpath(dest).catch((error) => {
|
|
51294
|
+
const code = error.code;
|
|
51295
|
+
if (code === "ENOENT" || code === "ELOOP")
|
|
51296
|
+
return;
|
|
51297
|
+
throw error;
|
|
51298
|
+
});
|
|
51299
|
+
if (destReal === undefined) {
|
|
51300
|
+
await unlink(dest);
|
|
51301
|
+
await symlink(src, dest);
|
|
51302
|
+
return;
|
|
51303
|
+
}
|
|
51304
|
+
if (destReal === srcReal)
|
|
51305
|
+
return;
|
|
51306
|
+
throw new Error(`already installed from a different source: "${dest}" points to "${destReal}", expected "${srcReal}"`);
|
|
51307
|
+
}
|
|
51308
|
+
async function applyOneSkillChange(name, targetState, publicDir, curatedDir) {
|
|
51309
|
+
if (targetState) {
|
|
51310
|
+
const paths = skillSymlinkPaths(publicDir, curatedDir, name);
|
|
51311
|
+
if (paths === undefined)
|
|
51312
|
+
return `cannot install: skill not found in "${publicDir}"`;
|
|
51313
|
+
try {
|
|
51314
|
+
await installSkillSymlink(paths.src, paths.dest);
|
|
51315
|
+
return;
|
|
51316
|
+
} catch (error) {
|
|
51317
|
+
return `cannot install: ${error instanceof Error ? error.message : String(error)}`;
|
|
51318
|
+
}
|
|
51319
|
+
}
|
|
51320
|
+
try {
|
|
51321
|
+
const destMd = join9(curatedDir, `${name}.md`);
|
|
51322
|
+
const destBundle = join9(curatedDir, name);
|
|
51323
|
+
const mdStat = await lstat(destMd).catch(() => {
|
|
51324
|
+
return;
|
|
51325
|
+
});
|
|
51326
|
+
if (mdStat !== undefined) {
|
|
51327
|
+
if (!mdStat.isSymbolicLink())
|
|
51328
|
+
throw new Error(`refusing to remove "${destMd}": not a symlink`);
|
|
51329
|
+
await unlink(destMd);
|
|
51330
|
+
return;
|
|
51331
|
+
}
|
|
51332
|
+
const bundleStat = await lstat(destBundle).catch(() => {
|
|
51333
|
+
return;
|
|
51334
|
+
});
|
|
51335
|
+
if (bundleStat !== undefined) {
|
|
51336
|
+
if (!bundleStat.isSymbolicLink())
|
|
51337
|
+
throw new Error(`refusing to remove "${destBundle}": not a symlink`);
|
|
51338
|
+
await unlink(destBundle);
|
|
51339
|
+
}
|
|
51340
|
+
return;
|
|
51341
|
+
} catch (error) {
|
|
51342
|
+
return `cannot uninstall: ${error instanceof Error ? error.message : String(error)}`;
|
|
51343
|
+
}
|
|
51344
|
+
}
|
|
51345
|
+
function skillApplyShortReason(error) {
|
|
51346
|
+
if (error.includes("not a symlink"))
|
|
51347
|
+
return "protected (not a symlink)";
|
|
51348
|
+
if (error.includes("different source"))
|
|
51349
|
+
return "installed from a different source";
|
|
51350
|
+
if (error.includes("skill not found") || error.includes("source vanished"))
|
|
51351
|
+
return "source missing";
|
|
51352
|
+
return "failed";
|
|
51353
|
+
}
|
|
51354
|
+
function skillApplySummary(results) {
|
|
51355
|
+
const failures = results.filter((r) => r.error !== undefined);
|
|
51356
|
+
if (failures.length === 0)
|
|
51357
|
+
return "";
|
|
51358
|
+
const okNames = results.filter((r) => r.error === undefined).map((r) => r.name);
|
|
51359
|
+
const failed = failures.slice(0, SKILL_SUMMARY_MAX_ITEMS).map((r) => `${r.name} (${skillApplyShortReason(r.error ?? "")})`).join(", ");
|
|
51360
|
+
const failedExtra = failures.length - SKILL_SUMMARY_MAX_ITEMS;
|
|
51361
|
+
const failedMore = failedExtra > 0 ? ` +${failedExtra} more` : "";
|
|
51362
|
+
const okShown = okNames.slice(0, SKILL_SUMMARY_MAX_ITEMS).join(", ");
|
|
51363
|
+
const okExtra = okNames.length - SKILL_SUMMARY_MAX_ITEMS;
|
|
51364
|
+
const okMore = okExtra > 0 ? ` +${okExtra} more` : "";
|
|
51365
|
+
const okPart = okNames.length > 0 ? `ok: ${okShown}${okMore} \xB7 ` : "";
|
|
51366
|
+
return `applied ${okNames.length}/${results.length} \u2014 ${okPart}failed: ${failed}${failedMore}`;
|
|
51367
|
+
}
|
|
51368
|
+
function oneLine2(value) {
|
|
51369
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
51370
|
+
if (normalized.length <= DESCRIPTION_MAX2)
|
|
51371
|
+
return normalized;
|
|
51372
|
+
return `${normalized.slice(0, DESCRIPTION_MAX2 - 3)}...`;
|
|
51373
|
+
}
|
|
51374
|
+
async function readSkillDescription(path) {
|
|
51375
|
+
try {
|
|
51376
|
+
const text = await readFile3(path, "utf8");
|
|
51377
|
+
const front = parseFrontmatter(text);
|
|
51378
|
+
if (front === undefined)
|
|
51379
|
+
return "";
|
|
51380
|
+
return oneLine2((front.description ?? "").trim());
|
|
51381
|
+
} catch {
|
|
51382
|
+
return "";
|
|
51383
|
+
}
|
|
51384
|
+
}
|
|
51385
|
+
async function scanAvailableSkills(publicDir, curatedDir) {
|
|
51386
|
+
let entries;
|
|
51387
|
+
try {
|
|
51388
|
+
entries = await readdir(publicDir, { encoding: "utf8" });
|
|
51389
|
+
} catch {
|
|
51390
|
+
return [];
|
|
51391
|
+
}
|
|
51392
|
+
const skillNames = new Set;
|
|
51393
|
+
for (const name of entries) {
|
|
51394
|
+
if (name.endsWith(".md")) {
|
|
51395
|
+
skillNames.add(name.slice(0, -3));
|
|
51396
|
+
} else if (!name.startsWith(".")) {
|
|
51397
|
+
if (existsSync9(join9(publicDir, name, "SKILL.md")))
|
|
51398
|
+
skillNames.add(name);
|
|
51399
|
+
}
|
|
51400
|
+
}
|
|
51401
|
+
const rows = [];
|
|
51402
|
+
for (const name of skillNames) {
|
|
51403
|
+
const installed = existsSync9(join9(curatedDir, `${name}.md`)) || existsSync9(join9(curatedDir, name));
|
|
51404
|
+
const description = await readSkillDescription(existsSync9(join9(publicDir, name, "SKILL.md")) ? join9(publicDir, name, "SKILL.md") : join9(publicDir, `${name}.md`));
|
|
51405
|
+
rows.push({ name, description, installed });
|
|
51406
|
+
}
|
|
51407
|
+
rows.sort((a, b) => a.name.localeCompare(b.name));
|
|
51408
|
+
return rows;
|
|
51409
|
+
}
|
|
51410
|
+
function filterSkillRows(rows, query) {
|
|
51411
|
+
const needle = query.trim().toLowerCase();
|
|
51412
|
+
if (!needle)
|
|
51413
|
+
return [...rows];
|
|
51414
|
+
return rows.filter((row) => row.name.toLowerCase().includes(needle) || row.description.toLowerCase().includes(needle));
|
|
51415
|
+
}
|
|
51416
|
+
function skillStateText(row, pendingState) {
|
|
51417
|
+
const effective = pendingState ?? row.installed;
|
|
51418
|
+
const base = effective ? "installed" : "available";
|
|
51419
|
+
return pendingState === undefined || pendingState === row.installed ? base : `${base}*`;
|
|
51420
|
+
}
|
|
51421
|
+
async function ensureCuratedDir(curatedDir) {
|
|
51422
|
+
try {
|
|
51423
|
+
await mkdir2(curatedDir, { recursive: true });
|
|
51424
|
+
} catch {}
|
|
51425
|
+
}
|
|
51426
|
+
var SKILL_SUMMARY_MAX_ITEMS = 3, DESCRIPTION_MAX2 = 90;
|
|
51427
|
+
var init_skills_manage = __esm(() => {
|
|
51428
|
+
init_skills_source();
|
|
51429
|
+
});
|
|
51430
|
+
|
|
51431
|
+
// ../tui-base/src/routes/session/skills-panel.tsx
|
|
51432
|
+
import { TextAttributes as TextAttributes9 } from "@opentui/core";
|
|
51433
|
+
function openSkillsPanel() {
|
|
51434
|
+
setBridgeOpen(true);
|
|
51435
|
+
}
|
|
51436
|
+
function useSkillsPanelOpenState() {
|
|
51437
|
+
onCleanup(() => setPanelOpen2(false));
|
|
51438
|
+
return [skillsPanelOpen, setPanelOpen2];
|
|
51439
|
+
}
|
|
51440
|
+
function formatSkillLine(row, selected) {
|
|
51441
|
+
return `${selected ? "\u203A " : " "}${row.name.padEnd(30)}`;
|
|
51442
|
+
}
|
|
51443
|
+
function SkillsPanel(props) {
|
|
51444
|
+
const theme = useThemeOptional();
|
|
51445
|
+
const dialog = useDialog();
|
|
51446
|
+
const [open, setOpen] = useSkillsPanelOpenState();
|
|
51447
|
+
const [filterOpen, setFilterOpen] = createSignal(false);
|
|
51448
|
+
const [filter, setFilter] = createSignal("");
|
|
51449
|
+
const [cursor, setCursor] = createSignal(0);
|
|
51450
|
+
const [busy, setBusy] = createSignal(false);
|
|
51451
|
+
const [rows, setRows] = createSignal([]);
|
|
51452
|
+
const [status, setStatus] = createSignal(undefined);
|
|
51453
|
+
const [pending, setPending] = createSignal(new Map);
|
|
51454
|
+
let statusTimer;
|
|
51455
|
+
onCleanup(() => clearTimeout(statusTimer));
|
|
51456
|
+
createEffect(() => {
|
|
51457
|
+
if (bridgeOpen()) {
|
|
51458
|
+
setBridgeOpen(false);
|
|
51459
|
+
setFilter("");
|
|
51460
|
+
setFilterOpen(false);
|
|
51461
|
+
setCursor(0);
|
|
51462
|
+
setPending(new Map);
|
|
51463
|
+
setOpen(true);
|
|
51464
|
+
rescan();
|
|
51465
|
+
}
|
|
51466
|
+
});
|
|
51467
|
+
function flash(message, autoClearMs) {
|
|
51468
|
+
clearTimeout(statusTimer);
|
|
51469
|
+
setStatus(message);
|
|
51470
|
+
if (autoClearMs !== undefined) {
|
|
51471
|
+
statusTimer = setTimeout(() => setStatus(undefined), autoClearMs);
|
|
51472
|
+
}
|
|
51473
|
+
}
|
|
51474
|
+
async function rescan(notice) {
|
|
51475
|
+
if (notice === undefined)
|
|
51476
|
+
flash("scanning\u2026");
|
|
51477
|
+
const scanned = await scanAvailableSkills(props.source(), props.curated());
|
|
51478
|
+
setRows(scanned);
|
|
51479
|
+
if (notice !== undefined) {
|
|
51480
|
+
flash(notice, 1e4);
|
|
51481
|
+
} else {
|
|
51482
|
+
flash(undefined);
|
|
51483
|
+
}
|
|
51484
|
+
}
|
|
51485
|
+
function close() {
|
|
51486
|
+
if (filterOpen()) {
|
|
51487
|
+
setFilterOpen(false);
|
|
51488
|
+
setFilter("");
|
|
51489
|
+
return;
|
|
51490
|
+
}
|
|
51491
|
+
if (pending().size > 0) {
|
|
51492
|
+
const count = pending().size;
|
|
51493
|
+
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
51494
|
+
title: `Discard ${count} pending change${count === 1 ? "" : "s"}?`,
|
|
51495
|
+
message: "Pending install/uninstall marks are not applied yet.",
|
|
51496
|
+
label: {
|
|
51497
|
+
confirm: "Discard",
|
|
51498
|
+
cancel: "Keep editing"
|
|
51499
|
+
},
|
|
51500
|
+
onConfirm: () => {
|
|
51501
|
+
setPending(new Map);
|
|
51502
|
+
setOpen(false);
|
|
51503
|
+
setTimeout(() => props.onClosed?.(), 3);
|
|
51504
|
+
}
|
|
51505
|
+
}), undefined, {
|
|
51506
|
+
tone: "warning"
|
|
51507
|
+
});
|
|
51508
|
+
return;
|
|
51509
|
+
}
|
|
51510
|
+
setOpen(false);
|
|
51511
|
+
setTimeout(() => props.onClosed?.(), 3);
|
|
51512
|
+
}
|
|
51513
|
+
const visible = createMemo(() => filterSkillRows(rows(), filter()));
|
|
51514
|
+
const current = createMemo(() => {
|
|
51515
|
+
const list = visible();
|
|
51516
|
+
return list[Math.min(cursor(), list.length - 1)];
|
|
51517
|
+
});
|
|
51518
|
+
const cursorIndex = createMemo(() => visible().slice(0, 12).indexOf(current()));
|
|
51519
|
+
function moveCursor(delta) {
|
|
51520
|
+
const count = visible().length;
|
|
51521
|
+
if (count === 0)
|
|
51522
|
+
return;
|
|
51523
|
+
setCursor(Math.max(0, Math.min(cursor() + delta, count - 1)));
|
|
51524
|
+
}
|
|
51525
|
+
function togglePending(row) {
|
|
51526
|
+
if (row === undefined || busy())
|
|
51527
|
+
return;
|
|
51528
|
+
const effective = pending().get(row.name) ?? row.installed;
|
|
51529
|
+
const next = new Map(pending());
|
|
51530
|
+
next.set(row.name, !effective);
|
|
51531
|
+
setPending(next);
|
|
51532
|
+
}
|
|
51533
|
+
async function applyPending() {
|
|
51534
|
+
if (busy() || pending().size === 0)
|
|
51535
|
+
return;
|
|
51536
|
+
setBusy(true);
|
|
51537
|
+
const source = props.source();
|
|
51538
|
+
const curated = props.curated();
|
|
51539
|
+
await ensureCuratedDir(curated);
|
|
51540
|
+
const results = [];
|
|
51541
|
+
for (const [name, targetState] of pending()) {
|
|
51542
|
+
const error = await applyOneSkillChange(name, targetState, source, curated);
|
|
51543
|
+
results.push({
|
|
51544
|
+
name,
|
|
51545
|
+
error
|
|
51546
|
+
});
|
|
51547
|
+
}
|
|
51548
|
+
setPending(new Map);
|
|
51549
|
+
setBusy(false);
|
|
51550
|
+
const summary = skillApplySummary(results);
|
|
51551
|
+
rescan(summary === "" ? undefined : summary);
|
|
51552
|
+
}
|
|
51553
|
+
function onReturn() {
|
|
51554
|
+
if (filterOpen()) {
|
|
51555
|
+
setFilterOpen(false);
|
|
51556
|
+
setFilter("");
|
|
51557
|
+
return;
|
|
51558
|
+
}
|
|
51559
|
+
if (pending().size > 0) {
|
|
51560
|
+
applyPending();
|
|
51561
|
+
return;
|
|
51562
|
+
}
|
|
51563
|
+
togglePending(current());
|
|
51564
|
+
}
|
|
51565
|
+
Keymap2.createLayer(() => ({
|
|
51566
|
+
mode: "global",
|
|
51567
|
+
enabled: open() && dialog.stack.length === 0,
|
|
51568
|
+
priority: 2,
|
|
51569
|
+
commands: [{
|
|
51570
|
+
bind: "escape",
|
|
51571
|
+
title: "Close skills manager",
|
|
51572
|
+
group: "Skills",
|
|
51573
|
+
run: close
|
|
51574
|
+
}, {
|
|
51575
|
+
bind: "/",
|
|
51576
|
+
title: "Filter skills",
|
|
51577
|
+
group: "Skills",
|
|
51578
|
+
enabled: () => !filterOpen(),
|
|
51579
|
+
run: () => {
|
|
51580
|
+
setFilterOpen(true);
|
|
51581
|
+
return true;
|
|
51582
|
+
}
|
|
51583
|
+
}, {
|
|
51584
|
+
bind: "space",
|
|
51585
|
+
title: "Mark install/uninstall",
|
|
51586
|
+
group: "Skills",
|
|
51587
|
+
enabled: () => !filterOpen(),
|
|
51588
|
+
run: () => {
|
|
51589
|
+
togglePending(current());
|
|
51590
|
+
return true;
|
|
51591
|
+
}
|
|
51592
|
+
}, {
|
|
51593
|
+
bind: "return",
|
|
51594
|
+
title: "Commit input / apply batch",
|
|
51595
|
+
group: "Skills",
|
|
51596
|
+
run: () => {
|
|
51597
|
+
onReturn();
|
|
51598
|
+
return true;
|
|
51599
|
+
}
|
|
51600
|
+
}, {
|
|
51601
|
+
bind: "up,k",
|
|
51602
|
+
title: "Previous skill",
|
|
51603
|
+
group: "Skills",
|
|
51604
|
+
enabled: () => !filterOpen(),
|
|
51605
|
+
run: () => moveCursor(-1)
|
|
51606
|
+
}, {
|
|
51607
|
+
bind: "down,j",
|
|
51608
|
+
title: "Next skill",
|
|
51609
|
+
group: "Skills",
|
|
51610
|
+
enabled: () => !filterOpen(),
|
|
51611
|
+
run: () => moveCursor(1)
|
|
51612
|
+
}]
|
|
51613
|
+
}));
|
|
51614
|
+
const selected = createMemo(() => current());
|
|
51615
|
+
return createComponent2(Show, {
|
|
51616
|
+
get when() {
|
|
51617
|
+
return open();
|
|
51618
|
+
},
|
|
51619
|
+
get children() {
|
|
51620
|
+
var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$5 = createElement("text");
|
|
51621
|
+
insertNode(_el$, _el$2);
|
|
51622
|
+
setProp(_el$, "flexShrink", 0);
|
|
51623
|
+
setProp(_el$, "width", "100%");
|
|
51624
|
+
setProp(_el$, "flexDirection", "column");
|
|
51625
|
+
setProp(_el$, "border", ["left"]);
|
|
51626
|
+
setProp(_el$, "paddingLeft", 1);
|
|
51627
|
+
setProp(_el$, "paddingRight", 1);
|
|
51628
|
+
insertNode(_el$2, _el$3);
|
|
51629
|
+
insertNode(_el$2, _el$5);
|
|
51630
|
+
setProp(_el$2, "height", 1);
|
|
51631
|
+
setProp(_el$2, "flexShrink", 0);
|
|
51632
|
+
setProp(_el$2, "flexDirection", "row");
|
|
51633
|
+
insertNode(_el$3, createTextNode(`\uD83D\uDEE0 Skills`));
|
|
51634
|
+
setProp(_el$3, "wrapMode", "none");
|
|
51635
|
+
setProp(_el$5, "wrapMode", "none");
|
|
51636
|
+
insert(_el$5, () => ` ${visible().length}/${rows().length} / filter space mark enter apply esc close`);
|
|
51637
|
+
insert(_el$, createComponent2(Show, {
|
|
51638
|
+
get when() {
|
|
51639
|
+
return !filterOpen();
|
|
51640
|
+
},
|
|
51641
|
+
get fallback() {
|
|
51642
|
+
return (() => {
|
|
51643
|
+
var _el$11 = createElement("box"), _el$12 = createElement("input");
|
|
51644
|
+
insertNode(_el$11, _el$12);
|
|
51645
|
+
setProp(_el$11, "height", 1);
|
|
51646
|
+
setProp(_el$11, "flexShrink", 0);
|
|
51647
|
+
setProp(_el$11, "flexDirection", "row");
|
|
51648
|
+
use((renderable) => {
|
|
51649
|
+
setTimeout(() => {
|
|
51650
|
+
if (!renderable.isDestroyed)
|
|
51651
|
+
renderable.focus();
|
|
51652
|
+
}, 1);
|
|
51653
|
+
}, _el$12);
|
|
51654
|
+
setProp(_el$12, "flexGrow", 1);
|
|
51655
|
+
setProp(_el$12, "placeholder", "filter");
|
|
51656
|
+
setProp(_el$12, "onInput", (value) => setFilter(value));
|
|
51657
|
+
effect((_p$) => {
|
|
51658
|
+
var _v$7 = theme?.text.muted ?? "#565f89", _v$8 = filter();
|
|
51659
|
+
_v$7 !== _p$.e && (_p$.e = setProp(_el$12, "placeholderColor", _v$7, _p$.e));
|
|
51660
|
+
_v$8 !== _p$.t && (_p$.t = setProp(_el$12, "value", _v$8, _p$.t));
|
|
51661
|
+
return _p$;
|
|
51662
|
+
}, {
|
|
51663
|
+
e: undefined,
|
|
51664
|
+
t: undefined
|
|
51665
|
+
});
|
|
51666
|
+
return _el$11;
|
|
51667
|
+
})();
|
|
51668
|
+
},
|
|
51669
|
+
get children() {
|
|
51670
|
+
var _el$6 = createElement("box"), _el$7 = createElement("text");
|
|
51671
|
+
insertNode(_el$6, _el$7);
|
|
51672
|
+
setProp(_el$6, "height", 1);
|
|
51673
|
+
setProp(_el$6, "flexShrink", 0);
|
|
51674
|
+
insertNode(_el$7, createTextNode(`SKILL STATE`));
|
|
51675
|
+
setProp(_el$7, "wrapMode", "none");
|
|
51676
|
+
effect((_$p) => setProp(_el$7, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
51677
|
+
return _el$6;
|
|
51678
|
+
}
|
|
51679
|
+
}), null);
|
|
51680
|
+
insert(_el$, createComponent2(Show, {
|
|
51681
|
+
get when() {
|
|
51682
|
+
return visible().length > 0;
|
|
51683
|
+
},
|
|
51684
|
+
get fallback() {
|
|
51685
|
+
return (() => {
|
|
51686
|
+
var _el$13 = createElement("box"), _el$14 = createElement("text");
|
|
51687
|
+
insertNode(_el$13, _el$14);
|
|
51688
|
+
setProp(_el$13, "height", 1);
|
|
51689
|
+
setProp(_el$13, "flexShrink", 0);
|
|
51690
|
+
setProp(_el$14, "wrapMode", "none");
|
|
51691
|
+
insert(_el$14, (() => {
|
|
51692
|
+
var _c$ = memo2(() => rows().length === 0);
|
|
51693
|
+
return () => _c$() ? `no skills in ${props.source()}` : "no skills match the filter";
|
|
51694
|
+
})());
|
|
51695
|
+
effect((_$p) => setProp(_el$14, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
51696
|
+
return _el$13;
|
|
51697
|
+
})();
|
|
51698
|
+
},
|
|
51699
|
+
get children() {
|
|
51700
|
+
return createComponent2(For, {
|
|
51701
|
+
get each() {
|
|
51702
|
+
return visible().slice(0, 12);
|
|
51703
|
+
},
|
|
51704
|
+
children: (row, index) => {
|
|
51705
|
+
const effective = createMemo(() => pending().get(row.name));
|
|
51706
|
+
return (() => {
|
|
51707
|
+
var _el$15 = createElement("box"), _el$16 = createElement("text"), _el$17 = createElement("text");
|
|
51708
|
+
insertNode(_el$15, _el$16);
|
|
51709
|
+
insertNode(_el$15, _el$17);
|
|
51710
|
+
setProp(_el$15, "height", 1);
|
|
51711
|
+
setProp(_el$15, "flexShrink", 0);
|
|
51712
|
+
setProp(_el$15, "flexDirection", "row");
|
|
51713
|
+
setProp(_el$16, "wrapMode", "none");
|
|
51714
|
+
insert(_el$16, () => formatSkillLine(row, index() === cursorIndex()));
|
|
51715
|
+
setProp(_el$17, "wrapMode", "none");
|
|
51716
|
+
insert(_el$17, () => skillStateText(row, effective()));
|
|
51717
|
+
effect((_p$) => {
|
|
51718
|
+
var _v$9 = index() === cursorIndex() ? theme?.text.base ?? "#e6e6e6" : theme?.text.muted ?? "#565f89", _v$0 = effective() ?? row.installed ? successColor(theme ?? undefined) : theme?.text.muted ?? "#565f89";
|
|
51719
|
+
_v$9 !== _p$.e && (_p$.e = setProp(_el$16, "fg", _v$9, _p$.e));
|
|
51720
|
+
_v$0 !== _p$.t && (_p$.t = setProp(_el$17, "fg", _v$0, _p$.t));
|
|
51721
|
+
return _p$;
|
|
51722
|
+
}, {
|
|
51723
|
+
e: undefined,
|
|
51724
|
+
t: undefined
|
|
51725
|
+
});
|
|
51726
|
+
return _el$15;
|
|
51727
|
+
})();
|
|
51728
|
+
}
|
|
51729
|
+
});
|
|
51730
|
+
}
|
|
51731
|
+
}), null);
|
|
51732
|
+
insert(_el$, createComponent2(Show, {
|
|
51733
|
+
get when() {
|
|
51734
|
+
return memo2(() => selected() !== undefined)() && selected().description !== "";
|
|
51735
|
+
},
|
|
51736
|
+
get children() {
|
|
51737
|
+
var _el$9 = createElement("box"), _el$0 = createElement("text");
|
|
51738
|
+
insertNode(_el$9, _el$0);
|
|
51739
|
+
setProp(_el$9, "height", 1);
|
|
51740
|
+
setProp(_el$9, "flexShrink", 0);
|
|
51741
|
+
setProp(_el$0, "wrapMode", "none");
|
|
51742
|
+
insert(_el$0, () => ` ${selected().description}`);
|
|
51743
|
+
effect((_$p) => setProp(_el$0, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
51744
|
+
return _el$9;
|
|
51745
|
+
}
|
|
51746
|
+
}), null);
|
|
51747
|
+
insert(_el$, createComponent2(Show, {
|
|
51748
|
+
get when() {
|
|
51749
|
+
return status() !== undefined;
|
|
51750
|
+
},
|
|
51751
|
+
get children() {
|
|
51752
|
+
var _el$1 = createElement("box"), _el$10 = createElement("text");
|
|
51753
|
+
insertNode(_el$1, _el$10);
|
|
51754
|
+
setProp(_el$1, "height", 1);
|
|
51755
|
+
setProp(_el$1, "flexShrink", 0);
|
|
51756
|
+
setProp(_el$10, "wrapMode", "none");
|
|
51757
|
+
insert(_el$10, status);
|
|
51758
|
+
effect((_$p) => setProp(_el$10, "fg", warningColor(theme ?? undefined), _$p));
|
|
51759
|
+
return _el$1;
|
|
51760
|
+
}
|
|
51761
|
+
}), null);
|
|
51762
|
+
effect((_p$) => {
|
|
51763
|
+
var _v$ = 1 + 1 + Math.min(visible().length || 1, 12) + (selected() !== undefined && selected().description !== "" ? 1 : 0) + (status() !== undefined ? 1 : 0) + 1, _v$2 = theme?.border.base ?? "#7aa2f7", _v$3 = theme?.background.raised.base ?? "#1a1b26", _v$4 = theme?.text.base ?? "#e6e6e6", _v$5 = TextAttributes9.BOLD, _v$6 = theme?.text.muted ?? "#565f89";
|
|
51764
|
+
_v$ !== _p$.e && (_p$.e = setProp(_el$, "height", _v$, _p$.e));
|
|
51765
|
+
_v$2 !== _p$.t && (_p$.t = setProp(_el$, "borderColor", _v$2, _p$.t));
|
|
51766
|
+
_v$3 !== _p$.a && (_p$.a = setProp(_el$, "backgroundColor", _v$3, _p$.a));
|
|
51767
|
+
_v$4 !== _p$.o && (_p$.o = setProp(_el$3, "fg", _v$4, _p$.o));
|
|
51768
|
+
_v$5 !== _p$.i && (_p$.i = setProp(_el$3, "attributes", _v$5, _p$.i));
|
|
51769
|
+
_v$6 !== _p$.n && (_p$.n = setProp(_el$5, "fg", _v$6, _p$.n));
|
|
51770
|
+
return _p$;
|
|
51771
|
+
}, {
|
|
51772
|
+
e: undefined,
|
|
51773
|
+
t: undefined,
|
|
51774
|
+
a: undefined,
|
|
51775
|
+
o: undefined,
|
|
51776
|
+
i: undefined,
|
|
51777
|
+
n: undefined
|
|
51778
|
+
});
|
|
51779
|
+
return _el$;
|
|
51780
|
+
}
|
|
51781
|
+
});
|
|
51782
|
+
}
|
|
51783
|
+
var bridgeOpen, setBridgeOpen, panelOpen2, setPanelOpen2, skillsPanelOpen;
|
|
51784
|
+
var init_skills_panel = __esm(() => {
|
|
51785
|
+
init_index_bun();
|
|
51786
|
+
init_index_bun();
|
|
51787
|
+
init_index_bun();
|
|
51788
|
+
init_index_bun();
|
|
51789
|
+
init_index_bun();
|
|
51790
|
+
init_index_bun();
|
|
51791
|
+
init_index_bun();
|
|
51792
|
+
init_index_bun();
|
|
51793
|
+
init_index_bun();
|
|
51794
|
+
init_server();
|
|
51795
|
+
init_keymap();
|
|
51796
|
+
init_dialog();
|
|
51797
|
+
init_dialog_confirm();
|
|
51798
|
+
init_theme3();
|
|
51799
|
+
init_semantic();
|
|
51800
|
+
init_skills_manage();
|
|
51801
|
+
[bridgeOpen, setBridgeOpen] = createSignal(false);
|
|
51802
|
+
[panelOpen2, setPanelOpen2] = createSignal(false);
|
|
51803
|
+
skillsPanelOpen = panelOpen2;
|
|
51804
|
+
});
|
|
51805
|
+
|
|
50597
51806
|
// ../tui-base/src/routes/session/sessions-search.tsx
|
|
50598
51807
|
function openSessionsSearch() {
|
|
50599
|
-
|
|
51808
|
+
setBridgeOpen2(true);
|
|
50600
51809
|
}
|
|
50601
51810
|
function useSessionsSearchOpenState() {
|
|
50602
|
-
onCleanup(() =>
|
|
50603
|
-
return [sessionsSearchOpen,
|
|
51811
|
+
onCleanup(() => setPanelOpen3(false));
|
|
51812
|
+
return [sessionsSearchOpen, setPanelOpen3];
|
|
50604
51813
|
}
|
|
50605
51814
|
function formatSearchHitLine(hit) {
|
|
50606
51815
|
const snippet = hit.snippet.replace(/\s+/g, " ").trim();
|
|
50607
51816
|
return snippet ? `${hit.id} \u2014 ${snippet}` : hit.id;
|
|
50608
51817
|
}
|
|
51818
|
+
function hitCursorStep(current, delta, count) {
|
|
51819
|
+
if (count <= 0)
|
|
51820
|
+
return current;
|
|
51821
|
+
return (current + delta + count) % count;
|
|
51822
|
+
}
|
|
51823
|
+
function enterAction(hitCount) {
|
|
51824
|
+
return hitCount > 0 ? "resume" : "search";
|
|
51825
|
+
}
|
|
51826
|
+
function resumeFailureText(error) {
|
|
51827
|
+
return `resume failed \u2014 ${String(error instanceof Error ? error.message : error).slice(0, 150)}`;
|
|
51828
|
+
}
|
|
51829
|
+
async function resumeSearchHit(options) {
|
|
51830
|
+
try {
|
|
51831
|
+
await options.onResumed(options.sessionId);
|
|
51832
|
+
options.onSuccess();
|
|
51833
|
+
} catch (error) {
|
|
51834
|
+
options.onFailure(resumeFailureText(error));
|
|
51835
|
+
}
|
|
51836
|
+
}
|
|
50609
51837
|
function SessionsSearch(props) {
|
|
50610
51838
|
const theme = useThemeOptional();
|
|
50611
51839
|
const dialog = useDialog();
|
|
@@ -50614,12 +51842,15 @@ function SessionsSearch(props) {
|
|
|
50614
51842
|
const [hits, setHits] = createSignal([]);
|
|
50615
51843
|
const [searched, setSearched] = createSignal(false);
|
|
50616
51844
|
const [busy, setBusy] = createSignal(false);
|
|
51845
|
+
const [cursor, setCursor] = createSignal(0);
|
|
51846
|
+
const [resumeError, setResumeError] = createSignal("");
|
|
50617
51847
|
createEffect(() => {
|
|
50618
|
-
if (
|
|
50619
|
-
|
|
51848
|
+
if (bridgeOpen2()) {
|
|
51849
|
+
setBridgeOpen2(false);
|
|
50620
51850
|
setQuery("");
|
|
50621
51851
|
setHits([]);
|
|
50622
51852
|
setSearched(false);
|
|
51853
|
+
setResumeError("");
|
|
50623
51854
|
setOpen(true);
|
|
50624
51855
|
}
|
|
50625
51856
|
});
|
|
@@ -50628,16 +51859,49 @@ function SessionsSearch(props) {
|
|
|
50628
51859
|
if (!needle || busy())
|
|
50629
51860
|
return;
|
|
50630
51861
|
setBusy(true);
|
|
51862
|
+
setResumeError("");
|
|
50631
51863
|
try {
|
|
50632
51864
|
const found = await props.seam.searchSessions(needle);
|
|
50633
51865
|
setHits(found.slice(0, ROW_CAP));
|
|
51866
|
+
setCursor(0);
|
|
50634
51867
|
} catch {
|
|
50635
51868
|
setHits([]);
|
|
51869
|
+
setCursor(0);
|
|
50636
51870
|
} finally {
|
|
50637
51871
|
setSearched(true);
|
|
50638
51872
|
setBusy(false);
|
|
50639
51873
|
}
|
|
50640
51874
|
}
|
|
51875
|
+
function moveCursor(delta) {
|
|
51876
|
+
const count = hits().length;
|
|
51877
|
+
if (count === 0)
|
|
51878
|
+
return;
|
|
51879
|
+
setCursor((current) => hitCursorStep(current, delta, count));
|
|
51880
|
+
}
|
|
51881
|
+
function enterKey() {
|
|
51882
|
+
if (busy())
|
|
51883
|
+
return;
|
|
51884
|
+
if (enterAction(hits().length) === "resume") {
|
|
51885
|
+
const hit = hits()[cursor()];
|
|
51886
|
+
if (!hit)
|
|
51887
|
+
return;
|
|
51888
|
+
setBusy(true);
|
|
51889
|
+
resumeSearchHit({
|
|
51890
|
+
sessionId: hit.id,
|
|
51891
|
+
onResumed: (sessionId) => props.onResumed?.(sessionId),
|
|
51892
|
+
onSuccess: () => {
|
|
51893
|
+
setBusy(false);
|
|
51894
|
+
close();
|
|
51895
|
+
},
|
|
51896
|
+
onFailure: (statusLine) => {
|
|
51897
|
+
setBusy(false);
|
|
51898
|
+
setResumeError(statusLine);
|
|
51899
|
+
}
|
|
51900
|
+
});
|
|
51901
|
+
return;
|
|
51902
|
+
}
|
|
51903
|
+
run();
|
|
51904
|
+
}
|
|
50641
51905
|
function close() {
|
|
50642
51906
|
setOpen(false);
|
|
50643
51907
|
setTimeout(() => props.onClosed?.(), 3);
|
|
@@ -50646,17 +51910,34 @@ function SessionsSearch(props) {
|
|
|
50646
51910
|
mode: "global",
|
|
50647
51911
|
enabled: open() && dialog.stack.length === 0,
|
|
50648
51912
|
priority: 2,
|
|
50649
|
-
commands: [
|
|
50650
|
-
|
|
50651
|
-
|
|
50652
|
-
|
|
50653
|
-
|
|
50654
|
-
|
|
50655
|
-
|
|
50656
|
-
|
|
50657
|
-
|
|
50658
|
-
|
|
50659
|
-
|
|
51913
|
+
commands: [
|
|
51914
|
+
{
|
|
51915
|
+
bind: "escape",
|
|
51916
|
+
title: "Close session search",
|
|
51917
|
+
group: "Search",
|
|
51918
|
+
run: close
|
|
51919
|
+
},
|
|
51920
|
+
{
|
|
51921
|
+
bind: "return",
|
|
51922
|
+
title: "Search stored sessions / resume selected hit",
|
|
51923
|
+
group: "Search",
|
|
51924
|
+
run: () => enterKey()
|
|
51925
|
+
},
|
|
51926
|
+
{
|
|
51927
|
+
bind: "down",
|
|
51928
|
+
title: "Next hit",
|
|
51929
|
+
group: "Search",
|
|
51930
|
+
enabled: () => hits().length > 0,
|
|
51931
|
+
run: () => moveCursor(1)
|
|
51932
|
+
},
|
|
51933
|
+
{
|
|
51934
|
+
bind: "up",
|
|
51935
|
+
title: "Previous hit",
|
|
51936
|
+
group: "Search",
|
|
51937
|
+
enabled: () => hits().length > 0,
|
|
51938
|
+
run: () => moveCursor(-1)
|
|
51939
|
+
}
|
|
51940
|
+
]
|
|
50660
51941
|
}));
|
|
50661
51942
|
Keymap2.createLayer(() => ({
|
|
50662
51943
|
mode: "global",
|
|
@@ -50665,10 +51946,12 @@ function SessionsSearch(props) {
|
|
|
50665
51946
|
id: "session.searchSessions",
|
|
50666
51947
|
title: "Search stored sessions",
|
|
50667
51948
|
group: "Session",
|
|
50668
|
-
run: () =>
|
|
51949
|
+
run: () => setBridgeOpen2(true)
|
|
50669
51950
|
}]
|
|
50670
51951
|
}));
|
|
50671
51952
|
const status = createMemo(() => {
|
|
51953
|
+
if (resumeError())
|
|
51954
|
+
return resumeError();
|
|
50672
51955
|
if (busy())
|
|
50673
51956
|
return "searching\u2026";
|
|
50674
51957
|
if (!searched())
|
|
@@ -50704,7 +51987,7 @@ function SessionsSearch(props) {
|
|
|
50704
51987
|
var _el$5 = createElement("text");
|
|
50705
51988
|
setProp(_el$5, "wrapMode", "none");
|
|
50706
51989
|
insert(_el$5, () => ` ${status()}`);
|
|
50707
|
-
effect((_$p) => setProp(_el$5, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
51990
|
+
effect((_$p) => setProp(_el$5, "fg", resumeError() ? theme?.text.feedback.error.base ?? "#f7768e" : theme?.text.muted ?? "#565f89", _$p));
|
|
50708
51991
|
return _el$5;
|
|
50709
51992
|
}
|
|
50710
51993
|
}), null);
|
|
@@ -50721,7 +52004,7 @@ function SessionsSearch(props) {
|
|
|
50721
52004
|
setProp(_el$7, "flexGrow", 1);
|
|
50722
52005
|
setProp(_el$7, "placeholder", "Full-text over stored sessions");
|
|
50723
52006
|
setProp(_el$7, "onInput", (value) => setQuery(value));
|
|
50724
|
-
setProp(_el$7, "onSubmit", () =>
|
|
52007
|
+
setProp(_el$7, "onSubmit", () => enterKey());
|
|
50725
52008
|
insert(_el$, createComponent2(Show, {
|
|
50726
52009
|
get when() {
|
|
50727
52010
|
return hits().length > 0;
|
|
@@ -50743,14 +52026,17 @@ function SessionsSearch(props) {
|
|
|
50743
52026
|
get each() {
|
|
50744
52027
|
return hits();
|
|
50745
52028
|
},
|
|
50746
|
-
children: (hit) => (() => {
|
|
52029
|
+
children: (hit, index) => (() => {
|
|
50747
52030
|
var _el$0 = createElement("box"), _el$1 = createElement("text");
|
|
50748
52031
|
insertNode(_el$0, _el$1);
|
|
50749
52032
|
setProp(_el$0, "height", 1);
|
|
50750
52033
|
setProp(_el$0, "flexShrink", 0);
|
|
50751
52034
|
setProp(_el$1, "wrapMode", "none");
|
|
50752
|
-
insert(_el$1, () =>
|
|
50753
|
-
|
|
52035
|
+
insert(_el$1, (() => {
|
|
52036
|
+
var _c$ = memo2(() => index() === cursor());
|
|
52037
|
+
return () => _c$() ? `\u203A ${formatSearchHitLine(hit)}` : ` ${formatSearchHitLine(hit)}`;
|
|
52038
|
+
})());
|
|
52039
|
+
effect((_$p) => setProp(_el$1, "fg", index() === cursor() ? theme?.text.base ?? "#e6e6e6" : theme?.text.muted ?? "#565f89", _$p));
|
|
50754
52040
|
return _el$0;
|
|
50755
52041
|
})()
|
|
50756
52042
|
});
|
|
@@ -50777,7 +52063,7 @@ function SessionsSearch(props) {
|
|
|
50777
52063
|
}
|
|
50778
52064
|
});
|
|
50779
52065
|
}
|
|
50780
|
-
var
|
|
52066
|
+
var bridgeOpen2, setBridgeOpen2, panelOpen3, setPanelOpen3, sessionsSearchOpen, ROW_CAP = 8;
|
|
50781
52067
|
var init_sessions_search = __esm(() => {
|
|
50782
52068
|
init_index_bun();
|
|
50783
52069
|
init_index_bun();
|
|
@@ -50793,44 +52079,124 @@ var init_sessions_search = __esm(() => {
|
|
|
50793
52079
|
init_keymap();
|
|
50794
52080
|
init_dialog();
|
|
50795
52081
|
init_theme3();
|
|
50796
|
-
[
|
|
50797
|
-
[
|
|
50798
|
-
sessionsSearchOpen =
|
|
52082
|
+
[bridgeOpen2, setBridgeOpen2] = createSignal(false);
|
|
52083
|
+
[panelOpen3, setPanelOpen3] = createSignal(false);
|
|
52084
|
+
sessionsSearchOpen = panelOpen3;
|
|
50799
52085
|
});
|
|
50800
52086
|
|
|
50801
52087
|
// ../tui-base/src/routes/session/plugins-panel.tsx
|
|
50802
|
-
import { TextAttributes as
|
|
52088
|
+
import { TextAttributes as TextAttributes10 } from "@opentui/core";
|
|
50803
52089
|
function openPluginsPanel() {
|
|
50804
|
-
|
|
52090
|
+
setBridgeOpen3(true);
|
|
50805
52091
|
}
|
|
50806
52092
|
function usePluginsPanelOpenState() {
|
|
50807
|
-
onCleanup(() =>
|
|
50808
|
-
return [pluginsPanelOpen,
|
|
52093
|
+
onCleanup(() => setPanelOpen4(false));
|
|
52094
|
+
return [pluginsPanelOpen, setPanelOpen4];
|
|
50809
52095
|
}
|
|
50810
52096
|
function formatPluginLine(row) {
|
|
50811
52097
|
return `${row.name}@${row.version}`;
|
|
50812
52098
|
}
|
|
52099
|
+
function errorMessage2(error) {
|
|
52100
|
+
return String(error instanceof Error ? error.message : error).slice(0, 90);
|
|
52101
|
+
}
|
|
50813
52102
|
function filterPluginRows(rows, query) {
|
|
50814
52103
|
const needle = query.trim().toLowerCase();
|
|
50815
52104
|
if (!needle)
|
|
50816
52105
|
return [...rows];
|
|
50817
52106
|
return rows.filter((row) => formatPluginLine(row).toLowerCase().includes(needle));
|
|
50818
52107
|
}
|
|
52108
|
+
function bundleStateText(row) {
|
|
52109
|
+
const base = !row.installed && row.optional ? "available" : row.enabled ? "on" : "off";
|
|
52110
|
+
if (row.error !== undefined && row.error !== "")
|
|
52111
|
+
return `${base} error`;
|
|
52112
|
+
if (row.readOnlyReason !== undefined && row.readOnlyReason !== "")
|
|
52113
|
+
return `${base} read-only`;
|
|
52114
|
+
return base;
|
|
52115
|
+
}
|
|
52116
|
+
function pluginBundleViews(bundles) {
|
|
52117
|
+
return [...bundles].sort((a, b) => a.name.localeCompare(b.name)).map((bundle) => ({
|
|
52118
|
+
name: bundle.name,
|
|
52119
|
+
version: bundle.version ?? "",
|
|
52120
|
+
label: bundle.version !== undefined && bundle.version !== "" ? `${bundle.name}@${bundle.version}` : bundle.name,
|
|
52121
|
+
enabled: bundle.enabled === true,
|
|
52122
|
+
installed: bundle.installed === true,
|
|
52123
|
+
optional: bundle.optional === true,
|
|
52124
|
+
removable: bundle.removable === true,
|
|
52125
|
+
toggleable: bundle.readOnlyReason === undefined && (bundle.error === undefined || bundle.error === ""),
|
|
52126
|
+
readOnlyReason: bundle.readOnlyReason,
|
|
52127
|
+
error: bundle.error
|
|
52128
|
+
}));
|
|
52129
|
+
}
|
|
52130
|
+
function legacyPluginViews(rows) {
|
|
52131
|
+
return pluginBundleViews([...rows].map((row) => ({
|
|
52132
|
+
name: row.name,
|
|
52133
|
+
version: row.version,
|
|
52134
|
+
enabled: true,
|
|
52135
|
+
installed: true,
|
|
52136
|
+
optional: false,
|
|
52137
|
+
removable: false
|
|
52138
|
+
}))).map((view) => ({
|
|
52139
|
+
...view,
|
|
52140
|
+
toggleable: false
|
|
52141
|
+
}));
|
|
52142
|
+
}
|
|
52143
|
+
function pluginChangeNotice(change) {
|
|
52144
|
+
const target = change.target;
|
|
52145
|
+
switch (change.application) {
|
|
52146
|
+
case "applied":
|
|
52147
|
+
return `${target}: change applied`;
|
|
52148
|
+
case "restart-required":
|
|
52149
|
+
return `${target}: change saved \u2014 restart the host for it to take effect`;
|
|
52150
|
+
case "overridden":
|
|
52151
|
+
return `${target}: change saved, but a higher-priority config keeps the previous state`;
|
|
52152
|
+
case "failed":
|
|
52153
|
+
return `${target}: change failed${change.error ? ` \u2014 ${change.error}` : ""}`;
|
|
52154
|
+
case "cancelled":
|
|
52155
|
+
return `${target}: change cancelled`;
|
|
52156
|
+
}
|
|
52157
|
+
}
|
|
52158
|
+
function installPreviewLine(inspection) {
|
|
52159
|
+
const version = inspection.version !== undefined && inspection.version !== "" ? `@${inspection.version}` : "";
|
|
52160
|
+
const notBundle = inspection.bundle === false ? " (not a bundle package \u2014 installs as a plain dependency)" : "";
|
|
52161
|
+
return `${inspection.name ?? "spec"}${version}${notBundle}`;
|
|
52162
|
+
}
|
|
50819
52163
|
function PluginsPanel(props) {
|
|
50820
52164
|
const theme = useThemeOptional();
|
|
50821
52165
|
const dialog = useDialog();
|
|
50822
52166
|
const [open, setOpen] = usePluginsPanelOpenState();
|
|
50823
52167
|
const [filterOpen, setFilterOpen] = createSignal(false);
|
|
50824
52168
|
const [filter, setFilter] = createSignal("");
|
|
52169
|
+
const [cursor, setCursor] = createSignal(0);
|
|
52170
|
+
const [busy, setBusy] = createSignal(false);
|
|
52171
|
+
const [status, setStatus] = createSignal(undefined);
|
|
52172
|
+
const [installOpen, setInstallOpen] = createSignal(false);
|
|
52173
|
+
const [installText, setInstallText] = createSignal("");
|
|
52174
|
+
let statusTimer;
|
|
52175
|
+
onCleanup(() => clearTimeout(statusTimer));
|
|
50825
52176
|
createEffect(() => {
|
|
50826
|
-
if (
|
|
50827
|
-
|
|
52177
|
+
if (bridgeOpen3()) {
|
|
52178
|
+
setBridgeOpen3(false);
|
|
50828
52179
|
setFilter("");
|
|
50829
52180
|
setFilterOpen(false);
|
|
52181
|
+
setInstallOpen(false);
|
|
52182
|
+
setInstallText("");
|
|
52183
|
+
setCursor(0);
|
|
50830
52184
|
setOpen(true);
|
|
50831
52185
|
}
|
|
50832
52186
|
});
|
|
52187
|
+
function flash(message, autoClearMs) {
|
|
52188
|
+
clearTimeout(statusTimer);
|
|
52189
|
+
setStatus(message);
|
|
52190
|
+
if (autoClearMs !== undefined) {
|
|
52191
|
+
statusTimer = setTimeout(() => setStatus(undefined), autoClearMs);
|
|
52192
|
+
}
|
|
52193
|
+
}
|
|
50833
52194
|
function close() {
|
|
52195
|
+
if (installOpen()) {
|
|
52196
|
+
setInstallOpen(false);
|
|
52197
|
+
setInstallText("");
|
|
52198
|
+
return;
|
|
52199
|
+
}
|
|
50834
52200
|
if (filterOpen()) {
|
|
50835
52201
|
setFilterOpen(false);
|
|
50836
52202
|
setFilter("");
|
|
@@ -50839,15 +52205,156 @@ function PluginsPanel(props) {
|
|
|
50839
52205
|
setOpen(false);
|
|
50840
52206
|
setTimeout(() => props.onClosed?.(), 3);
|
|
50841
52207
|
}
|
|
50842
|
-
const
|
|
52208
|
+
const bundles = createMemo(() => {
|
|
50843
52209
|
open();
|
|
50844
52210
|
try {
|
|
50845
|
-
|
|
52211
|
+
const seam = props.seam;
|
|
52212
|
+
if (typeof seam.pluginBundles === "function")
|
|
52213
|
+
return pluginBundleViews(seam.pluginBundles());
|
|
52214
|
+
if (typeof seam.plugins === "function")
|
|
52215
|
+
return legacyPluginViews(seam.plugins());
|
|
52216
|
+
return [];
|
|
50846
52217
|
} catch {
|
|
50847
52218
|
return [];
|
|
50848
52219
|
}
|
|
50849
52220
|
});
|
|
50850
|
-
const visible = createMemo(() => filterPluginRows(
|
|
52221
|
+
const visible = createMemo(() => filterPluginRows(bundles(), filter()));
|
|
52222
|
+
const current = createMemo(() => {
|
|
52223
|
+
const rows = visible();
|
|
52224
|
+
return rows[Math.min(cursor(), rows.length - 1)];
|
|
52225
|
+
});
|
|
52226
|
+
const cursorIndex = createMemo(() => visible().slice(0, 12).indexOf(current()));
|
|
52227
|
+
function moveCursor(delta) {
|
|
52228
|
+
const count = visible().length;
|
|
52229
|
+
if (count === 0)
|
|
52230
|
+
return;
|
|
52231
|
+
const next = Math.max(0, Math.min(cursor() + delta, count - 1));
|
|
52232
|
+
setCursor(next);
|
|
52233
|
+
}
|
|
52234
|
+
async function toggle(row) {
|
|
52235
|
+
if (row === undefined)
|
|
52236
|
+
return;
|
|
52237
|
+
if (busy())
|
|
52238
|
+
return;
|
|
52239
|
+
if (!row.toggleable || typeof props.seam.setPluginBundleEnabled !== "function") {
|
|
52240
|
+
flash(`${row.name}: read-only${row.readOnlyReason ? ` (${row.readOnlyReason})` : ""}`, 4000);
|
|
52241
|
+
return;
|
|
52242
|
+
}
|
|
52243
|
+
setBusy(true);
|
|
52244
|
+
flash(`${row.enabled ? `disabling` : `enabling`} ${row.name}\u2026`);
|
|
52245
|
+
try {
|
|
52246
|
+
const change = await props.seam.setPluginBundleEnabled(row.name, !row.enabled);
|
|
52247
|
+
flash(pluginChangeNotice(change), 6000);
|
|
52248
|
+
} catch (error) {
|
|
52249
|
+
flash(`${row.name}: change failed \u2014 ${errorMessage2(error)}`, 8000);
|
|
52250
|
+
} finally {
|
|
52251
|
+
setBusy(false);
|
|
52252
|
+
}
|
|
52253
|
+
}
|
|
52254
|
+
function confirmRemove(row) {
|
|
52255
|
+
if (row === undefined || busy())
|
|
52256
|
+
return;
|
|
52257
|
+
if (!row.removable) {
|
|
52258
|
+
flash(`${row.name}: not removable`, 4000);
|
|
52259
|
+
return;
|
|
52260
|
+
}
|
|
52261
|
+
const name = row.name;
|
|
52262
|
+
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
52263
|
+
title: `Uninstall ${name}?`,
|
|
52264
|
+
message: `Removes the ${name} package from this profile. Its plugins stop at the change (or the next host start).`,
|
|
52265
|
+
label: {
|
|
52266
|
+
confirm: "Uninstall",
|
|
52267
|
+
cancel: "Keep"
|
|
52268
|
+
},
|
|
52269
|
+
onConfirm: () => void remove(name)
|
|
52270
|
+
}), undefined, {
|
|
52271
|
+
tone: "warning"
|
|
52272
|
+
});
|
|
52273
|
+
}
|
|
52274
|
+
async function remove(name) {
|
|
52275
|
+
if (busy())
|
|
52276
|
+
return;
|
|
52277
|
+
if (typeof props.seam.removePluginBundle !== "function")
|
|
52278
|
+
return;
|
|
52279
|
+
setBusy(true);
|
|
52280
|
+
flash(`uninstalling ${name}\u2026`);
|
|
52281
|
+
try {
|
|
52282
|
+
const change = await props.seam.removePluginBundle(name);
|
|
52283
|
+
flash(pluginChangeNotice(change), 8000);
|
|
52284
|
+
} catch (error) {
|
|
52285
|
+
flash(`${name}: change failed \u2014 ${errorMessage2(error)}`, 8000);
|
|
52286
|
+
} finally {
|
|
52287
|
+
setBusy(false);
|
|
52288
|
+
}
|
|
52289
|
+
}
|
|
52290
|
+
function beginInstall() {
|
|
52291
|
+
if (busy())
|
|
52292
|
+
return;
|
|
52293
|
+
if (typeof props.seam.installPluginSpec !== "function") {
|
|
52294
|
+
flash("install unavailable on this seam", 4000);
|
|
52295
|
+
return;
|
|
52296
|
+
}
|
|
52297
|
+
setInstallText("");
|
|
52298
|
+
setInstallOpen(true);
|
|
52299
|
+
}
|
|
52300
|
+
async function commitInstall() {
|
|
52301
|
+
const spec = installText().trim();
|
|
52302
|
+
if (spec === "") {
|
|
52303
|
+
flash("spec required (npm name, git url, path or tarball)", 4000);
|
|
52304
|
+
return;
|
|
52305
|
+
}
|
|
52306
|
+
setInstallOpen(false);
|
|
52307
|
+
setInstallText("");
|
|
52308
|
+
if (busy())
|
|
52309
|
+
return;
|
|
52310
|
+
if (typeof props.seam.inspectPluginSpec !== "function")
|
|
52311
|
+
return;
|
|
52312
|
+
setBusy(true);
|
|
52313
|
+
flash(`inspecting ${spec}\u2026`);
|
|
52314
|
+
let inspection;
|
|
52315
|
+
try {
|
|
52316
|
+
inspection = await props.seam.inspectPluginSpec(spec);
|
|
52317
|
+
} catch (error) {
|
|
52318
|
+
flash(`cannot install ${spec}: ${errorMessage2(error)}`, 8000);
|
|
52319
|
+
return;
|
|
52320
|
+
} finally {
|
|
52321
|
+
setBusy(false);
|
|
52322
|
+
}
|
|
52323
|
+
if (inspection.status === "refused") {
|
|
52324
|
+
flash(`cannot install ${spec}: ${inspection.problem} \u2014 ${inspection.reason}`, 8000);
|
|
52325
|
+
return;
|
|
52326
|
+
}
|
|
52327
|
+
const accepted = inspection;
|
|
52328
|
+
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
52329
|
+
title: "Install plugin?",
|
|
52330
|
+
get message() {
|
|
52331
|
+
return `${installPreviewLine(accepted)}${accepted.description ? ` \u2014 ${accepted.description}` : ""}`;
|
|
52332
|
+
},
|
|
52333
|
+
label: {
|
|
52334
|
+
confirm: "Install",
|
|
52335
|
+
cancel: "Cancel"
|
|
52336
|
+
},
|
|
52337
|
+
onConfirm: () => void install(spec)
|
|
52338
|
+
}), undefined, {
|
|
52339
|
+
tone: "warning"
|
|
52340
|
+
});
|
|
52341
|
+
}
|
|
52342
|
+
async function install(spec) {
|
|
52343
|
+
if (busy())
|
|
52344
|
+
return;
|
|
52345
|
+
if (typeof props.seam.installPluginSpec !== "function")
|
|
52346
|
+
return;
|
|
52347
|
+
setBusy(true);
|
|
52348
|
+
flash(`installing ${spec}\u2026`);
|
|
52349
|
+
try {
|
|
52350
|
+
const change = await props.seam.installPluginSpec(spec);
|
|
52351
|
+
flash(pluginChangeNotice(change), 8000);
|
|
52352
|
+
} catch (error) {
|
|
52353
|
+
flash(`${spec}: change failed \u2014 ${errorMessage2(error)}`, 8000);
|
|
52354
|
+
} finally {
|
|
52355
|
+
setBusy(false);
|
|
52356
|
+
}
|
|
52357
|
+
}
|
|
50851
52358
|
Keymap2.createLayer(() => ({
|
|
50852
52359
|
mode: "global",
|
|
50853
52360
|
enabled: open() && dialog.stack.length === 0,
|
|
@@ -50861,10 +52368,61 @@ function PluginsPanel(props) {
|
|
|
50861
52368
|
bind: "/",
|
|
50862
52369
|
title: "Filter bundles",
|
|
50863
52370
|
group: "Plugins",
|
|
52371
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
50864
52372
|
run: () => {
|
|
50865
52373
|
setFilterOpen(true);
|
|
50866
52374
|
return true;
|
|
50867
52375
|
}
|
|
52376
|
+
}, {
|
|
52377
|
+
bind: "return",
|
|
52378
|
+
title: "Commit input / toggle enable-disable",
|
|
52379
|
+
group: "Plugins",
|
|
52380
|
+
run: () => {
|
|
52381
|
+
if (installOpen()) {
|
|
52382
|
+
commitInstall();
|
|
52383
|
+
return true;
|
|
52384
|
+
}
|
|
52385
|
+
if (filterOpen()) {
|
|
52386
|
+
setFilterOpen(false);
|
|
52387
|
+
setFilter("");
|
|
52388
|
+
return true;
|
|
52389
|
+
}
|
|
52390
|
+
toggle(current());
|
|
52391
|
+
return true;
|
|
52392
|
+
}
|
|
52393
|
+
}, {
|
|
52394
|
+
bind: "space",
|
|
52395
|
+
title: "Toggle enable/disable",
|
|
52396
|
+
group: "Plugins",
|
|
52397
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
52398
|
+
run: () => {
|
|
52399
|
+
toggle(current());
|
|
52400
|
+
return true;
|
|
52401
|
+
}
|
|
52402
|
+
}, {
|
|
52403
|
+
bind: "d",
|
|
52404
|
+
title: "Uninstall (confirm)",
|
|
52405
|
+
group: "Plugins",
|
|
52406
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
52407
|
+
run: () => confirmRemove(current())
|
|
52408
|
+
}, {
|
|
52409
|
+
bind: "i",
|
|
52410
|
+
title: "Install a spec",
|
|
52411
|
+
group: "Plugins",
|
|
52412
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
52413
|
+
run: beginInstall
|
|
52414
|
+
}, {
|
|
52415
|
+
bind: "up,k",
|
|
52416
|
+
title: "Previous bundle",
|
|
52417
|
+
group: "Plugins",
|
|
52418
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
52419
|
+
run: () => moveCursor(-1)
|
|
52420
|
+
}, {
|
|
52421
|
+
bind: "down,j",
|
|
52422
|
+
title: "Next bundle",
|
|
52423
|
+
group: "Plugins",
|
|
52424
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
52425
|
+
run: () => moveCursor(1)
|
|
50868
52426
|
}]
|
|
50869
52427
|
}));
|
|
50870
52428
|
return createComponent2(Show, {
|
|
@@ -50888,48 +52446,83 @@ function PluginsPanel(props) {
|
|
|
50888
52446
|
insertNode(_el$3, createTextNode(`\uD83D\uDD0C Plugins`));
|
|
50889
52447
|
setProp(_el$3, "wrapMode", "none");
|
|
50890
52448
|
setProp(_el$5, "wrapMode", "none");
|
|
50891
|
-
insert(_el$5, () => ` ${visible().length}/${
|
|
52449
|
+
insert(_el$5, () => ` ${visible().length}/${bundles().length} / filter enter toggle d uninstall i install esc close`);
|
|
50892
52450
|
insert(_el$, createComponent2(Show, {
|
|
50893
52451
|
get when() {
|
|
50894
|
-
return
|
|
52452
|
+
return !installOpen();
|
|
50895
52453
|
},
|
|
50896
52454
|
get fallback() {
|
|
50897
52455
|
return (() => {
|
|
50898
|
-
var _el$
|
|
50899
|
-
insertNode(_el$
|
|
50900
|
-
setProp(_el$
|
|
50901
|
-
setProp(_el$
|
|
50902
|
-
|
|
50903
|
-
|
|
50904
|
-
|
|
50905
|
-
|
|
52456
|
+
var _el$0 = createElement("box"), _el$1 = createElement("input");
|
|
52457
|
+
insertNode(_el$0, _el$1);
|
|
52458
|
+
setProp(_el$0, "height", 1);
|
|
52459
|
+
setProp(_el$0, "flexShrink", 0);
|
|
52460
|
+
setProp(_el$0, "flexDirection", "row");
|
|
52461
|
+
use((renderable) => {
|
|
52462
|
+
setTimeout(() => {
|
|
52463
|
+
if (!renderable.isDestroyed)
|
|
52464
|
+
renderable.focus();
|
|
52465
|
+
}, 1);
|
|
52466
|
+
}, _el$1);
|
|
52467
|
+
setProp(_el$1, "flexGrow", 1);
|
|
52468
|
+
setProp(_el$1, "placeholder", "install spec (npm name, git url, path, tarball)");
|
|
52469
|
+
setProp(_el$1, "onInput", (value) => setInstallText(value));
|
|
52470
|
+
effect((_p$) => {
|
|
52471
|
+
var _v$9 = theme?.text.muted ?? "#565f89", _v$0 = installText();
|
|
52472
|
+
_v$9 !== _p$.e && (_p$.e = setProp(_el$1, "placeholderColor", _v$9, _p$.e));
|
|
52473
|
+
_v$0 !== _p$.t && (_p$.t = setProp(_el$1, "value", _v$0, _p$.t));
|
|
52474
|
+
return _p$;
|
|
52475
|
+
}, {
|
|
52476
|
+
e: undefined,
|
|
52477
|
+
t: undefined
|
|
52478
|
+
});
|
|
52479
|
+
return _el$0;
|
|
50906
52480
|
})();
|
|
50907
52481
|
},
|
|
50908
52482
|
get children() {
|
|
50909
|
-
|
|
50910
|
-
|
|
50911
|
-
|
|
50912
|
-
|
|
50913
|
-
|
|
50914
|
-
|
|
50915
|
-
|
|
50916
|
-
|
|
50917
|
-
|
|
50918
|
-
|
|
50919
|
-
|
|
50920
|
-
|
|
50921
|
-
|
|
50922
|
-
|
|
50923
|
-
|
|
50924
|
-
|
|
50925
|
-
|
|
50926
|
-
|
|
50927
|
-
|
|
50928
|
-
|
|
50929
|
-
|
|
50930
|
-
|
|
52483
|
+
return createComponent2(Show, {
|
|
52484
|
+
get when() {
|
|
52485
|
+
return filterOpen();
|
|
52486
|
+
},
|
|
52487
|
+
get fallback() {
|
|
52488
|
+
return (() => {
|
|
52489
|
+
var _el$10 = createElement("box"), _el$11 = createElement("text");
|
|
52490
|
+
insertNode(_el$10, _el$11);
|
|
52491
|
+
setProp(_el$10, "height", 1);
|
|
52492
|
+
setProp(_el$10, "flexShrink", 0);
|
|
52493
|
+
insertNode(_el$11, createTextNode(`BUNDLE STATE`));
|
|
52494
|
+
setProp(_el$11, "wrapMode", "none");
|
|
52495
|
+
effect((_$p) => setProp(_el$11, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
52496
|
+
return _el$10;
|
|
52497
|
+
})();
|
|
52498
|
+
},
|
|
52499
|
+
get children() {
|
|
52500
|
+
var _el$6 = createElement("box"), _el$7 = createElement("input");
|
|
52501
|
+
insertNode(_el$6, _el$7);
|
|
52502
|
+
setProp(_el$6, "height", 1);
|
|
52503
|
+
setProp(_el$6, "flexShrink", 0);
|
|
52504
|
+
setProp(_el$6, "flexDirection", "row");
|
|
52505
|
+
use((renderable) => {
|
|
52506
|
+
setTimeout(() => {
|
|
52507
|
+
if (!renderable.isDestroyed)
|
|
52508
|
+
renderable.focus();
|
|
52509
|
+
}, 1);
|
|
52510
|
+
}, _el$7);
|
|
52511
|
+
setProp(_el$7, "flexGrow", 1);
|
|
52512
|
+
setProp(_el$7, "placeholder", "filter");
|
|
52513
|
+
setProp(_el$7, "onInput", (value) => setFilter(value));
|
|
52514
|
+
effect((_p$) => {
|
|
52515
|
+
var _v$ = theme?.text.muted ?? "#565f89", _v$2 = filter();
|
|
52516
|
+
_v$ !== _p$.e && (_p$.e = setProp(_el$7, "placeholderColor", _v$, _p$.e));
|
|
52517
|
+
_v$2 !== _p$.t && (_p$.t = setProp(_el$7, "value", _v$2, _p$.t));
|
|
52518
|
+
return _p$;
|
|
52519
|
+
}, {
|
|
52520
|
+
e: undefined,
|
|
52521
|
+
t: undefined
|
|
52522
|
+
});
|
|
52523
|
+
return _el$6;
|
|
52524
|
+
}
|
|
50931
52525
|
});
|
|
50932
|
-
return _el$6;
|
|
50933
52526
|
}
|
|
50934
52527
|
}), null);
|
|
50935
52528
|
insert(_el$, createComponent2(Show, {
|
|
@@ -50938,14 +52531,14 @@ function PluginsPanel(props) {
|
|
|
50938
52531
|
},
|
|
50939
52532
|
get fallback() {
|
|
50940
52533
|
return (() => {
|
|
50941
|
-
var _el$
|
|
50942
|
-
insertNode(_el$
|
|
50943
|
-
setProp(_el$
|
|
50944
|
-
setProp(_el$
|
|
50945
|
-
setProp(_el$
|
|
50946
|
-
insert(_el$
|
|
50947
|
-
effect((_$p) => setProp(_el$
|
|
50948
|
-
return _el$
|
|
52534
|
+
var _el$13 = createElement("box"), _el$14 = createElement("text");
|
|
52535
|
+
insertNode(_el$13, _el$14);
|
|
52536
|
+
setProp(_el$13, "height", 1);
|
|
52537
|
+
setProp(_el$13, "flexShrink", 0);
|
|
52538
|
+
setProp(_el$14, "wrapMode", "none");
|
|
52539
|
+
insert(_el$14, () => bundles().length === 0 ? "no plugins installed" : "no bundles match the filter");
|
|
52540
|
+
effect((_$p) => setProp(_el$14, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
52541
|
+
return _el$13;
|
|
50949
52542
|
})();
|
|
50950
52543
|
},
|
|
50951
52544
|
get children() {
|
|
@@ -50953,33 +52546,48 @@ function PluginsPanel(props) {
|
|
|
50953
52546
|
get each() {
|
|
50954
52547
|
return visible().slice(0, 12);
|
|
50955
52548
|
},
|
|
50956
|
-
children: (row) => (() => {
|
|
50957
|
-
var _el$
|
|
50958
|
-
insertNode(_el$
|
|
50959
|
-
insertNode(_el$
|
|
50960
|
-
setProp(_el$
|
|
50961
|
-
setProp(_el$
|
|
50962
|
-
setProp(_el$
|
|
50963
|
-
setProp(_el$
|
|
50964
|
-
insert(_el$
|
|
50965
|
-
|
|
50966
|
-
|
|
52549
|
+
children: (row, index) => (() => {
|
|
52550
|
+
var _el$15 = createElement("box"), _el$16 = createElement("text"), _el$17 = createElement("text");
|
|
52551
|
+
insertNode(_el$15, _el$16);
|
|
52552
|
+
insertNode(_el$15, _el$17);
|
|
52553
|
+
setProp(_el$15, "height", 1);
|
|
52554
|
+
setProp(_el$15, "flexShrink", 0);
|
|
52555
|
+
setProp(_el$15, "flexDirection", "row");
|
|
52556
|
+
setProp(_el$16, "wrapMode", "none");
|
|
52557
|
+
insert(_el$16, () => `${index() === cursorIndex() ? "\u203A " : " "}${formatPluginLine(row).padEnd(34)}`);
|
|
52558
|
+
setProp(_el$17, "wrapMode", "none");
|
|
52559
|
+
insert(_el$17, () => bundleStateText(row));
|
|
50967
52560
|
effect((_p$) => {
|
|
50968
|
-
var _v$
|
|
50969
|
-
_v$
|
|
50970
|
-
_v$
|
|
52561
|
+
var _v$1 = index() === cursorIndex() ? theme?.text.base ?? "#e6e6e6" : theme?.text.muted ?? "#565f89", _v$10 = row.enabled ? successColor(theme ?? undefined) : theme?.text.muted ?? "#565f89";
|
|
52562
|
+
_v$1 !== _p$.e && (_p$.e = setProp(_el$16, "fg", _v$1, _p$.e));
|
|
52563
|
+
_v$10 !== _p$.t && (_p$.t = setProp(_el$17, "fg", _v$10, _p$.t));
|
|
50971
52564
|
return _p$;
|
|
50972
52565
|
}, {
|
|
50973
52566
|
e: undefined,
|
|
50974
52567
|
t: undefined
|
|
50975
52568
|
});
|
|
50976
|
-
return _el$
|
|
52569
|
+
return _el$15;
|
|
50977
52570
|
})()
|
|
50978
52571
|
});
|
|
50979
52572
|
}
|
|
50980
52573
|
}), null);
|
|
52574
|
+
insert(_el$, createComponent2(Show, {
|
|
52575
|
+
get when() {
|
|
52576
|
+
return status() !== undefined;
|
|
52577
|
+
},
|
|
52578
|
+
get children() {
|
|
52579
|
+
var _el$8 = createElement("box"), _el$9 = createElement("text");
|
|
52580
|
+
insertNode(_el$8, _el$9);
|
|
52581
|
+
setProp(_el$8, "height", 1);
|
|
52582
|
+
setProp(_el$8, "flexShrink", 0);
|
|
52583
|
+
setProp(_el$9, "wrapMode", "none");
|
|
52584
|
+
insert(_el$9, status);
|
|
52585
|
+
effect((_$p) => setProp(_el$9, "fg", warningColor(theme ?? undefined), _$p));
|
|
52586
|
+
return _el$8;
|
|
52587
|
+
}
|
|
52588
|
+
}), null);
|
|
50981
52589
|
effect((_p$) => {
|
|
50982
|
-
var _v$3 = 1 + 1 + Math.min(visible().length || 1, 12) + 1, _v$4 = theme?.border.base ?? "#7aa2f7", _v$5 = theme?.background.raised.base ?? "#1a1b26", _v$6 = theme?.text.base ?? "#e6e6e6", _v$7 =
|
|
52590
|
+
var _v$3 = 1 + 1 + Math.min(visible().length || 1, 12) + (status() !== undefined ? 1 : 0) + 1, _v$4 = theme?.border.base ?? "#7aa2f7", _v$5 = theme?.background.raised.base ?? "#1a1b26", _v$6 = theme?.text.base ?? "#e6e6e6", _v$7 = TextAttributes10.BOLD, _v$8 = theme?.text.muted ?? "#565f89";
|
|
50983
52591
|
_v$3 !== _p$.e && (_p$.e = setProp(_el$, "height", _v$3, _p$.e));
|
|
50984
52592
|
_v$4 !== _p$.t && (_p$.t = setProp(_el$, "borderColor", _v$4, _p$.t));
|
|
50985
52593
|
_v$5 !== _p$.a && (_p$.a = setProp(_el$, "backgroundColor", _v$5, _p$.a));
|
|
@@ -50999,7 +52607,7 @@ function PluginsPanel(props) {
|
|
|
50999
52607
|
}
|
|
51000
52608
|
});
|
|
51001
52609
|
}
|
|
51002
|
-
var
|
|
52610
|
+
var bridgeOpen3, setBridgeOpen3, panelOpen4, setPanelOpen4, pluginsPanelOpen;
|
|
51003
52611
|
var init_plugins_panel = __esm(() => {
|
|
51004
52612
|
init_index_bun();
|
|
51005
52613
|
init_index_bun();
|
|
@@ -51013,11 +52621,12 @@ var init_plugins_panel = __esm(() => {
|
|
|
51013
52621
|
init_server();
|
|
51014
52622
|
init_keymap();
|
|
51015
52623
|
init_dialog();
|
|
52624
|
+
init_dialog_confirm();
|
|
51016
52625
|
init_theme3();
|
|
51017
52626
|
init_semantic();
|
|
51018
|
-
[
|
|
51019
|
-
[
|
|
51020
|
-
pluginsPanelOpen =
|
|
52627
|
+
[bridgeOpen3, setBridgeOpen3] = createSignal(false);
|
|
52628
|
+
[panelOpen4, setPanelOpen4] = createSignal(false);
|
|
52629
|
+
pluginsPanelOpen = panelOpen4;
|
|
51021
52630
|
});
|
|
51022
52631
|
|
|
51023
52632
|
// ../panel-kit/src/contracts.ts
|
|
@@ -51031,7 +52640,7 @@ var init_contracts = __esm(() => {
|
|
|
51031
52640
|
});
|
|
51032
52641
|
|
|
51033
52642
|
// ../panel-kit/src/fallback.ts
|
|
51034
|
-
import { RGBA as RGBA13, TextAttributes as
|
|
52643
|
+
import { RGBA as RGBA13, TextAttributes as TextAttributes11 } from "@opentui/core";
|
|
51035
52644
|
var surface, content, raised, base2, muted, faint, accent, disabled, danger, warning, success, code, user, system, heading, FALLBACK_THEME;
|
|
51036
52645
|
var init_fallback = __esm(() => {
|
|
51037
52646
|
surface = RGBA13.fromHex("#1a1b26");
|
|
@@ -51080,11 +52689,11 @@ var init_fallback = __esm(() => {
|
|
|
51080
52689
|
warning: { style: "heavy", color: warning }
|
|
51081
52690
|
},
|
|
51082
52691
|
attributes: {
|
|
51083
|
-
title:
|
|
51084
|
-
group:
|
|
51085
|
-
selected:
|
|
51086
|
-
keyHint:
|
|
51087
|
-
subtitle:
|
|
52692
|
+
title: TextAttributes11.BOLD,
|
|
52693
|
+
group: TextAttributes11.BOLD,
|
|
52694
|
+
selected: TextAttributes11.BOLD,
|
|
52695
|
+
keyHint: TextAttributes11.NONE,
|
|
52696
|
+
subtitle: TextAttributes11.NONE
|
|
51088
52697
|
},
|
|
51089
52698
|
identity: [RGBA13.fromHex("#4D6BFE"), RGBA13.fromHex("#8B5CF6")]
|
|
51090
52699
|
});
|
|
@@ -54030,11 +55639,11 @@ function settingsSummary(changed) {
|
|
|
54030
55639
|
return changed.length > 0 ? `Settings updated: ${changed.join(", ")}` : "Settings unchanged.";
|
|
54031
55640
|
}
|
|
54032
55641
|
function openSettingsPanel(itemId) {
|
|
54033
|
-
|
|
55642
|
+
setBridgeOpen4(itemId ?? "");
|
|
54034
55643
|
}
|
|
54035
55644
|
function useSettingsPanelOpenState() {
|
|
54036
|
-
onCleanup(() =>
|
|
54037
|
-
return [settingsPanelOpen,
|
|
55645
|
+
onCleanup(() => setPanelOpen5(false));
|
|
55646
|
+
return [settingsPanelOpen, setPanelOpen5];
|
|
54038
55647
|
}
|
|
54039
55648
|
function readLocalSnapshot(seam) {
|
|
54040
55649
|
let merged = {};
|
|
@@ -54132,9 +55741,9 @@ function applySettingsLive(item, applied, hints, themes) {
|
|
|
54132
55741
|
}
|
|
54133
55742
|
}
|
|
54134
55743
|
function setSettingsBridge(value) {
|
|
54135
|
-
|
|
55744
|
+
setBridgeOpen4(value);
|
|
54136
55745
|
}
|
|
54137
|
-
var UNKNOWN = "(unset)", NA = "n/a", READONLY_NOTE = "\u53EA\u8BFB \xB7 \u672C TUI \u4E0D\u6D88\u8D39", ZONE_SUBTITLE, HOST_SETTINGS_WHITELIST, HIDDEN_NAMESPACES, LOCAL_SETTING_IDS,
|
|
55746
|
+
var UNKNOWN = "(unset)", NA = "n/a", READONLY_NOTE = "\u53EA\u8BFB \xB7 \u672C TUI \u4E0D\u6D88\u8D39", ZONE_SUBTITLE, HOST_SETTINGS_WHITELIST, HIDDEN_NAMESPACES, LOCAL_SETTING_IDS, bridgeOpen4, setBridgeOpen4, panelOpen5, setPanelOpen5, settingsPanelOpen, settingsBridgeOpen;
|
|
54138
55747
|
var init_settings_panel = __esm(() => {
|
|
54139
55748
|
init_server();
|
|
54140
55749
|
init_string_width();
|
|
@@ -54174,10 +55783,10 @@ var init_settings_panel = __esm(() => {
|
|
|
54174
55783
|
}];
|
|
54175
55784
|
HIDDEN_NAMESPACES = new Set([...HOST_SETTINGS_WHITELIST.map((spec) => spec.ns), "dsh-tui"]);
|
|
54176
55785
|
LOCAL_SETTING_IDS = ["theme", "themeMode", "workspaceThemeMode", "motion", ...FOOTER_HINT_IDS.map((id) => `footerHints.${id}`), "hintsLocale", "cacheHitMode", "retentionDays", "maxRounds", "maxRoundsGrace"];
|
|
54177
|
-
[
|
|
54178
|
-
[
|
|
54179
|
-
settingsPanelOpen =
|
|
54180
|
-
settingsBridgeOpen =
|
|
55786
|
+
[bridgeOpen4, setBridgeOpen4] = createSignal(undefined);
|
|
55787
|
+
[panelOpen5, setPanelOpen5] = createSignal(false);
|
|
55788
|
+
settingsPanelOpen = panelOpen5;
|
|
55789
|
+
settingsBridgeOpen = bridgeOpen4;
|
|
54181
55790
|
});
|
|
54182
55791
|
|
|
54183
55792
|
// ../tui-base/src/routes/session/agents-panel.tsx
|
|
@@ -54198,11 +55807,11 @@ function clipText(text, limit) {
|
|
|
54198
55807
|
return limit <= 1 ? "\u2026" : `${out}\u2026`;
|
|
54199
55808
|
}
|
|
54200
55809
|
function openAgentsPanel(name) {
|
|
54201
|
-
|
|
55810
|
+
setBridgeOpen5(name ?? "");
|
|
54202
55811
|
}
|
|
54203
55812
|
function useAgentsPanelOpenState() {
|
|
54204
|
-
onCleanup(() =>
|
|
54205
|
-
return [agentsPanelOpen,
|
|
55813
|
+
onCleanup(() => setPanelOpen6(false));
|
|
55814
|
+
return [agentsPanelOpen, setPanelOpen6];
|
|
54206
55815
|
}
|
|
54207
55816
|
function initialAgentLevel(rows) {
|
|
54208
55817
|
return rows.length === 0 ? "limits" : "table";
|
|
@@ -54615,10 +56224,10 @@ function AgentsPanel(props) {
|
|
|
54615
56224
|
}
|
|
54616
56225
|
}
|
|
54617
56226
|
createEffect(() => {
|
|
54618
|
-
const preselected =
|
|
56227
|
+
const preselected = bridgeOpen5();
|
|
54619
56228
|
if (preselected === undefined)
|
|
54620
56229
|
return;
|
|
54621
|
-
|
|
56230
|
+
setBridgeOpen5(undefined);
|
|
54622
56231
|
if (layers().length > 0)
|
|
54623
56232
|
return;
|
|
54624
56233
|
const next = reloadRows();
|
|
@@ -55481,7 +57090,7 @@ function AgentsPanel(props) {
|
|
|
55481
57090
|
}
|
|
55482
57091
|
return null;
|
|
55483
57092
|
}
|
|
55484
|
-
var INHERIT = "(inherit)", INHERIT_DEFAULT = "(inherit \u2014 default model)", PAGE_SIZE = 12, PANEL_SIZE = "xlarge",
|
|
57093
|
+
var INHERIT = "(inherit)", INHERIT_DEFAULT = "(inherit \u2014 default model)", PAGE_SIZE = 12, PANEL_SIZE = "xlarge", bridgeOpen5, setBridgeOpen5, panelOpen6, setPanelOpen6, agentsPanelOpen, AGENT_TABLE_COLUMNS, AGENT_FIELD_COLUMNS, LIMIT_DESCRIPTIONS, AGENT_PICKER_COLUMNS, AGENT_EFFORT_COLUMNS;
|
|
55485
57094
|
var init_agents_panel = __esm(() => {
|
|
55486
57095
|
init_index_bun();
|
|
55487
57096
|
init_index_bun();
|
|
@@ -55498,9 +57107,9 @@ var init_agents_panel = __esm(() => {
|
|
|
55498
57107
|
init_keymap();
|
|
55499
57108
|
init_string_width();
|
|
55500
57109
|
init_settings_panel();
|
|
55501
|
-
[
|
|
55502
|
-
[
|
|
55503
|
-
agentsPanelOpen =
|
|
57110
|
+
[bridgeOpen5, setBridgeOpen5] = createSignal(undefined);
|
|
57111
|
+
[panelOpen6, setPanelOpen6] = createSignal(false);
|
|
57112
|
+
agentsPanelOpen = panelOpen6;
|
|
55504
57113
|
AGENT_TABLE_COLUMNS = [{
|
|
55505
57114
|
id: "name",
|
|
55506
57115
|
title: "NAME",
|
|
@@ -55558,11 +57167,1162 @@ var init_agents_panel = __esm(() => {
|
|
|
55558
57167
|
}];
|
|
55559
57168
|
});
|
|
55560
57169
|
|
|
57170
|
+
// ../tui-base/src/routes/session/history-data.ts
|
|
57171
|
+
function asRecord3(value) {
|
|
57172
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
57173
|
+
}
|
|
57174
|
+
function blocksText2(content) {
|
|
57175
|
+
if (!Array.isArray(content))
|
|
57176
|
+
return "";
|
|
57177
|
+
let text = "";
|
|
57178
|
+
for (const block of content) {
|
|
57179
|
+
const typed = asRecord3(block);
|
|
57180
|
+
if (typeof typed.text === "string" && typed.type === "text") {
|
|
57181
|
+
text += (text === "" ? "" : `
|
|
57182
|
+
`) + typed.text;
|
|
57183
|
+
}
|
|
57184
|
+
}
|
|
57185
|
+
return text.trim();
|
|
57186
|
+
}
|
|
57187
|
+
function sourceKind2(data) {
|
|
57188
|
+
return asRecord3(data.source).kind;
|
|
57189
|
+
}
|
|
57190
|
+
function groupHistoryTurns(entries) {
|
|
57191
|
+
const turns = [];
|
|
57192
|
+
let open;
|
|
57193
|
+
const close = () => {
|
|
57194
|
+
if (open === undefined)
|
|
57195
|
+
return;
|
|
57196
|
+
const userTexts = open.userEntries.filter((entry) => entry.human && entry.text !== "").map((entry) => entry.text);
|
|
57197
|
+
const anyText = open.userEntries.find((entry) => entry.text !== "")?.text ?? "";
|
|
57198
|
+
turns.push({
|
|
57199
|
+
turn: open.turn,
|
|
57200
|
+
seqStart: open.seqStart,
|
|
57201
|
+
seqEnd: open.seqEnd,
|
|
57202
|
+
endReason: open.endReason,
|
|
57203
|
+
endError: open.endError,
|
|
57204
|
+
interrupted: open.interrupted,
|
|
57205
|
+
startTime: open.startTime,
|
|
57206
|
+
endTime: open.endTime,
|
|
57207
|
+
userTexts,
|
|
57208
|
+
previewText: userTexts[0] ?? anyText,
|
|
57209
|
+
assistantTexts: open.assistantTexts,
|
|
57210
|
+
toolCalls: open.toolCalls
|
|
57211
|
+
});
|
|
57212
|
+
open = undefined;
|
|
57213
|
+
};
|
|
57214
|
+
let ordinal = 0;
|
|
57215
|
+
for (const entry of entries) {
|
|
57216
|
+
if (entry.type === "turn/start") {
|
|
57217
|
+
open = {
|
|
57218
|
+
turn: typeof entry.data.turn === "number" ? entry.data.turn : ordinal,
|
|
57219
|
+
seqStart: entry.seq,
|
|
57220
|
+
seqEnd: entry.seq,
|
|
57221
|
+
endReason: "completed",
|
|
57222
|
+
endError: undefined,
|
|
57223
|
+
endTime: undefined,
|
|
57224
|
+
startTime: typeof entry.time === "number" ? entry.time : undefined,
|
|
57225
|
+
interrupted: false,
|
|
57226
|
+
userEntries: [],
|
|
57227
|
+
assistantTexts: [],
|
|
57228
|
+
toolCalls: [],
|
|
57229
|
+
callIndex: new Map
|
|
57230
|
+
};
|
|
57231
|
+
ordinal++;
|
|
57232
|
+
continue;
|
|
57233
|
+
}
|
|
57234
|
+
if (open === undefined)
|
|
57235
|
+
continue;
|
|
57236
|
+
switch (entry.type) {
|
|
57237
|
+
case "user/message": {
|
|
57238
|
+
const kind = sourceKind2(entry.data);
|
|
57239
|
+
const human = kind === undefined || kind === "user";
|
|
57240
|
+
open.userEntries.push({ human, text: blocksText2(entry.data.content) });
|
|
57241
|
+
break;
|
|
57242
|
+
}
|
|
57243
|
+
case "assistant/message": {
|
|
57244
|
+
const message = asRecord3(entry.data.message);
|
|
57245
|
+
const text = blocksText2(message.content);
|
|
57246
|
+
if (text !== "")
|
|
57247
|
+
open.assistantTexts.push(text);
|
|
57248
|
+
if (entry.data.interrupted === true)
|
|
57249
|
+
open.interrupted = true;
|
|
57250
|
+
break;
|
|
57251
|
+
}
|
|
57252
|
+
case "tool/call": {
|
|
57253
|
+
const index = open.toolCalls.push({
|
|
57254
|
+
name: String(entry.data.name ?? ""),
|
|
57255
|
+
args: typeof entry.data.arguments === "string" ? entry.data.arguments : ""
|
|
57256
|
+
}) - 1;
|
|
57257
|
+
if (entry.data.callId !== undefined)
|
|
57258
|
+
open.callIndex.set(String(entry.data.callId), index);
|
|
57259
|
+
break;
|
|
57260
|
+
}
|
|
57261
|
+
case "tool/result": {
|
|
57262
|
+
const message = asRecord3(entry.data.message);
|
|
57263
|
+
const callId = entry.data.callId !== undefined ? String(entry.data.callId) : message.toolCallId !== undefined ? String(message.toolCallId) : "";
|
|
57264
|
+
const index = callId === "" ? undefined : open.callIndex.get(callId);
|
|
57265
|
+
if (index === undefined)
|
|
57266
|
+
break;
|
|
57267
|
+
open.callIndex.delete(callId);
|
|
57268
|
+
const call = open.toolCalls[index];
|
|
57269
|
+
call.ok = entry.data.isError !== true && message.isError !== true;
|
|
57270
|
+
call.output = typeof entry.data.output === "string" ? entry.data.output : JSON.stringify(entry.data.output ?? entry.data);
|
|
57271
|
+
break;
|
|
57272
|
+
}
|
|
57273
|
+
case "turn/end": {
|
|
57274
|
+
open.seqEnd = entry.seq;
|
|
57275
|
+
open.endTime = typeof entry.time === "number" ? entry.time : undefined;
|
|
57276
|
+
const reason = asRecord3(entry.data.reason);
|
|
57277
|
+
open.endReason = typeof reason.kind === "string" ? reason.kind : "completed";
|
|
57278
|
+
const error = asRecord3(reason.error);
|
|
57279
|
+
open.endError = typeof error.message === "string" ? error.message : undefined;
|
|
57280
|
+
close();
|
|
57281
|
+
break;
|
|
57282
|
+
}
|
|
57283
|
+
default:
|
|
57284
|
+
break;
|
|
57285
|
+
}
|
|
57286
|
+
}
|
|
57287
|
+
return turns;
|
|
57288
|
+
}
|
|
57289
|
+
function turnPrimaryUserText(turn) {
|
|
57290
|
+
return turn.userTexts[0];
|
|
57291
|
+
}
|
|
57292
|
+
function normalizeHistoryPreview(text, maxChars = HISTORY_PREVIEW_MAX_CHARS) {
|
|
57293
|
+
const oneLine = text.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim();
|
|
57294
|
+
return oneLine.length <= maxChars ? oneLine : `${oneLine.slice(0, maxChars)}\u2026`;
|
|
57295
|
+
}
|
|
57296
|
+
function toolCallSummary(names) {
|
|
57297
|
+
if (names.length === 0)
|
|
57298
|
+
return "";
|
|
57299
|
+
const counts = new Map;
|
|
57300
|
+
for (const name of names)
|
|
57301
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
57302
|
+
const parts = [...counts.entries()].map(([name, count]) => `${name}\xD7${count}`);
|
|
57303
|
+
const label = names.length === 1 ? "tool call" : "tool calls";
|
|
57304
|
+
return `${names.length} ${label}: ${parts.join(", ")}`;
|
|
57305
|
+
}
|
|
57306
|
+
var HISTORY_PREVIEW_MAX_CHARS = 140;
|
|
57307
|
+
|
|
57308
|
+
// ../tui-base/src/routes/session/history-panel.tsx
|
|
57309
|
+
function openHistoryPanel() {
|
|
57310
|
+
setBridgeOpen6(true);
|
|
57311
|
+
}
|
|
57312
|
+
function useHistoryPanelOpenState() {
|
|
57313
|
+
onCleanup(() => setPanelOpen7(false));
|
|
57314
|
+
return [historyPanelOpen, setPanelOpen7];
|
|
57315
|
+
}
|
|
57316
|
+
function turnRowText(turn, width) {
|
|
57317
|
+
const number = `#${turn.turn} `;
|
|
57318
|
+
const preview = normalizeHistoryPreview(turn.previewText, Math.max(0, width - number.length - 1));
|
|
57319
|
+
return `${number}${preview}`;
|
|
57320
|
+
}
|
|
57321
|
+
function turnCursorStep(current, delta, count) {
|
|
57322
|
+
if (count <= 0)
|
|
57323
|
+
return current;
|
|
57324
|
+
return (current + delta + count) % count;
|
|
57325
|
+
}
|
|
57326
|
+
function turnWindow(count, cursor, visible) {
|
|
57327
|
+
const size = Math.max(0, Math.min(visible, count));
|
|
57328
|
+
const clamped = Math.max(0, Math.min(cursor, Math.max(0, count - 1)));
|
|
57329
|
+
let start = Math.min(clamped, Math.max(0, count - size));
|
|
57330
|
+
return {
|
|
57331
|
+
start,
|
|
57332
|
+
end: start + size
|
|
57333
|
+
};
|
|
57334
|
+
}
|
|
57335
|
+
function refillOrNotice(turn) {
|
|
57336
|
+
if (turn === undefined)
|
|
57337
|
+
return {
|
|
57338
|
+
kind: "notice",
|
|
57339
|
+
text: "no turn selected"
|
|
57340
|
+
};
|
|
57341
|
+
const text = turnPrimaryUserText(turn);
|
|
57342
|
+
if (text === undefined)
|
|
57343
|
+
return {
|
|
57344
|
+
kind: "notice",
|
|
57345
|
+
text: `turn #${turn.turn} has no prompt to refill`
|
|
57346
|
+
};
|
|
57347
|
+
return {
|
|
57348
|
+
kind: "refill",
|
|
57349
|
+
text
|
|
57350
|
+
};
|
|
57351
|
+
}
|
|
57352
|
+
function toolCallLine(call) {
|
|
57353
|
+
const marker = call.ok === undefined ? "\xB7" : call.ok ? "\u2713" : "\u2717";
|
|
57354
|
+
return `${marker} ${call.name}${call.args === "" ? "" : ` ${call.args}`}`;
|
|
57355
|
+
}
|
|
57356
|
+
function turnDetailLines(turn) {
|
|
57357
|
+
const lines = [];
|
|
57358
|
+
const flags = [turn.endReason, ...turn.interrupted ? ["interrupted"] : []].join(" \xB7 ");
|
|
57359
|
+
lines.push(`turn #${turn.turn} \u2014 ${flags}`);
|
|
57360
|
+
if (turn.endError !== undefined)
|
|
57361
|
+
lines.push(`error: ${turn.endError}`);
|
|
57362
|
+
if (turn.userTexts.length > 0) {
|
|
57363
|
+
lines.push("");
|
|
57364
|
+
lines.push("prompt:");
|
|
57365
|
+
for (const text of turn.userTexts)
|
|
57366
|
+
lines.push(...text.split(`
|
|
57367
|
+
`));
|
|
57368
|
+
}
|
|
57369
|
+
if (turn.assistantTexts.length > 0) {
|
|
57370
|
+
lines.push("");
|
|
57371
|
+
lines.push("assistant:");
|
|
57372
|
+
for (const text of turn.assistantTexts)
|
|
57373
|
+
lines.push(...text.split(`
|
|
57374
|
+
`));
|
|
57375
|
+
}
|
|
57376
|
+
if (turn.toolCalls.length > 0) {
|
|
57377
|
+
lines.push("");
|
|
57378
|
+
lines.push(`tools \u2014 ${toolCallSummary(turn.toolCalls.map((call) => call.name))}`);
|
|
57379
|
+
for (const call of turn.toolCalls)
|
|
57380
|
+
lines.push(toolCallLine(call));
|
|
57381
|
+
}
|
|
57382
|
+
return lines;
|
|
57383
|
+
}
|
|
57384
|
+
function historyFailureText(prefix, error) {
|
|
57385
|
+
return `${prefix} failed \u2014 ${String(error instanceof Error ? error.message : error).slice(0, 150)}`;
|
|
57386
|
+
}
|
|
57387
|
+
function HistoryPanel(props) {
|
|
57388
|
+
const panels = usePanels();
|
|
57389
|
+
const kitTheme = usePanelTheme();
|
|
57390
|
+
const theme = useThemeOptional();
|
|
57391
|
+
const dimensions = useTerminalDimensions();
|
|
57392
|
+
const [open, setOpen] = useHistoryPanelOpenState();
|
|
57393
|
+
const [browsingId, setBrowsingId] = createSignal(undefined);
|
|
57394
|
+
const [turns, setTurns] = createSignal([]);
|
|
57395
|
+
const [cursor, setCursor] = createSignal(0);
|
|
57396
|
+
const [status, setStatus] = createSignal(undefined);
|
|
57397
|
+
const [busy, setBusy] = createSignal(false);
|
|
57398
|
+
const [sessions, setSessions] = createSignal([]);
|
|
57399
|
+
const [sessionCursor, setSessionCursor] = createSignal(0);
|
|
57400
|
+
const [showSessions, setShowSessions] = createSignal(false);
|
|
57401
|
+
let handle;
|
|
57402
|
+
let sequence = 0;
|
|
57403
|
+
let loadSequence = 0;
|
|
57404
|
+
const current = createMemo(() => turns()[cursor()]);
|
|
57405
|
+
const bodyWidth = createMemo(() => {
|
|
57406
|
+
const frame = Math.min(116, dimensions().width - 2);
|
|
57407
|
+
return Math.max(20, Math.max(1, frame - 4));
|
|
57408
|
+
});
|
|
57409
|
+
const leftWidth = createMemo(() => Math.max(12, Math.floor(bodyWidth() * 0.4) - 1));
|
|
57410
|
+
const rightWidth = createMemo(() => Math.max(12, bodyWidth() - leftWidth() - 1));
|
|
57411
|
+
const visibleWindow = createMemo(() => turnWindow(turns().length, cursor(), LIST_ROWS));
|
|
57412
|
+
const detail = createMemo(() => {
|
|
57413
|
+
const turn = current();
|
|
57414
|
+
return turn === undefined ? [] : turnDetailLines(turn);
|
|
57415
|
+
});
|
|
57416
|
+
async function load(sessionId) {
|
|
57417
|
+
const token = ++loadSequence;
|
|
57418
|
+
if (!sessionId) {
|
|
57419
|
+
setTurns([]);
|
|
57420
|
+
setStatus("no active session to browse");
|
|
57421
|
+
return;
|
|
57422
|
+
}
|
|
57423
|
+
if (!props.seam.sessionJournal) {
|
|
57424
|
+
setTurns([]);
|
|
57425
|
+
setStatus("history unavailable in this session (no journal face)");
|
|
57426
|
+
return;
|
|
57427
|
+
}
|
|
57428
|
+
setTurns([]);
|
|
57429
|
+
setCursor(0);
|
|
57430
|
+
setBusy(true);
|
|
57431
|
+
setStatus(undefined);
|
|
57432
|
+
try {
|
|
57433
|
+
const entries = await props.seam.sessionJournal(sessionId);
|
|
57434
|
+
if (token !== loadSequence)
|
|
57435
|
+
return;
|
|
57436
|
+
const folded = groupHistoryTurns(entries);
|
|
57437
|
+
setTurns(folded);
|
|
57438
|
+
setCursor(0);
|
|
57439
|
+
if (folded.length === 0)
|
|
57440
|
+
setStatus(`no completed turns in ${sessionId.slice(0, 8)}`);
|
|
57441
|
+
} catch (error) {
|
|
57442
|
+
if (token !== loadSequence)
|
|
57443
|
+
return;
|
|
57444
|
+
setTurns([]);
|
|
57445
|
+
setCursor(0);
|
|
57446
|
+
setStatus(historyFailureText("history load", error));
|
|
57447
|
+
} finally {
|
|
57448
|
+
if (token === loadSequence)
|
|
57449
|
+
setBusy(false);
|
|
57450
|
+
}
|
|
57451
|
+
}
|
|
57452
|
+
function finish() {
|
|
57453
|
+
setOpen(false);
|
|
57454
|
+
setShowSessions(false);
|
|
57455
|
+
setStatus(undefined);
|
|
57456
|
+
setTimeout(() => props.onClosed?.(), 3);
|
|
57457
|
+
}
|
|
57458
|
+
function close() {
|
|
57459
|
+
if (showSessions()) {
|
|
57460
|
+
panels.close();
|
|
57461
|
+
return;
|
|
57462
|
+
}
|
|
57463
|
+
handle?.close();
|
|
57464
|
+
}
|
|
57465
|
+
createEffect(() => {
|
|
57466
|
+
if (!bridgeOpen6())
|
|
57467
|
+
return;
|
|
57468
|
+
setBridgeOpen6(false);
|
|
57469
|
+
if (handle !== undefined)
|
|
57470
|
+
return;
|
|
57471
|
+
const target = props.sessionId();
|
|
57472
|
+
setBrowsingId(target);
|
|
57473
|
+
setTurns([]);
|
|
57474
|
+
setCursor(0);
|
|
57475
|
+
setStatus(undefined);
|
|
57476
|
+
setOpen(true);
|
|
57477
|
+
handle = panels.open(() => renderBrowser(), {
|
|
57478
|
+
id: `history-${++sequence}`,
|
|
57479
|
+
title: "History",
|
|
57480
|
+
size: "xlarge",
|
|
57481
|
+
onClose: () => {
|
|
57482
|
+
handle = undefined;
|
|
57483
|
+
finish();
|
|
57484
|
+
}
|
|
57485
|
+
});
|
|
57486
|
+
load(target);
|
|
57487
|
+
});
|
|
57488
|
+
function moveCursor(delta) {
|
|
57489
|
+
setCursor((index) => turnCursorStep(index, delta, turns().length));
|
|
57490
|
+
}
|
|
57491
|
+
function refill() {
|
|
57492
|
+
const verdict = refillOrNotice(current());
|
|
57493
|
+
if (verdict.kind === "notice") {
|
|
57494
|
+
setStatus(verdict.text);
|
|
57495
|
+
return;
|
|
57496
|
+
}
|
|
57497
|
+
props.onRefill?.(verdict.text);
|
|
57498
|
+
close();
|
|
57499
|
+
}
|
|
57500
|
+
function openSessions() {
|
|
57501
|
+
if (showSessions())
|
|
57502
|
+
return;
|
|
57503
|
+
(async () => {
|
|
57504
|
+
try {
|
|
57505
|
+
const rows = await props.seam.listSessions(30);
|
|
57506
|
+
setSessions(rows);
|
|
57507
|
+
setSessionCursor(0);
|
|
57508
|
+
setShowSessions(rows.length > 0);
|
|
57509
|
+
if (rows.length === 0) {
|
|
57510
|
+
setStatus("no stored sessions to switch to");
|
|
57511
|
+
return;
|
|
57512
|
+
}
|
|
57513
|
+
panels.open(() => renderSessions(), {
|
|
57514
|
+
id: `history-sessions-${++sequence}`,
|
|
57515
|
+
title: "Switch session",
|
|
57516
|
+
size: "xlarge",
|
|
57517
|
+
onClose: () => setShowSessions(false)
|
|
57518
|
+
});
|
|
57519
|
+
} catch (error) {
|
|
57520
|
+
setStatus(historyFailureText("session list", error));
|
|
57521
|
+
}
|
|
57522
|
+
})();
|
|
57523
|
+
}
|
|
57524
|
+
function pickSession(index) {
|
|
57525
|
+
const picked = sessions()[index];
|
|
57526
|
+
if (!picked)
|
|
57527
|
+
return;
|
|
57528
|
+
setShowSessions(false);
|
|
57529
|
+
panels.close();
|
|
57530
|
+
setBrowsingId(picked.id);
|
|
57531
|
+
load(picked.id);
|
|
57532
|
+
}
|
|
57533
|
+
function fork() {
|
|
57534
|
+
if (busy())
|
|
57535
|
+
return;
|
|
57536
|
+
const turn = current();
|
|
57537
|
+
const id = browsingId();
|
|
57538
|
+
if (!props.seam.forkSession) {
|
|
57539
|
+
setStatus("fork unavailable \u2014 press c to refill the prompt instead");
|
|
57540
|
+
return;
|
|
57541
|
+
}
|
|
57542
|
+
if (!turn || !id)
|
|
57543
|
+
return;
|
|
57544
|
+
setBusy(true);
|
|
57545
|
+
props.seam.forkSession(id, turn.seqEnd).then((forkedId) => {
|
|
57546
|
+
props.onForked?.(forkedId, turn.turn);
|
|
57547
|
+
close();
|
|
57548
|
+
}).catch((error) => {
|
|
57549
|
+
setStatus(historyFailureText("fork", error));
|
|
57550
|
+
}).finally(() => setBusy(false));
|
|
57551
|
+
}
|
|
57552
|
+
Keymap2.createLayer(() => {
|
|
57553
|
+
const top = panels.top;
|
|
57554
|
+
return {
|
|
57555
|
+
mode: "global",
|
|
57556
|
+
enabled: open() && handle !== undefined && top !== undefined && handle === top,
|
|
57557
|
+
priority: 2,
|
|
57558
|
+
commands: [{
|
|
57559
|
+
bind: "up,k",
|
|
57560
|
+
title: "History: previous turn",
|
|
57561
|
+
group: "History",
|
|
57562
|
+
run: () => moveCursor(-1)
|
|
57563
|
+
}, {
|
|
57564
|
+
bind: "down,j",
|
|
57565
|
+
title: "History: next turn",
|
|
57566
|
+
group: "History",
|
|
57567
|
+
run: () => moveCursor(1)
|
|
57568
|
+
}, {
|
|
57569
|
+
bind: "return,c",
|
|
57570
|
+
title: showSessions() ? "History: pick session" : "History: refill prompt",
|
|
57571
|
+
group: "History",
|
|
57572
|
+
run: () => showSessions() ? pickSession(sessionCursor()) : refill()
|
|
57573
|
+
}, {
|
|
57574
|
+
bind: "s",
|
|
57575
|
+
title: "History: switch session",
|
|
57576
|
+
group: "History",
|
|
57577
|
+
run: openSessions
|
|
57578
|
+
}, {
|
|
57579
|
+
bind: "f",
|
|
57580
|
+
title: "History: fork at turn",
|
|
57581
|
+
group: "History",
|
|
57582
|
+
run: fork
|
|
57583
|
+
}]
|
|
57584
|
+
};
|
|
57585
|
+
});
|
|
57586
|
+
Keymap2.createLayer(() => ({
|
|
57587
|
+
mode: "global",
|
|
57588
|
+
enabled: open() && showSessions(),
|
|
57589
|
+
priority: 3,
|
|
57590
|
+
commands: [{
|
|
57591
|
+
bind: "up,k",
|
|
57592
|
+
title: "History: previous session",
|
|
57593
|
+
group: "History",
|
|
57594
|
+
run: () => setSessionCursor((index) => turnCursorStep(index, -1, sessions().length))
|
|
57595
|
+
}, {
|
|
57596
|
+
bind: "down,j",
|
|
57597
|
+
title: "History: next session",
|
|
57598
|
+
group: "History",
|
|
57599
|
+
run: () => setSessionCursor((index) => turnCursorStep(index, 1, sessions().length))
|
|
57600
|
+
}, {
|
|
57601
|
+
bind: "return,c",
|
|
57602
|
+
title: "History: browse picked session",
|
|
57603
|
+
group: "History",
|
|
57604
|
+
run: () => pickSession(sessionCursor())
|
|
57605
|
+
}]
|
|
57606
|
+
}));
|
|
57607
|
+
function clip(text, width) {
|
|
57608
|
+
if (width <= 0)
|
|
57609
|
+
return "";
|
|
57610
|
+
return text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}\u2026`;
|
|
57611
|
+
}
|
|
57612
|
+
function renderBrowser() {
|
|
57613
|
+
const muted = theme?.text.muted ?? kitTheme().text.muted;
|
|
57614
|
+
const base = theme?.text.base ?? kitTheme().text.base;
|
|
57615
|
+
const accent = kitTheme().text.accent ?? base;
|
|
57616
|
+
return (() => {
|
|
57617
|
+
var _el$ = createElement("box");
|
|
57618
|
+
setProp(_el$, "flexDirection", "column");
|
|
57619
|
+
setProp(_el$, "flexGrow", 1);
|
|
57620
|
+
insert(_el$, createComponent2(PanelBody, {
|
|
57621
|
+
get children() {
|
|
57622
|
+
return createComponent2(Show, {
|
|
57623
|
+
get when() {
|
|
57624
|
+
return turns().length > 0;
|
|
57625
|
+
},
|
|
57626
|
+
get fallback() {
|
|
57627
|
+
return (() => {
|
|
57628
|
+
var _el$8 = createElement("text");
|
|
57629
|
+
setProp(_el$8, "fg", muted);
|
|
57630
|
+
setProp(_el$8, "wrapMode", "none");
|
|
57631
|
+
insert(_el$8, (() => {
|
|
57632
|
+
var _c$ = memo2(() => !!busy());
|
|
57633
|
+
return () => _c$() ? "loading turns\u2026" : status() ?? "no completed turns";
|
|
57634
|
+
})());
|
|
57635
|
+
return _el$8;
|
|
57636
|
+
})();
|
|
57637
|
+
},
|
|
57638
|
+
get children() {
|
|
57639
|
+
return [(() => {
|
|
57640
|
+
var _el$2 = createElement("box"), _el$3 = createElement("box"), _el$6 = createElement("box");
|
|
57641
|
+
insertNode(_el$2, _el$3);
|
|
57642
|
+
insertNode(_el$2, _el$6);
|
|
57643
|
+
setProp(_el$2, "flexDirection", "row");
|
|
57644
|
+
setProp(_el$2, "height", 13);
|
|
57645
|
+
setProp(_el$2, "flexShrink", 0);
|
|
57646
|
+
setProp(_el$3, "flexDirection", "column");
|
|
57647
|
+
setProp(_el$3, "flexShrink", 0);
|
|
57648
|
+
insert(_el$3, createComponent2(For, {
|
|
57649
|
+
get each() {
|
|
57650
|
+
return turns().slice(visibleWindow().start, visibleWindow().end);
|
|
57651
|
+
},
|
|
57652
|
+
children: (turn, index) => {
|
|
57653
|
+
const at = () => visibleWindow().start + index();
|
|
57654
|
+
return (() => {
|
|
57655
|
+
var _el$9 = createElement("box"), _el$0 = createElement("text");
|
|
57656
|
+
insertNode(_el$9, _el$0);
|
|
57657
|
+
setProp(_el$9, "height", 1);
|
|
57658
|
+
setProp(_el$9, "flexShrink", 0);
|
|
57659
|
+
setProp(_el$0, "wrapMode", "none");
|
|
57660
|
+
insert(_el$0, (() => {
|
|
57661
|
+
var _c$2 = memo2(() => at() === cursor());
|
|
57662
|
+
return () => _c$2() ? `\u203A ${turnRowText(turn, leftWidth() - 2)}` : ` ${turnRowText(turn, leftWidth() - 2)}`;
|
|
57663
|
+
})());
|
|
57664
|
+
effect((_$p) => setProp(_el$0, "fg", at() === cursor() ? accent : muted, _$p));
|
|
57665
|
+
return _el$9;
|
|
57666
|
+
})();
|
|
57667
|
+
}
|
|
57668
|
+
}), null);
|
|
57669
|
+
insert(_el$3, createComponent2(Show, {
|
|
57670
|
+
get when() {
|
|
57671
|
+
return turns().length > LIST_ROWS;
|
|
57672
|
+
},
|
|
57673
|
+
get children() {
|
|
57674
|
+
var _el$4 = createElement("box"), _el$5 = createElement("text");
|
|
57675
|
+
insertNode(_el$4, _el$5);
|
|
57676
|
+
setProp(_el$4, "height", 1);
|
|
57677
|
+
setProp(_el$4, "flexShrink", 0);
|
|
57678
|
+
setProp(_el$5, "fg", muted);
|
|
57679
|
+
setProp(_el$5, "wrapMode", "none");
|
|
57680
|
+
insert(_el$5, () => `${visibleWindow().start + 1}-${visibleWindow().end}/${turns().length}`);
|
|
57681
|
+
return _el$4;
|
|
57682
|
+
}
|
|
57683
|
+
}), null);
|
|
57684
|
+
setProp(_el$6, "flexGrow", 1);
|
|
57685
|
+
setProp(_el$6, "flexDirection", "column");
|
|
57686
|
+
insert(_el$6, createComponent2(For, {
|
|
57687
|
+
get each() {
|
|
57688
|
+
return detail().slice(0, LIST_ROWS);
|
|
57689
|
+
},
|
|
57690
|
+
children: (line) => (() => {
|
|
57691
|
+
var _el$1 = createElement("box"), _el$10 = createElement("text");
|
|
57692
|
+
insertNode(_el$1, _el$10);
|
|
57693
|
+
setProp(_el$1, "height", 1);
|
|
57694
|
+
setProp(_el$1, "flexShrink", 0);
|
|
57695
|
+
setProp(_el$10, "fg", base);
|
|
57696
|
+
setProp(_el$10, "wrapMode", "none");
|
|
57697
|
+
insert(_el$10, () => clip(line === "" ? " " : line, rightWidth()));
|
|
57698
|
+
return _el$1;
|
|
57699
|
+
})()
|
|
57700
|
+
}));
|
|
57701
|
+
effect((_$p) => setProp(_el$3, "width", leftWidth(), _$p));
|
|
57702
|
+
return _el$2;
|
|
57703
|
+
})(), createComponent2(Show, {
|
|
57704
|
+
get when() {
|
|
57705
|
+
return status() !== undefined;
|
|
57706
|
+
},
|
|
57707
|
+
get children() {
|
|
57708
|
+
var _el$7 = createElement("text");
|
|
57709
|
+
setProp(_el$7, "wrapMode", "none");
|
|
57710
|
+
insert(_el$7, () => clip(status(), bodyWidth()));
|
|
57711
|
+
effect((_$p) => setProp(_el$7, "fg", kitTheme().text.warning, _$p));
|
|
57712
|
+
return _el$7;
|
|
57713
|
+
}
|
|
57714
|
+
})];
|
|
57715
|
+
}
|
|
57716
|
+
});
|
|
57717
|
+
}
|
|
57718
|
+
}), null);
|
|
57719
|
+
insert(_el$, createComponent2(PanelActions, {
|
|
57720
|
+
hint: "\u2191\u2193 turn \xB7 enter/c refill \xB7 s session \xB7 f fork \xB7 esc close"
|
|
57721
|
+
}), null);
|
|
57722
|
+
return _el$;
|
|
57723
|
+
})();
|
|
57724
|
+
}
|
|
57725
|
+
function renderSessions() {
|
|
57726
|
+
const muted = theme?.text.muted ?? kitTheme().text.muted;
|
|
57727
|
+
const accent = kitTheme().text.accent ?? muted;
|
|
57728
|
+
return (() => {
|
|
57729
|
+
var _el$11 = createElement("box");
|
|
57730
|
+
setProp(_el$11, "flexDirection", "column");
|
|
57731
|
+
setProp(_el$11, "flexGrow", 1);
|
|
57732
|
+
insert(_el$11, createComponent2(PanelBody, {
|
|
57733
|
+
get children() {
|
|
57734
|
+
return createComponent2(For, {
|
|
57735
|
+
get each() {
|
|
57736
|
+
return sessions();
|
|
57737
|
+
},
|
|
57738
|
+
children: (row, index) => (() => {
|
|
57739
|
+
var _el$12 = createElement("box"), _el$13 = createElement("text");
|
|
57740
|
+
insertNode(_el$12, _el$13);
|
|
57741
|
+
setProp(_el$12, "height", 1);
|
|
57742
|
+
setProp(_el$12, "flexShrink", 0);
|
|
57743
|
+
setProp(_el$13, "wrapMode", "none");
|
|
57744
|
+
insert(_el$13, () => index() === sessionCursor() ? `\u203A ` : ` `, null);
|
|
57745
|
+
insert(_el$13, () => clip(row.title === "" ? row.id : row.title, bodyWidth() - 4), null);
|
|
57746
|
+
effect((_$p) => setProp(_el$13, "fg", index() === sessionCursor() ? accent : muted, _$p));
|
|
57747
|
+
return _el$12;
|
|
57748
|
+
})()
|
|
57749
|
+
});
|
|
57750
|
+
}
|
|
57751
|
+
}), null);
|
|
57752
|
+
insert(_el$11, createComponent2(PanelActions, {
|
|
57753
|
+
hint: "\u2191\u2193 session \xB7 enter browse \xB7 esc back"
|
|
57754
|
+
}), null);
|
|
57755
|
+
return _el$11;
|
|
57756
|
+
})();
|
|
57757
|
+
}
|
|
57758
|
+
}
|
|
57759
|
+
var bridgeOpen6, setBridgeOpen6, panelOpen7, setPanelOpen7, historyPanelOpen, LIST_ROWS = 12;
|
|
57760
|
+
var init_history_panel = __esm(() => {
|
|
57761
|
+
init_index_bun();
|
|
57762
|
+
init_index_bun();
|
|
57763
|
+
init_index_bun();
|
|
57764
|
+
init_index_bun();
|
|
57765
|
+
init_index_bun();
|
|
57766
|
+
init_index_bun();
|
|
57767
|
+
init_index_bun();
|
|
57768
|
+
init_server();
|
|
57769
|
+
init_index_bun();
|
|
57770
|
+
init_src2();
|
|
57771
|
+
init_keymap();
|
|
57772
|
+
init_theme3();
|
|
57773
|
+
[bridgeOpen6, setBridgeOpen6] = createSignal(false);
|
|
57774
|
+
[panelOpen7, setPanelOpen7] = createSignal(false);
|
|
57775
|
+
historyPanelOpen = panelOpen7;
|
|
57776
|
+
});
|
|
57777
|
+
|
|
57778
|
+
// ../tui-base/src/routes/session/subagents-viewer.tsx
|
|
57779
|
+
function openSubagentsViewer() {
|
|
57780
|
+
setBridgeOpen7(true);
|
|
57781
|
+
}
|
|
57782
|
+
function useSubagentsViewerOpenState() {
|
|
57783
|
+
onCleanup(() => setPanelOpen8(false));
|
|
57784
|
+
return [subagentsViewerOpen, setPanelOpen8];
|
|
57785
|
+
}
|
|
57786
|
+
function viewerRows(views) {
|
|
57787
|
+
const running = views.filter((view) => view.status === "running");
|
|
57788
|
+
const settled = views.filter((view) => view.status !== "running").sort((a, b) => (b.endedAt ?? 0) - (a.endedAt ?? 0)).slice(0, SETTLED_CAP);
|
|
57789
|
+
return [...running, ...settled];
|
|
57790
|
+
}
|
|
57791
|
+
function viewerRowText(view, roundCap, elapsedText) {
|
|
57792
|
+
const glyph = view.status === "running" ? "\u280B" : view.status === "completed" ? "\u2713" : view.status === "failed" ? "\u2717" : "\u2014";
|
|
57793
|
+
const stop = subagentHardStopGlyph(view);
|
|
57794
|
+
const label = `${stop ? `${stop} ` : ""}${titlecase(view.label)}`;
|
|
57795
|
+
const suffix = subagentMarkerSuffix(view);
|
|
57796
|
+
const cap = roundCap !== undefined && roundCap > 0 ? `/${roundCap}` : "";
|
|
57797
|
+
const elapsed = elapsedText !== undefined && elapsedText !== "" ? ` \xB7 ${elapsedText}` : "";
|
|
57798
|
+
const model = view.model !== undefined ? ` \xB7 ${view.model}` : "";
|
|
57799
|
+
return `${glyph} ${label} \xB7 rounds ${view.rounds}${cap}${elapsed}${model}${suffix ? ` ${suffix.trim()}` : ""}`;
|
|
57800
|
+
}
|
|
57801
|
+
function formatViewerElapsed(ms) {
|
|
57802
|
+
if (ms < 60000)
|
|
57803
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
57804
|
+
const total = Math.floor(ms / 1000);
|
|
57805
|
+
return `${Math.floor(total / 60)}m${String(total % 60).padStart(2, "0")}s`;
|
|
57806
|
+
}
|
|
57807
|
+
function rowElapsedText(view, now) {
|
|
57808
|
+
if (view.status === "running" && view.startedAt !== undefined) {
|
|
57809
|
+
return formatViewerElapsed(Math.max(0, now - view.startedAt));
|
|
57810
|
+
}
|
|
57811
|
+
if (view.elapsedSec !== undefined)
|
|
57812
|
+
return `${view.elapsedSec.toFixed(1)}s`;
|
|
57813
|
+
return;
|
|
57814
|
+
}
|
|
57815
|
+
function scrollTarget(delta, offset, lineCount, visible) {
|
|
57816
|
+
const maxScroll = Math.max(0, lineCount - visible);
|
|
57817
|
+
const start = Math.min(offset, maxScroll);
|
|
57818
|
+
return Math.max(0, Math.min(start + delta, maxScroll));
|
|
57819
|
+
}
|
|
57820
|
+
function transcriptWindow(lineCount, offset, visible) {
|
|
57821
|
+
const maxScroll = Math.max(0, lineCount - visible);
|
|
57822
|
+
const start = Math.max(0, Math.min(offset, maxScroll));
|
|
57823
|
+
return {
|
|
57824
|
+
start,
|
|
57825
|
+
end: Math.min(lineCount, start + visible),
|
|
57826
|
+
follow: start === maxScroll
|
|
57827
|
+
};
|
|
57828
|
+
}
|
|
57829
|
+
function steerEchoText(sent, label) {
|
|
57830
|
+
const agent = titlecase(label);
|
|
57831
|
+
return sent ? `steered ${agent.toLowerCase()}` : `steer rejected \u2014 ${agent} is not running`;
|
|
57832
|
+
}
|
|
57833
|
+
function stopAllSummary(stopped) {
|
|
57834
|
+
return stopped === 1 ? "stop requested \u2014 1 subagent" : `stop requested \u2014 ${stopped} subagents`;
|
|
57835
|
+
}
|
|
57836
|
+
function doublePressArmed(lastPress, now) {
|
|
57837
|
+
const gap = now - lastPress;
|
|
57838
|
+
return lastPress > 0 && gap >= MIN_DOUBLE_PRESS_GAP_MS && gap <= DOUBLE_PRESS_MS;
|
|
57839
|
+
}
|
|
57840
|
+
function SubagentsViewer(props) {
|
|
57841
|
+
const panels = usePanels();
|
|
57842
|
+
const kitTheme = usePanelTheme();
|
|
57843
|
+
const theme = useThemeOptional();
|
|
57844
|
+
const dialog = useDialog();
|
|
57845
|
+
const [open, setOpen] = useSubagentsViewerOpenState();
|
|
57846
|
+
const [views, setViews] = createSignal([]);
|
|
57847
|
+
const [cursor, setCursor] = createSignal(0);
|
|
57848
|
+
const [sortByRounds, setSortByRounds] = createSignal(false);
|
|
57849
|
+
const [browsingId, setBrowsingId] = createSignal(undefined);
|
|
57850
|
+
const [tick, setTick] = createSignal(0);
|
|
57851
|
+
const [scrollOffset, setScrollOffset] = createSignal(0);
|
|
57852
|
+
const [status, setStatus] = createSignal(undefined);
|
|
57853
|
+
let handle;
|
|
57854
|
+
let transcriptHandle;
|
|
57855
|
+
let sequence = 0;
|
|
57856
|
+
let lastXPress = 0;
|
|
57857
|
+
let tickTimer;
|
|
57858
|
+
let statusTimer;
|
|
57859
|
+
let stopAllLatch = false;
|
|
57860
|
+
onCleanup(() => {
|
|
57861
|
+
clearInterval(tickTimer);
|
|
57862
|
+
clearTimeout(statusTimer);
|
|
57863
|
+
});
|
|
57864
|
+
function refreshViews() {
|
|
57865
|
+
setViews(props.seam.subagentViews?.() ?? []);
|
|
57866
|
+
}
|
|
57867
|
+
function flash(message, autoClearMs) {
|
|
57868
|
+
clearTimeout(statusTimer);
|
|
57869
|
+
setStatus(message);
|
|
57870
|
+
if (autoClearMs !== undefined) {
|
|
57871
|
+
statusTimer = setTimeout(() => setStatus(undefined), autoClearMs);
|
|
57872
|
+
}
|
|
57873
|
+
}
|
|
57874
|
+
const rows = createMemo(() => {
|
|
57875
|
+
tick();
|
|
57876
|
+
const list = [...viewerRows(views())];
|
|
57877
|
+
if (sortByRounds())
|
|
57878
|
+
list.sort((a, b) => b.rounds - a.rounds);
|
|
57879
|
+
return list;
|
|
57880
|
+
});
|
|
57881
|
+
function moveCursor(delta) {
|
|
57882
|
+
const count = rows().length;
|
|
57883
|
+
if (count === 0)
|
|
57884
|
+
return;
|
|
57885
|
+
setCursor((index) => (index + delta + count) % count);
|
|
57886
|
+
}
|
|
57887
|
+
function stopAll() {
|
|
57888
|
+
const seam = props.seam;
|
|
57889
|
+
if (seam.interruptChild === undefined) {
|
|
57890
|
+
flash("stop unavailable \u2014 no interrupt face in this session");
|
|
57891
|
+
return;
|
|
57892
|
+
}
|
|
57893
|
+
const targets = views().filter((view) => view.status === "running");
|
|
57894
|
+
if (targets.length === 0) {
|
|
57895
|
+
stopAllLatch = false;
|
|
57896
|
+
flash("no running subagents to stop");
|
|
57897
|
+
return;
|
|
57898
|
+
}
|
|
57899
|
+
if (stopAllLatch) {
|
|
57900
|
+
flash(stopAllSummary(targets.length));
|
|
57901
|
+
return;
|
|
57902
|
+
}
|
|
57903
|
+
stopAllLatch = true;
|
|
57904
|
+
for (const target of targets) {
|
|
57905
|
+
seam.interruptChild(target.id).catch((error) => {
|
|
57906
|
+
flash(`stop failed \u2014 ${String(error instanceof Error ? error.message : error).slice(0, 120)}`);
|
|
57907
|
+
});
|
|
57908
|
+
}
|
|
57909
|
+
flash(stopAllSummary(targets.length));
|
|
57910
|
+
}
|
|
57911
|
+
const browsing = createMemo(() => views().find((view) => view.id === browsingId()));
|
|
57912
|
+
const transcript = createMemo(() => {
|
|
57913
|
+
tick();
|
|
57914
|
+
const id = browsingId();
|
|
57915
|
+
if (id === undefined)
|
|
57916
|
+
return [];
|
|
57917
|
+
const face = props.seam.subagentTranscript;
|
|
57918
|
+
if (face === undefined)
|
|
57919
|
+
return [];
|
|
57920
|
+
return face(id);
|
|
57921
|
+
});
|
|
57922
|
+
const window = createMemo(() => transcriptWindow(transcript().length, scrollOffset(), TRANSCRIPT_ROWS));
|
|
57923
|
+
function startTicking() {
|
|
57924
|
+
if (tickTimer !== undefined)
|
|
57925
|
+
return;
|
|
57926
|
+
tickTimer = setInterval(() => {
|
|
57927
|
+
try {
|
|
57928
|
+
refreshViews();
|
|
57929
|
+
setTick((n) => n + 1);
|
|
57930
|
+
} catch {}
|
|
57931
|
+
}, TRANSCRIPT_TICK_MS);
|
|
57932
|
+
}
|
|
57933
|
+
function stopTicking() {
|
|
57934
|
+
clearInterval(tickTimer);
|
|
57935
|
+
tickTimer = undefined;
|
|
57936
|
+
}
|
|
57937
|
+
function scrollBy(delta) {
|
|
57938
|
+
setScrollOffset((offset) => scrollTarget(delta, offset, transcript().length, TRANSCRIPT_ROWS));
|
|
57939
|
+
}
|
|
57940
|
+
function openTranscript(id) {
|
|
57941
|
+
setBrowsingId(id);
|
|
57942
|
+
setScrollOffset(Number.MAX_SAFE_INTEGER);
|
|
57943
|
+
lastXPress = 0;
|
|
57944
|
+
setStatus(undefined);
|
|
57945
|
+
transcriptHandle = panels.open(() => renderTranscript(), {
|
|
57946
|
+
id: `subagents-transcript-${++sequence}`,
|
|
57947
|
+
title: "Subagent transcript",
|
|
57948
|
+
size: "xlarge",
|
|
57949
|
+
onClose: () => {
|
|
57950
|
+
transcriptHandle = undefined;
|
|
57951
|
+
stopTicking();
|
|
57952
|
+
}
|
|
57953
|
+
});
|
|
57954
|
+
startTicking();
|
|
57955
|
+
}
|
|
57956
|
+
function openSteer() {
|
|
57957
|
+
const view = browsing();
|
|
57958
|
+
const id = browsingId();
|
|
57959
|
+
if (view === undefined || id === undefined)
|
|
57960
|
+
return;
|
|
57961
|
+
if (view.status !== "running") {
|
|
57962
|
+
flash("this subagent has ended \u2014 steering unavailable");
|
|
57963
|
+
return;
|
|
57964
|
+
}
|
|
57965
|
+
if (props.seam.steerChild === undefined) {
|
|
57966
|
+
flash("steer unavailable in this session");
|
|
57967
|
+
return;
|
|
57968
|
+
}
|
|
57969
|
+
const agent = titlecase(view.label);
|
|
57970
|
+
dialog.replace(() => createComponent2(DialogPrompt, {
|
|
57971
|
+
title: `Steer ${agent}`,
|
|
57972
|
+
placeholder: "Steer message",
|
|
57973
|
+
onConfirm: (value) => {
|
|
57974
|
+
const text = value.trim();
|
|
57975
|
+
dialog.clear();
|
|
57976
|
+
if (!text)
|
|
57977
|
+
return;
|
|
57978
|
+
const sent = props.seam.steerChild(id, text);
|
|
57979
|
+
flash(steerEchoText(sent, view.label));
|
|
57980
|
+
},
|
|
57981
|
+
onCancel: () => dialog.clear()
|
|
57982
|
+
}));
|
|
57983
|
+
}
|
|
57984
|
+
function stopChild() {
|
|
57985
|
+
const view = browsing();
|
|
57986
|
+
const id = browsingId();
|
|
57987
|
+
if (view === undefined || id === undefined)
|
|
57988
|
+
return;
|
|
57989
|
+
const now = Date.now();
|
|
57990
|
+
if (!doublePressArmed(lastXPress, now)) {
|
|
57991
|
+
lastXPress = now;
|
|
57992
|
+
flash("press x again to stop this subagent");
|
|
57993
|
+
return;
|
|
57994
|
+
}
|
|
57995
|
+
lastXPress = 0;
|
|
57996
|
+
if (view.status !== "running") {
|
|
57997
|
+
flash("nothing to stop \u2014 this subagent has ended");
|
|
57998
|
+
return;
|
|
57999
|
+
}
|
|
58000
|
+
const face = props.seam.interruptChild;
|
|
58001
|
+
if (face === undefined) {
|
|
58002
|
+
flash("stop unavailable \u2014 no interrupt face in this session");
|
|
58003
|
+
return;
|
|
58004
|
+
}
|
|
58005
|
+
face(id).then(() => flash(`stop requested \u2014 ${titlecase(view.label)}`)).catch((error) => {
|
|
58006
|
+
flash(`stop failed \u2014 ${String(error instanceof Error ? error.message : error).slice(0, 120)}`);
|
|
58007
|
+
});
|
|
58008
|
+
}
|
|
58009
|
+
function finish() {
|
|
58010
|
+
stopTicking();
|
|
58011
|
+
setOpen(false);
|
|
58012
|
+
setStatus(undefined);
|
|
58013
|
+
setTimeout(() => props.onClosed?.(), 3);
|
|
58014
|
+
}
|
|
58015
|
+
createEffect(() => {
|
|
58016
|
+
if (!bridgeOpen7())
|
|
58017
|
+
return;
|
|
58018
|
+
setBridgeOpen7(false);
|
|
58019
|
+
if (handle !== undefined)
|
|
58020
|
+
return;
|
|
58021
|
+
refreshViews();
|
|
58022
|
+
setCursor(0);
|
|
58023
|
+
setSortByRounds(false);
|
|
58024
|
+
setBrowsingId(undefined);
|
|
58025
|
+
setStatus(undefined);
|
|
58026
|
+
stopAllLatch = false;
|
|
58027
|
+
setOpen(true);
|
|
58028
|
+
handle = panels.open(() => renderList(), {
|
|
58029
|
+
id: `subagents-${++sequence}`,
|
|
58030
|
+
title: "Subagents",
|
|
58031
|
+
size: "xlarge",
|
|
58032
|
+
onClose: () => {
|
|
58033
|
+
handle = undefined;
|
|
58034
|
+
if (transcriptHandle === undefined)
|
|
58035
|
+
finish();
|
|
58036
|
+
}
|
|
58037
|
+
});
|
|
58038
|
+
});
|
|
58039
|
+
Keymap2.createLayer(() => {
|
|
58040
|
+
const top = panels.top;
|
|
58041
|
+
return {
|
|
58042
|
+
mode: "global",
|
|
58043
|
+
enabled: open() && transcriptHandle === undefined && handle !== undefined && handle === top && dialog.stack.length === 0,
|
|
58044
|
+
priority: 2,
|
|
58045
|
+
commands: [{
|
|
58046
|
+
bind: "up,k",
|
|
58047
|
+
title: "Subagents: previous child",
|
|
58048
|
+
group: "Subagents",
|
|
58049
|
+
run: () => moveCursor(-1)
|
|
58050
|
+
}, {
|
|
58051
|
+
bind: "down,j",
|
|
58052
|
+
title: "Subagents: next child",
|
|
58053
|
+
group: "Subagents",
|
|
58054
|
+
run: () => moveCursor(1)
|
|
58055
|
+
}, {
|
|
58056
|
+
bind: "return",
|
|
58057
|
+
title: "Subagents: open transcript",
|
|
58058
|
+
group: "Subagents",
|
|
58059
|
+
run: () => {
|
|
58060
|
+
const row = rows()[cursor()];
|
|
58061
|
+
if (row !== undefined)
|
|
58062
|
+
openTranscript(row.id);
|
|
58063
|
+
return true;
|
|
58064
|
+
}
|
|
58065
|
+
}, {
|
|
58066
|
+
bind: "s",
|
|
58067
|
+
title: "Subagents: sort by rounds",
|
|
58068
|
+
group: "Subagents",
|
|
58069
|
+
run: () => {
|
|
58070
|
+
setSortByRounds((value) => !value);
|
|
58071
|
+
return true;
|
|
58072
|
+
}
|
|
58073
|
+
}, {
|
|
58074
|
+
bind: "shift+k",
|
|
58075
|
+
title: "Subagents: stop all running",
|
|
58076
|
+
group: "Subagents",
|
|
58077
|
+
run: stopAll
|
|
58078
|
+
}]
|
|
58079
|
+
};
|
|
58080
|
+
});
|
|
58081
|
+
Keymap2.createLayer(() => {
|
|
58082
|
+
const top = panels.top;
|
|
58083
|
+
return {
|
|
58084
|
+
mode: "global",
|
|
58085
|
+
enabled: open() && transcriptHandle !== undefined && transcriptHandle === top && dialog.stack.length === 0,
|
|
58086
|
+
priority: 2,
|
|
58087
|
+
commands: [{
|
|
58088
|
+
bind: "up,k",
|
|
58089
|
+
title: "Transcript: scroll up",
|
|
58090
|
+
group: "Subagents",
|
|
58091
|
+
run: () => scrollBy(-1)
|
|
58092
|
+
}, {
|
|
58093
|
+
bind: "down,j",
|
|
58094
|
+
title: "Transcript: scroll down",
|
|
58095
|
+
group: "Subagents",
|
|
58096
|
+
run: () => scrollBy(1)
|
|
58097
|
+
}, {
|
|
58098
|
+
bind: "return",
|
|
58099
|
+
title: "Transcript: steer subagent",
|
|
58100
|
+
group: "Subagents",
|
|
58101
|
+
run: openSteer
|
|
58102
|
+
}, {
|
|
58103
|
+
bind: "x",
|
|
58104
|
+
title: "Transcript: press twice to stop",
|
|
58105
|
+
group: "Subagents",
|
|
58106
|
+
run: stopChild
|
|
58107
|
+
}]
|
|
58108
|
+
};
|
|
58109
|
+
});
|
|
58110
|
+
function clip(text, width) {
|
|
58111
|
+
if (width <= 0)
|
|
58112
|
+
return "";
|
|
58113
|
+
return text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}\u2026`;
|
|
58114
|
+
}
|
|
58115
|
+
const bodyWidth = 110;
|
|
58116
|
+
function headerText(view, now) {
|
|
58117
|
+
if (view === undefined)
|
|
58118
|
+
return "subagent";
|
|
58119
|
+
const status = view.status === "running" ? "running" : view.status === "completed" ? "completed" : view.status === "failed" ? "failed" : "cancelled";
|
|
58120
|
+
const elapsed = rowElapsedText(view, now);
|
|
58121
|
+
const parts = [`${titlecase(view.label)} \xB7 ${status} \xB7 rounds ${view.rounds}`];
|
|
58122
|
+
if (elapsed !== undefined)
|
|
58123
|
+
parts.push(elapsed);
|
|
58124
|
+
if (view.model !== undefined)
|
|
58125
|
+
parts.push(view.model);
|
|
58126
|
+
return clip(parts.join(" \xB7 "), bodyWidth);
|
|
58127
|
+
}
|
|
58128
|
+
function renderList() {
|
|
58129
|
+
const muted = theme?.text.muted ?? kitTheme().text.muted;
|
|
58130
|
+
const accent = kitTheme().text.accent ?? muted;
|
|
58131
|
+
const list = rows();
|
|
58132
|
+
const start = Math.max(0, Math.min(cursor() - LIST_ROWS2 + 1, Math.max(0, list.length - LIST_ROWS2)));
|
|
58133
|
+
return (() => {
|
|
58134
|
+
var _el$ = createElement("box");
|
|
58135
|
+
setProp(_el$, "flexDirection", "column");
|
|
58136
|
+
setProp(_el$, "flexGrow", 1);
|
|
58137
|
+
insert(_el$, createComponent2(PanelBody, {
|
|
58138
|
+
get children() {
|
|
58139
|
+
return [createComponent2(Show, {
|
|
58140
|
+
get when() {
|
|
58141
|
+
return list.length > 0;
|
|
58142
|
+
},
|
|
58143
|
+
get fallback() {
|
|
58144
|
+
return (() => {
|
|
58145
|
+
var _el$3 = createElement("text");
|
|
58146
|
+
insertNode(_el$3, createTextNode(`no subagents in this session \u2014 spawn one and it shows up here`));
|
|
58147
|
+
setProp(_el$3, "fg", muted);
|
|
58148
|
+
setProp(_el$3, "wrapMode", "none");
|
|
58149
|
+
return _el$3;
|
|
58150
|
+
})();
|
|
58151
|
+
},
|
|
58152
|
+
get children() {
|
|
58153
|
+
return createComponent2(For, {
|
|
58154
|
+
get each() {
|
|
58155
|
+
return list.slice(start, start + LIST_ROWS2);
|
|
58156
|
+
},
|
|
58157
|
+
children: (row, index) => {
|
|
58158
|
+
const at = () => start + index();
|
|
58159
|
+
return (() => {
|
|
58160
|
+
var _el$5 = createElement("box"), _el$6 = createElement("text");
|
|
58161
|
+
insertNode(_el$5, _el$6);
|
|
58162
|
+
setProp(_el$5, "height", 1);
|
|
58163
|
+
setProp(_el$5, "flexShrink", 0);
|
|
58164
|
+
setProp(_el$6, "wrapMode", "none");
|
|
58165
|
+
insert(_el$6, () => clipToWidth(`${at() === cursor() ? "\u203A " : " "}${viewerRowText(row, undefined, rowElapsedText(row, Date.now()))}`, bodyWidth));
|
|
58166
|
+
effect((_$p) => setProp(_el$6, "fg", at() === cursor() ? accent : muted, _$p));
|
|
58167
|
+
return _el$5;
|
|
58168
|
+
})();
|
|
58169
|
+
}
|
|
58170
|
+
});
|
|
58171
|
+
}
|
|
58172
|
+
}), createComponent2(Show, {
|
|
58173
|
+
get when() {
|
|
58174
|
+
return status() !== undefined;
|
|
58175
|
+
},
|
|
58176
|
+
get children() {
|
|
58177
|
+
var _el$2 = createElement("text");
|
|
58178
|
+
setProp(_el$2, "wrapMode", "none");
|
|
58179
|
+
insert(_el$2, () => clip(status(), bodyWidth));
|
|
58180
|
+
effect((_$p) => setProp(_el$2, "fg", kitTheme().text.warning, _$p));
|
|
58181
|
+
return _el$2;
|
|
58182
|
+
}
|
|
58183
|
+
})];
|
|
58184
|
+
}
|
|
58185
|
+
}), null);
|
|
58186
|
+
insert(_el$, createComponent2(PanelActions, {
|
|
58187
|
+
get hint() {
|
|
58188
|
+
return sortByRounds() ? "\u2191\u2193 select \xB7 enter transcript \xB7 s start order \xB7 shift+k stop all \xB7 esc close" : "\u2191\u2193 select \xB7 enter transcript \xB7 s sort by rounds \xB7 shift+k stop all \xB7 esc close";
|
|
58189
|
+
}
|
|
58190
|
+
}), null);
|
|
58191
|
+
return _el$;
|
|
58192
|
+
})();
|
|
58193
|
+
}
|
|
58194
|
+
function renderTranscript() {
|
|
58195
|
+
const muted = theme?.text.muted ?? kitTheme().text.muted;
|
|
58196
|
+
const base = theme?.text.base ?? kitTheme().text.base;
|
|
58197
|
+
const view = browsing();
|
|
58198
|
+
const facePresent = props.seam.subagentTranscript !== undefined;
|
|
58199
|
+
const lines = transcript();
|
|
58200
|
+
const win = window();
|
|
58201
|
+
return (() => {
|
|
58202
|
+
var _el$7 = createElement("box");
|
|
58203
|
+
setProp(_el$7, "flexDirection", "column");
|
|
58204
|
+
setProp(_el$7, "flexGrow", 1);
|
|
58205
|
+
insert(_el$7, createComponent2(PanelBody, {
|
|
58206
|
+
get children() {
|
|
58207
|
+
return [(() => {
|
|
58208
|
+
var _el$8 = createElement("text");
|
|
58209
|
+
setProp(_el$8, "wrapMode", "none");
|
|
58210
|
+
insert(_el$8, () => clipToWidth(headerText(view, Date.now()), bodyWidth));
|
|
58211
|
+
effect((_$p) => setProp(_el$8, "fg", kitTheme().text.accent ?? base, _$p));
|
|
58212
|
+
return _el$8;
|
|
58213
|
+
})(), createComponent2(Show, {
|
|
58214
|
+
when: facePresent,
|
|
58215
|
+
get fallback() {
|
|
58216
|
+
return (() => {
|
|
58217
|
+
var _el$10 = createElement("text");
|
|
58218
|
+
insertNode(_el$10, createTextNode(`transcript unavailable in this session (no subagent transcript face)`));
|
|
58219
|
+
setProp(_el$10, "fg", muted);
|
|
58220
|
+
setProp(_el$10, "wrapMode", "none");
|
|
58221
|
+
return _el$10;
|
|
58222
|
+
})();
|
|
58223
|
+
},
|
|
58224
|
+
get children() {
|
|
58225
|
+
return createComponent2(Show, {
|
|
58226
|
+
get when() {
|
|
58227
|
+
return lines.length > 0;
|
|
58228
|
+
},
|
|
58229
|
+
get fallback() {
|
|
58230
|
+
return (() => {
|
|
58231
|
+
var _el$12 = createElement("text");
|
|
58232
|
+
insertNode(_el$12, createTextNode(`no activity yet \u2014 the child's events land here live`));
|
|
58233
|
+
setProp(_el$12, "fg", muted);
|
|
58234
|
+
setProp(_el$12, "wrapMode", "none");
|
|
58235
|
+
return _el$12;
|
|
58236
|
+
})();
|
|
58237
|
+
},
|
|
58238
|
+
get children() {
|
|
58239
|
+
return [createComponent2(For, {
|
|
58240
|
+
get each() {
|
|
58241
|
+
return lines.slice(win.start, win.end);
|
|
58242
|
+
},
|
|
58243
|
+
children: (line) => (() => {
|
|
58244
|
+
var _el$14 = createElement("box"), _el$15 = createElement("text");
|
|
58245
|
+
insertNode(_el$14, _el$15);
|
|
58246
|
+
setProp(_el$14, "height", 1);
|
|
58247
|
+
setProp(_el$14, "flexShrink", 0);
|
|
58248
|
+
setProp(_el$15, "fg", base);
|
|
58249
|
+
setProp(_el$15, "wrapMode", "none");
|
|
58250
|
+
insert(_el$15, () => clipToWidth(line === "" ? " " : line, bodyWidth));
|
|
58251
|
+
return _el$14;
|
|
58252
|
+
})()
|
|
58253
|
+
}), createComponent2(Show, {
|
|
58254
|
+
get when() {
|
|
58255
|
+
return lines.length > TRANSCRIPT_ROWS;
|
|
58256
|
+
},
|
|
58257
|
+
get children() {
|
|
58258
|
+
var _el$9 = createElement("box"), _el$0 = createElement("text");
|
|
58259
|
+
insertNode(_el$9, _el$0);
|
|
58260
|
+
setProp(_el$9, "height", 1);
|
|
58261
|
+
setProp(_el$9, "flexShrink", 0);
|
|
58262
|
+
setProp(_el$0, "fg", muted);
|
|
58263
|
+
setProp(_el$0, "wrapMode", "none");
|
|
58264
|
+
insert(_el$0, () => `${win.start + 1}-${win.end}/${lines.length}${win.follow ? " (following)" : " (detached \u2014 scroll to the bottom to re-follow)"}`);
|
|
58265
|
+
return _el$9;
|
|
58266
|
+
}
|
|
58267
|
+
})];
|
|
58268
|
+
}
|
|
58269
|
+
});
|
|
58270
|
+
}
|
|
58271
|
+
}), createComponent2(Show, {
|
|
58272
|
+
get when() {
|
|
58273
|
+
return status() !== undefined;
|
|
58274
|
+
},
|
|
58275
|
+
get children() {
|
|
58276
|
+
var _el$1 = createElement("text");
|
|
58277
|
+
setProp(_el$1, "wrapMode", "none");
|
|
58278
|
+
insert(_el$1, () => clip(status(), bodyWidth));
|
|
58279
|
+
effect((_$p) => setProp(_el$1, "fg", kitTheme().text.warning, _$p));
|
|
58280
|
+
return _el$1;
|
|
58281
|
+
}
|
|
58282
|
+
})];
|
|
58283
|
+
}
|
|
58284
|
+
}), null);
|
|
58285
|
+
insert(_el$7, createComponent2(PanelActions, {
|
|
58286
|
+
hint: "\u2191\u2193 scroll \xB7 enter steer \xB7 x\xD72 stop \xB7 esc back"
|
|
58287
|
+
}), null);
|
|
58288
|
+
return _el$7;
|
|
58289
|
+
})();
|
|
58290
|
+
}
|
|
58291
|
+
if (props.seam.onSubagentViews) {
|
|
58292
|
+
onCleanup(props.seam.onSubagentViews((next) => {
|
|
58293
|
+
setViews(next);
|
|
58294
|
+
}));
|
|
58295
|
+
}
|
|
58296
|
+
}
|
|
58297
|
+
var LIST_ROWS2 = 12, SETTLED_CAP = 5, TRANSCRIPT_TICK_MS = 500, TRANSCRIPT_ROWS = 14, DOUBLE_PRESS_MS = 600, MIN_DOUBLE_PRESS_GAP_MS = 80, bridgeOpen7, setBridgeOpen7, panelOpen8, setPanelOpen8, subagentsViewerOpen;
|
|
58298
|
+
var init_subagents_viewer = __esm(() => {
|
|
58299
|
+
init_index_bun();
|
|
58300
|
+
init_index_bun();
|
|
58301
|
+
init_index_bun();
|
|
58302
|
+
init_index_bun();
|
|
58303
|
+
init_index_bun();
|
|
58304
|
+
init_index_bun();
|
|
58305
|
+
init_index_bun();
|
|
58306
|
+
init_index_bun();
|
|
58307
|
+
init_server();
|
|
58308
|
+
init_src2();
|
|
58309
|
+
init_keymap();
|
|
58310
|
+
init_dialog();
|
|
58311
|
+
init_dialog_prompt();
|
|
58312
|
+
init_theme3();
|
|
58313
|
+
init_locale();
|
|
58314
|
+
init_tool_summarize();
|
|
58315
|
+
init_subagent_markers();
|
|
58316
|
+
[bridgeOpen7, setBridgeOpen7] = createSignal(false);
|
|
58317
|
+
[panelOpen8, setPanelOpen8] = createSignal(false);
|
|
58318
|
+
subagentsViewerOpen = panelOpen8;
|
|
58319
|
+
});
|
|
58320
|
+
|
|
55561
58321
|
// ../tui-base/src/routes/session/settings-modal.tsx
|
|
55562
|
-
import { TextAttributes as
|
|
58322
|
+
import { TextAttributes as TextAttributes12 } from "@opentui/core";
|
|
55563
58323
|
function resolveVersion() {
|
|
55564
58324
|
try {
|
|
55565
|
-
return "0.
|
|
58325
|
+
return "0.13.1";
|
|
55566
58326
|
} catch {
|
|
55567
58327
|
return "dev";
|
|
55568
58328
|
}
|
|
@@ -56464,7 +59224,7 @@ function SettingsModalBody(props) {
|
|
|
56464
59224
|
}
|
|
56465
59225
|
}), null);
|
|
56466
59226
|
effect((_p$) => {
|
|
56467
|
-
var _v$ = chrome().navBand, _v$2 = chrome().divider, _v$3 = contentBg(), _v$4 = chrome().titleBand, _v$5 =
|
|
59227
|
+
var _v$ = chrome().navBand, _v$2 = chrome().divider, _v$3 = contentBg(), _v$4 = chrome().titleBand, _v$5 = TextAttributes12.BOLD, _v$6 = role(theme().text.heading);
|
|
56468
59228
|
_v$ !== _p$.e && (_p$.e = setProp(_el$3, "backgroundColor", _v$, _p$.e));
|
|
56469
59229
|
_v$2 !== _p$.t && (_p$.t = setProp(_el$4, "backgroundColor", _v$2, _p$.t));
|
|
56470
59230
|
_v$3 !== _p$.a && (_p$.a = setProp(_el$5, "backgroundColor", _v$3, _p$.a));
|
|
@@ -56809,7 +59569,7 @@ var init_settings_modal = __esm(() => {
|
|
|
56809
59569
|
plugins: {
|
|
56810
59570
|
command: "/plugins",
|
|
56811
59571
|
label: "\u6253\u5F00 /plugins",
|
|
56812
|
-
note: "\u63D2\u4EF6\u6E05\u5355\u4E0E\u542F\u505C\u7531 /plugins \u9762\u677F\u627F\u62C5"
|
|
59572
|
+
note: "\u63D2\u4EF6\u6E05\u5355\u4E0E\u542F\u505C\u7531 /plugins \u9762\u677F\u627F\u62C5\uFF1Aenter/space \u542F\u505C\u3001d \u5378\u8F7D\uFF08\u786E\u8BA4\uFF09\u3001i \u5B89\u88C5\uFF1B\u90E8\u5206\u53D8\u66F4\u9700\u91CD\u542F\u5BBF\u4E3B\u751F\u6548"
|
|
56813
59573
|
},
|
|
56814
59574
|
presets: {
|
|
56815
59575
|
command: "/preset",
|
|
@@ -57130,7 +59890,7 @@ function ensureContrast(foreground, background, min = 4.5, fallback = foreground
|
|
|
57130
59890
|
}
|
|
57131
59891
|
|
|
57132
59892
|
// ../tui-base/src/context/panel-kit-host.tsx
|
|
57133
|
-
import { RGBA as RGBA15, TextAttributes as
|
|
59893
|
+
import { RGBA as RGBA15, TextAttributes as TextAttributes13 } from "@opentui/core";
|
|
57134
59894
|
function projectPanelTheme(theme) {
|
|
57135
59895
|
const primary = theme.text.action.primary;
|
|
57136
59896
|
const raised = theme.background.raised;
|
|
@@ -57179,11 +59939,11 @@ function projectPanelTheme(theme) {
|
|
|
57179
59939
|
}
|
|
57180
59940
|
},
|
|
57181
59941
|
attributes: {
|
|
57182
|
-
title:
|
|
57183
|
-
group:
|
|
57184
|
-
selected:
|
|
57185
|
-
keyHint:
|
|
57186
|
-
subtitle:
|
|
59942
|
+
title: TextAttributes13.BOLD,
|
|
59943
|
+
group: TextAttributes13.BOLD,
|
|
59944
|
+
selected: TextAttributes13.BOLD,
|
|
59945
|
+
keyHint: TextAttributes13.DIM,
|
|
59946
|
+
subtitle: TextAttributes13.DIM
|
|
57187
59947
|
},
|
|
57188
59948
|
identity: [theme.hue.accent[500], theme.hue.accent[300]]
|
|
57189
59949
|
};
|
|
@@ -57491,6 +60251,12 @@ class RemoteSessionSeam {
|
|
|
57491
60251
|
async searchSessions(query) {
|
|
57492
60252
|
return this.#session.searchSessions(query);
|
|
57493
60253
|
}
|
|
60254
|
+
async sessionJournal(sessionId) {
|
|
60255
|
+
return this.#session.sessionJournal(sessionId);
|
|
60256
|
+
}
|
|
60257
|
+
async forkSession(sessionId, seqEnd) {
|
|
60258
|
+
return this.#session.forkSession(sessionId, seqEnd);
|
|
60259
|
+
}
|
|
57494
60260
|
async storedTranscript(id, skip) {
|
|
57495
60261
|
const rows = await this.#session.storedTranscript(id, skip);
|
|
57496
60262
|
return rows.map((row) => {
|
|
@@ -57515,6 +60281,9 @@ class RemoteSessionSeam {
|
|
|
57515
60281
|
currentSessionId() {
|
|
57516
60282
|
return this.#session.currentSessionId();
|
|
57517
60283
|
}
|
|
60284
|
+
stagedSessionId() {
|
|
60285
|
+
return this.#session.stagedSessionId();
|
|
60286
|
+
}
|
|
57518
60287
|
cacheHitRate(mode) {
|
|
57519
60288
|
return this.#session.cacheHitRate(mode);
|
|
57520
60289
|
}
|
|
@@ -57558,6 +60327,12 @@ class RemoteSessionSeam {
|
|
|
57558
60327
|
resumeSession(id) {
|
|
57559
60328
|
return this.#session.resumeSession(id);
|
|
57560
60329
|
}
|
|
60330
|
+
repairScanBroken() {
|
|
60331
|
+
return this.#session.repairScanBroken();
|
|
60332
|
+
}
|
|
60333
|
+
repairSessionLog(path) {
|
|
60334
|
+
return this.#session.repairSessionLog(path);
|
|
60335
|
+
}
|
|
57561
60336
|
newSession() {
|
|
57562
60337
|
this.#session.newSession();
|
|
57563
60338
|
}
|
|
@@ -57671,6 +60446,22 @@ class RemoteSessionSeam {
|
|
|
57671
60446
|
this.#pluginsRevision[0]();
|
|
57672
60447
|
return this.#session.listPlugins();
|
|
57673
60448
|
}
|
|
60449
|
+
pluginBundles() {
|
|
60450
|
+
this.#pluginsRevision[0]();
|
|
60451
|
+
return this.#session.listBundles();
|
|
60452
|
+
}
|
|
60453
|
+
setPluginBundleEnabled(name, enabled) {
|
|
60454
|
+
return this.#session.setBundleEnabled(name, enabled);
|
|
60455
|
+
}
|
|
60456
|
+
removePluginBundle(name) {
|
|
60457
|
+
return this.#session.removeBundle(name);
|
|
60458
|
+
}
|
|
60459
|
+
inspectPluginSpec(spec) {
|
|
60460
|
+
return this.#session.inspectBundle(spec);
|
|
60461
|
+
}
|
|
60462
|
+
installPluginSpec(spec) {
|
|
60463
|
+
return this.#session.installBundle(spec);
|
|
60464
|
+
}
|
|
57674
60465
|
async refreshSkills() {
|
|
57675
60466
|
return this.#session.refreshSkills();
|
|
57676
60467
|
}
|
|
@@ -57734,13 +60525,20 @@ class RemoteSessionSeam {
|
|
|
57734
60525
|
login: (ref, apiKey) => this.#session.login(ref, apiKey),
|
|
57735
60526
|
logout: (ref) => this.#session.logout(ref),
|
|
57736
60527
|
routes: async () => {
|
|
57737
|
-
|
|
57738
|
-
|
|
57739
|
-
|
|
57740
|
-
|
|
57741
|
-
|
|
57742
|
-
|
|
57743
|
-
|
|
60528
|
+
const rows = await this.#session.settingsSeam.describe();
|
|
60529
|
+
const ns = Array.isArray(rows) ? rows.find((row) => row?.ns === "llm-pi-ai") : undefined;
|
|
60530
|
+
const providers = ns?.value?.providers ?? {};
|
|
60531
|
+
return Object.entries(providers).map(([id, profile]) => {
|
|
60532
|
+
const p = typeof profile === "object" && profile !== null ? profile : {};
|
|
60533
|
+
const apiKeyEnv = p.apiKeyEnv;
|
|
60534
|
+
const displayName = p.displayName;
|
|
60535
|
+
return {
|
|
60536
|
+
id,
|
|
60537
|
+
...typeof apiKeyEnv === "string" && apiKeyEnv !== "" ? { apiKeyEnv } : {},
|
|
60538
|
+
...typeof displayName === "string" && displayName !== "" ? { displayName } : {},
|
|
60539
|
+
...typeof p.api === "string" || typeof p.baseURL === "string" || Array.isArray(p.models) ? { declared: true } : {}
|
|
60540
|
+
};
|
|
60541
|
+
});
|
|
57744
60542
|
},
|
|
57745
60543
|
registerRoute: async (providerId, profile) => {
|
|
57746
60544
|
try {
|
|
@@ -57763,6 +60561,7 @@ class RemoteSessionSeam {
|
|
|
57763
60561
|
status: v.status,
|
|
57764
60562
|
rounds: v.rounds,
|
|
57765
60563
|
...v.startedAt !== undefined ? v.status === "running" ? { startedAt: v.startedAt } : { elapsedSec: Number(((Date.now() - v.startedAt) / 1000).toFixed(1)) } : {},
|
|
60564
|
+
...v.status !== "running" && v.endedAt !== undefined ? { endedAt: v.endedAt } : {},
|
|
57766
60565
|
...v.injectedRound !== undefined ? { injectedRound: v.injectedRound } : {},
|
|
57767
60566
|
...v.hardStopRound !== undefined ? { hardStopRound: v.hardStopRound } : {},
|
|
57768
60567
|
...v.spinStopRound !== undefined ? { spinStopRound: v.spinStopRound } : {},
|
|
@@ -57783,6 +60582,12 @@ class RemoteSessionSeam {
|
|
|
57783
60582
|
steerChild(id, text) {
|
|
57784
60583
|
return this.#session.steerChild(id, text);
|
|
57785
60584
|
}
|
|
60585
|
+
subagentTranscript(id) {
|
|
60586
|
+
return this.#session.childTranscript(id);
|
|
60587
|
+
}
|
|
60588
|
+
async interruptChild(id) {
|
|
60589
|
+
await this.#session.interruptChild(id);
|
|
60590
|
+
}
|
|
57786
60591
|
onSessionEvent(listener) {
|
|
57787
60592
|
this.#listeners.push(listener);
|
|
57788
60593
|
this.#ensureJournalFeed();
|
|
@@ -57824,7 +60629,7 @@ class RemoteSessionSeam {
|
|
|
57824
60629
|
}
|
|
57825
60630
|
function projectJournalRecord(entry, sessionId) {
|
|
57826
60631
|
if (entry.type === "user/message") {
|
|
57827
|
-
const text =
|
|
60632
|
+
const text = blocksText3(entry.data.content);
|
|
57828
60633
|
if (!text)
|
|
57829
60634
|
return [];
|
|
57830
60635
|
const id = typeof entry.data.messageID === "string" ? entry.data.messageID : `journal-${entry.seq}`;
|
|
@@ -57858,7 +60663,7 @@ function projectJournalRecord(entry, sessionId) {
|
|
|
57858
60663
|
}
|
|
57859
60664
|
return [];
|
|
57860
60665
|
}
|
|
57861
|
-
function
|
|
60666
|
+
function blocksText3(content) {
|
|
57862
60667
|
const blocks = Array.isArray(content) ? content : [];
|
|
57863
60668
|
let text = "";
|
|
57864
60669
|
for (const block of blocks) {
|
|
@@ -57874,7 +60679,7 @@ function blocksText2(content) {
|
|
|
57874
60679
|
function assistantTextValue(data) {
|
|
57875
60680
|
if (typeof data.text === "string")
|
|
57876
60681
|
return data.text.trim();
|
|
57877
|
-
return
|
|
60682
|
+
return blocksText3(data.content ?? data.parts);
|
|
57878
60683
|
}
|
|
57879
60684
|
function asSeamSettingsRow(row) {
|
|
57880
60685
|
return {
|
|
@@ -57897,6 +60702,7 @@ var init_session_seam_adapter = __esm(() => {
|
|
|
57897
60702
|
});
|
|
57898
60703
|
|
|
57899
60704
|
// ../tui-base/examples/v2-entry.tsx
|
|
60705
|
+
import { join as join10 } from "path";
|
|
57900
60706
|
async function loadShell() {
|
|
57901
60707
|
const [shared, lifecycle, transport, rhs, adapter, git] = await Promise.all([
|
|
57902
60708
|
Promise.resolve().then(() => (init_boot_shared(), exports_boot_shared)),
|
|
@@ -58081,7 +60887,7 @@ function V2SessionPage(props) {
|
|
|
58081
60887
|
mode: themeService.mode()
|
|
58082
60888
|
});
|
|
58083
60889
|
let cmdOrdinal = 0;
|
|
58084
|
-
const pickOne = (title, options, headerLine, currentValue) => new Promise((resolvePick) => {
|
|
60890
|
+
const pickOne = (title, options, headerLine, currentValue, extras) => new Promise((resolvePick) => {
|
|
58085
60891
|
let settled = false;
|
|
58086
60892
|
const done = (value) => {
|
|
58087
60893
|
if (settled)
|
|
@@ -58090,14 +60896,38 @@ function V2SessionPage(props) {
|
|
|
58090
60896
|
dialog.clear();
|
|
58091
60897
|
resolvePick(value);
|
|
58092
60898
|
};
|
|
60899
|
+
const [extrasTick, bumpExtrasTick] = createSignal(0);
|
|
60900
|
+
const actions = extras?.actions?.map((action) => ({
|
|
60901
|
+
command: action.command,
|
|
60902
|
+
title: typeof action.title === "function" ? (option) => action.title(option === undefined ? undefined : String(option.value)) : action.title,
|
|
60903
|
+
bind: action.bind,
|
|
60904
|
+
disabled: action.disabled ? (option) => option === undefined ? false : action.disabled(String(option.value)) : undefined,
|
|
60905
|
+
onTrigger: (option) => {
|
|
60906
|
+
extras.onAction?.(action.command, String(option.value));
|
|
60907
|
+
bumpExtrasTick((n) => n + 1);
|
|
60908
|
+
}
|
|
60909
|
+
}));
|
|
58093
60910
|
dialog.replace(() => createComponent2(DialogSelect, {
|
|
58094
60911
|
title,
|
|
58095
60912
|
renderFilter: false,
|
|
58096
|
-
|
|
58097
|
-
|
|
58098
|
-
|
|
58099
|
-
|
|
58100
|
-
|
|
60913
|
+
get options() {
|
|
60914
|
+
if (extras?.getOptions === undefined) {
|
|
60915
|
+
return options.map((option) => ({
|
|
60916
|
+
title: option.title,
|
|
60917
|
+
value: option.value,
|
|
60918
|
+
description: option.description
|
|
60919
|
+
}));
|
|
60920
|
+
}
|
|
60921
|
+
extrasTick();
|
|
60922
|
+
return extras.getOptions().map((option) => ({
|
|
60923
|
+
title: option.title,
|
|
60924
|
+
value: option.value,
|
|
60925
|
+
description: option.description,
|
|
60926
|
+
category: option.category
|
|
60927
|
+
}));
|
|
60928
|
+
},
|
|
60929
|
+
...actions && actions.length > 0 ? { actions } : {},
|
|
60930
|
+
...extras ? { preserveSelection: true } : {},
|
|
58101
60931
|
current: currentValue,
|
|
58102
60932
|
focusCurrent: false,
|
|
58103
60933
|
onSelect: (option) => done(option.value),
|
|
@@ -58163,6 +60993,26 @@ function V2SessionPage(props) {
|
|
|
58163
60993
|
}
|
|
58164
60994
|
})
|
|
58165
60995
|
};
|
|
60996
|
+
const reloadSession = (sessionId) => {
|
|
60997
|
+
setLastRequest(undefined);
|
|
60998
|
+
composerRef?.resetDeliveries();
|
|
60999
|
+
setComposerPending([]);
|
|
61000
|
+
setTools(0);
|
|
61001
|
+
resetSkinLineFades();
|
|
61002
|
+
const settled = projection.load(sessionId);
|
|
61003
|
+
seam.currentModelSelection().then(setModel);
|
|
61004
|
+
refreshFooterData();
|
|
61005
|
+
refreshPresetLabel();
|
|
61006
|
+
setSkillRows(props.skills ?? []);
|
|
61007
|
+
setContextRevision((n) => n + 1);
|
|
61008
|
+
return settled;
|
|
61009
|
+
};
|
|
61010
|
+
const resumeFromSearch = async (sessionId) => {
|
|
61011
|
+
await seam.storedTranscript(sessionId);
|
|
61012
|
+
seam.resumeSession(sessionId);
|
|
61013
|
+
await reloadSession(sessionId);
|
|
61014
|
+
sayLine(`resumed ${sessionId}`);
|
|
61015
|
+
};
|
|
58166
61016
|
const slash = createSlashHost(buildSlashDeps({
|
|
58167
61017
|
seam,
|
|
58168
61018
|
commands: slashCommands,
|
|
@@ -58178,20 +61028,7 @@ function V2SessionPage(props) {
|
|
|
58178
61028
|
setSkillRows(props.skills ?? []);
|
|
58179
61029
|
setContextRevision((n) => n + 1);
|
|
58180
61030
|
},
|
|
58181
|
-
reload:
|
|
58182
|
-
setLastRequest(undefined);
|
|
58183
|
-
composerRef?.resetDeliveries();
|
|
58184
|
-
setComposerPending([]);
|
|
58185
|
-
setTools(0);
|
|
58186
|
-
resetSkinLineFades();
|
|
58187
|
-
const settled = projection.load(sessionId);
|
|
58188
|
-
seam.currentModelSelection().then(setModel);
|
|
58189
|
-
refreshFooterData();
|
|
58190
|
-
refreshPresetLabel();
|
|
58191
|
-
setSkillRows(props.skills ?? []);
|
|
58192
|
-
setContextRevision((n) => n + 1);
|
|
58193
|
-
return settled;
|
|
58194
|
-
},
|
|
61031
|
+
reload: reloadSession,
|
|
58195
61032
|
quit: props.quit,
|
|
58196
61033
|
pickOne
|
|
58197
61034
|
}, {
|
|
@@ -58199,8 +61036,11 @@ function V2SessionPage(props) {
|
|
|
58199
61036
|
openBtw: (argText) => void openBtw(argText),
|
|
58200
61037
|
openSearch: () => openSessionsSearch(),
|
|
58201
61038
|
openPlugins: () => openPluginsPanel(),
|
|
61039
|
+
openSkills: () => openSkillsPanel(),
|
|
58202
61040
|
openAgents: (name) => openAgentsPanel(name),
|
|
58203
61041
|
openSettings: () => openSettingsPanel(),
|
|
61042
|
+
openHistory: () => openHistoryPanel(),
|
|
61043
|
+
openSubagents: () => openSubagentsViewer(),
|
|
58204
61044
|
refreshFooter: refreshFooterData,
|
|
58205
61045
|
invalidateFooter: () => {
|
|
58206
61046
|
footerRefreshSeq++;
|
|
@@ -58252,6 +61092,7 @@ function V2SessionPage(props) {
|
|
|
58252
61092
|
get seam() {
|
|
58253
61093
|
return seam;
|
|
58254
61094
|
},
|
|
61095
|
+
onResumed: (sessionId) => resumeFromSearch(sessionId),
|
|
58255
61096
|
onClosed: () => {
|
|
58256
61097
|
if (composerRef && !composerRef.focused())
|
|
58257
61098
|
composerRef.focus();
|
|
@@ -58266,6 +61107,14 @@ function V2SessionPage(props) {
|
|
|
58266
61107
|
composerRef.focus();
|
|
58267
61108
|
}
|
|
58268
61109
|
}),
|
|
61110
|
+
createComponent2(SkillsPanel, {
|
|
61111
|
+
source: () => props.skillsSource,
|
|
61112
|
+
curated: () => props.skillsCurated,
|
|
61113
|
+
onClosed: () => {
|
|
61114
|
+
if (composerRef && !composerRef.focused())
|
|
61115
|
+
composerRef.focus();
|
|
61116
|
+
}
|
|
61117
|
+
}),
|
|
58269
61118
|
createComponent2(AgentsPanel, {
|
|
58270
61119
|
get seam() {
|
|
58271
61120
|
return seam;
|
|
@@ -58277,6 +61126,35 @@ function V2SessionPage(props) {
|
|
|
58277
61126
|
composerRef.focus();
|
|
58278
61127
|
}
|
|
58279
61128
|
}),
|
|
61129
|
+
createComponent2(HistoryPanel, {
|
|
61130
|
+
get seam() {
|
|
61131
|
+
return seam;
|
|
61132
|
+
},
|
|
61133
|
+
sessionId: () => seam.currentSessionId() ?? seam.stagedSessionId?.() ?? props.initialSessionId,
|
|
61134
|
+
onRefill: (text) => {
|
|
61135
|
+
composerRef?.node()?.setText(text);
|
|
61136
|
+
if (composerRef && !composerRef.focused())
|
|
61137
|
+
composerRef.focus();
|
|
61138
|
+
},
|
|
61139
|
+
onForked: async (forkedId, turn) => {
|
|
61140
|
+
seam.resumeSession(forkedId);
|
|
61141
|
+
await reloadSession(forkedId);
|
|
61142
|
+
sayLine(`forked from turn #${turn} \u2192 ${forkedId}`);
|
|
61143
|
+
},
|
|
61144
|
+
onClosed: () => {
|
|
61145
|
+
if (composerRef && !composerRef.focused())
|
|
61146
|
+
composerRef.focus();
|
|
61147
|
+
}
|
|
61148
|
+
}),
|
|
61149
|
+
createComponent2(SubagentsViewer, {
|
|
61150
|
+
get seam() {
|
|
61151
|
+
return seam;
|
|
61152
|
+
},
|
|
61153
|
+
onClosed: () => {
|
|
61154
|
+
if (composerRef && !composerRef.focused())
|
|
61155
|
+
composerRef.focus();
|
|
61156
|
+
}
|
|
61157
|
+
}),
|
|
58280
61158
|
createComponent2(SettingsModalHost, {
|
|
58281
61159
|
get seam() {
|
|
58282
61160
|
return seam;
|
|
@@ -58458,11 +61336,16 @@ async function bootClientV2(options = {}) {
|
|
|
58458
61336
|
initialSessionId = autoResume?.id;
|
|
58459
61337
|
resumeNotice = autoResume?.line;
|
|
58460
61338
|
}
|
|
61339
|
+
const agentsHomeForSkills = resolveAgentsHome(seam.configLoad().agentsHome);
|
|
58461
61340
|
const skillRows = discoverSkills({
|
|
58462
61341
|
cwd: workspace,
|
|
58463
61342
|
dshHome: host.dshHome,
|
|
58464
|
-
agentsHome:
|
|
61343
|
+
agentsHome: agentsHomeForSkills
|
|
58465
61344
|
});
|
|
61345
|
+
const skillsManagerRoots = {
|
|
61346
|
+
source: join10(agentsHomeForSkills, "skills"),
|
|
61347
|
+
curated: join10(host.dshHome, "skills")
|
|
61348
|
+
};
|
|
58466
61349
|
const envTheme = process.env[shared.ENV_THEME];
|
|
58467
61350
|
const workspaceConfig = seam.workspaceConfig();
|
|
58468
61351
|
const migration = shared.skinMigrationPlan({
|
|
@@ -58531,7 +61414,9 @@ async function bootClientV2(options = {}) {
|
|
|
58531
61414
|
probeBranch: (cwd) => git.probeGitBranchOrSha(cwd),
|
|
58532
61415
|
initialSessionId,
|
|
58533
61416
|
resumeNotice,
|
|
58534
|
-
skills: skillRows
|
|
61417
|
+
skills: skillRows,
|
|
61418
|
+
skillsSource: skillsManagerRoots.source,
|
|
61419
|
+
skillsCurated: skillsManagerRoots.curated
|
|
58535
61420
|
});
|
|
58536
61421
|
}
|
|
58537
61422
|
});
|
|
@@ -58606,10 +61491,13 @@ var init_v2_entry = __esm(() => {
|
|
|
58606
61491
|
init_slash_deps();
|
|
58607
61492
|
init_commands();
|
|
58608
61493
|
init_skills_source();
|
|
61494
|
+
init_skills_panel();
|
|
58609
61495
|
init_sessions_search();
|
|
58610
61496
|
init_plugins_panel();
|
|
58611
61497
|
init_agents_panel();
|
|
58612
61498
|
init_settings_panel();
|
|
61499
|
+
init_history_panel();
|
|
61500
|
+
init_subagents_viewer();
|
|
58613
61501
|
init_settings_modal();
|
|
58614
61502
|
init_btw_overlay();
|
|
58615
61503
|
init_dialog_select();
|
|
@@ -58675,6 +61563,9 @@ async function bootClient(options = {}) {
|
|
|
58675
61563
|
idleExitSec,
|
|
58676
61564
|
...options.dshHome !== undefined ? { dshHome: options.dshHome } : {}
|
|
58677
61565
|
});
|
|
61566
|
+
if (options.installErrorLog !== false) {
|
|
61567
|
+
installClientErrorLog(host.dshHome);
|
|
61568
|
+
}
|
|
58678
61569
|
bootCallOrder.push("connect");
|
|
58679
61570
|
const connection = (options.connect ?? defaultConnect)(host.authority, host.cookieHeader);
|
|
58680
61571
|
bootCallOrder.push("createSession");
|
|
@@ -58755,6 +61646,7 @@ export {
|
|
|
58755
61646
|
aggregateTurnContext,
|
|
58756
61647
|
bootCallOrder,
|
|
58757
61648
|
bootClient,
|
|
61649
|
+
installClientErrorLog,
|
|
58758
61650
|
installExitPaths,
|
|
58759
61651
|
spawnIdleReaper,
|
|
58760
61652
|
themeNameFromConfig
|