@aiwayds/dsh-opentui 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/bin/dsh-opentui.mjs +43 -2
- package/bin/lib/launcher.mjs +283 -0
- package/dist/client/index.js +3119 -267
- 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 {
|
|
@@ -6826,7 +7074,7 @@ class RemoteSubagentPanel {
|
|
|
6826
7074
|
if (!view)
|
|
6827
7075
|
return;
|
|
6828
7076
|
if (!running && view.status === "running") {
|
|
6829
|
-
this.#children.set(sessionId, { ...view, status: "completed" });
|
|
7077
|
+
this.#children.set(sessionId, { ...view, status: "completed", endedAt: Date.now() });
|
|
6830
7078
|
this.#emit();
|
|
6831
7079
|
}
|
|
6832
7080
|
}
|
|
@@ -6861,7 +7109,7 @@ class RemoteSubagentPanel {
|
|
|
6861
7109
|
this.#adopt(id, `subagent ${id.slice(0, 8)}`);
|
|
6862
7110
|
changed = true;
|
|
6863
7111
|
} else if (row.running === false && existing.status === "running") {
|
|
6864
|
-
this.#children.set(id, { ...existing, status: "completed" });
|
|
7112
|
+
this.#children.set(id, { ...existing, status: "completed", endedAt: Date.now() });
|
|
6865
7113
|
changed = true;
|
|
6866
7114
|
}
|
|
6867
7115
|
}
|
|
@@ -6878,6 +7126,7 @@ class RemoteSubagentPanel {
|
|
|
6878
7126
|
status: v.status,
|
|
6879
7127
|
rounds: v.rounds,
|
|
6880
7128
|
startedAt: v.startedAt,
|
|
7129
|
+
...v.status !== "running" ? { endedAt: v.endedAt ?? Date.now() } : {},
|
|
6881
7130
|
...v.tokens !== undefined ? { tokens: v.tokens } : {},
|
|
6882
7131
|
elapsed: Math.max(0, Math.floor((Date.now() - v.startedAt) / 1000)),
|
|
6883
7132
|
...v.lastLine ? { lastLine: clamp(v.lastLine) } : {},
|
|
@@ -6977,7 +7226,7 @@ class RemoteSubagentPanel {
|
|
|
6977
7226
|
#settle(childId, outcome) {
|
|
6978
7227
|
const existing = this.#children.get(childId);
|
|
6979
7228
|
if (existing !== undefined && existing.status === "running") {
|
|
6980
|
-
this.#children.set(childId, { ...existing, status: outcome });
|
|
7229
|
+
this.#children.set(childId, { ...existing, status: outcome, endedAt: Date.now() });
|
|
6981
7230
|
this.#emit();
|
|
6982
7231
|
}
|
|
6983
7232
|
}
|
|
@@ -7113,7 +7362,7 @@ class RemoteSubagentPanel {
|
|
|
7113
7362
|
changed = true;
|
|
7114
7363
|
}
|
|
7115
7364
|
} else if (type === "turn/end" && view.status === "running") {
|
|
7116
|
-
this.#children.set(id, { ...view, status: "completed" });
|
|
7365
|
+
this.#children.set(id, { ...view, status: "completed", endedAt: Date.now() });
|
|
7117
7366
|
changed = true;
|
|
7118
7367
|
}
|
|
7119
7368
|
while (log.length > 200)
|
|
@@ -7188,7 +7437,7 @@ var init_remote_subagents = __esm(() => {
|
|
|
7188
7437
|
|
|
7189
7438
|
// src/client/remote-restart.ts
|
|
7190
7439
|
import { spawn as spawn3 } from "child_process";
|
|
7191
|
-
import { existsSync as existsSync6, readFileSync as readFileSync6, renameSync as
|
|
7440
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, renameSync as renameSync5, rmSync as rmSync3, unlinkSync as unlinkSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
7192
7441
|
import { join as join7 } from "path";
|
|
7193
7442
|
function defaultSpawnDsh2(argv, options) {
|
|
7194
7443
|
const child = spawn3("dsh", argv, {
|
|
@@ -7215,7 +7464,7 @@ function writeRestartedLock(home, profile, host) {
|
|
|
7215
7464
|
const tmp = `${path}.tmp`;
|
|
7216
7465
|
writeFileSync5(tmp, JSON.stringify(payload, null, 2) + `
|
|
7217
7466
|
`);
|
|
7218
|
-
|
|
7467
|
+
renameSync5(tmp, path);
|
|
7219
7468
|
}
|
|
7220
7469
|
async function restartSamePortHost(options = {}) {
|
|
7221
7470
|
const profile = options.profile ?? "opentui";
|
|
@@ -7264,7 +7513,7 @@ async function restartSamePortHost(options = {}) {
|
|
|
7264
7513
|
rmSync3(lockPath, { force: true });
|
|
7265
7514
|
} catch {
|
|
7266
7515
|
try {
|
|
7267
|
-
|
|
7516
|
+
unlinkSync3(lockPath);
|
|
7268
7517
|
} catch {}
|
|
7269
7518
|
}
|
|
7270
7519
|
const quietDeadline = deadline(KILL_GRACE_MS2 + KILL_ESCALATE_MS2 + LISTEN_RELEASE_GRACE_MS);
|
|
@@ -7343,7 +7592,7 @@ __export(exports_remote_host_session, {
|
|
|
7343
7592
|
openRemoteStream: () => openRemoteStream
|
|
7344
7593
|
});
|
|
7345
7594
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
7346
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync7, renameSync as
|
|
7595
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync7, renameSync as renameSync6, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "fs";
|
|
7347
7596
|
import { join as joinPath } from "path";
|
|
7348
7597
|
import WS3 from "ws";
|
|
7349
7598
|
function trace(message) {
|
|
@@ -7422,6 +7671,7 @@ class RemoteHostSession {
|
|
|
7422
7671
|
#turnArmSeq = -1;
|
|
7423
7672
|
#tail;
|
|
7424
7673
|
#pluginsCache = [];
|
|
7674
|
+
#bundlesCache = [];
|
|
7425
7675
|
#skillsCache = [];
|
|
7426
7676
|
#skillListeners = [];
|
|
7427
7677
|
#skillsRefreshedFor;
|
|
@@ -8011,7 +8261,7 @@ class RemoteHostSession {
|
|
|
8011
8261
|
try {
|
|
8012
8262
|
writeFileSync6(tmp, JSON.stringify(merged, null, 2) + `
|
|
8013
8263
|
`);
|
|
8014
|
-
|
|
8264
|
+
renameSync6(tmp, path);
|
|
8015
8265
|
} catch (error) {
|
|
8016
8266
|
try {
|
|
8017
8267
|
rmSync4(tmp, { force: true });
|
|
@@ -8173,13 +8423,16 @@ class RemoteHostSession {
|
|
|
8173
8423
|
})
|
|
8174
8424
|
]);
|
|
8175
8425
|
const versions = new Map;
|
|
8176
|
-
|
|
8426
|
+
const nextBundles = Array.isArray(bundles) ? bundles.map(normalizeBundleRow).filter((row) => row.name !== "") : undefined;
|
|
8427
|
+
const bundlesChanged = nextBundles !== undefined && JSON.stringify(nextBundles) !== JSON.stringify(this.#bundlesCache);
|
|
8428
|
+
if (nextBundles !== undefined) {
|
|
8177
8429
|
for (const b of bundles) {
|
|
8178
8430
|
const moduleName = typeof b?.moduleName === "string" ? b.moduleName : typeof b?.name === "string" ? b.name : "";
|
|
8179
8431
|
const version = typeof b?.version === "string" ? b.version : "";
|
|
8180
8432
|
if (moduleName && version)
|
|
8181
8433
|
versions.set(moduleName, version);
|
|
8182
8434
|
}
|
|
8435
|
+
this.#bundlesCache = nextBundles;
|
|
8183
8436
|
}
|
|
8184
8437
|
this.#pluginsCache = (Array.isArray(plugins) ? plugins : []).map((p) => {
|
|
8185
8438
|
const row = typeof p === "object" && p !== null ? p : {};
|
|
@@ -8188,7 +8441,7 @@ class RemoteHostSession {
|
|
|
8188
8441
|
const title = typeof meta.title === "string" ? meta.title : moduleName;
|
|
8189
8442
|
return { name: title, moduleName, version: versions.get(moduleName) ?? "" };
|
|
8190
8443
|
}).filter((p) => p.name && !p.moduleName.startsWith("@deepseek-ai/")).map(({ name, version }) => ({ name, version }));
|
|
8191
|
-
if (this.#pluginsCache.length !== before || before === 0) {
|
|
8444
|
+
if (this.#pluginsCache.length !== before || before === 0 || bundlesChanged) {
|
|
8192
8445
|
for (const listener of this.#pushListeners) {
|
|
8193
8446
|
try {
|
|
8194
8447
|
listener.onPluginsChanged?.();
|
|
@@ -8198,6 +8451,39 @@ class RemoteHostSession {
|
|
|
8198
8451
|
} catch {}
|
|
8199
8452
|
return [...this.#pluginsCache];
|
|
8200
8453
|
}
|
|
8454
|
+
listBundles() {
|
|
8455
|
+
return [...this.#bundlesCache];
|
|
8456
|
+
}
|
|
8457
|
+
async setBundleEnabled(name, enabled) {
|
|
8458
|
+
try {
|
|
8459
|
+
const change = normalizeChangeResult(await this.#rpc("pluginManager/setBundleEnabled", { name, enabled }));
|
|
8460
|
+
this.refreshPlugins().catch(() => {});
|
|
8461
|
+
return change;
|
|
8462
|
+
} catch (cause) {
|
|
8463
|
+
return failedChange(name, cause);
|
|
8464
|
+
}
|
|
8465
|
+
}
|
|
8466
|
+
async removeBundle(name) {
|
|
8467
|
+
try {
|
|
8468
|
+
const change = normalizeChangeResult(await this.#rpc("pluginManager/removeBundle", { name }));
|
|
8469
|
+
this.refreshPlugins().catch(() => {});
|
|
8470
|
+
return change;
|
|
8471
|
+
} catch (cause) {
|
|
8472
|
+
return failedChange(name, cause);
|
|
8473
|
+
}
|
|
8474
|
+
}
|
|
8475
|
+
async inspectBundle(spec) {
|
|
8476
|
+
return normalizeInspection(await this.#rpc("pluginManager/inspect", { spec }));
|
|
8477
|
+
}
|
|
8478
|
+
async installBundle(spec) {
|
|
8479
|
+
try {
|
|
8480
|
+
const change = normalizeChangeResult(await this.#rpc("pluginManager/installBundle", { spec, options: { enabled: true } }));
|
|
8481
|
+
this.refreshPlugins().catch(() => {});
|
|
8482
|
+
return change;
|
|
8483
|
+
} catch (cause) {
|
|
8484
|
+
return failedChange(spec, cause);
|
|
8485
|
+
}
|
|
8486
|
+
}
|
|
8201
8487
|
executionMode() {
|
|
8202
8488
|
return this.#executionMode;
|
|
8203
8489
|
}
|
|
@@ -8215,9 +8501,21 @@ class RemoteHostSession {
|
|
|
8215
8501
|
repairScan() {
|
|
8216
8502
|
return repairScanSessions(this.#dshHome);
|
|
8217
8503
|
}
|
|
8504
|
+
repairScanBroken() {
|
|
8505
|
+
return scanBrokenSessionLogs(this.#dshHome);
|
|
8506
|
+
}
|
|
8507
|
+
repairSessionLog(path) {
|
|
8508
|
+
return repairSessionLogTail(path);
|
|
8509
|
+
}
|
|
8218
8510
|
async searchSessions(query) {
|
|
8219
8511
|
return this.#opsClient().searchSessions(query);
|
|
8220
8512
|
}
|
|
8513
|
+
async sessionJournal(sessionId) {
|
|
8514
|
+
return this.#opsClient().fetchJournal(sessionId);
|
|
8515
|
+
}
|
|
8516
|
+
async forkSession(sessionId, atSeq) {
|
|
8517
|
+
return this.#opsClient().fork(sessionId, atSeq);
|
|
8518
|
+
}
|
|
8221
8519
|
historyTurns() {
|
|
8222
8520
|
return groupTurns(this.#journal);
|
|
8223
8521
|
}
|
|
@@ -8898,6 +9196,57 @@ function asPermissionOptions(value) {
|
|
|
8898
9196
|
];
|
|
8899
9197
|
});
|
|
8900
9198
|
}
|
|
9199
|
+
function normalizeBundleRow(raw) {
|
|
9200
|
+
const name = typeof raw.name === "string" ? raw.name : "";
|
|
9201
|
+
const error = raw.error;
|
|
9202
|
+
return {
|
|
9203
|
+
name,
|
|
9204
|
+
version: typeof raw.version === "string" ? raw.version : "",
|
|
9205
|
+
description: typeof raw.description === "string" ? raw.description : "",
|
|
9206
|
+
enabled: raw.enabled === true,
|
|
9207
|
+
installed: raw.installed === true,
|
|
9208
|
+
optional: raw.optional === true,
|
|
9209
|
+
removable: raw.removable === true,
|
|
9210
|
+
readOnlyReason: typeof raw.readOnlyReason === "string" ? raw.readOnlyReason : undefined,
|
|
9211
|
+
error: typeof error === "object" && error !== null ? typeof error.diagnostic === "string" ? error.diagnostic : typeof error.message === "string" ? error.message : undefined : typeof error === "string" ? error : undefined
|
|
9212
|
+
};
|
|
9213
|
+
}
|
|
9214
|
+
function normalizeChangeResult(raw) {
|
|
9215
|
+
const row = typeof raw === "object" && raw !== null ? raw : {};
|
|
9216
|
+
const application = row.application;
|
|
9217
|
+
const error = row.error;
|
|
9218
|
+
return {
|
|
9219
|
+
changed: row.changed === true,
|
|
9220
|
+
application: application === "applied" || application === "restart-required" || application === "overridden" || application === "cancelled" ? application : "failed",
|
|
9221
|
+
target: typeof row.target === "string" ? row.target : "",
|
|
9222
|
+
error: typeof error === "object" && error !== null ? typeof error.diagnostic === "string" ? error.diagnostic : typeof error.code === "string" ? error.code : undefined : undefined
|
|
9223
|
+
};
|
|
9224
|
+
}
|
|
9225
|
+
function normalizeInspection(raw) {
|
|
9226
|
+
const row = typeof raw === "object" && raw !== null ? raw : {};
|
|
9227
|
+
if (row.status === "accepted") {
|
|
9228
|
+
return {
|
|
9229
|
+
status: "accepted",
|
|
9230
|
+
name: typeof row.name === "string" ? row.name : undefined,
|
|
9231
|
+
version: typeof row.version === "string" ? row.version : undefined,
|
|
9232
|
+
description: typeof row.description === "string" ? row.description : undefined,
|
|
9233
|
+
bundle: row.bundle === true ? true : row.bundle === false ? false : null
|
|
9234
|
+
};
|
|
9235
|
+
}
|
|
9236
|
+
return {
|
|
9237
|
+
status: "refused",
|
|
9238
|
+
problem: typeof row.problem === "string" ? row.problem : "unknown",
|
|
9239
|
+
reason: typeof row.reason === "string" ? row.reason : ""
|
|
9240
|
+
};
|
|
9241
|
+
}
|
|
9242
|
+
function failedChange(target, cause) {
|
|
9243
|
+
return {
|
|
9244
|
+
changed: false,
|
|
9245
|
+
application: "failed",
|
|
9246
|
+
target,
|
|
9247
|
+
error: cause instanceof Error ? cause.message : String(cause)
|
|
9248
|
+
};
|
|
9249
|
+
}
|
|
8901
9250
|
var REATTACH_RETRY_MS = 1000, REATTACH_MAX_ATTEMPTS = 30, SPIN_REFRESH_TTL_MS = 5000, PRESET_ENGLISH_NAMES;
|
|
8902
9251
|
var init_remote_host_session = __esm(() => {
|
|
8903
9252
|
init_loop();
|
|
@@ -43173,18 +43522,44 @@ function fitColumn(header, cells) {
|
|
|
43173
43522
|
function padCell(cell, width) {
|
|
43174
43523
|
return cell.length >= width ? cell : cell + " ".repeat(width - cell.length);
|
|
43175
43524
|
}
|
|
43176
|
-
function resumePickerOptions(rows, now = Date.now()) {
|
|
43525
|
+
function resumePickerOptions(rows, now = Date.now(), corruptIds) {
|
|
43177
43526
|
const updatedCells = rows.map((row) => relativeTime(row.updatedAt, now));
|
|
43178
43527
|
const dirCells = rows.map((row) => resumeDirLabel(row.cwd));
|
|
43179
43528
|
const updated = fitColumn("UPDATED", updatedCells);
|
|
43180
43529
|
const dir = fitColumn("DIR", dirCells);
|
|
43181
43530
|
const header = `${padCell(updated.header, updated.width)} ${padCell(dir.header, dir.width)} SESSION`;
|
|
43182
43531
|
const options = rows.map((row, index) => ({
|
|
43183
|
-
title: `${padCell(updatedCells[index], updated.width)} ${padCell(dirCells[index], dir.width)} ${row.title}`,
|
|
43532
|
+
title: `${padCell(updatedCells[index], updated.width)} ${padCell(dirCells[index], dir.width)} ${resumeRowTitle(row.title, corruptIds?.has(row.id) ?? false)}`,
|
|
43184
43533
|
value: row.id
|
|
43185
43534
|
}));
|
|
43186
43535
|
return { header, options };
|
|
43187
43536
|
}
|
|
43537
|
+
function resumeRowTitle(title, corrupt) {
|
|
43538
|
+
return corrupt ? `\u26A0 ${title}` : title;
|
|
43539
|
+
}
|
|
43540
|
+
function corruptSessionIds(broken) {
|
|
43541
|
+
const ids = new Set;
|
|
43542
|
+
for (const row of broken) {
|
|
43543
|
+
if (row.sessionId !== undefined && row.sessionId !== "")
|
|
43544
|
+
ids.add(row.sessionId);
|
|
43545
|
+
}
|
|
43546
|
+
return ids;
|
|
43547
|
+
}
|
|
43548
|
+
function brokenLogsForSession(broken, sessionId) {
|
|
43549
|
+
return broken.filter((row) => row.sessionId === sessionId);
|
|
43550
|
+
}
|
|
43551
|
+
function isRepairableLogRow(row) {
|
|
43552
|
+
return row.path.endsWith(".jsonl") && row.reason !== "0 bytes";
|
|
43553
|
+
}
|
|
43554
|
+
function repairConfirmOptions() {
|
|
43555
|
+
return [
|
|
43556
|
+
{ title: "Repair & resume", value: "repair", description: "back up the log, truncate the broken tail" },
|
|
43557
|
+
{ title: "Cancel", value: "cancel", description: "leave the log untouched" }
|
|
43558
|
+
];
|
|
43559
|
+
}
|
|
43560
|
+
function repairConfirmBody(broken) {
|
|
43561
|
+
return broken.map((row) => `${row.name} \u2014 ${row.reason}`);
|
|
43562
|
+
}
|
|
43188
43563
|
var SESSIONS_MIN_BYTES = 1024, SESSIONS_DIR_CAP = 32;
|
|
43189
43564
|
|
|
43190
43565
|
// ../tui-base/src/routes/session/auto-resume.ts
|
|
@@ -45168,10 +45543,12 @@ function createSeamRows(seam, sessionID, options) {
|
|
|
45168
45543
|
return seam.storedTranscript(id).then((stored) => {
|
|
45169
45544
|
if (sessionIdOverride !== undefined || sessionID() === id)
|
|
45170
45545
|
hydrate(stored);
|
|
45171
|
-
}).catch(() => {
|
|
45546
|
+
}).catch((error) => {
|
|
45172
45547
|
console.warn(`[seam-rows] transcript read failed for ${id}`);
|
|
45173
|
-
if (!hydrated())
|
|
45174
|
-
|
|
45548
|
+
if (!hydrated()) {
|
|
45549
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
45550
|
+
hydrate([{ kind: "assistant", text: `error: transcript read failed (${message})`, final: true }]);
|
|
45551
|
+
}
|
|
45175
45552
|
});
|
|
45176
45553
|
}
|
|
45177
45554
|
function upsert(row) {
|
|
@@ -48095,6 +48472,7 @@ var init_search_overlay = __esm(() => {
|
|
|
48095
48472
|
|
|
48096
48473
|
// ../tui-base/src/routes/session/transcript-scroll.tsx
|
|
48097
48474
|
function TranscriptScrollKeys(props) {
|
|
48475
|
+
const renderer = useRenderer();
|
|
48098
48476
|
const page = (delta) => {
|
|
48099
48477
|
const scroll = props.scroll();
|
|
48100
48478
|
if (!scroll || scroll.isDestroyed)
|
|
@@ -48117,6 +48495,34 @@ function TranscriptScrollKeys(props) {
|
|
|
48117
48495
|
}],
|
|
48118
48496
|
bindings: ["session.page.up", "session.page.down"]
|
|
48119
48497
|
}));
|
|
48498
|
+
const first = () => {
|
|
48499
|
+
const scroll = props.scroll();
|
|
48500
|
+
if (!scroll || scroll.isDestroyed)
|
|
48501
|
+
return;
|
|
48502
|
+
scroll.stickyScroll = false;
|
|
48503
|
+
scroll.scrollTo(0);
|
|
48504
|
+
};
|
|
48505
|
+
const last = () => {
|
|
48506
|
+
const scroll = props.scroll();
|
|
48507
|
+
if (!scroll || scroll.isDestroyed)
|
|
48508
|
+
return;
|
|
48509
|
+
scroll.scrollTo(Infinity);
|
|
48510
|
+
};
|
|
48511
|
+
Keymap2.createLayer(() => ({
|
|
48512
|
+
enabled: () => props.enabled() && renderer.currentFocusedEditor === null,
|
|
48513
|
+
commands: [{
|
|
48514
|
+
id: "session.first",
|
|
48515
|
+
title: "First message",
|
|
48516
|
+
group: "Session",
|
|
48517
|
+
run: first
|
|
48518
|
+
}, {
|
|
48519
|
+
id: "session.last",
|
|
48520
|
+
title: "Last message",
|
|
48521
|
+
group: "Session",
|
|
48522
|
+
run: last
|
|
48523
|
+
}],
|
|
48524
|
+
bindings: ["session.first", "session.last"]
|
|
48525
|
+
}));
|
|
48120
48526
|
return createComponent2(Show, {
|
|
48121
48527
|
when: false,
|
|
48122
48528
|
children: null
|
|
@@ -48125,6 +48531,7 @@ function TranscriptScrollKeys(props) {
|
|
|
48125
48531
|
var init_transcript_scroll = __esm(() => {
|
|
48126
48532
|
init_index_bun();
|
|
48127
48533
|
init_server();
|
|
48534
|
+
init_index_bun();
|
|
48128
48535
|
init_keymap();
|
|
48129
48536
|
});
|
|
48130
48537
|
|
|
@@ -49129,6 +49536,37 @@ function formatSessionInfoPanel(rows) {
|
|
|
49129
49536
|
return rows.map((row) => `${row.field.padEnd(width)} ${row.value}`);
|
|
49130
49537
|
}
|
|
49131
49538
|
|
|
49539
|
+
// ../tui-base/src/routes/session/model-picker.ts
|
|
49540
|
+
function modelKey(providerID, modelID) {
|
|
49541
|
+
return `${providerID}/${modelID}`;
|
|
49542
|
+
}
|
|
49543
|
+
function toggleStringList(list, key) {
|
|
49544
|
+
return list.includes(key) ? list.filter((entry) => entry !== key) : [...list, key];
|
|
49545
|
+
}
|
|
49546
|
+
function narrowStringList(value) {
|
|
49547
|
+
return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
|
|
49548
|
+
}
|
|
49549
|
+
function readModelPrefsFromConfig(config) {
|
|
49550
|
+
return {
|
|
49551
|
+
favoriteModels: narrowStringList(config?.favoriteModels),
|
|
49552
|
+
hiddenModels: narrowStringList(config?.hiddenModels)
|
|
49553
|
+
};
|
|
49554
|
+
}
|
|
49555
|
+
function buildModelPickerRows(entries, favorites, hidden, current) {
|
|
49556
|
+
const byKey = new Map(entries.map((entry) => [modelKey(entry.providerID, entry.modelID), entry]));
|
|
49557
|
+
const hiddenSet = new Set(hidden);
|
|
49558
|
+
const row = (entry, category, star = false) => ({
|
|
49559
|
+
title: `${star ? "\u2605 " : ""}${entry.providerID}/${entry.modelID}`,
|
|
49560
|
+
value: modelKey(entry.providerID, entry.modelID),
|
|
49561
|
+
description: current !== undefined && current.providerID === entry.providerID && current.modelID === entry.modelID ? "current" : undefined,
|
|
49562
|
+
...category !== undefined ? { category } : {}
|
|
49563
|
+
});
|
|
49564
|
+
const favoriteRows = favorites.map((key) => byKey.get(key)).filter((entry) => entry !== undefined).map((entry) => row(entry, "Favorites", true));
|
|
49565
|
+
const normalRows = entries.filter((entry) => !favorites.includes(modelKey(entry.providerID, entry.modelID)) && !hiddenSet.has(modelKey(entry.providerID, entry.modelID))).map((entry) => row(entry));
|
|
49566
|
+
const hiddenRows = entries.filter((entry) => hiddenSet.has(modelKey(entry.providerID, entry.modelID)) && !favorites.includes(modelKey(entry.providerID, entry.modelID))).map((entry) => row(entry, "Hidden"));
|
|
49567
|
+
return [...favoriteRows, ...normalRows, ...hiddenRows];
|
|
49568
|
+
}
|
|
49569
|
+
|
|
49132
49570
|
// ../tui-base/src/routes/session/login.ts
|
|
49133
49571
|
function deriveKeyRef(provider) {
|
|
49134
49572
|
return `${provider.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_API_KEY`;
|
|
@@ -49284,6 +49722,39 @@ async function commitLoginRoute(say, face, entry, key) {
|
|
|
49284
49722
|
}
|
|
49285
49723
|
say(`${entry.name} subscribed \u2014 key stored, route registered (in /model next session)`);
|
|
49286
49724
|
}
|
|
49725
|
+
async function offerCorruptedLogRepair(ctx, sessionId, broken) {
|
|
49726
|
+
if (broken.length === 0) {
|
|
49727
|
+
ctx.say(`cannot repair ${sessionId}: no broken log found on disk`);
|
|
49728
|
+
return false;
|
|
49729
|
+
}
|
|
49730
|
+
if (!ctx.seam.repairSessionLog) {
|
|
49731
|
+
ctx.say("/resume repair unavailable in this session \u2014 the log was left untouched");
|
|
49732
|
+
return false;
|
|
49733
|
+
}
|
|
49734
|
+
const unrepairable = broken.filter((row) => !isRepairableLogRow(row));
|
|
49735
|
+
if (unrepairable.length > 0) {
|
|
49736
|
+
ctx.say(`cannot repair ${sessionId} client-side \u2014 ${repairConfirmBody(unrepairable).join("; ")}; only plain jsonl tails are repairable. The log was left untouched.`);
|
|
49737
|
+
return false;
|
|
49738
|
+
}
|
|
49739
|
+
const confirm = await ctx.pickOne(`Session ${sessionId} has a broken log (${repairConfirmBody(broken).join("; ")}) \u2014 repair it?`, repairConfirmOptions());
|
|
49740
|
+
if (confirm !== "repair") {
|
|
49741
|
+
ctx.say(`resume cancelled \u2014 the log was left untouched (${repairConfirmBody(broken).join("; ")})`);
|
|
49742
|
+
return false;
|
|
49743
|
+
}
|
|
49744
|
+
for (const row of broken) {
|
|
49745
|
+
const result = ctx.seam.repairSessionLog(row.path);
|
|
49746
|
+
if (result.kind === "failed") {
|
|
49747
|
+
ctx.say(`repair failed \u2014 ${row.name}: ${result.detail} (the log was left untouched or restored)`);
|
|
49748
|
+
return false;
|
|
49749
|
+
}
|
|
49750
|
+
if (result.kind === "clean") {
|
|
49751
|
+
ctx.say(`${row.name} needs no repair \u2014 the last line already parses; resuming`);
|
|
49752
|
+
} else {
|
|
49753
|
+
ctx.say(`repaired ${row.name} \u2014 the original was kept at ${result.backupPath}`);
|
|
49754
|
+
}
|
|
49755
|
+
}
|
|
49756
|
+
return true;
|
|
49757
|
+
}
|
|
49287
49758
|
async function commitCatalogLogin(ctx, face, entry) {
|
|
49288
49759
|
const key = await ctx.promptText?.(`API key for ${entry.name} (${deriveKeyRef(entry.id)})`, { mask: true });
|
|
49289
49760
|
if (key === undefined)
|
|
@@ -49336,6 +49807,17 @@ async function runCustomLoginChain(ctx, face, existingRoutes) {
|
|
|
49336
49807
|
}
|
|
49337
49808
|
}
|
|
49338
49809
|
}
|
|
49810
|
+
function logoutTargets(routes) {
|
|
49811
|
+
return routes.map((route) => {
|
|
49812
|
+
const entry = PROVIDER_CATALOG.find((e) => e.id === route.id);
|
|
49813
|
+
return {
|
|
49814
|
+
id: route.id,
|
|
49815
|
+
name: route.displayName ? route.displayName : entry?.name ?? route.id,
|
|
49816
|
+
ref: route.apiKeyEnv ?? deriveKeyRef(route.id),
|
|
49817
|
+
custom: route.declared === true || entry === undefined
|
|
49818
|
+
};
|
|
49819
|
+
});
|
|
49820
|
+
}
|
|
49339
49821
|
function coreCommands() {
|
|
49340
49822
|
return [
|
|
49341
49823
|
{
|
|
@@ -49387,11 +49869,45 @@ function coreCommands() {
|
|
|
49387
49869
|
return;
|
|
49388
49870
|
}
|
|
49389
49871
|
const current = await ctx.seam.currentModelSelection();
|
|
49390
|
-
const
|
|
49391
|
-
|
|
49392
|
-
|
|
49393
|
-
|
|
49394
|
-
|
|
49872
|
+
const prefs = readModelPrefsFromConfig(ctx.seam.configLoad?.());
|
|
49873
|
+
let favorites = prefs.favoriteModels;
|
|
49874
|
+
let hidden = prefs.hiddenModels;
|
|
49875
|
+
const persistPrefs = () => {
|
|
49876
|
+
try {
|
|
49877
|
+
ctx.seam.configSave?.({ favoriteModels: [...favorites], hiddenModels: [...hidden] });
|
|
49878
|
+
} catch (error) {
|
|
49879
|
+
console.error("[commands] model prefs persist failed:", error);
|
|
49880
|
+
}
|
|
49881
|
+
};
|
|
49882
|
+
const currentKey = current ? modelKey(current.providerID, current.modelID) : undefined;
|
|
49883
|
+
const picked = await ctx.pickOne("Select model", buildModelPickerRows(catalog, favorites, hidden, current), undefined, currentKey, {
|
|
49884
|
+
actions: [
|
|
49885
|
+
{
|
|
49886
|
+
command: "model.picker.favorite",
|
|
49887
|
+
title: (value) => value !== undefined && favorites.includes(value) ? "unfavorite" : "favorite",
|
|
49888
|
+
bind: "f"
|
|
49889
|
+
},
|
|
49890
|
+
{
|
|
49891
|
+
command: "model.picker.hide",
|
|
49892
|
+
title: "hide",
|
|
49893
|
+
bind: "h",
|
|
49894
|
+
disabled: (value) => favorites.includes(value)
|
|
49895
|
+
}
|
|
49896
|
+
],
|
|
49897
|
+
getOptions: () => buildModelPickerRows(catalog, favorites, hidden, current),
|
|
49898
|
+
onAction: (command, value) => {
|
|
49899
|
+
if (command === "model.picker.favorite") {
|
|
49900
|
+
favorites = toggleStringList(favorites, value);
|
|
49901
|
+
} else if (command === "model.picker.hide") {
|
|
49902
|
+
if (favorites.includes(value))
|
|
49903
|
+
return;
|
|
49904
|
+
hidden = toggleStringList(hidden, value);
|
|
49905
|
+
} else {
|
|
49906
|
+
return;
|
|
49907
|
+
}
|
|
49908
|
+
persistPrefs();
|
|
49909
|
+
}
|
|
49910
|
+
});
|
|
49395
49911
|
if (!picked)
|
|
49396
49912
|
return;
|
|
49397
49913
|
const [providerID, modelID] = picked.split("/");
|
|
@@ -49480,7 +49996,7 @@ function coreCommands() {
|
|
|
49480
49996
|
if (!picked)
|
|
49481
49997
|
return;
|
|
49482
49998
|
if (picked === CUSTOM_ENTRY.id) {
|
|
49483
|
-
const routes = await face.routes().catch(() => []);
|
|
49999
|
+
const routes = (await face.routes().catch(() => [])).map((route) => route.id);
|
|
49484
50000
|
await runCustomLoginChain(ctx, face, routes);
|
|
49485
50001
|
return;
|
|
49486
50002
|
}
|
|
@@ -49490,6 +50006,61 @@ function coreCommands() {
|
|
|
49490
50006
|
await commitCatalogLogin(ctx, face, entry);
|
|
49491
50007
|
}
|
|
49492
50008
|
},
|
|
50009
|
+
{
|
|
50010
|
+
name: "/logout",
|
|
50011
|
+
description: "log out a provider (drops the stored key)",
|
|
50012
|
+
async run(ctx, argText) {
|
|
50013
|
+
const face = ctx.seam.login;
|
|
50014
|
+
if (!face) {
|
|
50015
|
+
ctx.say("/logout unavailable in this session");
|
|
50016
|
+
return;
|
|
50017
|
+
}
|
|
50018
|
+
let routes;
|
|
50019
|
+
try {
|
|
50020
|
+
routes = await face.routes();
|
|
50021
|
+
} catch (error) {
|
|
50022
|
+
ctx.say(`logout failed \u2014 ${seamFailureReason(error)}`);
|
|
50023
|
+
return;
|
|
50024
|
+
}
|
|
50025
|
+
const loggedIn = [];
|
|
50026
|
+
for (const target of logoutTargets(routes)) {
|
|
50027
|
+
try {
|
|
50028
|
+
if ((await face.credentialStatus(target.ref)).configured)
|
|
50029
|
+
loggedIn.push(target);
|
|
50030
|
+
} catch {}
|
|
50031
|
+
}
|
|
50032
|
+
if (loggedIn.length === 0) {
|
|
50033
|
+
ctx.say("no logged-in providers");
|
|
50034
|
+
return;
|
|
50035
|
+
}
|
|
50036
|
+
const arg = argText.trim();
|
|
50037
|
+
let target = arg ? loggedIn.find((t) => t.id === arg) : undefined;
|
|
50038
|
+
if (arg && !target) {
|
|
50039
|
+
ctx.say(`not logged in: ${arg}`);
|
|
50040
|
+
return;
|
|
50041
|
+
}
|
|
50042
|
+
if (!target) {
|
|
50043
|
+
const picked = await ctx.pickOne("Log out provider", loggedIn.map((t) => ({ title: t.name, value: t.id, description: t.ref })));
|
|
50044
|
+
if (!picked)
|
|
50045
|
+
return;
|
|
50046
|
+
target = loggedIn.find((t) => t.id === picked);
|
|
50047
|
+
}
|
|
50048
|
+
if (!target)
|
|
50049
|
+
return;
|
|
50050
|
+
try {
|
|
50051
|
+
await face.logout(target.ref);
|
|
50052
|
+
} catch (error) {
|
|
50053
|
+
ctx.say(`${target.id}: logout failed \u2014 ${seamFailureReason(error)}`);
|
|
50054
|
+
return;
|
|
50055
|
+
}
|
|
50056
|
+
if (target.custom) {
|
|
50057
|
+
ctx.say(`${target.name} logged out \u2014 key removed (route kept)`);
|
|
50058
|
+
return;
|
|
50059
|
+
}
|
|
50060
|
+
const cleared = await face.registerRoute(target.id, undefined).catch(() => false);
|
|
50061
|
+
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`);
|
|
50062
|
+
}
|
|
50063
|
+
},
|
|
49493
50064
|
{
|
|
49494
50065
|
name: "/quit",
|
|
49495
50066
|
description: "exit the app",
|
|
@@ -49501,7 +50072,13 @@ function coreCommands() {
|
|
|
49501
50072
|
name: "/resume",
|
|
49502
50073
|
description: "resume a persisted session",
|
|
49503
50074
|
async run(ctx) {
|
|
49504
|
-
|
|
50075
|
+
let sessions;
|
|
50076
|
+
try {
|
|
50077
|
+
sessions = await ctx.seam.listSessions();
|
|
50078
|
+
} catch (error) {
|
|
50079
|
+
ctx.say(`resume unavailable \u2014 ${seamFailureReason(error)}`);
|
|
50080
|
+
return;
|
|
50081
|
+
}
|
|
49505
50082
|
if (sessions.length === 0) {
|
|
49506
50083
|
ctx.say("no stored sessions");
|
|
49507
50084
|
return;
|
|
@@ -49511,10 +50088,17 @@ function coreCommands() {
|
|
|
49511
50088
|
ctx.say(emptyFilteredCopy(sessions.length));
|
|
49512
50089
|
return;
|
|
49513
50090
|
}
|
|
49514
|
-
const
|
|
50091
|
+
const broken = ctx.seam.repairScanBroken?.() ?? [];
|
|
50092
|
+
const corruptIds = corruptSessionIds(broken);
|
|
50093
|
+
const { header, options } = resumePickerOptions(visible, Date.now(), corruptIds);
|
|
49515
50094
|
const picked = await ctx.pickOne("Resume session", options, header);
|
|
49516
50095
|
if (!picked)
|
|
49517
50096
|
return;
|
|
50097
|
+
if (corruptIds.has(picked)) {
|
|
50098
|
+
const ok = await offerCorruptedLogRepair(ctx, picked, brokenLogsForSession(broken, picked));
|
|
50099
|
+
if (!ok)
|
|
50100
|
+
return;
|
|
50101
|
+
}
|
|
49518
50102
|
ctx.seam.resumeSession(picked);
|
|
49519
50103
|
await ctx.reload(picked);
|
|
49520
50104
|
ctx.say(`resumed ${picked}`);
|
|
@@ -49597,6 +50181,17 @@ function coreCommands() {
|
|
|
49597
50181
|
ctx.say(`\u25CF ${plugin.name}@${plugin.version}`);
|
|
49598
50182
|
}
|
|
49599
50183
|
},
|
|
50184
|
+
{
|
|
50185
|
+
name: "/skills",
|
|
50186
|
+
description: "manage skills (opens the panel)",
|
|
50187
|
+
run(ctx) {
|
|
50188
|
+
if (!ctx.openSkills) {
|
|
50189
|
+
ctx.say("/skills unavailable in this session");
|
|
50190
|
+
return;
|
|
50191
|
+
}
|
|
50192
|
+
ctx.openSkills();
|
|
50193
|
+
}
|
|
50194
|
+
},
|
|
49600
50195
|
{
|
|
49601
50196
|
name: "/search",
|
|
49602
50197
|
description: "full-text search over stored sessions",
|
|
@@ -49635,6 +50230,33 @@ function coreCommands() {
|
|
|
49635
50230
|
ctx.openSettings();
|
|
49636
50231
|
}
|
|
49637
50232
|
},
|
|
50233
|
+
{
|
|
50234
|
+
name: "/history",
|
|
50235
|
+
description: "browse completed turns of the session (refill, switch, fork)",
|
|
50236
|
+
run(ctx) {
|
|
50237
|
+
if (!ctx.openHistory) {
|
|
50238
|
+
ctx.say("/history: the browser panel is not mounted in this entry");
|
|
50239
|
+
return;
|
|
50240
|
+
}
|
|
50241
|
+
ctx.openHistory();
|
|
50242
|
+
}
|
|
50243
|
+
},
|
|
50244
|
+
{
|
|
50245
|
+
name: "/subagents",
|
|
50246
|
+
description: "view live subagent transcripts (list, steer, stop)",
|
|
50247
|
+
run(ctx) {
|
|
50248
|
+
if (!ctx.openSubagents) {
|
|
50249
|
+
ctx.say("/subagents: the transcript viewer is not mounted in this entry");
|
|
50250
|
+
return;
|
|
50251
|
+
}
|
|
50252
|
+
const views = ctx.seam.subagentViews?.() ?? [];
|
|
50253
|
+
if (views.length === 0) {
|
|
50254
|
+
ctx.say("no subagents in this session \u2014 spawn one and run /subagents again");
|
|
50255
|
+
return;
|
|
50256
|
+
}
|
|
50257
|
+
ctx.openSubagents();
|
|
50258
|
+
}
|
|
50259
|
+
},
|
|
49638
50260
|
{
|
|
49639
50261
|
name: "/think",
|
|
49640
50262
|
description: "set reasoning effort (opens the picker)",
|
|
@@ -49934,8 +50556,11 @@ function buildSlashDeps(base, hooks) {
|
|
|
49934
50556
|
themes: hooks.themes,
|
|
49935
50557
|
openSearch: hooks.openSearch,
|
|
49936
50558
|
openPlugins: hooks.openPlugins,
|
|
50559
|
+
openSkills: hooks.openSkills,
|
|
49937
50560
|
openAgents: hooks.openAgents,
|
|
49938
50561
|
openSettings: hooks.openSettings,
|
|
50562
|
+
openHistory: hooks.openHistory,
|
|
50563
|
+
openSubagents: hooks.openSubagents,
|
|
49939
50564
|
refreshFooter: hooks.refreshFooter,
|
|
49940
50565
|
invalidateFooter: hooks.invalidateFooter,
|
|
49941
50566
|
flushQueue: hooks.flushQueue
|
|
@@ -49958,8 +50583,11 @@ var init_slash_deps = __esm(() => {
|
|
|
49958
50583
|
"themes",
|
|
49959
50584
|
"openSearch",
|
|
49960
50585
|
"openPlugins",
|
|
50586
|
+
"openSkills",
|
|
49961
50587
|
"openAgents",
|
|
49962
50588
|
"openSettings",
|
|
50589
|
+
"openHistory",
|
|
50590
|
+
"openSubagents",
|
|
49963
50591
|
"refreshFooter",
|
|
49964
50592
|
"invalidateFooter",
|
|
49965
50593
|
"flushQueue"
|
|
@@ -50075,14 +50703,14 @@ var init_slash_usage = __esm(() => {
|
|
|
50075
50703
|
// ../tui-base/src/routes/session/skills-source.ts
|
|
50076
50704
|
import { existsSync as existsSync8, readdirSync as readdirSync2, readFileSync as readFileSync8, statSync as statSync4 } from "fs";
|
|
50077
50705
|
import { homedir as homedir4 } from "os";
|
|
50078
|
-
import { dirname as
|
|
50706
|
+
import { dirname as dirname3, join as join8, resolve as resolve5 } from "path";
|
|
50079
50707
|
import { TextAttributes as TextAttributes8 } from "@opentui/core";
|
|
50080
50708
|
function findProjectRoot(cwd) {
|
|
50081
50709
|
let dir = resolve5(cwd);
|
|
50082
50710
|
for (let depth = 0;depth < 64; depth++) {
|
|
50083
50711
|
if (existsSync8(join8(dir, ".git")))
|
|
50084
50712
|
return dir;
|
|
50085
|
-
const parent =
|
|
50713
|
+
const parent = dirname3(dir);
|
|
50086
50714
|
if (parent === dir)
|
|
50087
50715
|
break;
|
|
50088
50716
|
dir = parent;
|
|
@@ -50594,18 +51222,578 @@ var init_slash_palette = __esm(() => {
|
|
|
50594
51222
|
PALETTE_ROWS = MAX_ROWS + 1;
|
|
50595
51223
|
});
|
|
50596
51224
|
|
|
51225
|
+
// ../tui-base/src/routes/session/skills-manage.ts
|
|
51226
|
+
import { existsSync as existsSync9 } from "fs";
|
|
51227
|
+
import { lstat, mkdir as mkdir2, readFile as readFile3, readdir, realpath, symlink, unlink } from "fs/promises";
|
|
51228
|
+
import { join as join9 } from "path";
|
|
51229
|
+
function skillSymlinkPaths(publicDir, curatedDir, name) {
|
|
51230
|
+
const srcMd = join9(publicDir, `${name}.md`);
|
|
51231
|
+
if (existsSync9(srcMd))
|
|
51232
|
+
return { src: srcMd, dest: join9(curatedDir, `${name}.md`) };
|
|
51233
|
+
const srcBundle = join9(publicDir, name);
|
|
51234
|
+
if (existsSync9(srcBundle))
|
|
51235
|
+
return { src: srcBundle, dest: join9(curatedDir, name) };
|
|
51236
|
+
return;
|
|
51237
|
+
}
|
|
51238
|
+
async function installSkillSymlink(src, dest) {
|
|
51239
|
+
const srcReal = await realpath(src).catch((error) => {
|
|
51240
|
+
const code = error.code;
|
|
51241
|
+
throw new Error(`skill source vanished: "${src}"${code === undefined ? "" : ` (${code})`}`);
|
|
51242
|
+
});
|
|
51243
|
+
const destStat = await lstat(dest).catch(() => {
|
|
51244
|
+
return;
|
|
51245
|
+
});
|
|
51246
|
+
if (destStat === undefined) {
|
|
51247
|
+
await symlink(src, dest);
|
|
51248
|
+
return;
|
|
51249
|
+
}
|
|
51250
|
+
if (!destStat.isSymbolicLink()) {
|
|
51251
|
+
throw new Error(`refusing to overwrite "${dest}": not a symlink`);
|
|
51252
|
+
}
|
|
51253
|
+
const destReal = await realpath(dest).catch((error) => {
|
|
51254
|
+
const code = error.code;
|
|
51255
|
+
if (code === "ENOENT" || code === "ELOOP")
|
|
51256
|
+
return;
|
|
51257
|
+
throw error;
|
|
51258
|
+
});
|
|
51259
|
+
if (destReal === undefined) {
|
|
51260
|
+
await unlink(dest);
|
|
51261
|
+
await symlink(src, dest);
|
|
51262
|
+
return;
|
|
51263
|
+
}
|
|
51264
|
+
if (destReal === srcReal)
|
|
51265
|
+
return;
|
|
51266
|
+
throw new Error(`already installed from a different source: "${dest}" points to "${destReal}", expected "${srcReal}"`);
|
|
51267
|
+
}
|
|
51268
|
+
async function applyOneSkillChange(name, targetState, publicDir, curatedDir) {
|
|
51269
|
+
if (targetState) {
|
|
51270
|
+
const paths = skillSymlinkPaths(publicDir, curatedDir, name);
|
|
51271
|
+
if (paths === undefined)
|
|
51272
|
+
return `cannot install: skill not found in "${publicDir}"`;
|
|
51273
|
+
try {
|
|
51274
|
+
await installSkillSymlink(paths.src, paths.dest);
|
|
51275
|
+
return;
|
|
51276
|
+
} catch (error) {
|
|
51277
|
+
return `cannot install: ${error instanceof Error ? error.message : String(error)}`;
|
|
51278
|
+
}
|
|
51279
|
+
}
|
|
51280
|
+
try {
|
|
51281
|
+
const destMd = join9(curatedDir, `${name}.md`);
|
|
51282
|
+
const destBundle = join9(curatedDir, name);
|
|
51283
|
+
const mdStat = await lstat(destMd).catch(() => {
|
|
51284
|
+
return;
|
|
51285
|
+
});
|
|
51286
|
+
if (mdStat !== undefined) {
|
|
51287
|
+
if (!mdStat.isSymbolicLink())
|
|
51288
|
+
throw new Error(`refusing to remove "${destMd}": not a symlink`);
|
|
51289
|
+
await unlink(destMd);
|
|
51290
|
+
return;
|
|
51291
|
+
}
|
|
51292
|
+
const bundleStat = await lstat(destBundle).catch(() => {
|
|
51293
|
+
return;
|
|
51294
|
+
});
|
|
51295
|
+
if (bundleStat !== undefined) {
|
|
51296
|
+
if (!bundleStat.isSymbolicLink())
|
|
51297
|
+
throw new Error(`refusing to remove "${destBundle}": not a symlink`);
|
|
51298
|
+
await unlink(destBundle);
|
|
51299
|
+
}
|
|
51300
|
+
return;
|
|
51301
|
+
} catch (error) {
|
|
51302
|
+
return `cannot uninstall: ${error instanceof Error ? error.message : String(error)}`;
|
|
51303
|
+
}
|
|
51304
|
+
}
|
|
51305
|
+
function skillApplyShortReason(error) {
|
|
51306
|
+
if (error.includes("not a symlink"))
|
|
51307
|
+
return "protected (not a symlink)";
|
|
51308
|
+
if (error.includes("different source"))
|
|
51309
|
+
return "installed from a different source";
|
|
51310
|
+
if (error.includes("skill not found") || error.includes("source vanished"))
|
|
51311
|
+
return "source missing";
|
|
51312
|
+
return "failed";
|
|
51313
|
+
}
|
|
51314
|
+
function skillApplySummary(results) {
|
|
51315
|
+
const failures = results.filter((r) => r.error !== undefined);
|
|
51316
|
+
if (failures.length === 0)
|
|
51317
|
+
return "";
|
|
51318
|
+
const okNames = results.filter((r) => r.error === undefined).map((r) => r.name);
|
|
51319
|
+
const failed = failures.slice(0, SKILL_SUMMARY_MAX_ITEMS).map((r) => `${r.name} (${skillApplyShortReason(r.error ?? "")})`).join(", ");
|
|
51320
|
+
const failedExtra = failures.length - SKILL_SUMMARY_MAX_ITEMS;
|
|
51321
|
+
const failedMore = failedExtra > 0 ? ` +${failedExtra} more` : "";
|
|
51322
|
+
const okShown = okNames.slice(0, SKILL_SUMMARY_MAX_ITEMS).join(", ");
|
|
51323
|
+
const okExtra = okNames.length - SKILL_SUMMARY_MAX_ITEMS;
|
|
51324
|
+
const okMore = okExtra > 0 ? ` +${okExtra} more` : "";
|
|
51325
|
+
const okPart = okNames.length > 0 ? `ok: ${okShown}${okMore} \xB7 ` : "";
|
|
51326
|
+
return `applied ${okNames.length}/${results.length} \u2014 ${okPart}failed: ${failed}${failedMore}`;
|
|
51327
|
+
}
|
|
51328
|
+
function oneLine2(value) {
|
|
51329
|
+
const normalized = value.replace(/\s+/g, " ").trim();
|
|
51330
|
+
if (normalized.length <= DESCRIPTION_MAX2)
|
|
51331
|
+
return normalized;
|
|
51332
|
+
return `${normalized.slice(0, DESCRIPTION_MAX2 - 3)}...`;
|
|
51333
|
+
}
|
|
51334
|
+
async function readSkillDescription(path) {
|
|
51335
|
+
try {
|
|
51336
|
+
const text = await readFile3(path, "utf8");
|
|
51337
|
+
const front = parseFrontmatter(text);
|
|
51338
|
+
if (front === undefined)
|
|
51339
|
+
return "";
|
|
51340
|
+
return oneLine2((front.description ?? "").trim());
|
|
51341
|
+
} catch {
|
|
51342
|
+
return "";
|
|
51343
|
+
}
|
|
51344
|
+
}
|
|
51345
|
+
async function scanAvailableSkills(publicDir, curatedDir) {
|
|
51346
|
+
let entries;
|
|
51347
|
+
try {
|
|
51348
|
+
entries = await readdir(publicDir, { encoding: "utf8" });
|
|
51349
|
+
} catch {
|
|
51350
|
+
return [];
|
|
51351
|
+
}
|
|
51352
|
+
const skillNames = new Set;
|
|
51353
|
+
for (const name of entries) {
|
|
51354
|
+
if (name.endsWith(".md")) {
|
|
51355
|
+
skillNames.add(name.slice(0, -3));
|
|
51356
|
+
} else if (!name.startsWith(".")) {
|
|
51357
|
+
if (existsSync9(join9(publicDir, name, "SKILL.md")))
|
|
51358
|
+
skillNames.add(name);
|
|
51359
|
+
}
|
|
51360
|
+
}
|
|
51361
|
+
const rows = [];
|
|
51362
|
+
for (const name of skillNames) {
|
|
51363
|
+
const installed = existsSync9(join9(curatedDir, `${name}.md`)) || existsSync9(join9(curatedDir, name));
|
|
51364
|
+
const description = await readSkillDescription(existsSync9(join9(publicDir, name, "SKILL.md")) ? join9(publicDir, name, "SKILL.md") : join9(publicDir, `${name}.md`));
|
|
51365
|
+
rows.push({ name, description, installed });
|
|
51366
|
+
}
|
|
51367
|
+
rows.sort((a, b) => a.name.localeCompare(b.name));
|
|
51368
|
+
return rows;
|
|
51369
|
+
}
|
|
51370
|
+
function filterSkillRows(rows, query) {
|
|
51371
|
+
const needle = query.trim().toLowerCase();
|
|
51372
|
+
if (!needle)
|
|
51373
|
+
return [...rows];
|
|
51374
|
+
return rows.filter((row) => row.name.toLowerCase().includes(needle) || row.description.toLowerCase().includes(needle));
|
|
51375
|
+
}
|
|
51376
|
+
function skillStateText(row, pendingState) {
|
|
51377
|
+
const effective = pendingState ?? row.installed;
|
|
51378
|
+
const base = effective ? "installed" : "available";
|
|
51379
|
+
return pendingState === undefined || pendingState === row.installed ? base : `${base}*`;
|
|
51380
|
+
}
|
|
51381
|
+
async function ensureCuratedDir(curatedDir) {
|
|
51382
|
+
try {
|
|
51383
|
+
await mkdir2(curatedDir, { recursive: true });
|
|
51384
|
+
} catch {}
|
|
51385
|
+
}
|
|
51386
|
+
var SKILL_SUMMARY_MAX_ITEMS = 3, DESCRIPTION_MAX2 = 90;
|
|
51387
|
+
var init_skills_manage = __esm(() => {
|
|
51388
|
+
init_skills_source();
|
|
51389
|
+
});
|
|
51390
|
+
|
|
51391
|
+
// ../tui-base/src/routes/session/skills-panel.tsx
|
|
51392
|
+
import { TextAttributes as TextAttributes9 } from "@opentui/core";
|
|
51393
|
+
function openSkillsPanel() {
|
|
51394
|
+
setBridgeOpen(true);
|
|
51395
|
+
}
|
|
51396
|
+
function useSkillsPanelOpenState() {
|
|
51397
|
+
onCleanup(() => setPanelOpen2(false));
|
|
51398
|
+
return [skillsPanelOpen, setPanelOpen2];
|
|
51399
|
+
}
|
|
51400
|
+
function formatSkillLine(row, selected) {
|
|
51401
|
+
return `${selected ? "\u203A " : " "}${row.name.padEnd(30)}`;
|
|
51402
|
+
}
|
|
51403
|
+
function SkillsPanel(props) {
|
|
51404
|
+
const theme = useThemeOptional();
|
|
51405
|
+
const dialog = useDialog();
|
|
51406
|
+
const [open, setOpen] = useSkillsPanelOpenState();
|
|
51407
|
+
const [filterOpen, setFilterOpen] = createSignal(false);
|
|
51408
|
+
const [filter, setFilter] = createSignal("");
|
|
51409
|
+
const [cursor, setCursor] = createSignal(0);
|
|
51410
|
+
const [busy, setBusy] = createSignal(false);
|
|
51411
|
+
const [rows, setRows] = createSignal([]);
|
|
51412
|
+
const [status, setStatus] = createSignal(undefined);
|
|
51413
|
+
const [pending, setPending] = createSignal(new Map);
|
|
51414
|
+
let statusTimer;
|
|
51415
|
+
onCleanup(() => clearTimeout(statusTimer));
|
|
51416
|
+
createEffect(() => {
|
|
51417
|
+
if (bridgeOpen()) {
|
|
51418
|
+
setBridgeOpen(false);
|
|
51419
|
+
setFilter("");
|
|
51420
|
+
setFilterOpen(false);
|
|
51421
|
+
setCursor(0);
|
|
51422
|
+
setPending(new Map);
|
|
51423
|
+
setOpen(true);
|
|
51424
|
+
rescan();
|
|
51425
|
+
}
|
|
51426
|
+
});
|
|
51427
|
+
function flash(message, autoClearMs) {
|
|
51428
|
+
clearTimeout(statusTimer);
|
|
51429
|
+
setStatus(message);
|
|
51430
|
+
if (autoClearMs !== undefined) {
|
|
51431
|
+
statusTimer = setTimeout(() => setStatus(undefined), autoClearMs);
|
|
51432
|
+
}
|
|
51433
|
+
}
|
|
51434
|
+
async function rescan(notice) {
|
|
51435
|
+
if (notice === undefined)
|
|
51436
|
+
flash("scanning\u2026");
|
|
51437
|
+
const scanned = await scanAvailableSkills(props.source(), props.curated());
|
|
51438
|
+
setRows(scanned);
|
|
51439
|
+
if (notice !== undefined) {
|
|
51440
|
+
flash(notice, 1e4);
|
|
51441
|
+
} else {
|
|
51442
|
+
flash(undefined);
|
|
51443
|
+
}
|
|
51444
|
+
}
|
|
51445
|
+
function close() {
|
|
51446
|
+
if (filterOpen()) {
|
|
51447
|
+
setFilterOpen(false);
|
|
51448
|
+
setFilter("");
|
|
51449
|
+
return;
|
|
51450
|
+
}
|
|
51451
|
+
if (pending().size > 0) {
|
|
51452
|
+
const count = pending().size;
|
|
51453
|
+
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
51454
|
+
title: `Discard ${count} pending change${count === 1 ? "" : "s"}?`,
|
|
51455
|
+
message: "Pending install/uninstall marks are not applied yet.",
|
|
51456
|
+
label: {
|
|
51457
|
+
confirm: "Discard",
|
|
51458
|
+
cancel: "Keep editing"
|
|
51459
|
+
},
|
|
51460
|
+
onConfirm: () => {
|
|
51461
|
+
setPending(new Map);
|
|
51462
|
+
setOpen(false);
|
|
51463
|
+
setTimeout(() => props.onClosed?.(), 3);
|
|
51464
|
+
}
|
|
51465
|
+
}), undefined, {
|
|
51466
|
+
tone: "warning"
|
|
51467
|
+
});
|
|
51468
|
+
return;
|
|
51469
|
+
}
|
|
51470
|
+
setOpen(false);
|
|
51471
|
+
setTimeout(() => props.onClosed?.(), 3);
|
|
51472
|
+
}
|
|
51473
|
+
const visible = createMemo(() => filterSkillRows(rows(), filter()));
|
|
51474
|
+
const current = createMemo(() => {
|
|
51475
|
+
const list = visible();
|
|
51476
|
+
return list[Math.min(cursor(), list.length - 1)];
|
|
51477
|
+
});
|
|
51478
|
+
const cursorIndex = createMemo(() => visible().slice(0, 12).indexOf(current()));
|
|
51479
|
+
function moveCursor(delta) {
|
|
51480
|
+
const count = visible().length;
|
|
51481
|
+
if (count === 0)
|
|
51482
|
+
return;
|
|
51483
|
+
setCursor(Math.max(0, Math.min(cursor() + delta, count - 1)));
|
|
51484
|
+
}
|
|
51485
|
+
function togglePending(row) {
|
|
51486
|
+
if (row === undefined || busy())
|
|
51487
|
+
return;
|
|
51488
|
+
const effective = pending().get(row.name) ?? row.installed;
|
|
51489
|
+
const next = new Map(pending());
|
|
51490
|
+
next.set(row.name, !effective);
|
|
51491
|
+
setPending(next);
|
|
51492
|
+
}
|
|
51493
|
+
async function applyPending() {
|
|
51494
|
+
if (busy() || pending().size === 0)
|
|
51495
|
+
return;
|
|
51496
|
+
setBusy(true);
|
|
51497
|
+
const source = props.source();
|
|
51498
|
+
const curated = props.curated();
|
|
51499
|
+
await ensureCuratedDir(curated);
|
|
51500
|
+
const results = [];
|
|
51501
|
+
for (const [name, targetState] of pending()) {
|
|
51502
|
+
const error = await applyOneSkillChange(name, targetState, source, curated);
|
|
51503
|
+
results.push({
|
|
51504
|
+
name,
|
|
51505
|
+
error
|
|
51506
|
+
});
|
|
51507
|
+
}
|
|
51508
|
+
setPending(new Map);
|
|
51509
|
+
setBusy(false);
|
|
51510
|
+
const summary = skillApplySummary(results);
|
|
51511
|
+
rescan(summary === "" ? undefined : summary);
|
|
51512
|
+
}
|
|
51513
|
+
function onReturn() {
|
|
51514
|
+
if (filterOpen()) {
|
|
51515
|
+
setFilterOpen(false);
|
|
51516
|
+
setFilter("");
|
|
51517
|
+
return;
|
|
51518
|
+
}
|
|
51519
|
+
if (pending().size > 0) {
|
|
51520
|
+
applyPending();
|
|
51521
|
+
return;
|
|
51522
|
+
}
|
|
51523
|
+
togglePending(current());
|
|
51524
|
+
}
|
|
51525
|
+
Keymap2.createLayer(() => ({
|
|
51526
|
+
mode: "global",
|
|
51527
|
+
enabled: open() && dialog.stack.length === 0,
|
|
51528
|
+
priority: 2,
|
|
51529
|
+
commands: [{
|
|
51530
|
+
bind: "escape",
|
|
51531
|
+
title: "Close skills manager",
|
|
51532
|
+
group: "Skills",
|
|
51533
|
+
run: close
|
|
51534
|
+
}, {
|
|
51535
|
+
bind: "/",
|
|
51536
|
+
title: "Filter skills",
|
|
51537
|
+
group: "Skills",
|
|
51538
|
+
enabled: () => !filterOpen(),
|
|
51539
|
+
run: () => {
|
|
51540
|
+
setFilterOpen(true);
|
|
51541
|
+
return true;
|
|
51542
|
+
}
|
|
51543
|
+
}, {
|
|
51544
|
+
bind: "space",
|
|
51545
|
+
title: "Mark install/uninstall",
|
|
51546
|
+
group: "Skills",
|
|
51547
|
+
enabled: () => !filterOpen(),
|
|
51548
|
+
run: () => {
|
|
51549
|
+
togglePending(current());
|
|
51550
|
+
return true;
|
|
51551
|
+
}
|
|
51552
|
+
}, {
|
|
51553
|
+
bind: "return",
|
|
51554
|
+
title: "Commit input / apply batch",
|
|
51555
|
+
group: "Skills",
|
|
51556
|
+
run: () => {
|
|
51557
|
+
onReturn();
|
|
51558
|
+
return true;
|
|
51559
|
+
}
|
|
51560
|
+
}, {
|
|
51561
|
+
bind: "up,k",
|
|
51562
|
+
title: "Previous skill",
|
|
51563
|
+
group: "Skills",
|
|
51564
|
+
enabled: () => !filterOpen(),
|
|
51565
|
+
run: () => moveCursor(-1)
|
|
51566
|
+
}, {
|
|
51567
|
+
bind: "down,j",
|
|
51568
|
+
title: "Next skill",
|
|
51569
|
+
group: "Skills",
|
|
51570
|
+
enabled: () => !filterOpen(),
|
|
51571
|
+
run: () => moveCursor(1)
|
|
51572
|
+
}]
|
|
51573
|
+
}));
|
|
51574
|
+
const selected = createMemo(() => current());
|
|
51575
|
+
return createComponent2(Show, {
|
|
51576
|
+
get when() {
|
|
51577
|
+
return open();
|
|
51578
|
+
},
|
|
51579
|
+
get children() {
|
|
51580
|
+
var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$5 = createElement("text");
|
|
51581
|
+
insertNode(_el$, _el$2);
|
|
51582
|
+
setProp(_el$, "flexShrink", 0);
|
|
51583
|
+
setProp(_el$, "width", "100%");
|
|
51584
|
+
setProp(_el$, "flexDirection", "column");
|
|
51585
|
+
setProp(_el$, "border", ["left"]);
|
|
51586
|
+
setProp(_el$, "paddingLeft", 1);
|
|
51587
|
+
setProp(_el$, "paddingRight", 1);
|
|
51588
|
+
insertNode(_el$2, _el$3);
|
|
51589
|
+
insertNode(_el$2, _el$5);
|
|
51590
|
+
setProp(_el$2, "height", 1);
|
|
51591
|
+
setProp(_el$2, "flexShrink", 0);
|
|
51592
|
+
setProp(_el$2, "flexDirection", "row");
|
|
51593
|
+
insertNode(_el$3, createTextNode(`\uD83D\uDEE0 Skills`));
|
|
51594
|
+
setProp(_el$3, "wrapMode", "none");
|
|
51595
|
+
setProp(_el$5, "wrapMode", "none");
|
|
51596
|
+
insert(_el$5, () => ` ${visible().length}/${rows().length} / filter space mark enter apply esc close`);
|
|
51597
|
+
insert(_el$, createComponent2(Show, {
|
|
51598
|
+
get when() {
|
|
51599
|
+
return !filterOpen();
|
|
51600
|
+
},
|
|
51601
|
+
get fallback() {
|
|
51602
|
+
return (() => {
|
|
51603
|
+
var _el$11 = createElement("box"), _el$12 = createElement("input");
|
|
51604
|
+
insertNode(_el$11, _el$12);
|
|
51605
|
+
setProp(_el$11, "height", 1);
|
|
51606
|
+
setProp(_el$11, "flexShrink", 0);
|
|
51607
|
+
setProp(_el$11, "flexDirection", "row");
|
|
51608
|
+
use((renderable) => {
|
|
51609
|
+
setTimeout(() => {
|
|
51610
|
+
if (!renderable.isDestroyed)
|
|
51611
|
+
renderable.focus();
|
|
51612
|
+
}, 1);
|
|
51613
|
+
}, _el$12);
|
|
51614
|
+
setProp(_el$12, "flexGrow", 1);
|
|
51615
|
+
setProp(_el$12, "placeholder", "filter");
|
|
51616
|
+
setProp(_el$12, "onInput", (value) => setFilter(value));
|
|
51617
|
+
effect((_p$) => {
|
|
51618
|
+
var _v$7 = theme?.text.muted ?? "#565f89", _v$8 = filter();
|
|
51619
|
+
_v$7 !== _p$.e && (_p$.e = setProp(_el$12, "placeholderColor", _v$7, _p$.e));
|
|
51620
|
+
_v$8 !== _p$.t && (_p$.t = setProp(_el$12, "value", _v$8, _p$.t));
|
|
51621
|
+
return _p$;
|
|
51622
|
+
}, {
|
|
51623
|
+
e: undefined,
|
|
51624
|
+
t: undefined
|
|
51625
|
+
});
|
|
51626
|
+
return _el$11;
|
|
51627
|
+
})();
|
|
51628
|
+
},
|
|
51629
|
+
get children() {
|
|
51630
|
+
var _el$6 = createElement("box"), _el$7 = createElement("text");
|
|
51631
|
+
insertNode(_el$6, _el$7);
|
|
51632
|
+
setProp(_el$6, "height", 1);
|
|
51633
|
+
setProp(_el$6, "flexShrink", 0);
|
|
51634
|
+
insertNode(_el$7, createTextNode(`SKILL STATE`));
|
|
51635
|
+
setProp(_el$7, "wrapMode", "none");
|
|
51636
|
+
effect((_$p) => setProp(_el$7, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
51637
|
+
return _el$6;
|
|
51638
|
+
}
|
|
51639
|
+
}), null);
|
|
51640
|
+
insert(_el$, createComponent2(Show, {
|
|
51641
|
+
get when() {
|
|
51642
|
+
return visible().length > 0;
|
|
51643
|
+
},
|
|
51644
|
+
get fallback() {
|
|
51645
|
+
return (() => {
|
|
51646
|
+
var _el$13 = createElement("box"), _el$14 = createElement("text");
|
|
51647
|
+
insertNode(_el$13, _el$14);
|
|
51648
|
+
setProp(_el$13, "height", 1);
|
|
51649
|
+
setProp(_el$13, "flexShrink", 0);
|
|
51650
|
+
setProp(_el$14, "wrapMode", "none");
|
|
51651
|
+
insert(_el$14, (() => {
|
|
51652
|
+
var _c$ = memo2(() => rows().length === 0);
|
|
51653
|
+
return () => _c$() ? `no skills in ${props.source()}` : "no skills match the filter";
|
|
51654
|
+
})());
|
|
51655
|
+
effect((_$p) => setProp(_el$14, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
51656
|
+
return _el$13;
|
|
51657
|
+
})();
|
|
51658
|
+
},
|
|
51659
|
+
get children() {
|
|
51660
|
+
return createComponent2(For, {
|
|
51661
|
+
get each() {
|
|
51662
|
+
return visible().slice(0, 12);
|
|
51663
|
+
},
|
|
51664
|
+
children: (row, index) => {
|
|
51665
|
+
const effective = createMemo(() => pending().get(row.name));
|
|
51666
|
+
return (() => {
|
|
51667
|
+
var _el$15 = createElement("box"), _el$16 = createElement("text"), _el$17 = createElement("text");
|
|
51668
|
+
insertNode(_el$15, _el$16);
|
|
51669
|
+
insertNode(_el$15, _el$17);
|
|
51670
|
+
setProp(_el$15, "height", 1);
|
|
51671
|
+
setProp(_el$15, "flexShrink", 0);
|
|
51672
|
+
setProp(_el$15, "flexDirection", "row");
|
|
51673
|
+
setProp(_el$16, "wrapMode", "none");
|
|
51674
|
+
insert(_el$16, () => formatSkillLine(row, index() === cursorIndex()));
|
|
51675
|
+
setProp(_el$17, "wrapMode", "none");
|
|
51676
|
+
insert(_el$17, () => skillStateText(row, effective()));
|
|
51677
|
+
effect((_p$) => {
|
|
51678
|
+
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";
|
|
51679
|
+
_v$9 !== _p$.e && (_p$.e = setProp(_el$16, "fg", _v$9, _p$.e));
|
|
51680
|
+
_v$0 !== _p$.t && (_p$.t = setProp(_el$17, "fg", _v$0, _p$.t));
|
|
51681
|
+
return _p$;
|
|
51682
|
+
}, {
|
|
51683
|
+
e: undefined,
|
|
51684
|
+
t: undefined
|
|
51685
|
+
});
|
|
51686
|
+
return _el$15;
|
|
51687
|
+
})();
|
|
51688
|
+
}
|
|
51689
|
+
});
|
|
51690
|
+
}
|
|
51691
|
+
}), null);
|
|
51692
|
+
insert(_el$, createComponent2(Show, {
|
|
51693
|
+
get when() {
|
|
51694
|
+
return memo2(() => selected() !== undefined)() && selected().description !== "";
|
|
51695
|
+
},
|
|
51696
|
+
get children() {
|
|
51697
|
+
var _el$9 = createElement("box"), _el$0 = createElement("text");
|
|
51698
|
+
insertNode(_el$9, _el$0);
|
|
51699
|
+
setProp(_el$9, "height", 1);
|
|
51700
|
+
setProp(_el$9, "flexShrink", 0);
|
|
51701
|
+
setProp(_el$0, "wrapMode", "none");
|
|
51702
|
+
insert(_el$0, () => ` ${selected().description}`);
|
|
51703
|
+
effect((_$p) => setProp(_el$0, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
51704
|
+
return _el$9;
|
|
51705
|
+
}
|
|
51706
|
+
}), null);
|
|
51707
|
+
insert(_el$, createComponent2(Show, {
|
|
51708
|
+
get when() {
|
|
51709
|
+
return status() !== undefined;
|
|
51710
|
+
},
|
|
51711
|
+
get children() {
|
|
51712
|
+
var _el$1 = createElement("box"), _el$10 = createElement("text");
|
|
51713
|
+
insertNode(_el$1, _el$10);
|
|
51714
|
+
setProp(_el$1, "height", 1);
|
|
51715
|
+
setProp(_el$1, "flexShrink", 0);
|
|
51716
|
+
setProp(_el$10, "wrapMode", "none");
|
|
51717
|
+
insert(_el$10, status);
|
|
51718
|
+
effect((_$p) => setProp(_el$10, "fg", warningColor(theme ?? undefined), _$p));
|
|
51719
|
+
return _el$1;
|
|
51720
|
+
}
|
|
51721
|
+
}), null);
|
|
51722
|
+
effect((_p$) => {
|
|
51723
|
+
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";
|
|
51724
|
+
_v$ !== _p$.e && (_p$.e = setProp(_el$, "height", _v$, _p$.e));
|
|
51725
|
+
_v$2 !== _p$.t && (_p$.t = setProp(_el$, "borderColor", _v$2, _p$.t));
|
|
51726
|
+
_v$3 !== _p$.a && (_p$.a = setProp(_el$, "backgroundColor", _v$3, _p$.a));
|
|
51727
|
+
_v$4 !== _p$.o && (_p$.o = setProp(_el$3, "fg", _v$4, _p$.o));
|
|
51728
|
+
_v$5 !== _p$.i && (_p$.i = setProp(_el$3, "attributes", _v$5, _p$.i));
|
|
51729
|
+
_v$6 !== _p$.n && (_p$.n = setProp(_el$5, "fg", _v$6, _p$.n));
|
|
51730
|
+
return _p$;
|
|
51731
|
+
}, {
|
|
51732
|
+
e: undefined,
|
|
51733
|
+
t: undefined,
|
|
51734
|
+
a: undefined,
|
|
51735
|
+
o: undefined,
|
|
51736
|
+
i: undefined,
|
|
51737
|
+
n: undefined
|
|
51738
|
+
});
|
|
51739
|
+
return _el$;
|
|
51740
|
+
}
|
|
51741
|
+
});
|
|
51742
|
+
}
|
|
51743
|
+
var bridgeOpen, setBridgeOpen, panelOpen2, setPanelOpen2, skillsPanelOpen;
|
|
51744
|
+
var init_skills_panel = __esm(() => {
|
|
51745
|
+
init_index_bun();
|
|
51746
|
+
init_index_bun();
|
|
51747
|
+
init_index_bun();
|
|
51748
|
+
init_index_bun();
|
|
51749
|
+
init_index_bun();
|
|
51750
|
+
init_index_bun();
|
|
51751
|
+
init_index_bun();
|
|
51752
|
+
init_index_bun();
|
|
51753
|
+
init_index_bun();
|
|
51754
|
+
init_server();
|
|
51755
|
+
init_keymap();
|
|
51756
|
+
init_dialog();
|
|
51757
|
+
init_dialog_confirm();
|
|
51758
|
+
init_theme3();
|
|
51759
|
+
init_semantic();
|
|
51760
|
+
init_skills_manage();
|
|
51761
|
+
[bridgeOpen, setBridgeOpen] = createSignal(false);
|
|
51762
|
+
[panelOpen2, setPanelOpen2] = createSignal(false);
|
|
51763
|
+
skillsPanelOpen = panelOpen2;
|
|
51764
|
+
});
|
|
51765
|
+
|
|
50597
51766
|
// ../tui-base/src/routes/session/sessions-search.tsx
|
|
50598
51767
|
function openSessionsSearch() {
|
|
50599
|
-
|
|
51768
|
+
setBridgeOpen2(true);
|
|
50600
51769
|
}
|
|
50601
51770
|
function useSessionsSearchOpenState() {
|
|
50602
|
-
onCleanup(() =>
|
|
50603
|
-
return [sessionsSearchOpen,
|
|
51771
|
+
onCleanup(() => setPanelOpen3(false));
|
|
51772
|
+
return [sessionsSearchOpen, setPanelOpen3];
|
|
50604
51773
|
}
|
|
50605
51774
|
function formatSearchHitLine(hit) {
|
|
50606
51775
|
const snippet = hit.snippet.replace(/\s+/g, " ").trim();
|
|
50607
51776
|
return snippet ? `${hit.id} \u2014 ${snippet}` : hit.id;
|
|
50608
51777
|
}
|
|
51778
|
+
function hitCursorStep(current, delta, count) {
|
|
51779
|
+
if (count <= 0)
|
|
51780
|
+
return current;
|
|
51781
|
+
return (current + delta + count) % count;
|
|
51782
|
+
}
|
|
51783
|
+
function enterAction(hitCount) {
|
|
51784
|
+
return hitCount > 0 ? "resume" : "search";
|
|
51785
|
+
}
|
|
51786
|
+
function resumeFailureText(error) {
|
|
51787
|
+
return `resume failed \u2014 ${String(error instanceof Error ? error.message : error).slice(0, 150)}`;
|
|
51788
|
+
}
|
|
51789
|
+
async function resumeSearchHit(options) {
|
|
51790
|
+
try {
|
|
51791
|
+
await options.onResumed(options.sessionId);
|
|
51792
|
+
options.onSuccess();
|
|
51793
|
+
} catch (error) {
|
|
51794
|
+
options.onFailure(resumeFailureText(error));
|
|
51795
|
+
}
|
|
51796
|
+
}
|
|
50609
51797
|
function SessionsSearch(props) {
|
|
50610
51798
|
const theme = useThemeOptional();
|
|
50611
51799
|
const dialog = useDialog();
|
|
@@ -50614,12 +51802,15 @@ function SessionsSearch(props) {
|
|
|
50614
51802
|
const [hits, setHits] = createSignal([]);
|
|
50615
51803
|
const [searched, setSearched] = createSignal(false);
|
|
50616
51804
|
const [busy, setBusy] = createSignal(false);
|
|
51805
|
+
const [cursor, setCursor] = createSignal(0);
|
|
51806
|
+
const [resumeError, setResumeError] = createSignal("");
|
|
50617
51807
|
createEffect(() => {
|
|
50618
|
-
if (
|
|
50619
|
-
|
|
51808
|
+
if (bridgeOpen2()) {
|
|
51809
|
+
setBridgeOpen2(false);
|
|
50620
51810
|
setQuery("");
|
|
50621
51811
|
setHits([]);
|
|
50622
51812
|
setSearched(false);
|
|
51813
|
+
setResumeError("");
|
|
50623
51814
|
setOpen(true);
|
|
50624
51815
|
}
|
|
50625
51816
|
});
|
|
@@ -50628,16 +51819,49 @@ function SessionsSearch(props) {
|
|
|
50628
51819
|
if (!needle || busy())
|
|
50629
51820
|
return;
|
|
50630
51821
|
setBusy(true);
|
|
51822
|
+
setResumeError("");
|
|
50631
51823
|
try {
|
|
50632
51824
|
const found = await props.seam.searchSessions(needle);
|
|
50633
51825
|
setHits(found.slice(0, ROW_CAP));
|
|
51826
|
+
setCursor(0);
|
|
50634
51827
|
} catch {
|
|
50635
51828
|
setHits([]);
|
|
51829
|
+
setCursor(0);
|
|
50636
51830
|
} finally {
|
|
50637
51831
|
setSearched(true);
|
|
50638
51832
|
setBusy(false);
|
|
50639
51833
|
}
|
|
50640
51834
|
}
|
|
51835
|
+
function moveCursor(delta) {
|
|
51836
|
+
const count = hits().length;
|
|
51837
|
+
if (count === 0)
|
|
51838
|
+
return;
|
|
51839
|
+
setCursor((current) => hitCursorStep(current, delta, count));
|
|
51840
|
+
}
|
|
51841
|
+
function enterKey() {
|
|
51842
|
+
if (busy())
|
|
51843
|
+
return;
|
|
51844
|
+
if (enterAction(hits().length) === "resume") {
|
|
51845
|
+
const hit = hits()[cursor()];
|
|
51846
|
+
if (!hit)
|
|
51847
|
+
return;
|
|
51848
|
+
setBusy(true);
|
|
51849
|
+
resumeSearchHit({
|
|
51850
|
+
sessionId: hit.id,
|
|
51851
|
+
onResumed: (sessionId) => props.onResumed?.(sessionId),
|
|
51852
|
+
onSuccess: () => {
|
|
51853
|
+
setBusy(false);
|
|
51854
|
+
close();
|
|
51855
|
+
},
|
|
51856
|
+
onFailure: (statusLine) => {
|
|
51857
|
+
setBusy(false);
|
|
51858
|
+
setResumeError(statusLine);
|
|
51859
|
+
}
|
|
51860
|
+
});
|
|
51861
|
+
return;
|
|
51862
|
+
}
|
|
51863
|
+
run();
|
|
51864
|
+
}
|
|
50641
51865
|
function close() {
|
|
50642
51866
|
setOpen(false);
|
|
50643
51867
|
setTimeout(() => props.onClosed?.(), 3);
|
|
@@ -50646,17 +51870,34 @@ function SessionsSearch(props) {
|
|
|
50646
51870
|
mode: "global",
|
|
50647
51871
|
enabled: open() && dialog.stack.length === 0,
|
|
50648
51872
|
priority: 2,
|
|
50649
|
-
commands: [
|
|
50650
|
-
|
|
50651
|
-
|
|
50652
|
-
|
|
50653
|
-
|
|
50654
|
-
|
|
50655
|
-
|
|
50656
|
-
|
|
50657
|
-
|
|
50658
|
-
|
|
50659
|
-
|
|
51873
|
+
commands: [
|
|
51874
|
+
{
|
|
51875
|
+
bind: "escape",
|
|
51876
|
+
title: "Close session search",
|
|
51877
|
+
group: "Search",
|
|
51878
|
+
run: close
|
|
51879
|
+
},
|
|
51880
|
+
{
|
|
51881
|
+
bind: "return",
|
|
51882
|
+
title: "Search stored sessions / resume selected hit",
|
|
51883
|
+
group: "Search",
|
|
51884
|
+
run: () => enterKey()
|
|
51885
|
+
},
|
|
51886
|
+
{
|
|
51887
|
+
bind: "down",
|
|
51888
|
+
title: "Next hit",
|
|
51889
|
+
group: "Search",
|
|
51890
|
+
enabled: () => hits().length > 0,
|
|
51891
|
+
run: () => moveCursor(1)
|
|
51892
|
+
},
|
|
51893
|
+
{
|
|
51894
|
+
bind: "up",
|
|
51895
|
+
title: "Previous hit",
|
|
51896
|
+
group: "Search",
|
|
51897
|
+
enabled: () => hits().length > 0,
|
|
51898
|
+
run: () => moveCursor(-1)
|
|
51899
|
+
}
|
|
51900
|
+
]
|
|
50660
51901
|
}));
|
|
50661
51902
|
Keymap2.createLayer(() => ({
|
|
50662
51903
|
mode: "global",
|
|
@@ -50665,10 +51906,12 @@ function SessionsSearch(props) {
|
|
|
50665
51906
|
id: "session.searchSessions",
|
|
50666
51907
|
title: "Search stored sessions",
|
|
50667
51908
|
group: "Session",
|
|
50668
|
-
run: () =>
|
|
51909
|
+
run: () => setBridgeOpen2(true)
|
|
50669
51910
|
}]
|
|
50670
51911
|
}));
|
|
50671
51912
|
const status = createMemo(() => {
|
|
51913
|
+
if (resumeError())
|
|
51914
|
+
return resumeError();
|
|
50672
51915
|
if (busy())
|
|
50673
51916
|
return "searching\u2026";
|
|
50674
51917
|
if (!searched())
|
|
@@ -50704,7 +51947,7 @@ function SessionsSearch(props) {
|
|
|
50704
51947
|
var _el$5 = createElement("text");
|
|
50705
51948
|
setProp(_el$5, "wrapMode", "none");
|
|
50706
51949
|
insert(_el$5, () => ` ${status()}`);
|
|
50707
|
-
effect((_$p) => setProp(_el$5, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
51950
|
+
effect((_$p) => setProp(_el$5, "fg", resumeError() ? theme?.text.feedback.error.base ?? "#f7768e" : theme?.text.muted ?? "#565f89", _$p));
|
|
50708
51951
|
return _el$5;
|
|
50709
51952
|
}
|
|
50710
51953
|
}), null);
|
|
@@ -50721,7 +51964,7 @@ function SessionsSearch(props) {
|
|
|
50721
51964
|
setProp(_el$7, "flexGrow", 1);
|
|
50722
51965
|
setProp(_el$7, "placeholder", "Full-text over stored sessions");
|
|
50723
51966
|
setProp(_el$7, "onInput", (value) => setQuery(value));
|
|
50724
|
-
setProp(_el$7, "onSubmit", () =>
|
|
51967
|
+
setProp(_el$7, "onSubmit", () => enterKey());
|
|
50725
51968
|
insert(_el$, createComponent2(Show, {
|
|
50726
51969
|
get when() {
|
|
50727
51970
|
return hits().length > 0;
|
|
@@ -50743,14 +51986,17 @@ function SessionsSearch(props) {
|
|
|
50743
51986
|
get each() {
|
|
50744
51987
|
return hits();
|
|
50745
51988
|
},
|
|
50746
|
-
children: (hit) => (() => {
|
|
51989
|
+
children: (hit, index) => (() => {
|
|
50747
51990
|
var _el$0 = createElement("box"), _el$1 = createElement("text");
|
|
50748
51991
|
insertNode(_el$0, _el$1);
|
|
50749
51992
|
setProp(_el$0, "height", 1);
|
|
50750
51993
|
setProp(_el$0, "flexShrink", 0);
|
|
50751
51994
|
setProp(_el$1, "wrapMode", "none");
|
|
50752
|
-
insert(_el$1, () =>
|
|
50753
|
-
|
|
51995
|
+
insert(_el$1, (() => {
|
|
51996
|
+
var _c$ = memo2(() => index() === cursor());
|
|
51997
|
+
return () => _c$() ? `\u203A ${formatSearchHitLine(hit)}` : ` ${formatSearchHitLine(hit)}`;
|
|
51998
|
+
})());
|
|
51999
|
+
effect((_$p) => setProp(_el$1, "fg", index() === cursor() ? theme?.text.base ?? "#e6e6e6" : theme?.text.muted ?? "#565f89", _$p));
|
|
50754
52000
|
return _el$0;
|
|
50755
52001
|
})()
|
|
50756
52002
|
});
|
|
@@ -50777,7 +52023,7 @@ function SessionsSearch(props) {
|
|
|
50777
52023
|
}
|
|
50778
52024
|
});
|
|
50779
52025
|
}
|
|
50780
|
-
var
|
|
52026
|
+
var bridgeOpen2, setBridgeOpen2, panelOpen3, setPanelOpen3, sessionsSearchOpen, ROW_CAP = 8;
|
|
50781
52027
|
var init_sessions_search = __esm(() => {
|
|
50782
52028
|
init_index_bun();
|
|
50783
52029
|
init_index_bun();
|
|
@@ -50793,44 +52039,124 @@ var init_sessions_search = __esm(() => {
|
|
|
50793
52039
|
init_keymap();
|
|
50794
52040
|
init_dialog();
|
|
50795
52041
|
init_theme3();
|
|
50796
|
-
[
|
|
50797
|
-
[
|
|
50798
|
-
sessionsSearchOpen =
|
|
52042
|
+
[bridgeOpen2, setBridgeOpen2] = createSignal(false);
|
|
52043
|
+
[panelOpen3, setPanelOpen3] = createSignal(false);
|
|
52044
|
+
sessionsSearchOpen = panelOpen3;
|
|
50799
52045
|
});
|
|
50800
52046
|
|
|
50801
52047
|
// ../tui-base/src/routes/session/plugins-panel.tsx
|
|
50802
|
-
import { TextAttributes as
|
|
52048
|
+
import { TextAttributes as TextAttributes10 } from "@opentui/core";
|
|
50803
52049
|
function openPluginsPanel() {
|
|
50804
|
-
|
|
52050
|
+
setBridgeOpen3(true);
|
|
50805
52051
|
}
|
|
50806
52052
|
function usePluginsPanelOpenState() {
|
|
50807
|
-
onCleanup(() =>
|
|
50808
|
-
return [pluginsPanelOpen,
|
|
52053
|
+
onCleanup(() => setPanelOpen4(false));
|
|
52054
|
+
return [pluginsPanelOpen, setPanelOpen4];
|
|
50809
52055
|
}
|
|
50810
52056
|
function formatPluginLine(row) {
|
|
50811
52057
|
return `${row.name}@${row.version}`;
|
|
50812
52058
|
}
|
|
52059
|
+
function errorMessage2(error) {
|
|
52060
|
+
return String(error instanceof Error ? error.message : error).slice(0, 90);
|
|
52061
|
+
}
|
|
50813
52062
|
function filterPluginRows(rows, query) {
|
|
50814
52063
|
const needle = query.trim().toLowerCase();
|
|
50815
52064
|
if (!needle)
|
|
50816
52065
|
return [...rows];
|
|
50817
52066
|
return rows.filter((row) => formatPluginLine(row).toLowerCase().includes(needle));
|
|
50818
52067
|
}
|
|
52068
|
+
function bundleStateText(row) {
|
|
52069
|
+
const base = !row.installed && row.optional ? "available" : row.enabled ? "on" : "off";
|
|
52070
|
+
if (row.error !== undefined && row.error !== "")
|
|
52071
|
+
return `${base} error`;
|
|
52072
|
+
if (row.readOnlyReason !== undefined && row.readOnlyReason !== "")
|
|
52073
|
+
return `${base} read-only`;
|
|
52074
|
+
return base;
|
|
52075
|
+
}
|
|
52076
|
+
function pluginBundleViews(bundles) {
|
|
52077
|
+
return [...bundles].sort((a, b) => a.name.localeCompare(b.name)).map((bundle) => ({
|
|
52078
|
+
name: bundle.name,
|
|
52079
|
+
version: bundle.version ?? "",
|
|
52080
|
+
label: bundle.version !== undefined && bundle.version !== "" ? `${bundle.name}@${bundle.version}` : bundle.name,
|
|
52081
|
+
enabled: bundle.enabled === true,
|
|
52082
|
+
installed: bundle.installed === true,
|
|
52083
|
+
optional: bundle.optional === true,
|
|
52084
|
+
removable: bundle.removable === true,
|
|
52085
|
+
toggleable: bundle.readOnlyReason === undefined && (bundle.error === undefined || bundle.error === ""),
|
|
52086
|
+
readOnlyReason: bundle.readOnlyReason,
|
|
52087
|
+
error: bundle.error
|
|
52088
|
+
}));
|
|
52089
|
+
}
|
|
52090
|
+
function legacyPluginViews(rows) {
|
|
52091
|
+
return pluginBundleViews([...rows].map((row) => ({
|
|
52092
|
+
name: row.name,
|
|
52093
|
+
version: row.version,
|
|
52094
|
+
enabled: true,
|
|
52095
|
+
installed: true,
|
|
52096
|
+
optional: false,
|
|
52097
|
+
removable: false
|
|
52098
|
+
}))).map((view) => ({
|
|
52099
|
+
...view,
|
|
52100
|
+
toggleable: false
|
|
52101
|
+
}));
|
|
52102
|
+
}
|
|
52103
|
+
function pluginChangeNotice(change) {
|
|
52104
|
+
const target = change.target;
|
|
52105
|
+
switch (change.application) {
|
|
52106
|
+
case "applied":
|
|
52107
|
+
return `${target}: change applied`;
|
|
52108
|
+
case "restart-required":
|
|
52109
|
+
return `${target}: change saved \u2014 restart the host for it to take effect`;
|
|
52110
|
+
case "overridden":
|
|
52111
|
+
return `${target}: change saved, but a higher-priority config keeps the previous state`;
|
|
52112
|
+
case "failed":
|
|
52113
|
+
return `${target}: change failed${change.error ? ` \u2014 ${change.error}` : ""}`;
|
|
52114
|
+
case "cancelled":
|
|
52115
|
+
return `${target}: change cancelled`;
|
|
52116
|
+
}
|
|
52117
|
+
}
|
|
52118
|
+
function installPreviewLine(inspection) {
|
|
52119
|
+
const version = inspection.version !== undefined && inspection.version !== "" ? `@${inspection.version}` : "";
|
|
52120
|
+
const notBundle = inspection.bundle === false ? " (not a bundle package \u2014 installs as a plain dependency)" : "";
|
|
52121
|
+
return `${inspection.name ?? "spec"}${version}${notBundle}`;
|
|
52122
|
+
}
|
|
50819
52123
|
function PluginsPanel(props) {
|
|
50820
52124
|
const theme = useThemeOptional();
|
|
50821
52125
|
const dialog = useDialog();
|
|
50822
52126
|
const [open, setOpen] = usePluginsPanelOpenState();
|
|
50823
52127
|
const [filterOpen, setFilterOpen] = createSignal(false);
|
|
50824
52128
|
const [filter, setFilter] = createSignal("");
|
|
52129
|
+
const [cursor, setCursor] = createSignal(0);
|
|
52130
|
+
const [busy, setBusy] = createSignal(false);
|
|
52131
|
+
const [status, setStatus] = createSignal(undefined);
|
|
52132
|
+
const [installOpen, setInstallOpen] = createSignal(false);
|
|
52133
|
+
const [installText, setInstallText] = createSignal("");
|
|
52134
|
+
let statusTimer;
|
|
52135
|
+
onCleanup(() => clearTimeout(statusTimer));
|
|
50825
52136
|
createEffect(() => {
|
|
50826
|
-
if (
|
|
50827
|
-
|
|
52137
|
+
if (bridgeOpen3()) {
|
|
52138
|
+
setBridgeOpen3(false);
|
|
50828
52139
|
setFilter("");
|
|
50829
52140
|
setFilterOpen(false);
|
|
52141
|
+
setInstallOpen(false);
|
|
52142
|
+
setInstallText("");
|
|
52143
|
+
setCursor(0);
|
|
50830
52144
|
setOpen(true);
|
|
50831
52145
|
}
|
|
50832
52146
|
});
|
|
52147
|
+
function flash(message, autoClearMs) {
|
|
52148
|
+
clearTimeout(statusTimer);
|
|
52149
|
+
setStatus(message);
|
|
52150
|
+
if (autoClearMs !== undefined) {
|
|
52151
|
+
statusTimer = setTimeout(() => setStatus(undefined), autoClearMs);
|
|
52152
|
+
}
|
|
52153
|
+
}
|
|
50833
52154
|
function close() {
|
|
52155
|
+
if (installOpen()) {
|
|
52156
|
+
setInstallOpen(false);
|
|
52157
|
+
setInstallText("");
|
|
52158
|
+
return;
|
|
52159
|
+
}
|
|
50834
52160
|
if (filterOpen()) {
|
|
50835
52161
|
setFilterOpen(false);
|
|
50836
52162
|
setFilter("");
|
|
@@ -50839,15 +52165,156 @@ function PluginsPanel(props) {
|
|
|
50839
52165
|
setOpen(false);
|
|
50840
52166
|
setTimeout(() => props.onClosed?.(), 3);
|
|
50841
52167
|
}
|
|
50842
|
-
const
|
|
52168
|
+
const bundles = createMemo(() => {
|
|
50843
52169
|
open();
|
|
50844
52170
|
try {
|
|
50845
|
-
|
|
52171
|
+
const seam = props.seam;
|
|
52172
|
+
if (typeof seam.pluginBundles === "function")
|
|
52173
|
+
return pluginBundleViews(seam.pluginBundles());
|
|
52174
|
+
if (typeof seam.plugins === "function")
|
|
52175
|
+
return legacyPluginViews(seam.plugins());
|
|
52176
|
+
return [];
|
|
50846
52177
|
} catch {
|
|
50847
52178
|
return [];
|
|
50848
52179
|
}
|
|
50849
52180
|
});
|
|
50850
|
-
const visible = createMemo(() => filterPluginRows(
|
|
52181
|
+
const visible = createMemo(() => filterPluginRows(bundles(), filter()));
|
|
52182
|
+
const current = createMemo(() => {
|
|
52183
|
+
const rows = visible();
|
|
52184
|
+
return rows[Math.min(cursor(), rows.length - 1)];
|
|
52185
|
+
});
|
|
52186
|
+
const cursorIndex = createMemo(() => visible().slice(0, 12).indexOf(current()));
|
|
52187
|
+
function moveCursor(delta) {
|
|
52188
|
+
const count = visible().length;
|
|
52189
|
+
if (count === 0)
|
|
52190
|
+
return;
|
|
52191
|
+
const next = Math.max(0, Math.min(cursor() + delta, count - 1));
|
|
52192
|
+
setCursor(next);
|
|
52193
|
+
}
|
|
52194
|
+
async function toggle(row) {
|
|
52195
|
+
if (row === undefined)
|
|
52196
|
+
return;
|
|
52197
|
+
if (busy())
|
|
52198
|
+
return;
|
|
52199
|
+
if (!row.toggleable || typeof props.seam.setPluginBundleEnabled !== "function") {
|
|
52200
|
+
flash(`${row.name}: read-only${row.readOnlyReason ? ` (${row.readOnlyReason})` : ""}`, 4000);
|
|
52201
|
+
return;
|
|
52202
|
+
}
|
|
52203
|
+
setBusy(true);
|
|
52204
|
+
flash(`${row.enabled ? `disabling` : `enabling`} ${row.name}\u2026`);
|
|
52205
|
+
try {
|
|
52206
|
+
const change = await props.seam.setPluginBundleEnabled(row.name, !row.enabled);
|
|
52207
|
+
flash(pluginChangeNotice(change), 6000);
|
|
52208
|
+
} catch (error) {
|
|
52209
|
+
flash(`${row.name}: change failed \u2014 ${errorMessage2(error)}`, 8000);
|
|
52210
|
+
} finally {
|
|
52211
|
+
setBusy(false);
|
|
52212
|
+
}
|
|
52213
|
+
}
|
|
52214
|
+
function confirmRemove(row) {
|
|
52215
|
+
if (row === undefined || busy())
|
|
52216
|
+
return;
|
|
52217
|
+
if (!row.removable) {
|
|
52218
|
+
flash(`${row.name}: not removable`, 4000);
|
|
52219
|
+
return;
|
|
52220
|
+
}
|
|
52221
|
+
const name = row.name;
|
|
52222
|
+
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
52223
|
+
title: `Uninstall ${name}?`,
|
|
52224
|
+
message: `Removes the ${name} package from this profile. Its plugins stop at the change (or the next host start).`,
|
|
52225
|
+
label: {
|
|
52226
|
+
confirm: "Uninstall",
|
|
52227
|
+
cancel: "Keep"
|
|
52228
|
+
},
|
|
52229
|
+
onConfirm: () => void remove(name)
|
|
52230
|
+
}), undefined, {
|
|
52231
|
+
tone: "warning"
|
|
52232
|
+
});
|
|
52233
|
+
}
|
|
52234
|
+
async function remove(name) {
|
|
52235
|
+
if (busy())
|
|
52236
|
+
return;
|
|
52237
|
+
if (typeof props.seam.removePluginBundle !== "function")
|
|
52238
|
+
return;
|
|
52239
|
+
setBusy(true);
|
|
52240
|
+
flash(`uninstalling ${name}\u2026`);
|
|
52241
|
+
try {
|
|
52242
|
+
const change = await props.seam.removePluginBundle(name);
|
|
52243
|
+
flash(pluginChangeNotice(change), 8000);
|
|
52244
|
+
} catch (error) {
|
|
52245
|
+
flash(`${name}: change failed \u2014 ${errorMessage2(error)}`, 8000);
|
|
52246
|
+
} finally {
|
|
52247
|
+
setBusy(false);
|
|
52248
|
+
}
|
|
52249
|
+
}
|
|
52250
|
+
function beginInstall() {
|
|
52251
|
+
if (busy())
|
|
52252
|
+
return;
|
|
52253
|
+
if (typeof props.seam.installPluginSpec !== "function") {
|
|
52254
|
+
flash("install unavailable on this seam", 4000);
|
|
52255
|
+
return;
|
|
52256
|
+
}
|
|
52257
|
+
setInstallText("");
|
|
52258
|
+
setInstallOpen(true);
|
|
52259
|
+
}
|
|
52260
|
+
async function commitInstall() {
|
|
52261
|
+
const spec = installText().trim();
|
|
52262
|
+
if (spec === "") {
|
|
52263
|
+
flash("spec required (npm name, git url, path or tarball)", 4000);
|
|
52264
|
+
return;
|
|
52265
|
+
}
|
|
52266
|
+
setInstallOpen(false);
|
|
52267
|
+
setInstallText("");
|
|
52268
|
+
if (busy())
|
|
52269
|
+
return;
|
|
52270
|
+
if (typeof props.seam.inspectPluginSpec !== "function")
|
|
52271
|
+
return;
|
|
52272
|
+
setBusy(true);
|
|
52273
|
+
flash(`inspecting ${spec}\u2026`);
|
|
52274
|
+
let inspection;
|
|
52275
|
+
try {
|
|
52276
|
+
inspection = await props.seam.inspectPluginSpec(spec);
|
|
52277
|
+
} catch (error) {
|
|
52278
|
+
flash(`cannot install ${spec}: ${errorMessage2(error)}`, 8000);
|
|
52279
|
+
return;
|
|
52280
|
+
} finally {
|
|
52281
|
+
setBusy(false);
|
|
52282
|
+
}
|
|
52283
|
+
if (inspection.status === "refused") {
|
|
52284
|
+
flash(`cannot install ${spec}: ${inspection.problem} \u2014 ${inspection.reason}`, 8000);
|
|
52285
|
+
return;
|
|
52286
|
+
}
|
|
52287
|
+
const accepted = inspection;
|
|
52288
|
+
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
52289
|
+
title: "Install plugin?",
|
|
52290
|
+
get message() {
|
|
52291
|
+
return `${installPreviewLine(accepted)}${accepted.description ? ` \u2014 ${accepted.description}` : ""}`;
|
|
52292
|
+
},
|
|
52293
|
+
label: {
|
|
52294
|
+
confirm: "Install",
|
|
52295
|
+
cancel: "Cancel"
|
|
52296
|
+
},
|
|
52297
|
+
onConfirm: () => void install(spec)
|
|
52298
|
+
}), undefined, {
|
|
52299
|
+
tone: "warning"
|
|
52300
|
+
});
|
|
52301
|
+
}
|
|
52302
|
+
async function install(spec) {
|
|
52303
|
+
if (busy())
|
|
52304
|
+
return;
|
|
52305
|
+
if (typeof props.seam.installPluginSpec !== "function")
|
|
52306
|
+
return;
|
|
52307
|
+
setBusy(true);
|
|
52308
|
+
flash(`installing ${spec}\u2026`);
|
|
52309
|
+
try {
|
|
52310
|
+
const change = await props.seam.installPluginSpec(spec);
|
|
52311
|
+
flash(pluginChangeNotice(change), 8000);
|
|
52312
|
+
} catch (error) {
|
|
52313
|
+
flash(`${spec}: change failed \u2014 ${errorMessage2(error)}`, 8000);
|
|
52314
|
+
} finally {
|
|
52315
|
+
setBusy(false);
|
|
52316
|
+
}
|
|
52317
|
+
}
|
|
50851
52318
|
Keymap2.createLayer(() => ({
|
|
50852
52319
|
mode: "global",
|
|
50853
52320
|
enabled: open() && dialog.stack.length === 0,
|
|
@@ -50861,10 +52328,61 @@ function PluginsPanel(props) {
|
|
|
50861
52328
|
bind: "/",
|
|
50862
52329
|
title: "Filter bundles",
|
|
50863
52330
|
group: "Plugins",
|
|
52331
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
50864
52332
|
run: () => {
|
|
50865
52333
|
setFilterOpen(true);
|
|
50866
52334
|
return true;
|
|
50867
52335
|
}
|
|
52336
|
+
}, {
|
|
52337
|
+
bind: "return",
|
|
52338
|
+
title: "Commit input / toggle enable-disable",
|
|
52339
|
+
group: "Plugins",
|
|
52340
|
+
run: () => {
|
|
52341
|
+
if (installOpen()) {
|
|
52342
|
+
commitInstall();
|
|
52343
|
+
return true;
|
|
52344
|
+
}
|
|
52345
|
+
if (filterOpen()) {
|
|
52346
|
+
setFilterOpen(false);
|
|
52347
|
+
setFilter("");
|
|
52348
|
+
return true;
|
|
52349
|
+
}
|
|
52350
|
+
toggle(current());
|
|
52351
|
+
return true;
|
|
52352
|
+
}
|
|
52353
|
+
}, {
|
|
52354
|
+
bind: "space",
|
|
52355
|
+
title: "Toggle enable/disable",
|
|
52356
|
+
group: "Plugins",
|
|
52357
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
52358
|
+
run: () => {
|
|
52359
|
+
toggle(current());
|
|
52360
|
+
return true;
|
|
52361
|
+
}
|
|
52362
|
+
}, {
|
|
52363
|
+
bind: "d",
|
|
52364
|
+
title: "Uninstall (confirm)",
|
|
52365
|
+
group: "Plugins",
|
|
52366
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
52367
|
+
run: () => confirmRemove(current())
|
|
52368
|
+
}, {
|
|
52369
|
+
bind: "i",
|
|
52370
|
+
title: "Install a spec",
|
|
52371
|
+
group: "Plugins",
|
|
52372
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
52373
|
+
run: beginInstall
|
|
52374
|
+
}, {
|
|
52375
|
+
bind: "up,k",
|
|
52376
|
+
title: "Previous bundle",
|
|
52377
|
+
group: "Plugins",
|
|
52378
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
52379
|
+
run: () => moveCursor(-1)
|
|
52380
|
+
}, {
|
|
52381
|
+
bind: "down,j",
|
|
52382
|
+
title: "Next bundle",
|
|
52383
|
+
group: "Plugins",
|
|
52384
|
+
enabled: () => !filterOpen() && !installOpen(),
|
|
52385
|
+
run: () => moveCursor(1)
|
|
50868
52386
|
}]
|
|
50869
52387
|
}));
|
|
50870
52388
|
return createComponent2(Show, {
|
|
@@ -50888,48 +52406,83 @@ function PluginsPanel(props) {
|
|
|
50888
52406
|
insertNode(_el$3, createTextNode(`\uD83D\uDD0C Plugins`));
|
|
50889
52407
|
setProp(_el$3, "wrapMode", "none");
|
|
50890
52408
|
setProp(_el$5, "wrapMode", "none");
|
|
50891
|
-
insert(_el$5, () => ` ${visible().length}/${
|
|
52409
|
+
insert(_el$5, () => ` ${visible().length}/${bundles().length} / filter enter toggle d uninstall i install esc close`);
|
|
50892
52410
|
insert(_el$, createComponent2(Show, {
|
|
50893
52411
|
get when() {
|
|
50894
|
-
return
|
|
52412
|
+
return !installOpen();
|
|
50895
52413
|
},
|
|
50896
52414
|
get fallback() {
|
|
50897
52415
|
return (() => {
|
|
50898
|
-
var _el$
|
|
50899
|
-
insertNode(_el$
|
|
50900
|
-
setProp(_el$
|
|
50901
|
-
setProp(_el$
|
|
50902
|
-
|
|
50903
|
-
|
|
50904
|
-
|
|
50905
|
-
|
|
52416
|
+
var _el$0 = createElement("box"), _el$1 = createElement("input");
|
|
52417
|
+
insertNode(_el$0, _el$1);
|
|
52418
|
+
setProp(_el$0, "height", 1);
|
|
52419
|
+
setProp(_el$0, "flexShrink", 0);
|
|
52420
|
+
setProp(_el$0, "flexDirection", "row");
|
|
52421
|
+
use((renderable) => {
|
|
52422
|
+
setTimeout(() => {
|
|
52423
|
+
if (!renderable.isDestroyed)
|
|
52424
|
+
renderable.focus();
|
|
52425
|
+
}, 1);
|
|
52426
|
+
}, _el$1);
|
|
52427
|
+
setProp(_el$1, "flexGrow", 1);
|
|
52428
|
+
setProp(_el$1, "placeholder", "install spec (npm name, git url, path, tarball)");
|
|
52429
|
+
setProp(_el$1, "onInput", (value) => setInstallText(value));
|
|
52430
|
+
effect((_p$) => {
|
|
52431
|
+
var _v$9 = theme?.text.muted ?? "#565f89", _v$0 = installText();
|
|
52432
|
+
_v$9 !== _p$.e && (_p$.e = setProp(_el$1, "placeholderColor", _v$9, _p$.e));
|
|
52433
|
+
_v$0 !== _p$.t && (_p$.t = setProp(_el$1, "value", _v$0, _p$.t));
|
|
52434
|
+
return _p$;
|
|
52435
|
+
}, {
|
|
52436
|
+
e: undefined,
|
|
52437
|
+
t: undefined
|
|
52438
|
+
});
|
|
52439
|
+
return _el$0;
|
|
50906
52440
|
})();
|
|
50907
52441
|
},
|
|
50908
52442
|
get children() {
|
|
50909
|
-
|
|
50910
|
-
|
|
50911
|
-
|
|
50912
|
-
|
|
50913
|
-
|
|
50914
|
-
|
|
50915
|
-
|
|
50916
|
-
|
|
50917
|
-
|
|
50918
|
-
|
|
50919
|
-
|
|
50920
|
-
|
|
50921
|
-
|
|
50922
|
-
|
|
50923
|
-
|
|
50924
|
-
|
|
50925
|
-
|
|
50926
|
-
|
|
50927
|
-
|
|
50928
|
-
|
|
50929
|
-
|
|
50930
|
-
|
|
52443
|
+
return createComponent2(Show, {
|
|
52444
|
+
get when() {
|
|
52445
|
+
return filterOpen();
|
|
52446
|
+
},
|
|
52447
|
+
get fallback() {
|
|
52448
|
+
return (() => {
|
|
52449
|
+
var _el$10 = createElement("box"), _el$11 = createElement("text");
|
|
52450
|
+
insertNode(_el$10, _el$11);
|
|
52451
|
+
setProp(_el$10, "height", 1);
|
|
52452
|
+
setProp(_el$10, "flexShrink", 0);
|
|
52453
|
+
insertNode(_el$11, createTextNode(`BUNDLE STATE`));
|
|
52454
|
+
setProp(_el$11, "wrapMode", "none");
|
|
52455
|
+
effect((_$p) => setProp(_el$11, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
52456
|
+
return _el$10;
|
|
52457
|
+
})();
|
|
52458
|
+
},
|
|
52459
|
+
get children() {
|
|
52460
|
+
var _el$6 = createElement("box"), _el$7 = createElement("input");
|
|
52461
|
+
insertNode(_el$6, _el$7);
|
|
52462
|
+
setProp(_el$6, "height", 1);
|
|
52463
|
+
setProp(_el$6, "flexShrink", 0);
|
|
52464
|
+
setProp(_el$6, "flexDirection", "row");
|
|
52465
|
+
use((renderable) => {
|
|
52466
|
+
setTimeout(() => {
|
|
52467
|
+
if (!renderable.isDestroyed)
|
|
52468
|
+
renderable.focus();
|
|
52469
|
+
}, 1);
|
|
52470
|
+
}, _el$7);
|
|
52471
|
+
setProp(_el$7, "flexGrow", 1);
|
|
52472
|
+
setProp(_el$7, "placeholder", "filter");
|
|
52473
|
+
setProp(_el$7, "onInput", (value) => setFilter(value));
|
|
52474
|
+
effect((_p$) => {
|
|
52475
|
+
var _v$ = theme?.text.muted ?? "#565f89", _v$2 = filter();
|
|
52476
|
+
_v$ !== _p$.e && (_p$.e = setProp(_el$7, "placeholderColor", _v$, _p$.e));
|
|
52477
|
+
_v$2 !== _p$.t && (_p$.t = setProp(_el$7, "value", _v$2, _p$.t));
|
|
52478
|
+
return _p$;
|
|
52479
|
+
}, {
|
|
52480
|
+
e: undefined,
|
|
52481
|
+
t: undefined
|
|
52482
|
+
});
|
|
52483
|
+
return _el$6;
|
|
52484
|
+
}
|
|
50931
52485
|
});
|
|
50932
|
-
return _el$6;
|
|
50933
52486
|
}
|
|
50934
52487
|
}), null);
|
|
50935
52488
|
insert(_el$, createComponent2(Show, {
|
|
@@ -50938,14 +52491,14 @@ function PluginsPanel(props) {
|
|
|
50938
52491
|
},
|
|
50939
52492
|
get fallback() {
|
|
50940
52493
|
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$
|
|
52494
|
+
var _el$13 = createElement("box"), _el$14 = createElement("text");
|
|
52495
|
+
insertNode(_el$13, _el$14);
|
|
52496
|
+
setProp(_el$13, "height", 1);
|
|
52497
|
+
setProp(_el$13, "flexShrink", 0);
|
|
52498
|
+
setProp(_el$14, "wrapMode", "none");
|
|
52499
|
+
insert(_el$14, () => bundles().length === 0 ? "no plugins installed" : "no bundles match the filter");
|
|
52500
|
+
effect((_$p) => setProp(_el$14, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
52501
|
+
return _el$13;
|
|
50949
52502
|
})();
|
|
50950
52503
|
},
|
|
50951
52504
|
get children() {
|
|
@@ -50953,33 +52506,48 @@ function PluginsPanel(props) {
|
|
|
50953
52506
|
get each() {
|
|
50954
52507
|
return visible().slice(0, 12);
|
|
50955
52508
|
},
|
|
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
|
-
|
|
52509
|
+
children: (row, index) => (() => {
|
|
52510
|
+
var _el$15 = createElement("box"), _el$16 = createElement("text"), _el$17 = createElement("text");
|
|
52511
|
+
insertNode(_el$15, _el$16);
|
|
52512
|
+
insertNode(_el$15, _el$17);
|
|
52513
|
+
setProp(_el$15, "height", 1);
|
|
52514
|
+
setProp(_el$15, "flexShrink", 0);
|
|
52515
|
+
setProp(_el$15, "flexDirection", "row");
|
|
52516
|
+
setProp(_el$16, "wrapMode", "none");
|
|
52517
|
+
insert(_el$16, () => `${index() === cursorIndex() ? "\u203A " : " "}${formatPluginLine(row).padEnd(34)}`);
|
|
52518
|
+
setProp(_el$17, "wrapMode", "none");
|
|
52519
|
+
insert(_el$17, () => bundleStateText(row));
|
|
50967
52520
|
effect((_p$) => {
|
|
50968
|
-
var _v$
|
|
50969
|
-
_v$
|
|
50970
|
-
_v$
|
|
52521
|
+
var _v$1 = index() === cursorIndex() ? theme?.text.base ?? "#e6e6e6" : theme?.text.muted ?? "#565f89", _v$10 = row.enabled ? successColor(theme ?? undefined) : theme?.text.muted ?? "#565f89";
|
|
52522
|
+
_v$1 !== _p$.e && (_p$.e = setProp(_el$16, "fg", _v$1, _p$.e));
|
|
52523
|
+
_v$10 !== _p$.t && (_p$.t = setProp(_el$17, "fg", _v$10, _p$.t));
|
|
50971
52524
|
return _p$;
|
|
50972
52525
|
}, {
|
|
50973
52526
|
e: undefined,
|
|
50974
52527
|
t: undefined
|
|
50975
52528
|
});
|
|
50976
|
-
return _el$
|
|
52529
|
+
return _el$15;
|
|
50977
52530
|
})()
|
|
50978
52531
|
});
|
|
50979
52532
|
}
|
|
50980
52533
|
}), null);
|
|
52534
|
+
insert(_el$, createComponent2(Show, {
|
|
52535
|
+
get when() {
|
|
52536
|
+
return status() !== undefined;
|
|
52537
|
+
},
|
|
52538
|
+
get children() {
|
|
52539
|
+
var _el$8 = createElement("box"), _el$9 = createElement("text");
|
|
52540
|
+
insertNode(_el$8, _el$9);
|
|
52541
|
+
setProp(_el$8, "height", 1);
|
|
52542
|
+
setProp(_el$8, "flexShrink", 0);
|
|
52543
|
+
setProp(_el$9, "wrapMode", "none");
|
|
52544
|
+
insert(_el$9, status);
|
|
52545
|
+
effect((_$p) => setProp(_el$9, "fg", warningColor(theme ?? undefined), _$p));
|
|
52546
|
+
return _el$8;
|
|
52547
|
+
}
|
|
52548
|
+
}), null);
|
|
50981
52549
|
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 =
|
|
52550
|
+
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
52551
|
_v$3 !== _p$.e && (_p$.e = setProp(_el$, "height", _v$3, _p$.e));
|
|
50984
52552
|
_v$4 !== _p$.t && (_p$.t = setProp(_el$, "borderColor", _v$4, _p$.t));
|
|
50985
52553
|
_v$5 !== _p$.a && (_p$.a = setProp(_el$, "backgroundColor", _v$5, _p$.a));
|
|
@@ -50999,7 +52567,7 @@ function PluginsPanel(props) {
|
|
|
50999
52567
|
}
|
|
51000
52568
|
});
|
|
51001
52569
|
}
|
|
51002
|
-
var
|
|
52570
|
+
var bridgeOpen3, setBridgeOpen3, panelOpen4, setPanelOpen4, pluginsPanelOpen;
|
|
51003
52571
|
var init_plugins_panel = __esm(() => {
|
|
51004
52572
|
init_index_bun();
|
|
51005
52573
|
init_index_bun();
|
|
@@ -51013,11 +52581,12 @@ var init_plugins_panel = __esm(() => {
|
|
|
51013
52581
|
init_server();
|
|
51014
52582
|
init_keymap();
|
|
51015
52583
|
init_dialog();
|
|
52584
|
+
init_dialog_confirm();
|
|
51016
52585
|
init_theme3();
|
|
51017
52586
|
init_semantic();
|
|
51018
|
-
[
|
|
51019
|
-
[
|
|
51020
|
-
pluginsPanelOpen =
|
|
52587
|
+
[bridgeOpen3, setBridgeOpen3] = createSignal(false);
|
|
52588
|
+
[panelOpen4, setPanelOpen4] = createSignal(false);
|
|
52589
|
+
pluginsPanelOpen = panelOpen4;
|
|
51021
52590
|
});
|
|
51022
52591
|
|
|
51023
52592
|
// ../panel-kit/src/contracts.ts
|
|
@@ -51031,7 +52600,7 @@ var init_contracts = __esm(() => {
|
|
|
51031
52600
|
});
|
|
51032
52601
|
|
|
51033
52602
|
// ../panel-kit/src/fallback.ts
|
|
51034
|
-
import { RGBA as RGBA13, TextAttributes as
|
|
52603
|
+
import { RGBA as RGBA13, TextAttributes as TextAttributes11 } from "@opentui/core";
|
|
51035
52604
|
var surface, content, raised, base2, muted, faint, accent, disabled, danger, warning, success, code, user, system, heading, FALLBACK_THEME;
|
|
51036
52605
|
var init_fallback = __esm(() => {
|
|
51037
52606
|
surface = RGBA13.fromHex("#1a1b26");
|
|
@@ -51080,11 +52649,11 @@ var init_fallback = __esm(() => {
|
|
|
51080
52649
|
warning: { style: "heavy", color: warning }
|
|
51081
52650
|
},
|
|
51082
52651
|
attributes: {
|
|
51083
|
-
title:
|
|
51084
|
-
group:
|
|
51085
|
-
selected:
|
|
51086
|
-
keyHint:
|
|
51087
|
-
subtitle:
|
|
52652
|
+
title: TextAttributes11.BOLD,
|
|
52653
|
+
group: TextAttributes11.BOLD,
|
|
52654
|
+
selected: TextAttributes11.BOLD,
|
|
52655
|
+
keyHint: TextAttributes11.NONE,
|
|
52656
|
+
subtitle: TextAttributes11.NONE
|
|
51088
52657
|
},
|
|
51089
52658
|
identity: [RGBA13.fromHex("#4D6BFE"), RGBA13.fromHex("#8B5CF6")]
|
|
51090
52659
|
});
|
|
@@ -54030,11 +55599,11 @@ function settingsSummary(changed) {
|
|
|
54030
55599
|
return changed.length > 0 ? `Settings updated: ${changed.join(", ")}` : "Settings unchanged.";
|
|
54031
55600
|
}
|
|
54032
55601
|
function openSettingsPanel(itemId) {
|
|
54033
|
-
|
|
55602
|
+
setBridgeOpen4(itemId ?? "");
|
|
54034
55603
|
}
|
|
54035
55604
|
function useSettingsPanelOpenState() {
|
|
54036
|
-
onCleanup(() =>
|
|
54037
|
-
return [settingsPanelOpen,
|
|
55605
|
+
onCleanup(() => setPanelOpen5(false));
|
|
55606
|
+
return [settingsPanelOpen, setPanelOpen5];
|
|
54038
55607
|
}
|
|
54039
55608
|
function readLocalSnapshot(seam) {
|
|
54040
55609
|
let merged = {};
|
|
@@ -54132,9 +55701,9 @@ function applySettingsLive(item, applied, hints, themes) {
|
|
|
54132
55701
|
}
|
|
54133
55702
|
}
|
|
54134
55703
|
function setSettingsBridge(value) {
|
|
54135
|
-
|
|
55704
|
+
setBridgeOpen4(value);
|
|
54136
55705
|
}
|
|
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,
|
|
55706
|
+
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
55707
|
var init_settings_panel = __esm(() => {
|
|
54139
55708
|
init_server();
|
|
54140
55709
|
init_string_width();
|
|
@@ -54174,10 +55743,10 @@ var init_settings_panel = __esm(() => {
|
|
|
54174
55743
|
}];
|
|
54175
55744
|
HIDDEN_NAMESPACES = new Set([...HOST_SETTINGS_WHITELIST.map((spec) => spec.ns), "dsh-tui"]);
|
|
54176
55745
|
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 =
|
|
55746
|
+
[bridgeOpen4, setBridgeOpen4] = createSignal(undefined);
|
|
55747
|
+
[panelOpen5, setPanelOpen5] = createSignal(false);
|
|
55748
|
+
settingsPanelOpen = panelOpen5;
|
|
55749
|
+
settingsBridgeOpen = bridgeOpen4;
|
|
54181
55750
|
});
|
|
54182
55751
|
|
|
54183
55752
|
// ../tui-base/src/routes/session/agents-panel.tsx
|
|
@@ -54198,11 +55767,11 @@ function clipText(text, limit) {
|
|
|
54198
55767
|
return limit <= 1 ? "\u2026" : `${out}\u2026`;
|
|
54199
55768
|
}
|
|
54200
55769
|
function openAgentsPanel(name) {
|
|
54201
|
-
|
|
55770
|
+
setBridgeOpen5(name ?? "");
|
|
54202
55771
|
}
|
|
54203
55772
|
function useAgentsPanelOpenState() {
|
|
54204
|
-
onCleanup(() =>
|
|
54205
|
-
return [agentsPanelOpen,
|
|
55773
|
+
onCleanup(() => setPanelOpen6(false));
|
|
55774
|
+
return [agentsPanelOpen, setPanelOpen6];
|
|
54206
55775
|
}
|
|
54207
55776
|
function initialAgentLevel(rows) {
|
|
54208
55777
|
return rows.length === 0 ? "limits" : "table";
|
|
@@ -54615,10 +56184,10 @@ function AgentsPanel(props) {
|
|
|
54615
56184
|
}
|
|
54616
56185
|
}
|
|
54617
56186
|
createEffect(() => {
|
|
54618
|
-
const preselected =
|
|
56187
|
+
const preselected = bridgeOpen5();
|
|
54619
56188
|
if (preselected === undefined)
|
|
54620
56189
|
return;
|
|
54621
|
-
|
|
56190
|
+
setBridgeOpen5(undefined);
|
|
54622
56191
|
if (layers().length > 0)
|
|
54623
56192
|
return;
|
|
54624
56193
|
const next = reloadRows();
|
|
@@ -55481,7 +57050,7 @@ function AgentsPanel(props) {
|
|
|
55481
57050
|
}
|
|
55482
57051
|
return null;
|
|
55483
57052
|
}
|
|
55484
|
-
var INHERIT = "(inherit)", INHERIT_DEFAULT = "(inherit \u2014 default model)", PAGE_SIZE = 12, PANEL_SIZE = "xlarge",
|
|
57053
|
+
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
57054
|
var init_agents_panel = __esm(() => {
|
|
55486
57055
|
init_index_bun();
|
|
55487
57056
|
init_index_bun();
|
|
@@ -55498,9 +57067,9 @@ var init_agents_panel = __esm(() => {
|
|
|
55498
57067
|
init_keymap();
|
|
55499
57068
|
init_string_width();
|
|
55500
57069
|
init_settings_panel();
|
|
55501
|
-
[
|
|
55502
|
-
[
|
|
55503
|
-
agentsPanelOpen =
|
|
57070
|
+
[bridgeOpen5, setBridgeOpen5] = createSignal(undefined);
|
|
57071
|
+
[panelOpen6, setPanelOpen6] = createSignal(false);
|
|
57072
|
+
agentsPanelOpen = panelOpen6;
|
|
55504
57073
|
AGENT_TABLE_COLUMNS = [{
|
|
55505
57074
|
id: "name",
|
|
55506
57075
|
title: "NAME",
|
|
@@ -55558,11 +57127,1162 @@ var init_agents_panel = __esm(() => {
|
|
|
55558
57127
|
}];
|
|
55559
57128
|
});
|
|
55560
57129
|
|
|
57130
|
+
// ../tui-base/src/routes/session/history-data.ts
|
|
57131
|
+
function asRecord3(value) {
|
|
57132
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
|
|
57133
|
+
}
|
|
57134
|
+
function blocksText2(content) {
|
|
57135
|
+
if (!Array.isArray(content))
|
|
57136
|
+
return "";
|
|
57137
|
+
let text = "";
|
|
57138
|
+
for (const block of content) {
|
|
57139
|
+
const typed = asRecord3(block);
|
|
57140
|
+
if (typeof typed.text === "string" && typed.type === "text") {
|
|
57141
|
+
text += (text === "" ? "" : `
|
|
57142
|
+
`) + typed.text;
|
|
57143
|
+
}
|
|
57144
|
+
}
|
|
57145
|
+
return text.trim();
|
|
57146
|
+
}
|
|
57147
|
+
function sourceKind2(data) {
|
|
57148
|
+
return asRecord3(data.source).kind;
|
|
57149
|
+
}
|
|
57150
|
+
function groupHistoryTurns(entries) {
|
|
57151
|
+
const turns = [];
|
|
57152
|
+
let open;
|
|
57153
|
+
const close = () => {
|
|
57154
|
+
if (open === undefined)
|
|
57155
|
+
return;
|
|
57156
|
+
const userTexts = open.userEntries.filter((entry) => entry.human && entry.text !== "").map((entry) => entry.text);
|
|
57157
|
+
const anyText = open.userEntries.find((entry) => entry.text !== "")?.text ?? "";
|
|
57158
|
+
turns.push({
|
|
57159
|
+
turn: open.turn,
|
|
57160
|
+
seqStart: open.seqStart,
|
|
57161
|
+
seqEnd: open.seqEnd,
|
|
57162
|
+
endReason: open.endReason,
|
|
57163
|
+
endError: open.endError,
|
|
57164
|
+
interrupted: open.interrupted,
|
|
57165
|
+
startTime: open.startTime,
|
|
57166
|
+
endTime: open.endTime,
|
|
57167
|
+
userTexts,
|
|
57168
|
+
previewText: userTexts[0] ?? anyText,
|
|
57169
|
+
assistantTexts: open.assistantTexts,
|
|
57170
|
+
toolCalls: open.toolCalls
|
|
57171
|
+
});
|
|
57172
|
+
open = undefined;
|
|
57173
|
+
};
|
|
57174
|
+
let ordinal = 0;
|
|
57175
|
+
for (const entry of entries) {
|
|
57176
|
+
if (entry.type === "turn/start") {
|
|
57177
|
+
open = {
|
|
57178
|
+
turn: typeof entry.data.turn === "number" ? entry.data.turn : ordinal,
|
|
57179
|
+
seqStart: entry.seq,
|
|
57180
|
+
seqEnd: entry.seq,
|
|
57181
|
+
endReason: "completed",
|
|
57182
|
+
endError: undefined,
|
|
57183
|
+
endTime: undefined,
|
|
57184
|
+
startTime: typeof entry.time === "number" ? entry.time : undefined,
|
|
57185
|
+
interrupted: false,
|
|
57186
|
+
userEntries: [],
|
|
57187
|
+
assistantTexts: [],
|
|
57188
|
+
toolCalls: [],
|
|
57189
|
+
callIndex: new Map
|
|
57190
|
+
};
|
|
57191
|
+
ordinal++;
|
|
57192
|
+
continue;
|
|
57193
|
+
}
|
|
57194
|
+
if (open === undefined)
|
|
57195
|
+
continue;
|
|
57196
|
+
switch (entry.type) {
|
|
57197
|
+
case "user/message": {
|
|
57198
|
+
const kind = sourceKind2(entry.data);
|
|
57199
|
+
const human = kind === undefined || kind === "user";
|
|
57200
|
+
open.userEntries.push({ human, text: blocksText2(entry.data.content) });
|
|
57201
|
+
break;
|
|
57202
|
+
}
|
|
57203
|
+
case "assistant/message": {
|
|
57204
|
+
const message = asRecord3(entry.data.message);
|
|
57205
|
+
const text = blocksText2(message.content);
|
|
57206
|
+
if (text !== "")
|
|
57207
|
+
open.assistantTexts.push(text);
|
|
57208
|
+
if (entry.data.interrupted === true)
|
|
57209
|
+
open.interrupted = true;
|
|
57210
|
+
break;
|
|
57211
|
+
}
|
|
57212
|
+
case "tool/call": {
|
|
57213
|
+
const index = open.toolCalls.push({
|
|
57214
|
+
name: String(entry.data.name ?? ""),
|
|
57215
|
+
args: typeof entry.data.arguments === "string" ? entry.data.arguments : ""
|
|
57216
|
+
}) - 1;
|
|
57217
|
+
if (entry.data.callId !== undefined)
|
|
57218
|
+
open.callIndex.set(String(entry.data.callId), index);
|
|
57219
|
+
break;
|
|
57220
|
+
}
|
|
57221
|
+
case "tool/result": {
|
|
57222
|
+
const message = asRecord3(entry.data.message);
|
|
57223
|
+
const callId = entry.data.callId !== undefined ? String(entry.data.callId) : message.toolCallId !== undefined ? String(message.toolCallId) : "";
|
|
57224
|
+
const index = callId === "" ? undefined : open.callIndex.get(callId);
|
|
57225
|
+
if (index === undefined)
|
|
57226
|
+
break;
|
|
57227
|
+
open.callIndex.delete(callId);
|
|
57228
|
+
const call = open.toolCalls[index];
|
|
57229
|
+
call.ok = entry.data.isError !== true && message.isError !== true;
|
|
57230
|
+
call.output = typeof entry.data.output === "string" ? entry.data.output : JSON.stringify(entry.data.output ?? entry.data);
|
|
57231
|
+
break;
|
|
57232
|
+
}
|
|
57233
|
+
case "turn/end": {
|
|
57234
|
+
open.seqEnd = entry.seq;
|
|
57235
|
+
open.endTime = typeof entry.time === "number" ? entry.time : undefined;
|
|
57236
|
+
const reason = asRecord3(entry.data.reason);
|
|
57237
|
+
open.endReason = typeof reason.kind === "string" ? reason.kind : "completed";
|
|
57238
|
+
const error = asRecord3(reason.error);
|
|
57239
|
+
open.endError = typeof error.message === "string" ? error.message : undefined;
|
|
57240
|
+
close();
|
|
57241
|
+
break;
|
|
57242
|
+
}
|
|
57243
|
+
default:
|
|
57244
|
+
break;
|
|
57245
|
+
}
|
|
57246
|
+
}
|
|
57247
|
+
return turns;
|
|
57248
|
+
}
|
|
57249
|
+
function turnPrimaryUserText(turn) {
|
|
57250
|
+
return turn.userTexts[0];
|
|
57251
|
+
}
|
|
57252
|
+
function normalizeHistoryPreview(text, maxChars = HISTORY_PREVIEW_MAX_CHARS) {
|
|
57253
|
+
const oneLine = text.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/\s+/g, " ").trim();
|
|
57254
|
+
return oneLine.length <= maxChars ? oneLine : `${oneLine.slice(0, maxChars)}\u2026`;
|
|
57255
|
+
}
|
|
57256
|
+
function toolCallSummary(names) {
|
|
57257
|
+
if (names.length === 0)
|
|
57258
|
+
return "";
|
|
57259
|
+
const counts = new Map;
|
|
57260
|
+
for (const name of names)
|
|
57261
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
57262
|
+
const parts = [...counts.entries()].map(([name, count]) => `${name}\xD7${count}`);
|
|
57263
|
+
const label = names.length === 1 ? "tool call" : "tool calls";
|
|
57264
|
+
return `${names.length} ${label}: ${parts.join(", ")}`;
|
|
57265
|
+
}
|
|
57266
|
+
var HISTORY_PREVIEW_MAX_CHARS = 140;
|
|
57267
|
+
|
|
57268
|
+
// ../tui-base/src/routes/session/history-panel.tsx
|
|
57269
|
+
function openHistoryPanel() {
|
|
57270
|
+
setBridgeOpen6(true);
|
|
57271
|
+
}
|
|
57272
|
+
function useHistoryPanelOpenState() {
|
|
57273
|
+
onCleanup(() => setPanelOpen7(false));
|
|
57274
|
+
return [historyPanelOpen, setPanelOpen7];
|
|
57275
|
+
}
|
|
57276
|
+
function turnRowText(turn, width) {
|
|
57277
|
+
const number = `#${turn.turn} `;
|
|
57278
|
+
const preview = normalizeHistoryPreview(turn.previewText, Math.max(0, width - number.length - 1));
|
|
57279
|
+
return `${number}${preview}`;
|
|
57280
|
+
}
|
|
57281
|
+
function turnCursorStep(current, delta, count) {
|
|
57282
|
+
if (count <= 0)
|
|
57283
|
+
return current;
|
|
57284
|
+
return (current + delta + count) % count;
|
|
57285
|
+
}
|
|
57286
|
+
function turnWindow(count, cursor, visible) {
|
|
57287
|
+
const size = Math.max(0, Math.min(visible, count));
|
|
57288
|
+
const clamped = Math.max(0, Math.min(cursor, Math.max(0, count - 1)));
|
|
57289
|
+
let start = Math.min(clamped, Math.max(0, count - size));
|
|
57290
|
+
return {
|
|
57291
|
+
start,
|
|
57292
|
+
end: start + size
|
|
57293
|
+
};
|
|
57294
|
+
}
|
|
57295
|
+
function refillOrNotice(turn) {
|
|
57296
|
+
if (turn === undefined)
|
|
57297
|
+
return {
|
|
57298
|
+
kind: "notice",
|
|
57299
|
+
text: "no turn selected"
|
|
57300
|
+
};
|
|
57301
|
+
const text = turnPrimaryUserText(turn);
|
|
57302
|
+
if (text === undefined)
|
|
57303
|
+
return {
|
|
57304
|
+
kind: "notice",
|
|
57305
|
+
text: `turn #${turn.turn} has no prompt to refill`
|
|
57306
|
+
};
|
|
57307
|
+
return {
|
|
57308
|
+
kind: "refill",
|
|
57309
|
+
text
|
|
57310
|
+
};
|
|
57311
|
+
}
|
|
57312
|
+
function toolCallLine(call) {
|
|
57313
|
+
const marker = call.ok === undefined ? "\xB7" : call.ok ? "\u2713" : "\u2717";
|
|
57314
|
+
return `${marker} ${call.name}${call.args === "" ? "" : ` ${call.args}`}`;
|
|
57315
|
+
}
|
|
57316
|
+
function turnDetailLines(turn) {
|
|
57317
|
+
const lines = [];
|
|
57318
|
+
const flags = [turn.endReason, ...turn.interrupted ? ["interrupted"] : []].join(" \xB7 ");
|
|
57319
|
+
lines.push(`turn #${turn.turn} \u2014 ${flags}`);
|
|
57320
|
+
if (turn.endError !== undefined)
|
|
57321
|
+
lines.push(`error: ${turn.endError}`);
|
|
57322
|
+
if (turn.userTexts.length > 0) {
|
|
57323
|
+
lines.push("");
|
|
57324
|
+
lines.push("prompt:");
|
|
57325
|
+
for (const text of turn.userTexts)
|
|
57326
|
+
lines.push(...text.split(`
|
|
57327
|
+
`));
|
|
57328
|
+
}
|
|
57329
|
+
if (turn.assistantTexts.length > 0) {
|
|
57330
|
+
lines.push("");
|
|
57331
|
+
lines.push("assistant:");
|
|
57332
|
+
for (const text of turn.assistantTexts)
|
|
57333
|
+
lines.push(...text.split(`
|
|
57334
|
+
`));
|
|
57335
|
+
}
|
|
57336
|
+
if (turn.toolCalls.length > 0) {
|
|
57337
|
+
lines.push("");
|
|
57338
|
+
lines.push(`tools \u2014 ${toolCallSummary(turn.toolCalls.map((call) => call.name))}`);
|
|
57339
|
+
for (const call of turn.toolCalls)
|
|
57340
|
+
lines.push(toolCallLine(call));
|
|
57341
|
+
}
|
|
57342
|
+
return lines;
|
|
57343
|
+
}
|
|
57344
|
+
function historyFailureText(prefix, error) {
|
|
57345
|
+
return `${prefix} failed \u2014 ${String(error instanceof Error ? error.message : error).slice(0, 150)}`;
|
|
57346
|
+
}
|
|
57347
|
+
function HistoryPanel(props) {
|
|
57348
|
+
const panels = usePanels();
|
|
57349
|
+
const kitTheme = usePanelTheme();
|
|
57350
|
+
const theme = useThemeOptional();
|
|
57351
|
+
const dimensions = useTerminalDimensions();
|
|
57352
|
+
const [open, setOpen] = useHistoryPanelOpenState();
|
|
57353
|
+
const [browsingId, setBrowsingId] = createSignal(undefined);
|
|
57354
|
+
const [turns, setTurns] = createSignal([]);
|
|
57355
|
+
const [cursor, setCursor] = createSignal(0);
|
|
57356
|
+
const [status, setStatus] = createSignal(undefined);
|
|
57357
|
+
const [busy, setBusy] = createSignal(false);
|
|
57358
|
+
const [sessions, setSessions] = createSignal([]);
|
|
57359
|
+
const [sessionCursor, setSessionCursor] = createSignal(0);
|
|
57360
|
+
const [showSessions, setShowSessions] = createSignal(false);
|
|
57361
|
+
let handle;
|
|
57362
|
+
let sequence = 0;
|
|
57363
|
+
let loadSequence = 0;
|
|
57364
|
+
const current = createMemo(() => turns()[cursor()]);
|
|
57365
|
+
const bodyWidth = createMemo(() => {
|
|
57366
|
+
const frame = Math.min(116, dimensions().width - 2);
|
|
57367
|
+
return Math.max(20, Math.max(1, frame - 4));
|
|
57368
|
+
});
|
|
57369
|
+
const leftWidth = createMemo(() => Math.max(12, Math.floor(bodyWidth() * 0.4) - 1));
|
|
57370
|
+
const rightWidth = createMemo(() => Math.max(12, bodyWidth() - leftWidth() - 1));
|
|
57371
|
+
const visibleWindow = createMemo(() => turnWindow(turns().length, cursor(), LIST_ROWS));
|
|
57372
|
+
const detail = createMemo(() => {
|
|
57373
|
+
const turn = current();
|
|
57374
|
+
return turn === undefined ? [] : turnDetailLines(turn);
|
|
57375
|
+
});
|
|
57376
|
+
async function load(sessionId) {
|
|
57377
|
+
const token = ++loadSequence;
|
|
57378
|
+
if (!sessionId) {
|
|
57379
|
+
setTurns([]);
|
|
57380
|
+
setStatus("no active session to browse");
|
|
57381
|
+
return;
|
|
57382
|
+
}
|
|
57383
|
+
if (!props.seam.sessionJournal) {
|
|
57384
|
+
setTurns([]);
|
|
57385
|
+
setStatus("history unavailable in this session (no journal face)");
|
|
57386
|
+
return;
|
|
57387
|
+
}
|
|
57388
|
+
setTurns([]);
|
|
57389
|
+
setCursor(0);
|
|
57390
|
+
setBusy(true);
|
|
57391
|
+
setStatus(undefined);
|
|
57392
|
+
try {
|
|
57393
|
+
const entries = await props.seam.sessionJournal(sessionId);
|
|
57394
|
+
if (token !== loadSequence)
|
|
57395
|
+
return;
|
|
57396
|
+
const folded = groupHistoryTurns(entries);
|
|
57397
|
+
setTurns(folded);
|
|
57398
|
+
setCursor(0);
|
|
57399
|
+
if (folded.length === 0)
|
|
57400
|
+
setStatus(`no completed turns in ${sessionId.slice(0, 8)}`);
|
|
57401
|
+
} catch (error) {
|
|
57402
|
+
if (token !== loadSequence)
|
|
57403
|
+
return;
|
|
57404
|
+
setTurns([]);
|
|
57405
|
+
setCursor(0);
|
|
57406
|
+
setStatus(historyFailureText("history load", error));
|
|
57407
|
+
} finally {
|
|
57408
|
+
if (token === loadSequence)
|
|
57409
|
+
setBusy(false);
|
|
57410
|
+
}
|
|
57411
|
+
}
|
|
57412
|
+
function finish() {
|
|
57413
|
+
setOpen(false);
|
|
57414
|
+
setShowSessions(false);
|
|
57415
|
+
setStatus(undefined);
|
|
57416
|
+
setTimeout(() => props.onClosed?.(), 3);
|
|
57417
|
+
}
|
|
57418
|
+
function close() {
|
|
57419
|
+
if (showSessions()) {
|
|
57420
|
+
panels.close();
|
|
57421
|
+
return;
|
|
57422
|
+
}
|
|
57423
|
+
handle?.close();
|
|
57424
|
+
}
|
|
57425
|
+
createEffect(() => {
|
|
57426
|
+
if (!bridgeOpen6())
|
|
57427
|
+
return;
|
|
57428
|
+
setBridgeOpen6(false);
|
|
57429
|
+
if (handle !== undefined)
|
|
57430
|
+
return;
|
|
57431
|
+
const target = props.sessionId();
|
|
57432
|
+
setBrowsingId(target);
|
|
57433
|
+
setTurns([]);
|
|
57434
|
+
setCursor(0);
|
|
57435
|
+
setStatus(undefined);
|
|
57436
|
+
setOpen(true);
|
|
57437
|
+
handle = panels.open(() => renderBrowser(), {
|
|
57438
|
+
id: `history-${++sequence}`,
|
|
57439
|
+
title: "History",
|
|
57440
|
+
size: "xlarge",
|
|
57441
|
+
onClose: () => {
|
|
57442
|
+
handle = undefined;
|
|
57443
|
+
finish();
|
|
57444
|
+
}
|
|
57445
|
+
});
|
|
57446
|
+
load(target);
|
|
57447
|
+
});
|
|
57448
|
+
function moveCursor(delta) {
|
|
57449
|
+
setCursor((index) => turnCursorStep(index, delta, turns().length));
|
|
57450
|
+
}
|
|
57451
|
+
function refill() {
|
|
57452
|
+
const verdict = refillOrNotice(current());
|
|
57453
|
+
if (verdict.kind === "notice") {
|
|
57454
|
+
setStatus(verdict.text);
|
|
57455
|
+
return;
|
|
57456
|
+
}
|
|
57457
|
+
props.onRefill?.(verdict.text);
|
|
57458
|
+
close();
|
|
57459
|
+
}
|
|
57460
|
+
function openSessions() {
|
|
57461
|
+
if (showSessions())
|
|
57462
|
+
return;
|
|
57463
|
+
(async () => {
|
|
57464
|
+
try {
|
|
57465
|
+
const rows = await props.seam.listSessions(30);
|
|
57466
|
+
setSessions(rows);
|
|
57467
|
+
setSessionCursor(0);
|
|
57468
|
+
setShowSessions(rows.length > 0);
|
|
57469
|
+
if (rows.length === 0) {
|
|
57470
|
+
setStatus("no stored sessions to switch to");
|
|
57471
|
+
return;
|
|
57472
|
+
}
|
|
57473
|
+
panels.open(() => renderSessions(), {
|
|
57474
|
+
id: `history-sessions-${++sequence}`,
|
|
57475
|
+
title: "Switch session",
|
|
57476
|
+
size: "xlarge",
|
|
57477
|
+
onClose: () => setShowSessions(false)
|
|
57478
|
+
});
|
|
57479
|
+
} catch (error) {
|
|
57480
|
+
setStatus(historyFailureText("session list", error));
|
|
57481
|
+
}
|
|
57482
|
+
})();
|
|
57483
|
+
}
|
|
57484
|
+
function pickSession(index) {
|
|
57485
|
+
const picked = sessions()[index];
|
|
57486
|
+
if (!picked)
|
|
57487
|
+
return;
|
|
57488
|
+
setShowSessions(false);
|
|
57489
|
+
panels.close();
|
|
57490
|
+
setBrowsingId(picked.id);
|
|
57491
|
+
load(picked.id);
|
|
57492
|
+
}
|
|
57493
|
+
function fork() {
|
|
57494
|
+
if (busy())
|
|
57495
|
+
return;
|
|
57496
|
+
const turn = current();
|
|
57497
|
+
const id = browsingId();
|
|
57498
|
+
if (!props.seam.forkSession) {
|
|
57499
|
+
setStatus("fork unavailable \u2014 press c to refill the prompt instead");
|
|
57500
|
+
return;
|
|
57501
|
+
}
|
|
57502
|
+
if (!turn || !id)
|
|
57503
|
+
return;
|
|
57504
|
+
setBusy(true);
|
|
57505
|
+
props.seam.forkSession(id, turn.seqEnd).then((forkedId) => {
|
|
57506
|
+
props.onForked?.(forkedId, turn.turn);
|
|
57507
|
+
close();
|
|
57508
|
+
}).catch((error) => {
|
|
57509
|
+
setStatus(historyFailureText("fork", error));
|
|
57510
|
+
}).finally(() => setBusy(false));
|
|
57511
|
+
}
|
|
57512
|
+
Keymap2.createLayer(() => {
|
|
57513
|
+
const top = panels.top;
|
|
57514
|
+
return {
|
|
57515
|
+
mode: "global",
|
|
57516
|
+
enabled: open() && handle !== undefined && top !== undefined && handle === top,
|
|
57517
|
+
priority: 2,
|
|
57518
|
+
commands: [{
|
|
57519
|
+
bind: "up,k",
|
|
57520
|
+
title: "History: previous turn",
|
|
57521
|
+
group: "History",
|
|
57522
|
+
run: () => moveCursor(-1)
|
|
57523
|
+
}, {
|
|
57524
|
+
bind: "down,j",
|
|
57525
|
+
title: "History: next turn",
|
|
57526
|
+
group: "History",
|
|
57527
|
+
run: () => moveCursor(1)
|
|
57528
|
+
}, {
|
|
57529
|
+
bind: "return,c",
|
|
57530
|
+
title: showSessions() ? "History: pick session" : "History: refill prompt",
|
|
57531
|
+
group: "History",
|
|
57532
|
+
run: () => showSessions() ? pickSession(sessionCursor()) : refill()
|
|
57533
|
+
}, {
|
|
57534
|
+
bind: "s",
|
|
57535
|
+
title: "History: switch session",
|
|
57536
|
+
group: "History",
|
|
57537
|
+
run: openSessions
|
|
57538
|
+
}, {
|
|
57539
|
+
bind: "f",
|
|
57540
|
+
title: "History: fork at turn",
|
|
57541
|
+
group: "History",
|
|
57542
|
+
run: fork
|
|
57543
|
+
}]
|
|
57544
|
+
};
|
|
57545
|
+
});
|
|
57546
|
+
Keymap2.createLayer(() => ({
|
|
57547
|
+
mode: "global",
|
|
57548
|
+
enabled: open() && showSessions(),
|
|
57549
|
+
priority: 3,
|
|
57550
|
+
commands: [{
|
|
57551
|
+
bind: "up,k",
|
|
57552
|
+
title: "History: previous session",
|
|
57553
|
+
group: "History",
|
|
57554
|
+
run: () => setSessionCursor((index) => turnCursorStep(index, -1, sessions().length))
|
|
57555
|
+
}, {
|
|
57556
|
+
bind: "down,j",
|
|
57557
|
+
title: "History: next session",
|
|
57558
|
+
group: "History",
|
|
57559
|
+
run: () => setSessionCursor((index) => turnCursorStep(index, 1, sessions().length))
|
|
57560
|
+
}, {
|
|
57561
|
+
bind: "return,c",
|
|
57562
|
+
title: "History: browse picked session",
|
|
57563
|
+
group: "History",
|
|
57564
|
+
run: () => pickSession(sessionCursor())
|
|
57565
|
+
}]
|
|
57566
|
+
}));
|
|
57567
|
+
function clip(text, width) {
|
|
57568
|
+
if (width <= 0)
|
|
57569
|
+
return "";
|
|
57570
|
+
return text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}\u2026`;
|
|
57571
|
+
}
|
|
57572
|
+
function renderBrowser() {
|
|
57573
|
+
const muted = theme?.text.muted ?? kitTheme().text.muted;
|
|
57574
|
+
const base = theme?.text.base ?? kitTheme().text.base;
|
|
57575
|
+
const accent = kitTheme().text.accent ?? base;
|
|
57576
|
+
return (() => {
|
|
57577
|
+
var _el$ = createElement("box");
|
|
57578
|
+
setProp(_el$, "flexDirection", "column");
|
|
57579
|
+
setProp(_el$, "flexGrow", 1);
|
|
57580
|
+
insert(_el$, createComponent2(PanelBody, {
|
|
57581
|
+
get children() {
|
|
57582
|
+
return createComponent2(Show, {
|
|
57583
|
+
get when() {
|
|
57584
|
+
return turns().length > 0;
|
|
57585
|
+
},
|
|
57586
|
+
get fallback() {
|
|
57587
|
+
return (() => {
|
|
57588
|
+
var _el$8 = createElement("text");
|
|
57589
|
+
setProp(_el$8, "fg", muted);
|
|
57590
|
+
setProp(_el$8, "wrapMode", "none");
|
|
57591
|
+
insert(_el$8, (() => {
|
|
57592
|
+
var _c$ = memo2(() => !!busy());
|
|
57593
|
+
return () => _c$() ? "loading turns\u2026" : status() ?? "no completed turns";
|
|
57594
|
+
})());
|
|
57595
|
+
return _el$8;
|
|
57596
|
+
})();
|
|
57597
|
+
},
|
|
57598
|
+
get children() {
|
|
57599
|
+
return [(() => {
|
|
57600
|
+
var _el$2 = createElement("box"), _el$3 = createElement("box"), _el$6 = createElement("box");
|
|
57601
|
+
insertNode(_el$2, _el$3);
|
|
57602
|
+
insertNode(_el$2, _el$6);
|
|
57603
|
+
setProp(_el$2, "flexDirection", "row");
|
|
57604
|
+
setProp(_el$2, "height", 13);
|
|
57605
|
+
setProp(_el$2, "flexShrink", 0);
|
|
57606
|
+
setProp(_el$3, "flexDirection", "column");
|
|
57607
|
+
setProp(_el$3, "flexShrink", 0);
|
|
57608
|
+
insert(_el$3, createComponent2(For, {
|
|
57609
|
+
get each() {
|
|
57610
|
+
return turns().slice(visibleWindow().start, visibleWindow().end);
|
|
57611
|
+
},
|
|
57612
|
+
children: (turn, index) => {
|
|
57613
|
+
const at = () => visibleWindow().start + index();
|
|
57614
|
+
return (() => {
|
|
57615
|
+
var _el$9 = createElement("box"), _el$0 = createElement("text");
|
|
57616
|
+
insertNode(_el$9, _el$0);
|
|
57617
|
+
setProp(_el$9, "height", 1);
|
|
57618
|
+
setProp(_el$9, "flexShrink", 0);
|
|
57619
|
+
setProp(_el$0, "wrapMode", "none");
|
|
57620
|
+
insert(_el$0, (() => {
|
|
57621
|
+
var _c$2 = memo2(() => at() === cursor());
|
|
57622
|
+
return () => _c$2() ? `\u203A ${turnRowText(turn, leftWidth() - 2)}` : ` ${turnRowText(turn, leftWidth() - 2)}`;
|
|
57623
|
+
})());
|
|
57624
|
+
effect((_$p) => setProp(_el$0, "fg", at() === cursor() ? accent : muted, _$p));
|
|
57625
|
+
return _el$9;
|
|
57626
|
+
})();
|
|
57627
|
+
}
|
|
57628
|
+
}), null);
|
|
57629
|
+
insert(_el$3, createComponent2(Show, {
|
|
57630
|
+
get when() {
|
|
57631
|
+
return turns().length > LIST_ROWS;
|
|
57632
|
+
},
|
|
57633
|
+
get children() {
|
|
57634
|
+
var _el$4 = createElement("box"), _el$5 = createElement("text");
|
|
57635
|
+
insertNode(_el$4, _el$5);
|
|
57636
|
+
setProp(_el$4, "height", 1);
|
|
57637
|
+
setProp(_el$4, "flexShrink", 0);
|
|
57638
|
+
setProp(_el$5, "fg", muted);
|
|
57639
|
+
setProp(_el$5, "wrapMode", "none");
|
|
57640
|
+
insert(_el$5, () => `${visibleWindow().start + 1}-${visibleWindow().end}/${turns().length}`);
|
|
57641
|
+
return _el$4;
|
|
57642
|
+
}
|
|
57643
|
+
}), null);
|
|
57644
|
+
setProp(_el$6, "flexGrow", 1);
|
|
57645
|
+
setProp(_el$6, "flexDirection", "column");
|
|
57646
|
+
insert(_el$6, createComponent2(For, {
|
|
57647
|
+
get each() {
|
|
57648
|
+
return detail().slice(0, LIST_ROWS);
|
|
57649
|
+
},
|
|
57650
|
+
children: (line) => (() => {
|
|
57651
|
+
var _el$1 = createElement("box"), _el$10 = createElement("text");
|
|
57652
|
+
insertNode(_el$1, _el$10);
|
|
57653
|
+
setProp(_el$1, "height", 1);
|
|
57654
|
+
setProp(_el$1, "flexShrink", 0);
|
|
57655
|
+
setProp(_el$10, "fg", base);
|
|
57656
|
+
setProp(_el$10, "wrapMode", "none");
|
|
57657
|
+
insert(_el$10, () => clip(line === "" ? " " : line, rightWidth()));
|
|
57658
|
+
return _el$1;
|
|
57659
|
+
})()
|
|
57660
|
+
}));
|
|
57661
|
+
effect((_$p) => setProp(_el$3, "width", leftWidth(), _$p));
|
|
57662
|
+
return _el$2;
|
|
57663
|
+
})(), createComponent2(Show, {
|
|
57664
|
+
get when() {
|
|
57665
|
+
return status() !== undefined;
|
|
57666
|
+
},
|
|
57667
|
+
get children() {
|
|
57668
|
+
var _el$7 = createElement("text");
|
|
57669
|
+
setProp(_el$7, "wrapMode", "none");
|
|
57670
|
+
insert(_el$7, () => clip(status(), bodyWidth()));
|
|
57671
|
+
effect((_$p) => setProp(_el$7, "fg", kitTheme().text.warning, _$p));
|
|
57672
|
+
return _el$7;
|
|
57673
|
+
}
|
|
57674
|
+
})];
|
|
57675
|
+
}
|
|
57676
|
+
});
|
|
57677
|
+
}
|
|
57678
|
+
}), null);
|
|
57679
|
+
insert(_el$, createComponent2(PanelActions, {
|
|
57680
|
+
hint: "\u2191\u2193 turn \xB7 enter/c refill \xB7 s session \xB7 f fork \xB7 esc close"
|
|
57681
|
+
}), null);
|
|
57682
|
+
return _el$;
|
|
57683
|
+
})();
|
|
57684
|
+
}
|
|
57685
|
+
function renderSessions() {
|
|
57686
|
+
const muted = theme?.text.muted ?? kitTheme().text.muted;
|
|
57687
|
+
const accent = kitTheme().text.accent ?? muted;
|
|
57688
|
+
return (() => {
|
|
57689
|
+
var _el$11 = createElement("box");
|
|
57690
|
+
setProp(_el$11, "flexDirection", "column");
|
|
57691
|
+
setProp(_el$11, "flexGrow", 1);
|
|
57692
|
+
insert(_el$11, createComponent2(PanelBody, {
|
|
57693
|
+
get children() {
|
|
57694
|
+
return createComponent2(For, {
|
|
57695
|
+
get each() {
|
|
57696
|
+
return sessions();
|
|
57697
|
+
},
|
|
57698
|
+
children: (row, index) => (() => {
|
|
57699
|
+
var _el$12 = createElement("box"), _el$13 = createElement("text");
|
|
57700
|
+
insertNode(_el$12, _el$13);
|
|
57701
|
+
setProp(_el$12, "height", 1);
|
|
57702
|
+
setProp(_el$12, "flexShrink", 0);
|
|
57703
|
+
setProp(_el$13, "wrapMode", "none");
|
|
57704
|
+
insert(_el$13, () => index() === sessionCursor() ? `\u203A ` : ` `, null);
|
|
57705
|
+
insert(_el$13, () => clip(row.title === "" ? row.id : row.title, bodyWidth() - 4), null);
|
|
57706
|
+
effect((_$p) => setProp(_el$13, "fg", index() === sessionCursor() ? accent : muted, _$p));
|
|
57707
|
+
return _el$12;
|
|
57708
|
+
})()
|
|
57709
|
+
});
|
|
57710
|
+
}
|
|
57711
|
+
}), null);
|
|
57712
|
+
insert(_el$11, createComponent2(PanelActions, {
|
|
57713
|
+
hint: "\u2191\u2193 session \xB7 enter browse \xB7 esc back"
|
|
57714
|
+
}), null);
|
|
57715
|
+
return _el$11;
|
|
57716
|
+
})();
|
|
57717
|
+
}
|
|
57718
|
+
}
|
|
57719
|
+
var bridgeOpen6, setBridgeOpen6, panelOpen7, setPanelOpen7, historyPanelOpen, LIST_ROWS = 12;
|
|
57720
|
+
var init_history_panel = __esm(() => {
|
|
57721
|
+
init_index_bun();
|
|
57722
|
+
init_index_bun();
|
|
57723
|
+
init_index_bun();
|
|
57724
|
+
init_index_bun();
|
|
57725
|
+
init_index_bun();
|
|
57726
|
+
init_index_bun();
|
|
57727
|
+
init_index_bun();
|
|
57728
|
+
init_server();
|
|
57729
|
+
init_index_bun();
|
|
57730
|
+
init_src2();
|
|
57731
|
+
init_keymap();
|
|
57732
|
+
init_theme3();
|
|
57733
|
+
[bridgeOpen6, setBridgeOpen6] = createSignal(false);
|
|
57734
|
+
[panelOpen7, setPanelOpen7] = createSignal(false);
|
|
57735
|
+
historyPanelOpen = panelOpen7;
|
|
57736
|
+
});
|
|
57737
|
+
|
|
57738
|
+
// ../tui-base/src/routes/session/subagents-viewer.tsx
|
|
57739
|
+
function openSubagentsViewer() {
|
|
57740
|
+
setBridgeOpen7(true);
|
|
57741
|
+
}
|
|
57742
|
+
function useSubagentsViewerOpenState() {
|
|
57743
|
+
onCleanup(() => setPanelOpen8(false));
|
|
57744
|
+
return [subagentsViewerOpen, setPanelOpen8];
|
|
57745
|
+
}
|
|
57746
|
+
function viewerRows(views) {
|
|
57747
|
+
const running = views.filter((view) => view.status === "running");
|
|
57748
|
+
const settled = views.filter((view) => view.status !== "running").sort((a, b) => (b.endedAt ?? 0) - (a.endedAt ?? 0)).slice(0, SETTLED_CAP);
|
|
57749
|
+
return [...running, ...settled];
|
|
57750
|
+
}
|
|
57751
|
+
function viewerRowText(view, roundCap, elapsedText) {
|
|
57752
|
+
const glyph = view.status === "running" ? "\u280B" : view.status === "completed" ? "\u2713" : view.status === "failed" ? "\u2717" : "\u2014";
|
|
57753
|
+
const stop = subagentHardStopGlyph(view);
|
|
57754
|
+
const label = `${stop ? `${stop} ` : ""}${titlecase(view.label)}`;
|
|
57755
|
+
const suffix = subagentMarkerSuffix(view);
|
|
57756
|
+
const cap = roundCap !== undefined && roundCap > 0 ? `/${roundCap}` : "";
|
|
57757
|
+
const elapsed = elapsedText !== undefined && elapsedText !== "" ? ` \xB7 ${elapsedText}` : "";
|
|
57758
|
+
const model = view.model !== undefined ? ` \xB7 ${view.model}` : "";
|
|
57759
|
+
return `${glyph} ${label} \xB7 rounds ${view.rounds}${cap}${elapsed}${model}${suffix ? ` ${suffix.trim()}` : ""}`;
|
|
57760
|
+
}
|
|
57761
|
+
function formatViewerElapsed(ms) {
|
|
57762
|
+
if (ms < 60000)
|
|
57763
|
+
return `${(ms / 1000).toFixed(1)}s`;
|
|
57764
|
+
const total = Math.floor(ms / 1000);
|
|
57765
|
+
return `${Math.floor(total / 60)}m${String(total % 60).padStart(2, "0")}s`;
|
|
57766
|
+
}
|
|
57767
|
+
function rowElapsedText(view, now) {
|
|
57768
|
+
if (view.status === "running" && view.startedAt !== undefined) {
|
|
57769
|
+
return formatViewerElapsed(Math.max(0, now - view.startedAt));
|
|
57770
|
+
}
|
|
57771
|
+
if (view.elapsedSec !== undefined)
|
|
57772
|
+
return `${view.elapsedSec.toFixed(1)}s`;
|
|
57773
|
+
return;
|
|
57774
|
+
}
|
|
57775
|
+
function scrollTarget(delta, offset, lineCount, visible) {
|
|
57776
|
+
const maxScroll = Math.max(0, lineCount - visible);
|
|
57777
|
+
const start = Math.min(offset, maxScroll);
|
|
57778
|
+
return Math.max(0, Math.min(start + delta, maxScroll));
|
|
57779
|
+
}
|
|
57780
|
+
function transcriptWindow(lineCount, offset, visible) {
|
|
57781
|
+
const maxScroll = Math.max(0, lineCount - visible);
|
|
57782
|
+
const start = Math.max(0, Math.min(offset, maxScroll));
|
|
57783
|
+
return {
|
|
57784
|
+
start,
|
|
57785
|
+
end: Math.min(lineCount, start + visible),
|
|
57786
|
+
follow: start === maxScroll
|
|
57787
|
+
};
|
|
57788
|
+
}
|
|
57789
|
+
function steerEchoText(sent, label) {
|
|
57790
|
+
const agent = titlecase(label);
|
|
57791
|
+
return sent ? `steered ${agent.toLowerCase()}` : `steer rejected \u2014 ${agent} is not running`;
|
|
57792
|
+
}
|
|
57793
|
+
function stopAllSummary(stopped) {
|
|
57794
|
+
return stopped === 1 ? "stop requested \u2014 1 subagent" : `stop requested \u2014 ${stopped} subagents`;
|
|
57795
|
+
}
|
|
57796
|
+
function doublePressArmed(lastPress, now) {
|
|
57797
|
+
const gap = now - lastPress;
|
|
57798
|
+
return lastPress > 0 && gap >= MIN_DOUBLE_PRESS_GAP_MS && gap <= DOUBLE_PRESS_MS;
|
|
57799
|
+
}
|
|
57800
|
+
function SubagentsViewer(props) {
|
|
57801
|
+
const panels = usePanels();
|
|
57802
|
+
const kitTheme = usePanelTheme();
|
|
57803
|
+
const theme = useThemeOptional();
|
|
57804
|
+
const dialog = useDialog();
|
|
57805
|
+
const [open, setOpen] = useSubagentsViewerOpenState();
|
|
57806
|
+
const [views, setViews] = createSignal([]);
|
|
57807
|
+
const [cursor, setCursor] = createSignal(0);
|
|
57808
|
+
const [sortByRounds, setSortByRounds] = createSignal(false);
|
|
57809
|
+
const [browsingId, setBrowsingId] = createSignal(undefined);
|
|
57810
|
+
const [tick, setTick] = createSignal(0);
|
|
57811
|
+
const [scrollOffset, setScrollOffset] = createSignal(0);
|
|
57812
|
+
const [status, setStatus] = createSignal(undefined);
|
|
57813
|
+
let handle;
|
|
57814
|
+
let transcriptHandle;
|
|
57815
|
+
let sequence = 0;
|
|
57816
|
+
let lastXPress = 0;
|
|
57817
|
+
let tickTimer;
|
|
57818
|
+
let statusTimer;
|
|
57819
|
+
let stopAllLatch = false;
|
|
57820
|
+
onCleanup(() => {
|
|
57821
|
+
clearInterval(tickTimer);
|
|
57822
|
+
clearTimeout(statusTimer);
|
|
57823
|
+
});
|
|
57824
|
+
function refreshViews() {
|
|
57825
|
+
setViews(props.seam.subagentViews?.() ?? []);
|
|
57826
|
+
}
|
|
57827
|
+
function flash(message, autoClearMs) {
|
|
57828
|
+
clearTimeout(statusTimer);
|
|
57829
|
+
setStatus(message);
|
|
57830
|
+
if (autoClearMs !== undefined) {
|
|
57831
|
+
statusTimer = setTimeout(() => setStatus(undefined), autoClearMs);
|
|
57832
|
+
}
|
|
57833
|
+
}
|
|
57834
|
+
const rows = createMemo(() => {
|
|
57835
|
+
tick();
|
|
57836
|
+
const list = [...viewerRows(views())];
|
|
57837
|
+
if (sortByRounds())
|
|
57838
|
+
list.sort((a, b) => b.rounds - a.rounds);
|
|
57839
|
+
return list;
|
|
57840
|
+
});
|
|
57841
|
+
function moveCursor(delta) {
|
|
57842
|
+
const count = rows().length;
|
|
57843
|
+
if (count === 0)
|
|
57844
|
+
return;
|
|
57845
|
+
setCursor((index) => (index + delta + count) % count);
|
|
57846
|
+
}
|
|
57847
|
+
function stopAll() {
|
|
57848
|
+
const seam = props.seam;
|
|
57849
|
+
if (seam.interruptChild === undefined) {
|
|
57850
|
+
flash("stop unavailable \u2014 no interrupt face in this session");
|
|
57851
|
+
return;
|
|
57852
|
+
}
|
|
57853
|
+
const targets = views().filter((view) => view.status === "running");
|
|
57854
|
+
if (targets.length === 0) {
|
|
57855
|
+
stopAllLatch = false;
|
|
57856
|
+
flash("no running subagents to stop");
|
|
57857
|
+
return;
|
|
57858
|
+
}
|
|
57859
|
+
if (stopAllLatch) {
|
|
57860
|
+
flash(stopAllSummary(targets.length));
|
|
57861
|
+
return;
|
|
57862
|
+
}
|
|
57863
|
+
stopAllLatch = true;
|
|
57864
|
+
for (const target of targets) {
|
|
57865
|
+
seam.interruptChild(target.id).catch((error) => {
|
|
57866
|
+
flash(`stop failed \u2014 ${String(error instanceof Error ? error.message : error).slice(0, 120)}`);
|
|
57867
|
+
});
|
|
57868
|
+
}
|
|
57869
|
+
flash(stopAllSummary(targets.length));
|
|
57870
|
+
}
|
|
57871
|
+
const browsing = createMemo(() => views().find((view) => view.id === browsingId()));
|
|
57872
|
+
const transcript = createMemo(() => {
|
|
57873
|
+
tick();
|
|
57874
|
+
const id = browsingId();
|
|
57875
|
+
if (id === undefined)
|
|
57876
|
+
return [];
|
|
57877
|
+
const face = props.seam.subagentTranscript;
|
|
57878
|
+
if (face === undefined)
|
|
57879
|
+
return [];
|
|
57880
|
+
return face(id);
|
|
57881
|
+
});
|
|
57882
|
+
const window = createMemo(() => transcriptWindow(transcript().length, scrollOffset(), TRANSCRIPT_ROWS));
|
|
57883
|
+
function startTicking() {
|
|
57884
|
+
if (tickTimer !== undefined)
|
|
57885
|
+
return;
|
|
57886
|
+
tickTimer = setInterval(() => {
|
|
57887
|
+
try {
|
|
57888
|
+
refreshViews();
|
|
57889
|
+
setTick((n) => n + 1);
|
|
57890
|
+
} catch {}
|
|
57891
|
+
}, TRANSCRIPT_TICK_MS);
|
|
57892
|
+
}
|
|
57893
|
+
function stopTicking() {
|
|
57894
|
+
clearInterval(tickTimer);
|
|
57895
|
+
tickTimer = undefined;
|
|
57896
|
+
}
|
|
57897
|
+
function scrollBy(delta) {
|
|
57898
|
+
setScrollOffset((offset) => scrollTarget(delta, offset, transcript().length, TRANSCRIPT_ROWS));
|
|
57899
|
+
}
|
|
57900
|
+
function openTranscript(id) {
|
|
57901
|
+
setBrowsingId(id);
|
|
57902
|
+
setScrollOffset(Number.MAX_SAFE_INTEGER);
|
|
57903
|
+
lastXPress = 0;
|
|
57904
|
+
setStatus(undefined);
|
|
57905
|
+
transcriptHandle = panels.open(() => renderTranscript(), {
|
|
57906
|
+
id: `subagents-transcript-${++sequence}`,
|
|
57907
|
+
title: "Subagent transcript",
|
|
57908
|
+
size: "xlarge",
|
|
57909
|
+
onClose: () => {
|
|
57910
|
+
transcriptHandle = undefined;
|
|
57911
|
+
stopTicking();
|
|
57912
|
+
}
|
|
57913
|
+
});
|
|
57914
|
+
startTicking();
|
|
57915
|
+
}
|
|
57916
|
+
function openSteer() {
|
|
57917
|
+
const view = browsing();
|
|
57918
|
+
const id = browsingId();
|
|
57919
|
+
if (view === undefined || id === undefined)
|
|
57920
|
+
return;
|
|
57921
|
+
if (view.status !== "running") {
|
|
57922
|
+
flash("this subagent has ended \u2014 steering unavailable");
|
|
57923
|
+
return;
|
|
57924
|
+
}
|
|
57925
|
+
if (props.seam.steerChild === undefined) {
|
|
57926
|
+
flash("steer unavailable in this session");
|
|
57927
|
+
return;
|
|
57928
|
+
}
|
|
57929
|
+
const agent = titlecase(view.label);
|
|
57930
|
+
dialog.replace(() => createComponent2(DialogPrompt, {
|
|
57931
|
+
title: `Steer ${agent}`,
|
|
57932
|
+
placeholder: "Steer message",
|
|
57933
|
+
onConfirm: (value) => {
|
|
57934
|
+
const text = value.trim();
|
|
57935
|
+
dialog.clear();
|
|
57936
|
+
if (!text)
|
|
57937
|
+
return;
|
|
57938
|
+
const sent = props.seam.steerChild(id, text);
|
|
57939
|
+
flash(steerEchoText(sent, view.label));
|
|
57940
|
+
},
|
|
57941
|
+
onCancel: () => dialog.clear()
|
|
57942
|
+
}));
|
|
57943
|
+
}
|
|
57944
|
+
function stopChild() {
|
|
57945
|
+
const view = browsing();
|
|
57946
|
+
const id = browsingId();
|
|
57947
|
+
if (view === undefined || id === undefined)
|
|
57948
|
+
return;
|
|
57949
|
+
const now = Date.now();
|
|
57950
|
+
if (!doublePressArmed(lastXPress, now)) {
|
|
57951
|
+
lastXPress = now;
|
|
57952
|
+
flash("press x again to stop this subagent");
|
|
57953
|
+
return;
|
|
57954
|
+
}
|
|
57955
|
+
lastXPress = 0;
|
|
57956
|
+
if (view.status !== "running") {
|
|
57957
|
+
flash("nothing to stop \u2014 this subagent has ended");
|
|
57958
|
+
return;
|
|
57959
|
+
}
|
|
57960
|
+
const face = props.seam.interruptChild;
|
|
57961
|
+
if (face === undefined) {
|
|
57962
|
+
flash("stop unavailable \u2014 no interrupt face in this session");
|
|
57963
|
+
return;
|
|
57964
|
+
}
|
|
57965
|
+
face(id).then(() => flash(`stop requested \u2014 ${titlecase(view.label)}`)).catch((error) => {
|
|
57966
|
+
flash(`stop failed \u2014 ${String(error instanceof Error ? error.message : error).slice(0, 120)}`);
|
|
57967
|
+
});
|
|
57968
|
+
}
|
|
57969
|
+
function finish() {
|
|
57970
|
+
stopTicking();
|
|
57971
|
+
setOpen(false);
|
|
57972
|
+
setStatus(undefined);
|
|
57973
|
+
setTimeout(() => props.onClosed?.(), 3);
|
|
57974
|
+
}
|
|
57975
|
+
createEffect(() => {
|
|
57976
|
+
if (!bridgeOpen7())
|
|
57977
|
+
return;
|
|
57978
|
+
setBridgeOpen7(false);
|
|
57979
|
+
if (handle !== undefined)
|
|
57980
|
+
return;
|
|
57981
|
+
refreshViews();
|
|
57982
|
+
setCursor(0);
|
|
57983
|
+
setSortByRounds(false);
|
|
57984
|
+
setBrowsingId(undefined);
|
|
57985
|
+
setStatus(undefined);
|
|
57986
|
+
stopAllLatch = false;
|
|
57987
|
+
setOpen(true);
|
|
57988
|
+
handle = panels.open(() => renderList(), {
|
|
57989
|
+
id: `subagents-${++sequence}`,
|
|
57990
|
+
title: "Subagents",
|
|
57991
|
+
size: "xlarge",
|
|
57992
|
+
onClose: () => {
|
|
57993
|
+
handle = undefined;
|
|
57994
|
+
if (transcriptHandle === undefined)
|
|
57995
|
+
finish();
|
|
57996
|
+
}
|
|
57997
|
+
});
|
|
57998
|
+
});
|
|
57999
|
+
Keymap2.createLayer(() => {
|
|
58000
|
+
const top = panels.top;
|
|
58001
|
+
return {
|
|
58002
|
+
mode: "global",
|
|
58003
|
+
enabled: open() && transcriptHandle === undefined && handle !== undefined && handle === top && dialog.stack.length === 0,
|
|
58004
|
+
priority: 2,
|
|
58005
|
+
commands: [{
|
|
58006
|
+
bind: "up,k",
|
|
58007
|
+
title: "Subagents: previous child",
|
|
58008
|
+
group: "Subagents",
|
|
58009
|
+
run: () => moveCursor(-1)
|
|
58010
|
+
}, {
|
|
58011
|
+
bind: "down,j",
|
|
58012
|
+
title: "Subagents: next child",
|
|
58013
|
+
group: "Subagents",
|
|
58014
|
+
run: () => moveCursor(1)
|
|
58015
|
+
}, {
|
|
58016
|
+
bind: "return",
|
|
58017
|
+
title: "Subagents: open transcript",
|
|
58018
|
+
group: "Subagents",
|
|
58019
|
+
run: () => {
|
|
58020
|
+
const row = rows()[cursor()];
|
|
58021
|
+
if (row !== undefined)
|
|
58022
|
+
openTranscript(row.id);
|
|
58023
|
+
return true;
|
|
58024
|
+
}
|
|
58025
|
+
}, {
|
|
58026
|
+
bind: "s",
|
|
58027
|
+
title: "Subagents: sort by rounds",
|
|
58028
|
+
group: "Subagents",
|
|
58029
|
+
run: () => {
|
|
58030
|
+
setSortByRounds((value) => !value);
|
|
58031
|
+
return true;
|
|
58032
|
+
}
|
|
58033
|
+
}, {
|
|
58034
|
+
bind: "shift+k",
|
|
58035
|
+
title: "Subagents: stop all running",
|
|
58036
|
+
group: "Subagents",
|
|
58037
|
+
run: stopAll
|
|
58038
|
+
}]
|
|
58039
|
+
};
|
|
58040
|
+
});
|
|
58041
|
+
Keymap2.createLayer(() => {
|
|
58042
|
+
const top = panels.top;
|
|
58043
|
+
return {
|
|
58044
|
+
mode: "global",
|
|
58045
|
+
enabled: open() && transcriptHandle !== undefined && transcriptHandle === top && dialog.stack.length === 0,
|
|
58046
|
+
priority: 2,
|
|
58047
|
+
commands: [{
|
|
58048
|
+
bind: "up,k",
|
|
58049
|
+
title: "Transcript: scroll up",
|
|
58050
|
+
group: "Subagents",
|
|
58051
|
+
run: () => scrollBy(-1)
|
|
58052
|
+
}, {
|
|
58053
|
+
bind: "down,j",
|
|
58054
|
+
title: "Transcript: scroll down",
|
|
58055
|
+
group: "Subagents",
|
|
58056
|
+
run: () => scrollBy(1)
|
|
58057
|
+
}, {
|
|
58058
|
+
bind: "return",
|
|
58059
|
+
title: "Transcript: steer subagent",
|
|
58060
|
+
group: "Subagents",
|
|
58061
|
+
run: openSteer
|
|
58062
|
+
}, {
|
|
58063
|
+
bind: "x",
|
|
58064
|
+
title: "Transcript: press twice to stop",
|
|
58065
|
+
group: "Subagents",
|
|
58066
|
+
run: stopChild
|
|
58067
|
+
}]
|
|
58068
|
+
};
|
|
58069
|
+
});
|
|
58070
|
+
function clip(text, width) {
|
|
58071
|
+
if (width <= 0)
|
|
58072
|
+
return "";
|
|
58073
|
+
return text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}\u2026`;
|
|
58074
|
+
}
|
|
58075
|
+
const bodyWidth = 110;
|
|
58076
|
+
function headerText(view, now) {
|
|
58077
|
+
if (view === undefined)
|
|
58078
|
+
return "subagent";
|
|
58079
|
+
const status = view.status === "running" ? "running" : view.status === "completed" ? "completed" : view.status === "failed" ? "failed" : "cancelled";
|
|
58080
|
+
const elapsed = rowElapsedText(view, now);
|
|
58081
|
+
const parts = [`${titlecase(view.label)} \xB7 ${status} \xB7 rounds ${view.rounds}`];
|
|
58082
|
+
if (elapsed !== undefined)
|
|
58083
|
+
parts.push(elapsed);
|
|
58084
|
+
if (view.model !== undefined)
|
|
58085
|
+
parts.push(view.model);
|
|
58086
|
+
return clip(parts.join(" \xB7 "), bodyWidth);
|
|
58087
|
+
}
|
|
58088
|
+
function renderList() {
|
|
58089
|
+
const muted = theme?.text.muted ?? kitTheme().text.muted;
|
|
58090
|
+
const accent = kitTheme().text.accent ?? muted;
|
|
58091
|
+
const list = rows();
|
|
58092
|
+
const start = Math.max(0, Math.min(cursor() - LIST_ROWS2 + 1, Math.max(0, list.length - LIST_ROWS2)));
|
|
58093
|
+
return (() => {
|
|
58094
|
+
var _el$ = createElement("box");
|
|
58095
|
+
setProp(_el$, "flexDirection", "column");
|
|
58096
|
+
setProp(_el$, "flexGrow", 1);
|
|
58097
|
+
insert(_el$, createComponent2(PanelBody, {
|
|
58098
|
+
get children() {
|
|
58099
|
+
return [createComponent2(Show, {
|
|
58100
|
+
get when() {
|
|
58101
|
+
return list.length > 0;
|
|
58102
|
+
},
|
|
58103
|
+
get fallback() {
|
|
58104
|
+
return (() => {
|
|
58105
|
+
var _el$3 = createElement("text");
|
|
58106
|
+
insertNode(_el$3, createTextNode(`no subagents in this session \u2014 spawn one and it shows up here`));
|
|
58107
|
+
setProp(_el$3, "fg", muted);
|
|
58108
|
+
setProp(_el$3, "wrapMode", "none");
|
|
58109
|
+
return _el$3;
|
|
58110
|
+
})();
|
|
58111
|
+
},
|
|
58112
|
+
get children() {
|
|
58113
|
+
return createComponent2(For, {
|
|
58114
|
+
get each() {
|
|
58115
|
+
return list.slice(start, start + LIST_ROWS2);
|
|
58116
|
+
},
|
|
58117
|
+
children: (row, index) => {
|
|
58118
|
+
const at = () => start + index();
|
|
58119
|
+
return (() => {
|
|
58120
|
+
var _el$5 = createElement("box"), _el$6 = createElement("text");
|
|
58121
|
+
insertNode(_el$5, _el$6);
|
|
58122
|
+
setProp(_el$5, "height", 1);
|
|
58123
|
+
setProp(_el$5, "flexShrink", 0);
|
|
58124
|
+
setProp(_el$6, "wrapMode", "none");
|
|
58125
|
+
insert(_el$6, () => clipToWidth(`${at() === cursor() ? "\u203A " : " "}${viewerRowText(row, undefined, rowElapsedText(row, Date.now()))}`, bodyWidth));
|
|
58126
|
+
effect((_$p) => setProp(_el$6, "fg", at() === cursor() ? accent : muted, _$p));
|
|
58127
|
+
return _el$5;
|
|
58128
|
+
})();
|
|
58129
|
+
}
|
|
58130
|
+
});
|
|
58131
|
+
}
|
|
58132
|
+
}), createComponent2(Show, {
|
|
58133
|
+
get when() {
|
|
58134
|
+
return status() !== undefined;
|
|
58135
|
+
},
|
|
58136
|
+
get children() {
|
|
58137
|
+
var _el$2 = createElement("text");
|
|
58138
|
+
setProp(_el$2, "wrapMode", "none");
|
|
58139
|
+
insert(_el$2, () => clip(status(), bodyWidth));
|
|
58140
|
+
effect((_$p) => setProp(_el$2, "fg", kitTheme().text.warning, _$p));
|
|
58141
|
+
return _el$2;
|
|
58142
|
+
}
|
|
58143
|
+
})];
|
|
58144
|
+
}
|
|
58145
|
+
}), null);
|
|
58146
|
+
insert(_el$, createComponent2(PanelActions, {
|
|
58147
|
+
get hint() {
|
|
58148
|
+
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";
|
|
58149
|
+
}
|
|
58150
|
+
}), null);
|
|
58151
|
+
return _el$;
|
|
58152
|
+
})();
|
|
58153
|
+
}
|
|
58154
|
+
function renderTranscript() {
|
|
58155
|
+
const muted = theme?.text.muted ?? kitTheme().text.muted;
|
|
58156
|
+
const base = theme?.text.base ?? kitTheme().text.base;
|
|
58157
|
+
const view = browsing();
|
|
58158
|
+
const facePresent = props.seam.subagentTranscript !== undefined;
|
|
58159
|
+
const lines = transcript();
|
|
58160
|
+
const win = window();
|
|
58161
|
+
return (() => {
|
|
58162
|
+
var _el$7 = createElement("box");
|
|
58163
|
+
setProp(_el$7, "flexDirection", "column");
|
|
58164
|
+
setProp(_el$7, "flexGrow", 1);
|
|
58165
|
+
insert(_el$7, createComponent2(PanelBody, {
|
|
58166
|
+
get children() {
|
|
58167
|
+
return [(() => {
|
|
58168
|
+
var _el$8 = createElement("text");
|
|
58169
|
+
setProp(_el$8, "wrapMode", "none");
|
|
58170
|
+
insert(_el$8, () => clipToWidth(headerText(view, Date.now()), bodyWidth));
|
|
58171
|
+
effect((_$p) => setProp(_el$8, "fg", kitTheme().text.accent ?? base, _$p));
|
|
58172
|
+
return _el$8;
|
|
58173
|
+
})(), createComponent2(Show, {
|
|
58174
|
+
when: facePresent,
|
|
58175
|
+
get fallback() {
|
|
58176
|
+
return (() => {
|
|
58177
|
+
var _el$10 = createElement("text");
|
|
58178
|
+
insertNode(_el$10, createTextNode(`transcript unavailable in this session (no subagent transcript face)`));
|
|
58179
|
+
setProp(_el$10, "fg", muted);
|
|
58180
|
+
setProp(_el$10, "wrapMode", "none");
|
|
58181
|
+
return _el$10;
|
|
58182
|
+
})();
|
|
58183
|
+
},
|
|
58184
|
+
get children() {
|
|
58185
|
+
return createComponent2(Show, {
|
|
58186
|
+
get when() {
|
|
58187
|
+
return lines.length > 0;
|
|
58188
|
+
},
|
|
58189
|
+
get fallback() {
|
|
58190
|
+
return (() => {
|
|
58191
|
+
var _el$12 = createElement("text");
|
|
58192
|
+
insertNode(_el$12, createTextNode(`no activity yet \u2014 the child's events land here live`));
|
|
58193
|
+
setProp(_el$12, "fg", muted);
|
|
58194
|
+
setProp(_el$12, "wrapMode", "none");
|
|
58195
|
+
return _el$12;
|
|
58196
|
+
})();
|
|
58197
|
+
},
|
|
58198
|
+
get children() {
|
|
58199
|
+
return [createComponent2(For, {
|
|
58200
|
+
get each() {
|
|
58201
|
+
return lines.slice(win.start, win.end);
|
|
58202
|
+
},
|
|
58203
|
+
children: (line) => (() => {
|
|
58204
|
+
var _el$14 = createElement("box"), _el$15 = createElement("text");
|
|
58205
|
+
insertNode(_el$14, _el$15);
|
|
58206
|
+
setProp(_el$14, "height", 1);
|
|
58207
|
+
setProp(_el$14, "flexShrink", 0);
|
|
58208
|
+
setProp(_el$15, "fg", base);
|
|
58209
|
+
setProp(_el$15, "wrapMode", "none");
|
|
58210
|
+
insert(_el$15, () => clipToWidth(line === "" ? " " : line, bodyWidth));
|
|
58211
|
+
return _el$14;
|
|
58212
|
+
})()
|
|
58213
|
+
}), createComponent2(Show, {
|
|
58214
|
+
get when() {
|
|
58215
|
+
return lines.length > TRANSCRIPT_ROWS;
|
|
58216
|
+
},
|
|
58217
|
+
get children() {
|
|
58218
|
+
var _el$9 = createElement("box"), _el$0 = createElement("text");
|
|
58219
|
+
insertNode(_el$9, _el$0);
|
|
58220
|
+
setProp(_el$9, "height", 1);
|
|
58221
|
+
setProp(_el$9, "flexShrink", 0);
|
|
58222
|
+
setProp(_el$0, "fg", muted);
|
|
58223
|
+
setProp(_el$0, "wrapMode", "none");
|
|
58224
|
+
insert(_el$0, () => `${win.start + 1}-${win.end}/${lines.length}${win.follow ? " (following)" : " (detached \u2014 scroll to the bottom to re-follow)"}`);
|
|
58225
|
+
return _el$9;
|
|
58226
|
+
}
|
|
58227
|
+
})];
|
|
58228
|
+
}
|
|
58229
|
+
});
|
|
58230
|
+
}
|
|
58231
|
+
}), createComponent2(Show, {
|
|
58232
|
+
get when() {
|
|
58233
|
+
return status() !== undefined;
|
|
58234
|
+
},
|
|
58235
|
+
get children() {
|
|
58236
|
+
var _el$1 = createElement("text");
|
|
58237
|
+
setProp(_el$1, "wrapMode", "none");
|
|
58238
|
+
insert(_el$1, () => clip(status(), bodyWidth));
|
|
58239
|
+
effect((_$p) => setProp(_el$1, "fg", kitTheme().text.warning, _$p));
|
|
58240
|
+
return _el$1;
|
|
58241
|
+
}
|
|
58242
|
+
})];
|
|
58243
|
+
}
|
|
58244
|
+
}), null);
|
|
58245
|
+
insert(_el$7, createComponent2(PanelActions, {
|
|
58246
|
+
hint: "\u2191\u2193 scroll \xB7 enter steer \xB7 x\xD72 stop \xB7 esc back"
|
|
58247
|
+
}), null);
|
|
58248
|
+
return _el$7;
|
|
58249
|
+
})();
|
|
58250
|
+
}
|
|
58251
|
+
if (props.seam.onSubagentViews) {
|
|
58252
|
+
onCleanup(props.seam.onSubagentViews((next) => {
|
|
58253
|
+
setViews(next);
|
|
58254
|
+
}));
|
|
58255
|
+
}
|
|
58256
|
+
}
|
|
58257
|
+
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;
|
|
58258
|
+
var init_subagents_viewer = __esm(() => {
|
|
58259
|
+
init_index_bun();
|
|
58260
|
+
init_index_bun();
|
|
58261
|
+
init_index_bun();
|
|
58262
|
+
init_index_bun();
|
|
58263
|
+
init_index_bun();
|
|
58264
|
+
init_index_bun();
|
|
58265
|
+
init_index_bun();
|
|
58266
|
+
init_index_bun();
|
|
58267
|
+
init_server();
|
|
58268
|
+
init_src2();
|
|
58269
|
+
init_keymap();
|
|
58270
|
+
init_dialog();
|
|
58271
|
+
init_dialog_prompt();
|
|
58272
|
+
init_theme3();
|
|
58273
|
+
init_locale();
|
|
58274
|
+
init_tool_summarize();
|
|
58275
|
+
init_subagent_markers();
|
|
58276
|
+
[bridgeOpen7, setBridgeOpen7] = createSignal(false);
|
|
58277
|
+
[panelOpen8, setPanelOpen8] = createSignal(false);
|
|
58278
|
+
subagentsViewerOpen = panelOpen8;
|
|
58279
|
+
});
|
|
58280
|
+
|
|
55561
58281
|
// ../tui-base/src/routes/session/settings-modal.tsx
|
|
55562
|
-
import { TextAttributes as
|
|
58282
|
+
import { TextAttributes as TextAttributes12 } from "@opentui/core";
|
|
55563
58283
|
function resolveVersion() {
|
|
55564
58284
|
try {
|
|
55565
|
-
return "0.
|
|
58285
|
+
return "0.13.0";
|
|
55566
58286
|
} catch {
|
|
55567
58287
|
return "dev";
|
|
55568
58288
|
}
|
|
@@ -56464,7 +59184,7 @@ function SettingsModalBody(props) {
|
|
|
56464
59184
|
}
|
|
56465
59185
|
}), null);
|
|
56466
59186
|
effect((_p$) => {
|
|
56467
|
-
var _v$ = chrome().navBand, _v$2 = chrome().divider, _v$3 = contentBg(), _v$4 = chrome().titleBand, _v$5 =
|
|
59187
|
+
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
59188
|
_v$ !== _p$.e && (_p$.e = setProp(_el$3, "backgroundColor", _v$, _p$.e));
|
|
56469
59189
|
_v$2 !== _p$.t && (_p$.t = setProp(_el$4, "backgroundColor", _v$2, _p$.t));
|
|
56470
59190
|
_v$3 !== _p$.a && (_p$.a = setProp(_el$5, "backgroundColor", _v$3, _p$.a));
|
|
@@ -56809,7 +59529,7 @@ var init_settings_modal = __esm(() => {
|
|
|
56809
59529
|
plugins: {
|
|
56810
59530
|
command: "/plugins",
|
|
56811
59531
|
label: "\u6253\u5F00 /plugins",
|
|
56812
|
-
note: "\u63D2\u4EF6\u6E05\u5355\u4E0E\u542F\u505C\u7531 /plugins \u9762\u677F\u627F\u62C5"
|
|
59532
|
+
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
59533
|
},
|
|
56814
59534
|
presets: {
|
|
56815
59535
|
command: "/preset",
|
|
@@ -57130,7 +59850,7 @@ function ensureContrast(foreground, background, min = 4.5, fallback = foreground
|
|
|
57130
59850
|
}
|
|
57131
59851
|
|
|
57132
59852
|
// ../tui-base/src/context/panel-kit-host.tsx
|
|
57133
|
-
import { RGBA as RGBA15, TextAttributes as
|
|
59853
|
+
import { RGBA as RGBA15, TextAttributes as TextAttributes13 } from "@opentui/core";
|
|
57134
59854
|
function projectPanelTheme(theme) {
|
|
57135
59855
|
const primary = theme.text.action.primary;
|
|
57136
59856
|
const raised = theme.background.raised;
|
|
@@ -57179,11 +59899,11 @@ function projectPanelTheme(theme) {
|
|
|
57179
59899
|
}
|
|
57180
59900
|
},
|
|
57181
59901
|
attributes: {
|
|
57182
|
-
title:
|
|
57183
|
-
group:
|
|
57184
|
-
selected:
|
|
57185
|
-
keyHint:
|
|
57186
|
-
subtitle:
|
|
59902
|
+
title: TextAttributes13.BOLD,
|
|
59903
|
+
group: TextAttributes13.BOLD,
|
|
59904
|
+
selected: TextAttributes13.BOLD,
|
|
59905
|
+
keyHint: TextAttributes13.DIM,
|
|
59906
|
+
subtitle: TextAttributes13.DIM
|
|
57187
59907
|
},
|
|
57188
59908
|
identity: [theme.hue.accent[500], theme.hue.accent[300]]
|
|
57189
59909
|
};
|
|
@@ -57491,6 +60211,12 @@ class RemoteSessionSeam {
|
|
|
57491
60211
|
async searchSessions(query) {
|
|
57492
60212
|
return this.#session.searchSessions(query);
|
|
57493
60213
|
}
|
|
60214
|
+
async sessionJournal(sessionId) {
|
|
60215
|
+
return this.#session.sessionJournal(sessionId);
|
|
60216
|
+
}
|
|
60217
|
+
async forkSession(sessionId, seqEnd) {
|
|
60218
|
+
return this.#session.forkSession(sessionId, seqEnd);
|
|
60219
|
+
}
|
|
57494
60220
|
async storedTranscript(id, skip) {
|
|
57495
60221
|
const rows = await this.#session.storedTranscript(id, skip);
|
|
57496
60222
|
return rows.map((row) => {
|
|
@@ -57515,6 +60241,9 @@ class RemoteSessionSeam {
|
|
|
57515
60241
|
currentSessionId() {
|
|
57516
60242
|
return this.#session.currentSessionId();
|
|
57517
60243
|
}
|
|
60244
|
+
stagedSessionId() {
|
|
60245
|
+
return this.#session.stagedSessionId();
|
|
60246
|
+
}
|
|
57518
60247
|
cacheHitRate(mode) {
|
|
57519
60248
|
return this.#session.cacheHitRate(mode);
|
|
57520
60249
|
}
|
|
@@ -57558,6 +60287,12 @@ class RemoteSessionSeam {
|
|
|
57558
60287
|
resumeSession(id) {
|
|
57559
60288
|
return this.#session.resumeSession(id);
|
|
57560
60289
|
}
|
|
60290
|
+
repairScanBroken() {
|
|
60291
|
+
return this.#session.repairScanBroken();
|
|
60292
|
+
}
|
|
60293
|
+
repairSessionLog(path) {
|
|
60294
|
+
return this.#session.repairSessionLog(path);
|
|
60295
|
+
}
|
|
57561
60296
|
newSession() {
|
|
57562
60297
|
this.#session.newSession();
|
|
57563
60298
|
}
|
|
@@ -57671,6 +60406,22 @@ class RemoteSessionSeam {
|
|
|
57671
60406
|
this.#pluginsRevision[0]();
|
|
57672
60407
|
return this.#session.listPlugins();
|
|
57673
60408
|
}
|
|
60409
|
+
pluginBundles() {
|
|
60410
|
+
this.#pluginsRevision[0]();
|
|
60411
|
+
return this.#session.listBundles();
|
|
60412
|
+
}
|
|
60413
|
+
setPluginBundleEnabled(name, enabled) {
|
|
60414
|
+
return this.#session.setBundleEnabled(name, enabled);
|
|
60415
|
+
}
|
|
60416
|
+
removePluginBundle(name) {
|
|
60417
|
+
return this.#session.removeBundle(name);
|
|
60418
|
+
}
|
|
60419
|
+
inspectPluginSpec(spec) {
|
|
60420
|
+
return this.#session.inspectBundle(spec);
|
|
60421
|
+
}
|
|
60422
|
+
installPluginSpec(spec) {
|
|
60423
|
+
return this.#session.installBundle(spec);
|
|
60424
|
+
}
|
|
57674
60425
|
async refreshSkills() {
|
|
57675
60426
|
return this.#session.refreshSkills();
|
|
57676
60427
|
}
|
|
@@ -57734,13 +60485,20 @@ class RemoteSessionSeam {
|
|
|
57734
60485
|
login: (ref, apiKey) => this.#session.login(ref, apiKey),
|
|
57735
60486
|
logout: (ref) => this.#session.logout(ref),
|
|
57736
60487
|
routes: async () => {
|
|
57737
|
-
|
|
57738
|
-
|
|
57739
|
-
|
|
57740
|
-
|
|
57741
|
-
|
|
57742
|
-
|
|
57743
|
-
|
|
60488
|
+
const rows = await this.#session.settingsSeam.describe();
|
|
60489
|
+
const ns = Array.isArray(rows) ? rows.find((row) => row?.ns === "llm-pi-ai") : undefined;
|
|
60490
|
+
const providers = ns?.value?.providers ?? {};
|
|
60491
|
+
return Object.entries(providers).map(([id, profile]) => {
|
|
60492
|
+
const p = typeof profile === "object" && profile !== null ? profile : {};
|
|
60493
|
+
const apiKeyEnv = p.apiKeyEnv;
|
|
60494
|
+
const displayName = p.displayName;
|
|
60495
|
+
return {
|
|
60496
|
+
id,
|
|
60497
|
+
...typeof apiKeyEnv === "string" && apiKeyEnv !== "" ? { apiKeyEnv } : {},
|
|
60498
|
+
...typeof displayName === "string" && displayName !== "" ? { displayName } : {},
|
|
60499
|
+
...typeof p.api === "string" || typeof p.baseURL === "string" || Array.isArray(p.models) ? { declared: true } : {}
|
|
60500
|
+
};
|
|
60501
|
+
});
|
|
57744
60502
|
},
|
|
57745
60503
|
registerRoute: async (providerId, profile) => {
|
|
57746
60504
|
try {
|
|
@@ -57763,6 +60521,7 @@ class RemoteSessionSeam {
|
|
|
57763
60521
|
status: v.status,
|
|
57764
60522
|
rounds: v.rounds,
|
|
57765
60523
|
...v.startedAt !== undefined ? v.status === "running" ? { startedAt: v.startedAt } : { elapsedSec: Number(((Date.now() - v.startedAt) / 1000).toFixed(1)) } : {},
|
|
60524
|
+
...v.status !== "running" && v.endedAt !== undefined ? { endedAt: v.endedAt } : {},
|
|
57766
60525
|
...v.injectedRound !== undefined ? { injectedRound: v.injectedRound } : {},
|
|
57767
60526
|
...v.hardStopRound !== undefined ? { hardStopRound: v.hardStopRound } : {},
|
|
57768
60527
|
...v.spinStopRound !== undefined ? { spinStopRound: v.spinStopRound } : {},
|
|
@@ -57783,6 +60542,12 @@ class RemoteSessionSeam {
|
|
|
57783
60542
|
steerChild(id, text) {
|
|
57784
60543
|
return this.#session.steerChild(id, text);
|
|
57785
60544
|
}
|
|
60545
|
+
subagentTranscript(id) {
|
|
60546
|
+
return this.#session.childTranscript(id);
|
|
60547
|
+
}
|
|
60548
|
+
async interruptChild(id) {
|
|
60549
|
+
await this.#session.interruptChild(id);
|
|
60550
|
+
}
|
|
57786
60551
|
onSessionEvent(listener) {
|
|
57787
60552
|
this.#listeners.push(listener);
|
|
57788
60553
|
this.#ensureJournalFeed();
|
|
@@ -57824,7 +60589,7 @@ class RemoteSessionSeam {
|
|
|
57824
60589
|
}
|
|
57825
60590
|
function projectJournalRecord(entry, sessionId) {
|
|
57826
60591
|
if (entry.type === "user/message") {
|
|
57827
|
-
const text =
|
|
60592
|
+
const text = blocksText3(entry.data.content);
|
|
57828
60593
|
if (!text)
|
|
57829
60594
|
return [];
|
|
57830
60595
|
const id = typeof entry.data.messageID === "string" ? entry.data.messageID : `journal-${entry.seq}`;
|
|
@@ -57858,7 +60623,7 @@ function projectJournalRecord(entry, sessionId) {
|
|
|
57858
60623
|
}
|
|
57859
60624
|
return [];
|
|
57860
60625
|
}
|
|
57861
|
-
function
|
|
60626
|
+
function blocksText3(content) {
|
|
57862
60627
|
const blocks = Array.isArray(content) ? content : [];
|
|
57863
60628
|
let text = "";
|
|
57864
60629
|
for (const block of blocks) {
|
|
@@ -57874,7 +60639,7 @@ function blocksText2(content) {
|
|
|
57874
60639
|
function assistantTextValue(data) {
|
|
57875
60640
|
if (typeof data.text === "string")
|
|
57876
60641
|
return data.text.trim();
|
|
57877
|
-
return
|
|
60642
|
+
return blocksText3(data.content ?? data.parts);
|
|
57878
60643
|
}
|
|
57879
60644
|
function asSeamSettingsRow(row) {
|
|
57880
60645
|
return {
|
|
@@ -57897,6 +60662,7 @@ var init_session_seam_adapter = __esm(() => {
|
|
|
57897
60662
|
});
|
|
57898
60663
|
|
|
57899
60664
|
// ../tui-base/examples/v2-entry.tsx
|
|
60665
|
+
import { join as join10 } from "path";
|
|
57900
60666
|
async function loadShell() {
|
|
57901
60667
|
const [shared, lifecycle, transport, rhs, adapter, git] = await Promise.all([
|
|
57902
60668
|
Promise.resolve().then(() => (init_boot_shared(), exports_boot_shared)),
|
|
@@ -58081,7 +60847,7 @@ function V2SessionPage(props) {
|
|
|
58081
60847
|
mode: themeService.mode()
|
|
58082
60848
|
});
|
|
58083
60849
|
let cmdOrdinal = 0;
|
|
58084
|
-
const pickOne = (title, options, headerLine, currentValue) => new Promise((resolvePick) => {
|
|
60850
|
+
const pickOne = (title, options, headerLine, currentValue, extras) => new Promise((resolvePick) => {
|
|
58085
60851
|
let settled = false;
|
|
58086
60852
|
const done = (value) => {
|
|
58087
60853
|
if (settled)
|
|
@@ -58090,14 +60856,38 @@ function V2SessionPage(props) {
|
|
|
58090
60856
|
dialog.clear();
|
|
58091
60857
|
resolvePick(value);
|
|
58092
60858
|
};
|
|
60859
|
+
const [extrasTick, bumpExtrasTick] = createSignal(0);
|
|
60860
|
+
const actions = extras?.actions?.map((action) => ({
|
|
60861
|
+
command: action.command,
|
|
60862
|
+
title: typeof action.title === "function" ? (option) => action.title(option === undefined ? undefined : String(option.value)) : action.title,
|
|
60863
|
+
bind: action.bind,
|
|
60864
|
+
disabled: action.disabled ? (option) => option === undefined ? false : action.disabled(String(option.value)) : undefined,
|
|
60865
|
+
onTrigger: (option) => {
|
|
60866
|
+
extras.onAction?.(action.command, String(option.value));
|
|
60867
|
+
bumpExtrasTick((n) => n + 1);
|
|
60868
|
+
}
|
|
60869
|
+
}));
|
|
58093
60870
|
dialog.replace(() => createComponent2(DialogSelect, {
|
|
58094
60871
|
title,
|
|
58095
60872
|
renderFilter: false,
|
|
58096
|
-
|
|
58097
|
-
|
|
58098
|
-
|
|
58099
|
-
|
|
58100
|
-
|
|
60873
|
+
get options() {
|
|
60874
|
+
if (extras?.getOptions === undefined) {
|
|
60875
|
+
return options.map((option) => ({
|
|
60876
|
+
title: option.title,
|
|
60877
|
+
value: option.value,
|
|
60878
|
+
description: option.description
|
|
60879
|
+
}));
|
|
60880
|
+
}
|
|
60881
|
+
extrasTick();
|
|
60882
|
+
return extras.getOptions().map((option) => ({
|
|
60883
|
+
title: option.title,
|
|
60884
|
+
value: option.value,
|
|
60885
|
+
description: option.description,
|
|
60886
|
+
category: option.category
|
|
60887
|
+
}));
|
|
60888
|
+
},
|
|
60889
|
+
...actions && actions.length > 0 ? { actions } : {},
|
|
60890
|
+
...extras ? { preserveSelection: true } : {},
|
|
58101
60891
|
current: currentValue,
|
|
58102
60892
|
focusCurrent: false,
|
|
58103
60893
|
onSelect: (option) => done(option.value),
|
|
@@ -58163,6 +60953,26 @@ function V2SessionPage(props) {
|
|
|
58163
60953
|
}
|
|
58164
60954
|
})
|
|
58165
60955
|
};
|
|
60956
|
+
const reloadSession = (sessionId) => {
|
|
60957
|
+
setLastRequest(undefined);
|
|
60958
|
+
composerRef?.resetDeliveries();
|
|
60959
|
+
setComposerPending([]);
|
|
60960
|
+
setTools(0);
|
|
60961
|
+
resetSkinLineFades();
|
|
60962
|
+
const settled = projection.load(sessionId);
|
|
60963
|
+
seam.currentModelSelection().then(setModel);
|
|
60964
|
+
refreshFooterData();
|
|
60965
|
+
refreshPresetLabel();
|
|
60966
|
+
setSkillRows(props.skills ?? []);
|
|
60967
|
+
setContextRevision((n) => n + 1);
|
|
60968
|
+
return settled;
|
|
60969
|
+
};
|
|
60970
|
+
const resumeFromSearch = async (sessionId) => {
|
|
60971
|
+
await seam.storedTranscript(sessionId);
|
|
60972
|
+
seam.resumeSession(sessionId);
|
|
60973
|
+
await reloadSession(sessionId);
|
|
60974
|
+
sayLine(`resumed ${sessionId}`);
|
|
60975
|
+
};
|
|
58166
60976
|
const slash = createSlashHost(buildSlashDeps({
|
|
58167
60977
|
seam,
|
|
58168
60978
|
commands: slashCommands,
|
|
@@ -58178,20 +60988,7 @@ function V2SessionPage(props) {
|
|
|
58178
60988
|
setSkillRows(props.skills ?? []);
|
|
58179
60989
|
setContextRevision((n) => n + 1);
|
|
58180
60990
|
},
|
|
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
|
-
},
|
|
60991
|
+
reload: reloadSession,
|
|
58195
60992
|
quit: props.quit,
|
|
58196
60993
|
pickOne
|
|
58197
60994
|
}, {
|
|
@@ -58199,8 +60996,11 @@ function V2SessionPage(props) {
|
|
|
58199
60996
|
openBtw: (argText) => void openBtw(argText),
|
|
58200
60997
|
openSearch: () => openSessionsSearch(),
|
|
58201
60998
|
openPlugins: () => openPluginsPanel(),
|
|
60999
|
+
openSkills: () => openSkillsPanel(),
|
|
58202
61000
|
openAgents: (name) => openAgentsPanel(name),
|
|
58203
61001
|
openSettings: () => openSettingsPanel(),
|
|
61002
|
+
openHistory: () => openHistoryPanel(),
|
|
61003
|
+
openSubagents: () => openSubagentsViewer(),
|
|
58204
61004
|
refreshFooter: refreshFooterData,
|
|
58205
61005
|
invalidateFooter: () => {
|
|
58206
61006
|
footerRefreshSeq++;
|
|
@@ -58252,6 +61052,7 @@ function V2SessionPage(props) {
|
|
|
58252
61052
|
get seam() {
|
|
58253
61053
|
return seam;
|
|
58254
61054
|
},
|
|
61055
|
+
onResumed: (sessionId) => resumeFromSearch(sessionId),
|
|
58255
61056
|
onClosed: () => {
|
|
58256
61057
|
if (composerRef && !composerRef.focused())
|
|
58257
61058
|
composerRef.focus();
|
|
@@ -58266,6 +61067,14 @@ function V2SessionPage(props) {
|
|
|
58266
61067
|
composerRef.focus();
|
|
58267
61068
|
}
|
|
58268
61069
|
}),
|
|
61070
|
+
createComponent2(SkillsPanel, {
|
|
61071
|
+
source: () => props.skillsSource,
|
|
61072
|
+
curated: () => props.skillsCurated,
|
|
61073
|
+
onClosed: () => {
|
|
61074
|
+
if (composerRef && !composerRef.focused())
|
|
61075
|
+
composerRef.focus();
|
|
61076
|
+
}
|
|
61077
|
+
}),
|
|
58269
61078
|
createComponent2(AgentsPanel, {
|
|
58270
61079
|
get seam() {
|
|
58271
61080
|
return seam;
|
|
@@ -58277,6 +61086,35 @@ function V2SessionPage(props) {
|
|
|
58277
61086
|
composerRef.focus();
|
|
58278
61087
|
}
|
|
58279
61088
|
}),
|
|
61089
|
+
createComponent2(HistoryPanel, {
|
|
61090
|
+
get seam() {
|
|
61091
|
+
return seam;
|
|
61092
|
+
},
|
|
61093
|
+
sessionId: () => seam.currentSessionId() ?? seam.stagedSessionId?.() ?? props.initialSessionId,
|
|
61094
|
+
onRefill: (text) => {
|
|
61095
|
+
composerRef?.node()?.setText(text);
|
|
61096
|
+
if (composerRef && !composerRef.focused())
|
|
61097
|
+
composerRef.focus();
|
|
61098
|
+
},
|
|
61099
|
+
onForked: async (forkedId, turn) => {
|
|
61100
|
+
seam.resumeSession(forkedId);
|
|
61101
|
+
await reloadSession(forkedId);
|
|
61102
|
+
sayLine(`forked from turn #${turn} \u2192 ${forkedId}`);
|
|
61103
|
+
},
|
|
61104
|
+
onClosed: () => {
|
|
61105
|
+
if (composerRef && !composerRef.focused())
|
|
61106
|
+
composerRef.focus();
|
|
61107
|
+
}
|
|
61108
|
+
}),
|
|
61109
|
+
createComponent2(SubagentsViewer, {
|
|
61110
|
+
get seam() {
|
|
61111
|
+
return seam;
|
|
61112
|
+
},
|
|
61113
|
+
onClosed: () => {
|
|
61114
|
+
if (composerRef && !composerRef.focused())
|
|
61115
|
+
composerRef.focus();
|
|
61116
|
+
}
|
|
61117
|
+
}),
|
|
58280
61118
|
createComponent2(SettingsModalHost, {
|
|
58281
61119
|
get seam() {
|
|
58282
61120
|
return seam;
|
|
@@ -58458,11 +61296,16 @@ async function bootClientV2(options = {}) {
|
|
|
58458
61296
|
initialSessionId = autoResume?.id;
|
|
58459
61297
|
resumeNotice = autoResume?.line;
|
|
58460
61298
|
}
|
|
61299
|
+
const agentsHomeForSkills = resolveAgentsHome(seam.configLoad().agentsHome);
|
|
58461
61300
|
const skillRows = discoverSkills({
|
|
58462
61301
|
cwd: workspace,
|
|
58463
61302
|
dshHome: host.dshHome,
|
|
58464
|
-
agentsHome:
|
|
61303
|
+
agentsHome: agentsHomeForSkills
|
|
58465
61304
|
});
|
|
61305
|
+
const skillsManagerRoots = {
|
|
61306
|
+
source: join10(agentsHomeForSkills, "skills"),
|
|
61307
|
+
curated: join10(host.dshHome, "skills")
|
|
61308
|
+
};
|
|
58466
61309
|
const envTheme = process.env[shared.ENV_THEME];
|
|
58467
61310
|
const workspaceConfig = seam.workspaceConfig();
|
|
58468
61311
|
const migration = shared.skinMigrationPlan({
|
|
@@ -58531,7 +61374,9 @@ async function bootClientV2(options = {}) {
|
|
|
58531
61374
|
probeBranch: (cwd) => git.probeGitBranchOrSha(cwd),
|
|
58532
61375
|
initialSessionId,
|
|
58533
61376
|
resumeNotice,
|
|
58534
|
-
skills: skillRows
|
|
61377
|
+
skills: skillRows,
|
|
61378
|
+
skillsSource: skillsManagerRoots.source,
|
|
61379
|
+
skillsCurated: skillsManagerRoots.curated
|
|
58535
61380
|
});
|
|
58536
61381
|
}
|
|
58537
61382
|
});
|
|
@@ -58606,10 +61451,13 @@ var init_v2_entry = __esm(() => {
|
|
|
58606
61451
|
init_slash_deps();
|
|
58607
61452
|
init_commands();
|
|
58608
61453
|
init_skills_source();
|
|
61454
|
+
init_skills_panel();
|
|
58609
61455
|
init_sessions_search();
|
|
58610
61456
|
init_plugins_panel();
|
|
58611
61457
|
init_agents_panel();
|
|
58612
61458
|
init_settings_panel();
|
|
61459
|
+
init_history_panel();
|
|
61460
|
+
init_subagents_viewer();
|
|
58613
61461
|
init_settings_modal();
|
|
58614
61462
|
init_btw_overlay();
|
|
58615
61463
|
init_dialog_select();
|
|
@@ -58675,6 +61523,9 @@ async function bootClient(options = {}) {
|
|
|
58675
61523
|
idleExitSec,
|
|
58676
61524
|
...options.dshHome !== undefined ? { dshHome: options.dshHome } : {}
|
|
58677
61525
|
});
|
|
61526
|
+
if (options.installErrorLog !== false) {
|
|
61527
|
+
installClientErrorLog(host.dshHome);
|
|
61528
|
+
}
|
|
58678
61529
|
bootCallOrder.push("connect");
|
|
58679
61530
|
const connection = (options.connect ?? defaultConnect)(host.authority, host.cookieHeader);
|
|
58680
61531
|
bootCallOrder.push("createSession");
|
|
@@ -58755,6 +61606,7 @@ export {
|
|
|
58755
61606
|
aggregateTurnContext,
|
|
58756
61607
|
bootCallOrder,
|
|
58757
61608
|
bootClient,
|
|
61609
|
+
installClientErrorLog,
|
|
58758
61610
|
installExitPaths,
|
|
58759
61611
|
spawnIdleReaper,
|
|
58760
61612
|
themeNameFromConfig
|