@aiwayds/dsh-opentui 0.23.3 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +35 -0
- package/bin/dsh-opentui.mjs +7 -13
- package/bin/lib/launcher.mjs +0 -1
- package/dist/bridge/bundle-fingerprint.json +1 -1
- package/dist/bridge/index.js +7153 -36
- package/dist/client/index.js +2677 -787
- package/dist/client/index.js.map +33 -25
- package/dist/host-launch.mjs +21 -8
- package/dist/host-launch.mjs.map +3 -3
- package/dist/locales/en.json +81 -0
- package/dist/locales/zh-CN.json +81 -0
- package/package.json +1 -1
- package/scripts/lib/bridge-failfast-text.d.mts +0 -1
- package/scripts/lib/bridge-failfast-text.mjs +3 -8
- package/scripts/provision-inproc-profile.mjs +89 -84
package/dist/client/index.js
CHANGED
|
@@ -687,6 +687,19 @@ var init_safe_kill = __esm(() => {
|
|
|
687
687
|
import { createHash, createHmac } from "crypto";
|
|
688
688
|
import { readFileSync as readFileSync2, statSync } from "fs";
|
|
689
689
|
import { join as join2 } from "path";
|
|
690
|
+
function resolveRetryWindow(option) {
|
|
691
|
+
if (option !== undefined && Number.isFinite(option) && option > 0)
|
|
692
|
+
return option;
|
|
693
|
+
const env = Number(process.env[RETRY_WINDOW_ENV]);
|
|
694
|
+
if (Number.isFinite(env) && env > 0)
|
|
695
|
+
return env;
|
|
696
|
+
return DEFAULT_RETRY_WINDOW_MS;
|
|
697
|
+
}
|
|
698
|
+
function resolveRetryInterval(option) {
|
|
699
|
+
if (option !== undefined && Number.isFinite(option) && option > 0)
|
|
700
|
+
return option;
|
|
701
|
+
return DEFAULT_RETRY_INTERVAL_MS;
|
|
702
|
+
}
|
|
690
703
|
function ownerCookieName(authority) {
|
|
691
704
|
return "dsh-auth-" + base64url(createHash("sha256").update(authority).digest());
|
|
692
705
|
}
|
|
@@ -695,7 +708,7 @@ function mintOwnerCookie(options) {
|
|
|
695
708
|
if (typeof authority !== "string" || authority.length === 0 || /[\r\n/]/.test(authority)) {
|
|
696
709
|
throw new OwnerCookieError("authority must be a non-empty host:port without scheme or path separators");
|
|
697
710
|
}
|
|
698
|
-
const secret = readGrantSecret(options.home);
|
|
711
|
+
const secret = readGrantSecret(options.home, resolveRetryWindow(options.timeoutMs), resolveRetryInterval(options.retryIntervalMs));
|
|
699
712
|
const issuedAt = Date.now();
|
|
700
713
|
const maxAgeMs = options.maxAgeMs ?? DEFAULT_MAX_AGE_MS;
|
|
701
714
|
const expiresAt = issuedAt + Math.min(maxAgeMs, DEFAULT_MAX_AGE_MS);
|
|
@@ -703,9 +716,9 @@ function mintOwnerCookie(options) {
|
|
|
703
716
|
const signature = base64url(createHmac("sha256", secret).update(body).digest());
|
|
704
717
|
return `${ownerCookieName(authority)}=v1.${body}.${signature}`;
|
|
705
718
|
}
|
|
706
|
-
function readGrantSecret(home) {
|
|
719
|
+
function readGrantSecret(home, timeoutMs, retryIntervalMs) {
|
|
707
720
|
const path = join2(home, ".credentials.yaml");
|
|
708
|
-
const deadline = Date.now() +
|
|
721
|
+
const deadline = Date.now() + timeoutMs;
|
|
709
722
|
let sawFile = false;
|
|
710
723
|
while (true) {
|
|
711
724
|
let file = "";
|
|
@@ -725,11 +738,11 @@ function readGrantSecret(home) {
|
|
|
725
738
|
}
|
|
726
739
|
if (Date.now() >= deadline) {
|
|
727
740
|
if (!sawFile) {
|
|
728
|
-
throw new CredentialsFileMissingError(`no credentials file at ${path} within ${
|
|
741
|
+
throw new CredentialsFileMissingError(`no credentials file at ${path} within ${timeoutMs}ms (host first boot still pending?)`);
|
|
729
742
|
}
|
|
730
|
-
throw new CredentialsGrantMissingError(`credentials record "${RECORD_KEY}" absent in ${path} within ${
|
|
743
|
+
throw new CredentialsGrantMissingError(`credentials record "${RECORD_KEY}" absent in ${path} within ${timeoutMs}ms (host first boot still pending?)`);
|
|
731
744
|
}
|
|
732
|
-
sleepSync(
|
|
745
|
+
sleepSync(retryIntervalMs);
|
|
733
746
|
}
|
|
734
747
|
}
|
|
735
748
|
function assertOwnerOnly(path) {
|
|
@@ -898,7 +911,7 @@ function sleepSync(ms) {
|
|
|
898
911
|
while (Date.now() < until) {}
|
|
899
912
|
}
|
|
900
913
|
}
|
|
901
|
-
var RECORD_KEY = "client-connection/browser-session", DEFAULT_MAX_AGE_MS,
|
|
914
|
+
var RECORD_KEY = "client-connection/browser-session", DEFAULT_MAX_AGE_MS, DEFAULT_RETRY_INTERVAL_MS = 100, DEFAULT_RETRY_WINDOW_MS = 30000, RETRY_WINDOW_ENV = "DSH_OPENTUI_COOKIE_MINT_TIMEOUT_MS", SECRET_PATTERN, OwnerCookieError, CredentialsFileMissingError, CredentialsGrantMissingError, CredentialsGrantInvalidError, CredentialsFileInsecureError, CredentialsParseError;
|
|
902
915
|
var init_cookie_mint = __esm(() => {
|
|
903
916
|
DEFAULT_MAX_AGE_MS = 30 * 86400000;
|
|
904
917
|
SECRET_PATTERN = /^[A-Za-z0-9_-]{43}$/;
|
|
@@ -5600,6 +5613,7 @@ class ClientConnection {
|
|
|
5600
5613
|
#state = "connecting";
|
|
5601
5614
|
#closed = false;
|
|
5602
5615
|
#maxConnectAttempts;
|
|
5616
|
+
#boundedPoll;
|
|
5603
5617
|
#connectBudgetMs;
|
|
5604
5618
|
#diagnostics;
|
|
5605
5619
|
#connectAttempts = 0;
|
|
@@ -5629,6 +5643,7 @@ class ClientConnection {
|
|
|
5629
5643
|
}
|
|
5630
5644
|
};
|
|
5631
5645
|
this.#recovery = options.recovery;
|
|
5646
|
+
this.#boundedPoll = options.maxConnectAttempts === undefined;
|
|
5632
5647
|
this.#maxConnectAttempts = Math.max(0, options.maxConnectAttempts ?? DEFAULT_MAX_CONNECT_ATTEMPTS);
|
|
5633
5648
|
this.#connectBudgetMs = resolveConnectTimeoutMs(options.connectBudgetMs);
|
|
5634
5649
|
this.#diagnostics = options.diagnostics;
|
|
@@ -5663,7 +5678,7 @@ class ClientConnection {
|
|
|
5663
5678
|
handle.registerGenerationSource((signal, ready) => {
|
|
5664
5679
|
if (!this.#connectedOnce) {
|
|
5665
5680
|
this.#connectAttempts += 1;
|
|
5666
|
-
if (this.#connectAttempts > this.#maxConnectAttempts + 1) {
|
|
5681
|
+
if (!this.#boundedPoll && this.#connectAttempts > this.#maxConnectAttempts + 1) {
|
|
5667
5682
|
this.#failConnect(new ConnectionRetryExhaustedError(this.#maxConnectAttempts, this.authority, this.#diagnostics?.()));
|
|
5668
5683
|
return new Promise((resolve) => {
|
|
5669
5684
|
if (signal.aborted)
|
|
@@ -41579,6 +41594,134 @@ var init_interactivity = __esm(() => {
|
|
|
41579
41594
|
Context4 = createContext(() => true);
|
|
41580
41595
|
});
|
|
41581
41596
|
|
|
41597
|
+
// ../tui-base/src/context/input-ownership.tsx
|
|
41598
|
+
function InputOwnershipProvider(props) {
|
|
41599
|
+
const page = {
|
|
41600
|
+
id: Symbol("page"),
|
|
41601
|
+
kind: "page"
|
|
41602
|
+
};
|
|
41603
|
+
const [stack, setStack] = createSignal([page]);
|
|
41604
|
+
const top = () => stack().at(-1) ?? page;
|
|
41605
|
+
const value = {
|
|
41606
|
+
top,
|
|
41607
|
+
pageFrame: () => page,
|
|
41608
|
+
push(kind) {
|
|
41609
|
+
const frame = {
|
|
41610
|
+
id: Symbol(kind),
|
|
41611
|
+
kind
|
|
41612
|
+
};
|
|
41613
|
+
setStack((items) => [...items, frame]);
|
|
41614
|
+
return frame;
|
|
41615
|
+
},
|
|
41616
|
+
pop(frame) {
|
|
41617
|
+
if (!frame || frame === page)
|
|
41618
|
+
return;
|
|
41619
|
+
setStack((items) => items.some((item) => item.id === frame.id) ? items.filter((item) => item.id !== frame.id) : items);
|
|
41620
|
+
},
|
|
41621
|
+
owns(frame) {
|
|
41622
|
+
return frame !== undefined && top().id === frame.id;
|
|
41623
|
+
}
|
|
41624
|
+
};
|
|
41625
|
+
return createComponent2(Context5.Provider, {
|
|
41626
|
+
value,
|
|
41627
|
+
get children() {
|
|
41628
|
+
return props.children;
|
|
41629
|
+
}
|
|
41630
|
+
});
|
|
41631
|
+
}
|
|
41632
|
+
function useInputOwnership() {
|
|
41633
|
+
const value = useContext(Context5);
|
|
41634
|
+
if (!value)
|
|
41635
|
+
throw new Error("InputOwnership.Provider is missing");
|
|
41636
|
+
return value;
|
|
41637
|
+
}
|
|
41638
|
+
function useInputOwnershipOptional() {
|
|
41639
|
+
return useContext(Context5);
|
|
41640
|
+
}
|
|
41641
|
+
function useIsPageOwner() {
|
|
41642
|
+
const ownership = useInputOwnershipOptional();
|
|
41643
|
+
return () => ownership === undefined || ownership.owns(ownership.pageFrame());
|
|
41644
|
+
}
|
|
41645
|
+
var Context5;
|
|
41646
|
+
var init_input_ownership = __esm(() => {
|
|
41647
|
+
init_index_bun();
|
|
41648
|
+
init_server();
|
|
41649
|
+
Context5 = createContext(undefined);
|
|
41650
|
+
});
|
|
41651
|
+
|
|
41652
|
+
// ../tui-base/src/context/focus-router.tsx
|
|
41653
|
+
function tierOfFrame(frame) {
|
|
41654
|
+
if (!frame)
|
|
41655
|
+
return;
|
|
41656
|
+
switch (frame.kind) {
|
|
41657
|
+
case "dialog":
|
|
41658
|
+
return "modal";
|
|
41659
|
+
case "panel":
|
|
41660
|
+
case "dock":
|
|
41661
|
+
return "overlay";
|
|
41662
|
+
case "page":
|
|
41663
|
+
return "main";
|
|
41664
|
+
}
|
|
41665
|
+
}
|
|
41666
|
+
function resolveCapture(top, tier, frame) {
|
|
41667
|
+
if (!top)
|
|
41668
|
+
return false;
|
|
41669
|
+
if (tier === "main" || tier === "global")
|
|
41670
|
+
return top.kind === "page";
|
|
41671
|
+
const tierMatches = tierOfFrame(top) === tier;
|
|
41672
|
+
if (!tierMatches)
|
|
41673
|
+
return false;
|
|
41674
|
+
return frame === undefined || top.id === frame.id;
|
|
41675
|
+
}
|
|
41676
|
+
function createFocusRouter(ownership) {
|
|
41677
|
+
const top = ownership.top;
|
|
41678
|
+
return {
|
|
41679
|
+
top,
|
|
41680
|
+
topTier: () => tierOfFrame(top()),
|
|
41681
|
+
allows(tier, frame) {
|
|
41682
|
+
return resolveCapture(top(), tier, frame);
|
|
41683
|
+
},
|
|
41684
|
+
ownership
|
|
41685
|
+
};
|
|
41686
|
+
}
|
|
41687
|
+
function useFocusRouterOptional() {
|
|
41688
|
+
return useContext(Context6);
|
|
41689
|
+
}
|
|
41690
|
+
function useIsPageOwner2() {
|
|
41691
|
+
const router = useFocusRouterOptional();
|
|
41692
|
+
if (router)
|
|
41693
|
+
return () => router.allows("main");
|
|
41694
|
+
const ownership = useInputOwnershipOptional();
|
|
41695
|
+
return () => ownership === undefined || ownership.owns(ownership.pageFrame());
|
|
41696
|
+
}
|
|
41697
|
+
function Scope2(props) {
|
|
41698
|
+
const router = createFocusRouter(useInputOwnership());
|
|
41699
|
+
return createComponent2(Context6.Provider, {
|
|
41700
|
+
value: router,
|
|
41701
|
+
get children() {
|
|
41702
|
+
return props.children;
|
|
41703
|
+
}
|
|
41704
|
+
});
|
|
41705
|
+
}
|
|
41706
|
+
function FocusRouterProvider(props) {
|
|
41707
|
+
return createComponent2(InputOwnershipProvider, {
|
|
41708
|
+
get children() {
|
|
41709
|
+
return createComponent2(Scope2, {
|
|
41710
|
+
get children() {
|
|
41711
|
+
return props.children;
|
|
41712
|
+
}
|
|
41713
|
+
});
|
|
41714
|
+
}
|
|
41715
|
+
});
|
|
41716
|
+
}
|
|
41717
|
+
var Context6;
|
|
41718
|
+
var init_focus_router = __esm(() => {
|
|
41719
|
+
init_index_bun();
|
|
41720
|
+
init_server();
|
|
41721
|
+
init_input_ownership();
|
|
41722
|
+
Context6 = createContext(undefined);
|
|
41723
|
+
});
|
|
41724
|
+
|
|
41582
41725
|
// ../tui-base/src/context/keymap.tsx
|
|
41583
41726
|
import { InputRenderable as InputRenderable4, TextareaRenderable as TextareaRenderable3 } from "@opentui/core";
|
|
41584
41727
|
function Provider(props) {
|
|
@@ -41634,7 +41777,7 @@ function Provider(props) {
|
|
|
41634
41777
|
return createComponent2(KeymapProvider, {
|
|
41635
41778
|
keymap,
|
|
41636
41779
|
get children() {
|
|
41637
|
-
return createComponent2(
|
|
41780
|
+
return createComponent2(Context7.Provider, {
|
|
41638
41781
|
value: {
|
|
41639
41782
|
keymap,
|
|
41640
41783
|
config,
|
|
@@ -41672,6 +41815,7 @@ function use2() {
|
|
|
41672
41815
|
function createLayer(input) {
|
|
41673
41816
|
const value = useValue();
|
|
41674
41817
|
const enabled = useInteractivity();
|
|
41818
|
+
const focus = useFocusRouterOptional();
|
|
41675
41819
|
const stable = new Map;
|
|
41676
41820
|
useBindings(() => {
|
|
41677
41821
|
const layer = input();
|
|
@@ -41679,12 +41823,20 @@ function createLayer(input) {
|
|
|
41679
41823
|
commands,
|
|
41680
41824
|
bindings,
|
|
41681
41825
|
mode,
|
|
41826
|
+
capture,
|
|
41827
|
+
captureFrame,
|
|
41682
41828
|
...options
|
|
41683
41829
|
} = layer;
|
|
41684
41830
|
const grouped = groupCommands(commands);
|
|
41831
|
+
const resolvedEnabled = focus && capture !== undefined ? () => {
|
|
41832
|
+
const base = typeof options.enabled === "function" ? options.enabled() : options.enabled === undefined ? true : options.enabled;
|
|
41833
|
+
if (!base)
|
|
41834
|
+
return false;
|
|
41835
|
+
return focus.allows(capture, captureFrame?.());
|
|
41836
|
+
} : options.enabled;
|
|
41685
41837
|
return {
|
|
41686
41838
|
...options,
|
|
41687
|
-
enabled: enabled() ?
|
|
41839
|
+
enabled: enabled() ? resolvedEnabled : false,
|
|
41688
41840
|
...mode === "global" ? {} : {
|
|
41689
41841
|
mode: mode ?? MODE.base
|
|
41690
41842
|
},
|
|
@@ -41908,13 +42060,13 @@ function useState() {
|
|
|
41908
42060
|
};
|
|
41909
42061
|
}
|
|
41910
42062
|
function useValue() {
|
|
41911
|
-
const value = useContext(
|
|
42063
|
+
const value = useContext(Context7);
|
|
41912
42064
|
if (!value)
|
|
41913
42065
|
throw new Error("Keymap.Provider is missing");
|
|
41914
42066
|
return value;
|
|
41915
42067
|
}
|
|
41916
42068
|
function useOptional() {
|
|
41917
|
-
return useContext(
|
|
42069
|
+
return useContext(Context7) ? use2() : undefined;
|
|
41918
42070
|
}
|
|
41919
42071
|
function createMode(keymap) {
|
|
41920
42072
|
const [stack, setStack] = createSignal([]);
|
|
@@ -41971,7 +42123,7 @@ function formatOptions(config) {
|
|
|
41971
42123
|
}
|
|
41972
42124
|
};
|
|
41973
42125
|
}
|
|
41974
|
-
var MODE,
|
|
42126
|
+
var MODE, Context7, Keymap2;
|
|
41975
42127
|
var init_keymap = __esm(() => {
|
|
41976
42128
|
init_index_bun();
|
|
41977
42129
|
init_src2();
|
|
@@ -41984,11 +42136,12 @@ var init_keymap = __esm(() => {
|
|
|
41984
42136
|
init_config();
|
|
41985
42137
|
init_keybind();
|
|
41986
42138
|
init_interactivity();
|
|
42139
|
+
init_focus_router();
|
|
41987
42140
|
MODE = {
|
|
41988
42141
|
key: "opencode.mode",
|
|
41989
42142
|
base: "base"
|
|
41990
42143
|
};
|
|
41991
|
-
|
|
42144
|
+
Context7 = createContext();
|
|
41992
42145
|
Keymap2 = {
|
|
41993
42146
|
Provider,
|
|
41994
42147
|
use: use2,
|
|
@@ -43577,55 +43730,6 @@ var require_fuzzysort = __commonJS(function(exports, module) {
|
|
|
43577
43730
|
});
|
|
43578
43731
|
});
|
|
43579
43732
|
|
|
43580
|
-
// ../tui-base/src/context/input-ownership.tsx
|
|
43581
|
-
function InputOwnershipProvider(props) {
|
|
43582
|
-
const page = {
|
|
43583
|
-
id: Symbol("page"),
|
|
43584
|
-
kind: "page"
|
|
43585
|
-
};
|
|
43586
|
-
const [stack, setStack] = createSignal([page]);
|
|
43587
|
-
const top = () => stack().at(-1) ?? page;
|
|
43588
|
-
const value = {
|
|
43589
|
-
top,
|
|
43590
|
-
pageFrame: () => page,
|
|
43591
|
-
push(kind) {
|
|
43592
|
-
const frame = {
|
|
43593
|
-
id: Symbol(kind),
|
|
43594
|
-
kind
|
|
43595
|
-
};
|
|
43596
|
-
setStack((items) => [...items, frame]);
|
|
43597
|
-
return frame;
|
|
43598
|
-
},
|
|
43599
|
-
pop(frame) {
|
|
43600
|
-
if (!frame || frame === page)
|
|
43601
|
-
return;
|
|
43602
|
-
setStack((items) => items.some((item) => item.id === frame.id) ? items.filter((item) => item.id !== frame.id) : items);
|
|
43603
|
-
},
|
|
43604
|
-
owns(frame) {
|
|
43605
|
-
return frame !== undefined && top().id === frame.id;
|
|
43606
|
-
}
|
|
43607
|
-
};
|
|
43608
|
-
return createComponent2(Context6.Provider, {
|
|
43609
|
-
value,
|
|
43610
|
-
get children() {
|
|
43611
|
-
return props.children;
|
|
43612
|
-
}
|
|
43613
|
-
});
|
|
43614
|
-
}
|
|
43615
|
-
function useInputOwnershipOptional() {
|
|
43616
|
-
return useContext(Context6);
|
|
43617
|
-
}
|
|
43618
|
-
function useIsPageOwner() {
|
|
43619
|
-
const ownership = useInputOwnershipOptional();
|
|
43620
|
-
return () => ownership === undefined || ownership.owns(ownership.pageFrame());
|
|
43621
|
-
}
|
|
43622
|
-
var Context6;
|
|
43623
|
-
var init_input_ownership = __esm(() => {
|
|
43624
|
-
init_index_bun();
|
|
43625
|
-
init_server();
|
|
43626
|
-
Context6 = createContext(undefined);
|
|
43627
|
-
});
|
|
43628
|
-
|
|
43629
43733
|
// ../tui-base/src/ui/border.ts
|
|
43630
43734
|
var EmptyBorder, SplitBorder;
|
|
43631
43735
|
var init_border = __esm(() => {
|
|
@@ -44275,6 +44379,8 @@ function init2() {
|
|
|
44275
44379
|
}
|
|
44276
44380
|
Keymap2.createLayer(() => ({
|
|
44277
44381
|
mode: "modal",
|
|
44382
|
+
capture: "modal",
|
|
44383
|
+
captureFrame: () => store.stack.at(-1)?.frame,
|
|
44278
44384
|
enabled: store.stack.length > 0 && (ownership === undefined || ownership.owns(store.stack.at(-1)?.frame)),
|
|
44279
44385
|
commands: [{
|
|
44280
44386
|
bind: "escape",
|
|
@@ -47557,12 +47663,6 @@ function subagentHardStopGlyph(view) {
|
|
|
47557
47663
|
return "\u23FB!";
|
|
47558
47664
|
return view.hardStopRound !== undefined ? "\u23FB" : "";
|
|
47559
47665
|
}
|
|
47560
|
-
function foldSubagentMarkerViews(views) {
|
|
47561
|
-
setSubagentViews(views);
|
|
47562
|
-
}
|
|
47563
|
-
function registerSubagentSteer(fn) {
|
|
47564
|
-
steerImpl = fn;
|
|
47565
|
-
}
|
|
47566
47666
|
function steerSubagent(id, text) {
|
|
47567
47667
|
return steerImpl?.(id, text);
|
|
47568
47668
|
}
|
|
@@ -52180,6 +52280,7 @@ function TranscriptScrollKeys(props) {
|
|
|
52180
52280
|
};
|
|
52181
52281
|
Keymap2.createLayer(() => ({
|
|
52182
52282
|
mode: "global",
|
|
52283
|
+
capture: "main",
|
|
52183
52284
|
enabled: props.enabled(),
|
|
52184
52285
|
commands: [{
|
|
52185
52286
|
id: "session.page.up",
|
|
@@ -52208,6 +52309,7 @@ function TranscriptScrollKeys(props) {
|
|
|
52208
52309
|
scroll.scrollTo(Infinity);
|
|
52209
52310
|
};
|
|
52210
52311
|
Keymap2.createLayer(() => ({
|
|
52312
|
+
capture: "main",
|
|
52211
52313
|
enabled: () => props.enabled() && renderer.currentFocusedEditor === null,
|
|
52212
52314
|
commands: [{
|
|
52213
52315
|
id: "session.first",
|
|
@@ -52312,6 +52414,7 @@ function PaneFocusKeys(props) {
|
|
|
52312
52414
|
Keymap2.createLayer(() => ({
|
|
52313
52415
|
mode: "global",
|
|
52314
52416
|
priority: 1,
|
|
52417
|
+
capture: "main",
|
|
52315
52418
|
enabled: paneToggleEnabled({
|
|
52316
52419
|
pane: props.pane(),
|
|
52317
52420
|
keysEnabled: props.keysEnabled(),
|
|
@@ -52332,6 +52435,7 @@ function PaneFocusKeys(props) {
|
|
|
52332
52435
|
Keymap2.createLayer(() => ({
|
|
52333
52436
|
mode: "global",
|
|
52334
52437
|
priority: 1,
|
|
52438
|
+
capture: "main",
|
|
52335
52439
|
enabled: transcriptKeysEnabled({
|
|
52336
52440
|
pane: props.pane(),
|
|
52337
52441
|
keysEnabled: props.keysEnabled()
|
|
@@ -52748,7 +52852,7 @@ function DockProvider(props) {
|
|
|
52748
52852
|
}
|
|
52749
52853
|
setQueue([]);
|
|
52750
52854
|
});
|
|
52751
|
-
return createComponent2(
|
|
52855
|
+
return createComponent2(Context8.Provider, {
|
|
52752
52856
|
value: api,
|
|
52753
52857
|
get children() {
|
|
52754
52858
|
return props.children;
|
|
@@ -52756,7 +52860,7 @@ function DockProvider(props) {
|
|
|
52756
52860
|
});
|
|
52757
52861
|
}
|
|
52758
52862
|
function useDock() {
|
|
52759
|
-
const value = useContext(
|
|
52863
|
+
const value = useContext(Context8);
|
|
52760
52864
|
if (!value)
|
|
52761
52865
|
throw new Error("Dock.Provider is missing");
|
|
52762
52866
|
return value;
|
|
@@ -52887,7 +52991,7 @@ function DockSeat(props) {
|
|
|
52887
52991
|
return _el$;
|
|
52888
52992
|
})();
|
|
52889
52993
|
}
|
|
52890
|
-
var DOCK_MAX_ROWS_RATIO = 0.6,
|
|
52994
|
+
var DOCK_MAX_ROWS_RATIO = 0.6, Context8, ordinal2 = 0;
|
|
52891
52995
|
var init_dock_host = __esm(() => {
|
|
52892
52996
|
init_index_bun();
|
|
52893
52997
|
init_index_bun();
|
|
@@ -52902,7 +53006,7 @@ var init_dock_host = __esm(() => {
|
|
|
52902
53006
|
init_input_ownership();
|
|
52903
53007
|
init_theme3();
|
|
52904
53008
|
init_terminal_size();
|
|
52905
|
-
|
|
53009
|
+
Context8 = createContext(undefined);
|
|
52906
53010
|
});
|
|
52907
53011
|
|
|
52908
53012
|
// ../tui-base/src/routes/session/ask-panel.tsx
|
|
@@ -54054,6 +54158,7 @@ function TurnCancelKeys(props) {
|
|
|
54054
54158
|
onCleanup(() => cancel.dispose());
|
|
54055
54159
|
Keymap2.createLayer(() => ({
|
|
54056
54160
|
mode: "global",
|
|
54161
|
+
capture: "main",
|
|
54057
54162
|
enabled: props.enabled(),
|
|
54058
54163
|
commands: [{
|
|
54059
54164
|
bind: "escape",
|
|
@@ -54759,6 +54864,72 @@ function formatSessionInfoPanel(rows) {
|
|
|
54759
54864
|
return rows.map((row) => `${row.field.padEnd(width)} ${row.value}`);
|
|
54760
54865
|
}
|
|
54761
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
|
+
|
|
54762
54933
|
// ../tui-base/src/routes/session/model-picker.ts
|
|
54763
54934
|
function modelKey(providerID, modelID) {
|
|
54764
54935
|
return `${providerID}/${modelID}`;
|
|
@@ -54789,8 +54960,39 @@ function buildModelPickerRows(entries, favorites, hidden, current) {
|
|
|
54789
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"));
|
|
54790
54961
|
return [...favoriteRows, ...normalRows, ...hiddenRows];
|
|
54791
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
|
+
}
|
|
54792
54966
|
|
|
54793
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
|
+
}
|
|
54794
54996
|
function deriveKeyRef(provider) {
|
|
54795
54997
|
return `${provider.toUpperCase().replace(/[^A-Z0-9]+/g, "_")}_API_KEY`;
|
|
54796
54998
|
}
|
|
@@ -55006,6 +55208,30 @@ async function offerCorruptedLogRepair(ctx, sessionId, broken) {
|
|
|
55006
55208
|
}
|
|
55007
55209
|
return true;
|
|
55008
55210
|
}
|
|
55211
|
+
async function resolveLoginCatalog(seam, say) {
|
|
55212
|
+
const dir = seam.providerDirectory;
|
|
55213
|
+
if (!dir)
|
|
55214
|
+
return { entries: [...PROVIDER_CATALOG], degraded: false };
|
|
55215
|
+
let registered = [];
|
|
55216
|
+
let configurable = [];
|
|
55217
|
+
let failed = false;
|
|
55218
|
+
try {
|
|
55219
|
+
registered = await dir.registered();
|
|
55220
|
+
} catch {
|
|
55221
|
+
failed = true;
|
|
55222
|
+
}
|
|
55223
|
+
try {
|
|
55224
|
+
configurable = await dir.configurable();
|
|
55225
|
+
} catch {
|
|
55226
|
+
failed = true;
|
|
55227
|
+
}
|
|
55228
|
+
const real = catalogEntriesFromDirectory(registered, configurable);
|
|
55229
|
+
if (real.length === 0)
|
|
55230
|
+
return { entries: [...PROVIDER_CATALOG], degraded: true };
|
|
55231
|
+
if (failed)
|
|
55232
|
+
say(t("command.login.directoryPartial"));
|
|
55233
|
+
return { entries: real, degraded: false };
|
|
55234
|
+
}
|
|
55009
55235
|
async function commitCatalogLogin(ctx, face, entry) {
|
|
55010
55236
|
const key = await ctx.promptText?.(`API key for ${entry.name} (${deriveKeyRef(entry.id)})`, { mask: true });
|
|
55011
55237
|
if (key === undefined)
|
|
@@ -55099,6 +55325,30 @@ function coreCommands() {
|
|
|
55099
55325
|
ctx.say(t("command.model.stagedSwitchFailed", { reason: pendingSelectionError }));
|
|
55100
55326
|
}
|
|
55101
55327
|
const arg = argText.trim();
|
|
55328
|
+
if (arg === "discover") {
|
|
55329
|
+
const discover = ctx.seam.providerDirectory?.discover;
|
|
55330
|
+
if (typeof discover !== "function") {
|
|
55331
|
+
ctx.say(t("command.model.discoverUnavailable", { reason: "no discovery face" }));
|
|
55332
|
+
return;
|
|
55333
|
+
}
|
|
55334
|
+
let providerID = "default";
|
|
55335
|
+
try {
|
|
55336
|
+
providerID = (await ctx.seam.currentModelSelection?.())?.providerID ?? "default";
|
|
55337
|
+
} catch {}
|
|
55338
|
+
ctx.say(t("command.model.discovering", { provider: providerID }));
|
|
55339
|
+
try {
|
|
55340
|
+
const models = await discover("llm", { provider: providerID });
|
|
55341
|
+
if (models.length === 0) {
|
|
55342
|
+
ctx.say(t("command.model.discoverEmpty"));
|
|
55343
|
+
return;
|
|
55344
|
+
}
|
|
55345
|
+
const list = formatDiscoveredModels(models);
|
|
55346
|
+
ctx.say(t("command.model.discovered", { n: models.length, list }));
|
|
55347
|
+
} catch (error) {
|
|
55348
|
+
ctx.say(t("command.model.discoverUnavailable", { reason: seamFailureReason(error) }));
|
|
55349
|
+
}
|
|
55350
|
+
return;
|
|
55351
|
+
}
|
|
55102
55352
|
if (arg) {
|
|
55103
55353
|
const [providerID, modelID] = arg.split("/");
|
|
55104
55354
|
if (!providerID || !modelID) {
|
|
@@ -55241,9 +55491,12 @@ function coreCommands() {
|
|
|
55241
55491
|
ctx.say(t("command.login.unavailable"));
|
|
55242
55492
|
return;
|
|
55243
55493
|
}
|
|
55494
|
+
const { entries, degraded } = await resolveLoginCatalog(ctx.seam, ctx.say);
|
|
55495
|
+
if (degraded)
|
|
55496
|
+
ctx.say(t("command.login.directoryDegraded"));
|
|
55244
55497
|
const arg = argText.trim().toLowerCase();
|
|
55245
55498
|
if (arg) {
|
|
55246
|
-
const entry =
|
|
55499
|
+
const entry = entries.find((e) => e.id === arg);
|
|
55247
55500
|
if (!entry) {
|
|
55248
55501
|
ctx.say(t("command.login.unknownProvider", { provider: arg }));
|
|
55249
55502
|
return;
|
|
@@ -55251,7 +55504,7 @@ function coreCommands() {
|
|
|
55251
55504
|
await commitCatalogLogin(ctx, face, entry);
|
|
55252
55505
|
return;
|
|
55253
55506
|
}
|
|
55254
|
-
const picked = await ctx.pickOne(LOGIN_PICKER_TITLE, [CUSTOM_ENTRY, ...
|
|
55507
|
+
const picked = await ctx.pickOne(LOGIN_PICKER_TITLE, [CUSTOM_ENTRY, ...entries].map((e) => ({ title: e.name, value: e.id, description: e.hint })));
|
|
55255
55508
|
if (!picked)
|
|
55256
55509
|
return;
|
|
55257
55510
|
if (picked === CUSTOM_ENTRY.id) {
|
|
@@ -55259,7 +55512,7 @@ function coreCommands() {
|
|
|
55259
55512
|
await runCustomLoginChain(ctx, face, routes);
|
|
55260
55513
|
return;
|
|
55261
55514
|
}
|
|
55262
|
-
const entry =
|
|
55515
|
+
const entry = entries.find((e) => e.id === picked);
|
|
55263
55516
|
if (!entry)
|
|
55264
55517
|
return;
|
|
55265
55518
|
await commitCatalogLogin(ctx, face, entry);
|
|
@@ -55440,6 +55693,71 @@ function coreCommands() {
|
|
|
55440
55693
|
ctx.say(t("command.plugins.entry", { name: plugin.name, version: plugin.version }));
|
|
55441
55694
|
}
|
|
55442
55695
|
},
|
|
55696
|
+
{
|
|
55697
|
+
name: "/goals",
|
|
55698
|
+
description: t("command.goals.description"),
|
|
55699
|
+
async run(ctx, argText) {
|
|
55700
|
+
const goals = ctx.seam.goals;
|
|
55701
|
+
if (!goals) {
|
|
55702
|
+
ctx.say(t("command.goals.unavailable"));
|
|
55703
|
+
return;
|
|
55704
|
+
}
|
|
55705
|
+
const unknownOp = goalsUnknownOp(argText);
|
|
55706
|
+
if (unknownOp !== undefined)
|
|
55707
|
+
ctx.say(goalsUnknownOpHint(unknownOp));
|
|
55708
|
+
const op = parseGoalsArgs(argText);
|
|
55709
|
+
if (op.kind === "status") {
|
|
55710
|
+
try {
|
|
55711
|
+
const view = await goals.status();
|
|
55712
|
+
if (view === undefined) {
|
|
55713
|
+
ctx.say(t("command.goals.none"));
|
|
55714
|
+
return;
|
|
55715
|
+
}
|
|
55716
|
+
for (const line of formatGoalStatus(view))
|
|
55717
|
+
ctx.say(line);
|
|
55718
|
+
} catch {
|
|
55719
|
+
ctx.say(t("command.goals.degraded"));
|
|
55720
|
+
}
|
|
55721
|
+
return;
|
|
55722
|
+
}
|
|
55723
|
+
let objective = op.kind === "create" || op.kind === "edit" ? op.objective : "";
|
|
55724
|
+
if ((op.kind === "create" || op.kind === "edit") && objective === "" && ctx.promptText) {
|
|
55725
|
+
const answer = await ctx.promptText(t("command.goals.prompt.objective"));
|
|
55726
|
+
objective = (answer ?? "").trim();
|
|
55727
|
+
}
|
|
55728
|
+
if ((op.kind === "create" || op.kind === "edit") && objective === "") {
|
|
55729
|
+
ctx.say(t("command.goals.aborted"));
|
|
55730
|
+
return;
|
|
55731
|
+
}
|
|
55732
|
+
const confirmed = ctx.pickOne ? await ctx.pickOne(goalsConfirmTitle(op), goalsConfirmOptions()) === "yes" : false;
|
|
55733
|
+
if (!confirmed) {
|
|
55734
|
+
ctx.say(t("command.goals.aborted"));
|
|
55735
|
+
return;
|
|
55736
|
+
}
|
|
55737
|
+
try {
|
|
55738
|
+
if (op.kind === "create") {
|
|
55739
|
+
const ref = await goals.create(objective);
|
|
55740
|
+
ctx.say(ref ? t("command.goals.created", { id: ref.id, revision: ref.revision }) : t("command.goals.failed"));
|
|
55741
|
+
} else {
|
|
55742
|
+
const view = await goals.status();
|
|
55743
|
+
if (view === undefined) {
|
|
55744
|
+
ctx.say(t("command.goals.none"));
|
|
55745
|
+
return;
|
|
55746
|
+
}
|
|
55747
|
+
const ref = { id: view.id, revision: view.revision };
|
|
55748
|
+
if (op.kind === "edit") {
|
|
55749
|
+
const edited = await goals.edit(ref, { objective });
|
|
55750
|
+
ctx.say(edited ? t("command.goals.edited") : t("command.goals.failed"));
|
|
55751
|
+
} else {
|
|
55752
|
+
const changed = await goals[op.kind](ref);
|
|
55753
|
+
ctx.say(changed ? t("command.goals.updated", { op: op.kind }) : t("command.goals.failed"));
|
|
55754
|
+
}
|
|
55755
|
+
}
|
|
55756
|
+
} catch {
|
|
55757
|
+
ctx.say(t("command.goals.degraded"));
|
|
55758
|
+
}
|
|
55759
|
+
}
|
|
55760
|
+
},
|
|
55443
55761
|
{
|
|
55444
55762
|
name: "/skills",
|
|
55445
55763
|
description: t("command.skills.description"),
|
|
@@ -55466,10 +55784,6 @@ function coreCommands() {
|
|
|
55466
55784
|
name: "/agents",
|
|
55467
55785
|
description: t("command.agents.description"),
|
|
55468
55786
|
run(ctx, argText) {
|
|
55469
|
-
if (!ctx.seam.agents) {
|
|
55470
|
-
ctx.say(t("command.agents.unavailable"));
|
|
55471
|
-
return;
|
|
55472
|
-
}
|
|
55473
55787
|
if (!ctx.openAgents) {
|
|
55474
55788
|
ctx.say(t("command.agents.panelNotMounted"));
|
|
55475
55789
|
return;
|
|
@@ -55813,6 +56127,39 @@ function coreCommands() {
|
|
|
55813
56127
|
];
|
|
55814
56128
|
ctx.say(t("command.stop.done", { parts: parts.join(", ") }));
|
|
55815
56129
|
}
|
|
56130
|
+
},
|
|
56131
|
+
{
|
|
56132
|
+
name: "/account",
|
|
56133
|
+
description: t("command.account.description"),
|
|
56134
|
+
async run(ctx, argText) {
|
|
56135
|
+
const face = ctx.seam.account;
|
|
56136
|
+
if (!face) {
|
|
56137
|
+
ctx.say(t("command.account.unavailable"));
|
|
56138
|
+
return;
|
|
56139
|
+
}
|
|
56140
|
+
const show = (state) => {
|
|
56141
|
+
ctx.say(t("command.account.state", {
|
|
56142
|
+
status: state.status ?? "\u2014",
|
|
56143
|
+
phase: state.attemptPhase ?? "\u2014",
|
|
56144
|
+
urlReady: state.authorizeUrlReady ? "\u2713" : "\u2014",
|
|
56145
|
+
links: state.linksPresent ? "\u2713" : "\u2014"
|
|
56146
|
+
}));
|
|
56147
|
+
};
|
|
56148
|
+
const arg = argText.trim().toLowerCase();
|
|
56149
|
+
try {
|
|
56150
|
+
if (!arg || arg === "state") {
|
|
56151
|
+
show(await face.getState());
|
|
56152
|
+
} else if (arg === "signin") {
|
|
56153
|
+
show(await face.startSignIn("http://localhost", "desktop"));
|
|
56154
|
+
} else if (arg === "signout") {
|
|
56155
|
+
show(await face.signOut());
|
|
56156
|
+
} else {
|
|
56157
|
+
ctx.say(t("command.account.unknownAction", { action: argText.trim() }));
|
|
56158
|
+
}
|
|
56159
|
+
} catch (error) {
|
|
56160
|
+
ctx.say(t("command.account.failed", { reason: seamFailureReason(error) }));
|
|
56161
|
+
}
|
|
56162
|
+
}
|
|
55816
56163
|
}
|
|
55817
56164
|
];
|
|
55818
56165
|
}
|
|
@@ -55840,6 +56187,7 @@ var MODEL_DEFAULT_EFFORT_PICK = "__model_default__";
|
|
|
55840
56187
|
var init_commands = __esm(() => {
|
|
55841
56188
|
init_i18n();
|
|
55842
56189
|
init_hotkeys();
|
|
56190
|
+
init_goals_command();
|
|
55843
56191
|
init_login();
|
|
55844
56192
|
init_hints_line();
|
|
55845
56193
|
init_motion();
|
|
@@ -57471,6 +57819,11 @@ var init_sessions_search = __esm(() => {
|
|
|
57471
57819
|
sessionsSearchOpen = panelOpen3;
|
|
57472
57820
|
});
|
|
57473
57821
|
|
|
57822
|
+
// ../tui-base/src/seams/session.ts
|
|
57823
|
+
function createPluginWriteConfirm(operation) {
|
|
57824
|
+
return { __pluginWriteConfirm: true, operation };
|
|
57825
|
+
}
|
|
57826
|
+
|
|
57474
57827
|
// ../tui-base/src/routes/session/plugins-panel.tsx
|
|
57475
57828
|
import { TextAttributes as TextAttributes10 } from "@opentui/core";
|
|
57476
57829
|
function openPluginsPanel() {
|
|
@@ -57493,6 +57846,8 @@ function filterPluginRows(rows, query) {
|
|
|
57493
57846
|
return rows.filter((row) => formatPluginLine(row).toLowerCase().includes(needle));
|
|
57494
57847
|
}
|
|
57495
57848
|
function bundleStateText(row) {
|
|
57849
|
+
if (row.stateUnknown === true)
|
|
57850
|
+
return t("panel.plugins.state.unknown");
|
|
57496
57851
|
const base = !row.installed && row.optional ? t("panel.plugins.state.available") : row.enabled ? t("panel.plugins.state.on") : t("panel.plugins.state.off");
|
|
57497
57852
|
if (row.error !== undefined && row.error !== "")
|
|
57498
57853
|
return t("panel.plugins.state.error", {
|
|
@@ -57513,9 +57868,10 @@ function pluginBundleViews(bundles) {
|
|
|
57513
57868
|
installed: bundle.installed === true,
|
|
57514
57869
|
optional: bundle.optional === true,
|
|
57515
57870
|
removable: bundle.removable === true,
|
|
57516
|
-
toggleable: bundle.readOnlyReason === undefined && (bundle.error === undefined || bundle.error === ""),
|
|
57871
|
+
toggleable: bundle.stateUnknown !== true && bundle.readOnlyReason === undefined && (bundle.error === undefined || bundle.error === ""),
|
|
57517
57872
|
readOnlyReason: bundle.readOnlyReason,
|
|
57518
|
-
error: bundle.error
|
|
57873
|
+
error: bundle.error,
|
|
57874
|
+
stateUnknown: bundle.stateUnknown
|
|
57519
57875
|
}));
|
|
57520
57876
|
}
|
|
57521
57877
|
function legacyPluginViews(rows) {
|
|
@@ -57565,6 +57921,72 @@ function installPreviewLine(inspection) {
|
|
|
57565
57921
|
spec
|
|
57566
57922
|
}) : spec;
|
|
57567
57923
|
}
|
|
57924
|
+
function writeConfirmObject(operation, target) {
|
|
57925
|
+
return t("panel.plugins.confirm.object", {
|
|
57926
|
+
operation: t(`panel.plugins.confirm.op.${operation}`),
|
|
57927
|
+
target
|
|
57928
|
+
});
|
|
57929
|
+
}
|
|
57930
|
+
function writeConfirmConsequence(operation) {
|
|
57931
|
+
return t(`panel.plugins.confirm.consequence.${operation}`);
|
|
57932
|
+
}
|
|
57933
|
+
function installProgressLine(progress) {
|
|
57934
|
+
switch (progress.state) {
|
|
57935
|
+
case "running":
|
|
57936
|
+
return t("panel.plugins.progress.running");
|
|
57937
|
+
case "cancelled":
|
|
57938
|
+
return t("panel.plugins.progress.cancelled", {
|
|
57939
|
+
target: progress.target || progress.requestId
|
|
57940
|
+
});
|
|
57941
|
+
case "failed":
|
|
57942
|
+
return t("panel.plugins.progress.failed", {
|
|
57943
|
+
target: progress.target || progress.requestId,
|
|
57944
|
+
error: progress.error ?? "?"
|
|
57945
|
+
});
|
|
57946
|
+
case "done":
|
|
57947
|
+
return t("panel.plugins.progress.done", {
|
|
57948
|
+
target: progress.target || progress.requestId
|
|
57949
|
+
});
|
|
57950
|
+
case "unknown":
|
|
57951
|
+
return t("panel.plugins.progress.unknown");
|
|
57952
|
+
}
|
|
57953
|
+
}
|
|
57954
|
+
async function pollInstallFace(wait, requestId, confirm, emit, stop, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))) {
|
|
57955
|
+
for (let tick = 0;tick < PROGRESS_POLL_MAX_TICKS; tick++) {
|
|
57956
|
+
if (stop())
|
|
57957
|
+
return;
|
|
57958
|
+
let progress;
|
|
57959
|
+
try {
|
|
57960
|
+
progress = await wait(requestId, confirm);
|
|
57961
|
+
} catch {
|
|
57962
|
+
return;
|
|
57963
|
+
}
|
|
57964
|
+
if (stop())
|
|
57965
|
+
return;
|
|
57966
|
+
emit(progress);
|
|
57967
|
+
if (progress.state !== "running")
|
|
57968
|
+
return;
|
|
57969
|
+
await sleep(PROGRESS_POLL_INTERVAL_MS);
|
|
57970
|
+
}
|
|
57971
|
+
}
|
|
57972
|
+
function pluginDetailPreview(detail, loading) {
|
|
57973
|
+
if (loading)
|
|
57974
|
+
return t("panel.plugins.detail.loading");
|
|
57975
|
+
if (detail === undefined)
|
|
57976
|
+
return t("panel.plugins.detail.unavailable");
|
|
57977
|
+
if (detail.status === "none")
|
|
57978
|
+
return t("panel.plugins.detail.none");
|
|
57979
|
+
const lines = detail.markdown.split(`
|
|
57980
|
+
`).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#"));
|
|
57981
|
+
const preview = lines.slice(0, 2).join(" ").slice(0, 180);
|
|
57982
|
+
return preview === "" ? t("panel.plugins.detail.none") : preview;
|
|
57983
|
+
}
|
|
57984
|
+
function createDegradedMemo(available, refreshTick) {
|
|
57985
|
+
return createMemo(() => {
|
|
57986
|
+
refreshTick();
|
|
57987
|
+
return available() === false;
|
|
57988
|
+
});
|
|
57989
|
+
}
|
|
57568
57990
|
function PluginsPanel(props) {
|
|
57569
57991
|
const theme = useThemeOptional();
|
|
57570
57992
|
const dialog = useDialog();
|
|
@@ -57577,8 +57999,18 @@ function PluginsPanel(props) {
|
|
|
57577
57999
|
const [status, setStatus] = createSignal(undefined);
|
|
57578
58000
|
const [installOpen, setInstallOpen] = createSignal(false);
|
|
57579
58001
|
const [installText, setInstallText] = createSignal("");
|
|
58002
|
+
const [detail, setDetail] = createSignal(undefined);
|
|
58003
|
+
const [detailLoading, setDetailLoading] = createSignal(false);
|
|
58004
|
+
const [refreshTick, setRefreshTick] = createSignal(0);
|
|
58005
|
+
const [installProgress, setInstallProgress] = createSignal(undefined);
|
|
58006
|
+
const [cancelArmed, setCancelArmed] = createSignal(false);
|
|
57580
58007
|
let statusTimer;
|
|
57581
|
-
|
|
58008
|
+
let progressTimer;
|
|
58009
|
+
onCleanup(() => {
|
|
58010
|
+
clearTimeout(statusTimer);
|
|
58011
|
+
if (progressTimer !== undefined)
|
|
58012
|
+
clearInterval(progressTimer);
|
|
58013
|
+
});
|
|
57582
58014
|
createEffect(() => {
|
|
57583
58015
|
if (bridgeOpen3()) {
|
|
57584
58016
|
setBridgeOpen3(false);
|
|
@@ -57587,7 +58019,12 @@ function PluginsPanel(props) {
|
|
|
57587
58019
|
setInstallOpen(false);
|
|
57588
58020
|
setInstallText("");
|
|
57589
58021
|
setCursor(0);
|
|
58022
|
+
setDetail(undefined);
|
|
57590
58023
|
setOpen(true);
|
|
58024
|
+
const seam = props.seam;
|
|
58025
|
+
if (typeof seam.refreshPluginBundles === "function") {
|
|
58026
|
+
seam.refreshPluginBundles().then(() => setRefreshTick((n) => n + 1)).catch(() => setRefreshTick((n) => n + 1));
|
|
58027
|
+
}
|
|
57591
58028
|
}
|
|
57592
58029
|
});
|
|
57593
58030
|
function flash(message, autoClearMs) {
|
|
@@ -57613,6 +58050,7 @@ function PluginsPanel(props) {
|
|
|
57613
58050
|
}
|
|
57614
58051
|
const bundles = createMemo(() => {
|
|
57615
58052
|
open();
|
|
58053
|
+
refreshTick();
|
|
57616
58054
|
try {
|
|
57617
58055
|
const seam = props.seam;
|
|
57618
58056
|
if (typeof seam.pluginBundles === "function")
|
|
@@ -57630,6 +58068,32 @@ function PluginsPanel(props) {
|
|
|
57630
58068
|
return rows[Math.min(cursor(), rows.length - 1)];
|
|
57631
58069
|
});
|
|
57632
58070
|
const cursorIndex = createMemo(() => visible().slice(0, 12).indexOf(current()));
|
|
58071
|
+
createEffect(() => {
|
|
58072
|
+
const row = current();
|
|
58073
|
+
const manager = props.seam.pluginsManager;
|
|
58074
|
+
if (row === undefined || typeof manager?.readBundleDetail !== "function" || manager.available?.() !== true) {
|
|
58075
|
+
setDetail(undefined);
|
|
58076
|
+
setDetailLoading(false);
|
|
58077
|
+
return;
|
|
58078
|
+
}
|
|
58079
|
+
const name = row.name;
|
|
58080
|
+
let stale = false;
|
|
58081
|
+
onCleanup(() => {
|
|
58082
|
+
stale = true;
|
|
58083
|
+
});
|
|
58084
|
+
setDetailLoading(true);
|
|
58085
|
+
manager.readBundleDetail(name, "en").then((d) => {
|
|
58086
|
+
if (!stale)
|
|
58087
|
+
setDetail(d);
|
|
58088
|
+
}).catch(() => {
|
|
58089
|
+
if (!stale)
|
|
58090
|
+
setDetail(undefined);
|
|
58091
|
+
}).finally(() => {
|
|
58092
|
+
if (!stale)
|
|
58093
|
+
setDetailLoading(false);
|
|
58094
|
+
});
|
|
58095
|
+
});
|
|
58096
|
+
const degraded = createDegradedMemo(() => props.seam.pluginsManager?.available?.(), refreshTick);
|
|
57633
58097
|
function moveCursor(delta) {
|
|
57634
58098
|
const count = visible().length;
|
|
57635
58099
|
if (count === 0)
|
|
@@ -57637,12 +58101,16 @@ function PluginsPanel(props) {
|
|
|
57637
58101
|
const next = Math.max(0, Math.min(cursor() + delta, count - 1));
|
|
57638
58102
|
setCursor(next);
|
|
57639
58103
|
}
|
|
57640
|
-
|
|
57641
|
-
if (row === undefined)
|
|
58104
|
+
function toggle(row) {
|
|
58105
|
+
if (row === undefined || busy())
|
|
57642
58106
|
return;
|
|
57643
|
-
if (
|
|
58107
|
+
if (typeof props.seam.setPluginBundleEnabled !== "function") {
|
|
58108
|
+
flash(t("panel.plugins.status.toggleUnavailable", {
|
|
58109
|
+
name: row.name
|
|
58110
|
+
}), 4000);
|
|
57644
58111
|
return;
|
|
57645
|
-
|
|
58112
|
+
}
|
|
58113
|
+
if (!row.toggleable) {
|
|
57646
58114
|
flash(row.readOnlyReason ? t("panel.plugins.status.readOnlyReason", {
|
|
57647
58115
|
name: row.name,
|
|
57648
58116
|
reason: row.readOnlyReason
|
|
@@ -57651,18 +58119,45 @@ function PluginsPanel(props) {
|
|
|
57651
58119
|
}), 4000);
|
|
57652
58120
|
return;
|
|
57653
58121
|
}
|
|
58122
|
+
const name = row.name;
|
|
58123
|
+
const enabled = !row.enabled;
|
|
58124
|
+
const operation = "setBundleEnabled";
|
|
58125
|
+
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
58126
|
+
get title() {
|
|
58127
|
+
return t("panel.plugins.dialog.actionTitle", {
|
|
58128
|
+
operation: t(`panel.plugins.confirm.op.${operation}`)
|
|
58129
|
+
});
|
|
58130
|
+
},
|
|
58131
|
+
get message() {
|
|
58132
|
+
return `${writeConfirmObject(operation, name)}
|
|
58133
|
+
${writeConfirmConsequence(operation)}`;
|
|
58134
|
+
},
|
|
58135
|
+
get label() {
|
|
58136
|
+
return {
|
|
58137
|
+
confirm: t("panel.plugins.dialog.actionConfirm"),
|
|
58138
|
+
cancel: t("panel.plugins.dialog.cancel")
|
|
58139
|
+
};
|
|
58140
|
+
},
|
|
58141
|
+
onConfirm: () => void toggleApply(name, enabled, operation)
|
|
58142
|
+
}), undefined, {
|
|
58143
|
+
tone: "warning"
|
|
58144
|
+
});
|
|
58145
|
+
}
|
|
58146
|
+
async function toggleApply(name, enabled, operation) {
|
|
58147
|
+
if (busy())
|
|
58148
|
+
return;
|
|
58149
|
+
if (typeof props.seam.setPluginBundleEnabled !== "function")
|
|
58150
|
+
return;
|
|
57654
58151
|
setBusy(true);
|
|
57655
|
-
flash(
|
|
57656
|
-
name
|
|
57657
|
-
}) : t("panel.plugins.status.enabling", {
|
|
57658
|
-
name: row.name
|
|
58152
|
+
flash(t(enabled ? "panel.plugins.status.enabling" : "panel.plugins.status.disabling", {
|
|
58153
|
+
name
|
|
57659
58154
|
}));
|
|
57660
58155
|
try {
|
|
57661
|
-
const change = await props.seam.setPluginBundleEnabled(
|
|
58156
|
+
const change = await props.seam.setPluginBundleEnabled(name, enabled, createPluginWriteConfirm(operation));
|
|
57662
58157
|
flash(pluginChangeNotice(change), 6000);
|
|
57663
58158
|
} catch (error) {
|
|
57664
58159
|
flash(t("panel.plugins.status.changeFailed", {
|
|
57665
|
-
name
|
|
58160
|
+
name,
|
|
57666
58161
|
error: errorMessage2(error)
|
|
57667
58162
|
}), 8000);
|
|
57668
58163
|
} finally {
|
|
@@ -57679,6 +58174,11 @@ function PluginsPanel(props) {
|
|
|
57679
58174
|
return;
|
|
57680
58175
|
}
|
|
57681
58176
|
const name = row.name;
|
|
58177
|
+
const operation = "removeBundle";
|
|
58178
|
+
const dryRun = t("panel.plugins.dryRun.remove", {
|
|
58179
|
+
name,
|
|
58180
|
+
version: row.version || "?"
|
|
58181
|
+
});
|
|
57682
58182
|
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
57683
58183
|
get title() {
|
|
57684
58184
|
return t("panel.plugins.dialog.uninstallTitle", {
|
|
@@ -57686,9 +58186,9 @@ function PluginsPanel(props) {
|
|
|
57686
58186
|
});
|
|
57687
58187
|
},
|
|
57688
58188
|
get message() {
|
|
57689
|
-
return
|
|
57690
|
-
|
|
57691
|
-
|
|
58189
|
+
return `${writeConfirmObject(operation, name)}
|
|
58190
|
+
${writeConfirmConsequence(operation)}
|
|
58191
|
+
${dryRun}`;
|
|
57692
58192
|
},
|
|
57693
58193
|
get label() {
|
|
57694
58194
|
return {
|
|
@@ -57696,12 +58196,12 @@ function PluginsPanel(props) {
|
|
|
57696
58196
|
cancel: t("panel.plugins.dialog.keep")
|
|
57697
58197
|
};
|
|
57698
58198
|
},
|
|
57699
|
-
onConfirm: () => void remove(name)
|
|
58199
|
+
onConfirm: () => void remove(name, operation)
|
|
57700
58200
|
}), undefined, {
|
|
57701
58201
|
tone: "warning"
|
|
57702
58202
|
});
|
|
57703
58203
|
}
|
|
57704
|
-
async function remove(name) {
|
|
58204
|
+
async function remove(name, operation) {
|
|
57705
58205
|
if (busy())
|
|
57706
58206
|
return;
|
|
57707
58207
|
if (typeof props.seam.removePluginBundle !== "function")
|
|
@@ -57711,7 +58211,7 @@ function PluginsPanel(props) {
|
|
|
57711
58211
|
name
|
|
57712
58212
|
}));
|
|
57713
58213
|
try {
|
|
57714
|
-
const change = await props.seam.removePluginBundle(name);
|
|
58214
|
+
const change = await props.seam.removePluginBundle(name, createPluginWriteConfirm(operation));
|
|
57715
58215
|
flash(pluginChangeNotice(change), 8000);
|
|
57716
58216
|
} catch (error) {
|
|
57717
58217
|
flash(t("panel.plugins.status.changeFailed", {
|
|
@@ -57769,17 +58269,19 @@ function PluginsPanel(props) {
|
|
|
57769
58269
|
return;
|
|
57770
58270
|
}
|
|
57771
58271
|
const accepted = inspection;
|
|
58272
|
+
const operation = "installBundle";
|
|
58273
|
+
const dryRun = t("panel.plugins.dryRun.install", {
|
|
58274
|
+
spec: installPreviewLine(accepted)
|
|
58275
|
+
});
|
|
57772
58276
|
dialog.replace(() => createComponent2(DialogConfirm, {
|
|
57773
58277
|
get title() {
|
|
57774
58278
|
return t("panel.plugins.dialog.installTitle");
|
|
57775
58279
|
},
|
|
57776
58280
|
get message() {
|
|
57777
|
-
return
|
|
57778
|
-
|
|
57779
|
-
|
|
57780
|
-
|
|
57781
|
-
preview: installPreviewLine(accepted)
|
|
57782
|
-
});
|
|
58281
|
+
return `${writeConfirmObject(operation, installPreviewLine(accepted))}
|
|
58282
|
+
` + `${writeConfirmConsequence(operation)}
|
|
58283
|
+
${dryRun}` + (accepted.description ? `
|
|
58284
|
+
${accepted.description}` : "");
|
|
57783
58285
|
},
|
|
57784
58286
|
get label() {
|
|
57785
58287
|
return {
|
|
@@ -57787,31 +58289,108 @@ function PluginsPanel(props) {
|
|
|
57787
58289
|
cancel: t("panel.plugins.dialog.cancel")
|
|
57788
58290
|
};
|
|
57789
58291
|
},
|
|
57790
|
-
onConfirm: () => void install(spec)
|
|
58292
|
+
onConfirm: () => void install(spec, operation)
|
|
57791
58293
|
}), undefined, {
|
|
57792
58294
|
tone: "warning"
|
|
57793
58295
|
});
|
|
57794
58296
|
}
|
|
57795
|
-
async function install(spec) {
|
|
58297
|
+
async function install(spec, operation) {
|
|
57796
58298
|
if (busy())
|
|
57797
58299
|
return;
|
|
57798
58300
|
if (typeof props.seam.installPluginSpec !== "function")
|
|
57799
58301
|
return;
|
|
58302
|
+
const requestId = `ui-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
57800
58303
|
setBusy(true);
|
|
58304
|
+
setInstallProgress({
|
|
58305
|
+
state: "running",
|
|
58306
|
+
requestId
|
|
58307
|
+
});
|
|
58308
|
+
setCancelArmed(true);
|
|
57801
58309
|
flash(t("panel.plugins.status.installing", {
|
|
57802
58310
|
spec
|
|
57803
58311
|
}));
|
|
58312
|
+
const confirm = createPluginWriteConfirm(operation);
|
|
58313
|
+
let terminalLanded = false;
|
|
58314
|
+
let pollStopped = false;
|
|
58315
|
+
const land = (progress) => {
|
|
58316
|
+
if (terminalLanded)
|
|
58317
|
+
return;
|
|
58318
|
+
setInstallProgress(progress);
|
|
58319
|
+
if (progress.state !== "running")
|
|
58320
|
+
terminalLanded = true;
|
|
58321
|
+
};
|
|
58322
|
+
const pollDone = typeof props.seam.waitForInstall === "function" ? pollInstallFace((rid, cf) => props.seam.waitForInstall(rid, cf), requestId, confirm, land, () => pollStopped) : Promise.resolve();
|
|
57804
58323
|
try {
|
|
57805
|
-
const change = await props.seam.installPluginSpec(spec);
|
|
58324
|
+
const change = await props.seam.installPluginSpec(spec, confirm, requestId);
|
|
58325
|
+
await Promise.race([pollDone, new Promise((resolve) => setTimeout(resolve, PROGRESS_SETTLE_GRACE_MS))]);
|
|
58326
|
+
pollStopped = true;
|
|
58327
|
+
land(terminalProgress(change, requestId));
|
|
57806
58328
|
flash(pluginChangeNotice(change), 8000);
|
|
57807
58329
|
} catch (error) {
|
|
58330
|
+
pollStopped = true;
|
|
58331
|
+
land({
|
|
58332
|
+
state: "failed",
|
|
58333
|
+
requestId,
|
|
58334
|
+
target: spec,
|
|
58335
|
+
error: errorMessage2(error)
|
|
58336
|
+
});
|
|
57808
58337
|
flash(t("panel.plugins.status.changeFailed", {
|
|
57809
58338
|
name: spec,
|
|
57810
58339
|
error: errorMessage2(error)
|
|
57811
58340
|
}), 8000);
|
|
57812
58341
|
} finally {
|
|
58342
|
+
pollStopped = true;
|
|
58343
|
+
setCancelArmed(false);
|
|
57813
58344
|
setBusy(false);
|
|
57814
|
-
|
|
58345
|
+
if (progressTimer !== undefined)
|
|
58346
|
+
clearInterval(progressTimer);
|
|
58347
|
+
progressTimer = setInterval(() => {
|
|
58348
|
+
setInstallProgress(undefined);
|
|
58349
|
+
if (progressTimer !== undefined)
|
|
58350
|
+
clearInterval(progressTimer);
|
|
58351
|
+
progressTimer = undefined;
|
|
58352
|
+
}, 6000);
|
|
58353
|
+
}
|
|
58354
|
+
}
|
|
58355
|
+
function terminalProgress(change, requestId) {
|
|
58356
|
+
if (change.application === "cancelled")
|
|
58357
|
+
return {
|
|
58358
|
+
state: "cancelled",
|
|
58359
|
+
requestId,
|
|
58360
|
+
target: change.target
|
|
58361
|
+
};
|
|
58362
|
+
if (change.application === "failed")
|
|
58363
|
+
return {
|
|
58364
|
+
state: "failed",
|
|
58365
|
+
requestId,
|
|
58366
|
+
target: change.target,
|
|
58367
|
+
error: change.error
|
|
58368
|
+
};
|
|
58369
|
+
return {
|
|
58370
|
+
state: "done",
|
|
58371
|
+
requestId,
|
|
58372
|
+
target: change.target
|
|
58373
|
+
};
|
|
58374
|
+
}
|
|
58375
|
+
function cancelActiveInstall() {
|
|
58376
|
+
const progress = installProgress();
|
|
58377
|
+
if (!cancelArmed() || progress === undefined || typeof props.seam.cancelInstall !== "function")
|
|
58378
|
+
return;
|
|
58379
|
+
const requestId = progress.requestId;
|
|
58380
|
+
props.seam.cancelInstall(requestId, createPluginWriteConfirm("cancelInstall")).then((result) => {
|
|
58381
|
+
flash(t("panel.plugins.progress.cancelResult", {
|
|
58382
|
+
status: result.status
|
|
58383
|
+
}), 6000);
|
|
58384
|
+
if (result.status === "cancelled")
|
|
58385
|
+
setInstallProgress({
|
|
58386
|
+
state: "cancelled",
|
|
58387
|
+
requestId,
|
|
58388
|
+
target: requestId
|
|
58389
|
+
});
|
|
58390
|
+
}).catch((error) => flash(t("panel.plugins.status.changeFailed", {
|
|
58391
|
+
name: requestId,
|
|
58392
|
+
error: errorMessage2(error)
|
|
58393
|
+
}), 8000));
|
|
57815
58394
|
}
|
|
57816
58395
|
Keymap2.createLayer(() => ({
|
|
57817
58396
|
mode: "global",
|
|
@@ -57869,6 +58448,12 @@ function PluginsPanel(props) {
|
|
|
57869
58448
|
group: "Plugins",
|
|
57870
58449
|
enabled: () => !filterOpen() && !installOpen(),
|
|
57871
58450
|
run: beginInstall
|
|
58451
|
+
}, {
|
|
58452
|
+
bind: "x",
|
|
58453
|
+
title: t("panel.plugins.keymap.cancelInstall"),
|
|
58454
|
+
group: "Plugins",
|
|
58455
|
+
enabled: () => !filterOpen() && !installOpen() && cancelArmed(),
|
|
58456
|
+
run: cancelActiveInstall
|
|
57872
58457
|
}, {
|
|
57873
58458
|
bind: "up,k",
|
|
57874
58459
|
title: t("panel.plugins.keymap.previous"),
|
|
@@ -57888,8 +58473,10 @@ function PluginsPanel(props) {
|
|
|
57888
58473
|
return open();
|
|
57889
58474
|
},
|
|
57890
58475
|
get children() {
|
|
57891
|
-
var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$4 = createElement("text");
|
|
58476
|
+
var _el$ = createElement("box"), _el$2 = createElement("box"), _el$3 = createElement("text"), _el$4 = createElement("text"), _el$9 = createElement("box"), _el$0 = createElement("text"), _el$1 = createElement("box"), _el$10 = createElement("text");
|
|
57892
58477
|
insertNode(_el$, _el$2);
|
|
58478
|
+
insertNode(_el$, _el$9);
|
|
58479
|
+
insertNode(_el$, _el$1);
|
|
57893
58480
|
setProp(_el$, "flexShrink", 0);
|
|
57894
58481
|
setProp(_el$, "width", "100%");
|
|
57895
58482
|
setProp(_el$, "flexDirection", "column");
|
|
@@ -57908,37 +58495,52 @@ function PluginsPanel(props) {
|
|
|
57908
58495
|
visible: String(visible().length),
|
|
57909
58496
|
total: String(bundles().length)
|
|
57910
58497
|
}));
|
|
58498
|
+
insert(_el$, createComponent2(Show, {
|
|
58499
|
+
get when() {
|
|
58500
|
+
return degraded();
|
|
58501
|
+
},
|
|
58502
|
+
get children() {
|
|
58503
|
+
var _el$5 = createElement("box"), _el$6 = createElement("text");
|
|
58504
|
+
insertNode(_el$5, _el$6);
|
|
58505
|
+
setProp(_el$5, "height", 1);
|
|
58506
|
+
setProp(_el$5, "flexShrink", 0);
|
|
58507
|
+
setProp(_el$6, "wrapMode", "none");
|
|
58508
|
+
insert(_el$6, () => t("panel.plugins.degrade.unavailable"));
|
|
58509
|
+
effect((_$p) => setProp(_el$6, "fg", warningColor(theme ?? undefined), _$p));
|
|
58510
|
+
return _el$5;
|
|
58511
|
+
}
|
|
58512
|
+
}), _el$9);
|
|
57911
58513
|
insert(_el$, createComponent2(Show, {
|
|
57912
58514
|
get when() {
|
|
57913
58515
|
return !installOpen();
|
|
57914
58516
|
},
|
|
57915
58517
|
get fallback() {
|
|
57916
58518
|
return (() => {
|
|
57917
|
-
var _el$
|
|
57918
|
-
insertNode(_el$
|
|
57919
|
-
setProp(_el$
|
|
57920
|
-
setProp(_el$
|
|
57921
|
-
setProp(_el$
|
|
58519
|
+
var _el$15 = createElement("box"), _el$16 = createElement("input");
|
|
58520
|
+
insertNode(_el$15, _el$16);
|
|
58521
|
+
setProp(_el$15, "height", 1);
|
|
58522
|
+
setProp(_el$15, "flexShrink", 0);
|
|
58523
|
+
setProp(_el$15, "flexDirection", "row");
|
|
57922
58524
|
use((renderable) => {
|
|
57923
58525
|
setTimeout(() => {
|
|
57924
58526
|
if (!renderable.isDestroyed)
|
|
57925
58527
|
renderable.focus();
|
|
57926
58528
|
}, 1);
|
|
57927
|
-
}, _el$
|
|
57928
|
-
setProp(_el$
|
|
57929
|
-
setProp(_el$
|
|
58529
|
+
}, _el$16);
|
|
58530
|
+
setProp(_el$16, "flexGrow", 1);
|
|
58531
|
+
setProp(_el$16, "onInput", (value) => setInstallText(value));
|
|
57930
58532
|
effect((_p$) => {
|
|
57931
|
-
var _v$
|
|
57932
|
-
_v$
|
|
57933
|
-
_v$
|
|
57934
|
-
_v$
|
|
58533
|
+
var _v$11 = t("panel.plugins.placeholder.install"), _v$12 = theme?.text.muted ?? "#565f89", _v$13 = installText();
|
|
58534
|
+
_v$11 !== _p$.e && (_p$.e = setProp(_el$16, "placeholder", _v$11, _p$.e));
|
|
58535
|
+
_v$12 !== _p$.t && (_p$.t = setProp(_el$16, "placeholderColor", _v$12, _p$.t));
|
|
58536
|
+
_v$13 !== _p$.a && (_p$.a = setProp(_el$16, "value", _v$13, _p$.a));
|
|
57935
58537
|
return _p$;
|
|
57936
58538
|
}, {
|
|
57937
58539
|
e: undefined,
|
|
57938
58540
|
t: undefined,
|
|
57939
58541
|
a: undefined
|
|
57940
58542
|
});
|
|
57941
|
-
return _el$
|
|
58543
|
+
return _el$15;
|
|
57942
58544
|
})();
|
|
57943
58545
|
},
|
|
57944
58546
|
get children() {
|
|
@@ -57948,63 +58550,63 @@ function PluginsPanel(props) {
|
|
|
57948
58550
|
},
|
|
57949
58551
|
get fallback() {
|
|
57950
58552
|
return (() => {
|
|
57951
|
-
var _el$
|
|
57952
|
-
insertNode(_el$
|
|
57953
|
-
setProp(_el$
|
|
57954
|
-
setProp(_el$
|
|
57955
|
-
setProp(_el$
|
|
57956
|
-
insert(_el$
|
|
57957
|
-
effect((_$p) => setProp(_el$
|
|
57958
|
-
return _el$
|
|
58553
|
+
var _el$17 = createElement("box"), _el$18 = createElement("text");
|
|
58554
|
+
insertNode(_el$17, _el$18);
|
|
58555
|
+
setProp(_el$17, "height", 1);
|
|
58556
|
+
setProp(_el$17, "flexShrink", 0);
|
|
58557
|
+
setProp(_el$18, "wrapMode", "none");
|
|
58558
|
+
insert(_el$18, () => `${t("panel.plugins.header.bundleColumn").padEnd(36)}${t("panel.plugins.header.stateColumn")}`);
|
|
58559
|
+
effect((_$p) => setProp(_el$18, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
58560
|
+
return _el$17;
|
|
57959
58561
|
})();
|
|
57960
58562
|
},
|
|
57961
58563
|
get children() {
|
|
57962
|
-
var _el$
|
|
57963
|
-
insertNode(_el$
|
|
57964
|
-
setProp(_el$
|
|
57965
|
-
setProp(_el$
|
|
57966
|
-
setProp(_el$
|
|
58564
|
+
var _el$7 = createElement("box"), _el$8 = createElement("input");
|
|
58565
|
+
insertNode(_el$7, _el$8);
|
|
58566
|
+
setProp(_el$7, "height", 1);
|
|
58567
|
+
setProp(_el$7, "flexShrink", 0);
|
|
58568
|
+
setProp(_el$7, "flexDirection", "row");
|
|
57967
58569
|
use((renderable) => {
|
|
57968
58570
|
setTimeout(() => {
|
|
57969
58571
|
if (!renderable.isDestroyed)
|
|
57970
58572
|
renderable.focus();
|
|
57971
58573
|
}, 1);
|
|
57972
|
-
}, _el$
|
|
57973
|
-
setProp(_el$
|
|
57974
|
-
setProp(_el$
|
|
58574
|
+
}, _el$8);
|
|
58575
|
+
setProp(_el$8, "flexGrow", 1);
|
|
58576
|
+
setProp(_el$8, "onInput", (value) => setFilter(value));
|
|
57975
58577
|
effect((_p$) => {
|
|
57976
58578
|
var _v$ = t("panel.plugins.placeholder.filter"), _v$2 = theme?.text.muted ?? "#565f89", _v$3 = filter();
|
|
57977
|
-
_v$ !== _p$.e && (_p$.e = setProp(_el$
|
|
57978
|
-
_v$2 !== _p$.t && (_p$.t = setProp(_el$
|
|
57979
|
-
_v$3 !== _p$.a && (_p$.a = setProp(_el$
|
|
58579
|
+
_v$ !== _p$.e && (_p$.e = setProp(_el$8, "placeholder", _v$, _p$.e));
|
|
58580
|
+
_v$2 !== _p$.t && (_p$.t = setProp(_el$8, "placeholderColor", _v$2, _p$.t));
|
|
58581
|
+
_v$3 !== _p$.a && (_p$.a = setProp(_el$8, "value", _v$3, _p$.a));
|
|
57980
58582
|
return _p$;
|
|
57981
58583
|
}, {
|
|
57982
58584
|
e: undefined,
|
|
57983
58585
|
t: undefined,
|
|
57984
58586
|
a: undefined
|
|
57985
58587
|
});
|
|
57986
|
-
return _el$
|
|
58588
|
+
return _el$7;
|
|
57987
58589
|
}
|
|
57988
58590
|
});
|
|
57989
58591
|
}
|
|
57990
|
-
}),
|
|
58592
|
+
}), _el$9);
|
|
57991
58593
|
insert(_el$, createComponent2(Show, {
|
|
57992
58594
|
get when() {
|
|
57993
58595
|
return visible().length > 0;
|
|
57994
58596
|
},
|
|
57995
58597
|
get fallback() {
|
|
57996
58598
|
return (() => {
|
|
57997
|
-
var _el$
|
|
57998
|
-
insertNode(_el$
|
|
57999
|
-
setProp(_el$
|
|
58000
|
-
setProp(_el$
|
|
58001
|
-
setProp(_el$
|
|
58002
|
-
insert(_el$
|
|
58003
|
-
var _c$ = memo2(() => bundles().length === 0);
|
|
58004
|
-
return () => _c$() ? t("panel.plugins.empty.noPlugins") : t("panel.plugins.empty.noMatch");
|
|
58599
|
+
var _el$19 = createElement("box"), _el$20 = createElement("text");
|
|
58600
|
+
insertNode(_el$19, _el$20);
|
|
58601
|
+
setProp(_el$19, "height", 1);
|
|
58602
|
+
setProp(_el$19, "flexShrink", 0);
|
|
58603
|
+
setProp(_el$20, "wrapMode", "none");
|
|
58604
|
+
insert(_el$20, (() => {
|
|
58605
|
+
var _c$4 = memo2(() => bundles().length === 0);
|
|
58606
|
+
return () => _c$4() ? t("panel.plugins.empty.noPlugins") : t("panel.plugins.empty.noMatch");
|
|
58005
58607
|
})());
|
|
58006
|
-
effect((_$p) => setProp(_el$
|
|
58007
|
-
return _el$
|
|
58608
|
+
effect((_$p) => setProp(_el$20, "fg", theme?.text.muted ?? "#565f89", _$p));
|
|
58609
|
+
return _el$19;
|
|
58008
58610
|
})();
|
|
58009
58611
|
},
|
|
58010
58612
|
get children() {
|
|
@@ -58013,53 +58615,92 @@ function PluginsPanel(props) {
|
|
|
58013
58615
|
return visible().slice(0, 12);
|
|
58014
58616
|
},
|
|
58015
58617
|
children: (row, index) => (() => {
|
|
58016
|
-
var _el$
|
|
58017
|
-
insertNode(_el$
|
|
58018
|
-
insertNode(_el$
|
|
58019
|
-
setProp(_el$
|
|
58020
|
-
setProp(_el$
|
|
58021
|
-
setProp(_el$
|
|
58022
|
-
setProp(_el$
|
|
58023
|
-
insert(_el$
|
|
58024
|
-
setProp(_el$
|
|
58025
|
-
insert(_el$
|
|
58618
|
+
var _el$21 = createElement("box"), _el$22 = createElement("text"), _el$23 = createElement("text");
|
|
58619
|
+
insertNode(_el$21, _el$22);
|
|
58620
|
+
insertNode(_el$21, _el$23);
|
|
58621
|
+
setProp(_el$21, "height", 1);
|
|
58622
|
+
setProp(_el$21, "flexShrink", 0);
|
|
58623
|
+
setProp(_el$21, "flexDirection", "row");
|
|
58624
|
+
setProp(_el$22, "wrapMode", "none");
|
|
58625
|
+
insert(_el$22, () => `${index() === cursorIndex() ? "\u203A " : " "}${formatPluginLine(row).padEnd(34)}`);
|
|
58626
|
+
setProp(_el$23, "wrapMode", "none");
|
|
58627
|
+
insert(_el$23, () => bundleStateText(row));
|
|
58026
58628
|
effect((_p$) => {
|
|
58027
|
-
var _v$
|
|
58028
|
-
_v$
|
|
58029
|
-
_v$
|
|
58629
|
+
var _v$14 = index() === cursorIndex() ? theme?.text.base ?? "#e6e6e6" : theme?.text.muted ?? "#565f89", _v$15 = row.enabled ? successColor(theme ?? undefined) : theme?.text.muted ?? "#565f89";
|
|
58630
|
+
_v$14 !== _p$.e && (_p$.e = setProp(_el$22, "fg", _v$14, _p$.e));
|
|
58631
|
+
_v$15 !== _p$.t && (_p$.t = setProp(_el$23, "fg", _v$15, _p$.t));
|
|
58030
58632
|
return _p$;
|
|
58031
58633
|
}, {
|
|
58032
58634
|
e: undefined,
|
|
58033
58635
|
t: undefined
|
|
58034
58636
|
});
|
|
58035
|
-
return _el$
|
|
58637
|
+
return _el$21;
|
|
58036
58638
|
})()
|
|
58037
58639
|
});
|
|
58038
58640
|
}
|
|
58641
|
+
}), _el$9);
|
|
58642
|
+
insertNode(_el$9, _el$0);
|
|
58643
|
+
setProp(_el$9, "height", 1);
|
|
58644
|
+
setProp(_el$9, "flexShrink", 0);
|
|
58645
|
+
setProp(_el$0, "wrapMode", "none");
|
|
58646
|
+
insert(_el$0, (() => {
|
|
58647
|
+
var _c$ = memo2(() => detail() !== undefined);
|
|
58648
|
+
return () => _c$() ? t("panel.plugins.detail.title", {
|
|
58649
|
+
name: current()?.name ?? ""
|
|
58650
|
+
}) : "";
|
|
58651
|
+
})());
|
|
58652
|
+
insertNode(_el$1, _el$10);
|
|
58653
|
+
setProp(_el$1, "height", 1);
|
|
58654
|
+
setProp(_el$1, "flexShrink", 0);
|
|
58655
|
+
setProp(_el$10, "wrapMode", "none");
|
|
58656
|
+
insert(_el$10, (() => {
|
|
58657
|
+
var _c$2 = memo2(() => detail() !== undefined);
|
|
58658
|
+
return () => _c$2() ? pluginDetailPreview(detail(), detailLoading()) : "";
|
|
58659
|
+
})());
|
|
58660
|
+
insert(_el$, createComponent2(Show, {
|
|
58661
|
+
get when() {
|
|
58662
|
+
return installProgress() !== undefined;
|
|
58663
|
+
},
|
|
58664
|
+
get children() {
|
|
58665
|
+
var _el$11 = createElement("box"), _el$12 = createElement("text");
|
|
58666
|
+
insertNode(_el$11, _el$12);
|
|
58667
|
+
setProp(_el$11, "height", 1);
|
|
58668
|
+
setProp(_el$11, "flexShrink", 0);
|
|
58669
|
+
setProp(_el$12, "wrapMode", "none");
|
|
58670
|
+
insert(_el$12, (() => {
|
|
58671
|
+
var _c$3 = memo2(() => installProgress() !== undefined);
|
|
58672
|
+
return () => _c$3() ? installProgressLine(installProgress()) : "";
|
|
58673
|
+
})());
|
|
58674
|
+
effect((_$p) => setProp(_el$12, "fg", warningColor(theme ?? undefined), _$p));
|
|
58675
|
+
return _el$11;
|
|
58676
|
+
}
|
|
58039
58677
|
}), null);
|
|
58040
58678
|
insert(_el$, createComponent2(Show, {
|
|
58041
58679
|
get when() {
|
|
58042
58680
|
return status() !== undefined;
|
|
58043
58681
|
},
|
|
58044
58682
|
get children() {
|
|
58045
|
-
var _el$
|
|
58046
|
-
insertNode(_el$
|
|
58047
|
-
setProp(_el$
|
|
58048
|
-
setProp(_el$
|
|
58049
|
-
setProp(_el$
|
|
58050
|
-
insert(_el$
|
|
58051
|
-
effect((_$p) => setProp(_el$
|
|
58052
|
-
return _el$
|
|
58683
|
+
var _el$13 = createElement("box"), _el$14 = createElement("text");
|
|
58684
|
+
insertNode(_el$13, _el$14);
|
|
58685
|
+
setProp(_el$13, "height", 1);
|
|
58686
|
+
setProp(_el$13, "flexShrink", 0);
|
|
58687
|
+
setProp(_el$14, "wrapMode", "none");
|
|
58688
|
+
insert(_el$14, status);
|
|
58689
|
+
effect((_$p) => setProp(_el$14, "fg", warningColor(theme ?? undefined), _$p));
|
|
58690
|
+
return _el$13;
|
|
58053
58691
|
}
|
|
58054
58692
|
}), null);
|
|
58055
58693
|
effect((_p$) => {
|
|
58056
|
-
var _v$4 = 1 + 1 + Math.min(visible().length || 1, 12) + (status() !== undefined ? 1 : 0) + 1, _v$5 = theme?.border.base ?? "#7aa2f7", _v$6 = theme?.background.raised.base ?? "#1a1b26", _v$7 = theme?.text.base ?? "#e6e6e6", _v$8 = TextAttributes10.BOLD, _v$9 = theme?.text.muted ?? "#565f89";
|
|
58694
|
+
var _v$4 = 1 + 1 + (degraded() ? 1 : 0) + Math.min(visible().length || 1, 12) + 2 + (installProgress() !== undefined ? 1 : 0) + (status() !== undefined ? 1 : 0) + 1, _v$5 = theme?.border.base ?? "#7aa2f7", _v$6 = theme?.background.raised.base ?? "#1a1b26", _v$7 = theme?.text.base ?? "#e6e6e6", _v$8 = TextAttributes10.BOLD, _v$9 = theme?.text.muted ?? "#565f89", _v$0 = theme?.text.base ?? "#e6e6e6", _v$1 = TextAttributes10.BOLD, _v$10 = theme?.text.muted ?? "#565f89";
|
|
58057
58695
|
_v$4 !== _p$.e && (_p$.e = setProp(_el$, "height", _v$4, _p$.e));
|
|
58058
58696
|
_v$5 !== _p$.t && (_p$.t = setProp(_el$, "borderColor", _v$5, _p$.t));
|
|
58059
58697
|
_v$6 !== _p$.a && (_p$.a = setProp(_el$, "backgroundColor", _v$6, _p$.a));
|
|
58060
58698
|
_v$7 !== _p$.o && (_p$.o = setProp(_el$3, "fg", _v$7, _p$.o));
|
|
58061
58699
|
_v$8 !== _p$.i && (_p$.i = setProp(_el$3, "attributes", _v$8, _p$.i));
|
|
58062
58700
|
_v$9 !== _p$.n && (_p$.n = setProp(_el$4, "fg", _v$9, _p$.n));
|
|
58701
|
+
_v$0 !== _p$.s && (_p$.s = setProp(_el$0, "fg", _v$0, _p$.s));
|
|
58702
|
+
_v$1 !== _p$.h && (_p$.h = setProp(_el$0, "attributes", _v$1, _p$.h));
|
|
58703
|
+
_v$10 !== _p$.r && (_p$.r = setProp(_el$10, "fg", _v$10, _p$.r));
|
|
58063
58704
|
return _p$;
|
|
58064
58705
|
}, {
|
|
58065
58706
|
e: undefined,
|
|
@@ -58067,13 +58708,16 @@ function PluginsPanel(props) {
|
|
|
58067
58708
|
a: undefined,
|
|
58068
58709
|
o: undefined,
|
|
58069
58710
|
i: undefined,
|
|
58070
|
-
n: undefined
|
|
58711
|
+
n: undefined,
|
|
58712
|
+
s: undefined,
|
|
58713
|
+
h: undefined,
|
|
58714
|
+
r: undefined
|
|
58071
58715
|
});
|
|
58072
58716
|
return _el$;
|
|
58073
58717
|
}
|
|
58074
58718
|
});
|
|
58075
58719
|
}
|
|
58076
|
-
var bridgeOpen3, setBridgeOpen3, panelOpen4, setPanelOpen4, pluginsPanelOpen;
|
|
58720
|
+
var bridgeOpen3, setBridgeOpen3, panelOpen4, setPanelOpen4, pluginsPanelOpen, PROGRESS_POLL_INTERVAL_MS = 250, PROGRESS_POLL_MAX_TICKS = 120, PROGRESS_SETTLE_GRACE_MS = 80;
|
|
58077
58721
|
var init_plugins_panel = __esm(() => {
|
|
58078
58722
|
init_index_bun();
|
|
58079
58723
|
init_index_bun();
|
|
@@ -62222,6 +62866,7 @@ function AgentsPanel(props) {
|
|
|
62222
62866
|
const ownTop = layers().at(-1)?.handle;
|
|
62223
62867
|
return {
|
|
62224
62868
|
mode: "global",
|
|
62869
|
+
capture: "overlay",
|
|
62225
62870
|
enabled: open() && ownTop?.ownsInput() === true,
|
|
62226
62871
|
priority: 2,
|
|
62227
62872
|
commands: [
|
|
@@ -64029,7 +64674,7 @@ var init_subagents_viewer = __esm(() => {
|
|
|
64029
64674
|
import { TextAttributes as TextAttributes12 } from "@opentui/core";
|
|
64030
64675
|
function resolveVersion() {
|
|
64031
64676
|
try {
|
|
64032
|
-
return "0.
|
|
64677
|
+
return "0.25.0";
|
|
64033
64678
|
} catch {
|
|
64034
64679
|
return "dev";
|
|
64035
64680
|
}
|
|
@@ -65391,6 +66036,18 @@ var init_settings_modal = __esm(() => {
|
|
|
65391
66036
|
});
|
|
65392
66037
|
|
|
65393
66038
|
// ../tui-base/src/routes/session/btw-overlay.tsx
|
|
66039
|
+
function btwDegradeText(code) {
|
|
66040
|
+
if (code === "UNSUPPORTED" || code === "SIDE_SESSION_UNAVAILABLE")
|
|
66041
|
+
return `error: ${t("command.btw.noModel")}`;
|
|
66042
|
+
if (code === "SIDE_SESSION_NO_ANSWER")
|
|
66043
|
+
return `error: ${t("command.btw.noAnswer")}`;
|
|
66044
|
+
if (code === "SIDE_SESSION_BUSY")
|
|
66045
|
+
return `error: ${t("command.btw.busy")}`;
|
|
66046
|
+
if (code === "SIDE_SESSION_FAILED" || code === "SIDE_SESSION_PROMPT_REJECTED")
|
|
66047
|
+
return `error: ${t("command.btw.failed")}`;
|
|
66048
|
+
return;
|
|
66049
|
+
}
|
|
66050
|
+
|
|
65394
66051
|
class BtwController {
|
|
65395
66052
|
#ask;
|
|
65396
66053
|
#snapshot;
|
|
@@ -65457,7 +66114,9 @@ class BtwController {
|
|
|
65457
66114
|
})).then((answer) => {
|
|
65458
66115
|
this.#settle(answer.startsWith("error:") ? "error" : "settled", answer);
|
|
65459
66116
|
}).catch((error) => {
|
|
65460
|
-
|
|
66117
|
+
const code = error !== null && typeof error === "object" ? error.code : undefined;
|
|
66118
|
+
const degrade = btwDegradeText(code);
|
|
66119
|
+
this.#settle("error", degrade ?? `error: ${error instanceof Error ? error.message : String(error)}`);
|
|
65461
66120
|
});
|
|
65462
66121
|
}
|
|
65463
66122
|
#settle(status, answer) {
|
|
@@ -65782,6 +66441,7 @@ function createTuiPanelKeymapHost(keymap) {
|
|
|
65782
66441
|
return Keymap2.createLayer(() => {
|
|
65783
66442
|
const layer = input();
|
|
65784
66443
|
return {
|
|
66444
|
+
capture: "overlay",
|
|
65785
66445
|
...layer.mode === undefined ? {} : {
|
|
65786
66446
|
mode: layer.mode
|
|
65787
66447
|
},
|
|
@@ -65880,440 +66540,15 @@ var init_jsx_dev_runtime = __esm(() => {
|
|
|
65880
66540
|
init_jsx_runtime();
|
|
65881
66541
|
});
|
|
65882
66542
|
|
|
65883
|
-
// src/client/
|
|
65884
|
-
|
|
65885
|
-
|
|
65886
|
-
|
|
65887
|
-
|
|
65888
|
-
projectJournalRecord: () => projectJournalRecord
|
|
65889
|
-
});
|
|
65890
|
-
|
|
65891
|
-
class RemoteSessionSeam {
|
|
65892
|
-
#session;
|
|
65893
|
-
#listeners = [];
|
|
65894
|
-
#turnInFlight = false;
|
|
65895
|
-
#unjournal;
|
|
65896
|
-
#pluginsRevision = createSignal(0);
|
|
65897
|
-
#unplugins;
|
|
65898
|
-
#pluginsPushListeners = [];
|
|
65899
|
-
constructor(session) {
|
|
65900
|
-
this.#session = session;
|
|
65901
|
-
registerSubagentSteer((id, text) => this.#session.steerChild(id, text));
|
|
65902
|
-
this.#unplugins = session.onPluginsChanged?.(() => {
|
|
65903
|
-
this.#pluginsRevision[1]((n) => n + 1);
|
|
65904
|
-
for (const listener of this.#pluginsPushListeners) {
|
|
65905
|
-
try {
|
|
65906
|
-
listener();
|
|
65907
|
-
} catch {}
|
|
65908
|
-
}
|
|
65909
|
-
}) ?? undefined;
|
|
65910
|
-
}
|
|
65911
|
-
status() {
|
|
65912
|
-
const s = this.#session.status;
|
|
65913
|
-
return { connection: s.connection, turn: s.turn, sessionAttached: s.sessionAttached };
|
|
65914
|
-
}
|
|
65915
|
-
async listSessions(limit) {
|
|
65916
|
-
const rows = await this.#session.listSessions(limit);
|
|
65917
|
-
return rows.map((row) => ({
|
|
65918
|
-
id: row.id,
|
|
65919
|
-
title: row.title,
|
|
65920
|
-
...row.updatedAt !== undefined ? { updatedAt: row.updatedAt } : {},
|
|
65921
|
-
...row.cwd !== undefined ? { cwd: row.cwd } : {},
|
|
65922
|
-
...row.sizeBytes !== undefined ? { sizeBytes: row.sizeBytes } : {},
|
|
65923
|
-
...row.blank !== undefined ? { blank: row.blank } : {}
|
|
65924
|
-
}));
|
|
65925
|
-
}
|
|
65926
|
-
async searchSessions(query) {
|
|
65927
|
-
return this.#session.searchSessions(query);
|
|
65928
|
-
}
|
|
65929
|
-
async sessionJournal(sessionId) {
|
|
65930
|
-
return this.#session.sessionJournal(sessionId);
|
|
65931
|
-
}
|
|
65932
|
-
async forkSession(sessionId, seqEnd) {
|
|
65933
|
-
return this.#session.forkSession(sessionId, seqEnd);
|
|
65934
|
-
}
|
|
65935
|
-
async storedTranscript(id, skip) {
|
|
65936
|
-
const rows = await this.#session.storedTranscript(id, skip);
|
|
65937
|
-
return rows.map((row) => {
|
|
65938
|
-
if (row.kind === "ask") {
|
|
65939
|
-
return { kind: row.kind, text: "", final: true, entries: row.entries };
|
|
65940
|
-
}
|
|
65941
|
-
if (row.kind === "tool") {
|
|
65942
|
-
return { kind: "tool", text: row.name, final: true, args: row.args, output: row.brief, ok: row.ok };
|
|
65943
|
-
}
|
|
65944
|
-
return {
|
|
65945
|
-
kind: row.kind,
|
|
65946
|
-
text: row.text,
|
|
65947
|
-
final: row.kind === "assistant" ? row.final ?? true : true
|
|
65948
|
-
};
|
|
65949
|
-
});
|
|
65950
|
-
}
|
|
65951
|
-
currentSessionId() {
|
|
65952
|
-
return this.#session.currentSessionId();
|
|
65953
|
-
}
|
|
65954
|
-
stagedSessionId() {
|
|
65955
|
-
return this.#session.stagedSessionId();
|
|
65956
|
-
}
|
|
65957
|
-
cacheHitRate(mode) {
|
|
65958
|
-
return this.#session.cacheHitRate(mode);
|
|
65959
|
-
}
|
|
65960
|
-
contextTokens() {
|
|
65961
|
-
return this.#session.contextTokens();
|
|
65962
|
-
}
|
|
65963
|
-
contextWindow() {
|
|
65964
|
-
return this.#session.contextWindow() ?? null;
|
|
65965
|
-
}
|
|
65966
|
-
configLoad() {
|
|
65967
|
-
return this.#session.configLoad();
|
|
65968
|
-
}
|
|
65969
|
-
configSave(patch) {
|
|
65970
|
-
return this.#session.configSave(patch);
|
|
65971
|
-
}
|
|
65972
|
-
configRaw() {
|
|
65973
|
-
return this.#session.configRaw();
|
|
65974
|
-
}
|
|
65975
|
-
workspaceConfig() {
|
|
65976
|
-
return this.#session.workspaceConfig();
|
|
65977
|
-
}
|
|
65978
|
-
async sessionInfo() {
|
|
65979
|
-
const base = this.#session.sessionInfo();
|
|
65980
|
-
const sessionId = base.sessionId ?? this.#session.stagedSessionId?.();
|
|
65981
|
-
if (sessionId === undefined)
|
|
65982
|
-
return;
|
|
65983
|
-
let messageCount = 0;
|
|
65984
|
-
let turnCount = 0;
|
|
65985
|
-
try {
|
|
65986
|
-
const rows = await this.#session.storedTranscript(sessionId);
|
|
65987
|
-
messageCount = rows.filter((row) => row.kind === "user" || row.kind === "assistant").length;
|
|
65988
|
-
turnCount = rows.filter((row) => row.kind === "user").length;
|
|
65989
|
-
} catch {}
|
|
65990
|
-
const msgCount = base.sessionId === undefined ? undefined : base.msgCount;
|
|
65991
|
-
return {
|
|
65992
|
-
...base,
|
|
65993
|
-
sessionId,
|
|
65994
|
-
model: base.model ?? null,
|
|
65995
|
-
messageCount,
|
|
65996
|
-
turnCount,
|
|
65997
|
-
msgCount,
|
|
65998
|
-
contextTokens: base.contextTokens,
|
|
65999
|
-
contextWindow: base.contextWindow ?? null
|
|
66000
|
-
};
|
|
66001
|
-
}
|
|
66002
|
-
resumeSession(id) {
|
|
66003
|
-
return this.#session.resumeSession(id);
|
|
66004
|
-
}
|
|
66005
|
-
repairScanBroken() {
|
|
66006
|
-
return this.#session.repairScanBroken();
|
|
66007
|
-
}
|
|
66008
|
-
repairSessionLog(path) {
|
|
66009
|
-
return this.#session.repairSessionLog(path);
|
|
66010
|
-
}
|
|
66011
|
-
newSession() {
|
|
66012
|
-
this.#session.newSession();
|
|
66013
|
-
}
|
|
66014
|
-
async renameSession(title) {
|
|
66015
|
-
return this.#session.renameSession(title);
|
|
66016
|
-
}
|
|
66017
|
-
async turn(userText, cb) {
|
|
66018
|
-
this.#turnInFlight = true;
|
|
66019
|
-
try {
|
|
66020
|
-
await this.#session.turn(userText, {
|
|
66021
|
-
onThinkingDelta: (text) => cb.onThinkingDelta(text),
|
|
66022
|
-
onContentDelta: (text) => cb.onContentDelta(text),
|
|
66023
|
-
onTurnEnd: () => {},
|
|
66024
|
-
onApprove: async (name, args) => await cb.onApprove(name, args) === "allowed-once",
|
|
66025
|
-
onToolStart: (start) => cb.onToolStart?.(start),
|
|
66026
|
-
onToolRun: (run) => cb.onToolRun?.(run),
|
|
66027
|
-
onError: (message) => cb.onError(message)
|
|
66028
|
-
});
|
|
66029
|
-
} finally {
|
|
66030
|
-
this.#turnInFlight = false;
|
|
66031
|
-
}
|
|
66032
|
-
}
|
|
66033
|
-
steer(text) {
|
|
66034
|
-
this.#session.steer(text);
|
|
66035
|
-
}
|
|
66036
|
-
interrupt() {
|
|
66037
|
-
this.#session.abort();
|
|
66038
|
-
}
|
|
66039
|
-
registerAskProvider(onAsk) {
|
|
66040
|
-
this.#session.registerAskProvider(async (questions) => onAsk(questions));
|
|
66041
|
-
}
|
|
66042
|
-
async listProviders() {
|
|
66043
|
-
return this.#session.listProviders();
|
|
66044
|
-
}
|
|
66045
|
-
async modelCatalog(force) {
|
|
66046
|
-
const catalog = await this.#session.modelCatalog(force ?? false);
|
|
66047
|
-
const rows = [];
|
|
66048
|
-
for (const group of Array.isArray(catalog.groups) ? catalog.groups : []) {
|
|
66049
|
-
const providerID = String(group?.id ?? "");
|
|
66050
|
-
if (!providerID)
|
|
66051
|
-
continue;
|
|
66052
|
-
for (const model of Array.isArray(group.models) ? group.models : []) {
|
|
66053
|
-
const modelID = String(model?.id ?? "");
|
|
66054
|
-
if (modelID)
|
|
66055
|
-
rows.push({ providerID, modelID });
|
|
66056
|
-
}
|
|
66057
|
-
}
|
|
66058
|
-
return rows;
|
|
66059
|
-
}
|
|
66060
|
-
async currentModelSelection() {
|
|
66061
|
-
const selection = await this.#session.currentModelSelection();
|
|
66062
|
-
if (!selection)
|
|
66063
|
-
return;
|
|
66064
|
-
return { providerID: selection.provider, modelID: selection.model };
|
|
66065
|
-
}
|
|
66066
|
-
selectModel(providerID, modelID) {
|
|
66067
|
-
return this.#session.selectModel({ provider: providerID, model: modelID }).then(() => {
|
|
66068
|
-
return;
|
|
66069
|
-
});
|
|
66070
|
-
}
|
|
66071
|
-
lastSelectionError() {
|
|
66072
|
-
return this.#session.lastSelectionError();
|
|
66073
|
-
}
|
|
66074
|
-
thinking = {
|
|
66075
|
-
efforts: async () => {
|
|
66076
|
-
try {
|
|
66077
|
-
const selection = await this.#session.currentModelSelection();
|
|
66078
|
-
if (!selection)
|
|
66079
|
-
return [];
|
|
66080
|
-
const catalog = await this.#session.modelCatalog(false);
|
|
66081
|
-
const group = Array.isArray(catalog.groups) ? catalog.groups.find((g) => String(g?.id ?? "") === selection.provider) : undefined;
|
|
66082
|
-
const model = Array.isArray(group?.models) ? group.models.find((m) => String(m?.id ?? "") === selection.model) : undefined;
|
|
66083
|
-
const efforts = model?.reasoning?.efforts;
|
|
66084
|
-
if (!Array.isArray(efforts) || efforts.length === 0)
|
|
66085
|
-
return [];
|
|
66086
|
-
return efforts.map((e) => ({
|
|
66087
|
-
id: String(typeof e === "object" && e !== null ? e?.id ?? "" : e ?? ""),
|
|
66088
|
-
name: String(typeof e === "object" && e !== null ? e?.name ?? e?.id ?? "" : e ?? ""),
|
|
66089
|
-
...typeof e === "object" && e !== null && typeof e?.description === "string" && e.description ? { description: e.description } : {}
|
|
66090
|
-
})).filter((e) => e.id);
|
|
66091
|
-
} catch {
|
|
66092
|
-
return [];
|
|
66093
|
-
}
|
|
66094
|
-
},
|
|
66095
|
-
effortsFor: (providerID, modelID) => this.#session.modelEfforts(providerID, modelID),
|
|
66096
|
-
currentEffort: async () => {
|
|
66097
|
-
const selection = await this.#session.currentModelSelection();
|
|
66098
|
-
return selection?.reasoningEffort;
|
|
66099
|
-
},
|
|
66100
|
-
selectEffort: (effort) => {
|
|
66101
|
-
return this.#session.currentModelSelection().then((selection) => {
|
|
66102
|
-
if (!selection)
|
|
66103
|
-
return;
|
|
66104
|
-
return this.#session.selectModel({
|
|
66105
|
-
provider: selection.provider,
|
|
66106
|
-
model: selection.model,
|
|
66107
|
-
...effort ? { reasoningEffort: effort } : {}
|
|
66108
|
-
});
|
|
66109
|
-
}).then(() => {
|
|
66110
|
-
return;
|
|
66111
|
-
});
|
|
66112
|
-
}
|
|
66113
|
-
};
|
|
66114
|
-
usageSummary() {
|
|
66115
|
-
return this.#session.usageSummary();
|
|
66116
|
-
}
|
|
66117
|
-
btwAsk(question, snapshot, onDelta) {
|
|
66118
|
-
return this.#session.btwAsk(question, snapshot, onDelta);
|
|
66119
|
-
}
|
|
66120
|
-
plugins() {
|
|
66121
|
-
this.#pluginsRevision[0]();
|
|
66122
|
-
return this.#session.listPlugins();
|
|
66123
|
-
}
|
|
66124
|
-
onPluginsChanged(listener) {
|
|
66125
|
-
this.#pluginsPushListeners.push(listener);
|
|
66126
|
-
return () => {
|
|
66127
|
-
const index = this.#pluginsPushListeners.indexOf(listener);
|
|
66128
|
-
if (index >= 0)
|
|
66129
|
-
this.#pluginsPushListeners.splice(index, 1);
|
|
66130
|
-
};
|
|
66131
|
-
}
|
|
66132
|
-
pluginBundles() {
|
|
66133
|
-
this.#pluginsRevision[0]();
|
|
66134
|
-
return this.#session.listBundles();
|
|
66135
|
-
}
|
|
66136
|
-
setPluginBundleEnabled(name, enabled) {
|
|
66137
|
-
return this.#session.setBundleEnabled(name, enabled);
|
|
66138
|
-
}
|
|
66139
|
-
removePluginBundle(name) {
|
|
66140
|
-
return this.#session.removeBundle(name);
|
|
66141
|
-
}
|
|
66142
|
-
inspectPluginSpec(spec) {
|
|
66143
|
-
return this.#session.inspectBundle(spec);
|
|
66144
|
-
}
|
|
66145
|
-
installPluginSpec(spec) {
|
|
66146
|
-
return this.#session.installBundle(spec);
|
|
66147
|
-
}
|
|
66148
|
-
async refreshSkills() {
|
|
66149
|
-
return this.#session.refreshSkills();
|
|
66150
|
-
}
|
|
66151
|
-
onSkillsChanged(listener) {
|
|
66152
|
-
return this.#session.onSkillsChanged(listener);
|
|
66153
|
-
}
|
|
66154
|
-
preset = {
|
|
66155
|
-
list: () => this.#session.listPresets(),
|
|
66156
|
-
currentId: async () => this.#session.resolveCurrentPresetId(),
|
|
66157
|
-
select: async (presetId) => {
|
|
66158
|
-
try {
|
|
66159
|
-
this.#session.switchPreset(presetId);
|
|
66160
|
-
return true;
|
|
66161
|
-
} catch (error) {
|
|
66162
|
-
console.error("[session-seam-adapter] preset switch failed:", error);
|
|
66163
|
-
return false;
|
|
66164
|
-
}
|
|
66165
|
-
}
|
|
66166
|
-
};
|
|
66167
|
-
agents = {
|
|
66168
|
-
list: () => this.#session.listAgents(),
|
|
66169
|
-
dir: () => this.#session.agentsDir(),
|
|
66170
|
-
set: (name, field, value) => {
|
|
66171
|
-
const result = this.#session.agentSet(name, field, value);
|
|
66172
|
-
return { target: result.target, ...result.error !== undefined ? { error: result.error } : {} };
|
|
66173
|
-
},
|
|
66174
|
-
body: (name) => this.#session.agentBody(name),
|
|
66175
|
-
modelEfforts: (providerID, modelID) => this.#session.modelEfforts(providerID, modelID),
|
|
66176
|
-
officialCaps: () => this.#session.agentOfficialCaps()
|
|
66177
|
-
};
|
|
66178
|
-
settings = {
|
|
66179
|
-
describe: async () => {
|
|
66180
|
-
const doc = await this.#session.settingsDocument();
|
|
66181
|
-
return {
|
|
66182
|
-
writable: doc.writable,
|
|
66183
|
-
hasDocument: doc.hasDocument,
|
|
66184
|
-
namespaces: doc.namespaces.map(asSeamSettingsRow)
|
|
66185
|
-
};
|
|
66186
|
-
},
|
|
66187
|
-
mutate: async (ns, ops, revision) => {
|
|
66188
|
-
try {
|
|
66189
|
-
await this.#session.settingsMutate(ns, ops, revision);
|
|
66190
|
-
return { ok: true };
|
|
66191
|
-
} catch (error) {
|
|
66192
|
-
return {
|
|
66193
|
-
ok: false,
|
|
66194
|
-
conflict: error?.code === "settings/conflict",
|
|
66195
|
-
error: error instanceof Error ? error.message : String(error)
|
|
66196
|
-
};
|
|
66197
|
-
}
|
|
66198
|
-
},
|
|
66199
|
-
onChanged: (listener) => this.#session.onSettingsUpdated(listener),
|
|
66200
|
-
identity: () => ({
|
|
66201
|
-
profile: this.#session.profileName(),
|
|
66202
|
-
dshHome: this.#session.homeDir()
|
|
66203
|
-
}),
|
|
66204
|
-
permissionCatalog: () => this.#session.permissionCatalog()
|
|
66205
|
-
};
|
|
66206
|
-
login = {
|
|
66207
|
-
credentialStatus: (ref) => this.#session.credentialStatus(ref),
|
|
66208
|
-
login: (ref, apiKey) => this.#session.login(ref, apiKey),
|
|
66209
|
-
logout: (ref) => this.#session.logout(ref),
|
|
66210
|
-
routes: async () => {
|
|
66211
|
-
const rows = await this.#session.settingsSeam.describe();
|
|
66212
|
-
const ns = Array.isArray(rows) ? rows.find((row) => row?.ns === "llm-pi-ai") : undefined;
|
|
66213
|
-
const providers = ns?.value?.providers ?? {};
|
|
66214
|
-
return Object.entries(providers).map(([id, profile]) => {
|
|
66215
|
-
const p = typeof profile === "object" && profile !== null ? profile : {};
|
|
66216
|
-
const apiKeyEnv = p.apiKeyEnv;
|
|
66217
|
-
const displayName = p.displayName;
|
|
66218
|
-
return {
|
|
66219
|
-
id,
|
|
66220
|
-
...typeof apiKeyEnv === "string" && apiKeyEnv !== "" ? { apiKeyEnv } : {},
|
|
66221
|
-
...typeof displayName === "string" && displayName !== "" ? { displayName } : {},
|
|
66222
|
-
...typeof p.api === "string" || typeof p.baseURL === "string" || Array.isArray(p.models) ? { declared: true } : {}
|
|
66223
|
-
};
|
|
66224
|
-
});
|
|
66225
|
-
},
|
|
66226
|
-
registerRoute: async (providerId, profile) => {
|
|
66227
|
-
try {
|
|
66228
|
-
const rows = await this.#session.settingsSeam.describe();
|
|
66229
|
-
const ns = Array.isArray(rows) ? rows.find((row) => row?.ns === "llm-pi-ai") : undefined;
|
|
66230
|
-
const ops = profile ? [{ op: "set", path: ["providers", providerId], value: profile }] : [{ op: "unset", path: ["providers", providerId] }];
|
|
66231
|
-
await this.#session.settingsSeam.mutate("llm-pi-ai", ops, ns?.revision);
|
|
66232
|
-
return true;
|
|
66233
|
-
} catch (error) {
|
|
66234
|
-
console.error("[session-seam-adapter] login route registration failed:", error);
|
|
66235
|
-
return false;
|
|
66236
|
-
}
|
|
66237
|
-
}
|
|
66238
|
-
};
|
|
66239
|
-
#projectSubagentViews(views) {
|
|
66240
|
-
return views.map((v) => ({
|
|
66241
|
-
id: v.id,
|
|
66242
|
-
label: v.label,
|
|
66243
|
-
...v.model ? { model: v.model } : {},
|
|
66244
|
-
status: v.status,
|
|
66245
|
-
rounds: v.rounds,
|
|
66246
|
-
...v.startedAt !== undefined ? v.status === "running" ? { startedAt: v.startedAt } : { elapsedSec: Number(((Date.now() - v.startedAt) / 1000).toFixed(1)) } : {},
|
|
66247
|
-
...v.status !== "running" && v.endedAt !== undefined ? { endedAt: v.endedAt } : {},
|
|
66248
|
-
...v.injectedRound !== undefined ? { injectedRound: v.injectedRound } : {},
|
|
66249
|
-
...v.hardStopRound !== undefined ? { hardStopRound: v.hardStopRound } : {},
|
|
66250
|
-
...v.spinStopRound !== undefined ? { spinStopRound: v.spinStopRound } : {},
|
|
66251
|
-
...v.lastLine !== undefined ? { lastLine: v.lastLine } : {}
|
|
66252
|
-
}));
|
|
66253
|
-
}
|
|
66254
|
-
subagentViews() {
|
|
66255
|
-
return this.#projectSubagentViews(this.#session.subagentViews());
|
|
66256
|
-
}
|
|
66257
|
-
onSubagentViews(listener) {
|
|
66258
|
-
foldSubagentMarkerViews(this.subagentViews());
|
|
66259
|
-
return this.#session.onSubagentViews((views) => {
|
|
66260
|
-
const projected = this.#projectSubagentViews(views);
|
|
66261
|
-
foldSubagentMarkerViews(projected);
|
|
66262
|
-
listener(projected);
|
|
66263
|
-
});
|
|
66264
|
-
}
|
|
66265
|
-
steerChild(id, text) {
|
|
66266
|
-
return this.#session.steerChild(id, text);
|
|
66267
|
-
}
|
|
66268
|
-
subagentTranscript(id) {
|
|
66269
|
-
return this.#session.childTranscript(id);
|
|
66270
|
-
}
|
|
66271
|
-
async interruptChild(id) {
|
|
66272
|
-
await this.#session.interruptChild(id);
|
|
66273
|
-
}
|
|
66274
|
-
onSessionEvent(listener) {
|
|
66275
|
-
this.#listeners.push(listener);
|
|
66276
|
-
this.#ensureJournalFeed();
|
|
66277
|
-
return () => {
|
|
66278
|
-
const index = this.#listeners.indexOf(listener);
|
|
66279
|
-
if (index >= 0)
|
|
66280
|
-
this.#listeners.splice(index, 1);
|
|
66281
|
-
};
|
|
66282
|
-
}
|
|
66283
|
-
async dispose() {
|
|
66284
|
-
this.#unjournal?.();
|
|
66285
|
-
this.#unjournal = undefined;
|
|
66286
|
-
this.#unplugins?.();
|
|
66287
|
-
this.#unplugins = undefined;
|
|
66288
|
-
this.#listeners.length = 0;
|
|
66289
|
-
this.#pluginsPushListeners.length = 0;
|
|
66290
|
-
await this.#session.dispose();
|
|
66291
|
-
}
|
|
66292
|
-
#ensureJournalFeed() {
|
|
66293
|
-
if (this.#unjournal !== undefined)
|
|
66294
|
-
return;
|
|
66295
|
-
const hook = this.#session;
|
|
66296
|
-
if (typeof hook.onJournalRecord !== "function")
|
|
66297
|
-
return;
|
|
66298
|
-
this.#unjournal = hook.onJournalRecord((entry) => {
|
|
66299
|
-
if (this.#turnInFlight)
|
|
66300
|
-
return;
|
|
66301
|
-
for (const event of projectJournalRecord(entry, this.#session.currentSessionId() ?? "")) {
|
|
66302
|
-
this.#emit(event);
|
|
66303
|
-
}
|
|
66304
|
-
});
|
|
66305
|
-
}
|
|
66306
|
-
#emit(event) {
|
|
66307
|
-
for (const listener of this.#listeners) {
|
|
66308
|
-
try {
|
|
66309
|
-
listener(event);
|
|
66310
|
-
} catch {}
|
|
66311
|
-
}
|
|
66312
|
-
}
|
|
66543
|
+
// src/client/journal-projection.ts
|
|
66544
|
+
function assistantTextValue(data) {
|
|
66545
|
+
if (typeof data.text === "string")
|
|
66546
|
+
return data.text.trim();
|
|
66547
|
+
return blocksText(data.content ?? data.parts);
|
|
66313
66548
|
}
|
|
66314
66549
|
function projectJournalRecord(entry, sessionId) {
|
|
66315
66550
|
if (entry.type === "user/message") {
|
|
66316
|
-
const text =
|
|
66551
|
+
const text = blocksText(entry.data.content);
|
|
66317
66552
|
if (!text)
|
|
66318
66553
|
return [];
|
|
66319
66554
|
const id = typeof entry.data.messageID === "string" ? entry.data.messageID : `journal-${entry.seq}`;
|
|
@@ -66347,45 +66582,1186 @@ function projectJournalRecord(entry, sessionId) {
|
|
|
66347
66582
|
}
|
|
66348
66583
|
return [];
|
|
66349
66584
|
}
|
|
66350
|
-
|
|
66351
|
-
|
|
66352
|
-
|
|
66353
|
-
|
|
66354
|
-
|
|
66355
|
-
|
|
66356
|
-
|
|
66357
|
-
|
|
66358
|
-
|
|
66585
|
+
var NOTICE_SOURCE_KINDS;
|
|
66586
|
+
var init_journal_projection = __esm(() => {
|
|
66587
|
+
init_remote_follow();
|
|
66588
|
+
NOTICE_SOURCE_KINDS = new Set(["subagent-settled", "agent-message", "team-message", "webhook"]);
|
|
66589
|
+
});
|
|
66590
|
+
|
|
66591
|
+
// src/client/bridge-side-session.ts
|
|
66592
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
66593
|
+
function classify(err, stage) {
|
|
66594
|
+
const raw = err instanceof Error ? err.message : String(err);
|
|
66595
|
+
if (/NOT_WIRED|UNSUPPORTED|unavailable|no inproc host adapter/i.test(raw)) {
|
|
66596
|
+
return new SideSessionError("SIDE_SESSION_UNAVAILABLE", `/btw side-session ${stage} unavailable: ${raw.slice(0, 160)}`);
|
|
66597
|
+
}
|
|
66598
|
+
return new SideSessionError("SIDE_SESSION_FAILED", `/btw side-session ${stage} failed: ${raw.slice(0, 160)}`);
|
|
66599
|
+
}
|
|
66600
|
+
function projectWaitAnswer(value, maxLength = 4000) {
|
|
66601
|
+
const v = asRecord5(value);
|
|
66602
|
+
const output = asRecord5(v.output);
|
|
66603
|
+
const records = Array.isArray(output.records) ? output.records : [];
|
|
66604
|
+
const texts = [];
|
|
66605
|
+
for (const raw of [...records].reverse()) {
|
|
66606
|
+
const rec = asRecord5(raw);
|
|
66607
|
+
const event = asRecord5(rec.event);
|
|
66608
|
+
if (event.type !== "assistant/message")
|
|
66609
|
+
continue;
|
|
66610
|
+
const data = asRecord5(event.data);
|
|
66611
|
+
const message = asRecord5(data.message);
|
|
66612
|
+
const content = Array.isArray(message.content) ? message.content : Array.isArray(data.content) ? data.content : Array.isArray(data.parts) ? data.parts : [];
|
|
66613
|
+
const parts = [];
|
|
66614
|
+
for (const block of content) {
|
|
66615
|
+
const b = asRecord5(block);
|
|
66616
|
+
if (b.type === "text" && typeof b.text === "string")
|
|
66617
|
+
parts.push(b.text);
|
|
66618
|
+
}
|
|
66619
|
+
let text = parts.join(`
|
|
66620
|
+
`).trim();
|
|
66621
|
+
if (text === "") {
|
|
66622
|
+
const flat = typeof message.text === "string" ? message.text : typeof data.text === "string" ? data.text : "";
|
|
66623
|
+
text = flat.trim();
|
|
66359
66624
|
}
|
|
66625
|
+
if (text)
|
|
66626
|
+
texts.push(text);
|
|
66360
66627
|
}
|
|
66361
|
-
|
|
66628
|
+
let answer = texts.join(`
|
|
66629
|
+
|
|
66630
|
+
`);
|
|
66631
|
+
let truncated = output.truncated === true;
|
|
66632
|
+
if (answer.length > maxLength) {
|
|
66633
|
+
answer = answer.slice(0, maxLength);
|
|
66634
|
+
truncated = true;
|
|
66635
|
+
}
|
|
66636
|
+
return { answer, truncated };
|
|
66362
66637
|
}
|
|
66363
|
-
function
|
|
66364
|
-
|
|
66365
|
-
|
|
66366
|
-
|
|
66638
|
+
async function runSideSession(options) {
|
|
66639
|
+
const timeoutMs = options.timeoutMs ?? 120000;
|
|
66640
|
+
const rpc = options.rpc;
|
|
66641
|
+
let created;
|
|
66642
|
+
try {
|
|
66643
|
+
created = asRecord5(await rpc("session.create", {
|
|
66644
|
+
request: options.sessionId !== undefined ? { sessionId: options.sessionId } : {}
|
|
66645
|
+
}));
|
|
66646
|
+
} catch (err) {
|
|
66647
|
+
throw classify(err, "create");
|
|
66648
|
+
}
|
|
66649
|
+
const sessionId = typeof created.sessionId === "string" ? created.sessionId : "";
|
|
66650
|
+
if (sessionId === "") {
|
|
66651
|
+
throw new SideSessionError("SIDE_SESSION_UNAVAILABLE", "/btw side-session create returned no sessionId");
|
|
66652
|
+
}
|
|
66653
|
+
const requestId = options.requestId?.() ?? randomUUID8();
|
|
66654
|
+
const snap = options.snapshot && options.snapshot.length > 0 ? `Recent conversation context (for reference only):
|
|
66655
|
+
${options.snapshot.join(`
|
|
66656
|
+
`).slice(-1500)}
|
|
66657
|
+
|
|
66658
|
+
` : "";
|
|
66659
|
+
try {
|
|
66660
|
+
const accepted = asRecord5(await rpc("session.prompt", {
|
|
66661
|
+
request: {
|
|
66662
|
+
requestId,
|
|
66663
|
+
sessionId,
|
|
66664
|
+
mode: "queue",
|
|
66665
|
+
content: [{ type: "text", text: `${snap}Side question (answer in one or two sentences, do not use tools): ${options.question}` }]
|
|
66666
|
+
}
|
|
66667
|
+
}));
|
|
66668
|
+
if (accepted.accepted !== true) {
|
|
66669
|
+
throw new SideSessionError("SIDE_SESSION_PROMPT_REJECTED", "/btw side-session prompt was not accepted");
|
|
66670
|
+
}
|
|
66671
|
+
} catch (err) {
|
|
66672
|
+
if (err instanceof SideSessionError)
|
|
66673
|
+
throw err;
|
|
66674
|
+
throw classify(err, "prompt");
|
|
66675
|
+
}
|
|
66676
|
+
let waited;
|
|
66677
|
+
try {
|
|
66678
|
+
waited = asRecord5(await rpc("session.wait", {
|
|
66679
|
+
request: {
|
|
66680
|
+
sessionId,
|
|
66681
|
+
timeoutMs,
|
|
66682
|
+
...options.maxMessages !== undefined ? { maxMessages: options.maxMessages } : {}
|
|
66683
|
+
}
|
|
66684
|
+
}));
|
|
66685
|
+
} catch (err) {
|
|
66686
|
+
throw classify(err, "wait");
|
|
66687
|
+
}
|
|
66688
|
+
const { answer, truncated } = projectWaitAnswer(waited, options.maxAnswerLength);
|
|
66689
|
+
const reason = typeof waited.reason === "string" ? waited.reason : "idle";
|
|
66690
|
+
if (process.env.DSH_OPENTUI_DEBUG) {
|
|
66691
|
+
const out = asRecord5(waited.output);
|
|
66692
|
+
const recs = Array.isArray(out.records) ? out.records : [];
|
|
66693
|
+
const types = recs.map((r) => String(asRecord5(asRecord5(r).event).type ?? "?")).join(",");
|
|
66694
|
+
process.stderr.write(`[btw-side] wait reason=${reason} records=${recs.length} types=[${types}] truncated=${String(out.truncated)} answerLen=${answer.length}
|
|
66695
|
+
`);
|
|
66696
|
+
}
|
|
66697
|
+
if (answer !== "" && options.onDelta !== undefined) {
|
|
66698
|
+
try {
|
|
66699
|
+
options.onDelta(answer);
|
|
66700
|
+
} catch {}
|
|
66701
|
+
}
|
|
66702
|
+
return { answer, sessionId, reason, truncated };
|
|
66703
|
+
}
|
|
66704
|
+
var SideSessionError, asRecord5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
66705
|
+
var init_bridge_side_session = __esm(() => {
|
|
66706
|
+
SideSessionError = class SideSessionError extends Error {
|
|
66707
|
+
code;
|
|
66708
|
+
constructor(code, message) {
|
|
66709
|
+
super(message);
|
|
66710
|
+
this.code = code;
|
|
66711
|
+
this.name = "SideSessionError";
|
|
66712
|
+
}
|
|
66713
|
+
};
|
|
66714
|
+
});
|
|
66715
|
+
|
|
66716
|
+
// src/client/local-config-faces.ts
|
|
66717
|
+
import { chmodSync as chmodSync4, existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync13, renameSync as renameSync9, rmSync as rmSync5, writeFileSync as writeFileSync9 } from "fs";
|
|
66718
|
+
import { dirname as dirname7, join as join15 } from "path";
|
|
66719
|
+
function asRecord6(value) {
|
|
66720
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
66721
|
+
}
|
|
66722
|
+
function parseScalar(raw) {
|
|
66723
|
+
const v = raw.trim();
|
|
66724
|
+
if (v === "true")
|
|
66725
|
+
return true;
|
|
66726
|
+
if (v === "false")
|
|
66727
|
+
return false;
|
|
66728
|
+
if (v === "null" || v === "~")
|
|
66729
|
+
return null;
|
|
66730
|
+
if (/^-?\d+$/.test(v))
|
|
66731
|
+
return Number(v);
|
|
66732
|
+
if (/^-?\d+\.\d+$/.test(v))
|
|
66733
|
+
return Number(v);
|
|
66734
|
+
return v.replace(/^["']|["']$/g, "");
|
|
66735
|
+
}
|
|
66736
|
+
function nsEntrySpan(lines, ns) {
|
|
66737
|
+
const start = lines.findIndex((line) => new RegExp(`^- id:\\s*${ns}\\s*$`).test(line));
|
|
66738
|
+
if (start < 0)
|
|
66739
|
+
return;
|
|
66740
|
+
let end = lines.length;
|
|
66741
|
+
for (let i = start + 1;i < lines.length; i++) {
|
|
66742
|
+
if (/^- /.test(lines[i]) || /^-insert:/.test(lines[i]) || /^-\s+insert:/.test(lines[i])) {
|
|
66743
|
+
end = i;
|
|
66744
|
+
break;
|
|
66745
|
+
}
|
|
66746
|
+
}
|
|
66747
|
+
return [start, end];
|
|
66748
|
+
}
|
|
66749
|
+
function readNsValue(lines, ns) {
|
|
66750
|
+
const span = nsEntrySpan(lines, ns);
|
|
66751
|
+
const out = {};
|
|
66752
|
+
const fields = NS_VALUE_FIELDS[ns];
|
|
66753
|
+
if (span === undefined)
|
|
66754
|
+
return out;
|
|
66755
|
+
let inConfig = false;
|
|
66756
|
+
for (let i = span[0] + 1;i < span[1]; i++) {
|
|
66757
|
+
const line = lines[i];
|
|
66758
|
+
if (/^\s{2}config:\s*$/.test(line)) {
|
|
66759
|
+
inConfig = true;
|
|
66760
|
+
continue;
|
|
66761
|
+
}
|
|
66762
|
+
if (inConfig && /^\s{2}\S/.test(line))
|
|
66763
|
+
break;
|
|
66764
|
+
if (!inConfig)
|
|
66765
|
+
continue;
|
|
66766
|
+
const m = /^\s{4}([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/.exec(line);
|
|
66767
|
+
if (m && fields.includes(m[1]))
|
|
66768
|
+
out[m[1]] = parseScalar(m[2]);
|
|
66769
|
+
}
|
|
66770
|
+
return out;
|
|
66771
|
+
}
|
|
66772
|
+
function writeNsField(lines, ns, key, raw) {
|
|
66773
|
+
const fields = NS_VALUE_FIELDS[ns];
|
|
66774
|
+
if (!fields.includes(key))
|
|
66775
|
+
return false;
|
|
66776
|
+
const yaml = /^(true|false|null|~|-?\d+(?:\.\d+)?)$/.test(raw.trim()) || /^["']/.test(raw.trim()) ? raw.trim() : JSON.stringify(raw);
|
|
66777
|
+
const span = nsEntrySpan(lines, ns);
|
|
66778
|
+
if (span === undefined) {
|
|
66779
|
+
lines.push("", `- id: ${ns}`, ` name: '${NS_PACKAGE[ns]}'`, " config:", ` ${key}: ${yaml}`);
|
|
66780
|
+
return true;
|
|
66781
|
+
}
|
|
66782
|
+
let configLine = -1;
|
|
66783
|
+
for (let i = span[0] + 1;i < span[1]; i++) {
|
|
66784
|
+
if (/^\s{2}config:\s*$/.test(lines[i])) {
|
|
66785
|
+
configLine = i;
|
|
66786
|
+
break;
|
|
66787
|
+
}
|
|
66788
|
+
}
|
|
66789
|
+
if (configLine < 0) {
|
|
66790
|
+
lines.splice(span[0] + 1, 0, " config:", ` ${key}: ${yaml}`);
|
|
66791
|
+
return true;
|
|
66792
|
+
}
|
|
66793
|
+
for (let i = configLine + 1;i < span[1]; i++) {
|
|
66794
|
+
const m = /^(\s{4})([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/.exec(lines[i]);
|
|
66795
|
+
if (!m)
|
|
66796
|
+
continue;
|
|
66797
|
+
if (/^\s{2}\S/.test(lines[i]))
|
|
66798
|
+
break;
|
|
66799
|
+
if (m[2] === key) {
|
|
66800
|
+
lines[i] = ` ${key}: ${yaml}`;
|
|
66801
|
+
return true;
|
|
66802
|
+
}
|
|
66803
|
+
}
|
|
66804
|
+
lines.splice(configLine + 1, 0, ` ${key}: ${yaml}`);
|
|
66805
|
+
return true;
|
|
66806
|
+
}
|
|
66807
|
+
function atomicWrite2(path, text) {
|
|
66808
|
+
mkdirSync7(dirname7(path), { recursive: true });
|
|
66809
|
+
const tmp = `${path}.${process.pid}.s5.tmp`;
|
|
66810
|
+
try {
|
|
66811
|
+
writeFileSync9(tmp, text);
|
|
66812
|
+
renameSync9(tmp, path);
|
|
66813
|
+
} catch (err) {
|
|
66814
|
+
try {
|
|
66815
|
+
rmSync5(tmp, { force: true });
|
|
66816
|
+
} catch {}
|
|
66817
|
+
throw err;
|
|
66818
|
+
}
|
|
66819
|
+
}
|
|
66820
|
+
function buildLoginRouteBlock(providerId, profile) {
|
|
66821
|
+
const block = [` ${providerId}:`];
|
|
66822
|
+
const apiKeyEnv = typeof profile.apiKeyEnv === "string" ? profile.apiKeyEnv : "";
|
|
66823
|
+
if (apiKeyEnv !== "") {
|
|
66824
|
+
if (!/^[A-Za-z0-9_]+$/.test(apiKeyEnv))
|
|
66825
|
+
return;
|
|
66826
|
+
block.push(` apiKeyEnv: ${apiKeyEnv}`);
|
|
66827
|
+
}
|
|
66828
|
+
if (profile.api !== undefined) {
|
|
66829
|
+
if (typeof profile.api !== "string" || !/^[A-Za-z0-9_.-]+$/.test(profile.api))
|
|
66830
|
+
return;
|
|
66831
|
+
block.push(` api: ${profile.api}`);
|
|
66832
|
+
}
|
|
66833
|
+
if (profile.baseURL !== undefined) {
|
|
66834
|
+
if (typeof profile.baseURL !== "string" || !/^https?:\/\/\S+$/.test(profile.baseURL))
|
|
66835
|
+
return;
|
|
66836
|
+
block.push(` baseURL: ${JSON.stringify(profile.baseURL)}`);
|
|
66837
|
+
}
|
|
66838
|
+
if (profile.displayName !== undefined) {
|
|
66839
|
+
if (typeof profile.displayName !== "string" || /[\r\n]/.test(profile.displayName))
|
|
66840
|
+
return;
|
|
66841
|
+
block.push(` displayName: ${JSON.stringify(profile.displayName)}`);
|
|
66842
|
+
}
|
|
66843
|
+
if (profile.models !== undefined) {
|
|
66844
|
+
if (!Array.isArray(profile.models))
|
|
66845
|
+
return;
|
|
66846
|
+
block.push(" models:");
|
|
66847
|
+
for (const entry of profile.models) {
|
|
66848
|
+
const m = asRecord6(entry);
|
|
66849
|
+
const id = m.id;
|
|
66850
|
+
if (typeof id !== "string" || !id || /[\r\n\x00-\x1f]/.test(id))
|
|
66851
|
+
return;
|
|
66852
|
+
block.push(` - id: ${JSON.stringify(id)}`);
|
|
66853
|
+
if (m.name !== undefined) {
|
|
66854
|
+
if (typeof m.name !== "string" || /[\r\n\x00-\x1f]/.test(m.name))
|
|
66855
|
+
return;
|
|
66856
|
+
block.push(` name: ${JSON.stringify(m.name)}`);
|
|
66857
|
+
}
|
|
66858
|
+
}
|
|
66859
|
+
}
|
|
66860
|
+
return block;
|
|
66861
|
+
}
|
|
66862
|
+
|
|
66863
|
+
class LocalSettingsStore {
|
|
66864
|
+
#patchPath;
|
|
66865
|
+
constructor(home, profile) {
|
|
66866
|
+
this.#patchPath = join15(home, "profiles", profile, "cordis.patch.yml");
|
|
66867
|
+
}
|
|
66868
|
+
describe() {
|
|
66869
|
+
let lines = [];
|
|
66870
|
+
try {
|
|
66871
|
+
lines = readFileSync13(this.#patchPath, "utf8").split(`
|
|
66872
|
+
`);
|
|
66873
|
+
} catch {}
|
|
66874
|
+
const namespaces = SETTINGS_NAMESPACES.map((ns) => {
|
|
66875
|
+
const patchValue = readNsValue(lines, ns);
|
|
66876
|
+
const value = {};
|
|
66877
|
+
for (const field of NS_VALUE_FIELDS[ns]) {
|
|
66878
|
+
const v = patchValue[field] ?? NS_DEFAULTS[ns][field];
|
|
66879
|
+
if (v !== undefined)
|
|
66880
|
+
value[field] = v;
|
|
66881
|
+
}
|
|
66882
|
+
const schema = {};
|
|
66883
|
+
for (const field of NS_VALUE_FIELDS[ns])
|
|
66884
|
+
schema[field] = { type: typeof value[field] };
|
|
66885
|
+
if (ns === "permission") {
|
|
66886
|
+
const presets = value.presets;
|
|
66887
|
+
if (presets && typeof presets === "object") {
|
|
66888
|
+
schema.defaultPreset = { type: "string", enum: Object.keys(presets) };
|
|
66889
|
+
}
|
|
66890
|
+
}
|
|
66891
|
+
return { ns, revision: 1, value, base: { ...value }, schema, secrets: [] };
|
|
66892
|
+
});
|
|
66893
|
+
const hidden = new Set([...SETTINGS_NAMESPACES, "dsh-tui"]);
|
|
66894
|
+
const seen = new Set(SETTINGS_NAMESPACES);
|
|
66895
|
+
const others = [];
|
|
66896
|
+
for (const line of lines) {
|
|
66897
|
+
const m = /^- id:\s*([A-Za-z0-9_.\-@/]+)\s*$/.exec(line);
|
|
66898
|
+
if (!m)
|
|
66899
|
+
continue;
|
|
66900
|
+
const ns = m[1];
|
|
66901
|
+
if (hidden.has(ns) || seen.has(ns))
|
|
66902
|
+
continue;
|
|
66903
|
+
seen.add(ns);
|
|
66904
|
+
others.push({ ns, revision: 1 });
|
|
66905
|
+
}
|
|
66906
|
+
others.sort((a, b) => a.ns === "agent-default-model" ? -1 : b.ns === "agent-default-model" ? 1 : 0);
|
|
66907
|
+
namespaces.push(...others);
|
|
66908
|
+
return { writable: true, hasDocument: existsSync12(this.#patchPath), namespaces };
|
|
66909
|
+
}
|
|
66910
|
+
mutate(ns, ops, _revision) {
|
|
66911
|
+
if (!SETTINGS_NAMESPACES.includes(ns)) {
|
|
66912
|
+
return { ok: false, conflict: false, error: `settings.mutate: namespace '${ns}' is not whitelisted` };
|
|
66913
|
+
}
|
|
66914
|
+
const allow = NS_VALUE_FIELDS[ns];
|
|
66915
|
+
for (const op of ops) {
|
|
66916
|
+
if (!Array.isArray(op.path) || op.path.length !== 1 || !allow.includes(op.path[0])) {
|
|
66917
|
+
return { ok: false, conflict: false, error: `settings.mutate: path not whitelisted for '${ns}'` };
|
|
66918
|
+
}
|
|
66919
|
+
}
|
|
66920
|
+
let text = "";
|
|
66921
|
+
try {
|
|
66922
|
+
text = readFileSync13(this.#patchPath, "utf8");
|
|
66923
|
+
} catch {}
|
|
66924
|
+
const lines = text.length > 0 ? text.split(`
|
|
66925
|
+
`) : [];
|
|
66926
|
+
for (const op of ops) {
|
|
66927
|
+
const key = op.path[0];
|
|
66928
|
+
if (op.op === "unset") {
|
|
66929
|
+
const fallback = NS_DEFAULTS[ns][key];
|
|
66930
|
+
if (fallback !== undefined)
|
|
66931
|
+
writeNsField(lines, ns, key, String(fallback));
|
|
66932
|
+
continue;
|
|
66933
|
+
}
|
|
66934
|
+
const value = op.value;
|
|
66935
|
+
if (typeof value === "object" && value !== null) {
|
|
66936
|
+
return { ok: false, conflict: false, error: "settings.mutate: nested value not whitelisted" };
|
|
66937
|
+
}
|
|
66938
|
+
writeNsField(lines, ns, key, String(value));
|
|
66939
|
+
}
|
|
66940
|
+
try {
|
|
66941
|
+
atomicWrite2(this.#patchPath, lines.join(`
|
|
66942
|
+
`).replace(/\n*$/, `
|
|
66943
|
+
`));
|
|
66944
|
+
} catch (err) {
|
|
66945
|
+
return { ok: false, conflict: false, error: err instanceof Error ? err.message : String(err) };
|
|
66946
|
+
}
|
|
66947
|
+
return { ok: true };
|
|
66948
|
+
}
|
|
66949
|
+
}
|
|
66950
|
+
|
|
66951
|
+
class LocalConfigStore {
|
|
66952
|
+
#configPath;
|
|
66953
|
+
#overlayPath;
|
|
66954
|
+
#overlayCache;
|
|
66955
|
+
constructor(home, profile, workspaceDir) {
|
|
66956
|
+
this.#configPath = join15(home, "profiles", profile, "config.json");
|
|
66957
|
+
this.#overlayPath = workspaceConfigPath(workspaceDir);
|
|
66958
|
+
this.#overlayCache = loadWorkspaceConfigState(workspaceDir);
|
|
66959
|
+
}
|
|
66960
|
+
#readProfile() {
|
|
66961
|
+
try {
|
|
66962
|
+
return asRecord6(JSON.parse(readFileSync13(this.#configPath, "utf8")));
|
|
66963
|
+
} catch {
|
|
66964
|
+
return {};
|
|
66965
|
+
}
|
|
66966
|
+
}
|
|
66967
|
+
configRaw() {
|
|
66968
|
+
return this.#readProfile();
|
|
66969
|
+
}
|
|
66970
|
+
configLoad() {
|
|
66971
|
+
const base = this.#readProfile();
|
|
66972
|
+
const merged = mergeConfig({ theme: typeof base.theme === "string" ? base.theme : undefined }, this.#overlayCache, process.env);
|
|
66973
|
+
const out = {};
|
|
66974
|
+
for (const key of CONFIG_KEYS)
|
|
66975
|
+
if (base[key] !== undefined)
|
|
66976
|
+
out[key] = base[key];
|
|
66977
|
+
if (merged.theme !== undefined)
|
|
66978
|
+
out.theme = merged.theme;
|
|
66979
|
+
if (merged.themeMode !== undefined)
|
|
66980
|
+
out.themeMode = merged.themeMode;
|
|
66981
|
+
if (merged.model !== undefined)
|
|
66982
|
+
out.model = merged.model;
|
|
66983
|
+
return out;
|
|
66984
|
+
}
|
|
66985
|
+
workspaceConfig() {
|
|
66986
|
+
return { ...this.#overlayCache };
|
|
66987
|
+
}
|
|
66988
|
+
configSave(patch) {
|
|
66989
|
+
const current = this.#readProfile();
|
|
66990
|
+
const next = {};
|
|
66991
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
66992
|
+
if (CONFIG_KEY_SET.has(key))
|
|
66993
|
+
next[key] = value;
|
|
66994
|
+
}
|
|
66995
|
+
if (Object.keys(next).length === 0)
|
|
66996
|
+
return this.configLoad();
|
|
66997
|
+
const merged = { ...current, ...next };
|
|
66998
|
+
atomicWrite2(this.#configPath, JSON.stringify(merged, null, 2) + `
|
|
66999
|
+
`);
|
|
67000
|
+
return this.configLoad();
|
|
67001
|
+
}
|
|
67002
|
+
}
|
|
67003
|
+
function loadWorkspaceConfigState(workspaceDir) {
|
|
67004
|
+
try {
|
|
67005
|
+
const raw = JSON.parse(readFileSync13(join15(workspaceDir, ".dsh", "config.yml"), "utf8"));
|
|
67006
|
+
return asRecord6(raw);
|
|
67007
|
+
} catch {
|
|
67008
|
+
try {
|
|
67009
|
+
const text = readFileSync13(join15(workspaceDir, ".dsh", "config.yml"), "utf8");
|
|
67010
|
+
const out = {};
|
|
67011
|
+
const m = /^\s*theme:\s*(.+)$/m.exec(text);
|
|
67012
|
+
if (m)
|
|
67013
|
+
out.theme = parseScalar(m[1]);
|
|
67014
|
+
return out;
|
|
67015
|
+
} catch {
|
|
67016
|
+
return {};
|
|
67017
|
+
}
|
|
67018
|
+
}
|
|
67019
|
+
}
|
|
67020
|
+
|
|
67021
|
+
class LocalAgentsFace {
|
|
67022
|
+
#home;
|
|
67023
|
+
#workspaceDir;
|
|
67024
|
+
#settings;
|
|
67025
|
+
#modelCatalog;
|
|
67026
|
+
constructor(options) {
|
|
67027
|
+
this.#home = options.home;
|
|
67028
|
+
this.#workspaceDir = options.workspaceDir;
|
|
67029
|
+
this.#settings = options.settings;
|
|
67030
|
+
this.#modelCatalog = options.modelCatalog;
|
|
67031
|
+
}
|
|
67032
|
+
#rows() {
|
|
67033
|
+
return listComposedAgents(this.#home, this.#workspaceDir);
|
|
67034
|
+
}
|
|
67035
|
+
list() {
|
|
67036
|
+
return this.#rows().map((row) => ({
|
|
67037
|
+
name: row.name,
|
|
67038
|
+
...row.displayName ? { displayName: row.displayName } : {},
|
|
67039
|
+
...row.description ? { description: row.description } : {},
|
|
67040
|
+
...row.model ? { model: row.model } : {},
|
|
67041
|
+
...row.thinking ? { thinking: row.thinking } : {},
|
|
67042
|
+
deep: row.deep,
|
|
67043
|
+
...row.maxRounds !== undefined ? { maxRounds: row.maxRounds } : {},
|
|
67044
|
+
...row.background !== undefined ? { background: row.background } : {},
|
|
67045
|
+
file: row.file,
|
|
67046
|
+
...row.pin ? { pin: row.pin } : {},
|
|
67047
|
+
...row.broken ? { broken: row.broken } : {}
|
|
67048
|
+
}));
|
|
67049
|
+
}
|
|
67050
|
+
dir() {
|
|
67051
|
+
return join15(this.#home, "agents");
|
|
67052
|
+
}
|
|
67053
|
+
body(name) {
|
|
67054
|
+
return this.#rows().find((row) => row.name === name && row.broken === undefined)?.body ?? "";
|
|
67055
|
+
}
|
|
67056
|
+
set(name, field, value) {
|
|
67057
|
+
if (field === "deep" || field === "maxRounds" || field === "background") {
|
|
67058
|
+
const error = setAgentField(name, field, value, this.#home);
|
|
67059
|
+
return { target: { kind: "frontmatter" }, ...error ? { error } : {} };
|
|
67060
|
+
}
|
|
67061
|
+
const row = this.#rows().find((agent) => agent.name === name && agent.broken === undefined);
|
|
67062
|
+
if (row === undefined)
|
|
67063
|
+
return { target: { kind: "frontmatter" }, error: `agent "${name}" not found` };
|
|
67064
|
+
const result = commitAgentModelEdit(this.#home, this.#workspaceDir, row.file, name, { [field]: value });
|
|
67065
|
+
return { target: result.target, ...result.error ? { error: result.error } : {} };
|
|
67066
|
+
}
|
|
67067
|
+
async modelEfforts(providerID, modelID) {
|
|
67068
|
+
const catalog = await this.#modelCatalog();
|
|
67069
|
+
const model = catalog.groups.find((g) => g.id === providerID)?.models.find((m) => m.id === modelID);
|
|
67070
|
+
return model?.reasoning?.efforts ?? [];
|
|
67071
|
+
}
|
|
67072
|
+
async officialCaps() {
|
|
67073
|
+
const doc = this.#settings.describe();
|
|
67074
|
+
const row = doc.namespaces.find((n) => n.ns === "subagent");
|
|
67075
|
+
const value = asRecord6(row?.value);
|
|
67076
|
+
const caps = {};
|
|
67077
|
+
if (typeof value.maxActiveSubagents === "number" && Number.isFinite(value.maxActiveSubagents))
|
|
67078
|
+
caps.maxActiveSubagents = value.maxActiveSubagents;
|
|
67079
|
+
if (typeof value.maxDepth === "number" && Number.isFinite(value.maxDepth))
|
|
67080
|
+
caps.maxDepth = value.maxDepth;
|
|
67081
|
+
return caps;
|
|
67082
|
+
}
|
|
67083
|
+
}
|
|
67084
|
+
|
|
67085
|
+
class LocalPresetFace {
|
|
67086
|
+
#patchPath;
|
|
67087
|
+
#configPath;
|
|
67088
|
+
constructor(home, profile) {
|
|
67089
|
+
this.#patchPath = join15(home, "profiles", profile, "cordis.patch.yml");
|
|
67090
|
+
this.#configPath = join15(home, "profiles", profile, "config.json");
|
|
67091
|
+
}
|
|
67092
|
+
list() {
|
|
67093
|
+
let lines = [];
|
|
67094
|
+
try {
|
|
67095
|
+
lines = readFileSync13(this.#patchPath, "utf8").split(`
|
|
67096
|
+
`);
|
|
67097
|
+
} catch {
|
|
67098
|
+
return [];
|
|
67099
|
+
}
|
|
67100
|
+
const rows = [];
|
|
67101
|
+
const seen = new Set;
|
|
67102
|
+
for (let i = 0;i < lines.length; i++) {
|
|
67103
|
+
if (!/^\s*- id:\s*preset-\S+\s*$/.test(lines[i]))
|
|
67104
|
+
continue;
|
|
67105
|
+
let end = lines.length;
|
|
67106
|
+
for (let j = i + 1;j < lines.length; j++) {
|
|
67107
|
+
if (/^\s*- id:\s*\S+/.test(lines[j]) || /^- /.test(lines[j])) {
|
|
67108
|
+
end = j;
|
|
67109
|
+
break;
|
|
67110
|
+
}
|
|
67111
|
+
}
|
|
67112
|
+
const span = lines.slice(i, end);
|
|
67113
|
+
if (!span.some((l) => /name:\s*['"]?@deepseek-ai\/dsh-agent-preset/.test(l)))
|
|
67114
|
+
continue;
|
|
67115
|
+
const cfg = span.findIndex((l) => /^\s{4,}config:\s*$/.test(l));
|
|
67116
|
+
const val = {};
|
|
67117
|
+
if (cfg >= 0) {
|
|
67118
|
+
for (let k = cfg + 1;k < span.length; k++) {
|
|
67119
|
+
const m = /^\s{6,}([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/.exec(span[k]);
|
|
67120
|
+
if (!m)
|
|
67121
|
+
continue;
|
|
67122
|
+
if (/^\s{6,}(plugins|disabled|order):/.test(span[k]) && m[1] !== "order") {
|
|
67123
|
+
if (m[1] === "plugins")
|
|
67124
|
+
break;
|
|
67125
|
+
}
|
|
67126
|
+
const key = m[1];
|
|
67127
|
+
if (key === "id" || key === "name" || key === "description") {
|
|
67128
|
+
let v = m[2].trim().replace(/^['"]|['"]$/g, "");
|
|
67129
|
+
let kk = k + 1;
|
|
67130
|
+
while (kk < span.length && /^\s{10,}\S/.test(span[kk]) && !/^\s{10,}[A-Za-z_][A-Za-z0-9_]*\s*:/.test(span[kk])) {
|
|
67131
|
+
v += " " + span[kk].trim();
|
|
67132
|
+
kk++;
|
|
67133
|
+
}
|
|
67134
|
+
val[key] = v;
|
|
67135
|
+
}
|
|
67136
|
+
}
|
|
67137
|
+
}
|
|
67138
|
+
const id = val.id;
|
|
67139
|
+
if (!id || seen.has(id))
|
|
67140
|
+
continue;
|
|
67141
|
+
seen.add(id);
|
|
67142
|
+
rows.push({
|
|
67143
|
+
id,
|
|
67144
|
+
name: val.name || id,
|
|
67145
|
+
...val.description ? { description: val.description } : {}
|
|
67146
|
+
});
|
|
67147
|
+
}
|
|
67148
|
+
return rows;
|
|
67149
|
+
}
|
|
67150
|
+
currentId() {
|
|
67151
|
+
try {
|
|
67152
|
+
const doc = asRecord6(JSON.parse(readFileSync13(this.#configPath, "utf8")));
|
|
67153
|
+
return typeof doc.agentPreset === "string" && doc.agentPreset !== "" ? doc.agentPreset : undefined;
|
|
67154
|
+
} catch {
|
|
67155
|
+
return;
|
|
67156
|
+
}
|
|
67157
|
+
}
|
|
67158
|
+
select(presetId) {
|
|
67159
|
+
const current = this.#readDoc();
|
|
67160
|
+
try {
|
|
67161
|
+
atomicWrite2(this.#configPath, JSON.stringify({ ...current, agentPreset: presetId }, null, 2) + `
|
|
67162
|
+
`);
|
|
67163
|
+
return true;
|
|
67164
|
+
} catch {
|
|
67165
|
+
return false;
|
|
67166
|
+
}
|
|
67167
|
+
}
|
|
67168
|
+
#readDoc() {
|
|
67169
|
+
try {
|
|
67170
|
+
return asRecord6(JSON.parse(readFileSync13(this.#configPath, "utf8")));
|
|
67171
|
+
} catch {
|
|
67172
|
+
return {};
|
|
67173
|
+
}
|
|
67174
|
+
}
|
|
67175
|
+
}
|
|
67176
|
+
|
|
67177
|
+
class LocalLoginFace {
|
|
67178
|
+
#patchPath;
|
|
67179
|
+
#keysPath;
|
|
67180
|
+
constructor(home, profile) {
|
|
67181
|
+
this.#patchPath = join15(home, "profiles", profile, "cordis.patch.yml");
|
|
67182
|
+
this.#keysPath = join15(home, "profiles", profile, "provider-keys.json");
|
|
67183
|
+
}
|
|
67184
|
+
routes() {
|
|
67185
|
+
let lines = [];
|
|
67186
|
+
try {
|
|
67187
|
+
lines = readFileSync13(this.#patchPath, "utf8").split(`
|
|
67188
|
+
`);
|
|
67189
|
+
} catch {
|
|
67190
|
+
return [];
|
|
67191
|
+
}
|
|
67192
|
+
const span = nsEntrySpan(lines, "llm-pi-ai");
|
|
67193
|
+
if (span === undefined)
|
|
67194
|
+
return [];
|
|
67195
|
+
const providersLine = lines.findIndex((l, i) => i >= span[0] && i < span[1] && /^\s{4}providers:\s*$/.test(l));
|
|
67196
|
+
if (providersLine < 0)
|
|
67197
|
+
return [];
|
|
67198
|
+
const out = [];
|
|
67199
|
+
for (let i = providersLine + 1;i < lines.length; i++) {
|
|
67200
|
+
const line = lines[i];
|
|
67201
|
+
const m = /^\s{6}([A-Za-z0-9_.\-]+):\s*$/.exec(line);
|
|
67202
|
+
if (!m) {
|
|
67203
|
+
if (/^\s{0,4}\S/.test(line))
|
|
67204
|
+
break;
|
|
67205
|
+
continue;
|
|
67206
|
+
}
|
|
67207
|
+
const id = m[1];
|
|
67208
|
+
let apiKeyEnv;
|
|
67209
|
+
let displayName;
|
|
67210
|
+
let declared = false;
|
|
67211
|
+
for (let j = i + 1;j < lines.length; j++) {
|
|
67212
|
+
if (/^\s{6}\S/.test(lines[j]) || /^\s{0,4}\S/.test(lines[j]))
|
|
67213
|
+
break;
|
|
67214
|
+
const f = /^\s{8}([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/.exec(lines[j]);
|
|
67215
|
+
if (!f)
|
|
67216
|
+
continue;
|
|
67217
|
+
if (f[1] === "apiKeyEnv")
|
|
67218
|
+
apiKeyEnv = f[2].trim().replace(/^['"]|['"]$/g, "");
|
|
67219
|
+
else if (f[1] === "displayName")
|
|
67220
|
+
displayName = f[2].trim().replace(/^['"]|['"]$/g, "");
|
|
67221
|
+
else if (f[1] === "api" || f[1] === "baseURL" || f[1] === "models")
|
|
67222
|
+
declared = true;
|
|
67223
|
+
}
|
|
67224
|
+
out.push({ id, ...apiKeyEnv ? { apiKeyEnv } : {}, ...displayName ? { displayName } : {}, declared });
|
|
67225
|
+
}
|
|
67226
|
+
return out;
|
|
67227
|
+
}
|
|
67228
|
+
credentialStatus(ref) {
|
|
67229
|
+
if (typeof process.env[ref] === "string" && process.env[ref] !== "")
|
|
67230
|
+
return { configured: true };
|
|
67231
|
+
return { configured: Object.prototype.hasOwnProperty.call(this.#readKeys(), ref) };
|
|
67232
|
+
}
|
|
67233
|
+
login(ref, apiKey) {
|
|
67234
|
+
const keys = this.#readKeys();
|
|
67235
|
+
keys[ref] = apiKey;
|
|
67236
|
+
this.#writeKeys(keys);
|
|
67237
|
+
}
|
|
67238
|
+
logout(ref) {
|
|
67239
|
+
const keys = this.#readKeys();
|
|
67240
|
+
delete keys[ref];
|
|
67241
|
+
this.#writeKeys(keys);
|
|
67242
|
+
}
|
|
67243
|
+
registerRoute(providerId, profile) {
|
|
67244
|
+
let text = "";
|
|
67245
|
+
try {
|
|
67246
|
+
text = readFileSync13(this.#patchPath, "utf8");
|
|
67247
|
+
} catch {
|
|
67248
|
+
return false;
|
|
67249
|
+
}
|
|
67250
|
+
const lines = text.length > 0 ? text.split(`
|
|
67251
|
+
`) : [];
|
|
67252
|
+
const span = nsEntrySpan(lines, "llm-pi-ai");
|
|
67253
|
+
if (span === undefined)
|
|
67254
|
+
return false;
|
|
67255
|
+
const providersLine = lines.findIndex((l, i) => i >= span[0] && i < span[1] && /^\s{4}providers:\s*$/.test(l));
|
|
67256
|
+
if (providersLine < 0)
|
|
67257
|
+
return false;
|
|
67258
|
+
let pStart = -1;
|
|
67259
|
+
let pEnd = -1;
|
|
67260
|
+
for (let i = providersLine + 1;i < lines.length; i++) {
|
|
67261
|
+
const m = /^\s{6}([A-Za-z0-9_.\-]+):\s*$/.exec(lines[i]);
|
|
67262
|
+
if (m && m[1] === providerId) {
|
|
67263
|
+
pStart = i;
|
|
67264
|
+
pEnd = i + 1;
|
|
67265
|
+
for (let j = i + 1;j < lines.length; j++) {
|
|
67266
|
+
if (/^\s{6}\S/.test(lines[j]) || /^\s{0,4}\S/.test(lines[j]))
|
|
67267
|
+
break;
|
|
67268
|
+
pEnd = j + 1;
|
|
67269
|
+
}
|
|
67270
|
+
break;
|
|
67271
|
+
}
|
|
67272
|
+
if (/^\s{0,4}\S/.test(lines[i]))
|
|
67273
|
+
break;
|
|
67274
|
+
}
|
|
67275
|
+
if (profile === undefined) {
|
|
67276
|
+
if (pStart < 0)
|
|
67277
|
+
return true;
|
|
67278
|
+
lines.splice(pStart, pEnd - pStart);
|
|
67279
|
+
} else {
|
|
67280
|
+
if (!/^[A-Za-z0-9_.-]+$/.test(providerId))
|
|
67281
|
+
return false;
|
|
67282
|
+
const block = buildLoginRouteBlock(providerId, profile);
|
|
67283
|
+
if (block === undefined)
|
|
67284
|
+
return false;
|
|
67285
|
+
if (pStart >= 0)
|
|
67286
|
+
lines.splice(pStart, pEnd - pStart, ...block);
|
|
67287
|
+
else
|
|
67288
|
+
lines.splice(providersLine + 1, 0, ...block);
|
|
67289
|
+
}
|
|
67290
|
+
try {
|
|
67291
|
+
atomicWrite2(this.#patchPath, lines.join(`
|
|
67292
|
+
`).replace(/\n*$/, `
|
|
67293
|
+
`));
|
|
67294
|
+
} catch {
|
|
67295
|
+
return false;
|
|
67296
|
+
}
|
|
67297
|
+
return true;
|
|
67298
|
+
}
|
|
67299
|
+
#readKeys() {
|
|
67300
|
+
try {
|
|
67301
|
+
const doc = asRecord6(JSON.parse(readFileSync13(this.#keysPath, "utf8")));
|
|
67302
|
+
const out = {};
|
|
67303
|
+
for (const [k, v] of Object.entries(doc))
|
|
67304
|
+
if (typeof v === "string")
|
|
67305
|
+
out[k] = v;
|
|
67306
|
+
return out;
|
|
67307
|
+
} catch {
|
|
67308
|
+
return {};
|
|
67309
|
+
}
|
|
67310
|
+
}
|
|
67311
|
+
#writeKeys(keys) {
|
|
67312
|
+
mkdirSync7(dirname7(this.#keysPath), { recursive: true });
|
|
67313
|
+
const tmp = `${this.#keysPath}.${process.pid}.s5.tmp`;
|
|
67314
|
+
try {
|
|
67315
|
+
writeFileSync9(tmp, JSON.stringify(keys, null, 2) + `
|
|
67316
|
+
`, { mode: 384 });
|
|
67317
|
+
try {
|
|
67318
|
+
chmodSync4(tmp, 384);
|
|
67319
|
+
} catch {}
|
|
67320
|
+
renameSync9(tmp, this.#keysPath);
|
|
67321
|
+
} catch (err) {
|
|
67322
|
+
try {
|
|
67323
|
+
rmSync5(tmp, { force: true });
|
|
67324
|
+
} catch {}
|
|
67325
|
+
throw err;
|
|
67326
|
+
}
|
|
67327
|
+
}
|
|
67328
|
+
}
|
|
67329
|
+
var SETTINGS_NAMESPACES, NS_VALUE_FIELDS, NS_PACKAGE, NS_DEFAULTS, CONFIG_KEYS, CONFIG_KEY_SET;
|
|
67330
|
+
var init_local_config_faces = __esm(() => {
|
|
67331
|
+
init_remote_agent_profiles();
|
|
67332
|
+
init_remote_local_fs();
|
|
67333
|
+
init_workspace_config();
|
|
67334
|
+
SETTINGS_NAMESPACES = ["subagent", "permission", "session-log-deepseek"];
|
|
67335
|
+
NS_VALUE_FIELDS = {
|
|
67336
|
+
subagent: ["maxActiveSubagents", "maxDepth"],
|
|
67337
|
+
permission: ["defaultPreset", "presets"],
|
|
67338
|
+
"session-log-deepseek": ["enabled"]
|
|
67339
|
+
};
|
|
67340
|
+
NS_PACKAGE = {
|
|
67341
|
+
subagent: "@deepseek-ai/dsh-subagent",
|
|
67342
|
+
permission: "@deepseek-ai/dsh-permission-presets",
|
|
67343
|
+
"session-log-deepseek": "@deepseek-ai/dsh-session-log-deepseek"
|
|
67344
|
+
};
|
|
67345
|
+
NS_DEFAULTS = {
|
|
67346
|
+
subagent: { maxActiveSubagents: 1, maxDepth: 1 },
|
|
67347
|
+
permission: { defaultPreset: "workspace-write" },
|
|
67348
|
+
"session-log-deepseek": { enabled: true }
|
|
67349
|
+
};
|
|
67350
|
+
CONFIG_KEYS = [
|
|
67351
|
+
"lang",
|
|
67352
|
+
"motion",
|
|
67353
|
+
"theme",
|
|
67354
|
+
"themeMode",
|
|
67355
|
+
"skin",
|
|
67356
|
+
"cacheHitMode",
|
|
67357
|
+
"footerHints",
|
|
67358
|
+
"hintsLocale",
|
|
67359
|
+
"autoResume",
|
|
67360
|
+
"autoResumeDays",
|
|
67361
|
+
"maxRoundsGrace",
|
|
67362
|
+
"activity_panel_height",
|
|
67363
|
+
"stepsDisplay",
|
|
67364
|
+
"stepsCollapse",
|
|
67365
|
+
"stepsFolded",
|
|
67366
|
+
"agentPreset"
|
|
67367
|
+
];
|
|
67368
|
+
CONFIG_KEY_SET = new Set(CONFIG_KEYS);
|
|
67369
|
+
});
|
|
67370
|
+
|
|
67371
|
+
// src/client/bridge-plugins-manager.ts
|
|
67372
|
+
function asRecord7(value) {
|
|
67373
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
67374
|
+
}
|
|
67375
|
+
function unwrapWireValue(raw) {
|
|
67376
|
+
const rec = asRecord7(raw);
|
|
67377
|
+
if (Object.prototype.hasOwnProperty.call(rec, "value"))
|
|
67378
|
+
return rec.value;
|
|
67379
|
+
return raw;
|
|
67380
|
+
}
|
|
67381
|
+
function text(value, max = MAX_TEXT) {
|
|
67382
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
66367
67383
|
}
|
|
66368
|
-
function
|
|
67384
|
+
function bool(value) {
|
|
67385
|
+
return value === true;
|
|
67386
|
+
}
|
|
67387
|
+
function projectBundleRows(raw) {
|
|
67388
|
+
const value = unwrapWireValue(raw);
|
|
67389
|
+
if (!Array.isArray(value))
|
|
67390
|
+
return [];
|
|
67391
|
+
const out = [];
|
|
67392
|
+
for (const entry of value) {
|
|
67393
|
+
const row = asRecord7(entry);
|
|
67394
|
+
const name = text(row.name, MAX_SHORT);
|
|
67395
|
+
if (name === undefined || name === "")
|
|
67396
|
+
continue;
|
|
67397
|
+
const version = text(row.version, MAX_SHORT) ?? "";
|
|
67398
|
+
const description = text(row.description);
|
|
67399
|
+
const readOnlyReason = text(row.readOnlyReason, MAX_SHORT);
|
|
67400
|
+
const errorRaw = row.error;
|
|
67401
|
+
const error = typeof errorRaw === "string" ? errorRaw.slice(0, MAX_SHORT) : text(asRecord7(errorRaw).message, MAX_SHORT);
|
|
67402
|
+
const projected = {
|
|
67403
|
+
name,
|
|
67404
|
+
version,
|
|
67405
|
+
enabled: bool(row.enabled),
|
|
67406
|
+
installed: bool(row.installed),
|
|
67407
|
+
optional: bool(row.optional),
|
|
67408
|
+
removable: bool(row.removable)
|
|
67409
|
+
};
|
|
67410
|
+
if (description !== undefined)
|
|
67411
|
+
projected.description = description;
|
|
67412
|
+
if (readOnlyReason !== undefined)
|
|
67413
|
+
projected.readOnlyReason = readOnlyReason;
|
|
67414
|
+
if (error !== undefined)
|
|
67415
|
+
projected.error = error;
|
|
67416
|
+
out.push(projected);
|
|
67417
|
+
}
|
|
67418
|
+
return out;
|
|
67419
|
+
}
|
|
67420
|
+
function projectPluginRows(raw) {
|
|
67421
|
+
const value = unwrapWireValue(raw);
|
|
67422
|
+
if (!Array.isArray(value))
|
|
67423
|
+
return [];
|
|
67424
|
+
const out = [];
|
|
67425
|
+
for (const entry of value) {
|
|
67426
|
+
const row = asRecord7(entry);
|
|
67427
|
+
const name = text(row.name, MAX_SHORT) ?? text(row.id, MAX_SHORT);
|
|
67428
|
+
if (name === undefined || name === "")
|
|
67429
|
+
continue;
|
|
67430
|
+
out.push({ name, version: text(row.version, MAX_SHORT) ?? "" });
|
|
67431
|
+
}
|
|
67432
|
+
return out;
|
|
67433
|
+
}
|
|
67434
|
+
function projectDetail(raw) {
|
|
67435
|
+
const value = unwrapWireValue(raw);
|
|
67436
|
+
const row = asRecord7(value);
|
|
67437
|
+
if (row.status === "found") {
|
|
67438
|
+
const origin = row.origin === "locale" || row.origin === "readme" ? row.origin : "readme";
|
|
67439
|
+
return {
|
|
67440
|
+
status: "found",
|
|
67441
|
+
origin,
|
|
67442
|
+
path: text(row.path, MAX_SHORT) ?? "",
|
|
67443
|
+
markdown: text(row.markdown) ?? ""
|
|
67444
|
+
};
|
|
67445
|
+
}
|
|
67446
|
+
return { status: "none" };
|
|
67447
|
+
}
|
|
67448
|
+
function projectRegistries(raw) {
|
|
67449
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67450
|
+
const fallback = Array.isArray(row.fallbackRegistries) ? row.fallbackRegistries.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "") : [];
|
|
66369
67451
|
return {
|
|
66370
|
-
|
|
66371
|
-
|
|
66372
|
-
|
|
66373
|
-
...row.base !== undefined ? { base: row.base } : {},
|
|
66374
|
-
...row.autoGenerate !== undefined ? { autoGenerate: row.autoGenerate } : {},
|
|
66375
|
-
...row.schema !== undefined ? { schema: row.schema } : {},
|
|
66376
|
-
...row.user !== undefined ? { user: row.user } : {},
|
|
66377
|
-
...row.secrets !== undefined ? { secrets: row.secrets.map((secret) => ({ path: [...secret.path], set: secret.set })) } : {}
|
|
67452
|
+
registry: text(row.registry, MAX_SHORT) ?? null,
|
|
67453
|
+
fallbackRegistries: fallback,
|
|
67454
|
+
resolved: text(row.resolved, MAX_SHORT) ?? null
|
|
66378
67455
|
};
|
|
66379
67456
|
}
|
|
66380
|
-
|
|
66381
|
-
|
|
66382
|
-
|
|
66383
|
-
|
|
66384
|
-
|
|
66385
|
-
|
|
67457
|
+
function projectVersionExemptions(raw) {
|
|
67458
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67459
|
+
const exemptions = {};
|
|
67460
|
+
const src = asRecord7(row.exemptions);
|
|
67461
|
+
for (const [key, versions] of Object.entries(src)) {
|
|
67462
|
+
exemptions[text(key, MAX_SHORT) ?? ""] = Array.isArray(versions) ? versions.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "") : [];
|
|
67463
|
+
}
|
|
67464
|
+
const warnings = Array.isArray(row.warnings) ? row.warnings.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "") : [];
|
|
67465
|
+
return { exemptions, warnings };
|
|
67466
|
+
}
|
|
67467
|
+
function projectInspection(raw) {
|
|
67468
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67469
|
+
if (row.status === "refused") {
|
|
67470
|
+
return {
|
|
67471
|
+
status: "refused",
|
|
67472
|
+
problem: text(row.problem, MAX_SHORT) ?? "unknown",
|
|
67473
|
+
reason: text(row.reason) ?? ""
|
|
67474
|
+
};
|
|
67475
|
+
}
|
|
67476
|
+
const bundle = row.bundle === true ? true : row.bundle === false ? false : null;
|
|
67477
|
+
const accepted = { status: "accepted", bundle };
|
|
67478
|
+
const name = text(row.name, MAX_SHORT);
|
|
67479
|
+
const version = text(row.version, MAX_SHORT);
|
|
67480
|
+
const description = text(row.description);
|
|
67481
|
+
if (name !== undefined)
|
|
67482
|
+
accepted.name = name;
|
|
67483
|
+
if (version !== undefined)
|
|
67484
|
+
accepted.version = version;
|
|
67485
|
+
if (description !== undefined)
|
|
67486
|
+
accepted.description = description;
|
|
67487
|
+
return accepted;
|
|
67488
|
+
}
|
|
67489
|
+
function projectVersions(raw) {
|
|
67490
|
+
const value = unwrapWireValue(raw);
|
|
67491
|
+
if (!Array.isArray(value))
|
|
67492
|
+
return [];
|
|
67493
|
+
return value.map((v) => text(v, MAX_SHORT) ?? "").filter((v) => v !== "");
|
|
67494
|
+
}
|
|
67495
|
+
function projectChange(raw) {
|
|
67496
|
+
const value = unwrapWireValue(raw);
|
|
67497
|
+
const row = asRecord7(value);
|
|
67498
|
+
const application = row.application;
|
|
67499
|
+
const safeApplication = application === "applied" || application === "restart-required" || application === "overridden" || application === "failed" || application === "cancelled" ? application : "failed";
|
|
67500
|
+
const target = text(row.target, MAX_SHORT) ?? "";
|
|
67501
|
+
const requestId = text(row.requestId, MAX_SHORT);
|
|
67502
|
+
const errorObj = row.error;
|
|
67503
|
+
const error = typeof errorObj === "string" ? errorObj.slice(0, MAX_SHORT) : text(asRecord7(errorObj).diagnostic, MAX_SHORT) ?? text(asRecord7(errorObj).code, MAX_SHORT);
|
|
67504
|
+
const out = {
|
|
67505
|
+
changed: safeApplication === "failed" ? false : row.changed === true,
|
|
67506
|
+
application: safeApplication,
|
|
67507
|
+
target
|
|
67508
|
+
};
|
|
67509
|
+
if (error !== undefined)
|
|
67510
|
+
out.error = error;
|
|
67511
|
+
if (requestId !== undefined && requestId !== "")
|
|
67512
|
+
out.requestId = requestId;
|
|
67513
|
+
return out;
|
|
67514
|
+
}
|
|
67515
|
+
function projectInstallProgress(raw, requestId) {
|
|
67516
|
+
if (raw === null || raw === undefined)
|
|
67517
|
+
return { state: "done", requestId };
|
|
67518
|
+
const value = unwrapWireValue(raw);
|
|
67519
|
+
if (value === null || value === undefined)
|
|
67520
|
+
return { state: "done", requestId };
|
|
67521
|
+
const row = asRecord7(value);
|
|
67522
|
+
const application = row.application;
|
|
67523
|
+
const target = text(row.target, MAX_SHORT) ?? "";
|
|
67524
|
+
if (application === "cancelled")
|
|
67525
|
+
return { state: "cancelled", requestId, target };
|
|
67526
|
+
if (application === "failed") {
|
|
67527
|
+
const errorObj = row.error;
|
|
67528
|
+
const error = typeof errorObj === "string" ? errorObj.slice(0, MAX_SHORT) : text(asRecord7(errorObj).diagnostic, MAX_SHORT) ?? text(asRecord7(errorObj).code, MAX_SHORT);
|
|
67529
|
+
return error !== undefined ? { state: "failed", requestId, target, error } : { state: "failed", requestId, target };
|
|
67530
|
+
}
|
|
67531
|
+
if (application === "applied" || application === "restart-required" || application === "overridden") {
|
|
67532
|
+
return { state: "done", requestId, target };
|
|
67533
|
+
}
|
|
67534
|
+
return { state: "unknown", requestId };
|
|
67535
|
+
}
|
|
67536
|
+
function projectCancellation(raw) {
|
|
67537
|
+
const row = asRecord7(unwrapWireValue(raw));
|
|
67538
|
+
const status = row.status;
|
|
67539
|
+
if (status === "cancelled" || status === "too-late" || status === "not-running")
|
|
67540
|
+
return { status };
|
|
67541
|
+
return { status: "not-running" };
|
|
67542
|
+
}
|
|
67543
|
+
var MAX_TEXT = 4096, MAX_SHORT = 240;
|
|
67544
|
+
|
|
67545
|
+
// src/client/bridge-directory.ts
|
|
67546
|
+
function asRecord8(value) {
|
|
67547
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
67548
|
+
}
|
|
67549
|
+
function unwrapWireValue2(raw) {
|
|
67550
|
+
const rec = asRecord8(raw);
|
|
67551
|
+
if (Object.prototype.hasOwnProperty.call(rec, "value"))
|
|
67552
|
+
return rec.value;
|
|
67553
|
+
return raw;
|
|
67554
|
+
}
|
|
67555
|
+
function text2(value, max = MAX_TEXT2) {
|
|
67556
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
67557
|
+
}
|
|
67558
|
+
function projectLlmProviders(raw) {
|
|
67559
|
+
const value = unwrapWireValue2(raw);
|
|
67560
|
+
if (!Array.isArray(value))
|
|
67561
|
+
return [];
|
|
67562
|
+
const out = [];
|
|
67563
|
+
for (const entry of value) {
|
|
67564
|
+
const row = asRecord8(entry);
|
|
67565
|
+
const id = text2(row.id, MAX_SHORT2);
|
|
67566
|
+
const name = text2(row.name, MAX_SHORT2);
|
|
67567
|
+
if (id === undefined || id === "" || name === undefined)
|
|
67568
|
+
continue;
|
|
67569
|
+
out.push({ id, name });
|
|
67570
|
+
if (out.length >= MAX_ROWS2)
|
|
67571
|
+
break;
|
|
67572
|
+
}
|
|
67573
|
+
return out;
|
|
67574
|
+
}
|
|
67575
|
+
function envNames(value) {
|
|
67576
|
+
if (!Array.isArray(value))
|
|
67577
|
+
return;
|
|
67578
|
+
const names = [];
|
|
67579
|
+
for (const item of value) {
|
|
67580
|
+
if (typeof item === "string" && item.length > 0 && names.length < 16)
|
|
67581
|
+
names.push(item.slice(0, MAX_SHORT2));
|
|
67582
|
+
}
|
|
67583
|
+
return names.length > 0 ? names : undefined;
|
|
67584
|
+
}
|
|
67585
|
+
function projectConfigurableProviders(raw) {
|
|
67586
|
+
const value = unwrapWireValue2(raw);
|
|
67587
|
+
if (!Array.isArray(value))
|
|
67588
|
+
return [];
|
|
67589
|
+
const out = [];
|
|
67590
|
+
for (const entry of value) {
|
|
67591
|
+
const row = asRecord8(entry);
|
|
67592
|
+
const provider = text2(row.provider, MAX_SHORT2);
|
|
67593
|
+
const displayName = text2(row.displayName, MAX_SHORT2);
|
|
67594
|
+
if (provider === undefined || provider === "" || displayName === undefined)
|
|
67595
|
+
continue;
|
|
67596
|
+
const projected = { provider, displayName };
|
|
67597
|
+
const settingsNs = text2(row.settingsNs, MAX_SHORT2);
|
|
67598
|
+
if (settingsNs !== undefined)
|
|
67599
|
+
projected.settingsNs = settingsNs;
|
|
67600
|
+
if (row.declared === true || row.declared === false)
|
|
67601
|
+
projected.declared = row.declared;
|
|
67602
|
+
const auth = asRecord8(row.nativeAuth);
|
|
67603
|
+
const authEnv = envNames(auth.env);
|
|
67604
|
+
if (authEnv !== undefined)
|
|
67605
|
+
projected.authEnvNames = authEnv;
|
|
67606
|
+
const baseEnv = envNames(row.baseURLEnv);
|
|
67607
|
+
if (baseEnv !== undefined) {
|
|
67608
|
+
projected.authEnvNames = [...projected.authEnvNames ?? [], ...baseEnv].slice(0, 16);
|
|
67609
|
+
}
|
|
67610
|
+
const error = text2(row.error, MAX_SHORT2);
|
|
67611
|
+
if (error !== undefined)
|
|
67612
|
+
projected.error = error;
|
|
67613
|
+
out.push(projected);
|
|
67614
|
+
if (out.length >= MAX_ROWS2)
|
|
67615
|
+
break;
|
|
67616
|
+
}
|
|
67617
|
+
return out;
|
|
67618
|
+
}
|
|
67619
|
+
function projectOptions(value) {
|
|
67620
|
+
if (!Array.isArray(value))
|
|
67621
|
+
return [];
|
|
67622
|
+
const out = [];
|
|
67623
|
+
for (const entry of value) {
|
|
67624
|
+
const row = asRecord8(entry);
|
|
67625
|
+
const key = text2(row.value, MAX_SHORT2);
|
|
67626
|
+
if (key === undefined || key === "")
|
|
67627
|
+
continue;
|
|
67628
|
+
const opt = { value: key };
|
|
67629
|
+
const name = text2(row.name, MAX_SHORT2);
|
|
67630
|
+
if (name !== undefined)
|
|
67631
|
+
opt.name = name;
|
|
67632
|
+
const description = text2(row.description, MAX_TEXT2);
|
|
67633
|
+
if (description !== undefined)
|
|
67634
|
+
opt.description = description;
|
|
67635
|
+
out.push(opt);
|
|
67636
|
+
if (out.length >= MAX_ROWS2)
|
|
67637
|
+
break;
|
|
67638
|
+
}
|
|
67639
|
+
return out;
|
|
67640
|
+
}
|
|
67641
|
+
function projectPermissionCatalog(raw) {
|
|
67642
|
+
const value = unwrapWireValue2(raw);
|
|
67643
|
+
const rec = asRecord8(value);
|
|
67644
|
+
const options = projectOptions(rec.options);
|
|
67645
|
+
const defaultOptions = projectOptions(rec.defaultOptions);
|
|
67646
|
+
const defaultPreset = text2(rec.defaultPreset, MAX_SHORT2) ?? "";
|
|
67647
|
+
if (options.length === 0 && defaultOptions.length === 0 && defaultPreset === "")
|
|
67648
|
+
return;
|
|
67649
|
+
return { options, defaultOptions, defaultPreset };
|
|
67650
|
+
}
|
|
67651
|
+
function cappedNumber(value) {
|
|
67652
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.min(value, MAX_NUM) : undefined;
|
|
67653
|
+
}
|
|
67654
|
+
function projectDiscoverModels(raw) {
|
|
67655
|
+
const value = unwrapWireValue2(raw);
|
|
67656
|
+
if (!Array.isArray(value))
|
|
67657
|
+
return [];
|
|
67658
|
+
const out = [];
|
|
67659
|
+
for (const entry of value) {
|
|
67660
|
+
const row = asRecord8(entry);
|
|
67661
|
+
const id = text2(row.id, MAX_SHORT2);
|
|
67662
|
+
if (id === undefined || id === "")
|
|
67663
|
+
continue;
|
|
67664
|
+
const projected = { id };
|
|
67665
|
+
const name = text2(row.name, MAX_SHORT2);
|
|
67666
|
+
if (name !== undefined)
|
|
67667
|
+
projected.name = name;
|
|
67668
|
+
const cw = cappedNumber(row.contextWindow);
|
|
67669
|
+
if (cw !== undefined)
|
|
67670
|
+
projected.contextWindow = cw;
|
|
67671
|
+
const mt = cappedNumber(row.maxTokens);
|
|
67672
|
+
if (mt !== undefined)
|
|
67673
|
+
projected.maxTokens = mt;
|
|
67674
|
+
if (Array.isArray(row.inputModalities)) {
|
|
67675
|
+
const mods = row.inputModalities.filter((m) => m === "text" || m === "image").slice(0, 4);
|
|
67676
|
+
if (mods.length > 0)
|
|
67677
|
+
projected.inputModalities = mods;
|
|
67678
|
+
}
|
|
67679
|
+
out.push(projected);
|
|
67680
|
+
if (out.length >= MAX_ROWS2)
|
|
67681
|
+
break;
|
|
67682
|
+
}
|
|
67683
|
+
return out;
|
|
67684
|
+
}
|
|
67685
|
+
var MAX_TEXT2 = 4096, MAX_SHORT2 = 240, MAX_ROWS2 = 512, MAX_NUM = 1e7;
|
|
67686
|
+
|
|
67687
|
+
// src/client/bridge-goals.ts
|
|
67688
|
+
function asRecord9(value) {
|
|
67689
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
67690
|
+
}
|
|
67691
|
+
function unwrapGoalsValue(raw) {
|
|
67692
|
+
const rec = asRecord9(raw);
|
|
67693
|
+
if (Object.prototype.hasOwnProperty.call(rec, "value"))
|
|
67694
|
+
return rec.value;
|
|
67695
|
+
return raw;
|
|
67696
|
+
}
|
|
67697
|
+
function text3(value, max = MAX_TEXT3) {
|
|
67698
|
+
return typeof value === "string" ? value.slice(0, max) : undefined;
|
|
67699
|
+
}
|
|
67700
|
+
function finiteNumber(value) {
|
|
67701
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
67702
|
+
}
|
|
67703
|
+
function oneOf(value, set) {
|
|
67704
|
+
return typeof value === "string" && set.includes(value) ? value : undefined;
|
|
67705
|
+
}
|
|
67706
|
+
function projectGoalRef(raw) {
|
|
67707
|
+
const rec = asRecord9(unwrapGoalsValue(raw));
|
|
67708
|
+
const id = text3(rec.id, MAX_SHORT3);
|
|
67709
|
+
const revision = finiteNumber(rec.revision);
|
|
67710
|
+
if (id === undefined || id === "" || revision === undefined)
|
|
67711
|
+
return;
|
|
67712
|
+
return { id, revision };
|
|
67713
|
+
}
|
|
67714
|
+
function projectGoalView(raw) {
|
|
67715
|
+
const value = unwrapGoalsValue(raw);
|
|
67716
|
+
if (value === null || value === undefined)
|
|
67717
|
+
return;
|
|
67718
|
+
const rec = asRecord9(value);
|
|
67719
|
+
const id = text3(rec.id, MAX_SHORT3);
|
|
67720
|
+
const revision = finiteNumber(rec.revision);
|
|
67721
|
+
const objective = text3(rec.objective, MAX_TEXT3);
|
|
67722
|
+
const phase = oneOf(rec.phase, PHASES);
|
|
67723
|
+
const activation = oneOf(rec.activation, ACTIVATIONS);
|
|
67724
|
+
const roundsStarted = finiteNumber(rec.roundsStarted);
|
|
67725
|
+
const maxGoalRounds = finiteNumber(rec.maxGoalRounds);
|
|
67726
|
+
const createdAt = finiteNumber(rec.createdAt);
|
|
67727
|
+
const updatedAt = finiteNumber(rec.updatedAt);
|
|
67728
|
+
if (id === undefined || id === "" || revision === undefined || objective === undefined || phase === undefined || activation === undefined || roundsStarted === undefined || maxGoalRounds === undefined || createdAt === undefined || updatedAt === undefined)
|
|
67729
|
+
return;
|
|
67730
|
+
const view = {
|
|
67731
|
+
id,
|
|
67732
|
+
revision,
|
|
67733
|
+
objective,
|
|
67734
|
+
phase,
|
|
67735
|
+
activation,
|
|
67736
|
+
roundsStarted,
|
|
67737
|
+
maxGoalRounds,
|
|
67738
|
+
createdAt,
|
|
67739
|
+
updatedAt
|
|
67740
|
+
};
|
|
67741
|
+
const reason = asRecord9(rec.blockedReason);
|
|
67742
|
+
const code = text3(reason.code, MAX_SHORT3);
|
|
67743
|
+
const message = text3(reason.message, MAX_TEXT3);
|
|
67744
|
+
if (code !== undefined && message !== undefined)
|
|
67745
|
+
view.blockedReason = { code, message };
|
|
67746
|
+
return view;
|
|
67747
|
+
}
|
|
67748
|
+
function projectCreateGoalResult(raw) {
|
|
67749
|
+
const rec = asRecord9(unwrapGoalsValue(raw));
|
|
67750
|
+
return projectGoalRef(rec.ref);
|
|
67751
|
+
}
|
|
67752
|
+
var MAX_TEXT3 = 4096, MAX_SHORT3 = 240, PHASES, ACTIVATIONS;
|
|
67753
|
+
var init_bridge_goals = __esm(() => {
|
|
67754
|
+
PHASES = ["active", "paused", "blocked", "complete"];
|
|
67755
|
+
ACTIVATIONS = ["armed", "disarmed"];
|
|
66386
67756
|
});
|
|
66387
67757
|
|
|
66388
67758
|
// src/client/bridge-session-seam.ts
|
|
67759
|
+
import { existsSync as existsSync13, readFileSync as readFileSync14, readdirSync as readdirSync4 } from "fs";
|
|
67760
|
+
import { join as join16 } from "path";
|
|
67761
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
67762
|
+
function writeConfirmed(confirm) {
|
|
67763
|
+
return typeof confirm === "object" && confirm !== null && confirm.__pluginWriteConfirm === true && typeof confirm.operation === "string";
|
|
67764
|
+
}
|
|
66389
67765
|
function askTurnId(eventId) {
|
|
66390
67766
|
const i = eventId.lastIndexOf(":ask-");
|
|
66391
67767
|
return i === -1 ? "" : eventId.slice(0, i);
|
|
@@ -66395,7 +67771,7 @@ function optionalStringField(row, key) {
|
|
|
66395
67771
|
return typeof value === "string" && value !== "" ? value : undefined;
|
|
66396
67772
|
}
|
|
66397
67773
|
function parseAskRequest(value) {
|
|
66398
|
-
const row =
|
|
67774
|
+
const row = asRecord10(value);
|
|
66399
67775
|
const eventId = optionalStringField(row, "eventId");
|
|
66400
67776
|
const sessionId = optionalStringField(row, "sessionId");
|
|
66401
67777
|
const kind = row.kind;
|
|
@@ -66418,14 +67794,14 @@ function parseAskRequest(value) {
|
|
|
66418
67794
|
if (Array.isArray(row.questions)) {
|
|
66419
67795
|
const questions = [];
|
|
66420
67796
|
for (const raw of row.questions) {
|
|
66421
|
-
const q =
|
|
67797
|
+
const q = asRecord10(raw);
|
|
66422
67798
|
const id = optionalStringField(q, "id");
|
|
66423
67799
|
const prompt = optionalStringField(q, "prompt");
|
|
66424
67800
|
if (id === undefined || prompt === undefined || !Array.isArray(q.options))
|
|
66425
67801
|
continue;
|
|
66426
67802
|
const options = [];
|
|
66427
67803
|
for (const rawOpt of q.options) {
|
|
66428
|
-
const opt =
|
|
67804
|
+
const opt = asRecord10(rawOpt);
|
|
66429
67805
|
const label = optionalStringField(opt, "label");
|
|
66430
67806
|
if (label === undefined)
|
|
66431
67807
|
continue;
|
|
@@ -66495,9 +67871,25 @@ function answersFor(request, picks) {
|
|
|
66495
67871
|
function unavailableResponse(request) {
|
|
66496
67872
|
return request.kind === "questions" ? { eventId: request.eventId, kind: "questions", verdict: "unavailable", answers: answersFor(request, []) } : { eventId: request.eventId, kind: "approval", verdict: "unavailable" };
|
|
66497
67873
|
}
|
|
66498
|
-
function
|
|
67874
|
+
function asRecord10(value) {
|
|
66499
67875
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
66500
67876
|
}
|
|
67877
|
+
function projectSeamAccountView(value) {
|
|
67878
|
+
const v = asRecord10(value);
|
|
67879
|
+
return {
|
|
67880
|
+
status: typeof v.status === "string" && ACCOUNT_STATUSES.has(v.status) ? v.status : null,
|
|
67881
|
+
attemptPhase: typeof v.attemptPhase === "string" && ACCOUNT_PHASES.has(v.attemptPhase) ? v.attemptPhase : null,
|
|
67882
|
+
authorizeUrlReady: v.authorizeUrlReady === true,
|
|
67883
|
+
linksPresent: v.linksPresent === true
|
|
67884
|
+
};
|
|
67885
|
+
}
|
|
67886
|
+
function accountClientMeta() {
|
|
67887
|
+
return {
|
|
67888
|
+
version: "0.25-w1b",
|
|
67889
|
+
locale: typeof Intl !== "undefined" ? Intl.DateTimeFormat().resolvedOptions().locale : "en",
|
|
67890
|
+
timezoneOffsetSeconds: -new Date().getTimezoneOffset() * 60
|
|
67891
|
+
};
|
|
67892
|
+
}
|
|
66501
67893
|
function unsupported(capability) {
|
|
66502
67894
|
throw new BridgeProtocolError("UNSUPPORTED", `${capability} is not backed by the in-process bridge`, { capability });
|
|
66503
67895
|
}
|
|
@@ -66505,14 +67897,14 @@ function projectBridgeSessionList(items, limit = 12) {
|
|
|
66505
67897
|
const rows = Array.isArray(items) ? items : [];
|
|
66506
67898
|
const out = [];
|
|
66507
67899
|
for (const item of rows) {
|
|
66508
|
-
const row =
|
|
67900
|
+
const row = asRecord10(item);
|
|
66509
67901
|
if (row.origin === "subagent")
|
|
66510
67902
|
continue;
|
|
66511
67903
|
const id = typeof row.sessionId === "string" ? row.sessionId : "";
|
|
66512
67904
|
if (!id)
|
|
66513
67905
|
continue;
|
|
66514
67906
|
const updatedAt = typeof row.updatedAt === "number" ? String(row.updatedAt) : "";
|
|
66515
|
-
const values =
|
|
67907
|
+
const values = asRecord10(asRecord10(row.projections).values);
|
|
66516
67908
|
const title = typeof values.title === "string" ? values.title : "";
|
|
66517
67909
|
out.push({
|
|
66518
67910
|
id,
|
|
@@ -66530,7 +67922,7 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
|
|
|
66530
67922
|
type: row.type,
|
|
66531
67923
|
seq: row.seq,
|
|
66532
67924
|
time: 0,
|
|
66533
|
-
data:
|
|
67925
|
+
data: asRecord10(row.payload)
|
|
66534
67926
|
}));
|
|
66535
67927
|
const durable = journalToTranscriptRows(entries, skip);
|
|
66536
67928
|
return durable.map((row) => {
|
|
@@ -66544,8 +67936,8 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
|
|
|
66544
67936
|
});
|
|
66545
67937
|
}
|
|
66546
67938
|
function seamReplayEventKey(event) {
|
|
66547
|
-
const details =
|
|
66548
|
-
return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(
|
|
67939
|
+
const details = asRecord10(event.details);
|
|
67940
|
+
return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord10(details.part).id ?? "")}`;
|
|
66549
67941
|
}
|
|
66550
67942
|
function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
66551
67943
|
const events = [];
|
|
@@ -66559,7 +67951,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
|
66559
67951
|
};
|
|
66560
67952
|
const toolCalls = new Map;
|
|
66561
67953
|
for (const row of rows) {
|
|
66562
|
-
const entry = { type: row.type, seq: row.seq, time: 0, data:
|
|
67954
|
+
const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord10(row.payload) };
|
|
66563
67955
|
for (const event of projectJournalRecord(entry, sessionId))
|
|
66564
67956
|
push(event);
|
|
66565
67957
|
const data = entry.data;
|
|
@@ -66573,7 +67965,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
|
|
|
66573
67965
|
});
|
|
66574
67966
|
}
|
|
66575
67967
|
} else if (row.type === "tool/result") {
|
|
66576
|
-
const message =
|
|
67968
|
+
const message = asRecord10(data.message);
|
|
66577
67969
|
const callId = data.callId !== undefined ? String(data.callId) : message.toolCallId !== undefined ? String(message.toolCallId) : "";
|
|
66578
67970
|
const call = callId ? toolCalls.get(callId) : undefined;
|
|
66579
67971
|
if (call !== undefined) {
|
|
@@ -66627,7 +68019,7 @@ function bridgeSettleChild(existing, outcome, startedAt, now) {
|
|
|
66627
68019
|
}
|
|
66628
68020
|
function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, live) {
|
|
66629
68021
|
if (type === "user/message") {
|
|
66630
|
-
const source =
|
|
68022
|
+
const source = asRecord10(data.source);
|
|
66631
68023
|
if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
|
|
66632
68024
|
return false;
|
|
66633
68025
|
const childId = typeof source.senderSessionId === "string" ? source.senderSessionId : "";
|
|
@@ -66722,7 +68114,7 @@ function bridgeSweepSettledChildIds(rows, parentId, locallyRunning) {
|
|
|
66722
68114
|
return [];
|
|
66723
68115
|
const settled = [];
|
|
66724
68116
|
for (const raw of rows) {
|
|
66725
|
-
const row =
|
|
68117
|
+
const row = asRecord10(raw);
|
|
66726
68118
|
if (row.origin !== "subagent")
|
|
66727
68119
|
continue;
|
|
66728
68120
|
if (row.parentSessionId !== parentId)
|
|
@@ -66772,16 +68164,16 @@ function bridgeChildJournalMeta(rows) {
|
|
|
66772
68164
|
let contextModel;
|
|
66773
68165
|
let descriptorModel;
|
|
66774
68166
|
for (const row of rows) {
|
|
66775
|
-
const data =
|
|
68167
|
+
const data = asRecord10(row.payload);
|
|
66776
68168
|
if (row.type === "assistant/message") {
|
|
66777
68169
|
rounds += 1;
|
|
66778
|
-
const message =
|
|
68170
|
+
const message = asRecord10(data.message);
|
|
66779
68171
|
const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
|
|
66780
68172
|
if (tail !== undefined)
|
|
66781
68173
|
lastLine = tail;
|
|
66782
68174
|
} else if (row.type === "tool/result") {
|
|
66783
68175
|
if (data.isError !== true) {
|
|
66784
|
-
const message =
|
|
68176
|
+
const message = asRecord10(data.message);
|
|
66785
68177
|
const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
|
|
66786
68178
|
if (tail !== undefined)
|
|
66787
68179
|
lastLine = tail;
|
|
@@ -66803,12 +68195,23 @@ function bridgeChildJournalMeta(rows) {
|
|
|
66803
68195
|
...model !== undefined ? { model } : {}
|
|
66804
68196
|
};
|
|
66805
68197
|
}
|
|
68198
|
+
function bridgeReplayRowsToChildLog(rows) {
|
|
68199
|
+
return bridgeReplayRowsToSeamTranscript(rows).map((row) => {
|
|
68200
|
+
if (row.kind === "tool") {
|
|
68201
|
+
return row.output ? `\u25B6 ${row.text}
|
|
68202
|
+
\u23BF ${row.output}` : `\u25B6 ${row.text}`;
|
|
68203
|
+
}
|
|
68204
|
+
if (row.kind === "ask")
|
|
68205
|
+
return "[ask]";
|
|
68206
|
+
return row.text;
|
|
68207
|
+
}).filter((line) => line !== "");
|
|
68208
|
+
}
|
|
66806
68209
|
function bridgeChildStopReason(rows) {
|
|
66807
68210
|
for (let i = rows.length - 1;i >= 0; i -= 1) {
|
|
66808
68211
|
const row = rows[i];
|
|
66809
68212
|
if (row.type !== "user/message")
|
|
66810
68213
|
continue;
|
|
66811
|
-
const source =
|
|
68214
|
+
const source = asRecord10(asRecord10(row.payload).source);
|
|
66812
68215
|
if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
|
|
66813
68216
|
continue;
|
|
66814
68217
|
const reason = source.stopReason;
|
|
@@ -66819,7 +68222,7 @@ function bridgeChildStopReason(rows) {
|
|
|
66819
68222
|
const row = rows[i];
|
|
66820
68223
|
if (row.type !== "turn/end")
|
|
66821
68224
|
continue;
|
|
66822
|
-
const reason =
|
|
68225
|
+
const reason = asRecord10(asRecord10(row.payload).reason);
|
|
66823
68226
|
const kind = reason.kind;
|
|
66824
68227
|
if (typeof kind === "string" && kind !== "")
|
|
66825
68228
|
return kind;
|
|
@@ -66877,7 +68280,7 @@ function lastJournalTurnTerminal(rows, startOutsideWindow = false) {
|
|
|
66877
68280
|
return latest;
|
|
66878
68281
|
}
|
|
66879
68282
|
function journalTurnId(row) {
|
|
66880
|
-
const payload =
|
|
68283
|
+
const payload = asRecord10(row.payload);
|
|
66881
68284
|
if (typeof payload.turn === "number" && Number.isFinite(payload.turn))
|
|
66882
68285
|
return payload.turn;
|
|
66883
68286
|
if (typeof payload.turnId === "string" && payload.turnId !== "")
|
|
@@ -66885,7 +68288,7 @@ function journalTurnId(row) {
|
|
|
66885
68288
|
return;
|
|
66886
68289
|
}
|
|
66887
68290
|
function projectBridgeEvent(frame, sessionId) {
|
|
66888
|
-
const payload =
|
|
68291
|
+
const payload = asRecord10(frame.payload);
|
|
66889
68292
|
const turnId = typeof payload.turnId === "string" ? payload.turnId : "";
|
|
66890
68293
|
if (frame.type === "turn.start") {
|
|
66891
68294
|
return [{ type: "session.updated", details: { sessionID: sessionId, turnId, turn: "starting" } }];
|
|
@@ -66907,7 +68310,7 @@ function projectBridgeEvent(frame, sessionId) {
|
|
|
66907
68310
|
return [];
|
|
66908
68311
|
}
|
|
66909
68312
|
function parseUsage(value) {
|
|
66910
|
-
const u =
|
|
68313
|
+
const u = asRecord10(value);
|
|
66911
68314
|
const num = (...aliases) => {
|
|
66912
68315
|
let present = false;
|
|
66913
68316
|
let best = 0;
|
|
@@ -66936,7 +68339,7 @@ function parseUsage(value) {
|
|
|
66936
68339
|
return out;
|
|
66937
68340
|
}
|
|
66938
68341
|
function journalUsage(payload) {
|
|
66939
|
-
const usage =
|
|
68342
|
+
const usage = asRecord10(asRecord10(payload).usage);
|
|
66940
68343
|
const parsed = parseUsage(usage);
|
|
66941
68344
|
if (Object.keys(parsed).length === 0)
|
|
66942
68345
|
return;
|
|
@@ -66946,7 +68349,7 @@ function journalUsage(payload) {
|
|
|
66946
68349
|
return { ...parsed, total };
|
|
66947
68350
|
}
|
|
66948
68351
|
function asDeadCause(value) {
|
|
66949
|
-
const r =
|
|
68352
|
+
const r = asRecord10(value);
|
|
66950
68353
|
const stage = r.stage;
|
|
66951
68354
|
const stages = ["spawn", "handshake", "runtime", "closed"];
|
|
66952
68355
|
return {
|
|
@@ -66962,6 +68365,285 @@ function asDeadCause(value) {
|
|
|
66962
68365
|
class BridgeSessionSeam {
|
|
66963
68366
|
#transport;
|
|
66964
68367
|
#ctx;
|
|
68368
|
+
#dshHome;
|
|
68369
|
+
#profile;
|
|
68370
|
+
#configStore;
|
|
68371
|
+
#settingsStore;
|
|
68372
|
+
#localAgents;
|
|
68373
|
+
#localPresets;
|
|
68374
|
+
#localLogin;
|
|
68375
|
+
#pluginBundlesCache = [];
|
|
68376
|
+
#pluginsManagerAvailable = undefined;
|
|
68377
|
+
#goalsAvailable = undefined;
|
|
68378
|
+
settings = {
|
|
68379
|
+
describe: () => Promise.resolve(this.#settingsStore.describe()),
|
|
68380
|
+
mutate: (ns, ops, revision) => Promise.resolve(this.#settingsStore.mutate(ns, ops, revision)),
|
|
68381
|
+
identity: () => ({ profile: this.#profile, dshHome: this.#dshHome }),
|
|
68382
|
+
permissionCatalog: () => this.#readPermissionCatalog()
|
|
68383
|
+
};
|
|
68384
|
+
providerDirectory = {
|
|
68385
|
+
registered: () => this.#directoryRequest("llm.listProviders", projectLlmProviders),
|
|
68386
|
+
configurable: () => this.#directoryRequest("llm.listConfigurableProviders", projectConfigurableProviders),
|
|
68387
|
+
discover: (settingsNs, request) => this.#directoryRequest("llm.discoverModels", projectDiscoverModels, { settingsNs, request })
|
|
68388
|
+
};
|
|
68389
|
+
goals = {
|
|
68390
|
+
status: () => this.#goalsRequest("goals.get", {}, projectGoalView),
|
|
68391
|
+
available: () => this.#goalsAvailable === true,
|
|
68392
|
+
create: (objective, maxGoalRounds) => {
|
|
68393
|
+
const request = { objective };
|
|
68394
|
+
if (maxGoalRounds !== undefined)
|
|
68395
|
+
request.maxGoalRounds = maxGoalRounds;
|
|
68396
|
+
return this.#goalsRequest("goals.create", { request }, projectCreateGoalResult);
|
|
68397
|
+
},
|
|
68398
|
+
edit: (ref, patch) => this.#goalsRequest("goals.edit", { ref, request: patch }, projectGoalView),
|
|
68399
|
+
complete: (ref) => this.#goalsRequest("goals.complete", { ref }, projectGoalView),
|
|
68400
|
+
pause: (ref) => this.#goalsRequest("goals.pause", { ref }, projectGoalView),
|
|
68401
|
+
resume: (ref) => this.#goalsRequest("goals.resume", { ref }, projectGoalView),
|
|
68402
|
+
clear: (ref) => this.#goalsRequest("goals.clear", { ref }, projectGoalRef)
|
|
68403
|
+
};
|
|
68404
|
+
agents = {
|
|
68405
|
+
list: () => this.#localAgents.list(),
|
|
68406
|
+
dir: () => this.#localAgents.dir(),
|
|
68407
|
+
set: (name, field, value) => this.#localAgents.set(name, field, value),
|
|
68408
|
+
body: (name) => this.#localAgents.body(name),
|
|
68409
|
+
modelEfforts: (providerID, modelID) => this.#localAgents.modelEfforts(providerID, modelID),
|
|
68410
|
+
officialCaps: () => this.#localAgents.officialCaps()
|
|
68411
|
+
};
|
|
68412
|
+
preset = {
|
|
68413
|
+
list: () => Promise.resolve(this.#localPresets.list()),
|
|
68414
|
+
currentId: () => Promise.resolve(this.#localPresets.currentId()),
|
|
68415
|
+
select: (presetId) => Promise.resolve(this.#localPresets.select(presetId))
|
|
68416
|
+
};
|
|
68417
|
+
login = {
|
|
68418
|
+
credentialStatus: (ref) => Promise.resolve(this.#localLogin.credentialStatus(ref)),
|
|
68419
|
+
login: (ref, apiKey) => {
|
|
68420
|
+
this.#localLogin.login(ref, apiKey);
|
|
68421
|
+
return Promise.resolve();
|
|
68422
|
+
},
|
|
68423
|
+
logout: (ref) => {
|
|
68424
|
+
this.#localLogin.logout(ref);
|
|
68425
|
+
return Promise.resolve();
|
|
68426
|
+
},
|
|
68427
|
+
routes: () => Promise.resolve(this.#localLogin.routes()),
|
|
68428
|
+
registerRoute: (providerId, profile) => Promise.resolve(this.#localLogin.registerRoute(providerId, profile))
|
|
68429
|
+
};
|
|
68430
|
+
account = {
|
|
68431
|
+
getState: async () => projectSeamAccountView(await this.#transport.request("account.getState")),
|
|
68432
|
+
startSignIn: async (callbackOrigin, loginSource) => projectSeamAccountView(await this.#transport.request("account.startSignIn", { client: accountClientMeta(), callbackOrigin, loginSource })),
|
|
68433
|
+
cancelSignIn: async (attemptId) => projectSeamAccountView(await this.#transport.request("account.cancelSignIn", { attemptId })),
|
|
68434
|
+
signOut: async () => projectSeamAccountView(await this.#transport.request("account.signOut", { client: accountClientMeta() })),
|
|
68435
|
+
hasRunningAccountTasks: async () => {
|
|
68436
|
+
const value = asRecord10(await this.#transport.request("account.hasRunningAccountTasks"));
|
|
68437
|
+
return value.running === true;
|
|
68438
|
+
}
|
|
68439
|
+
};
|
|
68440
|
+
plugins() {
|
|
68441
|
+
const root = join16(this.#dshHome, "profiles", this.#profile, "node_modules");
|
|
68442
|
+
if (!existsSync13(root))
|
|
68443
|
+
return [];
|
|
68444
|
+
const out = [];
|
|
68445
|
+
const seen = new Set;
|
|
68446
|
+
const readPkg = (dir, fallbackName) => {
|
|
68447
|
+
try {
|
|
68448
|
+
const pkg = JSON.parse(readFileSync14(join16(dir, "package.json"), "utf8"));
|
|
68449
|
+
const name = typeof pkg.name === "string" && pkg.name ? pkg.name : fallbackName;
|
|
68450
|
+
const version = typeof pkg.version === "string" ? pkg.version : "";
|
|
68451
|
+
if (name.startsWith("@deepseek-ai/") || name.startsWith("@aiwayds/"))
|
|
68452
|
+
return;
|
|
68453
|
+
if (seen.has(name))
|
|
68454
|
+
return;
|
|
68455
|
+
seen.add(name);
|
|
68456
|
+
out.push({ name, version });
|
|
68457
|
+
} catch {}
|
|
68458
|
+
};
|
|
68459
|
+
let entries = [];
|
|
68460
|
+
try {
|
|
68461
|
+
entries = readdirSync4(root);
|
|
68462
|
+
} catch {
|
|
68463
|
+
return [];
|
|
68464
|
+
}
|
|
68465
|
+
for (const entry of entries) {
|
|
68466
|
+
if (entry.startsWith("."))
|
|
68467
|
+
continue;
|
|
68468
|
+
if (entry.startsWith("@")) {
|
|
68469
|
+
let scoped = [];
|
|
68470
|
+
try {
|
|
68471
|
+
scoped = readdirSync4(join16(root, entry));
|
|
68472
|
+
} catch {
|
|
68473
|
+
continue;
|
|
68474
|
+
}
|
|
68475
|
+
for (const sub of scoped) {
|
|
68476
|
+
if (sub.startsWith("."))
|
|
68477
|
+
continue;
|
|
68478
|
+
readPkg(join16(root, entry, sub), `${entry}/${sub}`);
|
|
68479
|
+
}
|
|
68480
|
+
} else {
|
|
68481
|
+
readPkg(join16(root, entry), entry);
|
|
68482
|
+
}
|
|
68483
|
+
}
|
|
68484
|
+
return out;
|
|
68485
|
+
}
|
|
68486
|
+
async#directoryRequest(method, project, params) {
|
|
68487
|
+
const reply = params === undefined ? await this.#transport.request(method) : await this.#transport.request(method, params);
|
|
68488
|
+
return project(reply);
|
|
68489
|
+
}
|
|
68490
|
+
async#readPermissionCatalog() {
|
|
68491
|
+
try {
|
|
68492
|
+
const reply = await this.#transport.request("permissionPresets.catalog");
|
|
68493
|
+
return projectPermissionCatalog(reply);
|
|
68494
|
+
} catch {
|
|
68495
|
+
return;
|
|
68496
|
+
}
|
|
68497
|
+
}
|
|
68498
|
+
async#goalsRequest(method, extraParams, project) {
|
|
68499
|
+
const agentId = this.currentSessionId();
|
|
68500
|
+
if (agentId === undefined || agentId === "") {
|
|
68501
|
+
throw new BridgeProtocolError("UNSUPPORTED", `${method}: no active session (agentId unavailable)`);
|
|
68502
|
+
}
|
|
68503
|
+
try {
|
|
68504
|
+
const reply = await this.#transport.request(method, { agentId, ...extraParams });
|
|
68505
|
+
this.#goalsAvailable = true;
|
|
68506
|
+
return project(reply);
|
|
68507
|
+
} catch (err) {
|
|
68508
|
+
const code = err instanceof BridgeProtocolError ? err.code : undefined;
|
|
68509
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
68510
|
+
const serviceAbsent = code === "UNSUPPORTED" || code === "NOT_WIRED" || code === "UNAVAILABLE" || code === undefined && (/^NOT_WIRED/.test(message) || /unavailable/i.test(message));
|
|
68511
|
+
if (serviceAbsent) {
|
|
68512
|
+
this.#goalsAvailable = false;
|
|
68513
|
+
throw new BridgeProtocolError("UNSUPPORTED", `${method}: ${message}`);
|
|
68514
|
+
}
|
|
68515
|
+
throw err;
|
|
68516
|
+
}
|
|
68517
|
+
}
|
|
68518
|
+
async#pmRequest(method, params, project) {
|
|
68519
|
+
try {
|
|
68520
|
+
const reply = await this.#transport.request(method, params);
|
|
68521
|
+
const projected = project(reply);
|
|
68522
|
+
this.#pluginsManagerAvailable = true;
|
|
68523
|
+
return projected;
|
|
68524
|
+
} catch (err) {
|
|
68525
|
+
const code = err instanceof BridgeProtocolError ? err.code : undefined;
|
|
68526
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
68527
|
+
const serviceAbsent = code === "UNSUPPORTED" || code === "NOT_WIRED" || code === "UNAVAILABLE" || code === undefined && (/^NOT_WIRED/.test(message) || /unavailable/i.test(message));
|
|
68528
|
+
if (serviceAbsent) {
|
|
68529
|
+
this.#pluginsManagerAvailable = false;
|
|
68530
|
+
throw new BridgeProtocolError("UNSUPPORTED", `${method}: ${message}`);
|
|
68531
|
+
}
|
|
68532
|
+
throw err;
|
|
68533
|
+
}
|
|
68534
|
+
}
|
|
68535
|
+
async#pmConfirmed(method, params, confirm, project) {
|
|
68536
|
+
if (!writeConfirmed(confirm))
|
|
68537
|
+
throw CONFIRM_REQUIRED(method);
|
|
68538
|
+
return this.#pmRequest(method, { ...params, __confirm: true }, project);
|
|
68539
|
+
}
|
|
68540
|
+
async#pmWrite(method, params, confirm, target) {
|
|
68541
|
+
const reply = await this.#pmConfirmed(method, params, confirm, projectChange);
|
|
68542
|
+
if (reply.target === "" && target !== "")
|
|
68543
|
+
reply.target = target;
|
|
68544
|
+
this.refreshPluginBundles();
|
|
68545
|
+
return reply;
|
|
68546
|
+
}
|
|
68547
|
+
pluginsManager = {
|
|
68548
|
+
listBundles: async () => {
|
|
68549
|
+
const rows = await this.#pmRequest("pluginManager.listBundles", {}, projectBundleRows);
|
|
68550
|
+
this.#pluginBundlesCache = rows;
|
|
68551
|
+
return rows;
|
|
68552
|
+
},
|
|
68553
|
+
listPlugins: async () => this.#pmRequest("pluginManager.listPlugins", {}, projectPluginRows),
|
|
68554
|
+
readBundleDetail: async (name, language) => this.#pmRequest("pluginManager.readBundleDetail", { name, language }, projectDetail),
|
|
68555
|
+
registries: async () => this.#pmRequest("pluginManager.registries", {}, projectRegistries),
|
|
68556
|
+
listVersions: async (name) => this.#pmRequest("pluginManager.listVersions", { name }, projectVersions),
|
|
68557
|
+
listVersionExemptions: async () => this.#pmRequest("pluginManager.listVersionExemptions", {}, projectVersionExemptions),
|
|
68558
|
+
inspect: async (spec) => this.#pmRequest("pluginManager.inspect", { spec }, projectInspection),
|
|
68559
|
+
available: () => this.#pluginsManagerAvailable
|
|
68560
|
+
};
|
|
68561
|
+
setPluginBundleEnabled = (name, enabled, confirm) => this.#pmWrite("pluginManager.setBundleEnabled", { name, enabled }, confirm, name);
|
|
68562
|
+
removePluginBundle = (name, confirm) => this.#pmWrite("pluginManager.removeBundle", { name }, confirm, name);
|
|
68563
|
+
inspectPluginSpec = (spec) => this.pluginsManager.inspect(spec);
|
|
68564
|
+
installPluginSpec = async (spec, confirm, requestIdArg) => {
|
|
68565
|
+
const requestId = requestIdArg ?? `w23-${randomUUID9()}`;
|
|
68566
|
+
const change = await this.#pmWrite("pluginManager.installBundle", { spec, options: { enabled: true, requestId } }, confirm, spec);
|
|
68567
|
+
change.requestId = requestId;
|
|
68568
|
+
return change;
|
|
68569
|
+
};
|
|
68570
|
+
updatePluginBundle = (name, version, confirm) => this.#pmWrite("pluginManager.updateBundle", { name, version, options: {} }, confirm, name);
|
|
68571
|
+
setPluginEnabled = (id, enabled, confirm) => this.#pmWrite("pluginManager.setPluginEnabled", { id, enabled }, confirm, id);
|
|
68572
|
+
setVersionExemption = (packageVersion, runtimeVersion, enabled, acceptRisk, confirm) => this.#pmWrite("pluginManager.setVersionExemption", { packageVersion, runtimeVersion, enabled, acceptRisk }, confirm, `${packageVersion}@${runtimeVersion}`);
|
|
68573
|
+
waitForInstall = (requestId, confirm) => this.#pmConfirmed("pluginManager.waitForInstall", { requestId }, confirm, (raw) => projectInstallProgress(raw, requestId));
|
|
68574
|
+
cancelInstall = (requestId, confirm) => this.#pmConfirmed("pluginManager.cancelInstall", { requestId }, confirm, projectCancellation);
|
|
68575
|
+
async refreshPluginBundles() {
|
|
68576
|
+
try {
|
|
68577
|
+
await this.pluginsManager.listBundles();
|
|
68578
|
+
} catch {}
|
|
68579
|
+
}
|
|
68580
|
+
pluginBundles() {
|
|
68581
|
+
if (this.#pluginsManagerAvailable === true)
|
|
68582
|
+
return [...this.#pluginBundlesCache];
|
|
68583
|
+
return this.plugins().map((row) => ({
|
|
68584
|
+
name: row.name,
|
|
68585
|
+
version: row.version,
|
|
68586
|
+
enabled: false,
|
|
68587
|
+
installed: true,
|
|
68588
|
+
optional: false,
|
|
68589
|
+
removable: false,
|
|
68590
|
+
stateUnknown: true
|
|
68591
|
+
}));
|
|
68592
|
+
}
|
|
68593
|
+
thinking = {
|
|
68594
|
+
efforts: () => this.#catalogEfforts(),
|
|
68595
|
+
effortsFor: (providerID, modelID) => this.#catalogEfforts(providerID, modelID),
|
|
68596
|
+
currentEffort: async () => {
|
|
68597
|
+
const selection = await this.#transport.request("model.currentSelection");
|
|
68598
|
+
const value = asRecord10(selection).reasoningEffort;
|
|
68599
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
68600
|
+
},
|
|
68601
|
+
selectEffort: async (effort) => {
|
|
68602
|
+
const selection = await this.currentModelSelection();
|
|
68603
|
+
if (selection === undefined)
|
|
68604
|
+
return unsupported("selectEffort");
|
|
68605
|
+
const sessionId = this.#currentSessionId ?? this.stagedSessionId();
|
|
68606
|
+
const reply = await this.#transport.request("selectModel", {
|
|
68607
|
+
provider: selection.providerID,
|
|
68608
|
+
model: selection.modelID,
|
|
68609
|
+
...effort === undefined ? {} : { reasoningEffort: effort },
|
|
68610
|
+
...sessionId !== undefined && sessionId !== "" ? { sessionId } : {}
|
|
68611
|
+
});
|
|
68612
|
+
const r = reply;
|
|
68613
|
+
if (r === undefined || r === null || r.selected === undefined) {
|
|
68614
|
+
return unsupported("selectEffort");
|
|
68615
|
+
}
|
|
68616
|
+
}
|
|
68617
|
+
};
|
|
68618
|
+
async#catalogEfforts(providerID, modelID) {
|
|
68619
|
+
const raw = await this.#transport.request("modelCatalog");
|
|
68620
|
+
if (raw === undefined || raw === null || !Array.isArray(raw.groups))
|
|
68621
|
+
return [];
|
|
68622
|
+
let group = raw.groups.find((g) => typeof g?.id === "string" && g.id === providerID);
|
|
68623
|
+
let model = group?.models?.find((m) => typeof m?.id === "string" && m.id === modelID);
|
|
68624
|
+
if (providerID === undefined || modelID === undefined) {
|
|
68625
|
+
const d = raw.default;
|
|
68626
|
+
group = raw.groups.find((g) => typeof g?.id === "string" && g.id === d?.provider) ?? raw.groups[0];
|
|
68627
|
+
model = group?.models?.find((m) => typeof m?.id === "string" && m.id === d?.model) ?? group?.models?.[0];
|
|
68628
|
+
}
|
|
68629
|
+
const efforts = model?.reasoning?.efforts;
|
|
68630
|
+
if (!Array.isArray(efforts))
|
|
68631
|
+
return [];
|
|
68632
|
+
const out = [];
|
|
68633
|
+
for (const e of efforts) {
|
|
68634
|
+
const row = asRecord10(e);
|
|
68635
|
+
const id = typeof row.id === "string" ? row.id : "";
|
|
68636
|
+
const name = typeof row.name === "string" ? row.name : "";
|
|
68637
|
+
if (!id)
|
|
68638
|
+
continue;
|
|
68639
|
+
out.push({
|
|
68640
|
+
id,
|
|
68641
|
+
name: name || id,
|
|
68642
|
+
...typeof row.description === "string" && row.description !== "" ? { description: row.description } : {}
|
|
68643
|
+
});
|
|
68644
|
+
}
|
|
68645
|
+
return out;
|
|
68646
|
+
}
|
|
66965
68647
|
#unsubEvent;
|
|
66966
68648
|
#listeners = [];
|
|
66967
68649
|
#onDead;
|
|
@@ -66972,6 +68654,7 @@ class BridgeSessionSeam {
|
|
|
66972
68654
|
#subagentSessionId;
|
|
66973
68655
|
#subagentJournalLoaded = new Set;
|
|
66974
68656
|
#subagentJournalMeta = new Map;
|
|
68657
|
+
#subagentTranscripts = new Map;
|
|
66975
68658
|
#sweepSettledRuns = new Map;
|
|
66976
68659
|
#subagentSettleSnapshots = new Map;
|
|
66977
68660
|
#interruptInFlight = new Map;
|
|
@@ -66989,11 +68672,16 @@ class BridgeSessionSeam {
|
|
|
66989
68672
|
#recoveryState = "idle";
|
|
66990
68673
|
#pendingOpen;
|
|
66991
68674
|
#inFlightTurnId;
|
|
68675
|
+
#sideSessionInFlight = false;
|
|
68676
|
+
#lastSideSessionId;
|
|
66992
68677
|
#activeCallbacks;
|
|
66993
68678
|
#turnDone;
|
|
66994
68679
|
#turnGeneration = 0;
|
|
66995
68680
|
#inFlightGeneration = 0;
|
|
66996
68681
|
#degradedOnce = new Set;
|
|
68682
|
+
#capPushListeners = new Map;
|
|
68683
|
+
#capPushStatus = new Map;
|
|
68684
|
+
#capPushDrops = new Map;
|
|
66997
68685
|
#usage = { turns: 0, prompt: 0, completion: 0, cacheRead: 0, cacheWrite: 0 };
|
|
66998
68686
|
#decodeWindowStart;
|
|
66999
68687
|
#lastTurnDecode;
|
|
@@ -67014,6 +68702,19 @@ class BridgeSessionSeam {
|
|
|
67014
68702
|
constructor(options) {
|
|
67015
68703
|
this.#transport = options.transport;
|
|
67016
68704
|
this.#ctx = options.ctx;
|
|
68705
|
+
this.#dshHome = options.dshHome ?? resolveDshHome();
|
|
68706
|
+
this.#profile = options.profile ?? DEFAULT_PROFILE;
|
|
68707
|
+
const workspaceDir = options.workspaceDir ?? process.cwd();
|
|
68708
|
+
this.#settingsStore = new LocalSettingsStore(this.#dshHome, this.#profile);
|
|
68709
|
+
this.#configStore = new LocalConfigStore(this.#dshHome, this.#profile, workspaceDir);
|
|
68710
|
+
this.#localAgents = new LocalAgentsFace({
|
|
68711
|
+
home: this.#dshHome,
|
|
68712
|
+
workspaceDir,
|
|
68713
|
+
settings: this.#settingsStore,
|
|
68714
|
+
modelCatalog: () => this.#transport.request("modelCatalog")
|
|
68715
|
+
});
|
|
68716
|
+
this.#localPresets = new LocalPresetFace(this.#dshHome, this.#profile);
|
|
68717
|
+
this.#localLogin = new LocalLoginFace(this.#dshHome, this.#profile);
|
|
67017
68718
|
this.#onDead = options.onDead;
|
|
67018
68719
|
this.#onPermissionUnavailable = options.onPermissionUnavailable;
|
|
67019
68720
|
this.#confirmClock = options.confirmClock ?? {
|
|
@@ -67027,7 +68728,7 @@ class BridgeSessionSeam {
|
|
|
67027
68728
|
}
|
|
67028
68729
|
async connect() {
|
|
67029
68730
|
try {
|
|
67030
|
-
const reply =
|
|
68731
|
+
const reply = asRecord10(await this.#transport.request("bridge.ping"));
|
|
67031
68732
|
this.#recordBridgeCapabilities(reply.capabilities);
|
|
67032
68733
|
this.#connection = "connected";
|
|
67033
68734
|
} catch (err) {
|
|
@@ -67114,7 +68815,7 @@ class BridgeSessionSeam {
|
|
|
67114
68815
|
this.#replayDrainPending = true;
|
|
67115
68816
|
let opened;
|
|
67116
68817
|
try {
|
|
67117
|
-
opened =
|
|
68818
|
+
opened = asRecord10(await this.#transport.request("session.open", { mode: "resume", id: sessionId }));
|
|
67118
68819
|
} catch (err) {
|
|
67119
68820
|
const code = err instanceof BridgeProtocolError ? err.code : "SESSION_OPEN_FAILED";
|
|
67120
68821
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -67124,7 +68825,7 @@ class BridgeSessionSeam {
|
|
|
67124
68825
|
this.#bufferedPendingSnapshot = undefined;
|
|
67125
68826
|
this.#replayDrainPending = false;
|
|
67126
68827
|
this.#settleSuspendedTurn();
|
|
67127
|
-
const errorDetail = err instanceof BridgeProtocolError ?
|
|
68828
|
+
const errorDetail = err instanceof BridgeProtocolError ? asRecord10(err.detail) : {};
|
|
67128
68829
|
const holder = typeof errorDetail.holder === "string" && errorDetail.holder.trim() !== "" ? errorDetail.holder : undefined;
|
|
67129
68830
|
const result = {
|
|
67130
68831
|
state: "locked",
|
|
@@ -67199,7 +68900,7 @@ class BridgeSessionSeam {
|
|
|
67199
68900
|
turnId: dead.turnId,
|
|
67200
68901
|
seq: terminal.seq,
|
|
67201
68902
|
terminalType: terminal.type,
|
|
67202
|
-
reason:
|
|
68903
|
+
reason: asRecord10(terminal.payload).reason,
|
|
67203
68904
|
payload: terminal.payload,
|
|
67204
68905
|
source: "journal"
|
|
67205
68906
|
}
|
|
@@ -67233,6 +68934,11 @@ class BridgeSessionSeam {
|
|
|
67233
68934
|
this.#connection = "connected";
|
|
67234
68935
|
this.#bridgeLink = "ready";
|
|
67235
68936
|
this.#recoveryState = "attached";
|
|
68937
|
+
for (const [key, status] of this.#capPushStatus) {
|
|
68938
|
+
if (status.sessionId !== boundId)
|
|
68939
|
+
continue;
|
|
68940
|
+
this.#capPushStatus.set(key, { ...status, state: "attached", lastSeq: 0 });
|
|
68941
|
+
}
|
|
67236
68942
|
const result = {
|
|
67237
68943
|
state: "attached",
|
|
67238
68944
|
sessionId: boundId,
|
|
@@ -67252,7 +68958,7 @@ class BridgeSessionSeam {
|
|
|
67252
68958
|
const seen = new Set;
|
|
67253
68959
|
const collected = [];
|
|
67254
68960
|
for (;; ) {
|
|
67255
|
-
const value =
|
|
68961
|
+
const value = asRecord10(await this.#transport.request("journal.replay", { sessionId, from }));
|
|
67256
68962
|
const rawRows = Array.isArray(value.rows) ? value.rows : [];
|
|
67257
68963
|
if (typeof value.cursor === "number" && Number.isFinite(value.cursor))
|
|
67258
68964
|
cursor = value.cursor;
|
|
@@ -67265,7 +68971,7 @@ class BridgeSessionSeam {
|
|
|
67265
68971
|
let added = 0;
|
|
67266
68972
|
let pageMax = from - 1;
|
|
67267
68973
|
for (const raw of rawRows) {
|
|
67268
|
-
const row =
|
|
68974
|
+
const row = asRecord10(raw);
|
|
67269
68975
|
const seq = row.seq;
|
|
67270
68976
|
if (typeof seq !== "number" || !Number.isFinite(seq) || seq < floor || seen.has(seq))
|
|
67271
68977
|
continue;
|
|
@@ -67314,7 +69020,7 @@ class BridgeSessionSeam {
|
|
|
67314
69020
|
};
|
|
67315
69021
|
const attempt = (remaining) => {
|
|
67316
69022
|
this.#transport.request("turn.abort", { turnId }).then((result) => {
|
|
67317
|
-
if (
|
|
69023
|
+
if (asRecord10(result).noop === true) {
|
|
67318
69024
|
fail(`turn.abort was a noop for turn ${turnId}; turn may still be running`, "TURN_ABORT_NOOP");
|
|
67319
69025
|
}
|
|
67320
69026
|
}).catch((err) => {
|
|
@@ -67450,7 +69156,7 @@ class BridgeSessionSeam {
|
|
|
67450
69156
|
stats.contextTokens = usage.total;
|
|
67451
69157
|
}
|
|
67452
69158
|
} else if (row.type === "request/context") {
|
|
67453
|
-
const data =
|
|
69159
|
+
const data = asRecord10(row.payload);
|
|
67454
69160
|
const window = data.contextWindow;
|
|
67455
69161
|
if (typeof window === "number" && Number.isFinite(window) && window > 0) {
|
|
67456
69162
|
const provider = typeof data.provider === "string" ? data.provider : "";
|
|
@@ -67501,6 +69207,49 @@ class BridgeSessionSeam {
|
|
|
67501
69207
|
contextWindow: this.#liveContextWindow()
|
|
67502
69208
|
};
|
|
67503
69209
|
}
|
|
69210
|
+
onCapPush(sessionId, listener) {
|
|
69211
|
+
let set = this.#capPushListeners.get(sessionId);
|
|
69212
|
+
if (set === undefined) {
|
|
69213
|
+
set = new Set;
|
|
69214
|
+
this.#capPushListeners.set(sessionId, set);
|
|
69215
|
+
}
|
|
69216
|
+
set.add(listener);
|
|
69217
|
+
return () => {
|
|
69218
|
+
const current = this.#capPushListeners.get(sessionId);
|
|
69219
|
+
if (current === undefined)
|
|
69220
|
+
return;
|
|
69221
|
+
current.delete(listener);
|
|
69222
|
+
if (current.size === 0)
|
|
69223
|
+
this.#capPushListeners.delete(sessionId);
|
|
69224
|
+
};
|
|
69225
|
+
}
|
|
69226
|
+
capPushStatus(sessionId) {
|
|
69227
|
+
let seen = false;
|
|
69228
|
+
let state = "attached";
|
|
69229
|
+
let lastSeq = 0;
|
|
69230
|
+
for (const status of this.#capPushStatus.values()) {
|
|
69231
|
+
if (status.sessionId !== sessionId)
|
|
69232
|
+
continue;
|
|
69233
|
+
seen = true;
|
|
69234
|
+
lastSeq = Math.max(lastSeq, status.lastSeq);
|
|
69235
|
+
if (status.state === "disconnected")
|
|
69236
|
+
state = "disconnected";
|
|
69237
|
+
else if (status.state === "degraded" && state === "attached")
|
|
69238
|
+
state = "degraded";
|
|
69239
|
+
}
|
|
69240
|
+
return seen ? { sessionId, state, lastSeq } : undefined;
|
|
69241
|
+
}
|
|
69242
|
+
capPushDropCount(sessionId, methodId) {
|
|
69243
|
+
if (methodId !== undefined) {
|
|
69244
|
+
return this.#capPushDrops.get(`${sessionId}|${methodId}`)?.count ?? 0;
|
|
69245
|
+
}
|
|
69246
|
+
let total = 0;
|
|
69247
|
+
for (const drop of this.#capPushDrops.values()) {
|
|
69248
|
+
if (drop.sessionId === sessionId)
|
|
69249
|
+
total += drop.count;
|
|
69250
|
+
}
|
|
69251
|
+
return total;
|
|
69252
|
+
}
|
|
67504
69253
|
onSessionEvent(listener) {
|
|
67505
69254
|
this.#degradeOnce("onSessionEvent", "only turn.* lifecycle/error events project; permission.asked / bridge.shutdown absent");
|
|
67506
69255
|
this.#listeners.push(listener);
|
|
@@ -67513,6 +69262,24 @@ class BridgeSessionSeam {
|
|
|
67513
69262
|
subagentViews() {
|
|
67514
69263
|
return [...this.#subagentViews.values()].map((view) => ({ ...view }));
|
|
67515
69264
|
}
|
|
69265
|
+
subagentTranscript(id) {
|
|
69266
|
+
return [...this.#subagentTranscripts.get(id) ?? []];
|
|
69267
|
+
}
|
|
69268
|
+
steerChild(id, text) {
|
|
69269
|
+
const view = this.#subagentViews.get(id);
|
|
69270
|
+
if (view === undefined || view.status !== "running")
|
|
69271
|
+
return false;
|
|
69272
|
+
const requestId = `${id}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
69273
|
+
this.#transport.request("subagents.prompt", {
|
|
69274
|
+
requestId,
|
|
69275
|
+
childSessionId: id,
|
|
69276
|
+
delivery: "steer",
|
|
69277
|
+
content: [{ type: "text", text }]
|
|
69278
|
+
}).catch((err) => {
|
|
69279
|
+
this.#degrade("steerChild", `subagents.prompt failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
69280
|
+
});
|
|
69281
|
+
return true;
|
|
69282
|
+
}
|
|
67516
69283
|
async interruptChild(childId) {
|
|
67517
69284
|
const parentSessionId = this.#currentSessionId;
|
|
67518
69285
|
if (parentSessionId === undefined || parentSessionId === "") {
|
|
@@ -67523,7 +69290,7 @@ class BridgeSessionSeam {
|
|
|
67523
69290
|
this.#interruptInFlight.set(childId, generation);
|
|
67524
69291
|
let value;
|
|
67525
69292
|
try {
|
|
67526
|
-
value =
|
|
69293
|
+
value = asRecord10(await this.#transport.request("subagents.interrupt", { parentSessionId, childId }));
|
|
67527
69294
|
} catch (err) {
|
|
67528
69295
|
if (this.#interruptInFlight.get(childId) === generation)
|
|
67529
69296
|
this.#interruptInFlight.delete(childId);
|
|
@@ -67549,13 +69316,13 @@ class BridgeSessionSeam {
|
|
|
67549
69316
|
if (parentSessionId === undefined || parentSessionId === "") {
|
|
67550
69317
|
throw new BridgeProtocolError("NO_SESSION", "cannot stop children: no session is bound to this bridge connection");
|
|
67551
69318
|
}
|
|
67552
|
-
const value =
|
|
69319
|
+
const value = asRecord10(await this.#transport.request("subagents.stopChildren", { parentSessionId }));
|
|
67553
69320
|
const children = value.children;
|
|
67554
69321
|
if (!Array.isArray(children))
|
|
67555
69322
|
return [];
|
|
67556
69323
|
const sessionAtStart = this.#subagentSessionId;
|
|
67557
69324
|
const rows = children.map((row) => {
|
|
67558
|
-
const r =
|
|
69325
|
+
const r = asRecord10(row);
|
|
67559
69326
|
return {
|
|
67560
69327
|
childId: typeof r.childId === "string" ? r.childId : "",
|
|
67561
69328
|
disposition: typeof r.disposition === "string" ? r.disposition : "failed"
|
|
@@ -67581,10 +69348,10 @@ class BridgeSessionSeam {
|
|
|
67581
69348
|
return;
|
|
67582
69349
|
let stopped = false;
|
|
67583
69350
|
try {
|
|
67584
|
-
const items =
|
|
69351
|
+
const items = asRecord10(await this.#transport.request("session.list", { _request: {} })).items;
|
|
67585
69352
|
if (Array.isArray(items)) {
|
|
67586
69353
|
stopped = items.some((row) => {
|
|
67587
|
-
const item =
|
|
69354
|
+
const item = asRecord10(row);
|
|
67588
69355
|
return item.sessionId === childId && item.running === false;
|
|
67589
69356
|
});
|
|
67590
69357
|
}
|
|
@@ -67594,7 +69361,7 @@ class BridgeSessionSeam {
|
|
|
67594
69361
|
if (stopped) {
|
|
67595
69362
|
let reason = "aborted";
|
|
67596
69363
|
try {
|
|
67597
|
-
const rows =
|
|
69364
|
+
const rows = asRecord10(await this.#transport.request("journal.replay", { sessionId: childId })).rows;
|
|
67598
69365
|
if (Array.isArray(rows)) {
|
|
67599
69366
|
const clean = rows.filter((row) => row !== null && typeof row === "object" && !Array.isArray(row));
|
|
67600
69367
|
reason = bridgeChildStopReason(clean) ?? "aborted";
|
|
@@ -67653,7 +69420,7 @@ class BridgeSessionSeam {
|
|
|
67653
69420
|
} catch {
|
|
67654
69421
|
return;
|
|
67655
69422
|
}
|
|
67656
|
-
const items =
|
|
69423
|
+
const items = asRecord10(value).items;
|
|
67657
69424
|
if (!Array.isArray(items))
|
|
67658
69425
|
return;
|
|
67659
69426
|
const locallyRunning = new Set;
|
|
@@ -67698,7 +69465,7 @@ class BridgeSessionSeam {
|
|
|
67698
69465
|
this.#subagentJournalLoaded.add(key);
|
|
67699
69466
|
const sessionAtStart = this.#subagentSessionId;
|
|
67700
69467
|
try {
|
|
67701
|
-
const value =
|
|
69468
|
+
const value = asRecord10(await this.#transport.request("journal.replay", { sessionId: childId }));
|
|
67702
69469
|
const rows = value.rows;
|
|
67703
69470
|
if (!Array.isArray(rows))
|
|
67704
69471
|
return;
|
|
@@ -67706,6 +69473,7 @@ class BridgeSessionSeam {
|
|
|
67706
69473
|
const meta = bridgeChildJournalMeta(cleanRows);
|
|
67707
69474
|
if (this.#subagentSessionId !== sessionAtStart || this.#disposed)
|
|
67708
69475
|
return;
|
|
69476
|
+
this.#subagentTranscripts.set(childId, bridgeReplayRowsToChildLog(cleanRows));
|
|
67709
69477
|
this.#subagentJournalMeta.set(key, meta);
|
|
67710
69478
|
const existing = this.#subagentViews.get(childId);
|
|
67711
69479
|
if (existing === undefined || bridgeChildJournalKey(existing) !== key)
|
|
@@ -67804,7 +69572,7 @@ class BridgeSessionSeam {
|
|
|
67804
69572
|
}
|
|
67805
69573
|
}
|
|
67806
69574
|
#foldAgentFrame(frame) {
|
|
67807
|
-
const payload =
|
|
69575
|
+
const payload = asRecord10(frame.payload);
|
|
67808
69576
|
const frameSession = typeof payload.sessionId === "string" ? payload.sessionId : "";
|
|
67809
69577
|
if (this.#subagentSessionId !== undefined && frameSession !== "" && frameSession !== this.#subagentSessionId)
|
|
67810
69578
|
return;
|
|
@@ -67830,6 +69598,7 @@ class BridgeSessionSeam {
|
|
|
67830
69598
|
this.#subagentLiveStarts.clear();
|
|
67831
69599
|
this.#subagentJournalLoaded.clear();
|
|
67832
69600
|
this.#subagentJournalMeta.clear();
|
|
69601
|
+
this.#subagentTranscripts.clear();
|
|
67833
69602
|
this.#sweepSettledRuns.clear();
|
|
67834
69603
|
this.#subagentSettleSnapshots.clear();
|
|
67835
69604
|
this.#interruptInFlight.clear();
|
|
@@ -67840,7 +69609,7 @@ class BridgeSessionSeam {
|
|
|
67840
69609
|
let changed = false;
|
|
67841
69610
|
const now = Date.now();
|
|
67842
69611
|
for (const row of rows) {
|
|
67843
|
-
if (this.#foldWithFrozenSettle(row.type,
|
|
69612
|
+
if (this.#foldWithFrozenSettle(row.type, asRecord10(row.payload), now, false))
|
|
67844
69613
|
changed = true;
|
|
67845
69614
|
}
|
|
67846
69615
|
if (rosterReset || changed) {
|
|
@@ -67849,16 +69618,16 @@ class BridgeSessionSeam {
|
|
|
67849
69618
|
}
|
|
67850
69619
|
}
|
|
67851
69620
|
configLoad() {
|
|
67852
|
-
this.#
|
|
67853
|
-
return {};
|
|
69621
|
+
return this.#configStore.configLoad();
|
|
67854
69622
|
}
|
|
67855
69623
|
configRaw() {
|
|
67856
|
-
this.#
|
|
67857
|
-
return {};
|
|
69624
|
+
return this.#configStore.configRaw();
|
|
67858
69625
|
}
|
|
67859
69626
|
workspaceConfig() {
|
|
67860
|
-
this.#
|
|
67861
|
-
|
|
69627
|
+
return this.#configStore.workspaceConfig();
|
|
69628
|
+
}
|
|
69629
|
+
configSave(patch) {
|
|
69630
|
+
return this.#configStore.configSave(patch);
|
|
67862
69631
|
}
|
|
67863
69632
|
async permissionCatalog() {
|
|
67864
69633
|
const answererReady = this.#askProvider !== undefined || this.#inFlightGeneration !== 0 && this.#activeCallbacks !== undefined || this.#askFrameSeen;
|
|
@@ -67874,20 +69643,41 @@ class BridgeSessionSeam {
|
|
|
67874
69643
|
}
|
|
67875
69644
|
async listSessions(limit) {
|
|
67876
69645
|
const value = await this.#transport.request("session.list");
|
|
67877
|
-
return projectBridgeSessionList(
|
|
69646
|
+
return projectBridgeSessionList(asRecord10(value).items, limit);
|
|
67878
69647
|
}
|
|
67879
69648
|
async storedTranscript(id, skip = 0) {
|
|
67880
69649
|
const value = await this.#transport.request("journal.replay", { sessionId: id });
|
|
67881
|
-
const rows = Array.isArray(
|
|
69650
|
+
const rows = Array.isArray(asRecord10(value).rows) ? asRecord10(value).rows : [];
|
|
67882
69651
|
this.#foldAgentReplayRows(rows, id);
|
|
67883
69652
|
this.#sweepSubagents(id);
|
|
67884
69653
|
return bridgeReplayRowsToSeamTranscript(rows, skip);
|
|
67885
69654
|
}
|
|
69655
|
+
async sessionJournal(id) {
|
|
69656
|
+
const value = await this.#transport.request("journal.replay", { sessionId: id });
|
|
69657
|
+
const rows = Array.isArray(asRecord10(value).rows) ? asRecord10(value).rows : [];
|
|
69658
|
+
return rows.map((row) => ({
|
|
69659
|
+
type: row.type,
|
|
69660
|
+
seq: row.seq,
|
|
69661
|
+
time: 0,
|
|
69662
|
+
data: asRecord10(row.payload)
|
|
69663
|
+
}));
|
|
69664
|
+
}
|
|
69665
|
+
async forkSession(sessionId, seqEnd) {
|
|
69666
|
+
const value = asRecord10(await this.#transport.request("session.fork", {
|
|
69667
|
+
sessionId,
|
|
69668
|
+
...seqEnd !== undefined ? { atSeq: seqEnd } : {}
|
|
69669
|
+
}));
|
|
69670
|
+
const forked = value.sessionId;
|
|
69671
|
+
if (typeof forked !== "string" || forked === "") {
|
|
69672
|
+
throw new BridgeProtocolError("FORK_FAILED", "/history fork: session.fork returned no session id");
|
|
69673
|
+
}
|
|
69674
|
+
return forked;
|
|
69675
|
+
}
|
|
67886
69676
|
async currentModelSelection() {
|
|
67887
69677
|
const selection = await this.#transport.request("model.currentSelection");
|
|
67888
69678
|
if (selection === undefined || selection === null)
|
|
67889
69679
|
return;
|
|
67890
|
-
const s =
|
|
69680
|
+
const s = asRecord10(selection);
|
|
67891
69681
|
const providerID = typeof s.provider === "string" ? s.provider : "";
|
|
67892
69682
|
const modelID = typeof s.model === "string" ? s.model : "";
|
|
67893
69683
|
if (!providerID || !modelID)
|
|
@@ -67924,7 +69714,7 @@ class BridgeSessionSeam {
|
|
|
67924
69714
|
this.#pendingOpen = undefined;
|
|
67925
69715
|
const params = pending.mode === "resume" ? { mode: "resume", id: pending.id, ...this.#sessionAttached ? { replace: true } : {} } : { mode: "new", ...this.#sessionAttached ? { replace: true } : {} };
|
|
67926
69716
|
try {
|
|
67927
|
-
const opened =
|
|
69717
|
+
const opened = asRecord10(await this.#transport.request("session.open", params));
|
|
67928
69718
|
if (typeof opened.sessionId === "string")
|
|
67929
69719
|
this.#currentSessionId = opened.sessionId;
|
|
67930
69720
|
if (this.#lastAppliedSessionId !== this.#currentSessionId) {
|
|
@@ -67941,7 +69731,7 @@ class BridgeSessionSeam {
|
|
|
67941
69731
|
const done = new Promise((resolve) => {
|
|
67942
69732
|
this.#turnDone = resolve;
|
|
67943
69733
|
});
|
|
67944
|
-
const sent =
|
|
69734
|
+
const sent = asRecord10(await this.#transport.request("session.send", { text: userText }));
|
|
67945
69735
|
if (typeof sent.turnId === "string") {
|
|
67946
69736
|
this.#inFlightTurnId = sent.turnId;
|
|
67947
69737
|
this.#emitEvent({
|
|
@@ -68005,8 +69795,44 @@ class BridgeSessionSeam {
|
|
|
68005
69795
|
this.#sessionAttached = false;
|
|
68006
69796
|
this.#currentSessionId = undefined;
|
|
68007
69797
|
}
|
|
68008
|
-
async
|
|
68009
|
-
|
|
69798
|
+
async btwAsk(question, snapshot, onDelta) {
|
|
69799
|
+
if (this.#sideSessionInFlight) {
|
|
69800
|
+
throw new BridgeProtocolError("SIDE_SESSION_BUSY", "/btw: a side question is already running");
|
|
69801
|
+
}
|
|
69802
|
+
this.#sideSessionInFlight = true;
|
|
69803
|
+
try {
|
|
69804
|
+
const result = await runSideSession({
|
|
69805
|
+
rpc: (method, params) => this.#transport.request(method, params),
|
|
69806
|
+
question,
|
|
69807
|
+
snapshot,
|
|
69808
|
+
onDelta,
|
|
69809
|
+
...this.#lastSideSessionId !== undefined ? { sessionId: this.#lastSideSessionId } : {}
|
|
69810
|
+
});
|
|
69811
|
+
this.#lastSideSessionId = result.sessionId;
|
|
69812
|
+
if (result.answer === "") {
|
|
69813
|
+
throw new BridgeProtocolError("SIDE_SESSION_NO_ANSWER", `/btw: side-session produced no answer (${result.reason})${result.truncated ? ", truncated" : ""}`);
|
|
69814
|
+
}
|
|
69815
|
+
return result.answer;
|
|
69816
|
+
} catch (err) {
|
|
69817
|
+
if (err instanceof SideSessionError) {
|
|
69818
|
+
const code = err.code === "SIDE_SESSION_UNAVAILABLE" ? "UNSUPPORTED" : err.code;
|
|
69819
|
+
throw new BridgeProtocolError(code, err.message);
|
|
69820
|
+
}
|
|
69821
|
+
throw err;
|
|
69822
|
+
} finally {
|
|
69823
|
+
this.#sideSessionInFlight = false;
|
|
69824
|
+
}
|
|
69825
|
+
}
|
|
69826
|
+
async searchSessions(query) {
|
|
69827
|
+
const value = asRecord10(await this.#transport.request("session.search", { query }));
|
|
69828
|
+
const rows = Array.isArray(value.items) ? value.items : [];
|
|
69829
|
+
return rows.map((row) => {
|
|
69830
|
+
const r = asRecord10(row);
|
|
69831
|
+
return {
|
|
69832
|
+
id: typeof r.id === "string" ? r.id : "",
|
|
69833
|
+
snippet: typeof r.snippet === "string" ? r.snippet : ""
|
|
69834
|
+
};
|
|
69835
|
+
}).filter((row) => row.id);
|
|
68010
69836
|
}
|
|
68011
69837
|
async renameSession(_title) {
|
|
68012
69838
|
return unsupported("renameSession");
|
|
@@ -68027,10 +69853,35 @@ class BridgeSessionSeam {
|
|
|
68027
69853
|
return unsupported("listProviders");
|
|
68028
69854
|
}
|
|
68029
69855
|
async modelCatalog(_force) {
|
|
68030
|
-
|
|
69856
|
+
const raw = await this.#transport.request("modelCatalog");
|
|
69857
|
+
if (raw === undefined || raw === null || !Array.isArray(raw.groups)) {
|
|
69858
|
+
return unsupported("modelCatalog");
|
|
69859
|
+
}
|
|
69860
|
+
const rows = [];
|
|
69861
|
+
for (const group of raw.groups) {
|
|
69862
|
+
const providerID = typeof group?.id === "string" ? group.id : "";
|
|
69863
|
+
if (!providerID)
|
|
69864
|
+
continue;
|
|
69865
|
+
for (const model of Array.isArray(group.models) ? group.models : []) {
|
|
69866
|
+
const modelID = typeof model?.id === "string" ? model.id : "";
|
|
69867
|
+
if (modelID)
|
|
69868
|
+
rows.push({ providerID, modelID });
|
|
69869
|
+
}
|
|
69870
|
+
}
|
|
69871
|
+
return rows;
|
|
68031
69872
|
}
|
|
68032
|
-
selectModel(
|
|
68033
|
-
|
|
69873
|
+
selectModel(providerID, modelID) {
|
|
69874
|
+
const sessionId = this.#currentSessionId ?? this.stagedSessionId();
|
|
69875
|
+
return this.#transport.request("selectModel", {
|
|
69876
|
+
provider: providerID,
|
|
69877
|
+
model: modelID,
|
|
69878
|
+
...sessionId !== undefined && sessionId !== "" ? { sessionId } : {}
|
|
69879
|
+
}).then((reply) => {
|
|
69880
|
+
const r = reply;
|
|
69881
|
+
if (r === undefined || r === null || r.selected === undefined) {
|
|
69882
|
+
return unsupported("selectModel");
|
|
69883
|
+
}
|
|
69884
|
+
});
|
|
68034
69885
|
}
|
|
68035
69886
|
#approvalParams(request, verdict) {
|
|
68036
69887
|
const base = { eventId: request.eventId, kind: "approval" };
|
|
@@ -68157,7 +70008,7 @@ class BridgeSessionSeam {
|
|
|
68157
70008
|
this.#settlePendingAsk(eventId);
|
|
68158
70009
|
}
|
|
68159
70010
|
#onAskEvent(frame) {
|
|
68160
|
-
const payload =
|
|
70011
|
+
const payload = asRecord10(frame.payload);
|
|
68161
70012
|
if (frame.type === "ask.request" || frame.type === "ask.pending")
|
|
68162
70013
|
this.#askFrameSeen = true;
|
|
68163
70014
|
switch (frame.type) {
|
|
@@ -68214,9 +70065,60 @@ class BridgeSessionSeam {
|
|
|
68214
70065
|
this.#degradedOnce.add(member);
|
|
68215
70066
|
this.#degrade(member, reason);
|
|
68216
70067
|
}
|
|
70068
|
+
#onCapPushEvent(frame) {
|
|
70069
|
+
if (frame.type !== "cap.event" && frame.type !== "cap.end")
|
|
70070
|
+
return false;
|
|
70071
|
+
const payload = asRecord10(frame.payload);
|
|
70072
|
+
const sessionId = optionalStringField(payload, "sessionId");
|
|
70073
|
+
if (sessionId === undefined || sessionId === "")
|
|
70074
|
+
return true;
|
|
70075
|
+
const methodId = optionalStringField(payload, "methodId") ?? "unknown";
|
|
70076
|
+
const key = `${sessionId}|${methodId}`;
|
|
70077
|
+
if (frame.type === "cap.end") {
|
|
70078
|
+
const current = this.#capPushStatus.get(key);
|
|
70079
|
+
this.#capPushStatus.set(key, {
|
|
70080
|
+
sessionId,
|
|
70081
|
+
methodId,
|
|
70082
|
+
state: "degraded",
|
|
70083
|
+
lastSeq: current?.lastSeq ?? 0
|
|
70084
|
+
});
|
|
70085
|
+
const code = optionalStringField(payload, "code");
|
|
70086
|
+
this.#degradeOnce("cap.end", `push stream ${methodId} ended for ${sessionId}${code === undefined ? "" : ` (code=${code})`}`);
|
|
70087
|
+
return true;
|
|
70088
|
+
}
|
|
70089
|
+
const seq = typeof payload.seq === "number" && Number.isInteger(payload.seq) ? payload.seq : 0;
|
|
70090
|
+
const current = this.#capPushStatus.get(key) ?? {
|
|
70091
|
+
sessionId,
|
|
70092
|
+
methodId,
|
|
70093
|
+
state: "attached",
|
|
70094
|
+
lastSeq: 0
|
|
70095
|
+
};
|
|
70096
|
+
if (seq <= current.lastSeq) {
|
|
70097
|
+
const drop = this.#capPushDrops.get(key) ?? { sessionId, methodId, count: 0 };
|
|
70098
|
+
drop.count += 1;
|
|
70099
|
+
this.#capPushDrops.set(key, drop);
|
|
70100
|
+
return true;
|
|
70101
|
+
}
|
|
70102
|
+
const status = { ...current, lastSeq: seq };
|
|
70103
|
+
this.#capPushStatus.set(key, status);
|
|
70104
|
+
const event = {
|
|
70105
|
+
methodId,
|
|
70106
|
+
sessionId,
|
|
70107
|
+
seq,
|
|
70108
|
+
eventType: optionalStringField(payload, "eventType") ?? "event"
|
|
70109
|
+
};
|
|
70110
|
+
for (const listener of [...this.#capPushListeners.get(sessionId) ?? []]) {
|
|
70111
|
+
try {
|
|
70112
|
+
listener(event);
|
|
70113
|
+
} catch {}
|
|
70114
|
+
}
|
|
70115
|
+
return true;
|
|
70116
|
+
}
|
|
68217
70117
|
#onBridgeEvent(frame) {
|
|
68218
70118
|
if (this.#onAskEvent(frame))
|
|
68219
70119
|
return;
|
|
70120
|
+
if (this.#onCapPushEvent(frame))
|
|
70121
|
+
return;
|
|
68220
70122
|
if (frame.type === "agent.spawn" || frame.type === "agent.settle") {
|
|
68221
70123
|
this.#foldAgentFrame(frame);
|
|
68222
70124
|
return;
|
|
@@ -68229,6 +70131,9 @@ class BridgeSessionSeam {
|
|
|
68229
70131
|
this.#bridgeLink = "dead";
|
|
68230
70132
|
this.#connection = "disconnected";
|
|
68231
70133
|
this.#turn = "idle";
|
|
70134
|
+
for (const [key, status] of this.#capPushStatus) {
|
|
70135
|
+
this.#capPushStatus.set(key, { ...status, state: "disconnected" });
|
|
70136
|
+
}
|
|
68232
70137
|
this.#onDead?.(cause);
|
|
68233
70138
|
for (const listener of [...this.#listeners]) {
|
|
68234
70139
|
try {
|
|
@@ -68237,7 +70142,7 @@ class BridgeSessionSeam {
|
|
|
68237
70142
|
}
|
|
68238
70143
|
return;
|
|
68239
70144
|
}
|
|
68240
|
-
const payload =
|
|
70145
|
+
const payload = asRecord10(frame.payload);
|
|
68241
70146
|
if (frame.type === "turn.start") {
|
|
68242
70147
|
this.#turn = "starting";
|
|
68243
70148
|
this.#decodeWindowStart = undefined;
|
|
@@ -68318,11 +70223,16 @@ class BridgeSessionSeam {
|
|
|
68318
70223
|
}
|
|
68319
70224
|
}
|
|
68320
70225
|
}
|
|
68321
|
-
var BridgeProtocolError, BRIDGE_AGENT_START = "tool-workflow/agent-start", BRIDGE_AGENT_END = "tool-workflow/agent-end", BRIDGE_SUBAGENT_CATALOG = "subagent/catalog", BRIDGE_SUBAGENT_SETTLED = "subagent-settled", BRIDGE_CATALOG_RUN_PREFIX = "catalog:", CONFIRM_POLL_INITIAL_MS = 250, CONFIRM_POLL_MAX_MS = 1000, CONFIRM_TIMEOUT_MS = 45000, fmtTokens = (n) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`;
|
|
70226
|
+
var CONFIRM_REQUIRED = (method) => new BridgeProtocolError("CONFIRM_REQUIRED", `${method}: write requires a confirmed TUI modal token`), BridgeProtocolError, ACCOUNT_STATUSES, ACCOUNT_PHASES, BRIDGE_AGENT_START = "tool-workflow/agent-start", BRIDGE_AGENT_END = "tool-workflow/agent-end", BRIDGE_SUBAGENT_CATALOG = "subagent/catalog", BRIDGE_SUBAGENT_SETTLED = "subagent-settled", BRIDGE_CATALOG_RUN_PREFIX = "catalog:", CONFIRM_POLL_INITIAL_MS = 250, CONFIRM_POLL_MAX_MS = 1000, CONFIRM_TIMEOUT_MS = 45000, fmtTokens = (n) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`;
|
|
68322
70227
|
var init_bridge_session_seam = __esm(() => {
|
|
68323
70228
|
init_remote_session_ops();
|
|
68324
|
-
|
|
70229
|
+
init_journal_projection();
|
|
70230
|
+
init_bridge_side_session();
|
|
68325
70231
|
init_loop();
|
|
70232
|
+
init_local_config_faces();
|
|
70233
|
+
init_remote_local_fs();
|
|
70234
|
+
init_lifecycle();
|
|
70235
|
+
init_bridge_goals();
|
|
68326
70236
|
BridgeProtocolError = class BridgeProtocolError extends Error {
|
|
68327
70237
|
code;
|
|
68328
70238
|
detail;
|
|
@@ -68334,6 +70244,17 @@ var init_bridge_session_seam = __esm(() => {
|
|
|
68334
70244
|
this.detail = detail;
|
|
68335
70245
|
}
|
|
68336
70246
|
};
|
|
70247
|
+
ACCOUNT_STATUSES = new Set(["signed-out", "credential-stored"]);
|
|
70248
|
+
ACCOUNT_PHASES = new Set([
|
|
70249
|
+
"initializing",
|
|
70250
|
+
"waiting-browser",
|
|
70251
|
+
"exchanging",
|
|
70252
|
+
"committing",
|
|
70253
|
+
"succeeded",
|
|
70254
|
+
"cancelled",
|
|
70255
|
+
"expired",
|
|
70256
|
+
"failed"
|
|
70257
|
+
]);
|
|
68337
70258
|
});
|
|
68338
70259
|
|
|
68339
70260
|
// scripts/lib/bridge-failfast-text.mjs
|
|
@@ -68341,10 +70262,9 @@ function formatBridgeFailFastMessage(diagnosis, repairCommand = BRIDGE_REPAIR_CO
|
|
|
68341
70262
|
return [diagnosis, `Fix: ${repairCommand}`, BRIDGE_APPEND_PRESET_NOTICE].join(`
|
|
68342
70263
|
`);
|
|
68343
70264
|
}
|
|
68344
|
-
var BRIDGE_REPAIR_COMMAND = "dsh-opentui --repair-bridge", BRIDGE_APPEND_PRESET_NOTICE = "inproc bridge mode injects append-system via the bridge section; presets are standard only.",
|
|
70265
|
+
var BRIDGE_REPAIR_COMMAND = "dsh-opentui --repair-bridge", BRIDGE_APPEND_PRESET_NOTICE = "inproc bridge mode injects append-system via the bridge section; presets are standard only.", BRIDGE_REPAIR_HINT;
|
|
68345
70266
|
var init_bridge_failfast_text = __esm(() => {
|
|
68346
|
-
BRIDGE_REPAIR_HINT = `Run \`${BRIDGE_REPAIR_COMMAND}\` to rebuild the bridge
|
|
68347
|
-
${BRIDGE_LEGACY_REMOTE_HINT}`;
|
|
70267
|
+
BRIDGE_REPAIR_HINT = `Run \`${BRIDGE_REPAIR_COMMAND}\` to rebuild the bridge manifest (it fixes links, not corrupted artifact contents).`;
|
|
68348
70268
|
});
|
|
68349
70269
|
|
|
68350
70270
|
// scripts/lib/host-compat.mjs
|
|
@@ -68418,22 +70338,13 @@ __export(exports_seam_bootstrap, {
|
|
|
68418
70338
|
BRIDGE_REPAIR_HINT: () => BRIDGE_REPAIR_HINT,
|
|
68419
70339
|
BridgeBootstrapError: () => BridgeBootstrapError,
|
|
68420
70340
|
createBridgeSessionSeam: () => createBridgeSessionSeam,
|
|
68421
|
-
createSessionSeam: () => createSessionSeam,
|
|
68422
70341
|
formatBridgeBootstrapMessage: () => formatBridgeBootstrapMessage,
|
|
68423
70342
|
formatDeadNotice: () => formatDeadNotice,
|
|
68424
|
-
isInprocMode: () => isInprocMode,
|
|
68425
70343
|
recoverBridgeSession: () => recoverBridgeSession,
|
|
68426
|
-
selectSeamKind: () => selectSeamKind,
|
|
68427
70344
|
toBridgeBootstrapError: () => toBridgeBootstrapError,
|
|
68428
70345
|
verifyBridgeFingerprint: () => verifyBridgeFingerprint,
|
|
68429
70346
|
verifyRecoveryHandshake: () => verifyRecoveryHandshake
|
|
68430
70347
|
});
|
|
68431
|
-
function selectSeamKind(input) {
|
|
68432
|
-
return input.inproc ? "bridge" : "remote";
|
|
68433
|
-
}
|
|
68434
|
-
function isInprocMode(env = process.env) {
|
|
68435
|
-
return env.DSH_OPENTUI_INPROC !== "0";
|
|
68436
|
-
}
|
|
68437
70348
|
function formatBridgeBootstrapMessage(options) {
|
|
68438
70349
|
return formatBridgeFailFastMessage(`dsh-opentui inproc bridge seam failed [${options.code}]: ${options.diagnosis}`, options.repairCommand ?? BRIDGE_REPAIR_COMMAND);
|
|
68439
70350
|
}
|
|
@@ -68450,11 +70361,11 @@ function toBridgeBootstrapError(err, fallbackCode = "BRIDGE_HANDSHAKE_FAILED") {
|
|
|
68450
70361
|
const message = err instanceof Error ? err.message : String(err);
|
|
68451
70362
|
return new BridgeBootstrapError({ code: fallbackCode, diagnosis: `bridge handshake failed: ${message}` });
|
|
68452
70363
|
}
|
|
68453
|
-
function
|
|
70364
|
+
function asRecord11(value) {
|
|
68454
70365
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
68455
70366
|
}
|
|
68456
70367
|
function verifyBridgeFingerprint(hello, expectedProtocolVersion = BRIDGE_PROTOCOL_VERSION) {
|
|
68457
|
-
const h =
|
|
70368
|
+
const h = asRecord11(hello);
|
|
68458
70369
|
const protocolVersion = h.protocolVersion;
|
|
68459
70370
|
if (protocolVersion !== expectedProtocolVersion) {
|
|
68460
70371
|
throw new BridgeBootstrapError({
|
|
@@ -68532,11 +70443,6 @@ async function createBridgeSessionSeam(options) {
|
|
|
68532
70443
|
await seam.connect();
|
|
68533
70444
|
return seam;
|
|
68534
70445
|
}
|
|
68535
|
-
async function createSessionSeam(options) {
|
|
68536
|
-
if (options.kind === "remote")
|
|
68537
|
-
return options.createRemote();
|
|
68538
|
-
return options.createBridge();
|
|
68539
|
-
}
|
|
68540
70446
|
async function recoverBridgeSession(options) {
|
|
68541
70447
|
await options.transport.recover();
|
|
68542
70448
|
return options.seam.recoverSession();
|
|
@@ -68562,31 +70468,30 @@ var init_seam_bootstrap = __esm(() => {
|
|
|
68562
70468
|
});
|
|
68563
70469
|
|
|
68564
70470
|
// ../tui-base/examples/v2-entry.tsx
|
|
68565
|
-
import { join as
|
|
68566
|
-
import { existsSync as
|
|
70471
|
+
import { join as join17 } from "path";
|
|
70472
|
+
import { existsSync as existsSync14 } from "fs";
|
|
68567
70473
|
function resolveWatchdogScript() {
|
|
68568
70474
|
const candidates = [
|
|
68569
|
-
|
|
68570
|
-
|
|
68571
|
-
|
|
70475
|
+
join17(import.meta.dir, "..", "watchdog.mjs"),
|
|
70476
|
+
join17(import.meta.dir, "..", "..", "shell", "dist", "watchdog.mjs"),
|
|
70477
|
+
join17(import.meta.dir, "..", "..", "..", "shell", "dist", "watchdog.mjs")
|
|
68572
70478
|
];
|
|
68573
70479
|
for (const candidate of candidates)
|
|
68574
|
-
if (
|
|
70480
|
+
if (existsSync14(candidate))
|
|
68575
70481
|
return candidate;
|
|
68576
70482
|
return null;
|
|
68577
70483
|
}
|
|
68578
70484
|
async function loadShell() {
|
|
68579
|
-
const [shared, lifecycle, clifecycle, transport, rhs,
|
|
70485
|
+
const [shared, lifecycle, clifecycle, transport, rhs, git, seamBootstrap] = await Promise.all([
|
|
68580
70486
|
Promise.resolve().then(() => (init_boot_shared(), exports_boot_shared)),
|
|
68581
70487
|
Promise.resolve().then(() => (init_lifecycle(), exports_lifecycle)),
|
|
68582
70488
|
Promise.resolve().then(() => (init_client_lifecycle(), exports_client_lifecycle)),
|
|
68583
70489
|
Promise.resolve().then(() => (init_transport(), exports_transport)),
|
|
68584
70490
|
Promise.resolve().then(() => (init_remote_host_session(), exports_remote_host_session)),
|
|
68585
|
-
Promise.resolve().then(() => (init_session_seam_adapter(), exports_session_seam_adapter)),
|
|
68586
70491
|
Promise.resolve().then(() => (init_remote_git(), exports_remote_git)),
|
|
68587
70492
|
Promise.resolve().then(() => (init_seam_bootstrap(), exports_seam_bootstrap))
|
|
68588
70493
|
]);
|
|
68589
|
-
return { shared, lifecycle, clifecycle, transport, rhs,
|
|
70494
|
+
return { shared, lifecycle, clifecycle, transport, rhs, git, seamBootstrap };
|
|
68590
70495
|
}
|
|
68591
70496
|
function V2SessionPage(props) {
|
|
68592
70497
|
return createComponent2(DockProvider, {
|
|
@@ -68618,7 +70523,7 @@ function V2SessionPageBody(props) {
|
|
|
68618
70523
|
}
|
|
68619
70524
|
});
|
|
68620
70525
|
const dialog = useDialog();
|
|
68621
|
-
const pageOwns =
|
|
70526
|
+
const pageOwns = useIsPageOwner2();
|
|
68622
70527
|
const dock = useDock();
|
|
68623
70528
|
const theme = useTheme();
|
|
68624
70529
|
const themeService = useThemes();
|
|
@@ -69291,7 +71196,7 @@ function appendDiagnostic(line) {
|
|
|
69291
71196
|
} catch {}
|
|
69292
71197
|
}
|
|
69293
71198
|
async function bootClientV2(options = {}) {
|
|
69294
|
-
const { shared, lifecycle, clifecycle, transport, rhs,
|
|
71199
|
+
const { shared, lifecycle, clifecycle, transport, rhs, git, seamBootstrap } = await loadShell();
|
|
69295
71200
|
const workspace = process.cwd();
|
|
69296
71201
|
const profile = lifecycle.DEFAULT_PROFILE;
|
|
69297
71202
|
const idleExitMs = lifecycle.resolveIdleExitMs();
|
|
@@ -69340,31 +71245,22 @@ async function bootClientV2(options = {}) {
|
|
|
69340
71245
|
}
|
|
69341
71246
|
}
|
|
69342
71247
|
const launchArgs = parseLaunchArgs(options.argv ?? process.argv.slice(2));
|
|
69343
|
-
|
|
69344
|
-
|
|
69345
|
-
|
|
69346
|
-
|
|
69347
|
-
|
|
69348
|
-
|
|
69349
|
-
|
|
69350
|
-
|
|
69351
|
-
|
|
69352
|
-
|
|
69353
|
-
|
|
69354
|
-
}
|
|
69355
|
-
return seamBootstrap.createBridgeSessionSeam({
|
|
69356
|
-
transport: options.bridgeTransport,
|
|
69357
|
-
ctx: options.bridgeCtx ?? { logger: console },
|
|
69358
|
-
onDead: (cause) => void showNotice(`${seamBootstrap.formatDeadNotice(cause)} \xB7 ${t("recovery.action.reconnect")}`, undefined, "error"),
|
|
69359
|
-
onPermissionUnavailable: (reason) => void showNotice(`${t("notice.permission.unavailable")} \xB7 ${t(`notice.permission.reason.${reason}`)}`, undefined, "error")
|
|
69360
|
-
});
|
|
69361
|
-
},
|
|
69362
|
-
createRemote: () => new adapter.RemoteSessionSeam(session)
|
|
71248
|
+
if (options.bridgeTransport === undefined) {
|
|
71249
|
+
throw new seamBootstrap.BridgeBootstrapError({
|
|
71250
|
+
code: "BRIDGE_TRANSPORT_MISSING",
|
|
71251
|
+
diagnosis: "no bridge transport was injected at the synthetic root"
|
|
71252
|
+
});
|
|
71253
|
+
}
|
|
71254
|
+
const seam = await seamBootstrap.createBridgeSessionSeam({
|
|
71255
|
+
transport: options.bridgeTransport,
|
|
71256
|
+
ctx: options.bridgeCtx ?? { logger: console },
|
|
71257
|
+
onDead: (cause) => void showNotice(`${seamBootstrap.formatDeadNotice(cause)} \xB7 ${t("recovery.action.reconnect")}`, undefined, "error"),
|
|
71258
|
+
onPermissionUnavailable: (reason) => void showNotice(`${t("notice.permission.unavailable")} \xB7 ${t(`notice.permission.reason.${reason}`)}`, undefined, "error")
|
|
69363
71259
|
});
|
|
69364
|
-
const recoverBridge =
|
|
71260
|
+
const recoverBridge = () => seamBootstrap.recoverBridgeSession({
|
|
69365
71261
|
transport: options.bridgeTransport,
|
|
69366
71262
|
seam
|
|
69367
|
-
})
|
|
71263
|
+
});
|
|
69368
71264
|
registerTurnOverlays(seam, overlays, {
|
|
69369
71265
|
deadReason: (details) => {
|
|
69370
71266
|
const cause = details;
|
|
@@ -69395,8 +71291,8 @@ async function bootClientV2(options = {}) {
|
|
|
69395
71291
|
agentsHome: agentsHomeForSkills
|
|
69396
71292
|
});
|
|
69397
71293
|
const skillsManagerRoots = {
|
|
69398
|
-
source:
|
|
69399
|
-
curated:
|
|
71294
|
+
source: join17(agentsHomeForSkills, "skills"),
|
|
71295
|
+
curated: join17(host.dshHome, "skills")
|
|
69400
71296
|
};
|
|
69401
71297
|
const envTheme = process.env[shared.ENV_THEME];
|
|
69402
71298
|
const workspaceConfig = seam.workspaceConfig?.() ?? {};
|
|
@@ -69435,12 +71331,10 @@ async function bootClientV2(options = {}) {
|
|
|
69435
71331
|
try {
|
|
69436
71332
|
await Promise.race([session.dispose(), new Promise((resolve) => setTimeout(resolve, shared.SHUTDOWN_GRACE_MS))]);
|
|
69437
71333
|
} catch {}
|
|
69438
|
-
|
|
69439
|
-
|
|
69440
|
-
|
|
69441
|
-
|
|
69442
|
-
options.bridgeTransport?.close?.();
|
|
69443
|
-
}
|
|
71334
|
+
try {
|
|
71335
|
+
await Promise.race([seam.dispose(), new Promise((resolve) => setTimeout(resolve, shared.SHUTDOWN_GRACE_MS))]);
|
|
71336
|
+
} catch {}
|
|
71337
|
+
options.bridgeTransport?.close?.();
|
|
69444
71338
|
if (clientHeartbeat) {
|
|
69445
71339
|
clientHeartbeat.stop();
|
|
69446
71340
|
clientHeartbeat.remove();
|
|
@@ -69472,7 +71366,7 @@ async function bootClientV2(options = {}) {
|
|
|
69472
71366
|
get children() {
|
|
69473
71367
|
return createComponent2(ClipboardHost, {
|
|
69474
71368
|
get children() {
|
|
69475
|
-
return createComponent2(
|
|
71369
|
+
return createComponent2(FocusRouterProvider, {
|
|
69476
71370
|
get children() {
|
|
69477
71371
|
return createComponent2(DialogProvider, {
|
|
69478
71372
|
get children() {
|
|
@@ -69596,7 +71490,7 @@ var init_v2_entry = __esm(() => {
|
|
|
69596
71490
|
init_keymap();
|
|
69597
71491
|
init_theme3();
|
|
69598
71492
|
init_panel_kit_host();
|
|
69599
|
-
|
|
71493
|
+
init_focus_router();
|
|
69600
71494
|
init_config();
|
|
69601
71495
|
init_selection();
|
|
69602
71496
|
init_theme2();
|
|
@@ -69611,7 +71505,7 @@ var init_v2_entry = __esm(() => {
|
|
|
69611
71505
|
// src/client/bridge-transport.ts
|
|
69612
71506
|
import { spawn as nodeSpawn2 } from "child_process";
|
|
69613
71507
|
import { homedir as homedir9 } from "os";
|
|
69614
|
-
import { join as
|
|
71508
|
+
import { join as join18 } from "path";
|
|
69615
71509
|
function recoveryCause(err, phase) {
|
|
69616
71510
|
if (err instanceof BridgeBootstrapError) {
|
|
69617
71511
|
return {
|
|
@@ -69624,7 +71518,7 @@ function recoveryCause(err, phase) {
|
|
|
69624
71518
|
};
|
|
69625
71519
|
}
|
|
69626
71520
|
if (err instanceof BridgeProtocolError && err.code === "BRIDGE_DEAD") {
|
|
69627
|
-
const detail =
|
|
71521
|
+
const detail = asRecord12(err.detail);
|
|
69628
71522
|
return {
|
|
69629
71523
|
stage: phase,
|
|
69630
71524
|
code: typeof detail.code === "number" ? detail.code : null,
|
|
@@ -69675,7 +71569,7 @@ class StdioBridgeTransport {
|
|
|
69675
71569
|
#spawn() {
|
|
69676
71570
|
if (this.#child !== undefined)
|
|
69677
71571
|
return this.#child;
|
|
69678
|
-
const dshHome = this.#opts.dshHome ?? process.env.DSH_HOME ??
|
|
71572
|
+
const dshHome = this.#opts.dshHome ?? process.env.DSH_HOME ?? join18(homedir9(), ".dsh");
|
|
69679
71573
|
const env = {
|
|
69680
71574
|
...process.env,
|
|
69681
71575
|
...this.#opts.env ?? {},
|
|
@@ -69739,7 +71633,7 @@ class StdioBridgeTransport {
|
|
|
69739
71633
|
} catch {
|
|
69740
71634
|
return;
|
|
69741
71635
|
}
|
|
69742
|
-
const rec =
|
|
71636
|
+
const rec = asRecord12(frame);
|
|
69743
71637
|
if (typeof rec.id === "number") {
|
|
69744
71638
|
const pending = this.#pending.get(rec.id);
|
|
69745
71639
|
if (pending === undefined)
|
|
@@ -69751,7 +71645,7 @@ class StdioBridgeTransport {
|
|
|
69751
71645
|
this.#setState("ready");
|
|
69752
71646
|
pending.resolve(rec.result);
|
|
69753
71647
|
} else {
|
|
69754
|
-
const error =
|
|
71648
|
+
const error = asRecord12(rec.error);
|
|
69755
71649
|
pending.reject(new BridgeProtocolError(typeof error.code === "string" ? error.code : "BRIDGE_ERROR", typeof error.message === "string" ? error.message : "bridge request failed", error.detail));
|
|
69756
71650
|
}
|
|
69757
71651
|
return;
|
|
@@ -69883,7 +71777,7 @@ class StdioBridgeTransport {
|
|
|
69883
71777
|
} catch {}
|
|
69884
71778
|
}
|
|
69885
71779
|
}
|
|
69886
|
-
var
|
|
71780
|
+
var asRecord12 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
69887
71781
|
var init_bridge_transport = __esm(() => {
|
|
69888
71782
|
init_bridge_session_seam();
|
|
69889
71783
|
init_seam_bootstrap();
|
|
@@ -69896,16 +71790,16 @@ init_boot_shared();
|
|
|
69896
71790
|
init_lifecycle();
|
|
69897
71791
|
init_transport();
|
|
69898
71792
|
init_remote_host_session();
|
|
69899
|
-
import { existsSync as
|
|
69900
|
-
import { join as
|
|
71793
|
+
import { existsSync as existsSync15 } from "fs";
|
|
71794
|
+
import { join as join19 } from "path";
|
|
69901
71795
|
function resolveWatchdogScript2() {
|
|
69902
71796
|
const candidates = [
|
|
69903
|
-
|
|
69904
|
-
|
|
69905
|
-
|
|
71797
|
+
join19(import.meta.dir, "..", "watchdog.mjs"),
|
|
71798
|
+
join19(import.meta.dir, "..", "dist", "watchdog.mjs"),
|
|
71799
|
+
join19(import.meta.dir, "..", "scripts", "watchdog.mjs")
|
|
69906
71800
|
];
|
|
69907
71801
|
for (const candidate of candidates) {
|
|
69908
|
-
if (
|
|
71802
|
+
if (existsSync15(candidate))
|
|
69909
71803
|
return candidate;
|
|
69910
71804
|
}
|
|
69911
71805
|
return null;
|
|
@@ -70050,16 +71944,12 @@ async function main() {
|
|
|
70050
71944
|
const v2Specifier = "../../" + "tui-base/examples/v2-entry.tsx";
|
|
70051
71945
|
const mod = await Promise.resolve().then(() => (init_v2_entry(), {}));
|
|
70052
71946
|
const argv = process.argv.slice(2);
|
|
70053
|
-
|
|
70054
|
-
|
|
70055
|
-
|
|
70056
|
-
|
|
70057
|
-
|
|
70058
|
-
|
|
70059
|
-
bridgeCtx: { logger: console }
|
|
70060
|
-
};
|
|
70061
|
-
}
|
|
70062
|
-
await bootClientV2(bootOptions);
|
|
71947
|
+
const bridgeMod = await Promise.resolve().then(() => (init_bridge_transport(), {}));
|
|
71948
|
+
await bootClientV2({
|
|
71949
|
+
argv,
|
|
71950
|
+
bridgeTransport: new StdioBridgeTransport,
|
|
71951
|
+
bridgeCtx: { logger: console }
|
|
71952
|
+
});
|
|
70063
71953
|
} catch (error) {
|
|
70064
71954
|
const message = error instanceof Error ? error.stack ?? error.message : String(error);
|
|
70065
71955
|
process.stderr.write(`dsh-opentui client boot failed: ${message}
|
|
@@ -70080,5 +71970,5 @@ export {
|
|
|
70080
71970
|
themeNameFromConfig
|
|
70081
71971
|
};
|
|
70082
71972
|
|
|
70083
|
-
//# debugId=
|
|
71973
|
+
//# debugId=D9F1F54DB3A9E37E64756E2164756E21
|
|
70084
71974
|
//# sourceMappingURL=index.js.map
|