@aiwayds/dsh-opentui 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/README.md +148 -53
- package/dist/bridge/bundle-fingerprint.json +1 -1
- package/dist/bridge/index.js +1849 -29
- package/dist/client/index.js +2107 -187
- package/dist/client/index.js.map +19 -12
- package/dist/host-launch.mjs.map +2 -2
- package/dist/locales/en.json +98 -0
- package/dist/locales/zh-CN.json +98 -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
|
}
|
|
@@ -55055,6 +55154,29 @@ function presetLabelFor(rows, currentId) {
|
|
|
55055
55154
|
const marked = rows.find((row) => row.isDefault) ?? rows.find((row) => row.id === "standard");
|
|
55056
55155
|
return (marked ?? rows[0])?.name;
|
|
55057
55156
|
}
|
|
55157
|
+
function isRiskPermissionPreset(value, name) {
|
|
55158
|
+
return /danger-full-access|full.?access|auto/i.test(`${value} ${name ?? ""}`);
|
|
55159
|
+
}
|
|
55160
|
+
function cwdBasename(cwd) {
|
|
55161
|
+
if (cwd === undefined || cwd === "")
|
|
55162
|
+
return;
|
|
55163
|
+
const trimmed = cwd.replace(/[\\/]+$/, "");
|
|
55164
|
+
if (trimmed === "")
|
|
55165
|
+
return cwd;
|
|
55166
|
+
const parts = trimmed.split(/[\\/]/);
|
|
55167
|
+
return parts[parts.length - 1] || trimmed;
|
|
55168
|
+
}
|
|
55169
|
+
function permissionCatalogLines(catalog) {
|
|
55170
|
+
const names = catalog.options.map((option) => option.value).join(", ");
|
|
55171
|
+
const lines = [`available presets: ${names}`];
|
|
55172
|
+
for (const option of catalog.options) {
|
|
55173
|
+
const detail = option.description === undefined || option.description === "" ? "" : ` \u2014 ${option.description}`;
|
|
55174
|
+
lines.push(`${option.value}${detail}`);
|
|
55175
|
+
}
|
|
55176
|
+
lines.push(`default preset: ${catalog.defaultPreset}`);
|
|
55177
|
+
lines.push("current session preset is host-authoritative (not readable here); use /permission <preset> to set it");
|
|
55178
|
+
return lines;
|
|
55179
|
+
}
|
|
55058
55180
|
function loginStepTitle(stepTitle, error) {
|
|
55059
55181
|
return error ? `${stepTitle} \u2014 ${error}` : stepTitle;
|
|
55060
55182
|
}
|
|
@@ -55109,6 +55231,30 @@ async function offerCorruptedLogRepair(ctx, sessionId, broken) {
|
|
|
55109
55231
|
}
|
|
55110
55232
|
return true;
|
|
55111
55233
|
}
|
|
55234
|
+
async function resolveLoginCatalog(seam, say) {
|
|
55235
|
+
const dir = seam.providerDirectory;
|
|
55236
|
+
if (!dir)
|
|
55237
|
+
return { entries: [...PROVIDER_CATALOG], degraded: false };
|
|
55238
|
+
let registered = [];
|
|
55239
|
+
let configurable = [];
|
|
55240
|
+
let failed = false;
|
|
55241
|
+
try {
|
|
55242
|
+
registered = await dir.registered();
|
|
55243
|
+
} catch {
|
|
55244
|
+
failed = true;
|
|
55245
|
+
}
|
|
55246
|
+
try {
|
|
55247
|
+
configurable = await dir.configurable();
|
|
55248
|
+
} catch {
|
|
55249
|
+
failed = true;
|
|
55250
|
+
}
|
|
55251
|
+
const real = catalogEntriesFromDirectory(registered, configurable);
|
|
55252
|
+
if (real.length === 0)
|
|
55253
|
+
return { entries: [...PROVIDER_CATALOG], degraded: true };
|
|
55254
|
+
if (failed)
|
|
55255
|
+
say(t("command.login.directoryPartial"));
|
|
55256
|
+
return { entries: real, degraded: false };
|
|
55257
|
+
}
|
|
55112
55258
|
async function commitCatalogLogin(ctx, face, entry) {
|
|
55113
55259
|
const key = await ctx.promptText?.(`API key for ${entry.name} (${deriveKeyRef(entry.id)})`, { mask: true });
|
|
55114
55260
|
if (key === undefined)
|
|
@@ -55202,6 +55348,30 @@ function coreCommands() {
|
|
|
55202
55348
|
ctx.say(t("command.model.stagedSwitchFailed", { reason: pendingSelectionError }));
|
|
55203
55349
|
}
|
|
55204
55350
|
const arg = argText.trim();
|
|
55351
|
+
if (arg === "discover") {
|
|
55352
|
+
const discover = ctx.seam.providerDirectory?.discover;
|
|
55353
|
+
if (typeof discover !== "function") {
|
|
55354
|
+
ctx.say(t("command.model.discoverUnavailable", { reason: "no discovery face" }));
|
|
55355
|
+
return;
|
|
55356
|
+
}
|
|
55357
|
+
let providerID = "default";
|
|
55358
|
+
try {
|
|
55359
|
+
providerID = (await ctx.seam.currentModelSelection?.())?.providerID ?? "default";
|
|
55360
|
+
} catch {}
|
|
55361
|
+
ctx.say(t("command.model.discovering", { provider: providerID }));
|
|
55362
|
+
try {
|
|
55363
|
+
const models = await discover("llm", { provider: providerID });
|
|
55364
|
+
if (models.length === 0) {
|
|
55365
|
+
ctx.say(t("command.model.discoverEmpty"));
|
|
55366
|
+
return;
|
|
55367
|
+
}
|
|
55368
|
+
const list = formatDiscoveredModels(models);
|
|
55369
|
+
ctx.say(t("command.model.discovered", { n: models.length, list }));
|
|
55370
|
+
} catch (error) {
|
|
55371
|
+
ctx.say(t("command.model.discoverUnavailable", { reason: seamFailureReason(error) }));
|
|
55372
|
+
}
|
|
55373
|
+
return;
|
|
55374
|
+
}
|
|
55205
55375
|
if (arg) {
|
|
55206
55376
|
const [providerID, modelID] = arg.split("/");
|
|
55207
55377
|
if (!providerID || !modelID) {
|
|
@@ -55344,9 +55514,12 @@ function coreCommands() {
|
|
|
55344
55514
|
ctx.say(t("command.login.unavailable"));
|
|
55345
55515
|
return;
|
|
55346
55516
|
}
|
|
55517
|
+
const { entries, degraded } = await resolveLoginCatalog(ctx.seam, ctx.say);
|
|
55518
|
+
if (degraded)
|
|
55519
|
+
ctx.say(t("command.login.directoryDegraded"));
|
|
55347
55520
|
const arg = argText.trim().toLowerCase();
|
|
55348
55521
|
if (arg) {
|
|
55349
|
-
const entry =
|
|
55522
|
+
const entry = entries.find((e) => e.id === arg);
|
|
55350
55523
|
if (!entry) {
|
|
55351
55524
|
ctx.say(t("command.login.unknownProvider", { provider: arg }));
|
|
55352
55525
|
return;
|
|
@@ -55354,7 +55527,7 @@ function coreCommands() {
|
|
|
55354
55527
|
await commitCatalogLogin(ctx, face, entry);
|
|
55355
55528
|
return;
|
|
55356
55529
|
}
|
|
55357
|
-
const picked = await ctx.pickOne(LOGIN_PICKER_TITLE, [CUSTOM_ENTRY, ...
|
|
55530
|
+
const picked = await ctx.pickOne(LOGIN_PICKER_TITLE, [CUSTOM_ENTRY, ...entries].map((e) => ({ title: e.name, value: e.id, description: e.hint })));
|
|
55358
55531
|
if (!picked)
|
|
55359
55532
|
return;
|
|
55360
55533
|
if (picked === CUSTOM_ENTRY.id) {
|
|
@@ -55362,7 +55535,7 @@ function coreCommands() {
|
|
|
55362
55535
|
await runCustomLoginChain(ctx, face, routes);
|
|
55363
55536
|
return;
|
|
55364
55537
|
}
|
|
55365
|
-
const entry =
|
|
55538
|
+
const entry = entries.find((e) => e.id === picked);
|
|
55366
55539
|
if (!entry)
|
|
55367
55540
|
return;
|
|
55368
55541
|
await commitCatalogLogin(ctx, face, entry);
|
|
@@ -55543,6 +55716,71 @@ function coreCommands() {
|
|
|
55543
55716
|
ctx.say(t("command.plugins.entry", { name: plugin.name, version: plugin.version }));
|
|
55544
55717
|
}
|
|
55545
55718
|
},
|
|
55719
|
+
{
|
|
55720
|
+
name: "/goals",
|
|
55721
|
+
description: t("command.goals.description"),
|
|
55722
|
+
async run(ctx, argText) {
|
|
55723
|
+
const goals = ctx.seam.goals;
|
|
55724
|
+
if (!goals) {
|
|
55725
|
+
ctx.say(t("command.goals.unavailable"));
|
|
55726
|
+
return;
|
|
55727
|
+
}
|
|
55728
|
+
const unknownOp = goalsUnknownOp(argText);
|
|
55729
|
+
if (unknownOp !== undefined)
|
|
55730
|
+
ctx.say(goalsUnknownOpHint(unknownOp));
|
|
55731
|
+
const op = parseGoalsArgs(argText);
|
|
55732
|
+
if (op.kind === "status") {
|
|
55733
|
+
try {
|
|
55734
|
+
const view = await goals.status();
|
|
55735
|
+
if (view === undefined) {
|
|
55736
|
+
ctx.say(t("command.goals.none"));
|
|
55737
|
+
return;
|
|
55738
|
+
}
|
|
55739
|
+
for (const line of formatGoalStatus(view))
|
|
55740
|
+
ctx.say(line);
|
|
55741
|
+
} catch {
|
|
55742
|
+
ctx.say(t("command.goals.degraded"));
|
|
55743
|
+
}
|
|
55744
|
+
return;
|
|
55745
|
+
}
|
|
55746
|
+
let objective = op.kind === "create" || op.kind === "edit" ? op.objective : "";
|
|
55747
|
+
if ((op.kind === "create" || op.kind === "edit") && objective === "" && ctx.promptText) {
|
|
55748
|
+
const answer = await ctx.promptText(t("command.goals.prompt.objective"));
|
|
55749
|
+
objective = (answer ?? "").trim();
|
|
55750
|
+
}
|
|
55751
|
+
if ((op.kind === "create" || op.kind === "edit") && objective === "") {
|
|
55752
|
+
ctx.say(t("command.goals.aborted"));
|
|
55753
|
+
return;
|
|
55754
|
+
}
|
|
55755
|
+
const confirmed = ctx.pickOne ? await ctx.pickOne(goalsConfirmTitle(op), goalsConfirmOptions()) === "yes" : false;
|
|
55756
|
+
if (!confirmed) {
|
|
55757
|
+
ctx.say(t("command.goals.aborted"));
|
|
55758
|
+
return;
|
|
55759
|
+
}
|
|
55760
|
+
try {
|
|
55761
|
+
if (op.kind === "create") {
|
|
55762
|
+
const ref = await goals.create(objective);
|
|
55763
|
+
ctx.say(ref ? t("command.goals.created", { id: ref.id, revision: ref.revision }) : t("command.goals.failed"));
|
|
55764
|
+
} else {
|
|
55765
|
+
const view = await goals.status();
|
|
55766
|
+
if (view === undefined) {
|
|
55767
|
+
ctx.say(t("command.goals.none"));
|
|
55768
|
+
return;
|
|
55769
|
+
}
|
|
55770
|
+
const ref = { id: view.id, revision: view.revision };
|
|
55771
|
+
if (op.kind === "edit") {
|
|
55772
|
+
const edited = await goals.edit(ref, { objective });
|
|
55773
|
+
ctx.say(edited ? t("command.goals.edited") : t("command.goals.failed"));
|
|
55774
|
+
} else {
|
|
55775
|
+
const changed = await goals[op.kind](ref);
|
|
55776
|
+
ctx.say(changed ? t("command.goals.updated", { op: op.kind }) : t("command.goals.failed"));
|
|
55777
|
+
}
|
|
55778
|
+
}
|
|
55779
|
+
} catch {
|
|
55780
|
+
ctx.say(t("command.goals.degraded"));
|
|
55781
|
+
}
|
|
55782
|
+
}
|
|
55783
|
+
},
|
|
55546
55784
|
{
|
|
55547
55785
|
name: "/skills",
|
|
55548
55786
|
description: t("command.skills.description"),
|
|
@@ -55912,6 +56150,120 @@ function coreCommands() {
|
|
|
55912
56150
|
];
|
|
55913
56151
|
ctx.say(t("command.stop.done", { parts: parts.join(", ") }));
|
|
55914
56152
|
}
|
|
56153
|
+
},
|
|
56154
|
+
{
|
|
56155
|
+
name: "/account",
|
|
56156
|
+
description: t("command.account.description"),
|
|
56157
|
+
async run(ctx, argText) {
|
|
56158
|
+
const face = ctx.seam.account;
|
|
56159
|
+
if (!face) {
|
|
56160
|
+
ctx.say(t("command.account.unavailable"));
|
|
56161
|
+
return;
|
|
56162
|
+
}
|
|
56163
|
+
const show = (state) => {
|
|
56164
|
+
ctx.say(t("command.account.state", {
|
|
56165
|
+
status: state.status ?? "\u2014",
|
|
56166
|
+
phase: state.attemptPhase ?? "\u2014",
|
|
56167
|
+
urlReady: state.authorizeUrlReady ? "\u2713" : "\u2014",
|
|
56168
|
+
links: state.linksPresent ? "\u2713" : "\u2014"
|
|
56169
|
+
}));
|
|
56170
|
+
};
|
|
56171
|
+
const arg = argText.trim().toLowerCase();
|
|
56172
|
+
try {
|
|
56173
|
+
if (!arg || arg === "state") {
|
|
56174
|
+
show(await face.getState());
|
|
56175
|
+
} else if (arg === "signin") {
|
|
56176
|
+
show(await face.startSignIn("http://localhost", "desktop"));
|
|
56177
|
+
} else if (arg === "signout") {
|
|
56178
|
+
show(await face.signOut());
|
|
56179
|
+
} else {
|
|
56180
|
+
ctx.say(t("command.account.unknownAction", { action: argText.trim() }));
|
|
56181
|
+
}
|
|
56182
|
+
} catch (error) {
|
|
56183
|
+
ctx.say(t("command.account.failed", { reason: seamFailureReason(error) }));
|
|
56184
|
+
}
|
|
56185
|
+
}
|
|
56186
|
+
},
|
|
56187
|
+
{
|
|
56188
|
+
name: "/permission",
|
|
56189
|
+
description: t("command.permission.description"),
|
|
56190
|
+
async run(ctx, argText) {
|
|
56191
|
+
const face = ctx.seam.permission;
|
|
56192
|
+
if (!face) {
|
|
56193
|
+
ctx.say(t("command.permission.unavailable"));
|
|
56194
|
+
return;
|
|
56195
|
+
}
|
|
56196
|
+
let catalog;
|
|
56197
|
+
try {
|
|
56198
|
+
catalog = await face.catalog();
|
|
56199
|
+
} catch {
|
|
56200
|
+
catalog = undefined;
|
|
56201
|
+
}
|
|
56202
|
+
if (catalog === undefined) {
|
|
56203
|
+
ctx.say(t("command.permission.catalogUnavailable"));
|
|
56204
|
+
return;
|
|
56205
|
+
}
|
|
56206
|
+
const arg = argText.trim();
|
|
56207
|
+
if (arg === "") {
|
|
56208
|
+
for (const line of permissionCatalogLines(catalog))
|
|
56209
|
+
ctx.say(line);
|
|
56210
|
+
return;
|
|
56211
|
+
}
|
|
56212
|
+
const target = catalog.options.find((option) => option.value === arg || option.name === arg);
|
|
56213
|
+
if (target === undefined) {
|
|
56214
|
+
const names = catalog.options.map((option) => option.value).join(", ");
|
|
56215
|
+
ctx.say(t("command.permission.unknown", { name: arg, available: names }));
|
|
56216
|
+
return;
|
|
56217
|
+
}
|
|
56218
|
+
if (isRiskPermissionPreset(target.value, target.name)) {
|
|
56219
|
+
const verdict = await ctx.pickOne(t("command.permission.riskTitle", { name: target.value }), [
|
|
56220
|
+
{ title: t("command.permission.riskAck"), value: "ack" },
|
|
56221
|
+
{ title: t("command.permission.cancel"), value: "cancel" }
|
|
56222
|
+
]);
|
|
56223
|
+
if (verdict !== "ack") {
|
|
56224
|
+
ctx.say(t("command.permission.cancelled"));
|
|
56225
|
+
return;
|
|
56226
|
+
}
|
|
56227
|
+
}
|
|
56228
|
+
try {
|
|
56229
|
+
const result = await face.switch(target.value);
|
|
56230
|
+
if (!result.matched) {
|
|
56231
|
+
ctx.say(t("command.permission.noCommand"));
|
|
56232
|
+
return;
|
|
56233
|
+
}
|
|
56234
|
+
if (!result.ok) {
|
|
56235
|
+
ctx.say(t("command.permission.failed", { reason: result.text || "error" }));
|
|
56236
|
+
return;
|
|
56237
|
+
}
|
|
56238
|
+
ctx.say(t("command.permission.set", { name: target.value }));
|
|
56239
|
+
if (result.text !== "")
|
|
56240
|
+
ctx.say(result.text);
|
|
56241
|
+
await ctx.reload();
|
|
56242
|
+
} catch (error) {
|
|
56243
|
+
ctx.say(t("command.permission.failed", { reason: seamFailureReason(error) }));
|
|
56244
|
+
}
|
|
56245
|
+
}
|
|
56246
|
+
},
|
|
56247
|
+
{
|
|
56248
|
+
name: "/cwd",
|
|
56249
|
+
description: t("command.cwd.description"),
|
|
56250
|
+
async run(ctx) {
|
|
56251
|
+
if (!ctx.seam.cwd) {
|
|
56252
|
+
ctx.say(t("command.cwd.unavailable"));
|
|
56253
|
+
return;
|
|
56254
|
+
}
|
|
56255
|
+
try {
|
|
56256
|
+
const cwd = await ctx.seam.cwd();
|
|
56257
|
+
const label = cwdBasename(cwd);
|
|
56258
|
+
if (label === undefined) {
|
|
56259
|
+
ctx.say(t("command.cwd.none"));
|
|
56260
|
+
return;
|
|
56261
|
+
}
|
|
56262
|
+
ctx.say(t("command.cwd.current", { cwd: label }));
|
|
56263
|
+
} catch (error) {
|
|
56264
|
+
ctx.say(t("command.cwd.failed", { reason: seamFailureReason(error) }));
|
|
56265
|
+
}
|
|
56266
|
+
}
|
|
55915
56267
|
}
|
|
55916
56268
|
];
|
|
55917
56269
|
}
|
|
@@ -55939,6 +56291,7 @@ var MODEL_DEFAULT_EFFORT_PICK = "__model_default__";
|
|
|
55939
56291
|
var init_commands = __esm(() => {
|
|
55940
56292
|
init_i18n();
|
|
55941
56293
|
init_hotkeys();
|
|
56294
|
+
init_goals_command();
|
|
55942
56295
|
init_login();
|
|
55943
56296
|
init_hints_line();
|
|
55944
56297
|
init_motion();
|
|
@@ -57570,6 +57923,11 @@ var init_sessions_search = __esm(() => {
|
|
|
57570
57923
|
sessionsSearchOpen = panelOpen3;
|
|
57571
57924
|
});
|
|
57572
57925
|
|
|
57926
|
+
// ../tui-base/src/seams/session.ts
|
|
57927
|
+
function createPluginWriteConfirm(operation) {
|
|
57928
|
+
return { __pluginWriteConfirm: true, operation };
|
|
57929
|
+
}
|
|
57930
|
+
|
|
57573
57931
|
// ../tui-base/src/routes/session/plugins-panel.tsx
|
|
57574
57932
|
import { TextAttributes as TextAttributes10 } from "@opentui/core";
|
|
57575
57933
|
function openPluginsPanel() {
|
|
@@ -57592,6 +57950,8 @@ function filterPluginRows(rows, query) {
|
|
|
57592
57950
|
return rows.filter((row) => formatPluginLine(row).toLowerCase().includes(needle));
|
|
57593
57951
|
}
|
|
57594
57952
|
function bundleStateText(row) {
|
|
57953
|
+
if (row.stateUnknown === true)
|
|
57954
|
+
return t("panel.plugins.state.unknown");
|
|
57595
57955
|
const base = !row.installed && row.optional ? t("panel.plugins.state.available") : row.enabled ? t("panel.plugins.state.on") : t("panel.plugins.state.off");
|
|
57596
57956
|
if (row.error !== undefined && row.error !== "")
|
|
57597
57957
|
return t("panel.plugins.state.error", {
|
|
@@ -57612,9 +57972,10 @@ function pluginBundleViews(bundles) {
|
|
|
57612
57972
|
installed: bundle.installed === true,
|
|
57613
57973
|
optional: bundle.optional === true,
|
|
57614
57974
|
removable: bundle.removable === true,
|
|
57615
|
-
toggleable: bundle.readOnlyReason === undefined && (bundle.error === undefined || bundle.error === ""),
|
|
57975
|
+
toggleable: bundle.stateUnknown !== true && bundle.readOnlyReason === undefined && (bundle.error === undefined || bundle.error === ""),
|
|
57616
57976
|
readOnlyReason: bundle.readOnlyReason,
|
|
57617
|
-
error: bundle.error
|
|
57977
|
+
error: bundle.error,
|
|
57978
|
+
stateUnknown: bundle.stateUnknown
|
|
57618
57979
|
}));
|
|
57619
57980
|
}
|
|
57620
57981
|
function legacyPluginViews(rows) {
|
|
@@ -57664,6 +58025,72 @@ function installPreviewLine(inspection) {
|
|
|
57664
58025
|
spec
|
|
57665
58026
|
}) : spec;
|
|
57666
58027
|
}
|
|
58028
|
+
function writeConfirmObject(operation, target) {
|
|
58029
|
+
return t("panel.plugins.confirm.object", {
|
|
58030
|
+
operation: t(`panel.plugins.confirm.op.${operation}`),
|
|
58031
|
+
target
|
|
58032
|
+
});
|
|
58033
|
+
}
|
|
58034
|
+
function writeConfirmConsequence(operation) {
|
|
58035
|
+
return t(`panel.plugins.confirm.consequence.${operation}`);
|
|
58036
|
+
}
|
|
58037
|
+
function installProgressLine(progress) {
|
|
58038
|
+
switch (progress.state) {
|
|
58039
|
+
case "running":
|
|
58040
|
+
return t("panel.plugins.progress.running");
|
|
58041
|
+
case "cancelled":
|
|
58042
|
+
return t("panel.plugins.progress.cancelled", {
|
|
58043
|
+
target: progress.target || progress.requestId
|
|
58044
|
+
});
|
|
58045
|
+
case "failed":
|
|
58046
|
+
return t("panel.plugins.progress.failed", {
|
|
58047
|
+
target: progress.target || progress.requestId,
|
|
58048
|
+
error: progress.error ?? "?"
|
|
58049
|
+
});
|
|
58050
|
+
case "done":
|
|
58051
|
+
return t("panel.plugins.progress.done", {
|
|
58052
|
+
target: progress.target || progress.requestId
|
|
58053
|
+
});
|
|
58054
|
+
case "unknown":
|
|
58055
|
+
return t("panel.plugins.progress.unknown");
|
|
58056
|
+
}
|
|
58057
|
+
}
|
|
58058
|
+
async function pollInstallFace(wait, requestId, confirm, emit, stop, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))) {
|
|
58059
|
+
for (let tick = 0;tick < PROGRESS_POLL_MAX_TICKS; tick++) {
|
|
58060
|
+
if (stop())
|
|
58061
|
+
return;
|
|
58062
|
+
let progress;
|
|
58063
|
+
try {
|
|
58064
|
+
progress = await wait(requestId, confirm);
|
|
58065
|
+
} catch {
|
|
58066
|
+
return;
|
|
58067
|
+
}
|
|
58068
|
+
if (stop())
|
|
58069
|
+
return;
|
|
58070
|
+
emit(progress);
|
|
58071
|
+
if (progress.state !== "running")
|
|
58072
|
+
return;
|
|
58073
|
+
await sleep(PROGRESS_POLL_INTERVAL_MS);
|
|
58074
|
+
}
|
|
58075
|
+
}
|
|
58076
|
+
function pluginDetailPreview(detail, loading) {
|
|
58077
|
+
if (loading)
|
|
58078
|
+
return t("panel.plugins.detail.loading");
|
|
58079
|
+
if (detail === undefined)
|
|
58080
|
+
return t("panel.plugins.detail.unavailable");
|
|
58081
|
+
if (detail.status === "none")
|
|
58082
|
+
return t("panel.plugins.detail.none");
|
|
58083
|
+
const lines = detail.markdown.split(`
|
|
58084
|
+
`).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#"));
|
|
58085
|
+
const preview = lines.slice(0, 2).join(" ").slice(0, 180);
|
|
58086
|
+
return preview === "" ? t("panel.plugins.detail.none") : preview;
|
|
58087
|
+
}
|
|
58088
|
+
function createDegradedMemo(available, refreshTick) {
|
|
58089
|
+
return createMemo(() => {
|
|
58090
|
+
refreshTick();
|
|
58091
|
+
return available() === false;
|
|
58092
|
+
});
|
|
58093
|
+
}
|
|
57667
58094
|
function PluginsPanel(props) {
|
|
57668
58095
|
const theme = useThemeOptional();
|
|
57669
58096
|
const dialog = useDialog();
|
|
@@ -57676,8 +58103,18 @@ function PluginsPanel(props) {
|
|
|
57676
58103
|
const [status, setStatus] = createSignal(undefined);
|
|
57677
58104
|
const [installOpen, setInstallOpen] = createSignal(false);
|
|
57678
58105
|
const [installText, setInstallText] = createSignal("");
|
|
58106
|
+
const [detail, setDetail] = createSignal(undefined);
|
|
58107
|
+
const [detailLoading, setDetailLoading] = createSignal(false);
|
|
58108
|
+
const [refreshTick, setRefreshTick] = createSignal(0);
|
|
58109
|
+
const [installProgress, setInstallProgress] = createSignal(undefined);
|
|
58110
|
+
const [cancelArmed, setCancelArmed] = createSignal(false);
|
|
57679
58111
|
let statusTimer;
|
|
57680
|
-
|
|
58112
|
+
let progressTimer;
|
|
58113
|
+
onCleanup(() => {
|
|
58114
|
+
clearTimeout(statusTimer);
|
|
58115
|
+
if (progressTimer !== undefined)
|
|
58116
|
+
clearInterval(progressTimer);
|
|
58117
|
+
});
|
|
57681
58118
|
createEffect(() => {
|
|
57682
58119
|
if (bridgeOpen3()) {
|
|
57683
58120
|
setBridgeOpen3(false);
|
|
@@ -57686,7 +58123,12 @@ function PluginsPanel(props) {
|
|
|
57686
58123
|
setInstallOpen(false);
|
|
57687
58124
|
setInstallText("");
|
|
57688
58125
|
setCursor(0);
|
|
58126
|
+
setDetail(undefined);
|
|
57689
58127
|
setOpen(true);
|
|
58128
|
+
const seam = props.seam;
|
|
58129
|
+
if (typeof seam.refreshPluginBundles === "function") {
|
|
58130
|
+
seam.refreshPluginBundles().then(() => setRefreshTick((n) => n + 1)).catch(() => setRefreshTick((n) => n + 1));
|
|
58131
|
+
}
|
|
57690
58132
|
}
|
|
57691
58133
|
});
|
|
57692
58134
|
function flash(message, autoClearMs) {
|
|
@@ -57712,6 +58154,7 @@ function PluginsPanel(props) {
|
|
|
57712
58154
|
}
|
|
57713
58155
|
const bundles = createMemo(() => {
|
|
57714
58156
|
open();
|
|
58157
|
+
refreshTick();
|
|
57715
58158
|
try {
|
|
57716
58159
|
const seam = props.seam;
|
|
57717
58160
|
if (typeof seam.pluginBundles === "function")
|
|
@@ -57729,6 +58172,32 @@ function PluginsPanel(props) {
|
|
|
57729
58172
|
return rows[Math.min(cursor(), rows.length - 1)];
|
|
57730
58173
|
});
|
|
57731
58174
|
const cursorIndex = createMemo(() => visible().slice(0, 12).indexOf(current()));
|
|
58175
|
+
createEffect(() => {
|
|
58176
|
+
const row = current();
|
|
58177
|
+
const manager = props.seam.pluginsManager;
|
|
58178
|
+
if (row === undefined || typeof manager?.readBundleDetail !== "function" || manager.available?.() !== true) {
|
|
58179
|
+
setDetail(undefined);
|
|
58180
|
+
setDetailLoading(false);
|
|
58181
|
+
return;
|
|
58182
|
+
}
|
|
58183
|
+
const name = row.name;
|
|
58184
|
+
let stale = false;
|
|
58185
|
+
onCleanup(() => {
|
|
58186
|
+
stale = true;
|
|
58187
|
+
});
|
|
58188
|
+
setDetailLoading(true);
|
|
58189
|
+
manager.readBundleDetail(name, "en").then((d) => {
|
|
58190
|
+
if (!stale)
|
|
58191
|
+
setDetail(d);
|
|
58192
|
+
}).catch(() => {
|
|
58193
|
+
if (!stale)
|
|
58194
|
+
setDetail(undefined);
|
|
58195
|
+
}).finally(() => {
|
|
58196
|
+
if (!stale)
|
|
58197
|
+
setDetailLoading(false);
|
|
58198
|
+
});
|
|
58199
|
+
});
|
|
58200
|
+
const degraded = createDegradedMemo(() => props.seam.pluginsManager?.available?.(), refreshTick);
|
|
57732
58201
|
function moveCursor(delta) {
|
|
57733
58202
|
const count = visible().length;
|
|
57734
58203
|
if (count === 0)
|
|
@@ -57736,12 +58205,16 @@ function PluginsPanel(props) {
|
|
|
57736
58205
|
const next = Math.max(0, Math.min(cursor() + delta, count - 1));
|
|
57737
58206
|
setCursor(next);
|
|
57738
58207
|
}
|
|
57739
|
-
|
|
57740
|
-
if (row === undefined)
|
|
58208
|
+
function toggle(row) {
|
|
58209
|
+
if (row === undefined || busy())
|
|
57741
58210
|
return;
|
|
57742
|
-
if (
|
|
58211
|
+
if (typeof props.seam.setPluginBundleEnabled !== "function") {
|
|
58212
|
+
flash(t("panel.plugins.status.toggleUnavailable", {
|
|
58213
|
+
name: row.name
|
|
58214
|
+
}), 4000);
|
|
57743
58215
|
return;
|
|
57744
|
-
|
|
58216
|
+
}
|
|
58217
|
+
if (!row.toggleable) {
|
|
57745
58218
|
flash(row.readOnlyReason ? t("panel.plugins.status.readOnlyReason", {
|
|
57746
58219
|
name: row.name,
|
|
57747
58220
|
reason: row.readOnlyReason
|
|
@@ -57750,18 +58223,45 @@ function PluginsPanel(props) {
|
|
|
57750
58223
|
}), 4000);
|
|
57751
58224
|
return;
|
|
57752
58225
|
}
|
|
58226
|
+
const name = row.name;
|
|
58227
|
+
const enabled = !row.enabled;
|
|
58228
|
+
const operation = "setBundleEnabled";
|
|
58229
|
+
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
58230
|
+
get title() {
|
|
58231
|
+
return t("panel.plugins.dialog.actionTitle", {
|
|
58232
|
+
operation: t(`panel.plugins.confirm.op.${operation}`)
|
|
58233
|
+
});
|
|
58234
|
+
},
|
|
58235
|
+
get message() {
|
|
58236
|
+
return `${writeConfirmObject(operation, name)}
|
|
58237
|
+
${writeConfirmConsequence(operation)}`;
|
|
58238
|
+
},
|
|
58239
|
+
get label() {
|
|
58240
|
+
return {
|
|
58241
|
+
confirm: t("panel.plugins.dialog.actionConfirm"),
|
|
58242
|
+
cancel: t("panel.plugins.dialog.cancel")
|
|
58243
|
+
};
|
|
58244
|
+
},
|
|
58245
|
+
onConfirm: () => void toggleApply(name, enabled, operation)
|
|
58246
|
+
}), undefined, {
|
|
58247
|
+
tone: "warning"
|
|
58248
|
+
});
|
|
58249
|
+
}
|
|
58250
|
+
async function toggleApply(name, enabled, operation) {
|
|
58251
|
+
if (busy())
|
|
58252
|
+
return;
|
|
58253
|
+
if (typeof props.seam.setPluginBundleEnabled !== "function")
|
|
58254
|
+
return;
|
|
57753
58255
|
setBusy(true);
|
|
57754
|
-
flash(
|
|
57755
|
-
name
|
|
57756
|
-
}) : t("panel.plugins.status.enabling", {
|
|
57757
|
-
name: row.name
|
|
58256
|
+
flash(t(enabled ? "panel.plugins.status.enabling" : "panel.plugins.status.disabling", {
|
|
58257
|
+
name
|
|
57758
58258
|
}));
|
|
57759
58259
|
try {
|
|
57760
|
-
const change = await props.seam.setPluginBundleEnabled(
|
|
58260
|
+
const change = await props.seam.setPluginBundleEnabled(name, enabled, createPluginWriteConfirm(operation));
|
|
57761
58261
|
flash(pluginChangeNotice(change), 6000);
|
|
57762
58262
|
} catch (error) {
|
|
57763
58263
|
flash(t("panel.plugins.status.changeFailed", {
|
|
57764
|
-
name
|
|
58264
|
+
name,
|
|
57765
58265
|
error: errorMessage2(error)
|
|
57766
58266
|
}), 8000);
|
|
57767
58267
|
} finally {
|
|
@@ -57778,6 +58278,11 @@ function PluginsPanel(props) {
|
|
|
57778
58278
|
return;
|
|
57779
58279
|
}
|
|
57780
58280
|
const name = row.name;
|
|
58281
|
+
const operation = "removeBundle";
|
|
58282
|
+
const dryRun = t("panel.plugins.dryRun.remove", {
|
|
58283
|
+
name,
|
|
58284
|
+
version: row.version || "?"
|
|
58285
|
+
});
|
|
57781
58286
|
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
57782
58287
|
get title() {
|
|
57783
58288
|
return t("panel.plugins.dialog.uninstallTitle", {
|
|
@@ -57785,9 +58290,9 @@ function PluginsPanel(props) {
|
|
|
57785
58290
|
});
|
|
57786
58291
|
},
|
|
57787
58292
|
get message() {
|
|
57788
|
-
return
|
|
57789
|
-
|
|
57790
|
-
|
|
58293
|
+
return `${writeConfirmObject(operation, name)}
|
|
58294
|
+
${writeConfirmConsequence(operation)}
|
|
58295
|
+
${dryRun}`;
|
|
57791
58296
|
},
|
|
57792
58297
|
get label() {
|
|
57793
58298
|
return {
|
|
@@ -57795,12 +58300,12 @@ function PluginsPanel(props) {
|
|
|
57795
58300
|
cancel: t("panel.plugins.dialog.keep")
|
|
57796
58301
|
};
|
|
57797
58302
|
},
|
|
57798
|
-
onConfirm: () => void remove(name)
|
|
58303
|
+
onConfirm: () => void remove(name, operation)
|
|
57799
58304
|
}), undefined, {
|
|
57800
58305
|
tone: "warning"
|
|
57801
58306
|
});
|
|
57802
58307
|
}
|
|
57803
|
-
async function remove(name) {
|
|
58308
|
+
async function remove(name, operation) {
|
|
57804
58309
|
if (busy())
|
|
57805
58310
|
return;
|
|
57806
58311
|
if (typeof props.seam.removePluginBundle !== "function")
|
|
@@ -57810,7 +58315,7 @@ function PluginsPanel(props) {
|
|
|
57810
58315
|
name
|
|
57811
58316
|
}));
|
|
57812
58317
|
try {
|
|
57813
|
-
const change = await props.seam.removePluginBundle(name);
|
|
58318
|
+
const change = await props.seam.removePluginBundle(name, createPluginWriteConfirm(operation));
|
|
57814
58319
|
flash(pluginChangeNotice(change), 8000);
|
|
57815
58320
|
} catch (error) {
|
|
57816
58321
|
flash(t("panel.plugins.status.changeFailed", {
|
|
@@ -57868,17 +58373,19 @@ function PluginsPanel(props) {
|
|
|
57868
58373
|
return;
|
|
57869
58374
|
}
|
|
57870
58375
|
const accepted = inspection;
|
|
58376
|
+
const operation = "installBundle";
|
|
58377
|
+
const dryRun = t("panel.plugins.dryRun.install", {
|
|
58378
|
+
spec: installPreviewLine(accepted)
|
|
58379
|
+
});
|
|
57871
58380
|
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
57872
58381
|
get title() {
|
|
57873
58382
|
return t("panel.plugins.dialog.installTitle");
|
|
57874
58383
|
},
|
|
57875
58384
|
get message() {
|
|
57876
|
-
return
|
|
57877
|
-
|
|
57878
|
-
|
|
57879
|
-
|
|
57880
|
-
preview: installPreviewLine(accepted)
|
|
57881
|
-
});
|
|
58385
|
+
return `${writeConfirmObject(operation, installPreviewLine(accepted))}
|
|
58386
|
+
` + `${writeConfirmConsequence(operation)}
|
|
58387
|
+
${dryRun}` + (accepted.description ? `
|
|
58388
|
+
${accepted.description}` : "");
|
|
57882
58389
|
},
|
|
57883
58390
|
get label() {
|
|
57884
58391
|
return {
|
|
@@ -57886,31 +58393,108 @@ function PluginsPanel(props) {
|
|
|
57886
58393
|
cancel: t("panel.plugins.dialog.cancel")
|
|
57887
58394
|
};
|
|
57888
58395
|
},
|
|
57889
|
-
onConfirm: () => void install(spec)
|
|
58396
|
+
onConfirm: () => void install(spec, operation)
|
|
57890
58397
|
}), undefined, {
|
|
57891
58398
|
tone: "warning"
|
|
57892
58399
|
});
|
|
57893
58400
|
}
|
|
57894
|
-
async function install(spec) {
|
|
58401
|
+
async function install(spec, operation) {
|
|
57895
58402
|
if (busy())
|
|
57896
58403
|
return;
|
|
57897
58404
|
if (typeof props.seam.installPluginSpec !== "function")
|
|
57898
58405
|
return;
|
|
58406
|
+
const requestId = `ui-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
57899
58407
|
setBusy(true);
|
|
58408
|
+
setInstallProgress({
|
|
58409
|
+
state: "running",
|
|
58410
|
+
requestId
|
|
58411
|
+
});
|
|
58412
|
+
setCancelArmed(true);
|
|
57900
58413
|
flash(t("panel.plugins.status.installing", {
|
|
57901
58414
|
spec
|
|
57902
58415
|
}));
|
|
58416
|
+
const confirm = createPluginWriteConfirm(operation);
|
|
58417
|
+
let terminalLanded = false;
|
|
58418
|
+
let pollStopped = false;
|
|
58419
|
+
const land = (progress) => {
|
|
58420
|
+
if (terminalLanded)
|
|
58421
|
+
return;
|
|
58422
|
+
setInstallProgress(progress);
|
|
58423
|
+
if (progress.state !== "running")
|
|
58424
|
+
terminalLanded = true;
|
|
58425
|
+
};
|
|
58426
|
+
const pollDone = typeof props.seam.waitForInstall === "function" ? pollInstallFace((rid, cf) => props.seam.waitForInstall(rid, cf), requestId, confirm, land, () => pollStopped) : Promise.resolve();
|
|
57903
58427
|
try {
|
|
57904
|
-
const change = await props.seam.installPluginSpec(spec);
|
|
58428
|
+
const change = await props.seam.installPluginSpec(spec, confirm, requestId);
|
|
58429
|
+
await Promise.race([pollDone, new Promise((resolve) => setTimeout(resolve, PROGRESS_SETTLE_GRACE_MS))]);
|
|
58430
|
+
pollStopped = true;
|
|
58431
|
+
land(terminalProgress(change, requestId));
|
|
57905
58432
|
flash(pluginChangeNotice(change), 8000);
|
|
57906
58433
|
} catch (error) {
|
|
58434
|
+
pollStopped = true;
|
|
58435
|
+
land({
|
|
58436
|
+
state: "failed",
|
|
58437
|
+
requestId,
|
|
58438
|
+
target: spec,
|
|
58439
|
+
error: errorMessage2(error)
|
|
58440
|
+
});
|
|
57907
58441
|
flash(t("panel.plugins.status.changeFailed", {
|
|
57908
58442
|
name: spec,
|
|
57909
58443
|
error: errorMessage2(error)
|
|
57910
58444
|
}), 8000);
|
|
57911
58445
|
} finally {
|
|
58446
|
+
pollStopped = true;
|
|
58447
|
+
setCancelArmed(false);
|
|
57912
58448
|
setBusy(false);
|
|
57913
|
-
|
|
58449
|
+
if (progressTimer !== undefined)
|
|
58450
|
+
clearInterval(progressTimer);
|
|
58451
|
+
progressTimer = setInterval(() => {
|
|
58452
|
+
setInstallProgress(undefined);
|
|
58453
|
+
if (progressTimer !== undefined)
|
|
58454
|
+
clearInterval(progressTimer);
|
|
58455
|
+
progressTimer = undefined;
|
|
58456
|
+
}, 6000);
|
|
58457
|
+
}
|
|
58458
|
+
}
|
|
58459
|
+
function terminalProgress(change, requestId) {
|
|
58460
|
+
if (change.application === "cancelled")
|
|
58461
|
+
return {
|
|
58462
|
+
state: "cancelled",
|
|
58463
|
+
requestId,
|
|
58464
|
+
target: change.target
|
|
58465
|
+
};
|
|
58466
|
+
if (change.application === "failed")
|
|
58467
|
+
return {
|
|
58468
|
+
state: "failed",
|
|
58469
|
+
requestId,
|
|
58470
|
+
target: change.target,
|
|
58471
|
+
error: change.error
|
|
58472
|
+
};
|
|
58473
|
+
return {
|
|
58474
|
+
state: "done",
|
|
58475
|
+
requestId,
|
|
58476
|
+
target: change.target
|
|
58477
|
+
};
|
|
58478
|
+
}
|
|
58479
|
+
function cancelActiveInstall() {
|
|
58480
|
+
const progress = installProgress();
|
|
58481
|
+
if (!cancelArmed() || progress === undefined || typeof props.seam.cancelInstall !== "function")
|
|
58482
|
+
return;
|
|
58483
|
+
const requestId = progress.requestId;
|
|
58484
|
+
props.seam.cancelInstall(requestId, createPluginWriteConfirm("cancelInstall")).then((result) => {
|
|
58485
|
+
flash(t("panel.plugins.progress.cancelResult", {
|
|
58486
|
+
status: result.status
|
|
58487
|
+
}), 6000);
|
|
58488
|
+
if (result.status === "cancelled")
|
|
58489
|
+
setInstallProgress({
|
|
58490
|
+
state: "cancelled",
|
|
58491
|
+
requestId,
|
|
58492
|
+
target: requestId
|
|
58493
|
+
});
|
|
58494
|
+
}).catch((error) => flash(t("panel.plugins.status.changeFailed", {
|
|
58495
|
+
name: requestId,
|
|
58496
|
+
error: errorMessage2(error)
|
|
58497
|
+
}), 8000));
|
|
57914
58498
|
}
|
|
57915
58499
|
Keymap2.createLayer(() => ({
|
|
57916
58500
|
mode: "global",
|
|
@@ -57968,6 +58552,12 @@ function PluginsPanel(props) {
|
|
|
57968
58552
|
group: "Plugins",
|
|
57969
58553
|
enabled: () => !filterOpen() && !installOpen(),
|
|
57970
58554
|
run: beginInstall
|
|
58555
|
+
}, {
|
|
58556
|
+
bind: "x",
|
|
58557
|
+
title: t("panel.plugins.keymap.cancelInstall"),
|
|
58558
|
+
group: "Plugins",
|
|
58559
|
+
enabled: () => !filterOpen() && !installOpen() && cancelArmed(),
|
|
58560
|
+
run: cancelActiveInstall
|
|
57971
58561
|
}, {
|
|
57972
58562
|
bind: "up,k",
|
|
57973
58563
|
title: t("panel.plugins.keymap.previous"),
|
|
@@ -57987,8 +58577,10 @@ function PluginsPanel(props) {
|
|
|
57987
58577
|
return open();
|
|
57988
58578
|
},
|
|
57989
58579
|
get children() {
|
|
57990
|
-
var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$4 = createElement("text");
|
|
58580
|
+
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
58581
|
insertNode(_el$, _el$2);
|
|
58582
|
+
insertNode(_el$, _el$9);
|
|
58583
|
+
insertNode(_el$, _el$1);
|
|
57992
58584
|
setProp(_el$, "flexShrink", 0);
|
|
57993
58585
|
setProp(_el$, "width", "100%");
|
|
57994
58586
|
setProp(_el$, "flexDirection", "column");
|
|
@@ -58007,37 +58599,52 @@ function PluginsPanel(props) {
|
|
|
58007
58599
|
visible: String(visible().length),
|
|
58008
58600
|
total: String(bundles().length)
|
|
58009
58601
|
}));
|
|
58602
|
+
insert(_el$, createComponent2(Show, {
|
|
58603
|
+
get when() {
|
|
58604
|
+
return degraded();
|
|
58605
|
+
},
|
|
58606
|
+
get children() {
|
|
58607
|
+
var _el$5 = createElement("box"), _el$6 = createElement("text");
|
|
58608
|
+
insertNode(_el$5, _el$6);
|
|
58609
|
+
setProp(_el$5, "height", 1);
|
|
58610
|
+
setProp(_el$5, "flexShrink", 0);
|
|
58611
|
+
setProp(_el$6, "wrapMode", "none");
|
|
58612
|
+
insert(_el$6, () => t("panel.plugins.degrade.unavailable"));
|
|
58613
|
+
effect((_$p) => setProp(_el$6, "fg", warningColor(theme ?? undefined), _$p));
|
|
58614
|
+
return _el$5;
|
|
58615
|
+
}
|
|
58616
|
+
}), _el$9);
|
|
58010
58617
|
insert(_el$, createComponent2(Show, {
|
|
58011
58618
|
get when() {
|
|
58012
58619
|
return !installOpen();
|
|
58013
58620
|
},
|
|
58014
58621
|
get fallback() {
|
|
58015
58622
|
return (() => {
|
|
58016
|
-
var _el$
|
|
58017
|
-
insertNode(_el$
|
|
58018
|
-
setProp(_el$
|
|
58019
|
-
setProp(_el$
|
|
58020
|
-
setProp(_el$
|
|
58623
|
+
var _el$15 = createElement("box"), _el$16 = createElement("input");
|
|
58624
|
+
insertNode(_el$15, _el$16);
|
|
58625
|
+
setProp(_el$15, "height", 1);
|
|
58626
|
+
setProp(_el$15, "flexShrink", 0);
|
|
58627
|
+
setProp(_el$15, "flexDirection", "row");
|
|
58021
58628
|
use((renderable) => {
|
|
58022
58629
|
setTimeout(() => {
|
|
58023
58630
|
if (!renderable.isDestroyed)
|
|
58024
58631
|
renderable.focus();
|
|
58025
58632
|
}, 1);
|
|
58026
|
-
}, _el$
|
|
58027
|
-
setProp(_el$
|
|
58028
|
-
setProp(_el$
|
|
58633
|
+
}, _el$16);
|
|
58634
|
+
setProp(_el$16, "flexGrow", 1);
|
|
58635
|
+
setProp(_el$16, "onInput", (value) => setInstallText(value));
|
|
58029
58636
|
effect((_p$) => {
|
|
58030
|
-
var _v$
|
|
58031
|
-
_v$
|
|
58032
|
-
_v$
|
|
58033
|
-
_v$
|
|
58637
|
+
var _v$11 = t("panel.plugins.placeholder.install"), _v$12 = theme?.text.muted ?? "#565f89", _v$13 = installText();
|
|
58638
|
+
_v$11 !== _p$.e && (_p$.e = setProp(_el$16, "placeholder", _v$11, _p$.e));
|
|
58639
|
+
_v$12 !== _p$.t && (_p$.t = setProp(_el$16, "placeholderColor", _v$12, _p$.t));
|
|
58640
|
+
_v$13 !== _p$.a && (_p$.a = setProp(_el$16, "value", _v$13, _p$.a));
|
|
58034
58641
|
return _p$;
|
|
58035
58642
|
}, {
|
|
58036
58643
|
e: undefined,
|
|
58037
58644
|
t: undefined,
|
|
58038
58645
|
a: undefined
|
|
58039
58646
|
});
|
|
58040
|
-
return _el$
|
|
58647
|
+
return _el$15;
|
|
58041
58648
|
})();
|
|
58042
58649
|
},
|
|
58043
58650
|
get children() {
|
|
@@ -58047,63 +58654,63 @@ function PluginsPanel(props) {
|
|
|
58047
58654
|
},
|
|
58048
58655
|
get fallback() {
|
|
58049
58656
|
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$
|
|
58657
|
+
var _el$17 = createElement("box"), _el$18 = createElement("text");
|
|
58658
|
+
insertNode(_el$17, _el$18);
|
|
58659
|
+
setProp(_el$17, "height", 1);
|
|
58660
|
+
setProp(_el$17, "flexShrink", 0);
|
|
58661
|
+
setProp(_el$18, "wrapMode", "none");
|
|
58662
|
+
insert(_el$18, () => `${t("panel.plugins.header.bundleColumn").padEnd(36)}${t("panel.plugins.header.stateColumn")}`);
|
|
58663
|
+
effect((_$p) => setProp(_el$18, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
58664
|
+
return _el$17;
|
|
58058
58665
|
})();
|
|
58059
58666
|
},
|
|
58060
58667
|
get children() {
|
|
58061
|
-
var _el$
|
|
58062
|
-
insertNode(_el$
|
|
58063
|
-
setProp(_el$
|
|
58064
|
-
setProp(_el$
|
|
58065
|
-
setProp(_el$
|
|
58668
|
+
var _el$7 = createElement("box"), _el$8 = createElement("input");
|
|
58669
|
+
insertNode(_el$7, _el$8);
|
|
58670
|
+
setProp(_el$7, "height", 1);
|
|
58671
|
+
setProp(_el$7, "flexShrink", 0);
|
|
58672
|
+
setProp(_el$7, "flexDirection", "row");
|
|
58066
58673
|
use((renderable) => {
|
|
58067
58674
|
setTimeout(() => {
|
|
58068
58675
|
if (!renderable.isDestroyed)
|
|
58069
58676
|
renderable.focus();
|
|
58070
58677
|
}, 1);
|
|
58071
|
-
}, _el$
|
|
58072
|
-
setProp(_el$
|
|
58073
|
-
setProp(_el$
|
|
58678
|
+
}, _el$8);
|
|
58679
|
+
setProp(_el$8, "flexGrow", 1);
|
|
58680
|
+
setProp(_el$8, "onInput", (value) => setFilter(value));
|
|
58074
58681
|
effect((_p$) => {
|
|
58075
58682
|
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$
|
|
58683
|
+
_v$ !== _p$.e && (_p$.e = setProp(_el$8, "placeholder", _v$, _p$.e));
|
|
58684
|
+
_v$2 !== _p$.t && (_p$.t = setProp(_el$8, "placeholderColor", _v$2, _p$.t));
|
|
58685
|
+
_v$3 !== _p$.a && (_p$.a = setProp(_el$8, "value", _v$3, _p$.a));
|
|
58079
58686
|
return _p$;
|
|
58080
58687
|
}, {
|
|
58081
58688
|
e: undefined,
|
|
58082
58689
|
t: undefined,
|
|
58083
58690
|
a: undefined
|
|
58084
58691
|
});
|
|
58085
|
-
return _el$
|
|
58692
|
+
return _el$7;
|
|
58086
58693
|
}
|
|
58087
58694
|
});
|
|
58088
58695
|
}
|
|
58089
|
-
}),
|
|
58696
|
+
}), _el$9);
|
|
58090
58697
|
insert(_el$, createComponent2(Show, {
|
|
58091
58698
|
get when() {
|
|
58092
58699
|
return visible().length > 0;
|
|
58093
58700
|
},
|
|
58094
58701
|
get fallback() {
|
|
58095
58702
|
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");
|
|
58703
|
+
var _el$19 = createElement("box"), _el$20 = createElement("text");
|
|
58704
|
+
insertNode(_el$19, _el$20);
|
|
58705
|
+
setProp(_el$19, "height", 1);
|
|
58706
|
+
setProp(_el$19, "flexShrink", 0);
|
|
58707
|
+
setProp(_el$20, "wrapMode", "none");
|
|
58708
|
+
insert(_el$20, (() => {
|
|
58709
|
+
var _c$4 = memo2(() => bundles().length === 0);
|
|
58710
|
+
return () => _c$4() ? t("panel.plugins.empty.noPlugins") : t("panel.plugins.empty.noMatch");
|
|
58104
58711
|
})());
|
|
58105
|
-
effect((_$p) => setProp(_el$
|
|
58106
|
-
return _el$
|
|
58712
|
+
effect((_$p) => setProp(_el$20, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
58713
|
+
return _el$19;
|
|
58107
58714
|
})();
|
|
58108
58715
|
},
|
|
58109
58716
|
get children() {
|
|
@@ -58112,53 +58719,92 @@ function PluginsPanel(props) {
|
|
|
58112
58719
|
return visible().slice(0, 12);
|
|
58113
58720
|
},
|
|
58114
58721
|
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$
|
|
58722
|
+
var _el$21 = createElement("box"), _el$22 = createElement("text"), _el$23 = createElement("text");
|
|
58723
|
+
insertNode(_el$21, _el$22);
|
|
58724
|
+
insertNode(_el$21, _el$23);
|
|
58725
|
+
setProp(_el$21, "height", 1);
|
|
58726
|
+
setProp(_el$21, "flexShrink", 0);
|
|
58727
|
+
setProp(_el$21, "flexDirection", "row");
|
|
58728
|
+
setProp(_el$22, "wrapMode", "none");
|
|
58729
|
+
insert(_el$22, () => `${index() === cursorIndex() ? "\u203A " : " "}${formatPluginLine(row).padEnd(34)}`);
|
|
58730
|
+
setProp(_el$23, "wrapMode", "none");
|
|
58731
|
+
insert(_el$23, () => bundleStateText(row));
|
|
58125
58732
|
effect((_p$) => {
|
|
58126
|
-
var _v$
|
|
58127
|
-
_v$
|
|
58128
|
-
_v$
|
|
58733
|
+
var _v$14 = index() === cursorIndex() ? theme?.text.base ?? "#e6e6e6" : theme?.text.muted ?? "#565f89", _v$15 = row.enabled ? successColor(theme ?? undefined) : theme?.text.muted ?? "#565f89";
|
|
58734
|
+
_v$14 !== _p$.e && (_p$.e = setProp(_el$22, "fg", _v$14, _p$.e));
|
|
58735
|
+
_v$15 !== _p$.t && (_p$.t = setProp(_el$23, "fg", _v$15, _p$.t));
|
|
58129
58736
|
return _p$;
|
|
58130
58737
|
}, {
|
|
58131
58738
|
e: undefined,
|
|
58132
58739
|
t: undefined
|
|
58133
58740
|
});
|
|
58134
|
-
return _el$
|
|
58741
|
+
return _el$21;
|
|
58135
58742
|
})()
|
|
58136
58743
|
});
|
|
58137
58744
|
}
|
|
58745
|
+
}), _el$9);
|
|
58746
|
+
insertNode(_el$9, _el$0);
|
|
58747
|
+
setProp(_el$9, "height", 1);
|
|
58748
|
+
setProp(_el$9, "flexShrink", 0);
|
|
58749
|
+
setProp(_el$0, "wrapMode", "none");
|
|
58750
|
+
insert(_el$0, (() => {
|
|
58751
|
+
var _c$ = memo2(() => detail() !== undefined);
|
|
58752
|
+
return () => _c$() ? t("panel.plugins.detail.title", {
|
|
58753
|
+
name: current()?.name ?? ""
|
|
58754
|
+
}) : "";
|
|
58755
|
+
})());
|
|
58756
|
+
insertNode(_el$1, _el$10);
|
|
58757
|
+
setProp(_el$1, "height", 1);
|
|
58758
|
+
setProp(_el$1, "flexShrink", 0);
|
|
58759
|
+
setProp(_el$10, "wrapMode", "none");
|
|
58760
|
+
insert(_el$10, (() => {
|
|
58761
|
+
var _c$2 = memo2(() => detail() !== undefined);
|
|
58762
|
+
return () => _c$2() ? pluginDetailPreview(detail(), detailLoading()) : "";
|
|
58763
|
+
})());
|
|
58764
|
+
insert(_el$, createComponent2(Show, {
|
|
58765
|
+
get when() {
|
|
58766
|
+
return installProgress() !== undefined;
|
|
58767
|
+
},
|
|
58768
|
+
get children() {
|
|
58769
|
+
var _el$11 = createElement("box"), _el$12 = createElement("text");
|
|
58770
|
+
insertNode(_el$11, _el$12);
|
|
58771
|
+
setProp(_el$11, "height", 1);
|
|
58772
|
+
setProp(_el$11, "flexShrink", 0);
|
|
58773
|
+
setProp(_el$12, "wrapMode", "none");
|
|
58774
|
+
insert(_el$12, (() => {
|
|
58775
|
+
var _c$3 = memo2(() => installProgress() !== undefined);
|
|
58776
|
+
return () => _c$3() ? installProgressLine(installProgress()) : "";
|
|
58777
|
+
})());
|
|
58778
|
+
effect((_$p) => setProp(_el$12, "fg", warningColor(theme ?? undefined), _$p));
|
|
58779
|
+
return _el$11;
|
|
58780
|
+
}
|
|
58138
58781
|
}), null);
|
|
58139
58782
|
insert(_el$, createComponent2(Show, {
|
|
58140
58783
|
get when() {
|
|
58141
58784
|
return status() !== undefined;
|
|
58142
58785
|
},
|
|
58143
58786
|
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$
|
|
58787
|
+
var _el$13 = createElement("box"), _el$14 = createElement("text");
|
|
58788
|
+
insertNode(_el$13, _el$14);
|
|
58789
|
+
setProp(_el$13, "height", 1);
|
|
58790
|
+
setProp(_el$13, "flexShrink", 0);
|
|
58791
|
+
setProp(_el$14, "wrapMode", "none");
|
|
58792
|
+
insert(_el$14, status);
|
|
58793
|
+
effect((_$p) => setProp(_el$14, "fg", warningColor(theme ?? undefined), _$p));
|
|
58794
|
+
return _el$13;
|
|
58152
58795
|
}
|
|
58153
58796
|
}), null);
|
|
58154
58797
|
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";
|
|
58798
|
+
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
58799
|
_v$4 !== _p$.e && (_p$.e = setProp(_el$, "height", _v$4, _p$.e));
|
|
58157
58800
|
_v$5 !== _p$.t && (_p$.t = setProp(_el$, "borderColor", _v$5, _p$.t));
|
|
58158
58801
|
_v$6 !== _p$.a && (_p$.a = setProp(_el$, "backgroundColor", _v$6, _p$.a));
|
|
58159
58802
|
_v$7 !== _p$.o && (_p$.o = setProp(_el$3, "fg", _v$7, _p$.o));
|
|
58160
58803
|
_v$8 !== _p$.i && (_p$.i = setProp(_el$3, "attributes", _v$8, _p$.i));
|
|
58161
58804
|
_v$9 !== _p$.n && (_p$.n = setProp(_el$4, "fg", _v$9, _p$.n));
|
|
58805
|
+
_v$0 !== _p$.s && (_p$.s = setProp(_el$0, "fg", _v$0, _p$.s));
|
|
58806
|
+
_v$1 !== _p$.h && (_p$.h = setProp(_el$0, "attributes", _v$1, _p$.h));
|
|
58807
|
+
_v$10 !== _p$.r && (_p$.r = setProp(_el$10, "fg", _v$10, _p$.r));
|
|
58162
58808
|
return _p$;
|
|
58163
58809
|
}, {
|
|
58164
58810
|
e: undefined,
|
|
@@ -58166,13 +58812,16 @@ function PluginsPanel(props) {
|
|
|
58166
58812
|
a: undefined,
|
|
58167
58813
|
o: undefined,
|
|
58168
58814
|
i: undefined,
|
|
58169
|
-
n: undefined
|
|
58815
|
+
n: undefined,
|
|
58816
|
+
s: undefined,
|
|
58817
|
+
h: undefined,
|
|
58818
|
+
r: undefined
|
|
58170
58819
|
});
|
|
58171
58820
|
return _el$;
|
|
58172
58821
|
}
|
|
58173
58822
|
});
|
|
58174
58823
|
}
|
|
58175
|
-
var bridgeOpen3, setBridgeOpen3, panelOpen4, setPanelOpen4, pluginsPanelOpen;
|
|
58824
|
+
var bridgeOpen3, setBridgeOpen3, panelOpen4, setPanelOpen4, pluginsPanelOpen, PROGRESS_POLL_INTERVAL_MS = 250, PROGRESS_POLL_MAX_TICKS = 120, PROGRESS_SETTLE_GRACE_MS = 80;
|
|
58176
58825
|
var init_plugins_panel = __esm(() => {
|
|
58177
58826
|
init_index_bun();
|
|
58178
58827
|
init_index_bun();
|
|
@@ -64129,7 +64778,7 @@ var init_subagents_viewer = __esm(() => {
|
|
|
64129
64778
|
import { TextAttributes as TextAttributes12 } from "@opentui/core";
|
|
64130
64779
|
function resolveVersion() {
|
|
64131
64780
|
try {
|
|
64132
|
-
return "0.
|
|
64781
|
+
return "0.26.0";
|
|
64133
64782
|
} catch {
|
|
64134
64783
|
return "dev";
|
|
64135
64784
|
}
|
|
@@ -65491,6 +66140,18 @@ var init_settings_modal = __esm(() => {
|
|
|
65491
66140
|
});
|
|
65492
66141
|
|
|
65493
66142
|
// ../tui-base/src/routes/session/btw-overlay.tsx
|
|
66143
|
+
function btwDegradeText(code) {
|
|
66144
|
+
if (code === "UNSUPPORTED" || code === "SIDE_SESSION_UNAVAILABLE")
|
|
66145
|
+
return `error: ${t("command.btw.noModel")}`;
|
|
66146
|
+
if (code === "SIDE_SESSION_NO_ANSWER")
|
|
66147
|
+
return `error: ${t("command.btw.noAnswer")}`;
|
|
66148
|
+
if (code === "SIDE_SESSION_BUSY")
|
|
66149
|
+
return `error: ${t("command.btw.busy")}`;
|
|
66150
|
+
if (code === "SIDE_SESSION_FAILED" || code === "SIDE_SESSION_PROMPT_REJECTED")
|
|
66151
|
+
return `error: ${t("command.btw.failed")}`;
|
|
66152
|
+
return;
|
|
66153
|
+
}
|
|
66154
|
+
|
|
65494
66155
|
class BtwController {
|
|
65495
66156
|
#ask;
|
|
65496
66157
|
#snapshot;
|
|
@@ -65557,7 +66218,9 @@ class BtwController {
|
|
|
65557
66218
|
})).then((answer) => {
|
|
65558
66219
|
this.#settle(answer.startsWith("error:") ? "error" : "settled", answer);
|
|
65559
66220
|
}).catch((error) => {
|
|
65560
|
-
|
|
66221
|
+
const code = error !== null && typeof error === "object" ? error.code : undefined;
|
|
66222
|
+
const degrade = btwDegradeText(code);
|
|
66223
|
+
this.#settle("error", degrade ?? `error: ${error instanceof Error ? error.message : String(error)}`);
|
|
65561
66224
|
});
|
|
65562
66225
|
}
|
|
65563
66226
|
#settle(status, answer) {
|
|
@@ -66029,10 +66692,135 @@ var init_journal_projection = __esm(() => {
|
|
|
66029
66692
|
NOTICE_SOURCE_KINDS = new Set(["subagent-settled", "agent-message", "team-message", "webhook"]);
|
|
66030
66693
|
});
|
|
66031
66694
|
|
|
66695
|
+
// src/client/bridge-side-session.ts
|
|
66696
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
66697
|
+
function classify(err, stage) {
|
|
66698
|
+
const raw = err instanceof Error ? err.message : String(err);
|
|
66699
|
+
if (/NOT_WIRED|UNSUPPORTED|unavailable|no inproc host adapter/i.test(raw)) {
|
|
66700
|
+
return new SideSessionError("SIDE_SESSION_UNAVAILABLE", `/btw side-session ${stage} unavailable: ${raw.slice(0, 160)}`);
|
|
66701
|
+
}
|
|
66702
|
+
return new SideSessionError("SIDE_SESSION_FAILED", `/btw side-session ${stage} failed: ${raw.slice(0, 160)}`);
|
|
66703
|
+
}
|
|
66704
|
+
function projectWaitAnswer(value, maxLength = 4000) {
|
|
66705
|
+
const v = asRecord5(value);
|
|
66706
|
+
const output = asRecord5(v.output);
|
|
66707
|
+
const records = Array.isArray(output.records) ? output.records : [];
|
|
66708
|
+
const texts = [];
|
|
66709
|
+
for (const raw of [...records].reverse()) {
|
|
66710
|
+
const rec = asRecord5(raw);
|
|
66711
|
+
const event = asRecord5(rec.event);
|
|
66712
|
+
if (event.type !== "assistant/message")
|
|
66713
|
+
continue;
|
|
66714
|
+
const data = asRecord5(event.data);
|
|
66715
|
+
const message = asRecord5(data.message);
|
|
66716
|
+
const content = Array.isArray(message.content) ? message.content : Array.isArray(data.content) ? data.content : Array.isArray(data.parts) ? data.parts : [];
|
|
66717
|
+
const parts = [];
|
|
66718
|
+
for (const block of content) {
|
|
66719
|
+
const b = asRecord5(block);
|
|
66720
|
+
if (b.type === "text" && typeof b.text === "string")
|
|
66721
|
+
parts.push(b.text);
|
|
66722
|
+
}
|
|
66723
|
+
let text = parts.join(`
|
|
66724
|
+
`).trim();
|
|
66725
|
+
if (text === "") {
|
|
66726
|
+
const flat = typeof message.text === "string" ? message.text : typeof data.text === "string" ? data.text : "";
|
|
66727
|
+
text = flat.trim();
|
|
66728
|
+
}
|
|
66729
|
+
if (text)
|
|
66730
|
+
texts.push(text);
|
|
66731
|
+
}
|
|
66732
|
+
let answer = texts.join(`
|
|
66733
|
+
|
|
66734
|
+
`);
|
|
66735
|
+
let truncated = output.truncated === true;
|
|
66736
|
+
if (answer.length > maxLength) {
|
|
66737
|
+
answer = answer.slice(0, maxLength);
|
|
66738
|
+
truncated = true;
|
|
66739
|
+
}
|
|
66740
|
+
return { answer, truncated };
|
|
66741
|
+
}
|
|
66742
|
+
async function runSideSession(options) {
|
|
66743
|
+
const timeoutMs = options.timeoutMs ?? 120000;
|
|
66744
|
+
const rpc = options.rpc;
|
|
66745
|
+
let created;
|
|
66746
|
+
try {
|
|
66747
|
+
created = asRecord5(await rpc("session.create", {
|
|
66748
|
+
request: options.sessionId !== undefined ? { sessionId: options.sessionId } : {}
|
|
66749
|
+
}));
|
|
66750
|
+
} catch (err) {
|
|
66751
|
+
throw classify(err, "create");
|
|
66752
|
+
}
|
|
66753
|
+
const sessionId = typeof created.sessionId === "string" ? created.sessionId : "";
|
|
66754
|
+
if (sessionId === "") {
|
|
66755
|
+
throw new SideSessionError("SIDE_SESSION_UNAVAILABLE", "/btw side-session create returned no sessionId");
|
|
66756
|
+
}
|
|
66757
|
+
const requestId = options.requestId?.() ?? randomUUID8();
|
|
66758
|
+
const snap = options.snapshot && options.snapshot.length > 0 ? `Recent conversation context (for reference only):
|
|
66759
|
+
${options.snapshot.join(`
|
|
66760
|
+
`).slice(-1500)}
|
|
66761
|
+
|
|
66762
|
+
` : "";
|
|
66763
|
+
try {
|
|
66764
|
+
const accepted = asRecord5(await rpc("session.prompt", {
|
|
66765
|
+
request: {
|
|
66766
|
+
requestId,
|
|
66767
|
+
sessionId,
|
|
66768
|
+
mode: "queue",
|
|
66769
|
+
content: [{ type: "text", text: `${snap}Side question (answer in one or two sentences, do not use tools): ${options.question}` }]
|
|
66770
|
+
}
|
|
66771
|
+
}));
|
|
66772
|
+
if (accepted.accepted !== true) {
|
|
66773
|
+
throw new SideSessionError("SIDE_SESSION_PROMPT_REJECTED", "/btw side-session prompt was not accepted");
|
|
66774
|
+
}
|
|
66775
|
+
} catch (err) {
|
|
66776
|
+
if (err instanceof SideSessionError)
|
|
66777
|
+
throw err;
|
|
66778
|
+
throw classify(err, "prompt");
|
|
66779
|
+
}
|
|
66780
|
+
let waited;
|
|
66781
|
+
try {
|
|
66782
|
+
waited = asRecord5(await rpc("session.wait", {
|
|
66783
|
+
request: {
|
|
66784
|
+
sessionId,
|
|
66785
|
+
timeoutMs,
|
|
66786
|
+
...options.maxMessages !== undefined ? { maxMessages: options.maxMessages } : {}
|
|
66787
|
+
}
|
|
66788
|
+
}));
|
|
66789
|
+
} catch (err) {
|
|
66790
|
+
throw classify(err, "wait");
|
|
66791
|
+
}
|
|
66792
|
+
const { answer, truncated } = projectWaitAnswer(waited, options.maxAnswerLength);
|
|
66793
|
+
const reason = typeof waited.reason === "string" ? waited.reason : "idle";
|
|
66794
|
+
if (process.env.DSH_OPENTUI_DEBUG) {
|
|
66795
|
+
const out = asRecord5(waited.output);
|
|
66796
|
+
const recs = Array.isArray(out.records) ? out.records : [];
|
|
66797
|
+
const types = recs.map((r) => String(asRecord5(asRecord5(r).event).type ?? "?")).join(",");
|
|
66798
|
+
process.stderr.write(`[btw-side] wait reason=${reason} records=${recs.length} types=[${types}] truncated=${String(out.truncated)} answerLen=${answer.length}
|
|
66799
|
+
`);
|
|
66800
|
+
}
|
|
66801
|
+
if (answer !== "" && options.onDelta !== undefined) {
|
|
66802
|
+
try {
|
|
66803
|
+
options.onDelta(answer);
|
|
66804
|
+
} catch {}
|
|
66805
|
+
}
|
|
66806
|
+
return { answer, sessionId, reason, truncated };
|
|
66807
|
+
}
|
|
66808
|
+
var SideSessionError, asRecord5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
66809
|
+
var init_bridge_side_session = __esm(() => {
|
|
66810
|
+
SideSessionError = class SideSessionError extends Error {
|
|
66811
|
+
code;
|
|
66812
|
+
constructor(code, message) {
|
|
66813
|
+
super(message);
|
|
66814
|
+
this.code = code;
|
|
66815
|
+
this.name = "SideSessionError";
|
|
66816
|
+
}
|
|
66817
|
+
};
|
|
66818
|
+
});
|
|
66819
|
+
|
|
66032
66820
|
// 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";
|
|
66821
|
+
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
66822
|
import { dirname as dirname7, join as join15 } from "path";
|
|
66035
|
-
function
|
|
66823
|
+
function asRecord6(value) {
|
|
66036
66824
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
66037
66825
|
}
|
|
66038
66826
|
function parseScalar(raw) {
|
|
@@ -66133,6 +66921,48 @@ function atomicWrite2(path, text) {
|
|
|
66133
66921
|
throw err;
|
|
66134
66922
|
}
|
|
66135
66923
|
}
|
|
66924
|
+
function buildLoginRouteBlock(providerId, profile) {
|
|
66925
|
+
const block = [` ${providerId}:`];
|
|
66926
|
+
const apiKeyEnv = typeof profile.apiKeyEnv === "string" ? profile.apiKeyEnv : "";
|
|
66927
|
+
if (apiKeyEnv !== "") {
|
|
66928
|
+
if (!/^[A-Za-z0-9_]+$/.test(apiKeyEnv))
|
|
66929
|
+
return;
|
|
66930
|
+
block.push(` apiKeyEnv: ${apiKeyEnv}`);
|
|
66931
|
+
}
|
|
66932
|
+
if (profile.api !== undefined) {
|
|
66933
|
+
if (typeof profile.api !== "string" || !/^[A-Za-z0-9_.-]+$/.test(profile.api))
|
|
66934
|
+
return;
|
|
66935
|
+
block.push(` api: ${profile.api}`);
|
|
66936
|
+
}
|
|
66937
|
+
if (profile.baseURL !== undefined) {
|
|
66938
|
+
if (typeof profile.baseURL !== "string" || !/^https?:\/\/\S+$/.test(profile.baseURL))
|
|
66939
|
+
return;
|
|
66940
|
+
block.push(` baseURL: ${JSON.stringify(profile.baseURL)}`);
|
|
66941
|
+
}
|
|
66942
|
+
if (profile.displayName !== undefined) {
|
|
66943
|
+
if (typeof profile.displayName !== "string" || /[\r\n]/.test(profile.displayName))
|
|
66944
|
+
return;
|
|
66945
|
+
block.push(` displayName: ${JSON.stringify(profile.displayName)}`);
|
|
66946
|
+
}
|
|
66947
|
+
if (profile.models !== undefined) {
|
|
66948
|
+
if (!Array.isArray(profile.models))
|
|
66949
|
+
return;
|
|
66950
|
+
block.push(" models:");
|
|
66951
|
+
for (const entry of profile.models) {
|
|
66952
|
+
const m = asRecord6(entry);
|
|
66953
|
+
const id = m.id;
|
|
66954
|
+
if (typeof id !== "string" || !id || /[\r\n\x00-\x1f]/.test(id))
|
|
66955
|
+
return;
|
|
66956
|
+
block.push(` - id: ${JSON.stringify(id)}`);
|
|
66957
|
+
if (m.name !== undefined) {
|
|
66958
|
+
if (typeof m.name !== "string" || /[\r\n\x00-\x1f]/.test(m.name))
|
|
66959
|
+
return;
|
|
66960
|
+
block.push(` name: ${JSON.stringify(m.name)}`);
|
|
66961
|
+
}
|
|
66962
|
+
}
|
|
66963
|
+
}
|
|
66964
|
+
return block;
|
|
66965
|
+
}
|
|
66136
66966
|
|
|
66137
66967
|
class LocalSettingsStore {
|
|
66138
66968
|
#patchPath;
|
|
@@ -66233,7 +67063,7 @@ class LocalConfigStore {
|
|
|
66233
67063
|
}
|
|
66234
67064
|
#readProfile() {
|
|
66235
67065
|
try {
|
|
66236
|
-
return
|
|
67066
|
+
return asRecord6(JSON.parse(readFileSync13(this.#configPath, "utf8")));
|
|
66237
67067
|
} catch {
|
|
66238
67068
|
return {};
|
|
66239
67069
|
}
|
|
@@ -66277,7 +67107,7 @@ class LocalConfigStore {
|
|
|
66277
67107
|
function loadWorkspaceConfigState(workspaceDir) {
|
|
66278
67108
|
try {
|
|
66279
67109
|
const raw = JSON.parse(readFileSync13(join15(workspaceDir, ".dsh", "config.yml"), "utf8"));
|
|
66280
|
-
return
|
|
67110
|
+
return asRecord6(raw);
|
|
66281
67111
|
} catch {
|
|
66282
67112
|
try {
|
|
66283
67113
|
const text = readFileSync13(join15(workspaceDir, ".dsh", "config.yml"), "utf8");
|
|
@@ -66346,7 +67176,7 @@ class LocalAgentsFace {
|
|
|
66346
67176
|
async officialCaps() {
|
|
66347
67177
|
const doc = this.#settings.describe();
|
|
66348
67178
|
const row = doc.namespaces.find((n) => n.ns === "subagent");
|
|
66349
|
-
const value =
|
|
67179
|
+
const value = asRecord6(row?.value);
|
|
66350
67180
|
const caps = {};
|
|
66351
67181
|
if (typeof value.maxActiveSubagents === "number" && Number.isFinite(value.maxActiveSubagents))
|
|
66352
67182
|
caps.maxActiveSubagents = value.maxActiveSubagents;
|
|
@@ -66355,6 +67185,251 @@ class LocalAgentsFace {
|
|
|
66355
67185
|
return caps;
|
|
66356
67186
|
}
|
|
66357
67187
|
}
|
|
67188
|
+
|
|
67189
|
+
class LocalPresetFace {
|
|
67190
|
+
#patchPath;
|
|
67191
|
+
#configPath;
|
|
67192
|
+
constructor(home, profile) {
|
|
67193
|
+
this.#patchPath = join15(home, "profiles", profile, "cordis.patch.yml");
|
|
67194
|
+
this.#configPath = join15(home, "profiles", profile, "config.json");
|
|
67195
|
+
}
|
|
67196
|
+
list() {
|
|
67197
|
+
let lines = [];
|
|
67198
|
+
try {
|
|
67199
|
+
lines = readFileSync13(this.#patchPath, "utf8").split(`
|
|
67200
|
+
`);
|
|
67201
|
+
} catch {
|
|
67202
|
+
return [];
|
|
67203
|
+
}
|
|
67204
|
+
const rows = [];
|
|
67205
|
+
const seen = new Set;
|
|
67206
|
+
for (let i = 0;i < lines.length; i++) {
|
|
67207
|
+
if (!/^\s*- id:\s*preset-\S+\s*$/.test(lines[i]))
|
|
67208
|
+
continue;
|
|
67209
|
+
let end = lines.length;
|
|
67210
|
+
for (let j = i + 1;j < lines.length; j++) {
|
|
67211
|
+
if (/^\s*- id:\s*\S+/.test(lines[j]) || /^- /.test(lines[j])) {
|
|
67212
|
+
end = j;
|
|
67213
|
+
break;
|
|
67214
|
+
}
|
|
67215
|
+
}
|
|
67216
|
+
const span = lines.slice(i, end);
|
|
67217
|
+
if (!span.some((l) => /name:\s*['"]?@deepseek-ai\/dsh-agent-preset/.test(l)))
|
|
67218
|
+
continue;
|
|
67219
|
+
const cfg = span.findIndex((l) => /^\s{4,}config:\s*$/.test(l));
|
|
67220
|
+
const val = {};
|
|
67221
|
+
if (cfg >= 0) {
|
|
67222
|
+
for (let k = cfg + 1;k < span.length; k++) {
|
|
67223
|
+
const m = /^\s{6,}([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/.exec(span[k]);
|
|
67224
|
+
if (!m)
|
|
67225
|
+
continue;
|
|
67226
|
+
if (/^\s{6,}(plugins|disabled|order):/.test(span[k]) && m[1] !== "order") {
|
|
67227
|
+
if (m[1] === "plugins")
|
|
67228
|
+
break;
|
|
67229
|
+
}
|
|
67230
|
+
const key = m[1];
|
|
67231
|
+
if (key === "id" || key === "name" || key === "description") {
|
|
67232
|
+
let v = m[2].trim().replace(/^['"]|['"]$/g, "");
|
|
67233
|
+
let kk = k + 1;
|
|
67234
|
+
while (kk < span.length && /^\s{10,}\S/.test(span[kk]) && !/^\s{10,}[A-Za-z_][A-Za-z0-9_]*\s*:/.test(span[kk])) {
|
|
67235
|
+
v += " " + span[kk].trim();
|
|
67236
|
+
kk++;
|
|
67237
|
+
}
|
|
67238
|
+
val[key] = v;
|
|
67239
|
+
}
|
|
67240
|
+
}
|
|
67241
|
+
}
|
|
67242
|
+
const id = val.id;
|
|
67243
|
+
if (!id || seen.has(id))
|
|
67244
|
+
continue;
|
|
67245
|
+
seen.add(id);
|
|
67246
|
+
rows.push({
|
|
67247
|
+
id,
|
|
67248
|
+
name: val.name || id,
|
|
67249
|
+
...val.description ? { description: val.description } : {}
|
|
67250
|
+
});
|
|
67251
|
+
}
|
|
67252
|
+
return rows;
|
|
67253
|
+
}
|
|
67254
|
+
currentId() {
|
|
67255
|
+
try {
|
|
67256
|
+
const doc = asRecord6(JSON.parse(readFileSync13(this.#configPath, "utf8")));
|
|
67257
|
+
return typeof doc.agentPreset === "string" && doc.agentPreset !== "" ? doc.agentPreset : undefined;
|
|
67258
|
+
} catch {
|
|
67259
|
+
return;
|
|
67260
|
+
}
|
|
67261
|
+
}
|
|
67262
|
+
select(presetId) {
|
|
67263
|
+
const current = this.#readDoc();
|
|
67264
|
+
try {
|
|
67265
|
+
atomicWrite2(this.#configPath, JSON.stringify({ ...current, agentPreset: presetId }, null, 2) + `
|
|
67266
|
+
`);
|
|
67267
|
+
return true;
|
|
67268
|
+
} catch {
|
|
67269
|
+
return false;
|
|
67270
|
+
}
|
|
67271
|
+
}
|
|
67272
|
+
#readDoc() {
|
|
67273
|
+
try {
|
|
67274
|
+
return asRecord6(JSON.parse(readFileSync13(this.#configPath, "utf8")));
|
|
67275
|
+
} catch {
|
|
67276
|
+
return {};
|
|
67277
|
+
}
|
|
67278
|
+
}
|
|
67279
|
+
}
|
|
67280
|
+
|
|
67281
|
+
class LocalLoginFace {
|
|
67282
|
+
#patchPath;
|
|
67283
|
+
#keysPath;
|
|
67284
|
+
constructor(home, profile) {
|
|
67285
|
+
this.#patchPath = join15(home, "profiles", profile, "cordis.patch.yml");
|
|
67286
|
+
this.#keysPath = join15(home, "profiles", profile, "provider-keys.json");
|
|
67287
|
+
}
|
|
67288
|
+
routes() {
|
|
67289
|
+
let lines = [];
|
|
67290
|
+
try {
|
|
67291
|
+
lines = readFileSync13(this.#patchPath, "utf8").split(`
|
|
67292
|
+
`);
|
|
67293
|
+
} catch {
|
|
67294
|
+
return [];
|
|
67295
|
+
}
|
|
67296
|
+
const span = nsEntrySpan(lines, "llm-pi-ai");
|
|
67297
|
+
if (span === undefined)
|
|
67298
|
+
return [];
|
|
67299
|
+
const providersLine = lines.findIndex((l, i) => i >= span[0] && i < span[1] && /^\s{4}providers:\s*$/.test(l));
|
|
67300
|
+
if (providersLine < 0)
|
|
67301
|
+
return [];
|
|
67302
|
+
const out = [];
|
|
67303
|
+
for (let i = providersLine + 1;i < lines.length; i++) {
|
|
67304
|
+
const line = lines[i];
|
|
67305
|
+
const m = /^\s{6}([A-Za-z0-9_.\-]+):\s*$/.exec(line);
|
|
67306
|
+
if (!m) {
|
|
67307
|
+
if (/^\s{0,4}\S/.test(line))
|
|
67308
|
+
break;
|
|
67309
|
+
continue;
|
|
67310
|
+
}
|
|
67311
|
+
const id = m[1];
|
|
67312
|
+
let apiKeyEnv;
|
|
67313
|
+
let displayName;
|
|
67314
|
+
let declared = false;
|
|
67315
|
+
for (let j = i + 1;j < lines.length; j++) {
|
|
67316
|
+
if (/^\s{6}\S/.test(lines[j]) || /^\s{0,4}\S/.test(lines[j]))
|
|
67317
|
+
break;
|
|
67318
|
+
const f = /^\s{8}([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/.exec(lines[j]);
|
|
67319
|
+
if (!f)
|
|
67320
|
+
continue;
|
|
67321
|
+
if (f[1] === "apiKeyEnv")
|
|
67322
|
+
apiKeyEnv = f[2].trim().replace(/^['"]|['"]$/g, "");
|
|
67323
|
+
else if (f[1] === "displayName")
|
|
67324
|
+
displayName = f[2].trim().replace(/^['"]|['"]$/g, "");
|
|
67325
|
+
else if (f[1] === "api" || f[1] === "baseURL" || f[1] === "models")
|
|
67326
|
+
declared = true;
|
|
67327
|
+
}
|
|
67328
|
+
out.push({ id, ...apiKeyEnv ? { apiKeyEnv } : {}, ...displayName ? { displayName } : {}, declared });
|
|
67329
|
+
}
|
|
67330
|
+
return out;
|
|
67331
|
+
}
|
|
67332
|
+
credentialStatus(ref) {
|
|
67333
|
+
if (typeof process.env[ref] === "string" && process.env[ref] !== "")
|
|
67334
|
+
return { configured: true };
|
|
67335
|
+
return { configured: Object.prototype.hasOwnProperty.call(this.#readKeys(), ref) };
|
|
67336
|
+
}
|
|
67337
|
+
login(ref, apiKey) {
|
|
67338
|
+
const keys = this.#readKeys();
|
|
67339
|
+
keys[ref] = apiKey;
|
|
67340
|
+
this.#writeKeys(keys);
|
|
67341
|
+
}
|
|
67342
|
+
logout(ref) {
|
|
67343
|
+
const keys = this.#readKeys();
|
|
67344
|
+
delete keys[ref];
|
|
67345
|
+
this.#writeKeys(keys);
|
|
67346
|
+
}
|
|
67347
|
+
registerRoute(providerId, profile) {
|
|
67348
|
+
let text = "";
|
|
67349
|
+
try {
|
|
67350
|
+
text = readFileSync13(this.#patchPath, "utf8");
|
|
67351
|
+
} catch {
|
|
67352
|
+
return false;
|
|
67353
|
+
}
|
|
67354
|
+
const lines = text.length > 0 ? text.split(`
|
|
67355
|
+
`) : [];
|
|
67356
|
+
const span = nsEntrySpan(lines, "llm-pi-ai");
|
|
67357
|
+
if (span === undefined)
|
|
67358
|
+
return false;
|
|
67359
|
+
const providersLine = lines.findIndex((l, i) => i >= span[0] && i < span[1] && /^\s{4}providers:\s*$/.test(l));
|
|
67360
|
+
if (providersLine < 0)
|
|
67361
|
+
return false;
|
|
67362
|
+
let pStart = -1;
|
|
67363
|
+
let pEnd = -1;
|
|
67364
|
+
for (let i = providersLine + 1;i < lines.length; i++) {
|
|
67365
|
+
const m = /^\s{6}([A-Za-z0-9_.\-]+):\s*$/.exec(lines[i]);
|
|
67366
|
+
if (m && m[1] === providerId) {
|
|
67367
|
+
pStart = i;
|
|
67368
|
+
pEnd = i + 1;
|
|
67369
|
+
for (let j = i + 1;j < lines.length; j++) {
|
|
67370
|
+
if (/^\s{6}\S/.test(lines[j]) || /^\s{0,4}\S/.test(lines[j]))
|
|
67371
|
+
break;
|
|
67372
|
+
pEnd = j + 1;
|
|
67373
|
+
}
|
|
67374
|
+
break;
|
|
67375
|
+
}
|
|
67376
|
+
if (/^\s{0,4}\S/.test(lines[i]))
|
|
67377
|
+
break;
|
|
67378
|
+
}
|
|
67379
|
+
if (profile === undefined) {
|
|
67380
|
+
if (pStart < 0)
|
|
67381
|
+
return true;
|
|
67382
|
+
lines.splice(pStart, pEnd - pStart);
|
|
67383
|
+
} else {
|
|
67384
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(providerId))
|
|
67385
|
+
return false;
|
|
67386
|
+
const block = buildLoginRouteBlock(providerId, profile);
|
|
67387
|
+
if (block === undefined)
|
|
67388
|
+
return false;
|
|
67389
|
+
if (pStart >= 0)
|
|
67390
|
+
lines.splice(pStart, pEnd - pStart, ...block);
|
|
67391
|
+
else
|
|
67392
|
+
lines.splice(providersLine + 1, 0, ...block);
|
|
67393
|
+
}
|
|
67394
|
+
try {
|
|
67395
|
+
atomicWrite2(this.#patchPath, lines.join(`
|
|
67396
|
+
`).replace(/\n*$/, `
|
|
67397
|
+
`));
|
|
67398
|
+
} catch {
|
|
67399
|
+
return false;
|
|
67400
|
+
}
|
|
67401
|
+
return true;
|
|
67402
|
+
}
|
|
67403
|
+
#readKeys() {
|
|
67404
|
+
try {
|
|
67405
|
+
const doc = asRecord6(JSON.parse(readFileSync13(this.#keysPath, "utf8")));
|
|
67406
|
+
const out = {};
|
|
67407
|
+
for (const [k, v] of Object.entries(doc))
|
|
67408
|
+
if (typeof v === "string")
|
|
67409
|
+
out[k] = v;
|
|
67410
|
+
return out;
|
|
67411
|
+
} catch {
|
|
67412
|
+
return {};
|
|
67413
|
+
}
|
|
67414
|
+
}
|
|
67415
|
+
#writeKeys(keys) {
|
|
67416
|
+
mkdirSync7(dirname7(this.#keysPath), { recursive: true });
|
|
67417
|
+
const tmp = `${this.#keysPath}.${process.pid}.s5.tmp`;
|
|
67418
|
+
try {
|
|
67419
|
+
writeFileSync9(tmp, JSON.stringify(keys, null, 2) + `
|
|
67420
|
+
`, { mode: 384 });
|
|
67421
|
+
try {
|
|
67422
|
+
chmodSync4(tmp, 384);
|
|
67423
|
+
} catch {}
|
|
67424
|
+
renameSync9(tmp, this.#keysPath);
|
|
67425
|
+
} catch (err) {
|
|
67426
|
+
try {
|
|
67427
|
+
rmSync5(tmp, { force: true });
|
|
67428
|
+
} catch {}
|
|
67429
|
+
throw err;
|
|
67430
|
+
}
|
|
67431
|
+
}
|
|
67432
|
+
}
|
|
66358
67433
|
var SETTINGS_NAMESPACES, NS_VALUE_FIELDS, NS_PACKAGE, NS_DEFAULTS, CONFIG_KEYS, CONFIG_KEY_SET;
|
|
66359
67434
|
var init_local_config_faces = __esm(() => {
|
|
66360
67435
|
init_remote_agent_profiles();
|
|
@@ -66391,12 +67466,439 @@ var init_local_config_faces = __esm(() => {
|
|
|
66391
67466
|
"activity_panel_height",
|
|
66392
67467
|
"stepsDisplay",
|
|
66393
67468
|
"stepsCollapse",
|
|
66394
|
-
"stepsFolded"
|
|
67469
|
+
"stepsFolded",
|
|
67470
|
+
"agentPreset"
|
|
66395
67471
|
];
|
|
66396
67472
|
CONFIG_KEY_SET = new Set(CONFIG_KEYS);
|
|
66397
67473
|
});
|
|
66398
67474
|
|
|
67475
|
+
// src/client/bridge-plugins-manager.ts
|
|
67476
|
+
function asRecord7(value) {
|
|
67477
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
67478
|
+
}
|
|
67479
|
+
function unwrapWireValue(raw) {
|
|
67480
|
+
const rec = asRecord7(raw);
|
|
67481
|
+
if (Object.prototype.hasOwnProperty.call(rec, "value"))
|
|
67482
|
+
return rec.value;
|
|
67483
|
+
return raw;
|
|
67484
|
+
}
|
|
67485
|
+
function text(value, max = MAX_TEXT) {
|
|
67486
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
67487
|
+
}
|
|
67488
|
+
function bool(value) {
|
|
67489
|
+
return value === true;
|
|
67490
|
+
}
|
|
67491
|
+
function projectBundleRows(raw) {
|
|
67492
|
+
const value = unwrapWireValue(raw);
|
|
67493
|
+
if (!Array.isArray(value))
|
|
67494
|
+
return [];
|
|
67495
|
+
const out = [];
|
|
67496
|
+
for (const entry of value) {
|
|
67497
|
+
const row = asRecord7(entry);
|
|
67498
|
+
const name = text(row.name, MAX_SHORT);
|
|
67499
|
+
if (name === undefined || name === "")
|
|
67500
|
+
continue;
|
|
67501
|
+
const version = text(row.version, MAX_SHORT) ?? "";
|
|
67502
|
+
const description = text(row.description);
|
|
67503
|
+
const readOnlyReason = text(row.readOnlyReason, MAX_SHORT);
|
|
67504
|
+
const errorRaw = row.error;
|
|
67505
|
+
const error = typeof errorRaw === "string" ? errorRaw.slice(0, MAX_SHORT) : text(asRecord7(errorRaw).message, MAX_SHORT);
|
|
67506
|
+
const projected = {
|
|
67507
|
+
name,
|
|
67508
|
+
version,
|
|
67509
|
+
enabled: bool(row.enabled),
|
|
67510
|
+
installed: bool(row.installed),
|
|
67511
|
+
optional: bool(row.optional),
|
|
67512
|
+
removable: bool(row.removable)
|
|
67513
|
+
};
|
|
67514
|
+
if (description !== undefined)
|
|
67515
|
+
projected.description = description;
|
|
67516
|
+
if (readOnlyReason !== undefined)
|
|
67517
|
+
projected.readOnlyReason = readOnlyReason;
|
|
67518
|
+
if (error !== undefined)
|
|
67519
|
+
projected.error = error;
|
|
67520
|
+
out.push(projected);
|
|
67521
|
+
}
|
|
67522
|
+
return out;
|
|
67523
|
+
}
|
|
67524
|
+
function projectPluginRows(raw) {
|
|
67525
|
+
const value = unwrapWireValue(raw);
|
|
67526
|
+
if (!Array.isArray(value))
|
|
67527
|
+
return [];
|
|
67528
|
+
const out = [];
|
|
67529
|
+
for (const entry of value) {
|
|
67530
|
+
const row = asRecord7(entry);
|
|
67531
|
+
const name = text(row.name, MAX_SHORT) ?? text(row.id, MAX_SHORT);
|
|
67532
|
+
if (name === undefined || name === "")
|
|
67533
|
+
continue;
|
|
67534
|
+
out.push({ name, version: text(row.version, MAX_SHORT) ?? "" });
|
|
67535
|
+
}
|
|
67536
|
+
return out;
|
|
67537
|
+
}
|
|
67538
|
+
function projectDetail(raw) {
|
|
67539
|
+
const value = unwrapWireValue(raw);
|
|
67540
|
+
const row = asRecord7(value);
|
|
67541
|
+
if (row.status === "found") {
|
|
67542
|
+
const origin = row.origin === "locale" || row.origin === "readme" ? row.origin : "readme";
|
|
67543
|
+
return {
|
|
67544
|
+
status: "found",
|
|
67545
|
+
origin,
|
|
67546
|
+
path: text(row.path, MAX_SHORT) ?? "",
|
|
67547
|
+
markdown: text(row.markdown) ?? ""
|
|
67548
|
+
};
|
|
67549
|
+
}
|
|
67550
|
+
return { status: "none" };
|
|
67551
|
+
}
|
|
67552
|
+
function projectRegistries(raw) {
|
|
67553
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67554
|
+
const fallback = Array.isArray(row.fallbackRegistries) ? row.fallbackRegistries.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "") : [];
|
|
67555
|
+
return {
|
|
67556
|
+
registry: text(row.registry, MAX_SHORT) ?? null,
|
|
67557
|
+
fallbackRegistries: fallback,
|
|
67558
|
+
resolved: text(row.resolved, MAX_SHORT) ?? null
|
|
67559
|
+
};
|
|
67560
|
+
}
|
|
67561
|
+
function projectVersionExemptions(raw) {
|
|
67562
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67563
|
+
const exemptions = {};
|
|
67564
|
+
const src = asRecord7(row.exemptions);
|
|
67565
|
+
for (const [key, versions] of Object.entries(src)) {
|
|
67566
|
+
exemptions[text(key, MAX_SHORT) ?? ""] = Array.isArray(versions) ? versions.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "") : [];
|
|
67567
|
+
}
|
|
67568
|
+
const warnings = Array.isArray(row.warnings) ? row.warnings.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "") : [];
|
|
67569
|
+
return { exemptions, warnings };
|
|
67570
|
+
}
|
|
67571
|
+
function projectInspection(raw) {
|
|
67572
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67573
|
+
if (row.status === "refused") {
|
|
67574
|
+
return {
|
|
67575
|
+
status: "refused",
|
|
67576
|
+
problem: text(row.problem, MAX_SHORT) ?? "unknown",
|
|
67577
|
+
reason: text(row.reason) ?? ""
|
|
67578
|
+
};
|
|
67579
|
+
}
|
|
67580
|
+
const bundle = row.bundle === true ? true : row.bundle === false ? false : null;
|
|
67581
|
+
const accepted = { status: "accepted", bundle };
|
|
67582
|
+
const name = text(row.name, MAX_SHORT);
|
|
67583
|
+
const version = text(row.version, MAX_SHORT);
|
|
67584
|
+
const description = text(row.description);
|
|
67585
|
+
if (name !== undefined)
|
|
67586
|
+
accepted.name = name;
|
|
67587
|
+
if (version !== undefined)
|
|
67588
|
+
accepted.version = version;
|
|
67589
|
+
if (description !== undefined)
|
|
67590
|
+
accepted.description = description;
|
|
67591
|
+
return accepted;
|
|
67592
|
+
}
|
|
67593
|
+
function projectVersions(raw) {
|
|
67594
|
+
const value = unwrapWireValue(raw);
|
|
67595
|
+
if (!Array.isArray(value))
|
|
67596
|
+
return [];
|
|
67597
|
+
return value.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "");
|
|
67598
|
+
}
|
|
67599
|
+
function projectChange(raw) {
|
|
67600
|
+
const value = unwrapWireValue(raw);
|
|
67601
|
+
const row = asRecord7(value);
|
|
67602
|
+
const application = row.application;
|
|
67603
|
+
const safeApplication = application === "applied" || application === "restart-required" || application === "overridden" || application === "failed" || application === "cancelled" ? application : "failed";
|
|
67604
|
+
const target = text(row.target, MAX_SHORT) ?? "";
|
|
67605
|
+
const requestId = text(row.requestId, MAX_SHORT);
|
|
67606
|
+
const errorObj = row.error;
|
|
67607
|
+
const error = typeof errorObj === "string" ? errorObj.slice(0, MAX_SHORT) : text(asRecord7(errorObj).diagnostic, MAX_SHORT) ?? text(asRecord7(errorObj).code, MAX_SHORT);
|
|
67608
|
+
const out = {
|
|
67609
|
+
changed: safeApplication === "failed" ? false : row.changed === true,
|
|
67610
|
+
application: safeApplication,
|
|
67611
|
+
target
|
|
67612
|
+
};
|
|
67613
|
+
if (error !== undefined)
|
|
67614
|
+
out.error = error;
|
|
67615
|
+
if (requestId !== undefined && requestId !== "")
|
|
67616
|
+
out.requestId = requestId;
|
|
67617
|
+
return out;
|
|
67618
|
+
}
|
|
67619
|
+
function projectInstallProgress(raw, requestId) {
|
|
67620
|
+
if (raw === null || raw === undefined)
|
|
67621
|
+
return { state: "done", requestId };
|
|
67622
|
+
const value = unwrapWireValue(raw);
|
|
67623
|
+
if (value === null || value === undefined)
|
|
67624
|
+
return { state: "done", requestId };
|
|
67625
|
+
const row = asRecord7(value);
|
|
67626
|
+
const application = row.application;
|
|
67627
|
+
const target = text(row.target, MAX_SHORT) ?? "";
|
|
67628
|
+
if (application === "cancelled")
|
|
67629
|
+
return { state: "cancelled", requestId, target };
|
|
67630
|
+
if (application === "failed") {
|
|
67631
|
+
const errorObj = row.error;
|
|
67632
|
+
const error = typeof errorObj === "string" ? errorObj.slice(0, MAX_SHORT) : text(asRecord7(errorObj).diagnostic, MAX_SHORT) ?? text(asRecord7(errorObj).code, MAX_SHORT);
|
|
67633
|
+
return error !== undefined ? { state: "failed", requestId, target, error } : { state: "failed", requestId, target };
|
|
67634
|
+
}
|
|
67635
|
+
if (application === "applied" || application === "restart-required" || application === "overridden") {
|
|
67636
|
+
return { state: "done", requestId, target };
|
|
67637
|
+
}
|
|
67638
|
+
return { state: "unknown", requestId };
|
|
67639
|
+
}
|
|
67640
|
+
function projectCancellation(raw) {
|
|
67641
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67642
|
+
const status = row.status;
|
|
67643
|
+
if (status === "cancelled" || status === "too-late" || status === "not-running")
|
|
67644
|
+
return { status };
|
|
67645
|
+
return { status: "not-running" };
|
|
67646
|
+
}
|
|
67647
|
+
var MAX_TEXT = 4096, MAX_SHORT = 240;
|
|
67648
|
+
|
|
67649
|
+
// src/client/bridge-directory.ts
|
|
67650
|
+
function asRecord8(value) {
|
|
67651
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
67652
|
+
}
|
|
67653
|
+
function unwrapWireValue2(raw) {
|
|
67654
|
+
const rec = asRecord8(raw);
|
|
67655
|
+
if (Object.prototype.hasOwnProperty.call(rec, "value"))
|
|
67656
|
+
return rec.value;
|
|
67657
|
+
return raw;
|
|
67658
|
+
}
|
|
67659
|
+
function text2(value, max = MAX_TEXT2) {
|
|
67660
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
67661
|
+
}
|
|
67662
|
+
function projectLlmProviders(raw) {
|
|
67663
|
+
const value = unwrapWireValue2(raw);
|
|
67664
|
+
if (!Array.isArray(value))
|
|
67665
|
+
return [];
|
|
67666
|
+
const out = [];
|
|
67667
|
+
for (const entry of value) {
|
|
67668
|
+
const row = asRecord8(entry);
|
|
67669
|
+
const id = text2(row.id, MAX_SHORT2);
|
|
67670
|
+
const name = text2(row.name, MAX_SHORT2);
|
|
67671
|
+
if (id === undefined || id === "" || name === undefined)
|
|
67672
|
+
continue;
|
|
67673
|
+
out.push({ id, name });
|
|
67674
|
+
if (out.length >= MAX_ROWS2)
|
|
67675
|
+
break;
|
|
67676
|
+
}
|
|
67677
|
+
return out;
|
|
67678
|
+
}
|
|
67679
|
+
function envNames(value) {
|
|
67680
|
+
if (!Array.isArray(value))
|
|
67681
|
+
return;
|
|
67682
|
+
const names = [];
|
|
67683
|
+
for (const item of value) {
|
|
67684
|
+
if (typeof item === "string" && item.length > 0 && names.length < 16)
|
|
67685
|
+
names.push(item.slice(0, MAX_SHORT2));
|
|
67686
|
+
}
|
|
67687
|
+
return names.length > 0 ? names : undefined;
|
|
67688
|
+
}
|
|
67689
|
+
function projectConfigurableProviders(raw) {
|
|
67690
|
+
const value = unwrapWireValue2(raw);
|
|
67691
|
+
if (!Array.isArray(value))
|
|
67692
|
+
return [];
|
|
67693
|
+
const out = [];
|
|
67694
|
+
for (const entry of value) {
|
|
67695
|
+
const row = asRecord8(entry);
|
|
67696
|
+
const provider = text2(row.provider, MAX_SHORT2);
|
|
67697
|
+
const displayName = text2(row.displayName, MAX_SHORT2);
|
|
67698
|
+
if (provider === undefined || provider === "" || displayName === undefined)
|
|
67699
|
+
continue;
|
|
67700
|
+
const projected = { provider, displayName };
|
|
67701
|
+
const settingsNs = text2(row.settingsNs, MAX_SHORT2);
|
|
67702
|
+
if (settingsNs !== undefined)
|
|
67703
|
+
projected.settingsNs = settingsNs;
|
|
67704
|
+
if (row.declared === true || row.declared === false)
|
|
67705
|
+
projected.declared = row.declared;
|
|
67706
|
+
const auth = asRecord8(row.nativeAuth);
|
|
67707
|
+
const authEnv = envNames(auth.env);
|
|
67708
|
+
if (authEnv !== undefined)
|
|
67709
|
+
projected.authEnvNames = authEnv;
|
|
67710
|
+
const baseEnv = envNames(row.baseURLEnv);
|
|
67711
|
+
if (baseEnv !== undefined) {
|
|
67712
|
+
projected.authEnvNames = [...projected.authEnvNames ?? [], ...baseEnv].slice(0, 16);
|
|
67713
|
+
}
|
|
67714
|
+
const error = text2(row.error, MAX_SHORT2);
|
|
67715
|
+
if (error !== undefined)
|
|
67716
|
+
projected.error = error;
|
|
67717
|
+
out.push(projected);
|
|
67718
|
+
if (out.length >= MAX_ROWS2)
|
|
67719
|
+
break;
|
|
67720
|
+
}
|
|
67721
|
+
return out;
|
|
67722
|
+
}
|
|
67723
|
+
function projectOptions(value) {
|
|
67724
|
+
if (!Array.isArray(value))
|
|
67725
|
+
return [];
|
|
67726
|
+
const out = [];
|
|
67727
|
+
for (const entry of value) {
|
|
67728
|
+
const row = asRecord8(entry);
|
|
67729
|
+
const key = text2(row.value, MAX_SHORT2);
|
|
67730
|
+
if (key === undefined || key === "")
|
|
67731
|
+
continue;
|
|
67732
|
+
const opt = { value: key };
|
|
67733
|
+
const name = text2(row.name, MAX_SHORT2);
|
|
67734
|
+
if (name !== undefined)
|
|
67735
|
+
opt.name = name;
|
|
67736
|
+
const description = text2(row.description, MAX_TEXT2);
|
|
67737
|
+
if (description !== undefined)
|
|
67738
|
+
opt.description = description;
|
|
67739
|
+
out.push(opt);
|
|
67740
|
+
if (out.length >= MAX_ROWS2)
|
|
67741
|
+
break;
|
|
67742
|
+
}
|
|
67743
|
+
return out;
|
|
67744
|
+
}
|
|
67745
|
+
function projectPermissionCatalog(raw) {
|
|
67746
|
+
const value = unwrapWireValue2(raw);
|
|
67747
|
+
const rec = asRecord8(value);
|
|
67748
|
+
const options = projectOptions(rec.options);
|
|
67749
|
+
const defaultOptions = projectOptions(rec.defaultOptions);
|
|
67750
|
+
const defaultPreset = text2(rec.defaultPreset, MAX_SHORT2) ?? "";
|
|
67751
|
+
if (options.length === 0 && defaultOptions.length === 0 && defaultPreset === "")
|
|
67752
|
+
return;
|
|
67753
|
+
return { options, defaultOptions, defaultPreset };
|
|
67754
|
+
}
|
|
67755
|
+
function cappedNumber(value) {
|
|
67756
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.min(value, MAX_NUM) : undefined;
|
|
67757
|
+
}
|
|
67758
|
+
function projectDiscoverModels(raw) {
|
|
67759
|
+
const value = unwrapWireValue2(raw);
|
|
67760
|
+
if (!Array.isArray(value))
|
|
67761
|
+
return [];
|
|
67762
|
+
const out = [];
|
|
67763
|
+
for (const entry of value) {
|
|
67764
|
+
const row = asRecord8(entry);
|
|
67765
|
+
const id = text2(row.id, MAX_SHORT2);
|
|
67766
|
+
if (id === undefined || id === "")
|
|
67767
|
+
continue;
|
|
67768
|
+
const projected = { id };
|
|
67769
|
+
const name = text2(row.name, MAX_SHORT2);
|
|
67770
|
+
if (name !== undefined)
|
|
67771
|
+
projected.name = name;
|
|
67772
|
+
const cw = cappedNumber(row.contextWindow);
|
|
67773
|
+
if (cw !== undefined)
|
|
67774
|
+
projected.contextWindow = cw;
|
|
67775
|
+
const mt = cappedNumber(row.maxTokens);
|
|
67776
|
+
if (mt !== undefined)
|
|
67777
|
+
projected.maxTokens = mt;
|
|
67778
|
+
if (Array.isArray(row.inputModalities)) {
|
|
67779
|
+
const mods = row.inputModalities.filter((m) => m === "text" || m === "image").slice(0, 4);
|
|
67780
|
+
if (mods.length > 0)
|
|
67781
|
+
projected.inputModalities = mods;
|
|
67782
|
+
}
|
|
67783
|
+
out.push(projected);
|
|
67784
|
+
if (out.length >= MAX_ROWS2)
|
|
67785
|
+
break;
|
|
67786
|
+
}
|
|
67787
|
+
return out;
|
|
67788
|
+
}
|
|
67789
|
+
var MAX_TEXT2 = 4096, MAX_SHORT2 = 240, MAX_ROWS2 = 512, MAX_NUM = 1e7;
|
|
67790
|
+
|
|
67791
|
+
// src/client/bridge-goals.ts
|
|
67792
|
+
function asRecord9(value) {
|
|
67793
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
67794
|
+
}
|
|
67795
|
+
function unwrapGoalsValue(raw) {
|
|
67796
|
+
const rec = asRecord9(raw);
|
|
67797
|
+
if (Object.prototype.hasOwnProperty.call(rec, "value"))
|
|
67798
|
+
return rec.value;
|
|
67799
|
+
return raw;
|
|
67800
|
+
}
|
|
67801
|
+
function text3(value, max = MAX_TEXT3) {
|
|
67802
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
67803
|
+
}
|
|
67804
|
+
function finiteNumber(value) {
|
|
67805
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
67806
|
+
}
|
|
67807
|
+
function oneOf(value, set) {
|
|
67808
|
+
return typeof value === "string" && set.includes(value) ? value : undefined;
|
|
67809
|
+
}
|
|
67810
|
+
function projectGoalRef(raw) {
|
|
67811
|
+
const rec = asRecord9(unwrapGoalsValue(raw));
|
|
67812
|
+
const id = text3(rec.id, MAX_SHORT3);
|
|
67813
|
+
const revision = finiteNumber(rec.revision);
|
|
67814
|
+
if (id === undefined || id === "" || revision === undefined)
|
|
67815
|
+
return;
|
|
67816
|
+
return { id, revision };
|
|
67817
|
+
}
|
|
67818
|
+
function projectGoalView(raw) {
|
|
67819
|
+
const value = unwrapGoalsValue(raw);
|
|
67820
|
+
if (value === null || value === undefined)
|
|
67821
|
+
return;
|
|
67822
|
+
const rec = asRecord9(value);
|
|
67823
|
+
const id = text3(rec.id, MAX_SHORT3);
|
|
67824
|
+
const revision = finiteNumber(rec.revision);
|
|
67825
|
+
const objective = text3(rec.objective, MAX_TEXT3);
|
|
67826
|
+
const phase = oneOf(rec.phase, PHASES);
|
|
67827
|
+
const activation = oneOf(rec.activation, ACTIVATIONS);
|
|
67828
|
+
const roundsStarted = finiteNumber(rec.roundsStarted);
|
|
67829
|
+
const maxGoalRounds = finiteNumber(rec.maxGoalRounds);
|
|
67830
|
+
const createdAt = finiteNumber(rec.createdAt);
|
|
67831
|
+
const updatedAt = finiteNumber(rec.updatedAt);
|
|
67832
|
+
if (id === undefined || id === "" || revision === undefined || objective === undefined || phase === undefined || activation === undefined || roundsStarted === undefined || maxGoalRounds === undefined || createdAt === undefined || updatedAt === undefined)
|
|
67833
|
+
return;
|
|
67834
|
+
const view = {
|
|
67835
|
+
id,
|
|
67836
|
+
revision,
|
|
67837
|
+
objective,
|
|
67838
|
+
phase,
|
|
67839
|
+
activation,
|
|
67840
|
+
roundsStarted,
|
|
67841
|
+
maxGoalRounds,
|
|
67842
|
+
createdAt,
|
|
67843
|
+
updatedAt
|
|
67844
|
+
};
|
|
67845
|
+
const reason = asRecord9(rec.blockedReason);
|
|
67846
|
+
const code = text3(reason.code, MAX_SHORT3);
|
|
67847
|
+
const message = text3(reason.message, MAX_TEXT3);
|
|
67848
|
+
if (code !== undefined && message !== undefined)
|
|
67849
|
+
view.blockedReason = { code, message };
|
|
67850
|
+
return view;
|
|
67851
|
+
}
|
|
67852
|
+
function projectCreateGoalResult(raw) {
|
|
67853
|
+
const rec = asRecord9(unwrapGoalsValue(raw));
|
|
67854
|
+
return projectGoalRef(rec.ref);
|
|
67855
|
+
}
|
|
67856
|
+
var MAX_TEXT3 = 4096, MAX_SHORT3 = 240, PHASES, ACTIVATIONS;
|
|
67857
|
+
var init_bridge_goals = __esm(() => {
|
|
67858
|
+
PHASES = ["active", "paused", "blocked", "complete"];
|
|
67859
|
+
ACTIVATIONS = ["armed", "disarmed"];
|
|
67860
|
+
});
|
|
67861
|
+
|
|
67862
|
+
// src/client/bridge-permission.ts
|
|
67863
|
+
function asRecord10(value) {
|
|
67864
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
67865
|
+
}
|
|
67866
|
+
function unwrapWireValue3(raw) {
|
|
67867
|
+
const rec = asRecord10(raw);
|
|
67868
|
+
if (Object.prototype.hasOwnProperty.call(rec, "value"))
|
|
67869
|
+
return rec.value;
|
|
67870
|
+
return raw;
|
|
67871
|
+
}
|
|
67872
|
+
function cleanText(value, max = MAX_TEXT4) {
|
|
67873
|
+
if (typeof value !== "string")
|
|
67874
|
+
return;
|
|
67875
|
+
return value.replace(/[\u0000-\u001f\u007f-\u009f]/g, "").slice(0, max);
|
|
67876
|
+
}
|
|
67877
|
+
function projectPermissionSwitch(raw) {
|
|
67878
|
+
const value = unwrapWireValue3(raw);
|
|
67879
|
+
if (value === null || value === undefined) {
|
|
67880
|
+
return { ok: false, matched: false, text: "" };
|
|
67881
|
+
}
|
|
67882
|
+
const rec = asRecord10(value);
|
|
67883
|
+
const empty = Object.keys(rec).length === 0;
|
|
67884
|
+
if (empty)
|
|
67885
|
+
return { ok: false, matched: false, text: "" };
|
|
67886
|
+
const result = asRecord10(rec.result);
|
|
67887
|
+
const kind = cleanText(result.kind, MAX_SHORT4) ?? cleanText(rec.kind, MAX_SHORT4);
|
|
67888
|
+
const text = cleanText(result.text, MAX_TEXT4) ?? cleanText(rec.text, MAX_TEXT4) ?? "";
|
|
67889
|
+
if (kind === undefined && text === "")
|
|
67890
|
+
return { ok: false, matched: false, text: "" };
|
|
67891
|
+
return { ok: kind !== "error", matched: true, text };
|
|
67892
|
+
}
|
|
67893
|
+
var MAX_TEXT4 = 4096, MAX_SHORT4 = 240;
|
|
67894
|
+
|
|
66399
67895
|
// src/client/bridge-session-seam.ts
|
|
67896
|
+
import { existsSync as existsSync13, readFileSync as readFileSync14, readdirSync as readdirSync4 } from "fs";
|
|
67897
|
+
import { join as join16 } from "path";
|
|
67898
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
67899
|
+
function writeConfirmed(confirm) {
|
|
67900
|
+
return typeof confirm === "object" && confirm !== null && confirm.__pluginWriteConfirm === true && typeof confirm.operation === "string";
|
|
67901
|
+
}
|
|
66400
67902
|
function askTurnId(eventId) {
|
|
66401
67903
|
const i = eventId.lastIndexOf(":ask-");
|
|
66402
67904
|
return i === -1 ? "" : eventId.slice(0, i);
|
|
@@ -66406,7 +67908,7 @@ function optionalStringField(row, key) {
|
|
|
66406
67908
|
return typeof value === "string" && value !== "" ? value : undefined;
|
|
66407
67909
|
}
|
|
66408
67910
|
function parseAskRequest(value) {
|
|
66409
|
-
const row =
|
|
67911
|
+
const row = asRecord11(value);
|
|
66410
67912
|
const eventId = optionalStringField(row, "eventId");
|
|
66411
67913
|
const sessionId = optionalStringField(row, "sessionId");
|
|
66412
67914
|
const kind = row.kind;
|
|
@@ -66429,14 +67931,14 @@ function parseAskRequest(value) {
|
|
|
66429
67931
|
if (Array.isArray(row.questions)) {
|
|
66430
67932
|
const questions = [];
|
|
66431
67933
|
for (const raw of row.questions) {
|
|
66432
|
-
const q =
|
|
67934
|
+
const q = asRecord11(raw);
|
|
66433
67935
|
const id = optionalStringField(q, "id");
|
|
66434
67936
|
const prompt = optionalStringField(q, "prompt");
|
|
66435
67937
|
if (id === undefined || prompt === undefined || !Array.isArray(q.options))
|
|
66436
67938
|
continue;
|
|
66437
67939
|
const options = [];
|
|
66438
67940
|
for (const rawOpt of q.options) {
|
|
66439
|
-
const opt =
|
|
67941
|
+
const opt = asRecord11(rawOpt);
|
|
66440
67942
|
const label = optionalStringField(opt, "label");
|
|
66441
67943
|
if (label === undefined)
|
|
66442
67944
|
continue;
|
|
@@ -66506,9 +68008,25 @@ function answersFor(request, picks) {
|
|
|
66506
68008
|
function unavailableResponse(request) {
|
|
66507
68009
|
return request.kind === "questions" ? { eventId: request.eventId, kind: "questions", verdict: "unavailable", answers: answersFor(request, []) } : { eventId: request.eventId, kind: "approval", verdict: "unavailable" };
|
|
66508
68010
|
}
|
|
66509
|
-
function
|
|
68011
|
+
function asRecord11(value) {
|
|
66510
68012
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
66511
68013
|
}
|
|
68014
|
+
function projectSeamAccountView(value) {
|
|
68015
|
+
const v = asRecord11(value);
|
|
68016
|
+
return {
|
|
68017
|
+
status: typeof v.status === "string" && ACCOUNT_STATUSES.has(v.status) ? v.status : null,
|
|
68018
|
+
attemptPhase: typeof v.attemptPhase === "string" && ACCOUNT_PHASES.has(v.attemptPhase) ? v.attemptPhase : null,
|
|
68019
|
+
authorizeUrlReady: v.authorizeUrlReady === true,
|
|
68020
|
+
linksPresent: v.linksPresent === true
|
|
68021
|
+
};
|
|
68022
|
+
}
|
|
68023
|
+
function accountClientMeta() {
|
|
68024
|
+
return {
|
|
68025
|
+
version: "0.25-w1b",
|
|
68026
|
+
locale: typeof Intl !== "undefined" ? Intl.DateTimeFormat().resolvedOptions().locale : "en",
|
|
68027
|
+
timezoneOffsetSeconds: -new Date().getTimezoneOffset() * 60
|
|
68028
|
+
};
|
|
68029
|
+
}
|
|
66512
68030
|
function unsupported(capability) {
|
|
66513
68031
|
throw new BridgeProtocolError("UNSUPPORTED", `${capability} is not backed by the in-process bridge`, { capability });
|
|
66514
68032
|
}
|
|
@@ -66516,14 +68034,14 @@ function projectBridgeSessionList(items, limit = 12) {
|
|
|
66516
68034
|
const rows = Array.isArray(items) ? items : [];
|
|
66517
68035
|
const out = [];
|
|
66518
68036
|
for (const item of rows) {
|
|
66519
|
-
const row =
|
|
68037
|
+
const row = asRecord11(item);
|
|
66520
68038
|
if (row.origin === "subagent")
|
|
66521
68039
|
continue;
|
|
66522
68040
|
const id = typeof row.sessionId === "string" ? row.sessionId : "";
|
|
66523
68041
|
if (!id)
|
|
66524
68042
|
continue;
|
|
66525
68043
|
const updatedAt = typeof row.updatedAt === "number" ? String(row.updatedAt) : "";
|
|
66526
|
-
const values =
|
|
68044
|
+
const values = asRecord11(asRecord11(row.projections).values);
|
|
66527
68045
|
const title = typeof values.title === "string" ? values.title : "";
|
|
66528
68046
|
out.push({
|
|
66529
68047
|
id,
|
|
@@ -66536,12 +68054,23 @@ function projectBridgeSessionList(items, limit = 12) {
|
|
|
66536
68054
|
}
|
|
66537
68055
|
return out.sort((a, b) => String(b.updatedAt ?? "").localeCompare(String(a.updatedAt ?? ""))).slice(0, limit);
|
|
66538
68056
|
}
|
|
68057
|
+
function projectCurrentCwd(items, sessionId) {
|
|
68058
|
+
if (sessionId === undefined || sessionId === "" || !Array.isArray(items))
|
|
68059
|
+
return;
|
|
68060
|
+
for (const item of items) {
|
|
68061
|
+
const row = asRecord11(item);
|
|
68062
|
+
if (row.sessionId !== sessionId)
|
|
68063
|
+
continue;
|
|
68064
|
+
return typeof row.cwd === "string" && row.cwd !== "" ? row.cwd : undefined;
|
|
68065
|
+
}
|
|
68066
|
+
return;
|
|
68067
|
+
}
|
|
66539
68068
|
function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
|
|
66540
68069
|
const entries = rows.map((row) => ({
|
|
66541
68070
|
type: row.type,
|
|
66542
68071
|
seq: row.seq,
|
|
66543
68072
|
time: 0,
|
|
66544
|
-
data:
|
|
68073
|
+
data: asRecord11(row.payload)
|
|
66545
68074
|
}));
|
|
66546
68075
|
const durable = journalToTranscriptRows(entries, skip);
|
|
66547
68076
|
return durable.map((row) => {
|
|
@@ -66555,8 +68084,8 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
|
|
|
66555
68084
|
});
|
|
66556
68085
|
}
|
|
66557
68086
|
function seamReplayEventKey(event) {
|
|
66558
|
-
const details =
|
|
66559
|
-
return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(
|
|
68087
|
+
const details = asRecord11(event.details);
|
|
68088
|
+
return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord11(details.part).id ?? "")}`;
|
|
66560
68089
|
}
|
|
66561
68090
|
function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
66562
68091
|
const events = [];
|
|
@@ -66570,7 +68099,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
|
66570
68099
|
};
|
|
66571
68100
|
const toolCalls = new Map;
|
|
66572
68101
|
for (const row of rows) {
|
|
66573
|
-
const entry = { type: row.type, seq: row.seq, time: 0, data:
|
|
68102
|
+
const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord11(row.payload) };
|
|
66574
68103
|
for (const event of projectJournalRecord(entry, sessionId))
|
|
66575
68104
|
push(event);
|
|
66576
68105
|
const data = entry.data;
|
|
@@ -66584,7 +68113,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
|
66584
68113
|
});
|
|
66585
68114
|
}
|
|
66586
68115
|
} else if (row.type === "tool/result") {
|
|
66587
|
-
const message =
|
|
68116
|
+
const message = asRecord11(data.message);
|
|
66588
68117
|
const callId = data.callId !== undefined ? String(data.callId) : message.toolCallId !== undefined ? String(message.toolCallId) : "";
|
|
66589
68118
|
const call = callId ? toolCalls.get(callId) : undefined;
|
|
66590
68119
|
if (call !== undefined) {
|
|
@@ -66638,7 +68167,7 @@ function bridgeSettleChild(existing, outcome, startedAt, now) {
|
|
|
66638
68167
|
}
|
|
66639
68168
|
function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, live) {
|
|
66640
68169
|
if (type === "user/message") {
|
|
66641
|
-
const source =
|
|
68170
|
+
const source = asRecord11(data.source);
|
|
66642
68171
|
if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
|
|
66643
68172
|
return false;
|
|
66644
68173
|
const childId = typeof source.senderSessionId === "string" ? source.senderSessionId : "";
|
|
@@ -66733,7 +68262,7 @@ function bridgeSweepSettledChildIds(rows, parentId, locallyRunning) {
|
|
|
66733
68262
|
return [];
|
|
66734
68263
|
const settled = [];
|
|
66735
68264
|
for (const raw of rows) {
|
|
66736
|
-
const row =
|
|
68265
|
+
const row = asRecord11(raw);
|
|
66737
68266
|
if (row.origin !== "subagent")
|
|
66738
68267
|
continue;
|
|
66739
68268
|
if (row.parentSessionId !== parentId)
|
|
@@ -66783,16 +68312,16 @@ function bridgeChildJournalMeta(rows) {
|
|
|
66783
68312
|
let contextModel;
|
|
66784
68313
|
let descriptorModel;
|
|
66785
68314
|
for (const row of rows) {
|
|
66786
|
-
const data =
|
|
68315
|
+
const data = asRecord11(row.payload);
|
|
66787
68316
|
if (row.type === "assistant/message") {
|
|
66788
68317
|
rounds += 1;
|
|
66789
|
-
const message =
|
|
68318
|
+
const message = asRecord11(data.message);
|
|
66790
68319
|
const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
|
|
66791
68320
|
if (tail !== undefined)
|
|
66792
68321
|
lastLine = tail;
|
|
66793
68322
|
} else if (row.type === "tool/result") {
|
|
66794
68323
|
if (data.isError !== true) {
|
|
66795
|
-
const message =
|
|
68324
|
+
const message = asRecord11(data.message);
|
|
66796
68325
|
const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
|
|
66797
68326
|
if (tail !== undefined)
|
|
66798
68327
|
lastLine = tail;
|
|
@@ -66814,12 +68343,23 @@ function bridgeChildJournalMeta(rows) {
|
|
|
66814
68343
|
...model !== undefined ? { model } : {}
|
|
66815
68344
|
};
|
|
66816
68345
|
}
|
|
68346
|
+
function bridgeReplayRowsToChildLog(rows) {
|
|
68347
|
+
return bridgeReplayRowsToSeamTranscript(rows).map((row) => {
|
|
68348
|
+
if (row.kind === "tool") {
|
|
68349
|
+
return row.output ? `\u25B6 ${row.text}
|
|
68350
|
+
\u23BF ${row.output}` : `\u25B6 ${row.text}`;
|
|
68351
|
+
}
|
|
68352
|
+
if (row.kind === "ask")
|
|
68353
|
+
return "[ask]";
|
|
68354
|
+
return row.text;
|
|
68355
|
+
}).filter((line) => line !== "");
|
|
68356
|
+
}
|
|
66817
68357
|
function bridgeChildStopReason(rows) {
|
|
66818
68358
|
for (let i = rows.length - 1;i >= 0; i -= 1) {
|
|
66819
68359
|
const row = rows[i];
|
|
66820
68360
|
if (row.type !== "user/message")
|
|
66821
68361
|
continue;
|
|
66822
|
-
const source =
|
|
68362
|
+
const source = asRecord11(asRecord11(row.payload).source);
|
|
66823
68363
|
if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
|
|
66824
68364
|
continue;
|
|
66825
68365
|
const reason = source.stopReason;
|
|
@@ -66830,7 +68370,7 @@ function bridgeChildStopReason(rows) {
|
|
|
66830
68370
|
const row = rows[i];
|
|
66831
68371
|
if (row.type !== "turn/end")
|
|
66832
68372
|
continue;
|
|
66833
|
-
const reason =
|
|
68373
|
+
const reason = asRecord11(asRecord11(row.payload).reason);
|
|
66834
68374
|
const kind = reason.kind;
|
|
66835
68375
|
if (typeof kind === "string" && kind !== "")
|
|
66836
68376
|
return kind;
|
|
@@ -66888,7 +68428,7 @@ function lastJournalTurnTerminal(rows, startOutsideWindow = false) {
|
|
|
66888
68428
|
return latest;
|
|
66889
68429
|
}
|
|
66890
68430
|
function journalTurnId(row) {
|
|
66891
|
-
const payload =
|
|
68431
|
+
const payload = asRecord11(row.payload);
|
|
66892
68432
|
if (typeof payload.turn === "number" && Number.isFinite(payload.turn))
|
|
66893
68433
|
return payload.turn;
|
|
66894
68434
|
if (typeof payload.turnId === "string" && payload.turnId !== "")
|
|
@@ -66896,7 +68436,7 @@ function journalTurnId(row) {
|
|
|
66896
68436
|
return;
|
|
66897
68437
|
}
|
|
66898
68438
|
function projectBridgeEvent(frame, sessionId) {
|
|
66899
|
-
const payload =
|
|
68439
|
+
const payload = asRecord11(frame.payload);
|
|
66900
68440
|
const turnId = typeof payload.turnId === "string" ? payload.turnId : "";
|
|
66901
68441
|
if (frame.type === "turn.start") {
|
|
66902
68442
|
return [{ type: "session.updated", details: { sessionID: sessionId, turnId, turn: "starting" } }];
|
|
@@ -66918,7 +68458,7 @@ function projectBridgeEvent(frame, sessionId) {
|
|
|
66918
68458
|
return [];
|
|
66919
68459
|
}
|
|
66920
68460
|
function parseUsage(value) {
|
|
66921
|
-
const u =
|
|
68461
|
+
const u = asRecord11(value);
|
|
66922
68462
|
const num = (...aliases) => {
|
|
66923
68463
|
let present = false;
|
|
66924
68464
|
let best = 0;
|
|
@@ -66947,7 +68487,7 @@ function parseUsage(value) {
|
|
|
66947
68487
|
return out;
|
|
66948
68488
|
}
|
|
66949
68489
|
function journalUsage(payload) {
|
|
66950
|
-
const usage =
|
|
68490
|
+
const usage = asRecord11(asRecord11(payload).usage);
|
|
66951
68491
|
const parsed = parseUsage(usage);
|
|
66952
68492
|
if (Object.keys(parsed).length === 0)
|
|
66953
68493
|
return;
|
|
@@ -66957,7 +68497,7 @@ function journalUsage(payload) {
|
|
|
66957
68497
|
return { ...parsed, total };
|
|
66958
68498
|
}
|
|
66959
68499
|
function asDeadCause(value) {
|
|
66960
|
-
const r =
|
|
68500
|
+
const r = asRecord11(value);
|
|
66961
68501
|
const stage = r.stage;
|
|
66962
68502
|
const stages = ["spawn", "handshake", "runtime", "closed"];
|
|
66963
68503
|
return {
|
|
@@ -66978,10 +68518,40 @@ class BridgeSessionSeam {
|
|
|
66978
68518
|
#configStore;
|
|
66979
68519
|
#settingsStore;
|
|
66980
68520
|
#localAgents;
|
|
68521
|
+
#localPresets;
|
|
68522
|
+
#localLogin;
|
|
68523
|
+
#pluginBundlesCache = [];
|
|
68524
|
+
#pluginsManagerAvailable = undefined;
|
|
68525
|
+
#goalsAvailable = undefined;
|
|
66981
68526
|
settings = {
|
|
66982
68527
|
describe: () => Promise.resolve(this.#settingsStore.describe()),
|
|
66983
68528
|
mutate: (ns, ops, revision) => Promise.resolve(this.#settingsStore.mutate(ns, ops, revision)),
|
|
66984
|
-
identity: () => ({ profile: this.#profile, dshHome: this.#dshHome })
|
|
68529
|
+
identity: () => ({ profile: this.#profile, dshHome: this.#dshHome }),
|
|
68530
|
+
permissionCatalog: () => this.#readPermissionCatalog()
|
|
68531
|
+
};
|
|
68532
|
+
permission = {
|
|
68533
|
+
catalog: () => this.#readPermissionCatalog(),
|
|
68534
|
+
switch: (preset) => this.#permissionSwitch(preset)
|
|
68535
|
+
};
|
|
68536
|
+
providerDirectory = {
|
|
68537
|
+
registered: () => this.#directoryRequest("llm.listProviders", projectLlmProviders),
|
|
68538
|
+
configurable: () => this.#directoryRequest("llm.listConfigurableProviders", projectConfigurableProviders),
|
|
68539
|
+
discover: (settingsNs, request) => this.#directoryRequest("llm.discoverModels", projectDiscoverModels, { settingsNs, request })
|
|
68540
|
+
};
|
|
68541
|
+
goals = {
|
|
68542
|
+
status: () => this.#goalsRequest("goals.get", {}, projectGoalView),
|
|
68543
|
+
available: () => this.#goalsAvailable === true,
|
|
68544
|
+
create: (objective, maxGoalRounds) => {
|
|
68545
|
+
const request = { objective };
|
|
68546
|
+
if (maxGoalRounds !== undefined)
|
|
68547
|
+
request.maxGoalRounds = maxGoalRounds;
|
|
68548
|
+
return this.#goalsRequest("goals.create", { request }, projectCreateGoalResult);
|
|
68549
|
+
},
|
|
68550
|
+
edit: (ref, patch) => this.#goalsRequest("goals.edit", { ref, request: patch }, projectGoalView),
|
|
68551
|
+
complete: (ref) => this.#goalsRequest("goals.complete", { ref }, projectGoalView),
|
|
68552
|
+
pause: (ref) => this.#goalsRequest("goals.pause", { ref }, projectGoalView),
|
|
68553
|
+
resume: (ref) => this.#goalsRequest("goals.resume", { ref }, projectGoalView),
|
|
68554
|
+
clear: (ref) => this.#goalsRequest("goals.clear", { ref }, projectGoalRef)
|
|
66985
68555
|
};
|
|
66986
68556
|
agents = {
|
|
66987
68557
|
list: () => this.#localAgents.list(),
|
|
@@ -66991,6 +68561,254 @@ class BridgeSessionSeam {
|
|
|
66991
68561
|
modelEfforts: (providerID, modelID) => this.#localAgents.modelEfforts(providerID, modelID),
|
|
66992
68562
|
officialCaps: () => this.#localAgents.officialCaps()
|
|
66993
68563
|
};
|
|
68564
|
+
preset = {
|
|
68565
|
+
list: () => Promise.resolve(this.#localPresets.list()),
|
|
68566
|
+
currentId: () => Promise.resolve(this.#localPresets.currentId()),
|
|
68567
|
+
select: (presetId) => Promise.resolve(this.#localPresets.select(presetId))
|
|
68568
|
+
};
|
|
68569
|
+
login = {
|
|
68570
|
+
credentialStatus: (ref) => Promise.resolve(this.#localLogin.credentialStatus(ref)),
|
|
68571
|
+
login: (ref, apiKey) => {
|
|
68572
|
+
this.#localLogin.login(ref, apiKey);
|
|
68573
|
+
return Promise.resolve();
|
|
68574
|
+
},
|
|
68575
|
+
logout: (ref) => {
|
|
68576
|
+
this.#localLogin.logout(ref);
|
|
68577
|
+
return Promise.resolve();
|
|
68578
|
+
},
|
|
68579
|
+
routes: () => Promise.resolve(this.#localLogin.routes()),
|
|
68580
|
+
registerRoute: (providerId, profile) => Promise.resolve(this.#localLogin.registerRoute(providerId, profile))
|
|
68581
|
+
};
|
|
68582
|
+
account = {
|
|
68583
|
+
getState: async () => projectSeamAccountView(await this.#transport.request("account.getState")),
|
|
68584
|
+
startSignIn: async (callbackOrigin, loginSource) => projectSeamAccountView(await this.#transport.request("account.startSignIn", { client: accountClientMeta(), callbackOrigin, loginSource })),
|
|
68585
|
+
cancelSignIn: async (attemptId) => projectSeamAccountView(await this.#transport.request("account.cancelSignIn", { attemptId })),
|
|
68586
|
+
signOut: async () => projectSeamAccountView(await this.#transport.request("account.signOut", { client: accountClientMeta() })),
|
|
68587
|
+
hasRunningAccountTasks: async () => {
|
|
68588
|
+
const value = asRecord11(await this.#transport.request("account.hasRunningAccountTasks"));
|
|
68589
|
+
return value.running === true;
|
|
68590
|
+
}
|
|
68591
|
+
};
|
|
68592
|
+
plugins() {
|
|
68593
|
+
const root = join16(this.#dshHome, "profiles", this.#profile, "node_modules");
|
|
68594
|
+
if (!existsSync13(root))
|
|
68595
|
+
return [];
|
|
68596
|
+
const out = [];
|
|
68597
|
+
const seen = new Set;
|
|
68598
|
+
const readPkg = (dir, fallbackName) => {
|
|
68599
|
+
try {
|
|
68600
|
+
const pkg = JSON.parse(readFileSync14(join16(dir, "package.json"), "utf8"));
|
|
68601
|
+
const name = typeof pkg.name === "string" && pkg.name ? pkg.name : fallbackName;
|
|
68602
|
+
const version = typeof pkg.version === "string" ? pkg.version : "";
|
|
68603
|
+
if (name.startsWith("@deepseek-ai/") || name.startsWith("@aiwayds/"))
|
|
68604
|
+
return;
|
|
68605
|
+
if (seen.has(name))
|
|
68606
|
+
return;
|
|
68607
|
+
seen.add(name);
|
|
68608
|
+
out.push({ name, version });
|
|
68609
|
+
} catch {}
|
|
68610
|
+
};
|
|
68611
|
+
let entries = [];
|
|
68612
|
+
try {
|
|
68613
|
+
entries = readdirSync4(root);
|
|
68614
|
+
} catch {
|
|
68615
|
+
return [];
|
|
68616
|
+
}
|
|
68617
|
+
for (const entry of entries) {
|
|
68618
|
+
if (entry.startsWith("."))
|
|
68619
|
+
continue;
|
|
68620
|
+
if (entry.startsWith("@")) {
|
|
68621
|
+
let scoped = [];
|
|
68622
|
+
try {
|
|
68623
|
+
scoped = readdirSync4(join16(root, entry));
|
|
68624
|
+
} catch {
|
|
68625
|
+
continue;
|
|
68626
|
+
}
|
|
68627
|
+
for (const sub of scoped) {
|
|
68628
|
+
if (sub.startsWith("."))
|
|
68629
|
+
continue;
|
|
68630
|
+
readPkg(join16(root, entry, sub), `${entry}/${sub}`);
|
|
68631
|
+
}
|
|
68632
|
+
} else {
|
|
68633
|
+
readPkg(join16(root, entry), entry);
|
|
68634
|
+
}
|
|
68635
|
+
}
|
|
68636
|
+
return out;
|
|
68637
|
+
}
|
|
68638
|
+
async#directoryRequest(method, project, params) {
|
|
68639
|
+
const reply = params === undefined ? await this.#transport.request(method) : await this.#transport.request(method, params);
|
|
68640
|
+
return project(reply);
|
|
68641
|
+
}
|
|
68642
|
+
async#readPermissionCatalog() {
|
|
68643
|
+
try {
|
|
68644
|
+
const reply = await this.#transport.request("permissionPresets.catalog");
|
|
68645
|
+
return projectPermissionCatalog(reply);
|
|
68646
|
+
} catch {
|
|
68647
|
+
return;
|
|
68648
|
+
}
|
|
68649
|
+
}
|
|
68650
|
+
async#permissionSwitch(preset) {
|
|
68651
|
+
const agentId = this.currentSessionId();
|
|
68652
|
+
if (agentId === undefined || agentId === "") {
|
|
68653
|
+
throw new BridgeProtocolError("UNSUPPORTED", "permission.switch: no active session (agentId unavailable)");
|
|
68654
|
+
}
|
|
68655
|
+
const line = `/permission ${preset}`;
|
|
68656
|
+
const reply = await this.#transport.request("commands.execute", {
|
|
68657
|
+
agentId,
|
|
68658
|
+
line,
|
|
68659
|
+
submittedAttachments: []
|
|
68660
|
+
});
|
|
68661
|
+
return projectPermissionSwitch(reply);
|
|
68662
|
+
}
|
|
68663
|
+
async#goalsRequest(method, extraParams, project) {
|
|
68664
|
+
const agentId = this.currentSessionId();
|
|
68665
|
+
if (agentId === undefined || agentId === "") {
|
|
68666
|
+
throw new BridgeProtocolError("UNSUPPORTED", `${method}: no active session (agentId unavailable)`);
|
|
68667
|
+
}
|
|
68668
|
+
try {
|
|
68669
|
+
const reply = await this.#transport.request(method, { agentId, ...extraParams });
|
|
68670
|
+
this.#goalsAvailable = true;
|
|
68671
|
+
return project(reply);
|
|
68672
|
+
} catch (err) {
|
|
68673
|
+
const code = err instanceof BridgeProtocolError ? err.code : undefined;
|
|
68674
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
68675
|
+
const serviceAbsent = code === "UNSUPPORTED" || code === "NOT_WIRED" || code === "UNAVAILABLE" || code === undefined && (/^NOT_WIRED/.test(message) || /unavailable/i.test(message));
|
|
68676
|
+
if (serviceAbsent) {
|
|
68677
|
+
this.#goalsAvailable = false;
|
|
68678
|
+
throw new BridgeProtocolError("UNSUPPORTED", `${method}: ${message}`);
|
|
68679
|
+
}
|
|
68680
|
+
throw err;
|
|
68681
|
+
}
|
|
68682
|
+
}
|
|
68683
|
+
async#pmRequest(method, params, project) {
|
|
68684
|
+
try {
|
|
68685
|
+
const reply = await this.#transport.request(method, params);
|
|
68686
|
+
const projected = project(reply);
|
|
68687
|
+
this.#pluginsManagerAvailable = true;
|
|
68688
|
+
return projected;
|
|
68689
|
+
} catch (err) {
|
|
68690
|
+
const code = err instanceof BridgeProtocolError ? err.code : undefined;
|
|
68691
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
68692
|
+
const serviceAbsent = code === "UNSUPPORTED" || code === "NOT_WIRED" || code === "UNAVAILABLE" || code === undefined && (/^NOT_WIRED/.test(message) || /unavailable/i.test(message));
|
|
68693
|
+
if (serviceAbsent) {
|
|
68694
|
+
this.#pluginsManagerAvailable = false;
|
|
68695
|
+
throw new BridgeProtocolError("UNSUPPORTED", `${method}: ${message}`);
|
|
68696
|
+
}
|
|
68697
|
+
throw err;
|
|
68698
|
+
}
|
|
68699
|
+
}
|
|
68700
|
+
async#pmConfirmed(method, params, confirm, project) {
|
|
68701
|
+
if (!writeConfirmed(confirm))
|
|
68702
|
+
throw CONFIRM_REQUIRED(method);
|
|
68703
|
+
return this.#pmRequest(method, { ...params, __confirm: true }, project);
|
|
68704
|
+
}
|
|
68705
|
+
async#pmWrite(method, params, confirm, target) {
|
|
68706
|
+
const reply = await this.#pmConfirmed(method, params, confirm, projectChange);
|
|
68707
|
+
if (reply.target === "" && target !== "")
|
|
68708
|
+
reply.target = target;
|
|
68709
|
+
this.refreshPluginBundles();
|
|
68710
|
+
return reply;
|
|
68711
|
+
}
|
|
68712
|
+
pluginsManager = {
|
|
68713
|
+
listBundles: async () => {
|
|
68714
|
+
const rows = await this.#pmRequest("pluginManager.listBundles", {}, projectBundleRows);
|
|
68715
|
+
this.#pluginBundlesCache = rows;
|
|
68716
|
+
return rows;
|
|
68717
|
+
},
|
|
68718
|
+
listPlugins: async () => this.#pmRequest("pluginManager.listPlugins", {}, projectPluginRows),
|
|
68719
|
+
readBundleDetail: async (name, language) => this.#pmRequest("pluginManager.readBundleDetail", { name, language }, projectDetail),
|
|
68720
|
+
registries: async () => this.#pmRequest("pluginManager.registries", {}, projectRegistries),
|
|
68721
|
+
listVersions: async (name) => this.#pmRequest("pluginManager.listVersions", { name }, projectVersions),
|
|
68722
|
+
listVersionExemptions: async () => this.#pmRequest("pluginManager.listVersionExemptions", {}, projectVersionExemptions),
|
|
68723
|
+
inspect: async (spec) => this.#pmRequest("pluginManager.inspect", { spec }, projectInspection),
|
|
68724
|
+
available: () => this.#pluginsManagerAvailable
|
|
68725
|
+
};
|
|
68726
|
+
setPluginBundleEnabled = (name, enabled, confirm) => this.#pmWrite("pluginManager.setBundleEnabled", { name, enabled }, confirm, name);
|
|
68727
|
+
removePluginBundle = (name, confirm) => this.#pmWrite("pluginManager.removeBundle", { name }, confirm, name);
|
|
68728
|
+
inspectPluginSpec = (spec) => this.pluginsManager.inspect(spec);
|
|
68729
|
+
installPluginSpec = async (spec, confirm, requestIdArg) => {
|
|
68730
|
+
const requestId = requestIdArg ?? `w23-${randomUUID9()}`;
|
|
68731
|
+
const change = await this.#pmWrite("pluginManager.installBundle", { spec, options: { enabled: true, requestId } }, confirm, spec);
|
|
68732
|
+
change.requestId = requestId;
|
|
68733
|
+
return change;
|
|
68734
|
+
};
|
|
68735
|
+
updatePluginBundle = (name, version, confirm) => this.#pmWrite("pluginManager.updateBundle", { name, version, options: {} }, confirm, name);
|
|
68736
|
+
setPluginEnabled = (id, enabled, confirm) => this.#pmWrite("pluginManager.setPluginEnabled", { id, enabled }, confirm, id);
|
|
68737
|
+
setVersionExemption = (packageVersion, runtimeVersion, enabled, acceptRisk, confirm) => this.#pmWrite("pluginManager.setVersionExemption", { packageVersion, runtimeVersion, enabled, acceptRisk }, confirm, `${packageVersion}@${runtimeVersion}`);
|
|
68738
|
+
waitForInstall = (requestId, confirm) => this.#pmConfirmed("pluginManager.waitForInstall", { requestId }, confirm, (raw) => projectInstallProgress(raw, requestId));
|
|
68739
|
+
cancelInstall = (requestId, confirm) => this.#pmConfirmed("pluginManager.cancelInstall", { requestId }, confirm, projectCancellation);
|
|
68740
|
+
async refreshPluginBundles() {
|
|
68741
|
+
try {
|
|
68742
|
+
await this.pluginsManager.listBundles();
|
|
68743
|
+
} catch {}
|
|
68744
|
+
}
|
|
68745
|
+
pluginBundles() {
|
|
68746
|
+
if (this.#pluginsManagerAvailable === true)
|
|
68747
|
+
return [...this.#pluginBundlesCache];
|
|
68748
|
+
return this.plugins().map((row) => ({
|
|
68749
|
+
name: row.name,
|
|
68750
|
+
version: row.version,
|
|
68751
|
+
enabled: false,
|
|
68752
|
+
installed: true,
|
|
68753
|
+
optional: false,
|
|
68754
|
+
removable: false,
|
|
68755
|
+
stateUnknown: true
|
|
68756
|
+
}));
|
|
68757
|
+
}
|
|
68758
|
+
thinking = {
|
|
68759
|
+
efforts: () => this.#catalogEfforts(),
|
|
68760
|
+
effortsFor: (providerID, modelID) => this.#catalogEfforts(providerID, modelID),
|
|
68761
|
+
currentEffort: async () => {
|
|
68762
|
+
const selection = await this.#transport.request("model.currentSelection");
|
|
68763
|
+
const value = asRecord11(selection).reasoningEffort;
|
|
68764
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
68765
|
+
},
|
|
68766
|
+
selectEffort: async (effort) => {
|
|
68767
|
+
const selection = await this.currentModelSelection();
|
|
68768
|
+
if (selection === undefined)
|
|
68769
|
+
return unsupported("selectEffort");
|
|
68770
|
+
const sessionId = this.#currentSessionId ?? this.stagedSessionId();
|
|
68771
|
+
const reply = await this.#transport.request("selectModel", {
|
|
68772
|
+
provider: selection.providerID,
|
|
68773
|
+
model: selection.modelID,
|
|
68774
|
+
...effort === undefined ? {} : { reasoningEffort: effort },
|
|
68775
|
+
...sessionId !== undefined && sessionId !== "" ? { sessionId } : {}
|
|
68776
|
+
});
|
|
68777
|
+
const r = reply;
|
|
68778
|
+
if (r === undefined || r === null || r.selected === undefined) {
|
|
68779
|
+
return unsupported("selectEffort");
|
|
68780
|
+
}
|
|
68781
|
+
}
|
|
68782
|
+
};
|
|
68783
|
+
async#catalogEfforts(providerID, modelID) {
|
|
68784
|
+
const raw = await this.#transport.request("modelCatalog");
|
|
68785
|
+
if (raw === undefined || raw === null || !Array.isArray(raw.groups))
|
|
68786
|
+
return [];
|
|
68787
|
+
let group = raw.groups.find((g) => typeof g?.id === "string" && g.id === providerID);
|
|
68788
|
+
let model = group?.models?.find((m) => typeof m?.id === "string" && m.id === modelID);
|
|
68789
|
+
if (providerID === undefined || modelID === undefined) {
|
|
68790
|
+
const d = raw.default;
|
|
68791
|
+
group = raw.groups.find((g) => typeof g?.id === "string" && g.id === d?.provider) ?? raw.groups[0];
|
|
68792
|
+
model = group?.models?.find((m) => typeof m?.id === "string" && m.id === d?.model) ?? group?.models?.[0];
|
|
68793
|
+
}
|
|
68794
|
+
const efforts = model?.reasoning?.efforts;
|
|
68795
|
+
if (!Array.isArray(efforts))
|
|
68796
|
+
return [];
|
|
68797
|
+
const out = [];
|
|
68798
|
+
for (const e of efforts) {
|
|
68799
|
+
const row = asRecord11(e);
|
|
68800
|
+
const id = typeof row.id === "string" ? row.id : "";
|
|
68801
|
+
const name = typeof row.name === "string" ? row.name : "";
|
|
68802
|
+
if (!id)
|
|
68803
|
+
continue;
|
|
68804
|
+
out.push({
|
|
68805
|
+
id,
|
|
68806
|
+
name: name || id,
|
|
68807
|
+
...typeof row.description === "string" && row.description !== "" ? { description: row.description } : {}
|
|
68808
|
+
});
|
|
68809
|
+
}
|
|
68810
|
+
return out;
|
|
68811
|
+
}
|
|
66994
68812
|
#unsubEvent;
|
|
66995
68813
|
#listeners = [];
|
|
66996
68814
|
#onDead;
|
|
@@ -67001,6 +68819,7 @@ class BridgeSessionSeam {
|
|
|
67001
68819
|
#subagentSessionId;
|
|
67002
68820
|
#subagentJournalLoaded = new Set;
|
|
67003
68821
|
#subagentJournalMeta = new Map;
|
|
68822
|
+
#subagentTranscripts = new Map;
|
|
67004
68823
|
#sweepSettledRuns = new Map;
|
|
67005
68824
|
#subagentSettleSnapshots = new Map;
|
|
67006
68825
|
#interruptInFlight = new Map;
|
|
@@ -67018,6 +68837,8 @@ class BridgeSessionSeam {
|
|
|
67018
68837
|
#recoveryState = "idle";
|
|
67019
68838
|
#pendingOpen;
|
|
67020
68839
|
#inFlightTurnId;
|
|
68840
|
+
#sideSessionInFlight = false;
|
|
68841
|
+
#lastSideSessionId;
|
|
67021
68842
|
#activeCallbacks;
|
|
67022
68843
|
#turnDone;
|
|
67023
68844
|
#turnGeneration = 0;
|
|
@@ -67057,6 +68878,8 @@ class BridgeSessionSeam {
|
|
|
67057
68878
|
settings: this.#settingsStore,
|
|
67058
68879
|
modelCatalog: () => this.#transport.request("modelCatalog")
|
|
67059
68880
|
});
|
|
68881
|
+
this.#localPresets = new LocalPresetFace(this.#dshHome, this.#profile);
|
|
68882
|
+
this.#localLogin = new LocalLoginFace(this.#dshHome, this.#profile);
|
|
67060
68883
|
this.#onDead = options.onDead;
|
|
67061
68884
|
this.#onPermissionUnavailable = options.onPermissionUnavailable;
|
|
67062
68885
|
this.#confirmClock = options.confirmClock ?? {
|
|
@@ -67070,7 +68893,7 @@ class BridgeSessionSeam {
|
|
|
67070
68893
|
}
|
|
67071
68894
|
async connect() {
|
|
67072
68895
|
try {
|
|
67073
|
-
const reply =
|
|
68896
|
+
const reply = asRecord11(await this.#transport.request("bridge.ping"));
|
|
67074
68897
|
this.#recordBridgeCapabilities(reply.capabilities);
|
|
67075
68898
|
this.#connection = "connected";
|
|
67076
68899
|
} catch (err) {
|
|
@@ -67157,7 +68980,7 @@ class BridgeSessionSeam {
|
|
|
67157
68980
|
this.#replayDrainPending = true;
|
|
67158
68981
|
let opened;
|
|
67159
68982
|
try {
|
|
67160
|
-
opened =
|
|
68983
|
+
opened = asRecord11(await this.#transport.request("session.open", { mode: "resume", id: sessionId }));
|
|
67161
68984
|
} catch (err) {
|
|
67162
68985
|
const code = err instanceof BridgeProtocolError ? err.code : "SESSION_OPEN_FAILED";
|
|
67163
68986
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -67167,7 +68990,7 @@ class BridgeSessionSeam {
|
|
|
67167
68990
|
this.#bufferedPendingSnapshot = undefined;
|
|
67168
68991
|
this.#replayDrainPending = false;
|
|
67169
68992
|
this.#settleSuspendedTurn();
|
|
67170
|
-
const errorDetail = err instanceof BridgeProtocolError ?
|
|
68993
|
+
const errorDetail = err instanceof BridgeProtocolError ? asRecord11(err.detail) : {};
|
|
67171
68994
|
const holder = typeof errorDetail.holder === "string" && errorDetail.holder.trim() !== "" ? errorDetail.holder : undefined;
|
|
67172
68995
|
const result = {
|
|
67173
68996
|
state: "locked",
|
|
@@ -67242,7 +69065,7 @@ class BridgeSessionSeam {
|
|
|
67242
69065
|
turnId: dead.turnId,
|
|
67243
69066
|
seq: terminal.seq,
|
|
67244
69067
|
terminalType: terminal.type,
|
|
67245
|
-
reason:
|
|
69068
|
+
reason: asRecord11(terminal.payload).reason,
|
|
67246
69069
|
payload: terminal.payload,
|
|
67247
69070
|
source: "journal"
|
|
67248
69071
|
}
|
|
@@ -67300,7 +69123,7 @@ class BridgeSessionSeam {
|
|
|
67300
69123
|
const seen = new Set;
|
|
67301
69124
|
const collected = [];
|
|
67302
69125
|
for (;; ) {
|
|
67303
|
-
const value =
|
|
69126
|
+
const value = asRecord11(await this.#transport.request("journal.replay", { sessionId, from }));
|
|
67304
69127
|
const rawRows = Array.isArray(value.rows) ? value.rows : [];
|
|
67305
69128
|
if (typeof value.cursor === "number" && Number.isFinite(value.cursor))
|
|
67306
69129
|
cursor = value.cursor;
|
|
@@ -67313,7 +69136,7 @@ class BridgeSessionSeam {
|
|
|
67313
69136
|
let added = 0;
|
|
67314
69137
|
let pageMax = from - 1;
|
|
67315
69138
|
for (const raw of rawRows) {
|
|
67316
|
-
const row =
|
|
69139
|
+
const row = asRecord11(raw);
|
|
67317
69140
|
const seq = row.seq;
|
|
67318
69141
|
if (typeof seq !== "number" || !Number.isFinite(seq) || seq < floor || seen.has(seq))
|
|
67319
69142
|
continue;
|
|
@@ -67362,7 +69185,7 @@ class BridgeSessionSeam {
|
|
|
67362
69185
|
};
|
|
67363
69186
|
const attempt = (remaining) => {
|
|
67364
69187
|
this.#transport.request("turn.abort", { turnId }).then((result) => {
|
|
67365
|
-
if (
|
|
69188
|
+
if (asRecord11(result).noop === true) {
|
|
67366
69189
|
fail(`turn.abort was a noop for turn ${turnId}; turn may still be running`, "TURN_ABORT_NOOP");
|
|
67367
69190
|
}
|
|
67368
69191
|
}).catch((err) => {
|
|
@@ -67498,7 +69321,7 @@ class BridgeSessionSeam {
|
|
|
67498
69321
|
stats.contextTokens = usage.total;
|
|
67499
69322
|
}
|
|
67500
69323
|
} else if (row.type === "request/context") {
|
|
67501
|
-
const data =
|
|
69324
|
+
const data = asRecord11(row.payload);
|
|
67502
69325
|
const window = data.contextWindow;
|
|
67503
69326
|
if (typeof window === "number" && Number.isFinite(window) && window > 0) {
|
|
67504
69327
|
const provider = typeof data.provider === "string" ? data.provider : "";
|
|
@@ -67604,6 +69427,24 @@ class BridgeSessionSeam {
|
|
|
67604
69427
|
subagentViews() {
|
|
67605
69428
|
return [...this.#subagentViews.values()].map((view) => ({ ...view }));
|
|
67606
69429
|
}
|
|
69430
|
+
subagentTranscript(id) {
|
|
69431
|
+
return [...this.#subagentTranscripts.get(id) ?? []];
|
|
69432
|
+
}
|
|
69433
|
+
steerChild(id, text) {
|
|
69434
|
+
const view = this.#subagentViews.get(id);
|
|
69435
|
+
if (view === undefined || view.status !== "running")
|
|
69436
|
+
return false;
|
|
69437
|
+
const requestId = `${id}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
69438
|
+
this.#transport.request("subagents.prompt", {
|
|
69439
|
+
requestId,
|
|
69440
|
+
childSessionId: id,
|
|
69441
|
+
delivery: "steer",
|
|
69442
|
+
content: [{ type: "text", text }]
|
|
69443
|
+
}).catch((err) => {
|
|
69444
|
+
this.#degrade("steerChild", `subagents.prompt failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
69445
|
+
});
|
|
69446
|
+
return true;
|
|
69447
|
+
}
|
|
67607
69448
|
async interruptChild(childId) {
|
|
67608
69449
|
const parentSessionId = this.#currentSessionId;
|
|
67609
69450
|
if (parentSessionId === undefined || parentSessionId === "") {
|
|
@@ -67614,7 +69455,7 @@ class BridgeSessionSeam {
|
|
|
67614
69455
|
this.#interruptInFlight.set(childId, generation);
|
|
67615
69456
|
let value;
|
|
67616
69457
|
try {
|
|
67617
|
-
value =
|
|
69458
|
+
value = asRecord11(await this.#transport.request("subagents.interrupt", { parentSessionId, childId }));
|
|
67618
69459
|
} catch (err) {
|
|
67619
69460
|
if (this.#interruptInFlight.get(childId) === generation)
|
|
67620
69461
|
this.#interruptInFlight.delete(childId);
|
|
@@ -67640,13 +69481,13 @@ class BridgeSessionSeam {
|
|
|
67640
69481
|
if (parentSessionId === undefined || parentSessionId === "") {
|
|
67641
69482
|
throw new BridgeProtocolError("NO_SESSION", "cannot stop children: no session is bound to this bridge connection");
|
|
67642
69483
|
}
|
|
67643
|
-
const value =
|
|
69484
|
+
const value = asRecord11(await this.#transport.request("subagents.stopChildren", { parentSessionId }));
|
|
67644
69485
|
const children = value.children;
|
|
67645
69486
|
if (!Array.isArray(children))
|
|
67646
69487
|
return [];
|
|
67647
69488
|
const sessionAtStart = this.#subagentSessionId;
|
|
67648
69489
|
const rows = children.map((row) => {
|
|
67649
|
-
const r =
|
|
69490
|
+
const r = asRecord11(row);
|
|
67650
69491
|
return {
|
|
67651
69492
|
childId: typeof r.childId === "string" ? r.childId : "",
|
|
67652
69493
|
disposition: typeof r.disposition === "string" ? r.disposition : "failed"
|
|
@@ -67672,10 +69513,10 @@ class BridgeSessionSeam {
|
|
|
67672
69513
|
return;
|
|
67673
69514
|
let stopped = false;
|
|
67674
69515
|
try {
|
|
67675
|
-
const items =
|
|
69516
|
+
const items = asRecord11(await this.#transport.request("session.list", { _request: {} })).items;
|
|
67676
69517
|
if (Array.isArray(items)) {
|
|
67677
69518
|
stopped = items.some((row) => {
|
|
67678
|
-
const item =
|
|
69519
|
+
const item = asRecord11(row);
|
|
67679
69520
|
return item.sessionId === childId && item.running === false;
|
|
67680
69521
|
});
|
|
67681
69522
|
}
|
|
@@ -67685,7 +69526,7 @@ class BridgeSessionSeam {
|
|
|
67685
69526
|
if (stopped) {
|
|
67686
69527
|
let reason = "aborted";
|
|
67687
69528
|
try {
|
|
67688
|
-
const rows =
|
|
69529
|
+
const rows = asRecord11(await this.#transport.request("journal.replay", { sessionId: childId })).rows;
|
|
67689
69530
|
if (Array.isArray(rows)) {
|
|
67690
69531
|
const clean = rows.filter((row) => row !== null && typeof row === "object" && !Array.isArray(row));
|
|
67691
69532
|
reason = bridgeChildStopReason(clean) ?? "aborted";
|
|
@@ -67744,7 +69585,7 @@ class BridgeSessionSeam {
|
|
|
67744
69585
|
} catch {
|
|
67745
69586
|
return;
|
|
67746
69587
|
}
|
|
67747
|
-
const items =
|
|
69588
|
+
const items = asRecord11(value).items;
|
|
67748
69589
|
if (!Array.isArray(items))
|
|
67749
69590
|
return;
|
|
67750
69591
|
const locallyRunning = new Set;
|
|
@@ -67789,7 +69630,7 @@ class BridgeSessionSeam {
|
|
|
67789
69630
|
this.#subagentJournalLoaded.add(key);
|
|
67790
69631
|
const sessionAtStart = this.#subagentSessionId;
|
|
67791
69632
|
try {
|
|
67792
|
-
const value =
|
|
69633
|
+
const value = asRecord11(await this.#transport.request("journal.replay", { sessionId: childId }));
|
|
67793
69634
|
const rows = value.rows;
|
|
67794
69635
|
if (!Array.isArray(rows))
|
|
67795
69636
|
return;
|
|
@@ -67797,6 +69638,7 @@ class BridgeSessionSeam {
|
|
|
67797
69638
|
const meta = bridgeChildJournalMeta(cleanRows);
|
|
67798
69639
|
if (this.#subagentSessionId !== sessionAtStart || this.#disposed)
|
|
67799
69640
|
return;
|
|
69641
|
+
this.#subagentTranscripts.set(childId, bridgeReplayRowsToChildLog(cleanRows));
|
|
67800
69642
|
this.#subagentJournalMeta.set(key, meta);
|
|
67801
69643
|
const existing = this.#subagentViews.get(childId);
|
|
67802
69644
|
if (existing === undefined || bridgeChildJournalKey(existing) !== key)
|
|
@@ -67895,7 +69737,7 @@ class BridgeSessionSeam {
|
|
|
67895
69737
|
}
|
|
67896
69738
|
}
|
|
67897
69739
|
#foldAgentFrame(frame) {
|
|
67898
|
-
const payload =
|
|
69740
|
+
const payload = asRecord11(frame.payload);
|
|
67899
69741
|
const frameSession = typeof payload.sessionId === "string" ? payload.sessionId : "";
|
|
67900
69742
|
if (this.#subagentSessionId !== undefined && frameSession !== "" && frameSession !== this.#subagentSessionId)
|
|
67901
69743
|
return;
|
|
@@ -67921,6 +69763,7 @@ class BridgeSessionSeam {
|
|
|
67921
69763
|
this.#subagentLiveStarts.clear();
|
|
67922
69764
|
this.#subagentJournalLoaded.clear();
|
|
67923
69765
|
this.#subagentJournalMeta.clear();
|
|
69766
|
+
this.#subagentTranscripts.clear();
|
|
67924
69767
|
this.#sweepSettledRuns.clear();
|
|
67925
69768
|
this.#subagentSettleSnapshots.clear();
|
|
67926
69769
|
this.#interruptInFlight.clear();
|
|
@@ -67931,7 +69774,7 @@ class BridgeSessionSeam {
|
|
|
67931
69774
|
let changed = false;
|
|
67932
69775
|
const now = Date.now();
|
|
67933
69776
|
for (const row of rows) {
|
|
67934
|
-
if (this.#foldWithFrozenSettle(row.type,
|
|
69777
|
+
if (this.#foldWithFrozenSettle(row.type, asRecord11(row.payload), now, false))
|
|
67935
69778
|
changed = true;
|
|
67936
69779
|
}
|
|
67937
69780
|
if (rosterReset || changed) {
|
|
@@ -67965,20 +69808,48 @@ class BridgeSessionSeam {
|
|
|
67965
69808
|
}
|
|
67966
69809
|
async listSessions(limit) {
|
|
67967
69810
|
const value = await this.#transport.request("session.list");
|
|
67968
|
-
return projectBridgeSessionList(
|
|
69811
|
+
return projectBridgeSessionList(asRecord11(value).items, limit);
|
|
69812
|
+
}
|
|
69813
|
+
async cwd() {
|
|
69814
|
+
const sessionId = this.currentSessionId();
|
|
69815
|
+
if (sessionId === undefined || sessionId === "")
|
|
69816
|
+
return;
|
|
69817
|
+
const value = await this.#transport.request("session.list");
|
|
69818
|
+
return projectCurrentCwd(asRecord11(value).items, sessionId);
|
|
67969
69819
|
}
|
|
67970
69820
|
async storedTranscript(id, skip = 0) {
|
|
67971
69821
|
const value = await this.#transport.request("journal.replay", { sessionId: id });
|
|
67972
|
-
const rows = Array.isArray(
|
|
69822
|
+
const rows = Array.isArray(asRecord11(value).rows) ? asRecord11(value).rows : [];
|
|
67973
69823
|
this.#foldAgentReplayRows(rows, id);
|
|
67974
69824
|
this.#sweepSubagents(id);
|
|
67975
69825
|
return bridgeReplayRowsToSeamTranscript(rows, skip);
|
|
67976
69826
|
}
|
|
69827
|
+
async sessionJournal(id) {
|
|
69828
|
+
const value = await this.#transport.request("journal.replay", { sessionId: id });
|
|
69829
|
+
const rows = Array.isArray(asRecord11(value).rows) ? asRecord11(value).rows : [];
|
|
69830
|
+
return rows.map((row) => ({
|
|
69831
|
+
type: row.type,
|
|
69832
|
+
seq: row.seq,
|
|
69833
|
+
time: 0,
|
|
69834
|
+
data: asRecord11(row.payload)
|
|
69835
|
+
}));
|
|
69836
|
+
}
|
|
69837
|
+
async forkSession(sessionId, seqEnd) {
|
|
69838
|
+
const value = asRecord11(await this.#transport.request("session.fork", {
|
|
69839
|
+
sessionId,
|
|
69840
|
+
...seqEnd !== undefined ? { atSeq: seqEnd } : {}
|
|
69841
|
+
}));
|
|
69842
|
+
const forked = value.sessionId;
|
|
69843
|
+
if (typeof forked !== "string" || forked === "") {
|
|
69844
|
+
throw new BridgeProtocolError("FORK_FAILED", "/history fork: session.fork returned no session id");
|
|
69845
|
+
}
|
|
69846
|
+
return forked;
|
|
69847
|
+
}
|
|
67977
69848
|
async currentModelSelection() {
|
|
67978
69849
|
const selection = await this.#transport.request("model.currentSelection");
|
|
67979
69850
|
if (selection === undefined || selection === null)
|
|
67980
69851
|
return;
|
|
67981
|
-
const s =
|
|
69852
|
+
const s = asRecord11(selection);
|
|
67982
69853
|
const providerID = typeof s.provider === "string" ? s.provider : "";
|
|
67983
69854
|
const modelID = typeof s.model === "string" ? s.model : "";
|
|
67984
69855
|
if (!providerID || !modelID)
|
|
@@ -68015,7 +69886,7 @@ class BridgeSessionSeam {
|
|
|
68015
69886
|
this.#pendingOpen = undefined;
|
|
68016
69887
|
const params = pending.mode === "resume" ? { mode: "resume", id: pending.id, ...this.#sessionAttached ? { replace: true } : {} } : { mode: "new", ...this.#sessionAttached ? { replace: true } : {} };
|
|
68017
69888
|
try {
|
|
68018
|
-
const opened =
|
|
69889
|
+
const opened = asRecord11(await this.#transport.request("session.open", params));
|
|
68019
69890
|
if (typeof opened.sessionId === "string")
|
|
68020
69891
|
this.#currentSessionId = opened.sessionId;
|
|
68021
69892
|
if (this.#lastAppliedSessionId !== this.#currentSessionId) {
|
|
@@ -68032,7 +69903,7 @@ class BridgeSessionSeam {
|
|
|
68032
69903
|
const done = new Promise((resolve) => {
|
|
68033
69904
|
this.#turnDone = resolve;
|
|
68034
69905
|
});
|
|
68035
|
-
const sent =
|
|
69906
|
+
const sent = asRecord11(await this.#transport.request("session.send", { text: userText }));
|
|
68036
69907
|
if (typeof sent.turnId === "string") {
|
|
68037
69908
|
this.#inFlightTurnId = sent.turnId;
|
|
68038
69909
|
this.#emitEvent({
|
|
@@ -68096,8 +69967,44 @@ class BridgeSessionSeam {
|
|
|
68096
69967
|
this.#sessionAttached = false;
|
|
68097
69968
|
this.#currentSessionId = undefined;
|
|
68098
69969
|
}
|
|
68099
|
-
async
|
|
68100
|
-
|
|
69970
|
+
async btwAsk(question, snapshot, onDelta) {
|
|
69971
|
+
if (this.#sideSessionInFlight) {
|
|
69972
|
+
throw new BridgeProtocolError("SIDE_SESSION_BUSY", "/btw: a side question is already running");
|
|
69973
|
+
}
|
|
69974
|
+
this.#sideSessionInFlight = true;
|
|
69975
|
+
try {
|
|
69976
|
+
const result = await runSideSession({
|
|
69977
|
+
rpc: (method, params) => this.#transport.request(method, params),
|
|
69978
|
+
question,
|
|
69979
|
+
snapshot,
|
|
69980
|
+
onDelta,
|
|
69981
|
+
...this.#lastSideSessionId !== undefined ? { sessionId: this.#lastSideSessionId } : {}
|
|
69982
|
+
});
|
|
69983
|
+
this.#lastSideSessionId = result.sessionId;
|
|
69984
|
+
if (result.answer === "") {
|
|
69985
|
+
throw new BridgeProtocolError("SIDE_SESSION_NO_ANSWER", `/btw: side-session produced no answer (${result.reason})${result.truncated ? ", truncated" : ""}`);
|
|
69986
|
+
}
|
|
69987
|
+
return result.answer;
|
|
69988
|
+
} catch (err) {
|
|
69989
|
+
if (err instanceof SideSessionError) {
|
|
69990
|
+
const code = err.code === "SIDE_SESSION_UNAVAILABLE" ? "UNSUPPORTED" : err.code;
|
|
69991
|
+
throw new BridgeProtocolError(code, err.message);
|
|
69992
|
+
}
|
|
69993
|
+
throw err;
|
|
69994
|
+
} finally {
|
|
69995
|
+
this.#sideSessionInFlight = false;
|
|
69996
|
+
}
|
|
69997
|
+
}
|
|
69998
|
+
async searchSessions(query) {
|
|
69999
|
+
const value = asRecord11(await this.#transport.request("session.search", { query }));
|
|
70000
|
+
const rows = Array.isArray(value.items) ? value.items : [];
|
|
70001
|
+
return rows.map((row) => {
|
|
70002
|
+
const r = asRecord11(row);
|
|
70003
|
+
return {
|
|
70004
|
+
id: typeof r.id === "string" ? r.id : "",
|
|
70005
|
+
snippet: typeof r.snippet === "string" ? r.snippet : ""
|
|
70006
|
+
};
|
|
70007
|
+
}).filter((row) => row.id);
|
|
68101
70008
|
}
|
|
68102
70009
|
async renameSession(_title) {
|
|
68103
70010
|
return unsupported("renameSession");
|
|
@@ -68273,7 +70180,7 @@ class BridgeSessionSeam {
|
|
|
68273
70180
|
this.#settlePendingAsk(eventId);
|
|
68274
70181
|
}
|
|
68275
70182
|
#onAskEvent(frame) {
|
|
68276
|
-
const payload =
|
|
70183
|
+
const payload = asRecord11(frame.payload);
|
|
68277
70184
|
if (frame.type === "ask.request" || frame.type === "ask.pending")
|
|
68278
70185
|
this.#askFrameSeen = true;
|
|
68279
70186
|
switch (frame.type) {
|
|
@@ -68333,7 +70240,7 @@ class BridgeSessionSeam {
|
|
|
68333
70240
|
#onCapPushEvent(frame) {
|
|
68334
70241
|
if (frame.type !== "cap.event" && frame.type !== "cap.end")
|
|
68335
70242
|
return false;
|
|
68336
|
-
const payload =
|
|
70243
|
+
const payload = asRecord11(frame.payload);
|
|
68337
70244
|
const sessionId = optionalStringField(payload, "sessionId");
|
|
68338
70245
|
if (sessionId === undefined || sessionId === "")
|
|
68339
70246
|
return true;
|
|
@@ -68407,7 +70314,7 @@ class BridgeSessionSeam {
|
|
|
68407
70314
|
}
|
|
68408
70315
|
return;
|
|
68409
70316
|
}
|
|
68410
|
-
const payload =
|
|
70317
|
+
const payload = asRecord11(frame.payload);
|
|
68411
70318
|
if (frame.type === "turn.start") {
|
|
68412
70319
|
this.#turn = "starting";
|
|
68413
70320
|
this.#decodeWindowStart = undefined;
|
|
@@ -68488,14 +70395,16 @@ class BridgeSessionSeam {
|
|
|
68488
70395
|
}
|
|
68489
70396
|
}
|
|
68490
70397
|
}
|
|
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}`;
|
|
70398
|
+
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
70399
|
var init_bridge_session_seam = __esm(() => {
|
|
68493
70400
|
init_remote_session_ops();
|
|
68494
70401
|
init_journal_projection();
|
|
70402
|
+
init_bridge_side_session();
|
|
68495
70403
|
init_loop();
|
|
68496
70404
|
init_local_config_faces();
|
|
68497
70405
|
init_remote_local_fs();
|
|
68498
70406
|
init_lifecycle();
|
|
70407
|
+
init_bridge_goals();
|
|
68499
70408
|
BridgeProtocolError = class BridgeProtocolError extends Error {
|
|
68500
70409
|
code;
|
|
68501
70410
|
detail;
|
|
@@ -68507,6 +70416,17 @@ var init_bridge_session_seam = __esm(() => {
|
|
|
68507
70416
|
this.detail = detail;
|
|
68508
70417
|
}
|
|
68509
70418
|
};
|
|
70419
|
+
ACCOUNT_STATUSES = new Set(["signed-out", "credential-stored"]);
|
|
70420
|
+
ACCOUNT_PHASES = new Set([
|
|
70421
|
+
"initializing",
|
|
70422
|
+
"waiting-browser",
|
|
70423
|
+
"exchanging",
|
|
70424
|
+
"committing",
|
|
70425
|
+
"succeeded",
|
|
70426
|
+
"cancelled",
|
|
70427
|
+
"expired",
|
|
70428
|
+
"failed"
|
|
70429
|
+
]);
|
|
68510
70430
|
});
|
|
68511
70431
|
|
|
68512
70432
|
// scripts/lib/bridge-failfast-text.mjs
|
|
@@ -68613,11 +70533,11 @@ function toBridgeBootstrapError(err, fallbackCode = "BRIDGE_HANDSHAKE_FAILED") {
|
|
|
68613
70533
|
const message = err instanceof Error ? err.message : String(err);
|
|
68614
70534
|
return new BridgeBootstrapError({ code: fallbackCode, diagnosis: `bridge handshake failed: ${message}` });
|
|
68615
70535
|
}
|
|
68616
|
-
function
|
|
70536
|
+
function asRecord12(value) {
|
|
68617
70537
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
68618
70538
|
}
|
|
68619
70539
|
function verifyBridgeFingerprint(hello, expectedProtocolVersion = BRIDGE_PROTOCOL_VERSION) {
|
|
68620
|
-
const h =
|
|
70540
|
+
const h = asRecord12(hello);
|
|
68621
70541
|
const protocolVersion = h.protocolVersion;
|
|
68622
70542
|
if (protocolVersion !== expectedProtocolVersion) {
|
|
68623
70543
|
throw new BridgeBootstrapError({
|
|
@@ -68720,16 +70640,16 @@ var init_seam_bootstrap = __esm(() => {
|
|
|
68720
70640
|
});
|
|
68721
70641
|
|
|
68722
70642
|
// ../tui-base/examples/v2-entry.tsx
|
|
68723
|
-
import { join as
|
|
68724
|
-
import { existsSync as
|
|
70643
|
+
import { join as join17 } from "path";
|
|
70644
|
+
import { existsSync as existsSync14 } from "fs";
|
|
68725
70645
|
function resolveWatchdogScript() {
|
|
68726
70646
|
const candidates = [
|
|
68727
|
-
|
|
68728
|
-
|
|
68729
|
-
|
|
70647
|
+
join17(import.meta.dir, "..", "watchdog.mjs"),
|
|
70648
|
+
join17(import.meta.dir, "..", "..", "shell", "dist", "watchdog.mjs"),
|
|
70649
|
+
join17(import.meta.dir, "..", "..", "..", "shell", "dist", "watchdog.mjs")
|
|
68730
70650
|
];
|
|
68731
70651
|
for (const candidate of candidates)
|
|
68732
|
-
if (
|
|
70652
|
+
if (existsSync14(candidate))
|
|
68733
70653
|
return candidate;
|
|
68734
70654
|
return null;
|
|
68735
70655
|
}
|
|
@@ -69543,8 +71463,8 @@ async function bootClientV2(options = {}) {
|
|
|
69543
71463
|
agentsHome: agentsHomeForSkills
|
|
69544
71464
|
});
|
|
69545
71465
|
const skillsManagerRoots = {
|
|
69546
|
-
source:
|
|
69547
|
-
curated:
|
|
71466
|
+
source: join17(agentsHomeForSkills, "skills"),
|
|
71467
|
+
curated: join17(host.dshHome, "skills")
|
|
69548
71468
|
};
|
|
69549
71469
|
const envTheme = process.env[shared.ENV_THEME];
|
|
69550
71470
|
const workspaceConfig = seam.workspaceConfig?.() ?? {};
|
|
@@ -69757,7 +71677,7 @@ var init_v2_entry = __esm(() => {
|
|
|
69757
71677
|
// src/client/bridge-transport.ts
|
|
69758
71678
|
import { spawn as nodeSpawn2 } from "child_process";
|
|
69759
71679
|
import { homedir as homedir9 } from "os";
|
|
69760
|
-
import { join as
|
|
71680
|
+
import { join as join18 } from "path";
|
|
69761
71681
|
function recoveryCause(err, phase) {
|
|
69762
71682
|
if (err instanceof BridgeBootstrapError) {
|
|
69763
71683
|
return {
|
|
@@ -69770,7 +71690,7 @@ function recoveryCause(err, phase) {
|
|
|
69770
71690
|
};
|
|
69771
71691
|
}
|
|
69772
71692
|
if (err instanceof BridgeProtocolError && err.code === "BRIDGE_DEAD") {
|
|
69773
|
-
const detail =
|
|
71693
|
+
const detail = asRecord13(err.detail);
|
|
69774
71694
|
return {
|
|
69775
71695
|
stage: phase,
|
|
69776
71696
|
code: typeof detail.code === "number" ? detail.code : null,
|
|
@@ -69821,7 +71741,7 @@ class StdioBridgeTransport {
|
|
|
69821
71741
|
#spawn() {
|
|
69822
71742
|
if (this.#child !== undefined)
|
|
69823
71743
|
return this.#child;
|
|
69824
|
-
const dshHome = this.#opts.dshHome ?? process.env.DSH_HOME ??
|
|
71744
|
+
const dshHome = this.#opts.dshHome ?? process.env.DSH_HOME ?? join18(homedir9(), ".dsh");
|
|
69825
71745
|
const env = {
|
|
69826
71746
|
...process.env,
|
|
69827
71747
|
...this.#opts.env ?? {},
|
|
@@ -69885,7 +71805,7 @@ class StdioBridgeTransport {
|
|
|
69885
71805
|
} catch {
|
|
69886
71806
|
return;
|
|
69887
71807
|
}
|
|
69888
|
-
const rec =
|
|
71808
|
+
const rec = asRecord13(frame);
|
|
69889
71809
|
if (typeof rec.id === "number") {
|
|
69890
71810
|
const pending = this.#pending.get(rec.id);
|
|
69891
71811
|
if (pending === undefined)
|
|
@@ -69897,7 +71817,7 @@ class StdioBridgeTransport {
|
|
|
69897
71817
|
this.#setState("ready");
|
|
69898
71818
|
pending.resolve(rec.result);
|
|
69899
71819
|
} else {
|
|
69900
|
-
const error =
|
|
71820
|
+
const error = asRecord13(rec.error);
|
|
69901
71821
|
pending.reject(new BridgeProtocolError(typeof error.code === "string" ? error.code : "BRIDGE_ERROR", typeof error.message === "string" ? error.message : "bridge request failed", error.detail));
|
|
69902
71822
|
}
|
|
69903
71823
|
return;
|
|
@@ -70029,7 +71949,7 @@ class StdioBridgeTransport {
|
|
|
70029
71949
|
} catch {}
|
|
70030
71950
|
}
|
|
70031
71951
|
}
|
|
70032
|
-
var
|
|
71952
|
+
var asRecord13 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
70033
71953
|
var init_bridge_transport = __esm(() => {
|
|
70034
71954
|
init_bridge_session_seam();
|
|
70035
71955
|
init_seam_bootstrap();
|
|
@@ -70042,16 +71962,16 @@ init_boot_shared();
|
|
|
70042
71962
|
init_lifecycle();
|
|
70043
71963
|
init_transport();
|
|
70044
71964
|
init_remote_host_session();
|
|
70045
|
-
import { existsSync as
|
|
70046
|
-
import { join as
|
|
71965
|
+
import { existsSync as existsSync15 } from "fs";
|
|
71966
|
+
import { join as join19 } from "path";
|
|
70047
71967
|
function resolveWatchdogScript2() {
|
|
70048
71968
|
const candidates = [
|
|
70049
|
-
|
|
70050
|
-
|
|
70051
|
-
|
|
71969
|
+
join19(import.meta.dir, "..", "watchdog.mjs"),
|
|
71970
|
+
join19(import.meta.dir, "..", "dist", "watchdog.mjs"),
|
|
71971
|
+
join19(import.meta.dir, "..", "scripts", "watchdog.mjs")
|
|
70052
71972
|
];
|
|
70053
71973
|
for (const candidate of candidates) {
|
|
70054
|
-
if (
|
|
71974
|
+
if (existsSync15(candidate))
|
|
70055
71975
|
return candidate;
|
|
70056
71976
|
}
|
|
70057
71977
|
return null;
|
|
@@ -70222,5 +72142,5 @@ export {
|
|
|
70222
72142
|
themeNameFromConfig
|
|
70223
72143
|
};
|
|
70224
72144
|
|
|
70225
|
-
//# debugId=
|
|
72145
|
+
//# debugId=1280DDFA8B58FE3F64756E2164756E21
|
|
70226
72146
|
//# sourceMappingURL=index.js.map
|