@aiwayds/dsh-opentui 0.24.0 → 0.25.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/dist/bridge/bundle-fingerprint.json +1 -1
- package/dist/bridge/index.js +1848 -29
- package/dist/client/index.js +1935 -187
- package/dist/client/index.js.map +18 -12
- package/dist/host-launch.mjs.map +2 -2
- package/dist/locales/en.json +81 -0
- package/dist/locales/zh-CN.json +81 -0
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -5613,6 +5613,7 @@ class ClientConnection {
|
|
|
5613
5613
|
#state = "connecting";
|
|
5614
5614
|
#closed = false;
|
|
5615
5615
|
#maxConnectAttempts;
|
|
5616
|
+
#boundedPoll;
|
|
5616
5617
|
#connectBudgetMs;
|
|
5617
5618
|
#diagnostics;
|
|
5618
5619
|
#connectAttempts = 0;
|
|
@@ -5642,6 +5643,7 @@ class ClientConnection {
|
|
|
5642
5643
|
}
|
|
5643
5644
|
};
|
|
5644
5645
|
this.#recovery = options.recovery;
|
|
5646
|
+
this.#boundedPoll = options.maxConnectAttempts === undefined;
|
|
5645
5647
|
this.#maxConnectAttempts = Math.max(0, options.maxConnectAttempts ?? DEFAULT_MAX_CONNECT_ATTEMPTS);
|
|
5646
5648
|
this.#connectBudgetMs = resolveConnectTimeoutMs(options.connectBudgetMs);
|
|
5647
5649
|
this.#diagnostics = options.diagnostics;
|
|
@@ -5676,7 +5678,7 @@ class ClientConnection {
|
|
|
5676
5678
|
handle.registerGenerationSource((signal, ready) => {
|
|
5677
5679
|
if (!this.#connectedOnce) {
|
|
5678
5680
|
this.#connectAttempts += 1;
|
|
5679
|
-
if (this.#connectAttempts > this.#maxConnectAttempts + 1) {
|
|
5681
|
+
if (!this.#boundedPoll && this.#connectAttempts > this.#maxConnectAttempts + 1) {
|
|
5680
5682
|
this.#failConnect(new ConnectionRetryExhaustedError(this.#maxConnectAttempts, this.authority, this.#diagnostics?.()));
|
|
5681
5683
|
return new Promise((resolve) => {
|
|
5682
5684
|
if (signal.aborted)
|
|
@@ -54862,6 +54864,72 @@ function formatSessionInfoPanel(rows) {
|
|
|
54862
54864
|
return rows.map((row) => `${row.field.padEnd(width)} ${row.value}`);
|
|
54863
54865
|
}
|
|
54864
54866
|
|
|
54867
|
+
// ../tui-base/src/routes/session/goals-command.ts
|
|
54868
|
+
function goalsUnknownOp(argText) {
|
|
54869
|
+
const trimmed = argText.trim();
|
|
54870
|
+
if (trimmed === "")
|
|
54871
|
+
return;
|
|
54872
|
+
const space = trimmed.search(/\s/);
|
|
54873
|
+
const token = (space < 0 ? trimmed : trimmed.slice(0, space)).toLowerCase();
|
|
54874
|
+
return KNOWN_OPS.has(token) ? undefined : token;
|
|
54875
|
+
}
|
|
54876
|
+
function goalsUnknownOpHint(token) {
|
|
54877
|
+
return t("command.goals.unknownOp", { op: token.slice(0, 48) });
|
|
54878
|
+
}
|
|
54879
|
+
function parseGoalsArgs(argText) {
|
|
54880
|
+
const trimmed = argText.trim();
|
|
54881
|
+
if (trimmed === "")
|
|
54882
|
+
return { kind: "status" };
|
|
54883
|
+
const space = trimmed.search(/\s/);
|
|
54884
|
+
const op = (space < 0 ? trimmed : trimmed.slice(0, space)).toLowerCase();
|
|
54885
|
+
const rest = space < 0 ? "" : trimmed.slice(space + 1).trim();
|
|
54886
|
+
if (op === "create")
|
|
54887
|
+
return { kind: "create", objective: rest };
|
|
54888
|
+
if (op === "edit")
|
|
54889
|
+
return { kind: "edit", objective: rest };
|
|
54890
|
+
if (op === "pause" || op === "resume" || op === "complete" || op === "clear")
|
|
54891
|
+
return { kind: op };
|
|
54892
|
+
return { kind: "status" };
|
|
54893
|
+
}
|
|
54894
|
+
function formatGoalStatus(view) {
|
|
54895
|
+
const phaseKey = `command.goals.phase.${view.phase}`;
|
|
54896
|
+
const activationKey = `command.goals.activation.${view.activation}`;
|
|
54897
|
+
const phase = installed(phaseKey) ? t(phaseKey) : view.phase;
|
|
54898
|
+
const activation = installed(activationKey) ? t(activationKey) : view.activation;
|
|
54899
|
+
return [
|
|
54900
|
+
t("command.goals.header"),
|
|
54901
|
+
t("command.goals.objective", { text: view.objective.slice(0, 240) }),
|
|
54902
|
+
t("command.goals.phase.line", { phase }),
|
|
54903
|
+
t("command.goals.activation.line", { activation }),
|
|
54904
|
+
t("command.goals.rounds", { started: view.roundsStarted, max: view.maxGoalRounds }),
|
|
54905
|
+
t("command.goals.ref", { id: view.id.slice(0, 48), revision: view.revision }),
|
|
54906
|
+
...view.blockedReason ? [t("command.goals.blocked", { code: view.blockedReason.code.slice(0, 48), message: view.blockedReason.message.slice(0, 240) })] : []
|
|
54907
|
+
];
|
|
54908
|
+
}
|
|
54909
|
+
function installed(key) {
|
|
54910
|
+
try {
|
|
54911
|
+
return typeof t(key) === "string" && t(key) !== key;
|
|
54912
|
+
} catch {
|
|
54913
|
+
return false;
|
|
54914
|
+
}
|
|
54915
|
+
}
|
|
54916
|
+
function goalsConfirmOptions() {
|
|
54917
|
+
return [
|
|
54918
|
+
{ title: t("command.goals.confirm.yes"), value: "yes" },
|
|
54919
|
+
{ title: t("command.goals.confirm.no"), value: "no" }
|
|
54920
|
+
];
|
|
54921
|
+
}
|
|
54922
|
+
function goalsConfirmTitle(op) {
|
|
54923
|
+
if (op.kind === "status")
|
|
54924
|
+
return "";
|
|
54925
|
+
return t(`command.goals.confirm.${op.kind}`);
|
|
54926
|
+
}
|
|
54927
|
+
var KNOWN_OPS;
|
|
54928
|
+
var init_goals_command = __esm(() => {
|
|
54929
|
+
init_i18n();
|
|
54930
|
+
KNOWN_OPS = new Set(["create", "edit", "pause", "resume", "complete", "clear"]);
|
|
54931
|
+
});
|
|
54932
|
+
|
|
54865
54933
|
// ../tui-base/src/routes/session/model-picker.ts
|
|
54866
54934
|
function modelKey(providerID, modelID) {
|
|
54867
54935
|
return `${providerID}/${modelID}`;
|
|
@@ -54892,8 +54960,39 @@ function buildModelPickerRows(entries, favorites, hidden, current) {
|
|
|
54892
54960
|
const hiddenRows = entries.filter((entry) => hiddenSet.has(modelKey(entry.providerID, entry.modelID)) && !favorites.includes(modelKey(entry.providerID, entry.modelID))).map((entry) => row(entry, "Hidden"));
|
|
54893
54961
|
return [...favoriteRows, ...normalRows, ...hiddenRows];
|
|
54894
54962
|
}
|
|
54963
|
+
function formatDiscoveredModels(models, limit = 8) {
|
|
54964
|
+
return models.slice(0, limit).map((m) => m.name !== undefined ? `${m.id} (${m.name})` : m.id).join(", ");
|
|
54965
|
+
}
|
|
54895
54966
|
|
|
54896
54967
|
// ../tui-base/src/routes/session/login.ts
|
|
54968
|
+
function catalogEntriesFromDirectory(registered, configurable, staticCatalog = PROVIDER_CATALOG) {
|
|
54969
|
+
const out = [];
|
|
54970
|
+
const seen = new Set;
|
|
54971
|
+
for (const reg of registered) {
|
|
54972
|
+
if (!reg.id || seen.has(reg.id))
|
|
54973
|
+
continue;
|
|
54974
|
+
seen.add(reg.id);
|
|
54975
|
+
const stat = staticCatalog.find((e) => e.id === reg.id);
|
|
54976
|
+
out.push(stat ?? { id: reg.id, name: reg.name || reg.id, hint: "api key", catalogRoute: true });
|
|
54977
|
+
}
|
|
54978
|
+
for (const cfg of configurable) {
|
|
54979
|
+
if (!cfg.provider || seen.has(cfg.provider))
|
|
54980
|
+
continue;
|
|
54981
|
+
seen.add(cfg.provider);
|
|
54982
|
+
const stat = staticCatalog.find((e) => e.id === cfg.provider);
|
|
54983
|
+
if (stat) {
|
|
54984
|
+
out.push(stat);
|
|
54985
|
+
continue;
|
|
54986
|
+
}
|
|
54987
|
+
out.push({
|
|
54988
|
+
id: cfg.provider,
|
|
54989
|
+
name: cfg.displayName || cfg.provider,
|
|
54990
|
+
hint: cfg.error ? "provider configuration issue" : "configurable provider",
|
|
54991
|
+
catalogRoute: true
|
|
54992
|
+
});
|
|
54993
|
+
}
|
|
54994
|
+
return out;
|
|
54995
|
+
}
|
|
54897
54996
|
function deriveKeyRef(provider) {
|
|
54898
54997
|
return `${provider.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_API_KEY`;
|
|
54899
54998
|
}
|
|
@@ -55109,6 +55208,30 @@ async function offerCorruptedLogRepair(ctx, sessionId, broken) {
|
|
|
55109
55208
|
}
|
|
55110
55209
|
return true;
|
|
55111
55210
|
}
|
|
55211
|
+
async function resolveLoginCatalog(seam, say) {
|
|
55212
|
+
const dir = seam.providerDirectory;
|
|
55213
|
+
if (!dir)
|
|
55214
|
+
return { entries: [...PROVIDER_CATALOG], degraded: false };
|
|
55215
|
+
let registered = [];
|
|
55216
|
+
let configurable = [];
|
|
55217
|
+
let failed = false;
|
|
55218
|
+
try {
|
|
55219
|
+
registered = await dir.registered();
|
|
55220
|
+
} catch {
|
|
55221
|
+
failed = true;
|
|
55222
|
+
}
|
|
55223
|
+
try {
|
|
55224
|
+
configurable = await dir.configurable();
|
|
55225
|
+
} catch {
|
|
55226
|
+
failed = true;
|
|
55227
|
+
}
|
|
55228
|
+
const real = catalogEntriesFromDirectory(registered, configurable);
|
|
55229
|
+
if (real.length === 0)
|
|
55230
|
+
return { entries: [...PROVIDER_CATALOG], degraded: true };
|
|
55231
|
+
if (failed)
|
|
55232
|
+
say(t("command.login.directoryPartial"));
|
|
55233
|
+
return { entries: real, degraded: false };
|
|
55234
|
+
}
|
|
55112
55235
|
async function commitCatalogLogin(ctx, face, entry) {
|
|
55113
55236
|
const key = await ctx.promptText?.(`API key for ${entry.name} (${deriveKeyRef(entry.id)})`, { mask: true });
|
|
55114
55237
|
if (key === undefined)
|
|
@@ -55202,6 +55325,30 @@ function coreCommands() {
|
|
|
55202
55325
|
ctx.say(t("command.model.stagedSwitchFailed", { reason: pendingSelectionError }));
|
|
55203
55326
|
}
|
|
55204
55327
|
const arg = argText.trim();
|
|
55328
|
+
if (arg === "discover") {
|
|
55329
|
+
const discover = ctx.seam.providerDirectory?.discover;
|
|
55330
|
+
if (typeof discover !== "function") {
|
|
55331
|
+
ctx.say(t("command.model.discoverUnavailable", { reason: "no discovery face" }));
|
|
55332
|
+
return;
|
|
55333
|
+
}
|
|
55334
|
+
let providerID = "default";
|
|
55335
|
+
try {
|
|
55336
|
+
providerID = (await ctx.seam.currentModelSelection?.())?.providerID ?? "default";
|
|
55337
|
+
} catch {}
|
|
55338
|
+
ctx.say(t("command.model.discovering", { provider: providerID }));
|
|
55339
|
+
try {
|
|
55340
|
+
const models = await discover("llm", { provider: providerID });
|
|
55341
|
+
if (models.length === 0) {
|
|
55342
|
+
ctx.say(t("command.model.discoverEmpty"));
|
|
55343
|
+
return;
|
|
55344
|
+
}
|
|
55345
|
+
const list = formatDiscoveredModels(models);
|
|
55346
|
+
ctx.say(t("command.model.discovered", { n: models.length, list }));
|
|
55347
|
+
} catch (error) {
|
|
55348
|
+
ctx.say(t("command.model.discoverUnavailable", { reason: seamFailureReason(error) }));
|
|
55349
|
+
}
|
|
55350
|
+
return;
|
|
55351
|
+
}
|
|
55205
55352
|
if (arg) {
|
|
55206
55353
|
const [providerID, modelID] = arg.split("/");
|
|
55207
55354
|
if (!providerID || !modelID) {
|
|
@@ -55344,9 +55491,12 @@ function coreCommands() {
|
|
|
55344
55491
|
ctx.say(t("command.login.unavailable"));
|
|
55345
55492
|
return;
|
|
55346
55493
|
}
|
|
55494
|
+
const { entries, degraded } = await resolveLoginCatalog(ctx.seam, ctx.say);
|
|
55495
|
+
if (degraded)
|
|
55496
|
+
ctx.say(t("command.login.directoryDegraded"));
|
|
55347
55497
|
const arg = argText.trim().toLowerCase();
|
|
55348
55498
|
if (arg) {
|
|
55349
|
-
const entry =
|
|
55499
|
+
const entry = entries.find((e) => e.id === arg);
|
|
55350
55500
|
if (!entry) {
|
|
55351
55501
|
ctx.say(t("command.login.unknownProvider", { provider: arg }));
|
|
55352
55502
|
return;
|
|
@@ -55354,7 +55504,7 @@ function coreCommands() {
|
|
|
55354
55504
|
await commitCatalogLogin(ctx, face, entry);
|
|
55355
55505
|
return;
|
|
55356
55506
|
}
|
|
55357
|
-
const picked = await ctx.pickOne(LOGIN_PICKER_TITLE, [CUSTOM_ENTRY, ...
|
|
55507
|
+
const picked = await ctx.pickOne(LOGIN_PICKER_TITLE, [CUSTOM_ENTRY, ...entries].map((e) => ({ title: e.name, value: e.id, description: e.hint })));
|
|
55358
55508
|
if (!picked)
|
|
55359
55509
|
return;
|
|
55360
55510
|
if (picked === CUSTOM_ENTRY.id) {
|
|
@@ -55362,7 +55512,7 @@ function coreCommands() {
|
|
|
55362
55512
|
await runCustomLoginChain(ctx, face, routes);
|
|
55363
55513
|
return;
|
|
55364
55514
|
}
|
|
55365
|
-
const entry =
|
|
55515
|
+
const entry = entries.find((e) => e.id === picked);
|
|
55366
55516
|
if (!entry)
|
|
55367
55517
|
return;
|
|
55368
55518
|
await commitCatalogLogin(ctx, face, entry);
|
|
@@ -55543,6 +55693,71 @@ function coreCommands() {
|
|
|
55543
55693
|
ctx.say(t("command.plugins.entry", { name: plugin.name, version: plugin.version }));
|
|
55544
55694
|
}
|
|
55545
55695
|
},
|
|
55696
|
+
{
|
|
55697
|
+
name: "/goals",
|
|
55698
|
+
description: t("command.goals.description"),
|
|
55699
|
+
async run(ctx, argText) {
|
|
55700
|
+
const goals = ctx.seam.goals;
|
|
55701
|
+
if (!goals) {
|
|
55702
|
+
ctx.say(t("command.goals.unavailable"));
|
|
55703
|
+
return;
|
|
55704
|
+
}
|
|
55705
|
+
const unknownOp = goalsUnknownOp(argText);
|
|
55706
|
+
if (unknownOp !== undefined)
|
|
55707
|
+
ctx.say(goalsUnknownOpHint(unknownOp));
|
|
55708
|
+
const op = parseGoalsArgs(argText);
|
|
55709
|
+
if (op.kind === "status") {
|
|
55710
|
+
try {
|
|
55711
|
+
const view = await goals.status();
|
|
55712
|
+
if (view === undefined) {
|
|
55713
|
+
ctx.say(t("command.goals.none"));
|
|
55714
|
+
return;
|
|
55715
|
+
}
|
|
55716
|
+
for (const line of formatGoalStatus(view))
|
|
55717
|
+
ctx.say(line);
|
|
55718
|
+
} catch {
|
|
55719
|
+
ctx.say(t("command.goals.degraded"));
|
|
55720
|
+
}
|
|
55721
|
+
return;
|
|
55722
|
+
}
|
|
55723
|
+
let objective = op.kind === "create" || op.kind === "edit" ? op.objective : "";
|
|
55724
|
+
if ((op.kind === "create" || op.kind === "edit") && objective === "" && ctx.promptText) {
|
|
55725
|
+
const answer = await ctx.promptText(t("command.goals.prompt.objective"));
|
|
55726
|
+
objective = (answer ?? "").trim();
|
|
55727
|
+
}
|
|
55728
|
+
if ((op.kind === "create" || op.kind === "edit") && objective === "") {
|
|
55729
|
+
ctx.say(t("command.goals.aborted"));
|
|
55730
|
+
return;
|
|
55731
|
+
}
|
|
55732
|
+
const confirmed = ctx.pickOne ? await ctx.pickOne(goalsConfirmTitle(op), goalsConfirmOptions()) === "yes" : false;
|
|
55733
|
+
if (!confirmed) {
|
|
55734
|
+
ctx.say(t("command.goals.aborted"));
|
|
55735
|
+
return;
|
|
55736
|
+
}
|
|
55737
|
+
try {
|
|
55738
|
+
if (op.kind === "create") {
|
|
55739
|
+
const ref = await goals.create(objective);
|
|
55740
|
+
ctx.say(ref ? t("command.goals.created", { id: ref.id, revision: ref.revision }) : t("command.goals.failed"));
|
|
55741
|
+
} else {
|
|
55742
|
+
const view = await goals.status();
|
|
55743
|
+
if (view === undefined) {
|
|
55744
|
+
ctx.say(t("command.goals.none"));
|
|
55745
|
+
return;
|
|
55746
|
+
}
|
|
55747
|
+
const ref = { id: view.id, revision: view.revision };
|
|
55748
|
+
if (op.kind === "edit") {
|
|
55749
|
+
const edited = await goals.edit(ref, { objective });
|
|
55750
|
+
ctx.say(edited ? t("command.goals.edited") : t("command.goals.failed"));
|
|
55751
|
+
} else {
|
|
55752
|
+
const changed = await goals[op.kind](ref);
|
|
55753
|
+
ctx.say(changed ? t("command.goals.updated", { op: op.kind }) : t("command.goals.failed"));
|
|
55754
|
+
}
|
|
55755
|
+
}
|
|
55756
|
+
} catch {
|
|
55757
|
+
ctx.say(t("command.goals.degraded"));
|
|
55758
|
+
}
|
|
55759
|
+
}
|
|
55760
|
+
},
|
|
55546
55761
|
{
|
|
55547
55762
|
name: "/skills",
|
|
55548
55763
|
description: t("command.skills.description"),
|
|
@@ -55912,6 +56127,39 @@ function coreCommands() {
|
|
|
55912
56127
|
];
|
|
55913
56128
|
ctx.say(t("command.stop.done", { parts: parts.join(", ") }));
|
|
55914
56129
|
}
|
|
56130
|
+
},
|
|
56131
|
+
{
|
|
56132
|
+
name: "/account",
|
|
56133
|
+
description: t("command.account.description"),
|
|
56134
|
+
async run(ctx, argText) {
|
|
56135
|
+
const face = ctx.seam.account;
|
|
56136
|
+
if (!face) {
|
|
56137
|
+
ctx.say(t("command.account.unavailable"));
|
|
56138
|
+
return;
|
|
56139
|
+
}
|
|
56140
|
+
const show = (state) => {
|
|
56141
|
+
ctx.say(t("command.account.state", {
|
|
56142
|
+
status: state.status ?? "\u2014",
|
|
56143
|
+
phase: state.attemptPhase ?? "\u2014",
|
|
56144
|
+
urlReady: state.authorizeUrlReady ? "\u2713" : "\u2014",
|
|
56145
|
+
links: state.linksPresent ? "\u2713" : "\u2014"
|
|
56146
|
+
}));
|
|
56147
|
+
};
|
|
56148
|
+
const arg = argText.trim().toLowerCase();
|
|
56149
|
+
try {
|
|
56150
|
+
if (!arg || arg === "state") {
|
|
56151
|
+
show(await face.getState());
|
|
56152
|
+
} else if (arg === "signin") {
|
|
56153
|
+
show(await face.startSignIn("http://localhost", "desktop"));
|
|
56154
|
+
} else if (arg === "signout") {
|
|
56155
|
+
show(await face.signOut());
|
|
56156
|
+
} else {
|
|
56157
|
+
ctx.say(t("command.account.unknownAction", { action: argText.trim() }));
|
|
56158
|
+
}
|
|
56159
|
+
} catch (error) {
|
|
56160
|
+
ctx.say(t("command.account.failed", { reason: seamFailureReason(error) }));
|
|
56161
|
+
}
|
|
56162
|
+
}
|
|
55915
56163
|
}
|
|
55916
56164
|
];
|
|
55917
56165
|
}
|
|
@@ -55939,6 +56187,7 @@ var MODEL_DEFAULT_EFFORT_PICK = "__model_default__";
|
|
|
55939
56187
|
var init_commands = __esm(() => {
|
|
55940
56188
|
init_i18n();
|
|
55941
56189
|
init_hotkeys();
|
|
56190
|
+
init_goals_command();
|
|
55942
56191
|
init_login();
|
|
55943
56192
|
init_hints_line();
|
|
55944
56193
|
init_motion();
|
|
@@ -57570,6 +57819,11 @@ var init_sessions_search = __esm(() => {
|
|
|
57570
57819
|
sessionsSearchOpen = panelOpen3;
|
|
57571
57820
|
});
|
|
57572
57821
|
|
|
57822
|
+
// ../tui-base/src/seams/session.ts
|
|
57823
|
+
function createPluginWriteConfirm(operation) {
|
|
57824
|
+
return { __pluginWriteConfirm: true, operation };
|
|
57825
|
+
}
|
|
57826
|
+
|
|
57573
57827
|
// ../tui-base/src/routes/session/plugins-panel.tsx
|
|
57574
57828
|
import { TextAttributes as TextAttributes10 } from "@opentui/core";
|
|
57575
57829
|
function openPluginsPanel() {
|
|
@@ -57592,6 +57846,8 @@ function filterPluginRows(rows, query) {
|
|
|
57592
57846
|
return rows.filter((row) => formatPluginLine(row).toLowerCase().includes(needle));
|
|
57593
57847
|
}
|
|
57594
57848
|
function bundleStateText(row) {
|
|
57849
|
+
if (row.stateUnknown === true)
|
|
57850
|
+
return t("panel.plugins.state.unknown");
|
|
57595
57851
|
const base = !row.installed && row.optional ? t("panel.plugins.state.available") : row.enabled ? t("panel.plugins.state.on") : t("panel.plugins.state.off");
|
|
57596
57852
|
if (row.error !== undefined && row.error !== "")
|
|
57597
57853
|
return t("panel.plugins.state.error", {
|
|
@@ -57612,9 +57868,10 @@ function pluginBundleViews(bundles) {
|
|
|
57612
57868
|
installed: bundle.installed === true,
|
|
57613
57869
|
optional: bundle.optional === true,
|
|
57614
57870
|
removable: bundle.removable === true,
|
|
57615
|
-
toggleable: bundle.readOnlyReason === undefined && (bundle.error === undefined || bundle.error === ""),
|
|
57871
|
+
toggleable: bundle.stateUnknown !== true && bundle.readOnlyReason === undefined && (bundle.error === undefined || bundle.error === ""),
|
|
57616
57872
|
readOnlyReason: bundle.readOnlyReason,
|
|
57617
|
-
error: bundle.error
|
|
57873
|
+
error: bundle.error,
|
|
57874
|
+
stateUnknown: bundle.stateUnknown
|
|
57618
57875
|
}));
|
|
57619
57876
|
}
|
|
57620
57877
|
function legacyPluginViews(rows) {
|
|
@@ -57664,6 +57921,72 @@ function installPreviewLine(inspection) {
|
|
|
57664
57921
|
spec
|
|
57665
57922
|
}) : spec;
|
|
57666
57923
|
}
|
|
57924
|
+
function writeConfirmObject(operation, target) {
|
|
57925
|
+
return t("panel.plugins.confirm.object", {
|
|
57926
|
+
operation: t(`panel.plugins.confirm.op.${operation}`),
|
|
57927
|
+
target
|
|
57928
|
+
});
|
|
57929
|
+
}
|
|
57930
|
+
function writeConfirmConsequence(operation) {
|
|
57931
|
+
return t(`panel.plugins.confirm.consequence.${operation}`);
|
|
57932
|
+
}
|
|
57933
|
+
function installProgressLine(progress) {
|
|
57934
|
+
switch (progress.state) {
|
|
57935
|
+
case "running":
|
|
57936
|
+
return t("panel.plugins.progress.running");
|
|
57937
|
+
case "cancelled":
|
|
57938
|
+
return t("panel.plugins.progress.cancelled", {
|
|
57939
|
+
target: progress.target || progress.requestId
|
|
57940
|
+
});
|
|
57941
|
+
case "failed":
|
|
57942
|
+
return t("panel.plugins.progress.failed", {
|
|
57943
|
+
target: progress.target || progress.requestId,
|
|
57944
|
+
error: progress.error ?? "?"
|
|
57945
|
+
});
|
|
57946
|
+
case "done":
|
|
57947
|
+
return t("panel.plugins.progress.done", {
|
|
57948
|
+
target: progress.target || progress.requestId
|
|
57949
|
+
});
|
|
57950
|
+
case "unknown":
|
|
57951
|
+
return t("panel.plugins.progress.unknown");
|
|
57952
|
+
}
|
|
57953
|
+
}
|
|
57954
|
+
async function pollInstallFace(wait, requestId, confirm, emit, stop, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))) {
|
|
57955
|
+
for (let tick = 0;tick < PROGRESS_POLL_MAX_TICKS; tick++) {
|
|
57956
|
+
if (stop())
|
|
57957
|
+
return;
|
|
57958
|
+
let progress;
|
|
57959
|
+
try {
|
|
57960
|
+
progress = await wait(requestId, confirm);
|
|
57961
|
+
} catch {
|
|
57962
|
+
return;
|
|
57963
|
+
}
|
|
57964
|
+
if (stop())
|
|
57965
|
+
return;
|
|
57966
|
+
emit(progress);
|
|
57967
|
+
if (progress.state !== "running")
|
|
57968
|
+
return;
|
|
57969
|
+
await sleep(PROGRESS_POLL_INTERVAL_MS);
|
|
57970
|
+
}
|
|
57971
|
+
}
|
|
57972
|
+
function pluginDetailPreview(detail, loading) {
|
|
57973
|
+
if (loading)
|
|
57974
|
+
return t("panel.plugins.detail.loading");
|
|
57975
|
+
if (detail === undefined)
|
|
57976
|
+
return t("panel.plugins.detail.unavailable");
|
|
57977
|
+
if (detail.status === "none")
|
|
57978
|
+
return t("panel.plugins.detail.none");
|
|
57979
|
+
const lines = detail.markdown.split(`
|
|
57980
|
+
`).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#"));
|
|
57981
|
+
const preview = lines.slice(0, 2).join(" ").slice(0, 180);
|
|
57982
|
+
return preview === "" ? t("panel.plugins.detail.none") : preview;
|
|
57983
|
+
}
|
|
57984
|
+
function createDegradedMemo(available, refreshTick) {
|
|
57985
|
+
return createMemo(() => {
|
|
57986
|
+
refreshTick();
|
|
57987
|
+
return available() === false;
|
|
57988
|
+
});
|
|
57989
|
+
}
|
|
57667
57990
|
function PluginsPanel(props) {
|
|
57668
57991
|
const theme = useThemeOptional();
|
|
57669
57992
|
const dialog = useDialog();
|
|
@@ -57676,8 +57999,18 @@ function PluginsPanel(props) {
|
|
|
57676
57999
|
const [status, setStatus] = createSignal(undefined);
|
|
57677
58000
|
const [installOpen, setInstallOpen] = createSignal(false);
|
|
57678
58001
|
const [installText, setInstallText] = createSignal("");
|
|
58002
|
+
const [detail, setDetail] = createSignal(undefined);
|
|
58003
|
+
const [detailLoading, setDetailLoading] = createSignal(false);
|
|
58004
|
+
const [refreshTick, setRefreshTick] = createSignal(0);
|
|
58005
|
+
const [installProgress, setInstallProgress] = createSignal(undefined);
|
|
58006
|
+
const [cancelArmed, setCancelArmed] = createSignal(false);
|
|
57679
58007
|
let statusTimer;
|
|
57680
|
-
|
|
58008
|
+
let progressTimer;
|
|
58009
|
+
onCleanup(() => {
|
|
58010
|
+
clearTimeout(statusTimer);
|
|
58011
|
+
if (progressTimer !== undefined)
|
|
58012
|
+
clearInterval(progressTimer);
|
|
58013
|
+
});
|
|
57681
58014
|
createEffect(() => {
|
|
57682
58015
|
if (bridgeOpen3()) {
|
|
57683
58016
|
setBridgeOpen3(false);
|
|
@@ -57686,7 +58019,12 @@ function PluginsPanel(props) {
|
|
|
57686
58019
|
setInstallOpen(false);
|
|
57687
58020
|
setInstallText("");
|
|
57688
58021
|
setCursor(0);
|
|
58022
|
+
setDetail(undefined);
|
|
57689
58023
|
setOpen(true);
|
|
58024
|
+
const seam = props.seam;
|
|
58025
|
+
if (typeof seam.refreshPluginBundles === "function") {
|
|
58026
|
+
seam.refreshPluginBundles().then(() => setRefreshTick((n) => n + 1)).catch(() => setRefreshTick((n) => n + 1));
|
|
58027
|
+
}
|
|
57690
58028
|
}
|
|
57691
58029
|
});
|
|
57692
58030
|
function flash(message, autoClearMs) {
|
|
@@ -57712,6 +58050,7 @@ function PluginsPanel(props) {
|
|
|
57712
58050
|
}
|
|
57713
58051
|
const bundles = createMemo(() => {
|
|
57714
58052
|
open();
|
|
58053
|
+
refreshTick();
|
|
57715
58054
|
try {
|
|
57716
58055
|
const seam = props.seam;
|
|
57717
58056
|
if (typeof seam.pluginBundles === "function")
|
|
@@ -57729,6 +58068,32 @@ function PluginsPanel(props) {
|
|
|
57729
58068
|
return rows[Math.min(cursor(), rows.length - 1)];
|
|
57730
58069
|
});
|
|
57731
58070
|
const cursorIndex = createMemo(() => visible().slice(0, 12).indexOf(current()));
|
|
58071
|
+
createEffect(() => {
|
|
58072
|
+
const row = current();
|
|
58073
|
+
const manager = props.seam.pluginsManager;
|
|
58074
|
+
if (row === undefined || typeof manager?.readBundleDetail !== "function" || manager.available?.() !== true) {
|
|
58075
|
+
setDetail(undefined);
|
|
58076
|
+
setDetailLoading(false);
|
|
58077
|
+
return;
|
|
58078
|
+
}
|
|
58079
|
+
const name = row.name;
|
|
58080
|
+
let stale = false;
|
|
58081
|
+
onCleanup(() => {
|
|
58082
|
+
stale = true;
|
|
58083
|
+
});
|
|
58084
|
+
setDetailLoading(true);
|
|
58085
|
+
manager.readBundleDetail(name, "en").then((d) => {
|
|
58086
|
+
if (!stale)
|
|
58087
|
+
setDetail(d);
|
|
58088
|
+
}).catch(() => {
|
|
58089
|
+
if (!stale)
|
|
58090
|
+
setDetail(undefined);
|
|
58091
|
+
}).finally(() => {
|
|
58092
|
+
if (!stale)
|
|
58093
|
+
setDetailLoading(false);
|
|
58094
|
+
});
|
|
58095
|
+
});
|
|
58096
|
+
const degraded = createDegradedMemo(() => props.seam.pluginsManager?.available?.(), refreshTick);
|
|
57732
58097
|
function moveCursor(delta) {
|
|
57733
58098
|
const count = visible().length;
|
|
57734
58099
|
if (count === 0)
|
|
@@ -57736,12 +58101,16 @@ function PluginsPanel(props) {
|
|
|
57736
58101
|
const next = Math.max(0, Math.min(cursor() + delta, count - 1));
|
|
57737
58102
|
setCursor(next);
|
|
57738
58103
|
}
|
|
57739
|
-
|
|
57740
|
-
if (row === undefined)
|
|
58104
|
+
function toggle(row) {
|
|
58105
|
+
if (row === undefined || busy())
|
|
57741
58106
|
return;
|
|
57742
|
-
if (
|
|
58107
|
+
if (typeof props.seam.setPluginBundleEnabled !== "function") {
|
|
58108
|
+
flash(t("panel.plugins.status.toggleUnavailable", {
|
|
58109
|
+
name: row.name
|
|
58110
|
+
}), 4000);
|
|
57743
58111
|
return;
|
|
57744
|
-
|
|
58112
|
+
}
|
|
58113
|
+
if (!row.toggleable) {
|
|
57745
58114
|
flash(row.readOnlyReason ? t("panel.plugins.status.readOnlyReason", {
|
|
57746
58115
|
name: row.name,
|
|
57747
58116
|
reason: row.readOnlyReason
|
|
@@ -57750,18 +58119,45 @@ function PluginsPanel(props) {
|
|
|
57750
58119
|
}), 4000);
|
|
57751
58120
|
return;
|
|
57752
58121
|
}
|
|
58122
|
+
const name = row.name;
|
|
58123
|
+
const enabled = !row.enabled;
|
|
58124
|
+
const operation = "setBundleEnabled";
|
|
58125
|
+
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
58126
|
+
get title() {
|
|
58127
|
+
return t("panel.plugins.dialog.actionTitle", {
|
|
58128
|
+
operation: t(`panel.plugins.confirm.op.${operation}`)
|
|
58129
|
+
});
|
|
58130
|
+
},
|
|
58131
|
+
get message() {
|
|
58132
|
+
return `${writeConfirmObject(operation, name)}
|
|
58133
|
+
${writeConfirmConsequence(operation)}`;
|
|
58134
|
+
},
|
|
58135
|
+
get label() {
|
|
58136
|
+
return {
|
|
58137
|
+
confirm: t("panel.plugins.dialog.actionConfirm"),
|
|
58138
|
+
cancel: t("panel.plugins.dialog.cancel")
|
|
58139
|
+
};
|
|
58140
|
+
},
|
|
58141
|
+
onConfirm: () => void toggleApply(name, enabled, operation)
|
|
58142
|
+
}), undefined, {
|
|
58143
|
+
tone: "warning"
|
|
58144
|
+
});
|
|
58145
|
+
}
|
|
58146
|
+
async function toggleApply(name, enabled, operation) {
|
|
58147
|
+
if (busy())
|
|
58148
|
+
return;
|
|
58149
|
+
if (typeof props.seam.setPluginBundleEnabled !== "function")
|
|
58150
|
+
return;
|
|
57753
58151
|
setBusy(true);
|
|
57754
|
-
flash(
|
|
57755
|
-
name
|
|
57756
|
-
}) : t("panel.plugins.status.enabling", {
|
|
57757
|
-
name: row.name
|
|
58152
|
+
flash(t(enabled ? "panel.plugins.status.enabling" : "panel.plugins.status.disabling", {
|
|
58153
|
+
name
|
|
57758
58154
|
}));
|
|
57759
58155
|
try {
|
|
57760
|
-
const change = await props.seam.setPluginBundleEnabled(
|
|
58156
|
+
const change = await props.seam.setPluginBundleEnabled(name, enabled, createPluginWriteConfirm(operation));
|
|
57761
58157
|
flash(pluginChangeNotice(change), 6000);
|
|
57762
58158
|
} catch (error) {
|
|
57763
58159
|
flash(t("panel.plugins.status.changeFailed", {
|
|
57764
|
-
name
|
|
58160
|
+
name,
|
|
57765
58161
|
error: errorMessage2(error)
|
|
57766
58162
|
}), 8000);
|
|
57767
58163
|
} finally {
|
|
@@ -57778,6 +58174,11 @@ function PluginsPanel(props) {
|
|
|
57778
58174
|
return;
|
|
57779
58175
|
}
|
|
57780
58176
|
const name = row.name;
|
|
58177
|
+
const operation = "removeBundle";
|
|
58178
|
+
const dryRun = t("panel.plugins.dryRun.remove", {
|
|
58179
|
+
name,
|
|
58180
|
+
version: row.version || "?"
|
|
58181
|
+
});
|
|
57781
58182
|
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
57782
58183
|
get title() {
|
|
57783
58184
|
return t("panel.plugins.dialog.uninstallTitle", {
|
|
@@ -57785,9 +58186,9 @@ function PluginsPanel(props) {
|
|
|
57785
58186
|
});
|
|
57786
58187
|
},
|
|
57787
58188
|
get message() {
|
|
57788
|
-
return
|
|
57789
|
-
|
|
57790
|
-
|
|
58189
|
+
return `${writeConfirmObject(operation, name)}
|
|
58190
|
+
${writeConfirmConsequence(operation)}
|
|
58191
|
+
${dryRun}`;
|
|
57791
58192
|
},
|
|
57792
58193
|
get label() {
|
|
57793
58194
|
return {
|
|
@@ -57795,12 +58196,12 @@ function PluginsPanel(props) {
|
|
|
57795
58196
|
cancel: t("panel.plugins.dialog.keep")
|
|
57796
58197
|
};
|
|
57797
58198
|
},
|
|
57798
|
-
onConfirm: () => void remove(name)
|
|
58199
|
+
onConfirm: () => void remove(name, operation)
|
|
57799
58200
|
}), undefined, {
|
|
57800
58201
|
tone: "warning"
|
|
57801
58202
|
});
|
|
57802
58203
|
}
|
|
57803
|
-
async function remove(name) {
|
|
58204
|
+
async function remove(name, operation) {
|
|
57804
58205
|
if (busy())
|
|
57805
58206
|
return;
|
|
57806
58207
|
if (typeof props.seam.removePluginBundle !== "function")
|
|
@@ -57810,7 +58211,7 @@ function PluginsPanel(props) {
|
|
|
57810
58211
|
name
|
|
57811
58212
|
}));
|
|
57812
58213
|
try {
|
|
57813
|
-
const change = await props.seam.removePluginBundle(name);
|
|
58214
|
+
const change = await props.seam.removePluginBundle(name, createPluginWriteConfirm(operation));
|
|
57814
58215
|
flash(pluginChangeNotice(change), 8000);
|
|
57815
58216
|
} catch (error) {
|
|
57816
58217
|
flash(t("panel.plugins.status.changeFailed", {
|
|
@@ -57868,17 +58269,19 @@ function PluginsPanel(props) {
|
|
|
57868
58269
|
return;
|
|
57869
58270
|
}
|
|
57870
58271
|
const accepted = inspection;
|
|
58272
|
+
const operation = "installBundle";
|
|
58273
|
+
const dryRun = t("panel.plugins.dryRun.install", {
|
|
58274
|
+
spec: installPreviewLine(accepted)
|
|
58275
|
+
});
|
|
57871
58276
|
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
57872
58277
|
get title() {
|
|
57873
58278
|
return t("panel.plugins.dialog.installTitle");
|
|
57874
58279
|
},
|
|
57875
58280
|
get message() {
|
|
57876
|
-
return
|
|
57877
|
-
|
|
57878
|
-
|
|
57879
|
-
|
|
57880
|
-
preview: installPreviewLine(accepted)
|
|
57881
|
-
});
|
|
58281
|
+
return `${writeConfirmObject(operation, installPreviewLine(accepted))}
|
|
58282
|
+
` + `${writeConfirmConsequence(operation)}
|
|
58283
|
+
${dryRun}` + (accepted.description ? `
|
|
58284
|
+
${accepted.description}` : "");
|
|
57882
58285
|
},
|
|
57883
58286
|
get label() {
|
|
57884
58287
|
return {
|
|
@@ -57886,31 +58289,108 @@ function PluginsPanel(props) {
|
|
|
57886
58289
|
cancel: t("panel.plugins.dialog.cancel")
|
|
57887
58290
|
};
|
|
57888
58291
|
},
|
|
57889
|
-
onConfirm: () => void install(spec)
|
|
58292
|
+
onConfirm: () => void install(spec, operation)
|
|
57890
58293
|
}), undefined, {
|
|
57891
58294
|
tone: "warning"
|
|
57892
58295
|
});
|
|
57893
58296
|
}
|
|
57894
|
-
async function install(spec) {
|
|
58297
|
+
async function install(spec, operation) {
|
|
57895
58298
|
if (busy())
|
|
57896
58299
|
return;
|
|
57897
58300
|
if (typeof props.seam.installPluginSpec !== "function")
|
|
57898
58301
|
return;
|
|
58302
|
+
const requestId = `ui-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
57899
58303
|
setBusy(true);
|
|
58304
|
+
setInstallProgress({
|
|
58305
|
+
state: "running",
|
|
58306
|
+
requestId
|
|
58307
|
+
});
|
|
58308
|
+
setCancelArmed(true);
|
|
57900
58309
|
flash(t("panel.plugins.status.installing", {
|
|
57901
58310
|
spec
|
|
57902
58311
|
}));
|
|
58312
|
+
const confirm = createPluginWriteConfirm(operation);
|
|
58313
|
+
let terminalLanded = false;
|
|
58314
|
+
let pollStopped = false;
|
|
58315
|
+
const land = (progress) => {
|
|
58316
|
+
if (terminalLanded)
|
|
58317
|
+
return;
|
|
58318
|
+
setInstallProgress(progress);
|
|
58319
|
+
if (progress.state !== "running")
|
|
58320
|
+
terminalLanded = true;
|
|
58321
|
+
};
|
|
58322
|
+
const pollDone = typeof props.seam.waitForInstall === "function" ? pollInstallFace((rid, cf) => props.seam.waitForInstall(rid, cf), requestId, confirm, land, () => pollStopped) : Promise.resolve();
|
|
57903
58323
|
try {
|
|
57904
|
-
const change = await props.seam.installPluginSpec(spec);
|
|
58324
|
+
const change = await props.seam.installPluginSpec(spec, confirm, requestId);
|
|
58325
|
+
await Promise.race([pollDone, new Promise((resolve) => setTimeout(resolve, PROGRESS_SETTLE_GRACE_MS))]);
|
|
58326
|
+
pollStopped = true;
|
|
58327
|
+
land(terminalProgress(change, requestId));
|
|
57905
58328
|
flash(pluginChangeNotice(change), 8000);
|
|
57906
58329
|
} catch (error) {
|
|
58330
|
+
pollStopped = true;
|
|
58331
|
+
land({
|
|
58332
|
+
state: "failed",
|
|
58333
|
+
requestId,
|
|
58334
|
+
target: spec,
|
|
58335
|
+
error: errorMessage2(error)
|
|
58336
|
+
});
|
|
57907
58337
|
flash(t("panel.plugins.status.changeFailed", {
|
|
57908
58338
|
name: spec,
|
|
57909
58339
|
error: errorMessage2(error)
|
|
57910
58340
|
}), 8000);
|
|
57911
58341
|
} finally {
|
|
58342
|
+
pollStopped = true;
|
|
58343
|
+
setCancelArmed(false);
|
|
57912
58344
|
setBusy(false);
|
|
57913
|
-
|
|
58345
|
+
if (progressTimer !== undefined)
|
|
58346
|
+
clearInterval(progressTimer);
|
|
58347
|
+
progressTimer = setInterval(() => {
|
|
58348
|
+
setInstallProgress(undefined);
|
|
58349
|
+
if (progressTimer !== undefined)
|
|
58350
|
+
clearInterval(progressTimer);
|
|
58351
|
+
progressTimer = undefined;
|
|
58352
|
+
}, 6000);
|
|
58353
|
+
}
|
|
58354
|
+
}
|
|
58355
|
+
function terminalProgress(change, requestId) {
|
|
58356
|
+
if (change.application === "cancelled")
|
|
58357
|
+
return {
|
|
58358
|
+
state: "cancelled",
|
|
58359
|
+
requestId,
|
|
58360
|
+
target: change.target
|
|
58361
|
+
};
|
|
58362
|
+
if (change.application === "failed")
|
|
58363
|
+
return {
|
|
58364
|
+
state: "failed",
|
|
58365
|
+
requestId,
|
|
58366
|
+
target: change.target,
|
|
58367
|
+
error: change.error
|
|
58368
|
+
};
|
|
58369
|
+
return {
|
|
58370
|
+
state: "done",
|
|
58371
|
+
requestId,
|
|
58372
|
+
target: change.target
|
|
58373
|
+
};
|
|
58374
|
+
}
|
|
58375
|
+
function cancelActiveInstall() {
|
|
58376
|
+
const progress = installProgress();
|
|
58377
|
+
if (!cancelArmed() || progress === undefined || typeof props.seam.cancelInstall !== "function")
|
|
58378
|
+
return;
|
|
58379
|
+
const requestId = progress.requestId;
|
|
58380
|
+
props.seam.cancelInstall(requestId, createPluginWriteConfirm("cancelInstall")).then((result) => {
|
|
58381
|
+
flash(t("panel.plugins.progress.cancelResult", {
|
|
58382
|
+
status: result.status
|
|
58383
|
+
}), 6000);
|
|
58384
|
+
if (result.status === "cancelled")
|
|
58385
|
+
setInstallProgress({
|
|
58386
|
+
state: "cancelled",
|
|
58387
|
+
requestId,
|
|
58388
|
+
target: requestId
|
|
58389
|
+
});
|
|
58390
|
+
}).catch((error) => flash(t("panel.plugins.status.changeFailed", {
|
|
58391
|
+
name: requestId,
|
|
58392
|
+
error: errorMessage2(error)
|
|
58393
|
+
}), 8000));
|
|
57914
58394
|
}
|
|
57915
58395
|
Keymap2.createLayer(() => ({
|
|
57916
58396
|
mode: "global",
|
|
@@ -57968,6 +58448,12 @@ function PluginsPanel(props) {
|
|
|
57968
58448
|
group: "Plugins",
|
|
57969
58449
|
enabled: () => !filterOpen() && !installOpen(),
|
|
57970
58450
|
run: beginInstall
|
|
58451
|
+
}, {
|
|
58452
|
+
bind: "x",
|
|
58453
|
+
title: t("panel.plugins.keymap.cancelInstall"),
|
|
58454
|
+
group: "Plugins",
|
|
58455
|
+
enabled: () => !filterOpen() && !installOpen() && cancelArmed(),
|
|
58456
|
+
run: cancelActiveInstall
|
|
57971
58457
|
}, {
|
|
57972
58458
|
bind: "up,k",
|
|
57973
58459
|
title: t("panel.plugins.keymap.previous"),
|
|
@@ -57987,8 +58473,10 @@ function PluginsPanel(props) {
|
|
|
57987
58473
|
return open();
|
|
57988
58474
|
},
|
|
57989
58475
|
get children() {
|
|
57990
|
-
var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$4 = createElement("text");
|
|
58476
|
+
var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$4 = createElement("text"), _el$9 = createElement("box"), _el$0 = createElement("text"), _el$1 = createElement("box"), _el$10 = createElement("text");
|
|
57991
58477
|
insertNode(_el$, _el$2);
|
|
58478
|
+
insertNode(_el$, _el$9);
|
|
58479
|
+
insertNode(_el$, _el$1);
|
|
57992
58480
|
setProp(_el$, "flexShrink", 0);
|
|
57993
58481
|
setProp(_el$, "width", "100%");
|
|
57994
58482
|
setProp(_el$, "flexDirection", "column");
|
|
@@ -58007,37 +58495,52 @@ function PluginsPanel(props) {
|
|
|
58007
58495
|
visible: String(visible().length),
|
|
58008
58496
|
total: String(bundles().length)
|
|
58009
58497
|
}));
|
|
58498
|
+
insert(_el$, createComponent2(Show, {
|
|
58499
|
+
get when() {
|
|
58500
|
+
return degraded();
|
|
58501
|
+
},
|
|
58502
|
+
get children() {
|
|
58503
|
+
var _el$5 = createElement("box"), _el$6 = createElement("text");
|
|
58504
|
+
insertNode(_el$5, _el$6);
|
|
58505
|
+
setProp(_el$5, "height", 1);
|
|
58506
|
+
setProp(_el$5, "flexShrink", 0);
|
|
58507
|
+
setProp(_el$6, "wrapMode", "none");
|
|
58508
|
+
insert(_el$6, () => t("panel.plugins.degrade.unavailable"));
|
|
58509
|
+
effect((_$p) => setProp(_el$6, "fg", warningColor(theme ?? undefined), _$p));
|
|
58510
|
+
return _el$5;
|
|
58511
|
+
}
|
|
58512
|
+
}), _el$9);
|
|
58010
58513
|
insert(_el$, createComponent2(Show, {
|
|
58011
58514
|
get when() {
|
|
58012
58515
|
return !installOpen();
|
|
58013
58516
|
},
|
|
58014
58517
|
get fallback() {
|
|
58015
58518
|
return (() => {
|
|
58016
|
-
var _el$
|
|
58017
|
-
insertNode(_el$
|
|
58018
|
-
setProp(_el$
|
|
58019
|
-
setProp(_el$
|
|
58020
|
-
setProp(_el$
|
|
58519
|
+
var _el$15 = createElement("box"), _el$16 = createElement("input");
|
|
58520
|
+
insertNode(_el$15, _el$16);
|
|
58521
|
+
setProp(_el$15, "height", 1);
|
|
58522
|
+
setProp(_el$15, "flexShrink", 0);
|
|
58523
|
+
setProp(_el$15, "flexDirection", "row");
|
|
58021
58524
|
use((renderable) => {
|
|
58022
58525
|
setTimeout(() => {
|
|
58023
58526
|
if (!renderable.isDestroyed)
|
|
58024
58527
|
renderable.focus();
|
|
58025
58528
|
}, 1);
|
|
58026
|
-
}, _el$
|
|
58027
|
-
setProp(_el$
|
|
58028
|
-
setProp(_el$
|
|
58529
|
+
}, _el$16);
|
|
58530
|
+
setProp(_el$16, "flexGrow", 1);
|
|
58531
|
+
setProp(_el$16, "onInput", (value) => setInstallText(value));
|
|
58029
58532
|
effect((_p$) => {
|
|
58030
|
-
var _v$
|
|
58031
|
-
_v$
|
|
58032
|
-
_v$
|
|
58033
|
-
_v$
|
|
58533
|
+
var _v$11 = t("panel.plugins.placeholder.install"), _v$12 = theme?.text.muted ?? "#565f89", _v$13 = installText();
|
|
58534
|
+
_v$11 !== _p$.e && (_p$.e = setProp(_el$16, "placeholder", _v$11, _p$.e));
|
|
58535
|
+
_v$12 !== _p$.t && (_p$.t = setProp(_el$16, "placeholderColor", _v$12, _p$.t));
|
|
58536
|
+
_v$13 !== _p$.a && (_p$.a = setProp(_el$16, "value", _v$13, _p$.a));
|
|
58034
58537
|
return _p$;
|
|
58035
58538
|
}, {
|
|
58036
58539
|
e: undefined,
|
|
58037
58540
|
t: undefined,
|
|
58038
58541
|
a: undefined
|
|
58039
58542
|
});
|
|
58040
|
-
return _el$
|
|
58543
|
+
return _el$15;
|
|
58041
58544
|
})();
|
|
58042
58545
|
},
|
|
58043
58546
|
get children() {
|
|
@@ -58047,63 +58550,63 @@ function PluginsPanel(props) {
|
|
|
58047
58550
|
},
|
|
58048
58551
|
get fallback() {
|
|
58049
58552
|
return (() => {
|
|
58050
|
-
var _el$
|
|
58051
|
-
insertNode(_el$
|
|
58052
|
-
setProp(_el$
|
|
58053
|
-
setProp(_el$
|
|
58054
|
-
setProp(_el$
|
|
58055
|
-
insert(_el$
|
|
58056
|
-
effect((_$p) => setProp(_el$
|
|
58057
|
-
return _el$
|
|
58553
|
+
var _el$17 = createElement("box"), _el$18 = createElement("text");
|
|
58554
|
+
insertNode(_el$17, _el$18);
|
|
58555
|
+
setProp(_el$17, "height", 1);
|
|
58556
|
+
setProp(_el$17, "flexShrink", 0);
|
|
58557
|
+
setProp(_el$18, "wrapMode", "none");
|
|
58558
|
+
insert(_el$18, () => `${t("panel.plugins.header.bundleColumn").padEnd(36)}${t("panel.plugins.header.stateColumn")}`);
|
|
58559
|
+
effect((_$p) => setProp(_el$18, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
58560
|
+
return _el$17;
|
|
58058
58561
|
})();
|
|
58059
58562
|
},
|
|
58060
58563
|
get children() {
|
|
58061
|
-
var _el$
|
|
58062
|
-
insertNode(_el$
|
|
58063
|
-
setProp(_el$
|
|
58064
|
-
setProp(_el$
|
|
58065
|
-
setProp(_el$
|
|
58564
|
+
var _el$7 = createElement("box"), _el$8 = createElement("input");
|
|
58565
|
+
insertNode(_el$7, _el$8);
|
|
58566
|
+
setProp(_el$7, "height", 1);
|
|
58567
|
+
setProp(_el$7, "flexShrink", 0);
|
|
58568
|
+
setProp(_el$7, "flexDirection", "row");
|
|
58066
58569
|
use((renderable) => {
|
|
58067
58570
|
setTimeout(() => {
|
|
58068
58571
|
if (!renderable.isDestroyed)
|
|
58069
58572
|
renderable.focus();
|
|
58070
58573
|
}, 1);
|
|
58071
|
-
}, _el$
|
|
58072
|
-
setProp(_el$
|
|
58073
|
-
setProp(_el$
|
|
58574
|
+
}, _el$8);
|
|
58575
|
+
setProp(_el$8, "flexGrow", 1);
|
|
58576
|
+
setProp(_el$8, "onInput", (value) => setFilter(value));
|
|
58074
58577
|
effect((_p$) => {
|
|
58075
58578
|
var _v$ = t("panel.plugins.placeholder.filter"), _v$2 = theme?.text.muted ?? "#565f89", _v$3 = filter();
|
|
58076
|
-
_v$ !== _p$.e && (_p$.e = setProp(_el$
|
|
58077
|
-
_v$2 !== _p$.t && (_p$.t = setProp(_el$
|
|
58078
|
-
_v$3 !== _p$.a && (_p$.a = setProp(_el$
|
|
58579
|
+
_v$ !== _p$.e && (_p$.e = setProp(_el$8, "placeholder", _v$, _p$.e));
|
|
58580
|
+
_v$2 !== _p$.t && (_p$.t = setProp(_el$8, "placeholderColor", _v$2, _p$.t));
|
|
58581
|
+
_v$3 !== _p$.a && (_p$.a = setProp(_el$8, "value", _v$3, _p$.a));
|
|
58079
58582
|
return _p$;
|
|
58080
58583
|
}, {
|
|
58081
58584
|
e: undefined,
|
|
58082
58585
|
t: undefined,
|
|
58083
58586
|
a: undefined
|
|
58084
58587
|
});
|
|
58085
|
-
return _el$
|
|
58588
|
+
return _el$7;
|
|
58086
58589
|
}
|
|
58087
58590
|
});
|
|
58088
58591
|
}
|
|
58089
|
-
}),
|
|
58592
|
+
}), _el$9);
|
|
58090
58593
|
insert(_el$, createComponent2(Show, {
|
|
58091
58594
|
get when() {
|
|
58092
58595
|
return visible().length > 0;
|
|
58093
58596
|
},
|
|
58094
58597
|
get fallback() {
|
|
58095
58598
|
return (() => {
|
|
58096
|
-
var _el$
|
|
58097
|
-
insertNode(_el$
|
|
58098
|
-
setProp(_el$
|
|
58099
|
-
setProp(_el$
|
|
58100
|
-
setProp(_el$
|
|
58101
|
-
insert(_el$
|
|
58102
|
-
var _c$ = memo2(() => bundles().length === 0);
|
|
58103
|
-
return () => _c$() ? t("panel.plugins.empty.noPlugins") : t("panel.plugins.empty.noMatch");
|
|
58599
|
+
var _el$19 = createElement("box"), _el$20 = createElement("text");
|
|
58600
|
+
insertNode(_el$19, _el$20);
|
|
58601
|
+
setProp(_el$19, "height", 1);
|
|
58602
|
+
setProp(_el$19, "flexShrink", 0);
|
|
58603
|
+
setProp(_el$20, "wrapMode", "none");
|
|
58604
|
+
insert(_el$20, (() => {
|
|
58605
|
+
var _c$4 = memo2(() => bundles().length === 0);
|
|
58606
|
+
return () => _c$4() ? t("panel.plugins.empty.noPlugins") : t("panel.plugins.empty.noMatch");
|
|
58104
58607
|
})());
|
|
58105
|
-
effect((_$p) => setProp(_el$
|
|
58106
|
-
return _el$
|
|
58608
|
+
effect((_$p) => setProp(_el$20, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
58609
|
+
return _el$19;
|
|
58107
58610
|
})();
|
|
58108
58611
|
},
|
|
58109
58612
|
get children() {
|
|
@@ -58112,53 +58615,92 @@ function PluginsPanel(props) {
|
|
|
58112
58615
|
return visible().slice(0, 12);
|
|
58113
58616
|
},
|
|
58114
58617
|
children: (row, index) => (() => {
|
|
58115
|
-
var _el$
|
|
58116
|
-
insertNode(_el$
|
|
58117
|
-
insertNode(_el$
|
|
58118
|
-
setProp(_el$
|
|
58119
|
-
setProp(_el$
|
|
58120
|
-
setProp(_el$
|
|
58121
|
-
setProp(_el$
|
|
58122
|
-
insert(_el$
|
|
58123
|
-
setProp(_el$
|
|
58124
|
-
insert(_el$
|
|
58618
|
+
var _el$21 = createElement("box"), _el$22 = createElement("text"), _el$23 = createElement("text");
|
|
58619
|
+
insertNode(_el$21, _el$22);
|
|
58620
|
+
insertNode(_el$21, _el$23);
|
|
58621
|
+
setProp(_el$21, "height", 1);
|
|
58622
|
+
setProp(_el$21, "flexShrink", 0);
|
|
58623
|
+
setProp(_el$21, "flexDirection", "row");
|
|
58624
|
+
setProp(_el$22, "wrapMode", "none");
|
|
58625
|
+
insert(_el$22, () => `${index() === cursorIndex() ? "\u203A " : " "}${formatPluginLine(row).padEnd(34)}`);
|
|
58626
|
+
setProp(_el$23, "wrapMode", "none");
|
|
58627
|
+
insert(_el$23, () => bundleStateText(row));
|
|
58125
58628
|
effect((_p$) => {
|
|
58126
|
-
var _v$
|
|
58127
|
-
_v$
|
|
58128
|
-
_v$
|
|
58629
|
+
var _v$14 = index() === cursorIndex() ? theme?.text.base ?? "#e6e6e6" : theme?.text.muted ?? "#565f89", _v$15 = row.enabled ? successColor(theme ?? undefined) : theme?.text.muted ?? "#565f89";
|
|
58630
|
+
_v$14 !== _p$.e && (_p$.e = setProp(_el$22, "fg", _v$14, _p$.e));
|
|
58631
|
+
_v$15 !== _p$.t && (_p$.t = setProp(_el$23, "fg", _v$15, _p$.t));
|
|
58129
58632
|
return _p$;
|
|
58130
58633
|
}, {
|
|
58131
58634
|
e: undefined,
|
|
58132
58635
|
t: undefined
|
|
58133
58636
|
});
|
|
58134
|
-
return _el$
|
|
58637
|
+
return _el$21;
|
|
58135
58638
|
})()
|
|
58136
58639
|
});
|
|
58137
58640
|
}
|
|
58641
|
+
}), _el$9);
|
|
58642
|
+
insertNode(_el$9, _el$0);
|
|
58643
|
+
setProp(_el$9, "height", 1);
|
|
58644
|
+
setProp(_el$9, "flexShrink", 0);
|
|
58645
|
+
setProp(_el$0, "wrapMode", "none");
|
|
58646
|
+
insert(_el$0, (() => {
|
|
58647
|
+
var _c$ = memo2(() => detail() !== undefined);
|
|
58648
|
+
return () => _c$() ? t("panel.plugins.detail.title", {
|
|
58649
|
+
name: current()?.name ?? ""
|
|
58650
|
+
}) : "";
|
|
58651
|
+
})());
|
|
58652
|
+
insertNode(_el$1, _el$10);
|
|
58653
|
+
setProp(_el$1, "height", 1);
|
|
58654
|
+
setProp(_el$1, "flexShrink", 0);
|
|
58655
|
+
setProp(_el$10, "wrapMode", "none");
|
|
58656
|
+
insert(_el$10, (() => {
|
|
58657
|
+
var _c$2 = memo2(() => detail() !== undefined);
|
|
58658
|
+
return () => _c$2() ? pluginDetailPreview(detail(), detailLoading()) : "";
|
|
58659
|
+
})());
|
|
58660
|
+
insert(_el$, createComponent2(Show, {
|
|
58661
|
+
get when() {
|
|
58662
|
+
return installProgress() !== undefined;
|
|
58663
|
+
},
|
|
58664
|
+
get children() {
|
|
58665
|
+
var _el$11 = createElement("box"), _el$12 = createElement("text");
|
|
58666
|
+
insertNode(_el$11, _el$12);
|
|
58667
|
+
setProp(_el$11, "height", 1);
|
|
58668
|
+
setProp(_el$11, "flexShrink", 0);
|
|
58669
|
+
setProp(_el$12, "wrapMode", "none");
|
|
58670
|
+
insert(_el$12, (() => {
|
|
58671
|
+
var _c$3 = memo2(() => installProgress() !== undefined);
|
|
58672
|
+
return () => _c$3() ? installProgressLine(installProgress()) : "";
|
|
58673
|
+
})());
|
|
58674
|
+
effect((_$p) => setProp(_el$12, "fg", warningColor(theme ?? undefined), _$p));
|
|
58675
|
+
return _el$11;
|
|
58676
|
+
}
|
|
58138
58677
|
}), null);
|
|
58139
58678
|
insert(_el$, createComponent2(Show, {
|
|
58140
58679
|
get when() {
|
|
58141
58680
|
return status() !== undefined;
|
|
58142
58681
|
},
|
|
58143
58682
|
get children() {
|
|
58144
|
-
var _el$
|
|
58145
|
-
insertNode(_el$
|
|
58146
|
-
setProp(_el$
|
|
58147
|
-
setProp(_el$
|
|
58148
|
-
setProp(_el$
|
|
58149
|
-
insert(_el$
|
|
58150
|
-
effect((_$p) => setProp(_el$
|
|
58151
|
-
return _el$
|
|
58683
|
+
var _el$13 = createElement("box"), _el$14 = createElement("text");
|
|
58684
|
+
insertNode(_el$13, _el$14);
|
|
58685
|
+
setProp(_el$13, "height", 1);
|
|
58686
|
+
setProp(_el$13, "flexShrink", 0);
|
|
58687
|
+
setProp(_el$14, "wrapMode", "none");
|
|
58688
|
+
insert(_el$14, status);
|
|
58689
|
+
effect((_$p) => setProp(_el$14, "fg", warningColor(theme ?? undefined), _$p));
|
|
58690
|
+
return _el$13;
|
|
58152
58691
|
}
|
|
58153
58692
|
}), null);
|
|
58154
58693
|
effect((_p$) => {
|
|
58155
|
-
var _v$4 = 1 + 1 + Math.min(visible().length || 1, 12) + (status() !== undefined ? 1 : 0) + 1, _v$5 = theme?.border.base ?? "#7aa2f7", _v$6 = theme?.background.raised.base ?? "#1a1b26", _v$7 = theme?.text.base ?? "#e6e6e6", _v$8 = TextAttributes10.BOLD, _v$9 = theme?.text.muted ?? "#565f89";
|
|
58694
|
+
var _v$4 = 1 + 1 + (degraded() ? 1 : 0) + Math.min(visible().length || 1, 12) + 2 + (installProgress() !== undefined ? 1 : 0) + (status() !== undefined ? 1 : 0) + 1, _v$5 = theme?.border.base ?? "#7aa2f7", _v$6 = theme?.background.raised.base ?? "#1a1b26", _v$7 = theme?.text.base ?? "#e6e6e6", _v$8 = TextAttributes10.BOLD, _v$9 = theme?.text.muted ?? "#565f89", _v$0 = theme?.text.base ?? "#e6e6e6", _v$1 = TextAttributes10.BOLD, _v$10 = theme?.text.muted ?? "#565f89";
|
|
58156
58695
|
_v$4 !== _p$.e && (_p$.e = setProp(_el$, "height", _v$4, _p$.e));
|
|
58157
58696
|
_v$5 !== _p$.t && (_p$.t = setProp(_el$, "borderColor", _v$5, _p$.t));
|
|
58158
58697
|
_v$6 !== _p$.a && (_p$.a = setProp(_el$, "backgroundColor", _v$6, _p$.a));
|
|
58159
58698
|
_v$7 !== _p$.o && (_p$.o = setProp(_el$3, "fg", _v$7, _p$.o));
|
|
58160
58699
|
_v$8 !== _p$.i && (_p$.i = setProp(_el$3, "attributes", _v$8, _p$.i));
|
|
58161
58700
|
_v$9 !== _p$.n && (_p$.n = setProp(_el$4, "fg", _v$9, _p$.n));
|
|
58701
|
+
_v$0 !== _p$.s && (_p$.s = setProp(_el$0, "fg", _v$0, _p$.s));
|
|
58702
|
+
_v$1 !== _p$.h && (_p$.h = setProp(_el$0, "attributes", _v$1, _p$.h));
|
|
58703
|
+
_v$10 !== _p$.r && (_p$.r = setProp(_el$10, "fg", _v$10, _p$.r));
|
|
58162
58704
|
return _p$;
|
|
58163
58705
|
}, {
|
|
58164
58706
|
e: undefined,
|
|
@@ -58166,13 +58708,16 @@ function PluginsPanel(props) {
|
|
|
58166
58708
|
a: undefined,
|
|
58167
58709
|
o: undefined,
|
|
58168
58710
|
i: undefined,
|
|
58169
|
-
n: undefined
|
|
58711
|
+
n: undefined,
|
|
58712
|
+
s: undefined,
|
|
58713
|
+
h: undefined,
|
|
58714
|
+
r: undefined
|
|
58170
58715
|
});
|
|
58171
58716
|
return _el$;
|
|
58172
58717
|
}
|
|
58173
58718
|
});
|
|
58174
58719
|
}
|
|
58175
|
-
var bridgeOpen3, setBridgeOpen3, panelOpen4, setPanelOpen4, pluginsPanelOpen;
|
|
58720
|
+
var bridgeOpen3, setBridgeOpen3, panelOpen4, setPanelOpen4, pluginsPanelOpen, PROGRESS_POLL_INTERVAL_MS = 250, PROGRESS_POLL_MAX_TICKS = 120, PROGRESS_SETTLE_GRACE_MS = 80;
|
|
58176
58721
|
var init_plugins_panel = __esm(() => {
|
|
58177
58722
|
init_index_bun();
|
|
58178
58723
|
init_index_bun();
|
|
@@ -64129,7 +64674,7 @@ var init_subagents_viewer = __esm(() => {
|
|
|
64129
64674
|
import { TextAttributes as TextAttributes12 } from "@opentui/core";
|
|
64130
64675
|
function resolveVersion() {
|
|
64131
64676
|
try {
|
|
64132
|
-
return "0.
|
|
64677
|
+
return "0.25.0";
|
|
64133
64678
|
} catch {
|
|
64134
64679
|
return "dev";
|
|
64135
64680
|
}
|
|
@@ -65491,6 +66036,18 @@ var init_settings_modal = __esm(() => {
|
|
|
65491
66036
|
});
|
|
65492
66037
|
|
|
65493
66038
|
// ../tui-base/src/routes/session/btw-overlay.tsx
|
|
66039
|
+
function btwDegradeText(code) {
|
|
66040
|
+
if (code === "UNSUPPORTED" || code === "SIDE_SESSION_UNAVAILABLE")
|
|
66041
|
+
return `error: ${t("command.btw.noModel")}`;
|
|
66042
|
+
if (code === "SIDE_SESSION_NO_ANSWER")
|
|
66043
|
+
return `error: ${t("command.btw.noAnswer")}`;
|
|
66044
|
+
if (code === "SIDE_SESSION_BUSY")
|
|
66045
|
+
return `error: ${t("command.btw.busy")}`;
|
|
66046
|
+
if (code === "SIDE_SESSION_FAILED" || code === "SIDE_SESSION_PROMPT_REJECTED")
|
|
66047
|
+
return `error: ${t("command.btw.failed")}`;
|
|
66048
|
+
return;
|
|
66049
|
+
}
|
|
66050
|
+
|
|
65494
66051
|
class BtwController {
|
|
65495
66052
|
#ask;
|
|
65496
66053
|
#snapshot;
|
|
@@ -65557,7 +66114,9 @@ class BtwController {
|
|
|
65557
66114
|
})).then((answer) => {
|
|
65558
66115
|
this.#settle(answer.startsWith("error:") ? "error" : "settled", answer);
|
|
65559
66116
|
}).catch((error) => {
|
|
65560
|
-
|
|
66117
|
+
const code = error !== null && typeof error === "object" ? error.code : undefined;
|
|
66118
|
+
const degrade = btwDegradeText(code);
|
|
66119
|
+
this.#settle("error", degrade ?? `error: ${error instanceof Error ? error.message : String(error)}`);
|
|
65561
66120
|
});
|
|
65562
66121
|
}
|
|
65563
66122
|
#settle(status, answer) {
|
|
@@ -66029,10 +66588,135 @@ var init_journal_projection = __esm(() => {
|
|
|
66029
66588
|
NOTICE_SOURCE_KINDS = new Set(["subagent-settled", "agent-message", "team-message", "webhook"]);
|
|
66030
66589
|
});
|
|
66031
66590
|
|
|
66591
|
+
// src/client/bridge-side-session.ts
|
|
66592
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
66593
|
+
function classify(err, stage) {
|
|
66594
|
+
const raw = err instanceof Error ? err.message : String(err);
|
|
66595
|
+
if (/NOT_WIRED|UNSUPPORTED|unavailable|no inproc host adapter/i.test(raw)) {
|
|
66596
|
+
return new SideSessionError("SIDE_SESSION_UNAVAILABLE", `/btw side-session ${stage} unavailable: ${raw.slice(0, 160)}`);
|
|
66597
|
+
}
|
|
66598
|
+
return new SideSessionError("SIDE_SESSION_FAILED", `/btw side-session ${stage} failed: ${raw.slice(0, 160)}`);
|
|
66599
|
+
}
|
|
66600
|
+
function projectWaitAnswer(value, maxLength = 4000) {
|
|
66601
|
+
const v = asRecord5(value);
|
|
66602
|
+
const output = asRecord5(v.output);
|
|
66603
|
+
const records = Array.isArray(output.records) ? output.records : [];
|
|
66604
|
+
const texts = [];
|
|
66605
|
+
for (const raw of [...records].reverse()) {
|
|
66606
|
+
const rec = asRecord5(raw);
|
|
66607
|
+
const event = asRecord5(rec.event);
|
|
66608
|
+
if (event.type !== "assistant/message")
|
|
66609
|
+
continue;
|
|
66610
|
+
const data = asRecord5(event.data);
|
|
66611
|
+
const message = asRecord5(data.message);
|
|
66612
|
+
const content = Array.isArray(message.content) ? message.content : Array.isArray(data.content) ? data.content : Array.isArray(data.parts) ? data.parts : [];
|
|
66613
|
+
const parts = [];
|
|
66614
|
+
for (const block of content) {
|
|
66615
|
+
const b = asRecord5(block);
|
|
66616
|
+
if (b.type === "text" && typeof b.text === "string")
|
|
66617
|
+
parts.push(b.text);
|
|
66618
|
+
}
|
|
66619
|
+
let text = parts.join(`
|
|
66620
|
+
`).trim();
|
|
66621
|
+
if (text === "") {
|
|
66622
|
+
const flat = typeof message.text === "string" ? message.text : typeof data.text === "string" ? data.text : "";
|
|
66623
|
+
text = flat.trim();
|
|
66624
|
+
}
|
|
66625
|
+
if (text)
|
|
66626
|
+
texts.push(text);
|
|
66627
|
+
}
|
|
66628
|
+
let answer = texts.join(`
|
|
66629
|
+
|
|
66630
|
+
`);
|
|
66631
|
+
let truncated = output.truncated === true;
|
|
66632
|
+
if (answer.length > maxLength) {
|
|
66633
|
+
answer = answer.slice(0, maxLength);
|
|
66634
|
+
truncated = true;
|
|
66635
|
+
}
|
|
66636
|
+
return { answer, truncated };
|
|
66637
|
+
}
|
|
66638
|
+
async function runSideSession(options) {
|
|
66639
|
+
const timeoutMs = options.timeoutMs ?? 120000;
|
|
66640
|
+
const rpc = options.rpc;
|
|
66641
|
+
let created;
|
|
66642
|
+
try {
|
|
66643
|
+
created = asRecord5(await rpc("session.create", {
|
|
66644
|
+
request: options.sessionId !== undefined ? { sessionId: options.sessionId } : {}
|
|
66645
|
+
}));
|
|
66646
|
+
} catch (err) {
|
|
66647
|
+
throw classify(err, "create");
|
|
66648
|
+
}
|
|
66649
|
+
const sessionId = typeof created.sessionId === "string" ? created.sessionId : "";
|
|
66650
|
+
if (sessionId === "") {
|
|
66651
|
+
throw new SideSessionError("SIDE_SESSION_UNAVAILABLE", "/btw side-session create returned no sessionId");
|
|
66652
|
+
}
|
|
66653
|
+
const requestId = options.requestId?.() ?? randomUUID8();
|
|
66654
|
+
const snap = options.snapshot && options.snapshot.length > 0 ? `Recent conversation context (for reference only):
|
|
66655
|
+
${options.snapshot.join(`
|
|
66656
|
+
`).slice(-1500)}
|
|
66657
|
+
|
|
66658
|
+
` : "";
|
|
66659
|
+
try {
|
|
66660
|
+
const accepted = asRecord5(await rpc("session.prompt", {
|
|
66661
|
+
request: {
|
|
66662
|
+
requestId,
|
|
66663
|
+
sessionId,
|
|
66664
|
+
mode: "queue",
|
|
66665
|
+
content: [{ type: "text", text: `${snap}Side question (answer in one or two sentences, do not use tools): ${options.question}` }]
|
|
66666
|
+
}
|
|
66667
|
+
}));
|
|
66668
|
+
if (accepted.accepted !== true) {
|
|
66669
|
+
throw new SideSessionError("SIDE_SESSION_PROMPT_REJECTED", "/btw side-session prompt was not accepted");
|
|
66670
|
+
}
|
|
66671
|
+
} catch (err) {
|
|
66672
|
+
if (err instanceof SideSessionError)
|
|
66673
|
+
throw err;
|
|
66674
|
+
throw classify(err, "prompt");
|
|
66675
|
+
}
|
|
66676
|
+
let waited;
|
|
66677
|
+
try {
|
|
66678
|
+
waited = asRecord5(await rpc("session.wait", {
|
|
66679
|
+
request: {
|
|
66680
|
+
sessionId,
|
|
66681
|
+
timeoutMs,
|
|
66682
|
+
...options.maxMessages !== undefined ? { maxMessages: options.maxMessages } : {}
|
|
66683
|
+
}
|
|
66684
|
+
}));
|
|
66685
|
+
} catch (err) {
|
|
66686
|
+
throw classify(err, "wait");
|
|
66687
|
+
}
|
|
66688
|
+
const { answer, truncated } = projectWaitAnswer(waited, options.maxAnswerLength);
|
|
66689
|
+
const reason = typeof waited.reason === "string" ? waited.reason : "idle";
|
|
66690
|
+
if (process.env.DSH_OPENTUI_DEBUG) {
|
|
66691
|
+
const out = asRecord5(waited.output);
|
|
66692
|
+
const recs = Array.isArray(out.records) ? out.records : [];
|
|
66693
|
+
const types = recs.map((r) => String(asRecord5(asRecord5(r).event).type ?? "?")).join(",");
|
|
66694
|
+
process.stderr.write(`[btw-side] wait reason=${reason} records=${recs.length} types=[${types}] truncated=${String(out.truncated)} answerLen=${answer.length}
|
|
66695
|
+
`);
|
|
66696
|
+
}
|
|
66697
|
+
if (answer !== "" && options.onDelta !== undefined) {
|
|
66698
|
+
try {
|
|
66699
|
+
options.onDelta(answer);
|
|
66700
|
+
} catch {}
|
|
66701
|
+
}
|
|
66702
|
+
return { answer, sessionId, reason, truncated };
|
|
66703
|
+
}
|
|
66704
|
+
var SideSessionError, asRecord5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
66705
|
+
var init_bridge_side_session = __esm(() => {
|
|
66706
|
+
SideSessionError = class SideSessionError extends Error {
|
|
66707
|
+
code;
|
|
66708
|
+
constructor(code, message) {
|
|
66709
|
+
super(message);
|
|
66710
|
+
this.code = code;
|
|
66711
|
+
this.name = "SideSessionError";
|
|
66712
|
+
}
|
|
66713
|
+
};
|
|
66714
|
+
});
|
|
66715
|
+
|
|
66032
66716
|
// src/client/local-config-faces.ts
|
|
66033
|
-
import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync13, renameSync as renameSync9, rmSync as rmSync5, writeFileSync as writeFileSync9 } from "fs";
|
|
66717
|
+
import { chmodSync as chmodSync4, existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync13, renameSync as renameSync9, rmSync as rmSync5, writeFileSync as writeFileSync9 } from "fs";
|
|
66034
66718
|
import { dirname as dirname7, join as join15 } from "path";
|
|
66035
|
-
function
|
|
66719
|
+
function asRecord6(value) {
|
|
66036
66720
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
66037
66721
|
}
|
|
66038
66722
|
function parseScalar(raw) {
|
|
@@ -66133,6 +66817,48 @@ function atomicWrite2(path, text) {
|
|
|
66133
66817
|
throw err;
|
|
66134
66818
|
}
|
|
66135
66819
|
}
|
|
66820
|
+
function buildLoginRouteBlock(providerId, profile) {
|
|
66821
|
+
const block = [` ${providerId}:`];
|
|
66822
|
+
const apiKeyEnv = typeof profile.apiKeyEnv === "string" ? profile.apiKeyEnv : "";
|
|
66823
|
+
if (apiKeyEnv !== "") {
|
|
66824
|
+
if (!/^[A-Za-z0-9_]+$/.test(apiKeyEnv))
|
|
66825
|
+
return;
|
|
66826
|
+
block.push(` apiKeyEnv: ${apiKeyEnv}`);
|
|
66827
|
+
}
|
|
66828
|
+
if (profile.api !== undefined) {
|
|
66829
|
+
if (typeof profile.api !== "string" || !/^[A-Za-z0-9_.-]+$/.test(profile.api))
|
|
66830
|
+
return;
|
|
66831
|
+
block.push(` api: ${profile.api}`);
|
|
66832
|
+
}
|
|
66833
|
+
if (profile.baseURL !== undefined) {
|
|
66834
|
+
if (typeof profile.baseURL !== "string" || !/^https?:\/\/\S+$/.test(profile.baseURL))
|
|
66835
|
+
return;
|
|
66836
|
+
block.push(` baseURL: ${JSON.stringify(profile.baseURL)}`);
|
|
66837
|
+
}
|
|
66838
|
+
if (profile.displayName !== undefined) {
|
|
66839
|
+
if (typeof profile.displayName !== "string" || /[\r\n]/.test(profile.displayName))
|
|
66840
|
+
return;
|
|
66841
|
+
block.push(` displayName: ${JSON.stringify(profile.displayName)}`);
|
|
66842
|
+
}
|
|
66843
|
+
if (profile.models !== undefined) {
|
|
66844
|
+
if (!Array.isArray(profile.models))
|
|
66845
|
+
return;
|
|
66846
|
+
block.push(" models:");
|
|
66847
|
+
for (const entry of profile.models) {
|
|
66848
|
+
const m = asRecord6(entry);
|
|
66849
|
+
const id = m.id;
|
|
66850
|
+
if (typeof id !== "string" || !id || /[\r\n\x00-\x1f]/.test(id))
|
|
66851
|
+
return;
|
|
66852
|
+
block.push(` - id: ${JSON.stringify(id)}`);
|
|
66853
|
+
if (m.name !== undefined) {
|
|
66854
|
+
if (typeof m.name !== "string" || /[\r\n\x00-\x1f]/.test(m.name))
|
|
66855
|
+
return;
|
|
66856
|
+
block.push(` name: ${JSON.stringify(m.name)}`);
|
|
66857
|
+
}
|
|
66858
|
+
}
|
|
66859
|
+
}
|
|
66860
|
+
return block;
|
|
66861
|
+
}
|
|
66136
66862
|
|
|
66137
66863
|
class LocalSettingsStore {
|
|
66138
66864
|
#patchPath;
|
|
@@ -66233,7 +66959,7 @@ class LocalConfigStore {
|
|
|
66233
66959
|
}
|
|
66234
66960
|
#readProfile() {
|
|
66235
66961
|
try {
|
|
66236
|
-
return
|
|
66962
|
+
return asRecord6(JSON.parse(readFileSync13(this.#configPath, "utf8")));
|
|
66237
66963
|
} catch {
|
|
66238
66964
|
return {};
|
|
66239
66965
|
}
|
|
@@ -66277,7 +67003,7 @@ class LocalConfigStore {
|
|
|
66277
67003
|
function loadWorkspaceConfigState(workspaceDir) {
|
|
66278
67004
|
try {
|
|
66279
67005
|
const raw = JSON.parse(readFileSync13(join15(workspaceDir, ".dsh", "config.yml"), "utf8"));
|
|
66280
|
-
return
|
|
67006
|
+
return asRecord6(raw);
|
|
66281
67007
|
} catch {
|
|
66282
67008
|
try {
|
|
66283
67009
|
const text = readFileSync13(join15(workspaceDir, ".dsh", "config.yml"), "utf8");
|
|
@@ -66346,7 +67072,7 @@ class LocalAgentsFace {
|
|
|
66346
67072
|
async officialCaps() {
|
|
66347
67073
|
const doc = this.#settings.describe();
|
|
66348
67074
|
const row = doc.namespaces.find((n) => n.ns === "subagent");
|
|
66349
|
-
const value =
|
|
67075
|
+
const value = asRecord6(row?.value);
|
|
66350
67076
|
const caps = {};
|
|
66351
67077
|
if (typeof value.maxActiveSubagents === "number" && Number.isFinite(value.maxActiveSubagents))
|
|
66352
67078
|
caps.maxActiveSubagents = value.maxActiveSubagents;
|
|
@@ -66355,6 +67081,251 @@ class LocalAgentsFace {
|
|
|
66355
67081
|
return caps;
|
|
66356
67082
|
}
|
|
66357
67083
|
}
|
|
67084
|
+
|
|
67085
|
+
class LocalPresetFace {
|
|
67086
|
+
#patchPath;
|
|
67087
|
+
#configPath;
|
|
67088
|
+
constructor(home, profile) {
|
|
67089
|
+
this.#patchPath = join15(home, "profiles", profile, "cordis.patch.yml");
|
|
67090
|
+
this.#configPath = join15(home, "profiles", profile, "config.json");
|
|
67091
|
+
}
|
|
67092
|
+
list() {
|
|
67093
|
+
let lines = [];
|
|
67094
|
+
try {
|
|
67095
|
+
lines = readFileSync13(this.#patchPath, "utf8").split(`
|
|
67096
|
+
`);
|
|
67097
|
+
} catch {
|
|
67098
|
+
return [];
|
|
67099
|
+
}
|
|
67100
|
+
const rows = [];
|
|
67101
|
+
const seen = new Set;
|
|
67102
|
+
for (let i = 0;i < lines.length; i++) {
|
|
67103
|
+
if (!/^\s*- id:\s*preset-\S+\s*$/.test(lines[i]))
|
|
67104
|
+
continue;
|
|
67105
|
+
let end = lines.length;
|
|
67106
|
+
for (let j = i + 1;j < lines.length; j++) {
|
|
67107
|
+
if (/^\s*- id:\s*\S+/.test(lines[j]) || /^- /.test(lines[j])) {
|
|
67108
|
+
end = j;
|
|
67109
|
+
break;
|
|
67110
|
+
}
|
|
67111
|
+
}
|
|
67112
|
+
const span = lines.slice(i, end);
|
|
67113
|
+
if (!span.some((l) => /name:\s*['"]?@deepseek-ai\/dsh-agent-preset/.test(l)))
|
|
67114
|
+
continue;
|
|
67115
|
+
const cfg = span.findIndex((l) => /^\s{4,}config:\s*$/.test(l));
|
|
67116
|
+
const val = {};
|
|
67117
|
+
if (cfg >= 0) {
|
|
67118
|
+
for (let k = cfg + 1;k < span.length; k++) {
|
|
67119
|
+
const m = /^\s{6,}([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/.exec(span[k]);
|
|
67120
|
+
if (!m)
|
|
67121
|
+
continue;
|
|
67122
|
+
if (/^\s{6,}(plugins|disabled|order):/.test(span[k]) && m[1] !== "order") {
|
|
67123
|
+
if (m[1] === "plugins")
|
|
67124
|
+
break;
|
|
67125
|
+
}
|
|
67126
|
+
const key = m[1];
|
|
67127
|
+
if (key === "id" || key === "name" || key === "description") {
|
|
67128
|
+
let v = m[2].trim().replace(/^['"]|['"]$/g, "");
|
|
67129
|
+
let kk = k + 1;
|
|
67130
|
+
while (kk < span.length && /^\s{10,}\S/.test(span[kk]) && !/^\s{10,}[A-Za-z_][A-Za-z0-9_]*\s*:/.test(span[kk])) {
|
|
67131
|
+
v += " " + span[kk].trim();
|
|
67132
|
+
kk++;
|
|
67133
|
+
}
|
|
67134
|
+
val[key] = v;
|
|
67135
|
+
}
|
|
67136
|
+
}
|
|
67137
|
+
}
|
|
67138
|
+
const id = val.id;
|
|
67139
|
+
if (!id || seen.has(id))
|
|
67140
|
+
continue;
|
|
67141
|
+
seen.add(id);
|
|
67142
|
+
rows.push({
|
|
67143
|
+
id,
|
|
67144
|
+
name: val.name || id,
|
|
67145
|
+
...val.description ? { description: val.description } : {}
|
|
67146
|
+
});
|
|
67147
|
+
}
|
|
67148
|
+
return rows;
|
|
67149
|
+
}
|
|
67150
|
+
currentId() {
|
|
67151
|
+
try {
|
|
67152
|
+
const doc = asRecord6(JSON.parse(readFileSync13(this.#configPath, "utf8")));
|
|
67153
|
+
return typeof doc.agentPreset === "string" && doc.agentPreset !== "" ? doc.agentPreset : undefined;
|
|
67154
|
+
} catch {
|
|
67155
|
+
return;
|
|
67156
|
+
}
|
|
67157
|
+
}
|
|
67158
|
+
select(presetId) {
|
|
67159
|
+
const current = this.#readDoc();
|
|
67160
|
+
try {
|
|
67161
|
+
atomicWrite2(this.#configPath, JSON.stringify({ ...current, agentPreset: presetId }, null, 2) + `
|
|
67162
|
+
`);
|
|
67163
|
+
return true;
|
|
67164
|
+
} catch {
|
|
67165
|
+
return false;
|
|
67166
|
+
}
|
|
67167
|
+
}
|
|
67168
|
+
#readDoc() {
|
|
67169
|
+
try {
|
|
67170
|
+
return asRecord6(JSON.parse(readFileSync13(this.#configPath, "utf8")));
|
|
67171
|
+
} catch {
|
|
67172
|
+
return {};
|
|
67173
|
+
}
|
|
67174
|
+
}
|
|
67175
|
+
}
|
|
67176
|
+
|
|
67177
|
+
class LocalLoginFace {
|
|
67178
|
+
#patchPath;
|
|
67179
|
+
#keysPath;
|
|
67180
|
+
constructor(home, profile) {
|
|
67181
|
+
this.#patchPath = join15(home, "profiles", profile, "cordis.patch.yml");
|
|
67182
|
+
this.#keysPath = join15(home, "profiles", profile, "provider-keys.json");
|
|
67183
|
+
}
|
|
67184
|
+
routes() {
|
|
67185
|
+
let lines = [];
|
|
67186
|
+
try {
|
|
67187
|
+
lines = readFileSync13(this.#patchPath, "utf8").split(`
|
|
67188
|
+
`);
|
|
67189
|
+
} catch {
|
|
67190
|
+
return [];
|
|
67191
|
+
}
|
|
67192
|
+
const span = nsEntrySpan(lines, "llm-pi-ai");
|
|
67193
|
+
if (span === undefined)
|
|
67194
|
+
return [];
|
|
67195
|
+
const providersLine = lines.findIndex((l, i) => i >= span[0] && i < span[1] && /^\s{4}providers:\s*$/.test(l));
|
|
67196
|
+
if (providersLine < 0)
|
|
67197
|
+
return [];
|
|
67198
|
+
const out = [];
|
|
67199
|
+
for (let i = providersLine + 1;i < lines.length; i++) {
|
|
67200
|
+
const line = lines[i];
|
|
67201
|
+
const m = /^\s{6}([A-Za-z0-9_.\-]+):\s*$/.exec(line);
|
|
67202
|
+
if (!m) {
|
|
67203
|
+
if (/^\s{0,4}\S/.test(line))
|
|
67204
|
+
break;
|
|
67205
|
+
continue;
|
|
67206
|
+
}
|
|
67207
|
+
const id = m[1];
|
|
67208
|
+
let apiKeyEnv;
|
|
67209
|
+
let displayName;
|
|
67210
|
+
let declared = false;
|
|
67211
|
+
for (let j = i + 1;j < lines.length; j++) {
|
|
67212
|
+
if (/^\s{6}\S/.test(lines[j]) || /^\s{0,4}\S/.test(lines[j]))
|
|
67213
|
+
break;
|
|
67214
|
+
const f = /^\s{8}([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/.exec(lines[j]);
|
|
67215
|
+
if (!f)
|
|
67216
|
+
continue;
|
|
67217
|
+
if (f[1] === "apiKeyEnv")
|
|
67218
|
+
apiKeyEnv = f[2].trim().replace(/^['"]|['"]$/g, "");
|
|
67219
|
+
else if (f[1] === "displayName")
|
|
67220
|
+
displayName = f[2].trim().replace(/^['"]|['"]$/g, "");
|
|
67221
|
+
else if (f[1] === "api" || f[1] === "baseURL" || f[1] === "models")
|
|
67222
|
+
declared = true;
|
|
67223
|
+
}
|
|
67224
|
+
out.push({ id, ...apiKeyEnv ? { apiKeyEnv } : {}, ...displayName ? { displayName } : {}, declared });
|
|
67225
|
+
}
|
|
67226
|
+
return out;
|
|
67227
|
+
}
|
|
67228
|
+
credentialStatus(ref) {
|
|
67229
|
+
if (typeof process.env[ref] === "string" && process.env[ref] !== "")
|
|
67230
|
+
return { configured: true };
|
|
67231
|
+
return { configured: Object.prototype.hasOwnProperty.call(this.#readKeys(), ref) };
|
|
67232
|
+
}
|
|
67233
|
+
login(ref, apiKey) {
|
|
67234
|
+
const keys = this.#readKeys();
|
|
67235
|
+
keys[ref] = apiKey;
|
|
67236
|
+
this.#writeKeys(keys);
|
|
67237
|
+
}
|
|
67238
|
+
logout(ref) {
|
|
67239
|
+
const keys = this.#readKeys();
|
|
67240
|
+
delete keys[ref];
|
|
67241
|
+
this.#writeKeys(keys);
|
|
67242
|
+
}
|
|
67243
|
+
registerRoute(providerId, profile) {
|
|
67244
|
+
let text = "";
|
|
67245
|
+
try {
|
|
67246
|
+
text = readFileSync13(this.#patchPath, "utf8");
|
|
67247
|
+
} catch {
|
|
67248
|
+
return false;
|
|
67249
|
+
}
|
|
67250
|
+
const lines = text.length > 0 ? text.split(`
|
|
67251
|
+
`) : [];
|
|
67252
|
+
const span = nsEntrySpan(lines, "llm-pi-ai");
|
|
67253
|
+
if (span === undefined)
|
|
67254
|
+
return false;
|
|
67255
|
+
const providersLine = lines.findIndex((l, i) => i >= span[0] && i < span[1] && /^\s{4}providers:\s*$/.test(l));
|
|
67256
|
+
if (providersLine < 0)
|
|
67257
|
+
return false;
|
|
67258
|
+
let pStart = -1;
|
|
67259
|
+
let pEnd = -1;
|
|
67260
|
+
for (let i = providersLine + 1;i < lines.length; i++) {
|
|
67261
|
+
const m = /^\s{6}([A-Za-z0-9_.\-]+):\s*$/.exec(lines[i]);
|
|
67262
|
+
if (m && m[1] === providerId) {
|
|
67263
|
+
pStart = i;
|
|
67264
|
+
pEnd = i + 1;
|
|
67265
|
+
for (let j = i + 1;j < lines.length; j++) {
|
|
67266
|
+
if (/^\s{6}\S/.test(lines[j]) || /^\s{0,4}\S/.test(lines[j]))
|
|
67267
|
+
break;
|
|
67268
|
+
pEnd = j + 1;
|
|
67269
|
+
}
|
|
67270
|
+
break;
|
|
67271
|
+
}
|
|
67272
|
+
if (/^\s{0,4}\S/.test(lines[i]))
|
|
67273
|
+
break;
|
|
67274
|
+
}
|
|
67275
|
+
if (profile === undefined) {
|
|
67276
|
+
if (pStart < 0)
|
|
67277
|
+
return true;
|
|
67278
|
+
lines.splice(pStart, pEnd - pStart);
|
|
67279
|
+
} else {
|
|
67280
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(providerId))
|
|
67281
|
+
return false;
|
|
67282
|
+
const block = buildLoginRouteBlock(providerId, profile);
|
|
67283
|
+
if (block === undefined)
|
|
67284
|
+
return false;
|
|
67285
|
+
if (pStart >= 0)
|
|
67286
|
+
lines.splice(pStart, pEnd - pStart, ...block);
|
|
67287
|
+
else
|
|
67288
|
+
lines.splice(providersLine + 1, 0, ...block);
|
|
67289
|
+
}
|
|
67290
|
+
try {
|
|
67291
|
+
atomicWrite2(this.#patchPath, lines.join(`
|
|
67292
|
+
`).replace(/\n*$/, `
|
|
67293
|
+
`));
|
|
67294
|
+
} catch {
|
|
67295
|
+
return false;
|
|
67296
|
+
}
|
|
67297
|
+
return true;
|
|
67298
|
+
}
|
|
67299
|
+
#readKeys() {
|
|
67300
|
+
try {
|
|
67301
|
+
const doc = asRecord6(JSON.parse(readFileSync13(this.#keysPath, "utf8")));
|
|
67302
|
+
const out = {};
|
|
67303
|
+
for (const [k, v] of Object.entries(doc))
|
|
67304
|
+
if (typeof v === "string")
|
|
67305
|
+
out[k] = v;
|
|
67306
|
+
return out;
|
|
67307
|
+
} catch {
|
|
67308
|
+
return {};
|
|
67309
|
+
}
|
|
67310
|
+
}
|
|
67311
|
+
#writeKeys(keys) {
|
|
67312
|
+
mkdirSync7(dirname7(this.#keysPath), { recursive: true });
|
|
67313
|
+
const tmp = `${this.#keysPath}.${process.pid}.s5.tmp`;
|
|
67314
|
+
try {
|
|
67315
|
+
writeFileSync9(tmp, JSON.stringify(keys, null, 2) + `
|
|
67316
|
+
`, { mode: 384 });
|
|
67317
|
+
try {
|
|
67318
|
+
chmodSync4(tmp, 384);
|
|
67319
|
+
} catch {}
|
|
67320
|
+
renameSync9(tmp, this.#keysPath);
|
|
67321
|
+
} catch (err) {
|
|
67322
|
+
try {
|
|
67323
|
+
rmSync5(tmp, { force: true });
|
|
67324
|
+
} catch {}
|
|
67325
|
+
throw err;
|
|
67326
|
+
}
|
|
67327
|
+
}
|
|
67328
|
+
}
|
|
66358
67329
|
var SETTINGS_NAMESPACES, NS_VALUE_FIELDS, NS_PACKAGE, NS_DEFAULTS, CONFIG_KEYS, CONFIG_KEY_SET;
|
|
66359
67330
|
var init_local_config_faces = __esm(() => {
|
|
66360
67331
|
init_remote_agent_profiles();
|
|
@@ -66391,12 +67362,406 @@ var init_local_config_faces = __esm(() => {
|
|
|
66391
67362
|
"activity_panel_height",
|
|
66392
67363
|
"stepsDisplay",
|
|
66393
67364
|
"stepsCollapse",
|
|
66394
|
-
"stepsFolded"
|
|
67365
|
+
"stepsFolded",
|
|
67366
|
+
"agentPreset"
|
|
66395
67367
|
];
|
|
66396
67368
|
CONFIG_KEY_SET = new Set(CONFIG_KEYS);
|
|
66397
67369
|
});
|
|
66398
67370
|
|
|
67371
|
+
// src/client/bridge-plugins-manager.ts
|
|
67372
|
+
function asRecord7(value) {
|
|
67373
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
67374
|
+
}
|
|
67375
|
+
function unwrapWireValue(raw) {
|
|
67376
|
+
const rec = asRecord7(raw);
|
|
67377
|
+
if (Object.prototype.hasOwnProperty.call(rec, "value"))
|
|
67378
|
+
return rec.value;
|
|
67379
|
+
return raw;
|
|
67380
|
+
}
|
|
67381
|
+
function text(value, max = MAX_TEXT) {
|
|
67382
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
67383
|
+
}
|
|
67384
|
+
function bool(value) {
|
|
67385
|
+
return value === true;
|
|
67386
|
+
}
|
|
67387
|
+
function projectBundleRows(raw) {
|
|
67388
|
+
const value = unwrapWireValue(raw);
|
|
67389
|
+
if (!Array.isArray(value))
|
|
67390
|
+
return [];
|
|
67391
|
+
const out = [];
|
|
67392
|
+
for (const entry of value) {
|
|
67393
|
+
const row = asRecord7(entry);
|
|
67394
|
+
const name = text(row.name, MAX_SHORT);
|
|
67395
|
+
if (name === undefined || name === "")
|
|
67396
|
+
continue;
|
|
67397
|
+
const version = text(row.version, MAX_SHORT) ?? "";
|
|
67398
|
+
const description = text(row.description);
|
|
67399
|
+
const readOnlyReason = text(row.readOnlyReason, MAX_SHORT);
|
|
67400
|
+
const errorRaw = row.error;
|
|
67401
|
+
const error = typeof errorRaw === "string" ? errorRaw.slice(0, MAX_SHORT) : text(asRecord7(errorRaw).message, MAX_SHORT);
|
|
67402
|
+
const projected = {
|
|
67403
|
+
name,
|
|
67404
|
+
version,
|
|
67405
|
+
enabled: bool(row.enabled),
|
|
67406
|
+
installed: bool(row.installed),
|
|
67407
|
+
optional: bool(row.optional),
|
|
67408
|
+
removable: bool(row.removable)
|
|
67409
|
+
};
|
|
67410
|
+
if (description !== undefined)
|
|
67411
|
+
projected.description = description;
|
|
67412
|
+
if (readOnlyReason !== undefined)
|
|
67413
|
+
projected.readOnlyReason = readOnlyReason;
|
|
67414
|
+
if (error !== undefined)
|
|
67415
|
+
projected.error = error;
|
|
67416
|
+
out.push(projected);
|
|
67417
|
+
}
|
|
67418
|
+
return out;
|
|
67419
|
+
}
|
|
67420
|
+
function projectPluginRows(raw) {
|
|
67421
|
+
const value = unwrapWireValue(raw);
|
|
67422
|
+
if (!Array.isArray(value))
|
|
67423
|
+
return [];
|
|
67424
|
+
const out = [];
|
|
67425
|
+
for (const entry of value) {
|
|
67426
|
+
const row = asRecord7(entry);
|
|
67427
|
+
const name = text(row.name, MAX_SHORT) ?? text(row.id, MAX_SHORT);
|
|
67428
|
+
if (name === undefined || name === "")
|
|
67429
|
+
continue;
|
|
67430
|
+
out.push({ name, version: text(row.version, MAX_SHORT) ?? "" });
|
|
67431
|
+
}
|
|
67432
|
+
return out;
|
|
67433
|
+
}
|
|
67434
|
+
function projectDetail(raw) {
|
|
67435
|
+
const value = unwrapWireValue(raw);
|
|
67436
|
+
const row = asRecord7(value);
|
|
67437
|
+
if (row.status === "found") {
|
|
67438
|
+
const origin = row.origin === "locale" || row.origin === "readme" ? row.origin : "readme";
|
|
67439
|
+
return {
|
|
67440
|
+
status: "found",
|
|
67441
|
+
origin,
|
|
67442
|
+
path: text(row.path, MAX_SHORT) ?? "",
|
|
67443
|
+
markdown: text(row.markdown) ?? ""
|
|
67444
|
+
};
|
|
67445
|
+
}
|
|
67446
|
+
return { status: "none" };
|
|
67447
|
+
}
|
|
67448
|
+
function projectRegistries(raw) {
|
|
67449
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67450
|
+
const fallback = Array.isArray(row.fallbackRegistries) ? row.fallbackRegistries.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "") : [];
|
|
67451
|
+
return {
|
|
67452
|
+
registry: text(row.registry, MAX_SHORT) ?? null,
|
|
67453
|
+
fallbackRegistries: fallback,
|
|
67454
|
+
resolved: text(row.resolved, MAX_SHORT) ?? null
|
|
67455
|
+
};
|
|
67456
|
+
}
|
|
67457
|
+
function projectVersionExemptions(raw) {
|
|
67458
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67459
|
+
const exemptions = {};
|
|
67460
|
+
const src = asRecord7(row.exemptions);
|
|
67461
|
+
for (const [key, versions] of Object.entries(src)) {
|
|
67462
|
+
exemptions[text(key, MAX_SHORT) ?? ""] = Array.isArray(versions) ? versions.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "") : [];
|
|
67463
|
+
}
|
|
67464
|
+
const warnings = Array.isArray(row.warnings) ? row.warnings.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "") : [];
|
|
67465
|
+
return { exemptions, warnings };
|
|
67466
|
+
}
|
|
67467
|
+
function projectInspection(raw) {
|
|
67468
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67469
|
+
if (row.status === "refused") {
|
|
67470
|
+
return {
|
|
67471
|
+
status: "refused",
|
|
67472
|
+
problem: text(row.problem, MAX_SHORT) ?? "unknown",
|
|
67473
|
+
reason: text(row.reason) ?? ""
|
|
67474
|
+
};
|
|
67475
|
+
}
|
|
67476
|
+
const bundle = row.bundle === true ? true : row.bundle === false ? false : null;
|
|
67477
|
+
const accepted = { status: "accepted", bundle };
|
|
67478
|
+
const name = text(row.name, MAX_SHORT);
|
|
67479
|
+
const version = text(row.version, MAX_SHORT);
|
|
67480
|
+
const description = text(row.description);
|
|
67481
|
+
if (name !== undefined)
|
|
67482
|
+
accepted.name = name;
|
|
67483
|
+
if (version !== undefined)
|
|
67484
|
+
accepted.version = version;
|
|
67485
|
+
if (description !== undefined)
|
|
67486
|
+
accepted.description = description;
|
|
67487
|
+
return accepted;
|
|
67488
|
+
}
|
|
67489
|
+
function projectVersions(raw) {
|
|
67490
|
+
const value = unwrapWireValue(raw);
|
|
67491
|
+
if (!Array.isArray(value))
|
|
67492
|
+
return [];
|
|
67493
|
+
return value.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "");
|
|
67494
|
+
}
|
|
67495
|
+
function projectChange(raw) {
|
|
67496
|
+
const value = unwrapWireValue(raw);
|
|
67497
|
+
const row = asRecord7(value);
|
|
67498
|
+
const application = row.application;
|
|
67499
|
+
const safeApplication = application === "applied" || application === "restart-required" || application === "overridden" || application === "failed" || application === "cancelled" ? application : "failed";
|
|
67500
|
+
const target = text(row.target, MAX_SHORT) ?? "";
|
|
67501
|
+
const requestId = text(row.requestId, MAX_SHORT);
|
|
67502
|
+
const errorObj = row.error;
|
|
67503
|
+
const error = typeof errorObj === "string" ? errorObj.slice(0, MAX_SHORT) : text(asRecord7(errorObj).diagnostic, MAX_SHORT) ?? text(asRecord7(errorObj).code, MAX_SHORT);
|
|
67504
|
+
const out = {
|
|
67505
|
+
changed: safeApplication === "failed" ? false : row.changed === true,
|
|
67506
|
+
application: safeApplication,
|
|
67507
|
+
target
|
|
67508
|
+
};
|
|
67509
|
+
if (error !== undefined)
|
|
67510
|
+
out.error = error;
|
|
67511
|
+
if (requestId !== undefined && requestId !== "")
|
|
67512
|
+
out.requestId = requestId;
|
|
67513
|
+
return out;
|
|
67514
|
+
}
|
|
67515
|
+
function projectInstallProgress(raw, requestId) {
|
|
67516
|
+
if (raw === null || raw === undefined)
|
|
67517
|
+
return { state: "done", requestId };
|
|
67518
|
+
const value = unwrapWireValue(raw);
|
|
67519
|
+
if (value === null || value === undefined)
|
|
67520
|
+
return { state: "done", requestId };
|
|
67521
|
+
const row = asRecord7(value);
|
|
67522
|
+
const application = row.application;
|
|
67523
|
+
const target = text(row.target, MAX_SHORT) ?? "";
|
|
67524
|
+
if (application === "cancelled")
|
|
67525
|
+
return { state: "cancelled", requestId, target };
|
|
67526
|
+
if (application === "failed") {
|
|
67527
|
+
const errorObj = row.error;
|
|
67528
|
+
const error = typeof errorObj === "string" ? errorObj.slice(0, MAX_SHORT) : text(asRecord7(errorObj).diagnostic, MAX_SHORT) ?? text(asRecord7(errorObj).code, MAX_SHORT);
|
|
67529
|
+
return error !== undefined ? { state: "failed", requestId, target, error } : { state: "failed", requestId, target };
|
|
67530
|
+
}
|
|
67531
|
+
if (application === "applied" || application === "restart-required" || application === "overridden") {
|
|
67532
|
+
return { state: "done", requestId, target };
|
|
67533
|
+
}
|
|
67534
|
+
return { state: "unknown", requestId };
|
|
67535
|
+
}
|
|
67536
|
+
function projectCancellation(raw) {
|
|
67537
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67538
|
+
const status = row.status;
|
|
67539
|
+
if (status === "cancelled" || status === "too-late" || status === "not-running")
|
|
67540
|
+
return { status };
|
|
67541
|
+
return { status: "not-running" };
|
|
67542
|
+
}
|
|
67543
|
+
var MAX_TEXT = 4096, MAX_SHORT = 240;
|
|
67544
|
+
|
|
67545
|
+
// src/client/bridge-directory.ts
|
|
67546
|
+
function asRecord8(value) {
|
|
67547
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
67548
|
+
}
|
|
67549
|
+
function unwrapWireValue2(raw) {
|
|
67550
|
+
const rec = asRecord8(raw);
|
|
67551
|
+
if (Object.prototype.hasOwnProperty.call(rec, "value"))
|
|
67552
|
+
return rec.value;
|
|
67553
|
+
return raw;
|
|
67554
|
+
}
|
|
67555
|
+
function text2(value, max = MAX_TEXT2) {
|
|
67556
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
67557
|
+
}
|
|
67558
|
+
function projectLlmProviders(raw) {
|
|
67559
|
+
const value = unwrapWireValue2(raw);
|
|
67560
|
+
if (!Array.isArray(value))
|
|
67561
|
+
return [];
|
|
67562
|
+
const out = [];
|
|
67563
|
+
for (const entry of value) {
|
|
67564
|
+
const row = asRecord8(entry);
|
|
67565
|
+
const id = text2(row.id, MAX_SHORT2);
|
|
67566
|
+
const name = text2(row.name, MAX_SHORT2);
|
|
67567
|
+
if (id === undefined || id === "" || name === undefined)
|
|
67568
|
+
continue;
|
|
67569
|
+
out.push({ id, name });
|
|
67570
|
+
if (out.length >= MAX_ROWS2)
|
|
67571
|
+
break;
|
|
67572
|
+
}
|
|
67573
|
+
return out;
|
|
67574
|
+
}
|
|
67575
|
+
function envNames(value) {
|
|
67576
|
+
if (!Array.isArray(value))
|
|
67577
|
+
return;
|
|
67578
|
+
const names = [];
|
|
67579
|
+
for (const item of value) {
|
|
67580
|
+
if (typeof item === "string" && item.length > 0 && names.length < 16)
|
|
67581
|
+
names.push(item.slice(0, MAX_SHORT2));
|
|
67582
|
+
}
|
|
67583
|
+
return names.length > 0 ? names : undefined;
|
|
67584
|
+
}
|
|
67585
|
+
function projectConfigurableProviders(raw) {
|
|
67586
|
+
const value = unwrapWireValue2(raw);
|
|
67587
|
+
if (!Array.isArray(value))
|
|
67588
|
+
return [];
|
|
67589
|
+
const out = [];
|
|
67590
|
+
for (const entry of value) {
|
|
67591
|
+
const row = asRecord8(entry);
|
|
67592
|
+
const provider = text2(row.provider, MAX_SHORT2);
|
|
67593
|
+
const displayName = text2(row.displayName, MAX_SHORT2);
|
|
67594
|
+
if (provider === undefined || provider === "" || displayName === undefined)
|
|
67595
|
+
continue;
|
|
67596
|
+
const projected = { provider, displayName };
|
|
67597
|
+
const settingsNs = text2(row.settingsNs, MAX_SHORT2);
|
|
67598
|
+
if (settingsNs !== undefined)
|
|
67599
|
+
projected.settingsNs = settingsNs;
|
|
67600
|
+
if (row.declared === true || row.declared === false)
|
|
67601
|
+
projected.declared = row.declared;
|
|
67602
|
+
const auth = asRecord8(row.nativeAuth);
|
|
67603
|
+
const authEnv = envNames(auth.env);
|
|
67604
|
+
if (authEnv !== undefined)
|
|
67605
|
+
projected.authEnvNames = authEnv;
|
|
67606
|
+
const baseEnv = envNames(row.baseURLEnv);
|
|
67607
|
+
if (baseEnv !== undefined) {
|
|
67608
|
+
projected.authEnvNames = [...projected.authEnvNames ?? [], ...baseEnv].slice(0, 16);
|
|
67609
|
+
}
|
|
67610
|
+
const error = text2(row.error, MAX_SHORT2);
|
|
67611
|
+
if (error !== undefined)
|
|
67612
|
+
projected.error = error;
|
|
67613
|
+
out.push(projected);
|
|
67614
|
+
if (out.length >= MAX_ROWS2)
|
|
67615
|
+
break;
|
|
67616
|
+
}
|
|
67617
|
+
return out;
|
|
67618
|
+
}
|
|
67619
|
+
function projectOptions(value) {
|
|
67620
|
+
if (!Array.isArray(value))
|
|
67621
|
+
return [];
|
|
67622
|
+
const out = [];
|
|
67623
|
+
for (const entry of value) {
|
|
67624
|
+
const row = asRecord8(entry);
|
|
67625
|
+
const key = text2(row.value, MAX_SHORT2);
|
|
67626
|
+
if (key === undefined || key === "")
|
|
67627
|
+
continue;
|
|
67628
|
+
const opt = { value: key };
|
|
67629
|
+
const name = text2(row.name, MAX_SHORT2);
|
|
67630
|
+
if (name !== undefined)
|
|
67631
|
+
opt.name = name;
|
|
67632
|
+
const description = text2(row.description, MAX_TEXT2);
|
|
67633
|
+
if (description !== undefined)
|
|
67634
|
+
opt.description = description;
|
|
67635
|
+
out.push(opt);
|
|
67636
|
+
if (out.length >= MAX_ROWS2)
|
|
67637
|
+
break;
|
|
67638
|
+
}
|
|
67639
|
+
return out;
|
|
67640
|
+
}
|
|
67641
|
+
function projectPermissionCatalog(raw) {
|
|
67642
|
+
const value = unwrapWireValue2(raw);
|
|
67643
|
+
const rec = asRecord8(value);
|
|
67644
|
+
const options = projectOptions(rec.options);
|
|
67645
|
+
const defaultOptions = projectOptions(rec.defaultOptions);
|
|
67646
|
+
const defaultPreset = text2(rec.defaultPreset, MAX_SHORT2) ?? "";
|
|
67647
|
+
if (options.length === 0 && defaultOptions.length === 0 && defaultPreset === "")
|
|
67648
|
+
return;
|
|
67649
|
+
return { options, defaultOptions, defaultPreset };
|
|
67650
|
+
}
|
|
67651
|
+
function cappedNumber(value) {
|
|
67652
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.min(value, MAX_NUM) : undefined;
|
|
67653
|
+
}
|
|
67654
|
+
function projectDiscoverModels(raw) {
|
|
67655
|
+
const value = unwrapWireValue2(raw);
|
|
67656
|
+
if (!Array.isArray(value))
|
|
67657
|
+
return [];
|
|
67658
|
+
const out = [];
|
|
67659
|
+
for (const entry of value) {
|
|
67660
|
+
const row = asRecord8(entry);
|
|
67661
|
+
const id = text2(row.id, MAX_SHORT2);
|
|
67662
|
+
if (id === undefined || id === "")
|
|
67663
|
+
continue;
|
|
67664
|
+
const projected = { id };
|
|
67665
|
+
const name = text2(row.name, MAX_SHORT2);
|
|
67666
|
+
if (name !== undefined)
|
|
67667
|
+
projected.name = name;
|
|
67668
|
+
const cw = cappedNumber(row.contextWindow);
|
|
67669
|
+
if (cw !== undefined)
|
|
67670
|
+
projected.contextWindow = cw;
|
|
67671
|
+
const mt = cappedNumber(row.maxTokens);
|
|
67672
|
+
if (mt !== undefined)
|
|
67673
|
+
projected.maxTokens = mt;
|
|
67674
|
+
if (Array.isArray(row.inputModalities)) {
|
|
67675
|
+
const mods = row.inputModalities.filter((m) => m === "text" || m === "image").slice(0, 4);
|
|
67676
|
+
if (mods.length > 0)
|
|
67677
|
+
projected.inputModalities = mods;
|
|
67678
|
+
}
|
|
67679
|
+
out.push(projected);
|
|
67680
|
+
if (out.length >= MAX_ROWS2)
|
|
67681
|
+
break;
|
|
67682
|
+
}
|
|
67683
|
+
return out;
|
|
67684
|
+
}
|
|
67685
|
+
var MAX_TEXT2 = 4096, MAX_SHORT2 = 240, MAX_ROWS2 = 512, MAX_NUM = 1e7;
|
|
67686
|
+
|
|
67687
|
+
// src/client/bridge-goals.ts
|
|
67688
|
+
function asRecord9(value) {
|
|
67689
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
67690
|
+
}
|
|
67691
|
+
function unwrapGoalsValue(raw) {
|
|
67692
|
+
const rec = asRecord9(raw);
|
|
67693
|
+
if (Object.prototype.hasOwnProperty.call(rec, "value"))
|
|
67694
|
+
return rec.value;
|
|
67695
|
+
return raw;
|
|
67696
|
+
}
|
|
67697
|
+
function text3(value, max = MAX_TEXT3) {
|
|
67698
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
67699
|
+
}
|
|
67700
|
+
function finiteNumber(value) {
|
|
67701
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
67702
|
+
}
|
|
67703
|
+
function oneOf(value, set) {
|
|
67704
|
+
return typeof value === "string" && set.includes(value) ? value : undefined;
|
|
67705
|
+
}
|
|
67706
|
+
function projectGoalRef(raw) {
|
|
67707
|
+
const rec = asRecord9(unwrapGoalsValue(raw));
|
|
67708
|
+
const id = text3(rec.id, MAX_SHORT3);
|
|
67709
|
+
const revision = finiteNumber(rec.revision);
|
|
67710
|
+
if (id === undefined || id === "" || revision === undefined)
|
|
67711
|
+
return;
|
|
67712
|
+
return { id, revision };
|
|
67713
|
+
}
|
|
67714
|
+
function projectGoalView(raw) {
|
|
67715
|
+
const value = unwrapGoalsValue(raw);
|
|
67716
|
+
if (value === null || value === undefined)
|
|
67717
|
+
return;
|
|
67718
|
+
const rec = asRecord9(value);
|
|
67719
|
+
const id = text3(rec.id, MAX_SHORT3);
|
|
67720
|
+
const revision = finiteNumber(rec.revision);
|
|
67721
|
+
const objective = text3(rec.objective, MAX_TEXT3);
|
|
67722
|
+
const phase = oneOf(rec.phase, PHASES);
|
|
67723
|
+
const activation = oneOf(rec.activation, ACTIVATIONS);
|
|
67724
|
+
const roundsStarted = finiteNumber(rec.roundsStarted);
|
|
67725
|
+
const maxGoalRounds = finiteNumber(rec.maxGoalRounds);
|
|
67726
|
+
const createdAt = finiteNumber(rec.createdAt);
|
|
67727
|
+
const updatedAt = finiteNumber(rec.updatedAt);
|
|
67728
|
+
if (id === undefined || id === "" || revision === undefined || objective === undefined || phase === undefined || activation === undefined || roundsStarted === undefined || maxGoalRounds === undefined || createdAt === undefined || updatedAt === undefined)
|
|
67729
|
+
return;
|
|
67730
|
+
const view = {
|
|
67731
|
+
id,
|
|
67732
|
+
revision,
|
|
67733
|
+
objective,
|
|
67734
|
+
phase,
|
|
67735
|
+
activation,
|
|
67736
|
+
roundsStarted,
|
|
67737
|
+
maxGoalRounds,
|
|
67738
|
+
createdAt,
|
|
67739
|
+
updatedAt
|
|
67740
|
+
};
|
|
67741
|
+
const reason = asRecord9(rec.blockedReason);
|
|
67742
|
+
const code = text3(reason.code, MAX_SHORT3);
|
|
67743
|
+
const message = text3(reason.message, MAX_TEXT3);
|
|
67744
|
+
if (code !== undefined && message !== undefined)
|
|
67745
|
+
view.blockedReason = { code, message };
|
|
67746
|
+
return view;
|
|
67747
|
+
}
|
|
67748
|
+
function projectCreateGoalResult(raw) {
|
|
67749
|
+
const rec = asRecord9(unwrapGoalsValue(raw));
|
|
67750
|
+
return projectGoalRef(rec.ref);
|
|
67751
|
+
}
|
|
67752
|
+
var MAX_TEXT3 = 4096, MAX_SHORT3 = 240, PHASES, ACTIVATIONS;
|
|
67753
|
+
var init_bridge_goals = __esm(() => {
|
|
67754
|
+
PHASES = ["active", "paused", "blocked", "complete"];
|
|
67755
|
+
ACTIVATIONS = ["armed", "disarmed"];
|
|
67756
|
+
});
|
|
67757
|
+
|
|
66399
67758
|
// src/client/bridge-session-seam.ts
|
|
67759
|
+
import { existsSync as existsSync13, readFileSync as readFileSync14, readdirSync as readdirSync4 } from "fs";
|
|
67760
|
+
import { join as join16 } from "path";
|
|
67761
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
67762
|
+
function writeConfirmed(confirm) {
|
|
67763
|
+
return typeof confirm === "object" && confirm !== null && confirm.__pluginWriteConfirm === true && typeof confirm.operation === "string";
|
|
67764
|
+
}
|
|
66400
67765
|
function askTurnId(eventId) {
|
|
66401
67766
|
const i = eventId.lastIndexOf(":ask-");
|
|
66402
67767
|
return i === -1 ? "" : eventId.slice(0, i);
|
|
@@ -66406,7 +67771,7 @@ function optionalStringField(row, key) {
|
|
|
66406
67771
|
return typeof value === "string" && value !== "" ? value : undefined;
|
|
66407
67772
|
}
|
|
66408
67773
|
function parseAskRequest(value) {
|
|
66409
|
-
const row =
|
|
67774
|
+
const row = asRecord10(value);
|
|
66410
67775
|
const eventId = optionalStringField(row, "eventId");
|
|
66411
67776
|
const sessionId = optionalStringField(row, "sessionId");
|
|
66412
67777
|
const kind = row.kind;
|
|
@@ -66429,14 +67794,14 @@ function parseAskRequest(value) {
|
|
|
66429
67794
|
if (Array.isArray(row.questions)) {
|
|
66430
67795
|
const questions = [];
|
|
66431
67796
|
for (const raw of row.questions) {
|
|
66432
|
-
const q =
|
|
67797
|
+
const q = asRecord10(raw);
|
|
66433
67798
|
const id = optionalStringField(q, "id");
|
|
66434
67799
|
const prompt = optionalStringField(q, "prompt");
|
|
66435
67800
|
if (id === undefined || prompt === undefined || !Array.isArray(q.options))
|
|
66436
67801
|
continue;
|
|
66437
67802
|
const options = [];
|
|
66438
67803
|
for (const rawOpt of q.options) {
|
|
66439
|
-
const opt =
|
|
67804
|
+
const opt = asRecord10(rawOpt);
|
|
66440
67805
|
const label = optionalStringField(opt, "label");
|
|
66441
67806
|
if (label === undefined)
|
|
66442
67807
|
continue;
|
|
@@ -66506,9 +67871,25 @@ function answersFor(request, picks) {
|
|
|
66506
67871
|
function unavailableResponse(request) {
|
|
66507
67872
|
return request.kind === "questions" ? { eventId: request.eventId, kind: "questions", verdict: "unavailable", answers: answersFor(request, []) } : { eventId: request.eventId, kind: "approval", verdict: "unavailable" };
|
|
66508
67873
|
}
|
|
66509
|
-
function
|
|
67874
|
+
function asRecord10(value) {
|
|
66510
67875
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
66511
67876
|
}
|
|
67877
|
+
function projectSeamAccountView(value) {
|
|
67878
|
+
const v = asRecord10(value);
|
|
67879
|
+
return {
|
|
67880
|
+
status: typeof v.status === "string" && ACCOUNT_STATUSES.has(v.status) ? v.status : null,
|
|
67881
|
+
attemptPhase: typeof v.attemptPhase === "string" && ACCOUNT_PHASES.has(v.attemptPhase) ? v.attemptPhase : null,
|
|
67882
|
+
authorizeUrlReady: v.authorizeUrlReady === true,
|
|
67883
|
+
linksPresent: v.linksPresent === true
|
|
67884
|
+
};
|
|
67885
|
+
}
|
|
67886
|
+
function accountClientMeta() {
|
|
67887
|
+
return {
|
|
67888
|
+
version: "0.25-w1b",
|
|
67889
|
+
locale: typeof Intl !== "undefined" ? Intl.DateTimeFormat().resolvedOptions().locale : "en",
|
|
67890
|
+
timezoneOffsetSeconds: -new Date().getTimezoneOffset() * 60
|
|
67891
|
+
};
|
|
67892
|
+
}
|
|
66512
67893
|
function unsupported(capability) {
|
|
66513
67894
|
throw new BridgeProtocolError("UNSUPPORTED", `${capability} is not backed by the in-process bridge`, { capability });
|
|
66514
67895
|
}
|
|
@@ -66516,14 +67897,14 @@ function projectBridgeSessionList(items, limit = 12) {
|
|
|
66516
67897
|
const rows = Array.isArray(items) ? items : [];
|
|
66517
67898
|
const out = [];
|
|
66518
67899
|
for (const item of rows) {
|
|
66519
|
-
const row =
|
|
67900
|
+
const row = asRecord10(item);
|
|
66520
67901
|
if (row.origin === "subagent")
|
|
66521
67902
|
continue;
|
|
66522
67903
|
const id = typeof row.sessionId === "string" ? row.sessionId : "";
|
|
66523
67904
|
if (!id)
|
|
66524
67905
|
continue;
|
|
66525
67906
|
const updatedAt = typeof row.updatedAt === "number" ? String(row.updatedAt) : "";
|
|
66526
|
-
const values =
|
|
67907
|
+
const values = asRecord10(asRecord10(row.projections).values);
|
|
66527
67908
|
const title = typeof values.title === "string" ? values.title : "";
|
|
66528
67909
|
out.push({
|
|
66529
67910
|
id,
|
|
@@ -66541,7 +67922,7 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
|
|
|
66541
67922
|
type: row.type,
|
|
66542
67923
|
seq: row.seq,
|
|
66543
67924
|
time: 0,
|
|
66544
|
-
data:
|
|
67925
|
+
data: asRecord10(row.payload)
|
|
66545
67926
|
}));
|
|
66546
67927
|
const durable = journalToTranscriptRows(entries, skip);
|
|
66547
67928
|
return durable.map((row) => {
|
|
@@ -66555,8 +67936,8 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
|
|
|
66555
67936
|
});
|
|
66556
67937
|
}
|
|
66557
67938
|
function seamReplayEventKey(event) {
|
|
66558
|
-
const details =
|
|
66559
|
-
return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(
|
|
67939
|
+
const details = asRecord10(event.details);
|
|
67940
|
+
return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord10(details.part).id ?? "")}`;
|
|
66560
67941
|
}
|
|
66561
67942
|
function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
66562
67943
|
const events = [];
|
|
@@ -66570,7 +67951,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
|
66570
67951
|
};
|
|
66571
67952
|
const toolCalls = new Map;
|
|
66572
67953
|
for (const row of rows) {
|
|
66573
|
-
const entry = { type: row.type, seq: row.seq, time: 0, data:
|
|
67954
|
+
const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord10(row.payload) };
|
|
66574
67955
|
for (const event of projectJournalRecord(entry, sessionId))
|
|
66575
67956
|
push(event);
|
|
66576
67957
|
const data = entry.data;
|
|
@@ -66584,7 +67965,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
|
66584
67965
|
});
|
|
66585
67966
|
}
|
|
66586
67967
|
} else if (row.type === "tool/result") {
|
|
66587
|
-
const message =
|
|
67968
|
+
const message = asRecord10(data.message);
|
|
66588
67969
|
const callId = data.callId !== undefined ? String(data.callId) : message.toolCallId !== undefined ? String(message.toolCallId) : "";
|
|
66589
67970
|
const call = callId ? toolCalls.get(callId) : undefined;
|
|
66590
67971
|
if (call !== undefined) {
|
|
@@ -66638,7 +68019,7 @@ function bridgeSettleChild(existing, outcome, startedAt, now) {
|
|
|
66638
68019
|
}
|
|
66639
68020
|
function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, live) {
|
|
66640
68021
|
if (type === "user/message") {
|
|
66641
|
-
const source =
|
|
68022
|
+
const source = asRecord10(data.source);
|
|
66642
68023
|
if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
|
|
66643
68024
|
return false;
|
|
66644
68025
|
const childId = typeof source.senderSessionId === "string" ? source.senderSessionId : "";
|
|
@@ -66733,7 +68114,7 @@ function bridgeSweepSettledChildIds(rows, parentId, locallyRunning) {
|
|
|
66733
68114
|
return [];
|
|
66734
68115
|
const settled = [];
|
|
66735
68116
|
for (const raw of rows) {
|
|
66736
|
-
const row =
|
|
68117
|
+
const row = asRecord10(raw);
|
|
66737
68118
|
if (row.origin !== "subagent")
|
|
66738
68119
|
continue;
|
|
66739
68120
|
if (row.parentSessionId !== parentId)
|
|
@@ -66783,16 +68164,16 @@ function bridgeChildJournalMeta(rows) {
|
|
|
66783
68164
|
let contextModel;
|
|
66784
68165
|
let descriptorModel;
|
|
66785
68166
|
for (const row of rows) {
|
|
66786
|
-
const data =
|
|
68167
|
+
const data = asRecord10(row.payload);
|
|
66787
68168
|
if (row.type === "assistant/message") {
|
|
66788
68169
|
rounds += 1;
|
|
66789
|
-
const message =
|
|
68170
|
+
const message = asRecord10(data.message);
|
|
66790
68171
|
const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
|
|
66791
68172
|
if (tail !== undefined)
|
|
66792
68173
|
lastLine = tail;
|
|
66793
68174
|
} else if (row.type === "tool/result") {
|
|
66794
68175
|
if (data.isError !== true) {
|
|
66795
|
-
const message =
|
|
68176
|
+
const message = asRecord10(data.message);
|
|
66796
68177
|
const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
|
|
66797
68178
|
if (tail !== undefined)
|
|
66798
68179
|
lastLine = tail;
|
|
@@ -66814,12 +68195,23 @@ function bridgeChildJournalMeta(rows) {
|
|
|
66814
68195
|
...model !== undefined ? { model } : {}
|
|
66815
68196
|
};
|
|
66816
68197
|
}
|
|
68198
|
+
function bridgeReplayRowsToChildLog(rows) {
|
|
68199
|
+
return bridgeReplayRowsToSeamTranscript(rows).map((row) => {
|
|
68200
|
+
if (row.kind === "tool") {
|
|
68201
|
+
return row.output ? `\u25B6 ${row.text}
|
|
68202
|
+
\u23BF ${row.output}` : `\u25B6 ${row.text}`;
|
|
68203
|
+
}
|
|
68204
|
+
if (row.kind === "ask")
|
|
68205
|
+
return "[ask]";
|
|
68206
|
+
return row.text;
|
|
68207
|
+
}).filter((line) => line !== "");
|
|
68208
|
+
}
|
|
66817
68209
|
function bridgeChildStopReason(rows) {
|
|
66818
68210
|
for (let i = rows.length - 1;i >= 0; i -= 1) {
|
|
66819
68211
|
const row = rows[i];
|
|
66820
68212
|
if (row.type !== "user/message")
|
|
66821
68213
|
continue;
|
|
66822
|
-
const source =
|
|
68214
|
+
const source = asRecord10(asRecord10(row.payload).source);
|
|
66823
68215
|
if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
|
|
66824
68216
|
continue;
|
|
66825
68217
|
const reason = source.stopReason;
|
|
@@ -66830,7 +68222,7 @@ function bridgeChildStopReason(rows) {
|
|
|
66830
68222
|
const row = rows[i];
|
|
66831
68223
|
if (row.type !== "turn/end")
|
|
66832
68224
|
continue;
|
|
66833
|
-
const reason =
|
|
68225
|
+
const reason = asRecord10(asRecord10(row.payload).reason);
|
|
66834
68226
|
const kind = reason.kind;
|
|
66835
68227
|
if (typeof kind === "string" && kind !== "")
|
|
66836
68228
|
return kind;
|
|
@@ -66888,7 +68280,7 @@ function lastJournalTurnTerminal(rows, startOutsideWindow = false) {
|
|
|
66888
68280
|
return latest;
|
|
66889
68281
|
}
|
|
66890
68282
|
function journalTurnId(row) {
|
|
66891
|
-
const payload =
|
|
68283
|
+
const payload = asRecord10(row.payload);
|
|
66892
68284
|
if (typeof payload.turn === "number" && Number.isFinite(payload.turn))
|
|
66893
68285
|
return payload.turn;
|
|
66894
68286
|
if (typeof payload.turnId === "string" && payload.turnId !== "")
|
|
@@ -66896,7 +68288,7 @@ function journalTurnId(row) {
|
|
|
66896
68288
|
return;
|
|
66897
68289
|
}
|
|
66898
68290
|
function projectBridgeEvent(frame, sessionId) {
|
|
66899
|
-
const payload =
|
|
68291
|
+
const payload = asRecord10(frame.payload);
|
|
66900
68292
|
const turnId = typeof payload.turnId === "string" ? payload.turnId : "";
|
|
66901
68293
|
if (frame.type === "turn.start") {
|
|
66902
68294
|
return [{ type: "session.updated", details: { sessionID: sessionId, turnId, turn: "starting" } }];
|
|
@@ -66918,7 +68310,7 @@ function projectBridgeEvent(frame, sessionId) {
|
|
|
66918
68310
|
return [];
|
|
66919
68311
|
}
|
|
66920
68312
|
function parseUsage(value) {
|
|
66921
|
-
const u =
|
|
68313
|
+
const u = asRecord10(value);
|
|
66922
68314
|
const num = (...aliases) => {
|
|
66923
68315
|
let present = false;
|
|
66924
68316
|
let best = 0;
|
|
@@ -66947,7 +68339,7 @@ function parseUsage(value) {
|
|
|
66947
68339
|
return out;
|
|
66948
68340
|
}
|
|
66949
68341
|
function journalUsage(payload) {
|
|
66950
|
-
const usage =
|
|
68342
|
+
const usage = asRecord10(asRecord10(payload).usage);
|
|
66951
68343
|
const parsed = parseUsage(usage);
|
|
66952
68344
|
if (Object.keys(parsed).length === 0)
|
|
66953
68345
|
return;
|
|
@@ -66957,7 +68349,7 @@ function journalUsage(payload) {
|
|
|
66957
68349
|
return { ...parsed, total };
|
|
66958
68350
|
}
|
|
66959
68351
|
function asDeadCause(value) {
|
|
66960
|
-
const r =
|
|
68352
|
+
const r = asRecord10(value);
|
|
66961
68353
|
const stage = r.stage;
|
|
66962
68354
|
const stages = ["spawn", "handshake", "runtime", "closed"];
|
|
66963
68355
|
return {
|
|
@@ -66978,10 +68370,36 @@ class BridgeSessionSeam {
|
|
|
66978
68370
|
#configStore;
|
|
66979
68371
|
#settingsStore;
|
|
66980
68372
|
#localAgents;
|
|
68373
|
+
#localPresets;
|
|
68374
|
+
#localLogin;
|
|
68375
|
+
#pluginBundlesCache = [];
|
|
68376
|
+
#pluginsManagerAvailable = undefined;
|
|
68377
|
+
#goalsAvailable = undefined;
|
|
66981
68378
|
settings = {
|
|
66982
68379
|
describe: () => Promise.resolve(this.#settingsStore.describe()),
|
|
66983
68380
|
mutate: (ns, ops, revision) => Promise.resolve(this.#settingsStore.mutate(ns, ops, revision)),
|
|
66984
|
-
identity: () => ({ profile: this.#profile, dshHome: this.#dshHome })
|
|
68381
|
+
identity: () => ({ profile: this.#profile, dshHome: this.#dshHome }),
|
|
68382
|
+
permissionCatalog: () => this.#readPermissionCatalog()
|
|
68383
|
+
};
|
|
68384
|
+
providerDirectory = {
|
|
68385
|
+
registered: () => this.#directoryRequest("llm.listProviders", projectLlmProviders),
|
|
68386
|
+
configurable: () => this.#directoryRequest("llm.listConfigurableProviders", projectConfigurableProviders),
|
|
68387
|
+
discover: (settingsNs, request) => this.#directoryRequest("llm.discoverModels", projectDiscoverModels, { settingsNs, request })
|
|
68388
|
+
};
|
|
68389
|
+
goals = {
|
|
68390
|
+
status: () => this.#goalsRequest("goals.get", {}, projectGoalView),
|
|
68391
|
+
available: () => this.#goalsAvailable === true,
|
|
68392
|
+
create: (objective, maxGoalRounds) => {
|
|
68393
|
+
const request = { objective };
|
|
68394
|
+
if (maxGoalRounds !== undefined)
|
|
68395
|
+
request.maxGoalRounds = maxGoalRounds;
|
|
68396
|
+
return this.#goalsRequest("goals.create", { request }, projectCreateGoalResult);
|
|
68397
|
+
},
|
|
68398
|
+
edit: (ref, patch) => this.#goalsRequest("goals.edit", { ref, request: patch }, projectGoalView),
|
|
68399
|
+
complete: (ref) => this.#goalsRequest("goals.complete", { ref }, projectGoalView),
|
|
68400
|
+
pause: (ref) => this.#goalsRequest("goals.pause", { ref }, projectGoalView),
|
|
68401
|
+
resume: (ref) => this.#goalsRequest("goals.resume", { ref }, projectGoalView),
|
|
68402
|
+
clear: (ref) => this.#goalsRequest("goals.clear", { ref }, projectGoalRef)
|
|
66985
68403
|
};
|
|
66986
68404
|
agents = {
|
|
66987
68405
|
list: () => this.#localAgents.list(),
|
|
@@ -66991,6 +68409,241 @@ class BridgeSessionSeam {
|
|
|
66991
68409
|
modelEfforts: (providerID, modelID) => this.#localAgents.modelEfforts(providerID, modelID),
|
|
66992
68410
|
officialCaps: () => this.#localAgents.officialCaps()
|
|
66993
68411
|
};
|
|
68412
|
+
preset = {
|
|
68413
|
+
list: () => Promise.resolve(this.#localPresets.list()),
|
|
68414
|
+
currentId: () => Promise.resolve(this.#localPresets.currentId()),
|
|
68415
|
+
select: (presetId) => Promise.resolve(this.#localPresets.select(presetId))
|
|
68416
|
+
};
|
|
68417
|
+
login = {
|
|
68418
|
+
credentialStatus: (ref) => Promise.resolve(this.#localLogin.credentialStatus(ref)),
|
|
68419
|
+
login: (ref, apiKey) => {
|
|
68420
|
+
this.#localLogin.login(ref, apiKey);
|
|
68421
|
+
return Promise.resolve();
|
|
68422
|
+
},
|
|
68423
|
+
logout: (ref) => {
|
|
68424
|
+
this.#localLogin.logout(ref);
|
|
68425
|
+
return Promise.resolve();
|
|
68426
|
+
},
|
|
68427
|
+
routes: () => Promise.resolve(this.#localLogin.routes()),
|
|
68428
|
+
registerRoute: (providerId, profile) => Promise.resolve(this.#localLogin.registerRoute(providerId, profile))
|
|
68429
|
+
};
|
|
68430
|
+
account = {
|
|
68431
|
+
getState: async () => projectSeamAccountView(await this.#transport.request("account.getState")),
|
|
68432
|
+
startSignIn: async (callbackOrigin, loginSource) => projectSeamAccountView(await this.#transport.request("account.startSignIn", { client: accountClientMeta(), callbackOrigin, loginSource })),
|
|
68433
|
+
cancelSignIn: async (attemptId) => projectSeamAccountView(await this.#transport.request("account.cancelSignIn", { attemptId })),
|
|
68434
|
+
signOut: async () => projectSeamAccountView(await this.#transport.request("account.signOut", { client: accountClientMeta() })),
|
|
68435
|
+
hasRunningAccountTasks: async () => {
|
|
68436
|
+
const value = asRecord10(await this.#transport.request("account.hasRunningAccountTasks"));
|
|
68437
|
+
return value.running === true;
|
|
68438
|
+
}
|
|
68439
|
+
};
|
|
68440
|
+
plugins() {
|
|
68441
|
+
const root = join16(this.#dshHome, "profiles", this.#profile, "node_modules");
|
|
68442
|
+
if (!existsSync13(root))
|
|
68443
|
+
return [];
|
|
68444
|
+
const out = [];
|
|
68445
|
+
const seen = new Set;
|
|
68446
|
+
const readPkg = (dir, fallbackName) => {
|
|
68447
|
+
try {
|
|
68448
|
+
const pkg = JSON.parse(readFileSync14(join16(dir, "package.json"), "utf8"));
|
|
68449
|
+
const name = typeof pkg.name === "string" && pkg.name ? pkg.name : fallbackName;
|
|
68450
|
+
const version = typeof pkg.version === "string" ? pkg.version : "";
|
|
68451
|
+
if (name.startsWith("@deepseek-ai/") || name.startsWith("@aiwayds/"))
|
|
68452
|
+
return;
|
|
68453
|
+
if (seen.has(name))
|
|
68454
|
+
return;
|
|
68455
|
+
seen.add(name);
|
|
68456
|
+
out.push({ name, version });
|
|
68457
|
+
} catch {}
|
|
68458
|
+
};
|
|
68459
|
+
let entries = [];
|
|
68460
|
+
try {
|
|
68461
|
+
entries = readdirSync4(root);
|
|
68462
|
+
} catch {
|
|
68463
|
+
return [];
|
|
68464
|
+
}
|
|
68465
|
+
for (const entry of entries) {
|
|
68466
|
+
if (entry.startsWith("."))
|
|
68467
|
+
continue;
|
|
68468
|
+
if (entry.startsWith("@")) {
|
|
68469
|
+
let scoped = [];
|
|
68470
|
+
try {
|
|
68471
|
+
scoped = readdirSync4(join16(root, entry));
|
|
68472
|
+
} catch {
|
|
68473
|
+
continue;
|
|
68474
|
+
}
|
|
68475
|
+
for (const sub of scoped) {
|
|
68476
|
+
if (sub.startsWith("."))
|
|
68477
|
+
continue;
|
|
68478
|
+
readPkg(join16(root, entry, sub), `${entry}/${sub}`);
|
|
68479
|
+
}
|
|
68480
|
+
} else {
|
|
68481
|
+
readPkg(join16(root, entry), entry);
|
|
68482
|
+
}
|
|
68483
|
+
}
|
|
68484
|
+
return out;
|
|
68485
|
+
}
|
|
68486
|
+
async#directoryRequest(method, project, params) {
|
|
68487
|
+
const reply = params === undefined ? await this.#transport.request(method) : await this.#transport.request(method, params);
|
|
68488
|
+
return project(reply);
|
|
68489
|
+
}
|
|
68490
|
+
async#readPermissionCatalog() {
|
|
68491
|
+
try {
|
|
68492
|
+
const reply = await this.#transport.request("permissionPresets.catalog");
|
|
68493
|
+
return projectPermissionCatalog(reply);
|
|
68494
|
+
} catch {
|
|
68495
|
+
return;
|
|
68496
|
+
}
|
|
68497
|
+
}
|
|
68498
|
+
async#goalsRequest(method, extraParams, project) {
|
|
68499
|
+
const agentId = this.currentSessionId();
|
|
68500
|
+
if (agentId === undefined || agentId === "") {
|
|
68501
|
+
throw new BridgeProtocolError("UNSUPPORTED", `${method}: no active session (agentId unavailable)`);
|
|
68502
|
+
}
|
|
68503
|
+
try {
|
|
68504
|
+
const reply = await this.#transport.request(method, { agentId, ...extraParams });
|
|
68505
|
+
this.#goalsAvailable = true;
|
|
68506
|
+
return project(reply);
|
|
68507
|
+
} catch (err) {
|
|
68508
|
+
const code = err instanceof BridgeProtocolError ? err.code : undefined;
|
|
68509
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
68510
|
+
const serviceAbsent = code === "UNSUPPORTED" || code === "NOT_WIRED" || code === "UNAVAILABLE" || code === undefined && (/^NOT_WIRED/.test(message) || /unavailable/i.test(message));
|
|
68511
|
+
if (serviceAbsent) {
|
|
68512
|
+
this.#goalsAvailable = false;
|
|
68513
|
+
throw new BridgeProtocolError("UNSUPPORTED", `${method}: ${message}`);
|
|
68514
|
+
}
|
|
68515
|
+
throw err;
|
|
68516
|
+
}
|
|
68517
|
+
}
|
|
68518
|
+
async#pmRequest(method, params, project) {
|
|
68519
|
+
try {
|
|
68520
|
+
const reply = await this.#transport.request(method, params);
|
|
68521
|
+
const projected = project(reply);
|
|
68522
|
+
this.#pluginsManagerAvailable = true;
|
|
68523
|
+
return projected;
|
|
68524
|
+
} catch (err) {
|
|
68525
|
+
const code = err instanceof BridgeProtocolError ? err.code : undefined;
|
|
68526
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
68527
|
+
const serviceAbsent = code === "UNSUPPORTED" || code === "NOT_WIRED" || code === "UNAVAILABLE" || code === undefined && (/^NOT_WIRED/.test(message) || /unavailable/i.test(message));
|
|
68528
|
+
if (serviceAbsent) {
|
|
68529
|
+
this.#pluginsManagerAvailable = false;
|
|
68530
|
+
throw new BridgeProtocolError("UNSUPPORTED", `${method}: ${message}`);
|
|
68531
|
+
}
|
|
68532
|
+
throw err;
|
|
68533
|
+
}
|
|
68534
|
+
}
|
|
68535
|
+
async#pmConfirmed(method, params, confirm, project) {
|
|
68536
|
+
if (!writeConfirmed(confirm))
|
|
68537
|
+
throw CONFIRM_REQUIRED(method);
|
|
68538
|
+
return this.#pmRequest(method, { ...params, __confirm: true }, project);
|
|
68539
|
+
}
|
|
68540
|
+
async#pmWrite(method, params, confirm, target) {
|
|
68541
|
+
const reply = await this.#pmConfirmed(method, params, confirm, projectChange);
|
|
68542
|
+
if (reply.target === "" && target !== "")
|
|
68543
|
+
reply.target = target;
|
|
68544
|
+
this.refreshPluginBundles();
|
|
68545
|
+
return reply;
|
|
68546
|
+
}
|
|
68547
|
+
pluginsManager = {
|
|
68548
|
+
listBundles: async () => {
|
|
68549
|
+
const rows = await this.#pmRequest("pluginManager.listBundles", {}, projectBundleRows);
|
|
68550
|
+
this.#pluginBundlesCache = rows;
|
|
68551
|
+
return rows;
|
|
68552
|
+
},
|
|
68553
|
+
listPlugins: async () => this.#pmRequest("pluginManager.listPlugins", {}, projectPluginRows),
|
|
68554
|
+
readBundleDetail: async (name, language) => this.#pmRequest("pluginManager.readBundleDetail", { name, language }, projectDetail),
|
|
68555
|
+
registries: async () => this.#pmRequest("pluginManager.registries", {}, projectRegistries),
|
|
68556
|
+
listVersions: async (name) => this.#pmRequest("pluginManager.listVersions", { name }, projectVersions),
|
|
68557
|
+
listVersionExemptions: async () => this.#pmRequest("pluginManager.listVersionExemptions", {}, projectVersionExemptions),
|
|
68558
|
+
inspect: async (spec) => this.#pmRequest("pluginManager.inspect", { spec }, projectInspection),
|
|
68559
|
+
available: () => this.#pluginsManagerAvailable
|
|
68560
|
+
};
|
|
68561
|
+
setPluginBundleEnabled = (name, enabled, confirm) => this.#pmWrite("pluginManager.setBundleEnabled", { name, enabled }, confirm, name);
|
|
68562
|
+
removePluginBundle = (name, confirm) => this.#pmWrite("pluginManager.removeBundle", { name }, confirm, name);
|
|
68563
|
+
inspectPluginSpec = (spec) => this.pluginsManager.inspect(spec);
|
|
68564
|
+
installPluginSpec = async (spec, confirm, requestIdArg) => {
|
|
68565
|
+
const requestId = requestIdArg ?? `w23-${randomUUID9()}`;
|
|
68566
|
+
const change = await this.#pmWrite("pluginManager.installBundle", { spec, options: { enabled: true, requestId } }, confirm, spec);
|
|
68567
|
+
change.requestId = requestId;
|
|
68568
|
+
return change;
|
|
68569
|
+
};
|
|
68570
|
+
updatePluginBundle = (name, version, confirm) => this.#pmWrite("pluginManager.updateBundle", { name, version, options: {} }, confirm, name);
|
|
68571
|
+
setPluginEnabled = (id, enabled, confirm) => this.#pmWrite("pluginManager.setPluginEnabled", { id, enabled }, confirm, id);
|
|
68572
|
+
setVersionExemption = (packageVersion, runtimeVersion, enabled, acceptRisk, confirm) => this.#pmWrite("pluginManager.setVersionExemption", { packageVersion, runtimeVersion, enabled, acceptRisk }, confirm, `${packageVersion}@${runtimeVersion}`);
|
|
68573
|
+
waitForInstall = (requestId, confirm) => this.#pmConfirmed("pluginManager.waitForInstall", { requestId }, confirm, (raw) => projectInstallProgress(raw, requestId));
|
|
68574
|
+
cancelInstall = (requestId, confirm) => this.#pmConfirmed("pluginManager.cancelInstall", { requestId }, confirm, projectCancellation);
|
|
68575
|
+
async refreshPluginBundles() {
|
|
68576
|
+
try {
|
|
68577
|
+
await this.pluginsManager.listBundles();
|
|
68578
|
+
} catch {}
|
|
68579
|
+
}
|
|
68580
|
+
pluginBundles() {
|
|
68581
|
+
if (this.#pluginsManagerAvailable === true)
|
|
68582
|
+
return [...this.#pluginBundlesCache];
|
|
68583
|
+
return this.plugins().map((row) => ({
|
|
68584
|
+
name: row.name,
|
|
68585
|
+
version: row.version,
|
|
68586
|
+
enabled: false,
|
|
68587
|
+
installed: true,
|
|
68588
|
+
optional: false,
|
|
68589
|
+
removable: false,
|
|
68590
|
+
stateUnknown: true
|
|
68591
|
+
}));
|
|
68592
|
+
}
|
|
68593
|
+
thinking = {
|
|
68594
|
+
efforts: () => this.#catalogEfforts(),
|
|
68595
|
+
effortsFor: (providerID, modelID) => this.#catalogEfforts(providerID, modelID),
|
|
68596
|
+
currentEffort: async () => {
|
|
68597
|
+
const selection = await this.#transport.request("model.currentSelection");
|
|
68598
|
+
const value = asRecord10(selection).reasoningEffort;
|
|
68599
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
68600
|
+
},
|
|
68601
|
+
selectEffort: async (effort) => {
|
|
68602
|
+
const selection = await this.currentModelSelection();
|
|
68603
|
+
if (selection === undefined)
|
|
68604
|
+
return unsupported("selectEffort");
|
|
68605
|
+
const sessionId = this.#currentSessionId ?? this.stagedSessionId();
|
|
68606
|
+
const reply = await this.#transport.request("selectModel", {
|
|
68607
|
+
provider: selection.providerID,
|
|
68608
|
+
model: selection.modelID,
|
|
68609
|
+
...effort === undefined ? {} : { reasoningEffort: effort },
|
|
68610
|
+
...sessionId !== undefined && sessionId !== "" ? { sessionId } : {}
|
|
68611
|
+
});
|
|
68612
|
+
const r = reply;
|
|
68613
|
+
if (r === undefined || r === null || r.selected === undefined) {
|
|
68614
|
+
return unsupported("selectEffort");
|
|
68615
|
+
}
|
|
68616
|
+
}
|
|
68617
|
+
};
|
|
68618
|
+
async#catalogEfforts(providerID, modelID) {
|
|
68619
|
+
const raw = await this.#transport.request("modelCatalog");
|
|
68620
|
+
if (raw === undefined || raw === null || !Array.isArray(raw.groups))
|
|
68621
|
+
return [];
|
|
68622
|
+
let group = raw.groups.find((g) => typeof g?.id === "string" && g.id === providerID);
|
|
68623
|
+
let model = group?.models?.find((m) => typeof m?.id === "string" && m.id === modelID);
|
|
68624
|
+
if (providerID === undefined || modelID === undefined) {
|
|
68625
|
+
const d = raw.default;
|
|
68626
|
+
group = raw.groups.find((g) => typeof g?.id === "string" && g.id === d?.provider) ?? raw.groups[0];
|
|
68627
|
+
model = group?.models?.find((m) => typeof m?.id === "string" && m.id === d?.model) ?? group?.models?.[0];
|
|
68628
|
+
}
|
|
68629
|
+
const efforts = model?.reasoning?.efforts;
|
|
68630
|
+
if (!Array.isArray(efforts))
|
|
68631
|
+
return [];
|
|
68632
|
+
const out = [];
|
|
68633
|
+
for (const e of efforts) {
|
|
68634
|
+
const row = asRecord10(e);
|
|
68635
|
+
const id = typeof row.id === "string" ? row.id : "";
|
|
68636
|
+
const name = typeof row.name === "string" ? row.name : "";
|
|
68637
|
+
if (!id)
|
|
68638
|
+
continue;
|
|
68639
|
+
out.push({
|
|
68640
|
+
id,
|
|
68641
|
+
name: name || id,
|
|
68642
|
+
...typeof row.description === "string" && row.description !== "" ? { description: row.description } : {}
|
|
68643
|
+
});
|
|
68644
|
+
}
|
|
68645
|
+
return out;
|
|
68646
|
+
}
|
|
66994
68647
|
#unsubEvent;
|
|
66995
68648
|
#listeners = [];
|
|
66996
68649
|
#onDead;
|
|
@@ -67001,6 +68654,7 @@ class BridgeSessionSeam {
|
|
|
67001
68654
|
#subagentSessionId;
|
|
67002
68655
|
#subagentJournalLoaded = new Set;
|
|
67003
68656
|
#subagentJournalMeta = new Map;
|
|
68657
|
+
#subagentTranscripts = new Map;
|
|
67004
68658
|
#sweepSettledRuns = new Map;
|
|
67005
68659
|
#subagentSettleSnapshots = new Map;
|
|
67006
68660
|
#interruptInFlight = new Map;
|
|
@@ -67018,6 +68672,8 @@ class BridgeSessionSeam {
|
|
|
67018
68672
|
#recoveryState = "idle";
|
|
67019
68673
|
#pendingOpen;
|
|
67020
68674
|
#inFlightTurnId;
|
|
68675
|
+
#sideSessionInFlight = false;
|
|
68676
|
+
#lastSideSessionId;
|
|
67021
68677
|
#activeCallbacks;
|
|
67022
68678
|
#turnDone;
|
|
67023
68679
|
#turnGeneration = 0;
|
|
@@ -67057,6 +68713,8 @@ class BridgeSessionSeam {
|
|
|
67057
68713
|
settings: this.#settingsStore,
|
|
67058
68714
|
modelCatalog: () => this.#transport.request("modelCatalog")
|
|
67059
68715
|
});
|
|
68716
|
+
this.#localPresets = new LocalPresetFace(this.#dshHome, this.#profile);
|
|
68717
|
+
this.#localLogin = new LocalLoginFace(this.#dshHome, this.#profile);
|
|
67060
68718
|
this.#onDead = options.onDead;
|
|
67061
68719
|
this.#onPermissionUnavailable = options.onPermissionUnavailable;
|
|
67062
68720
|
this.#confirmClock = options.confirmClock ?? {
|
|
@@ -67070,7 +68728,7 @@ class BridgeSessionSeam {
|
|
|
67070
68728
|
}
|
|
67071
68729
|
async connect() {
|
|
67072
68730
|
try {
|
|
67073
|
-
const reply =
|
|
68731
|
+
const reply = asRecord10(await this.#transport.request("bridge.ping"));
|
|
67074
68732
|
this.#recordBridgeCapabilities(reply.capabilities);
|
|
67075
68733
|
this.#connection = "connected";
|
|
67076
68734
|
} catch (err) {
|
|
@@ -67157,7 +68815,7 @@ class BridgeSessionSeam {
|
|
|
67157
68815
|
this.#replayDrainPending = true;
|
|
67158
68816
|
let opened;
|
|
67159
68817
|
try {
|
|
67160
|
-
opened =
|
|
68818
|
+
opened = asRecord10(await this.#transport.request("session.open", { mode: "resume", id: sessionId }));
|
|
67161
68819
|
} catch (err) {
|
|
67162
68820
|
const code = err instanceof BridgeProtocolError ? err.code : "SESSION_OPEN_FAILED";
|
|
67163
68821
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -67167,7 +68825,7 @@ class BridgeSessionSeam {
|
|
|
67167
68825
|
this.#bufferedPendingSnapshot = undefined;
|
|
67168
68826
|
this.#replayDrainPending = false;
|
|
67169
68827
|
this.#settleSuspendedTurn();
|
|
67170
|
-
const errorDetail = err instanceof BridgeProtocolError ?
|
|
68828
|
+
const errorDetail = err instanceof BridgeProtocolError ? asRecord10(err.detail) : {};
|
|
67171
68829
|
const holder = typeof errorDetail.holder === "string" && errorDetail.holder.trim() !== "" ? errorDetail.holder : undefined;
|
|
67172
68830
|
const result = {
|
|
67173
68831
|
state: "locked",
|
|
@@ -67242,7 +68900,7 @@ class BridgeSessionSeam {
|
|
|
67242
68900
|
turnId: dead.turnId,
|
|
67243
68901
|
seq: terminal.seq,
|
|
67244
68902
|
terminalType: terminal.type,
|
|
67245
|
-
reason:
|
|
68903
|
+
reason: asRecord10(terminal.payload).reason,
|
|
67246
68904
|
payload: terminal.payload,
|
|
67247
68905
|
source: "journal"
|
|
67248
68906
|
}
|
|
@@ -67300,7 +68958,7 @@ class BridgeSessionSeam {
|
|
|
67300
68958
|
const seen = new Set;
|
|
67301
68959
|
const collected = [];
|
|
67302
68960
|
for (;; ) {
|
|
67303
|
-
const value =
|
|
68961
|
+
const value = asRecord10(await this.#transport.request("journal.replay", { sessionId, from }));
|
|
67304
68962
|
const rawRows = Array.isArray(value.rows) ? value.rows : [];
|
|
67305
68963
|
if (typeof value.cursor === "number" && Number.isFinite(value.cursor))
|
|
67306
68964
|
cursor = value.cursor;
|
|
@@ -67313,7 +68971,7 @@ class BridgeSessionSeam {
|
|
|
67313
68971
|
let added = 0;
|
|
67314
68972
|
let pageMax = from - 1;
|
|
67315
68973
|
for (const raw of rawRows) {
|
|
67316
|
-
const row =
|
|
68974
|
+
const row = asRecord10(raw);
|
|
67317
68975
|
const seq = row.seq;
|
|
67318
68976
|
if (typeof seq !== "number" || !Number.isFinite(seq) || seq < floor || seen.has(seq))
|
|
67319
68977
|
continue;
|
|
@@ -67362,7 +69020,7 @@ class BridgeSessionSeam {
|
|
|
67362
69020
|
};
|
|
67363
69021
|
const attempt = (remaining) => {
|
|
67364
69022
|
this.#transport.request("turn.abort", { turnId }).then((result) => {
|
|
67365
|
-
if (
|
|
69023
|
+
if (asRecord10(result).noop === true) {
|
|
67366
69024
|
fail(`turn.abort was a noop for turn ${turnId}; turn may still be running`, "TURN_ABORT_NOOP");
|
|
67367
69025
|
}
|
|
67368
69026
|
}).catch((err) => {
|
|
@@ -67498,7 +69156,7 @@ class BridgeSessionSeam {
|
|
|
67498
69156
|
stats.contextTokens = usage.total;
|
|
67499
69157
|
}
|
|
67500
69158
|
} else if (row.type === "request/context") {
|
|
67501
|
-
const data =
|
|
69159
|
+
const data = asRecord10(row.payload);
|
|
67502
69160
|
const window = data.contextWindow;
|
|
67503
69161
|
if (typeof window === "number" && Number.isFinite(window) && window > 0) {
|
|
67504
69162
|
const provider = typeof data.provider === "string" ? data.provider : "";
|
|
@@ -67604,6 +69262,24 @@ class BridgeSessionSeam {
|
|
|
67604
69262
|
subagentViews() {
|
|
67605
69263
|
return [...this.#subagentViews.values()].map((view) => ({ ...view }));
|
|
67606
69264
|
}
|
|
69265
|
+
subagentTranscript(id) {
|
|
69266
|
+
return [...this.#subagentTranscripts.get(id) ?? []];
|
|
69267
|
+
}
|
|
69268
|
+
steerChild(id, text) {
|
|
69269
|
+
const view = this.#subagentViews.get(id);
|
|
69270
|
+
if (view === undefined || view.status !== "running")
|
|
69271
|
+
return false;
|
|
69272
|
+
const requestId = `${id}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
69273
|
+
this.#transport.request("subagents.prompt", {
|
|
69274
|
+
requestId,
|
|
69275
|
+
childSessionId: id,
|
|
69276
|
+
delivery: "steer",
|
|
69277
|
+
content: [{ type: "text", text }]
|
|
69278
|
+
}).catch((err) => {
|
|
69279
|
+
this.#degrade("steerChild", `subagents.prompt failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
69280
|
+
});
|
|
69281
|
+
return true;
|
|
69282
|
+
}
|
|
67607
69283
|
async interruptChild(childId) {
|
|
67608
69284
|
const parentSessionId = this.#currentSessionId;
|
|
67609
69285
|
if (parentSessionId === undefined || parentSessionId === "") {
|
|
@@ -67614,7 +69290,7 @@ class BridgeSessionSeam {
|
|
|
67614
69290
|
this.#interruptInFlight.set(childId, generation);
|
|
67615
69291
|
let value;
|
|
67616
69292
|
try {
|
|
67617
|
-
value =
|
|
69293
|
+
value = asRecord10(await this.#transport.request("subagents.interrupt", { parentSessionId, childId }));
|
|
67618
69294
|
} catch (err) {
|
|
67619
69295
|
if (this.#interruptInFlight.get(childId) === generation)
|
|
67620
69296
|
this.#interruptInFlight.delete(childId);
|
|
@@ -67640,13 +69316,13 @@ class BridgeSessionSeam {
|
|
|
67640
69316
|
if (parentSessionId === undefined || parentSessionId === "") {
|
|
67641
69317
|
throw new BridgeProtocolError("NO_SESSION", "cannot stop children: no session is bound to this bridge connection");
|
|
67642
69318
|
}
|
|
67643
|
-
const value =
|
|
69319
|
+
const value = asRecord10(await this.#transport.request("subagents.stopChildren", { parentSessionId }));
|
|
67644
69320
|
const children = value.children;
|
|
67645
69321
|
if (!Array.isArray(children))
|
|
67646
69322
|
return [];
|
|
67647
69323
|
const sessionAtStart = this.#subagentSessionId;
|
|
67648
69324
|
const rows = children.map((row) => {
|
|
67649
|
-
const r =
|
|
69325
|
+
const r = asRecord10(row);
|
|
67650
69326
|
return {
|
|
67651
69327
|
childId: typeof r.childId === "string" ? r.childId : "",
|
|
67652
69328
|
disposition: typeof r.disposition === "string" ? r.disposition : "failed"
|
|
@@ -67672,10 +69348,10 @@ class BridgeSessionSeam {
|
|
|
67672
69348
|
return;
|
|
67673
69349
|
let stopped = false;
|
|
67674
69350
|
try {
|
|
67675
|
-
const items =
|
|
69351
|
+
const items = asRecord10(await this.#transport.request("session.list", { _request: {} })).items;
|
|
67676
69352
|
if (Array.isArray(items)) {
|
|
67677
69353
|
stopped = items.some((row) => {
|
|
67678
|
-
const item =
|
|
69354
|
+
const item = asRecord10(row);
|
|
67679
69355
|
return item.sessionId === childId && item.running === false;
|
|
67680
69356
|
});
|
|
67681
69357
|
}
|
|
@@ -67685,7 +69361,7 @@ class BridgeSessionSeam {
|
|
|
67685
69361
|
if (stopped) {
|
|
67686
69362
|
let reason = "aborted";
|
|
67687
69363
|
try {
|
|
67688
|
-
const rows =
|
|
69364
|
+
const rows = asRecord10(await this.#transport.request("journal.replay", { sessionId: childId })).rows;
|
|
67689
69365
|
if (Array.isArray(rows)) {
|
|
67690
69366
|
const clean = rows.filter((row) => row !== null && typeof row === "object" && !Array.isArray(row));
|
|
67691
69367
|
reason = bridgeChildStopReason(clean) ?? "aborted";
|
|
@@ -67744,7 +69420,7 @@ class BridgeSessionSeam {
|
|
|
67744
69420
|
} catch {
|
|
67745
69421
|
return;
|
|
67746
69422
|
}
|
|
67747
|
-
const items =
|
|
69423
|
+
const items = asRecord10(value).items;
|
|
67748
69424
|
if (!Array.isArray(items))
|
|
67749
69425
|
return;
|
|
67750
69426
|
const locallyRunning = new Set;
|
|
@@ -67789,7 +69465,7 @@ class BridgeSessionSeam {
|
|
|
67789
69465
|
this.#subagentJournalLoaded.add(key);
|
|
67790
69466
|
const sessionAtStart = this.#subagentSessionId;
|
|
67791
69467
|
try {
|
|
67792
|
-
const value =
|
|
69468
|
+
const value = asRecord10(await this.#transport.request("journal.replay", { sessionId: childId }));
|
|
67793
69469
|
const rows = value.rows;
|
|
67794
69470
|
if (!Array.isArray(rows))
|
|
67795
69471
|
return;
|
|
@@ -67797,6 +69473,7 @@ class BridgeSessionSeam {
|
|
|
67797
69473
|
const meta = bridgeChildJournalMeta(cleanRows);
|
|
67798
69474
|
if (this.#subagentSessionId !== sessionAtStart || this.#disposed)
|
|
67799
69475
|
return;
|
|
69476
|
+
this.#subagentTranscripts.set(childId, bridgeReplayRowsToChildLog(cleanRows));
|
|
67800
69477
|
this.#subagentJournalMeta.set(key, meta);
|
|
67801
69478
|
const existing = this.#subagentViews.get(childId);
|
|
67802
69479
|
if (existing === undefined || bridgeChildJournalKey(existing) !== key)
|
|
@@ -67895,7 +69572,7 @@ class BridgeSessionSeam {
|
|
|
67895
69572
|
}
|
|
67896
69573
|
}
|
|
67897
69574
|
#foldAgentFrame(frame) {
|
|
67898
|
-
const payload =
|
|
69575
|
+
const payload = asRecord10(frame.payload);
|
|
67899
69576
|
const frameSession = typeof payload.sessionId === "string" ? payload.sessionId : "";
|
|
67900
69577
|
if (this.#subagentSessionId !== undefined && frameSession !== "" && frameSession !== this.#subagentSessionId)
|
|
67901
69578
|
return;
|
|
@@ -67921,6 +69598,7 @@ class BridgeSessionSeam {
|
|
|
67921
69598
|
this.#subagentLiveStarts.clear();
|
|
67922
69599
|
this.#subagentJournalLoaded.clear();
|
|
67923
69600
|
this.#subagentJournalMeta.clear();
|
|
69601
|
+
this.#subagentTranscripts.clear();
|
|
67924
69602
|
this.#sweepSettledRuns.clear();
|
|
67925
69603
|
this.#subagentSettleSnapshots.clear();
|
|
67926
69604
|
this.#interruptInFlight.clear();
|
|
@@ -67931,7 +69609,7 @@ class BridgeSessionSeam {
|
|
|
67931
69609
|
let changed = false;
|
|
67932
69610
|
const now = Date.now();
|
|
67933
69611
|
for (const row of rows) {
|
|
67934
|
-
if (this.#foldWithFrozenSettle(row.type,
|
|
69612
|
+
if (this.#foldWithFrozenSettle(row.type, asRecord10(row.payload), now, false))
|
|
67935
69613
|
changed = true;
|
|
67936
69614
|
}
|
|
67937
69615
|
if (rosterReset || changed) {
|
|
@@ -67965,20 +69643,41 @@ class BridgeSessionSeam {
|
|
|
67965
69643
|
}
|
|
67966
69644
|
async listSessions(limit) {
|
|
67967
69645
|
const value = await this.#transport.request("session.list");
|
|
67968
|
-
return projectBridgeSessionList(
|
|
69646
|
+
return projectBridgeSessionList(asRecord10(value).items, limit);
|
|
67969
69647
|
}
|
|
67970
69648
|
async storedTranscript(id, skip = 0) {
|
|
67971
69649
|
const value = await this.#transport.request("journal.replay", { sessionId: id });
|
|
67972
|
-
const rows = Array.isArray(
|
|
69650
|
+
const rows = Array.isArray(asRecord10(value).rows) ? asRecord10(value).rows : [];
|
|
67973
69651
|
this.#foldAgentReplayRows(rows, id);
|
|
67974
69652
|
this.#sweepSubagents(id);
|
|
67975
69653
|
return bridgeReplayRowsToSeamTranscript(rows, skip);
|
|
67976
69654
|
}
|
|
69655
|
+
async sessionJournal(id) {
|
|
69656
|
+
const value = await this.#transport.request("journal.replay", { sessionId: id });
|
|
69657
|
+
const rows = Array.isArray(asRecord10(value).rows) ? asRecord10(value).rows : [];
|
|
69658
|
+
return rows.map((row) => ({
|
|
69659
|
+
type: row.type,
|
|
69660
|
+
seq: row.seq,
|
|
69661
|
+
time: 0,
|
|
69662
|
+
data: asRecord10(row.payload)
|
|
69663
|
+
}));
|
|
69664
|
+
}
|
|
69665
|
+
async forkSession(sessionId, seqEnd) {
|
|
69666
|
+
const value = asRecord10(await this.#transport.request("session.fork", {
|
|
69667
|
+
sessionId,
|
|
69668
|
+
...seqEnd !== undefined ? { atSeq: seqEnd } : {}
|
|
69669
|
+
}));
|
|
69670
|
+
const forked = value.sessionId;
|
|
69671
|
+
if (typeof forked !== "string" || forked === "") {
|
|
69672
|
+
throw new BridgeProtocolError("FORK_FAILED", "/history fork: session.fork returned no session id");
|
|
69673
|
+
}
|
|
69674
|
+
return forked;
|
|
69675
|
+
}
|
|
67977
69676
|
async currentModelSelection() {
|
|
67978
69677
|
const selection = await this.#transport.request("model.currentSelection");
|
|
67979
69678
|
if (selection === undefined || selection === null)
|
|
67980
69679
|
return;
|
|
67981
|
-
const s =
|
|
69680
|
+
const s = asRecord10(selection);
|
|
67982
69681
|
const providerID = typeof s.provider === "string" ? s.provider : "";
|
|
67983
69682
|
const modelID = typeof s.model === "string" ? s.model : "";
|
|
67984
69683
|
if (!providerID || !modelID)
|
|
@@ -68015,7 +69714,7 @@ class BridgeSessionSeam {
|
|
|
68015
69714
|
this.#pendingOpen = undefined;
|
|
68016
69715
|
const params = pending.mode === "resume" ? { mode: "resume", id: pending.id, ...this.#sessionAttached ? { replace: true } : {} } : { mode: "new", ...this.#sessionAttached ? { replace: true } : {} };
|
|
68017
69716
|
try {
|
|
68018
|
-
const opened =
|
|
69717
|
+
const opened = asRecord10(await this.#transport.request("session.open", params));
|
|
68019
69718
|
if (typeof opened.sessionId === "string")
|
|
68020
69719
|
this.#currentSessionId = opened.sessionId;
|
|
68021
69720
|
if (this.#lastAppliedSessionId !== this.#currentSessionId) {
|
|
@@ -68032,7 +69731,7 @@ class BridgeSessionSeam {
|
|
|
68032
69731
|
const done = new Promise((resolve) => {
|
|
68033
69732
|
this.#turnDone = resolve;
|
|
68034
69733
|
});
|
|
68035
|
-
const sent =
|
|
69734
|
+
const sent = asRecord10(await this.#transport.request("session.send", { text: userText }));
|
|
68036
69735
|
if (typeof sent.turnId === "string") {
|
|
68037
69736
|
this.#inFlightTurnId = sent.turnId;
|
|
68038
69737
|
this.#emitEvent({
|
|
@@ -68096,8 +69795,44 @@ class BridgeSessionSeam {
|
|
|
68096
69795
|
this.#sessionAttached = false;
|
|
68097
69796
|
this.#currentSessionId = undefined;
|
|
68098
69797
|
}
|
|
68099
|
-
async
|
|
68100
|
-
|
|
69798
|
+
async btwAsk(question, snapshot, onDelta) {
|
|
69799
|
+
if (this.#sideSessionInFlight) {
|
|
69800
|
+
throw new BridgeProtocolError("SIDE_SESSION_BUSY", "/btw: a side question is already running");
|
|
69801
|
+
}
|
|
69802
|
+
this.#sideSessionInFlight = true;
|
|
69803
|
+
try {
|
|
69804
|
+
const result = await runSideSession({
|
|
69805
|
+
rpc: (method, params) => this.#transport.request(method, params),
|
|
69806
|
+
question,
|
|
69807
|
+
snapshot,
|
|
69808
|
+
onDelta,
|
|
69809
|
+
...this.#lastSideSessionId !== undefined ? { sessionId: this.#lastSideSessionId } : {}
|
|
69810
|
+
});
|
|
69811
|
+
this.#lastSideSessionId = result.sessionId;
|
|
69812
|
+
if (result.answer === "") {
|
|
69813
|
+
throw new BridgeProtocolError("SIDE_SESSION_NO_ANSWER", `/btw: side-session produced no answer (${result.reason})${result.truncated ? ", truncated" : ""}`);
|
|
69814
|
+
}
|
|
69815
|
+
return result.answer;
|
|
69816
|
+
} catch (err) {
|
|
69817
|
+
if (err instanceof SideSessionError) {
|
|
69818
|
+
const code = err.code === "SIDE_SESSION_UNAVAILABLE" ? "UNSUPPORTED" : err.code;
|
|
69819
|
+
throw new BridgeProtocolError(code, err.message);
|
|
69820
|
+
}
|
|
69821
|
+
throw err;
|
|
69822
|
+
} finally {
|
|
69823
|
+
this.#sideSessionInFlight = false;
|
|
69824
|
+
}
|
|
69825
|
+
}
|
|
69826
|
+
async searchSessions(query) {
|
|
69827
|
+
const value = asRecord10(await this.#transport.request("session.search", { query }));
|
|
69828
|
+
const rows = Array.isArray(value.items) ? value.items : [];
|
|
69829
|
+
return rows.map((row) => {
|
|
69830
|
+
const r = asRecord10(row);
|
|
69831
|
+
return {
|
|
69832
|
+
id: typeof r.id === "string" ? r.id : "",
|
|
69833
|
+
snippet: typeof r.snippet === "string" ? r.snippet : ""
|
|
69834
|
+
};
|
|
69835
|
+
}).filter((row) => row.id);
|
|
68101
69836
|
}
|
|
68102
69837
|
async renameSession(_title) {
|
|
68103
69838
|
return unsupported("renameSession");
|
|
@@ -68273,7 +70008,7 @@ class BridgeSessionSeam {
|
|
|
68273
70008
|
this.#settlePendingAsk(eventId);
|
|
68274
70009
|
}
|
|
68275
70010
|
#onAskEvent(frame) {
|
|
68276
|
-
const payload =
|
|
70011
|
+
const payload = asRecord10(frame.payload);
|
|
68277
70012
|
if (frame.type === "ask.request" || frame.type === "ask.pending")
|
|
68278
70013
|
this.#askFrameSeen = true;
|
|
68279
70014
|
switch (frame.type) {
|
|
@@ -68333,7 +70068,7 @@ class BridgeSessionSeam {
|
|
|
68333
70068
|
#onCapPushEvent(frame) {
|
|
68334
70069
|
if (frame.type !== "cap.event" && frame.type !== "cap.end")
|
|
68335
70070
|
return false;
|
|
68336
|
-
const payload =
|
|
70071
|
+
const payload = asRecord10(frame.payload);
|
|
68337
70072
|
const sessionId = optionalStringField(payload, "sessionId");
|
|
68338
70073
|
if (sessionId === undefined || sessionId === "")
|
|
68339
70074
|
return true;
|
|
@@ -68407,7 +70142,7 @@ class BridgeSessionSeam {
|
|
|
68407
70142
|
}
|
|
68408
70143
|
return;
|
|
68409
70144
|
}
|
|
68410
|
-
const payload =
|
|
70145
|
+
const payload = asRecord10(frame.payload);
|
|
68411
70146
|
if (frame.type === "turn.start") {
|
|
68412
70147
|
this.#turn = "starting";
|
|
68413
70148
|
this.#decodeWindowStart = undefined;
|
|
@@ -68488,14 +70223,16 @@ class BridgeSessionSeam {
|
|
|
68488
70223
|
}
|
|
68489
70224
|
}
|
|
68490
70225
|
}
|
|
68491
|
-
var BridgeProtocolError, BRIDGE_AGENT_START = "tool-workflow/agent-start", BRIDGE_AGENT_END = "tool-workflow/agent-end", BRIDGE_SUBAGENT_CATALOG = "subagent/catalog", BRIDGE_SUBAGENT_SETTLED = "subagent-settled", BRIDGE_CATALOG_RUN_PREFIX = "catalog:", CONFIRM_POLL_INITIAL_MS = 250, CONFIRM_POLL_MAX_MS = 1000, CONFIRM_TIMEOUT_MS = 45000, fmtTokens = (n) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`;
|
|
70226
|
+
var CONFIRM_REQUIRED = (method) => new BridgeProtocolError("CONFIRM_REQUIRED", `${method}: write requires a confirmed TUI modal token`), BridgeProtocolError, ACCOUNT_STATUSES, ACCOUNT_PHASES, BRIDGE_AGENT_START = "tool-workflow/agent-start", BRIDGE_AGENT_END = "tool-workflow/agent-end", BRIDGE_SUBAGENT_CATALOG = "subagent/catalog", BRIDGE_SUBAGENT_SETTLED = "subagent-settled", BRIDGE_CATALOG_RUN_PREFIX = "catalog:", CONFIRM_POLL_INITIAL_MS = 250, CONFIRM_POLL_MAX_MS = 1000, CONFIRM_TIMEOUT_MS = 45000, fmtTokens = (n) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`;
|
|
68492
70227
|
var init_bridge_session_seam = __esm(() => {
|
|
68493
70228
|
init_remote_session_ops();
|
|
68494
70229
|
init_journal_projection();
|
|
70230
|
+
init_bridge_side_session();
|
|
68495
70231
|
init_loop();
|
|
68496
70232
|
init_local_config_faces();
|
|
68497
70233
|
init_remote_local_fs();
|
|
68498
70234
|
init_lifecycle();
|
|
70235
|
+
init_bridge_goals();
|
|
68499
70236
|
BridgeProtocolError = class BridgeProtocolError extends Error {
|
|
68500
70237
|
code;
|
|
68501
70238
|
detail;
|
|
@@ -68507,6 +70244,17 @@ var init_bridge_session_seam = __esm(() => {
|
|
|
68507
70244
|
this.detail = detail;
|
|
68508
70245
|
}
|
|
68509
70246
|
};
|
|
70247
|
+
ACCOUNT_STATUSES = new Set(["signed-out", "credential-stored"]);
|
|
70248
|
+
ACCOUNT_PHASES = new Set([
|
|
70249
|
+
"initializing",
|
|
70250
|
+
"waiting-browser",
|
|
70251
|
+
"exchanging",
|
|
70252
|
+
"committing",
|
|
70253
|
+
"succeeded",
|
|
70254
|
+
"cancelled",
|
|
70255
|
+
"expired",
|
|
70256
|
+
"failed"
|
|
70257
|
+
]);
|
|
68510
70258
|
});
|
|
68511
70259
|
|
|
68512
70260
|
// scripts/lib/bridge-failfast-text.mjs
|
|
@@ -68613,11 +70361,11 @@ function toBridgeBootstrapError(err, fallbackCode = "BRIDGE_HANDSHAKE_FAILED") {
|
|
|
68613
70361
|
const message = err instanceof Error ? err.message : String(err);
|
|
68614
70362
|
return new BridgeBootstrapError({ code: fallbackCode, diagnosis: `bridge handshake failed: ${message}` });
|
|
68615
70363
|
}
|
|
68616
|
-
function
|
|
70364
|
+
function asRecord11(value) {
|
|
68617
70365
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
68618
70366
|
}
|
|
68619
70367
|
function verifyBridgeFingerprint(hello, expectedProtocolVersion = BRIDGE_PROTOCOL_VERSION) {
|
|
68620
|
-
const h =
|
|
70368
|
+
const h = asRecord11(hello);
|
|
68621
70369
|
const protocolVersion = h.protocolVersion;
|
|
68622
70370
|
if (protocolVersion !== expectedProtocolVersion) {
|
|
68623
70371
|
throw new BridgeBootstrapError({
|
|
@@ -68720,16 +70468,16 @@ var init_seam_bootstrap = __esm(() => {
|
|
|
68720
70468
|
});
|
|
68721
70469
|
|
|
68722
70470
|
// ../tui-base/examples/v2-entry.tsx
|
|
68723
|
-
import { join as
|
|
68724
|
-
import { existsSync as
|
|
70471
|
+
import { join as join17 } from "path";
|
|
70472
|
+
import { existsSync as existsSync14 } from "fs";
|
|
68725
70473
|
function resolveWatchdogScript() {
|
|
68726
70474
|
const candidates = [
|
|
68727
|
-
|
|
68728
|
-
|
|
68729
|
-
|
|
70475
|
+
join17(import.meta.dir, "..", "watchdog.mjs"),
|
|
70476
|
+
join17(import.meta.dir, "..", "..", "shell", "dist", "watchdog.mjs"),
|
|
70477
|
+
join17(import.meta.dir, "..", "..", "..", "shell", "dist", "watchdog.mjs")
|
|
68730
70478
|
];
|
|
68731
70479
|
for (const candidate of candidates)
|
|
68732
|
-
if (
|
|
70480
|
+
if (existsSync14(candidate))
|
|
68733
70481
|
return candidate;
|
|
68734
70482
|
return null;
|
|
68735
70483
|
}
|
|
@@ -69543,8 +71291,8 @@ async function bootClientV2(options = {}) {
|
|
|
69543
71291
|
agentsHome: agentsHomeForSkills
|
|
69544
71292
|
});
|
|
69545
71293
|
const skillsManagerRoots = {
|
|
69546
|
-
source:
|
|
69547
|
-
curated:
|
|
71294
|
+
source: join17(agentsHomeForSkills, "skills"),
|
|
71295
|
+
curated: join17(host.dshHome, "skills")
|
|
69548
71296
|
};
|
|
69549
71297
|
const envTheme = process.env[shared.ENV_THEME];
|
|
69550
71298
|
const workspaceConfig = seam.workspaceConfig?.() ?? {};
|
|
@@ -69757,7 +71505,7 @@ var init_v2_entry = __esm(() => {
|
|
|
69757
71505
|
// src/client/bridge-transport.ts
|
|
69758
71506
|
import { spawn as nodeSpawn2 } from "child_process";
|
|
69759
71507
|
import { homedir as homedir9 } from "os";
|
|
69760
|
-
import { join as
|
|
71508
|
+
import { join as join18 } from "path";
|
|
69761
71509
|
function recoveryCause(err, phase) {
|
|
69762
71510
|
if (err instanceof BridgeBootstrapError) {
|
|
69763
71511
|
return {
|
|
@@ -69770,7 +71518,7 @@ function recoveryCause(err, phase) {
|
|
|
69770
71518
|
};
|
|
69771
71519
|
}
|
|
69772
71520
|
if (err instanceof BridgeProtocolError && err.code === "BRIDGE_DEAD") {
|
|
69773
|
-
const detail =
|
|
71521
|
+
const detail = asRecord12(err.detail);
|
|
69774
71522
|
return {
|
|
69775
71523
|
stage: phase,
|
|
69776
71524
|
code: typeof detail.code === "number" ? detail.code : null,
|
|
@@ -69821,7 +71569,7 @@ class StdioBridgeTransport {
|
|
|
69821
71569
|
#spawn() {
|
|
69822
71570
|
if (this.#child !== undefined)
|
|
69823
71571
|
return this.#child;
|
|
69824
|
-
const dshHome = this.#opts.dshHome ?? process.env.DSH_HOME ??
|
|
71572
|
+
const dshHome = this.#opts.dshHome ?? process.env.DSH_HOME ?? join18(homedir9(), ".dsh");
|
|
69825
71573
|
const env = {
|
|
69826
71574
|
...process.env,
|
|
69827
71575
|
...this.#opts.env ?? {},
|
|
@@ -69885,7 +71633,7 @@ class StdioBridgeTransport {
|
|
|
69885
71633
|
} catch {
|
|
69886
71634
|
return;
|
|
69887
71635
|
}
|
|
69888
|
-
const rec =
|
|
71636
|
+
const rec = asRecord12(frame);
|
|
69889
71637
|
if (typeof rec.id === "number") {
|
|
69890
71638
|
const pending = this.#pending.get(rec.id);
|
|
69891
71639
|
if (pending === undefined)
|
|
@@ -69897,7 +71645,7 @@ class StdioBridgeTransport {
|
|
|
69897
71645
|
this.#setState("ready");
|
|
69898
71646
|
pending.resolve(rec.result);
|
|
69899
71647
|
} else {
|
|
69900
|
-
const error =
|
|
71648
|
+
const error = asRecord12(rec.error);
|
|
69901
71649
|
pending.reject(new BridgeProtocolError(typeof error.code === "string" ? error.code : "BRIDGE_ERROR", typeof error.message === "string" ? error.message : "bridge request failed", error.detail));
|
|
69902
71650
|
}
|
|
69903
71651
|
return;
|
|
@@ -70029,7 +71777,7 @@ class StdioBridgeTransport {
|
|
|
70029
71777
|
} catch {}
|
|
70030
71778
|
}
|
|
70031
71779
|
}
|
|
70032
|
-
var
|
|
71780
|
+
var asRecord12 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
70033
71781
|
var init_bridge_transport = __esm(() => {
|
|
70034
71782
|
init_bridge_session_seam();
|
|
70035
71783
|
init_seam_bootstrap();
|
|
@@ -70042,16 +71790,16 @@ init_boot_shared();
|
|
|
70042
71790
|
init_lifecycle();
|
|
70043
71791
|
init_transport();
|
|
70044
71792
|
init_remote_host_session();
|
|
70045
|
-
import { existsSync as
|
|
70046
|
-
import { join as
|
|
71793
|
+
import { existsSync as existsSync15 } from "fs";
|
|
71794
|
+
import { join as join19 } from "path";
|
|
70047
71795
|
function resolveWatchdogScript2() {
|
|
70048
71796
|
const candidates = [
|
|
70049
|
-
|
|
70050
|
-
|
|
70051
|
-
|
|
71797
|
+
join19(import.meta.dir, "..", "watchdog.mjs"),
|
|
71798
|
+
join19(import.meta.dir, "..", "dist", "watchdog.mjs"),
|
|
71799
|
+
join19(import.meta.dir, "..", "scripts", "watchdog.mjs")
|
|
70052
71800
|
];
|
|
70053
71801
|
for (const candidate of candidates) {
|
|
70054
|
-
if (
|
|
71802
|
+
if (existsSync15(candidate))
|
|
70055
71803
|
return candidate;
|
|
70056
71804
|
}
|
|
70057
71805
|
return null;
|
|
@@ -70222,5 +71970,5 @@ export {
|
|
|
70222
71970
|
themeNameFromConfig
|
|
70223
71971
|
};
|
|
70224
71972
|
|
|
70225
|
-
//# debugId=
|
|
71973
|
+
//# debugId=D9F1F54DB3A9E37E64756E2164756E21
|
|
70226
71974
|
//# sourceMappingURL=index.js.map
|