@aiwayds/dsh-opentui 0.23.2 → 0.24.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.
@@ -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() + RETRY_WINDOW_MS;
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 ${RETRY_WINDOW_MS}ms (host first boot still pending?)`);
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 ${RETRY_WINDOW_MS}ms (host first boot still pending?)`);
743
+ throw new CredentialsGrantMissingError(`credentials record "${RECORD_KEY}" absent in ${path} within ${timeoutMs}ms (host first boot still pending?)`);
731
744
  }
732
- sleepSync(RETRY_INTERVAL_MS);
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, RETRY_INTERVAL_MS = 100, RETRY_WINDOW_MS = 2000, SECRET_PATTERN, OwnerCookieError, CredentialsFileMissingError, CredentialsGrantMissingError, CredentialsGrantInvalidError, CredentialsFileInsecureError, CredentialsParseError;
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}$/;
@@ -16032,7 +16045,9 @@ var Interrupt, causeInterrupt = (fiberId) => new CauseImpl([new Interrupt(fiberI
16032
16045
  return fail3(catcher(err));
16033
16046
  }
16034
16047
  });
16035
- }, tryPromise = (options) => {
16048
+ }, promise = (evaluate) => callbackOptions(function(resume, signal) {
16049
+ evaluate(signal).then((a) => resume(succeed3(a)), (e) => resume(die(e)));
16050
+ }, evaluate.length !== 0), tryPromise = (options) => {
16036
16051
  const f = typeof options === "function" ? options : options.try;
16037
16052
  const catcher = typeof options === "function" ? (cause) => new UnknownError(cause, "An error occurred in Effect.tryPromise") : options.catch;
16038
16053
  return callbackOptions(function(resume, signal) {
@@ -16049,7 +16064,14 @@ var Interrupt, causeInterrupt = (fiberId) => new CauseImpl([new Interrupt(fiberI
16049
16064
  resume(failWithCatch(err));
16050
16065
  }
16051
16066
  }, f.length !== 0);
16052
- }, callbackOptions, asyncFinalizer, callback = (register) => callbackOptions(register, register.length >= 2), fnBody = (bodyOrOptions, pipeables) => typeof bodyOrOptions === "function" ? bodyOrOptions : pipeables.shift().bind(bodyOrOptions.self), fnUntraced = (bodyOrOptions, ...pipeables) => {
16067
+ }, callbackOptions, asyncFinalizer, callback = (register) => callbackOptions(register, register.length >= 2), gen = (...args) => {
16068
+ if (args.length === 1) {
16069
+ const body = args[0];
16070
+ return suspend(() => fromIteratorUnsafe(body()));
16071
+ }
16072
+ const [options, body] = args;
16073
+ return suspend(() => fromIteratorUnsafe(body.call(options.self)));
16074
+ }, fnBody = (bodyOrOptions, pipeables) => typeof bodyOrOptions === "function" ? bodyOrOptions : pipeables.shift().bind(bodyOrOptions.self), fnUntraced = (bodyOrOptions, ...pipeables) => {
16053
16075
  const body = fnBody(bodyOrOptions, pipeables);
16054
16076
  const fn = pipeables.length === 0 ? function() {
16055
16077
  return suspend(() => fromIteratorUnsafe(body.apply(this, arguments)));
@@ -16128,14 +16150,19 @@ var Interrupt, causeInterrupt = (fiberId) => new CauseImpl([new Interrupt(fiberI
16128
16150
  }
16129
16151
  }
16130
16152
  return failures.length === 0 ? exitVoid : exitFailCause(causeFromReasons(failures));
16131
- }, updateContext, contextWith = (f) => withFiber((fiber) => f(fiber.context)), provideContext, catchCause, OnFailureProto, OnFailureImpl = function(self, f) {
16153
+ }, updateContext, contextWith = (f) => withFiber((fiber) => f(fiber.context)), provideContext, provideService = function() {
16154
+ if (arguments.length === 1) {
16155
+ return dual(2, (self, impl) => provideServiceImpl(self, arguments[0], impl));
16156
+ }
16157
+ return dual(3, (self, service, impl) => provideServiceImpl(self, service, impl)).apply(this, arguments);
16158
+ }, provideServiceImpl = (self, service, implementation) => updateContext(self, add(service, implementation)), catchCause, OnFailureProto, OnFailureImpl = function(self, f) {
16132
16159
  this[args] = self;
16133
16160
  this[contE] = f;
16134
16161
  }, mapError, mapBoth, matchCauseEffect, OnSuccessAndFailureProto, OnSuccessAndFailureImpl = function(self, onSuccess, onFailure) {
16135
16162
  this[args] = self;
16136
16163
  this[contA] = onSuccess;
16137
16164
  this[contE] = onFailure;
16138
- }, exit = (self) => effectIsExit(self) ? exitSucceed(self) : exitPrimitive(self), exitPrimitive, ScopeTypeId = "~effect/Scope", ScopeCloseableTypeId = "~effect/Scope/Closeable", scopeClose = (self, exit_) => withFiber((fiber) => {
16165
+ }, exit = (self) => effectIsExit(self) ? exitSucceed(self) : exitPrimitive(self), exitPrimitive, ScopeTypeId = "~effect/Scope", ScopeCloseableTypeId = "~effect/Scope/Closeable", scopeTag, scopeClose = (self, exit_) => withFiber((fiber) => {
16139
16166
  fiberEnterUninterruptibleUnsafe(fiber);
16140
16167
  return scopeCloseUnsafe(self, exit_) ?? void_;
16141
16168
  }), scopeCloseUnsafe = (self, exit_) => {
@@ -16210,7 +16237,7 @@ var Interrupt, causeInterrupt = (fiberId) => new CauseImpl([new Interrupt(fiberI
16210
16237
  strategy: finalizerStrategy,
16211
16238
  parent,
16212
16239
  state: constScopeEmpty
16213
- }), constScopeEmpty, OnExitImpl, onExitPrimitive = (effect, onExit, interruptible) => new OnExitImpl(effect, onExit, interruptible), onExitUnsafe = (fiber, f) => {
16240
+ }), constScopeEmpty, provideScope, OnExitImpl, onExitPrimitive = (effect, onExit, interruptible) => new OnExitImpl(effect, onExit, interruptible), onExitUnsafe = (fiber, f) => {
16214
16241
  fiber._stack.push(new OnExitImpl(undefined, f, undefined));
16215
16242
  }, onExit, uninterruptible = (self) => withFiber((fiber) => {
16216
16243
  if (!fiber.interruptible)
@@ -16921,6 +16948,7 @@ var init_effect = __esm(() => {
16921
16948
  return fiber.succeedWith(exit ?? exitFailCause(cause));
16922
16949
  }
16923
16950
  });
16951
+ scopeTag = /* @__PURE__ */ Service2("effect/Scope");
16924
16952
  scopeCloseFinalizers = /* @__PURE__ */ fnUntraced(function* (self, finalizers, exit_) {
16925
16953
  let exits = [];
16926
16954
  const fibers = [];
@@ -16942,6 +16970,7 @@ var init_effect = __esm(() => {
16942
16970
  constScopeEmpty = {
16943
16971
  _tag: "Empty"
16944
16972
  };
16973
+ provideScope = /* @__PURE__ */ provideService(scopeTag);
16945
16974
  OnExitImpl = /* @__PURE__ */ function() {
16946
16975
  const Proto = /* @__PURE__ */ makePrimitiveProto({
16947
16976
  op: "OnExit",
@@ -17152,9 +17181,10 @@ var init_Deferred = __esm(() => {
17152
17181
  var init_References = () => {};
17153
17182
 
17154
17183
  // ../../node_modules/.pnpm/effect@4.1.0/node_modules/effect/dist/Scope.js
17155
- var forkUnsafe2, close;
17184
+ var provide, forkUnsafe2, close;
17156
17185
  var init_Scope = __esm(() => {
17157
17186
  init_effect();
17187
+ provide = provideScope;
17158
17188
  forkUnsafe2 = scopeForkUnsafe;
17159
17189
  close = scopeClose;
17160
17190
  });
@@ -17170,7 +17200,12 @@ var TypeId6 = "~effect/Layer", isLayer = (u) => hasProperty(u, TypeId6), LayerPr
17170
17200
  }), fromBuildMemo = (build) => {
17171
17201
  const self = fromBuild((memoMap, scope) => memoMap.getOrElseMemoize(self, scope, build));
17172
17202
  return self;
17173
- }, succeedContext = (context) => fromBuildUnsafe(constant(succeed3(context))), mergeAllEffect = (layers, memoMap, scope) => {
17203
+ }, succeedContext = (context) => fromBuildUnsafe(constant(succeed3(context))), effect2 = function() {
17204
+ if (arguments.length === 1) {
17205
+ return (effect) => effectImpl(arguments[0], effect);
17206
+ }
17207
+ return effectImpl(arguments[0], arguments[1]);
17208
+ }, effectImpl = (service, effect) => effectContext(map3(effect, (value) => make3(service, value))), effectContext = (effect) => fromBuildMemo((_, scope) => provide(effect, scope)), mergeAllEffect = (layers, memoMap, scope) => {
17174
17209
  const parentScope = forkUnsafe2(scope, "parallel");
17175
17210
  return forEach(layers, (layer) => layer.build(memoMap, forkUnsafe2(parentScope, "sequential")), {
17176
17211
  concurrency: layers.length
@@ -17558,12 +17593,14 @@ var init_Request = __esm(() => {
17558
17593
  var init_Metric = () => {};
17559
17594
 
17560
17595
  // ../../node_modules/.pnpm/effect@4.1.0/node_modules/effect/dist/Effect.js
17561
- var tryPromise2, succeed5, suspend2, fail5, failCauseSync2, die3, try_2, fromResult2, flatMap2, exit2, catchCause2, runSyncExit2, mapEager2, mapErrorEager2, mapBothEager2, flatMapEager2, fnUntracedEager2;
17596
+ var promise2, tryPromise2, succeed5, suspend2, gen2, fail5, failCauseSync2, die3, try_2, fromResult2, flatMap2, exit2, catchCause2, runSyncExit2, mapEager2, mapErrorEager2, mapBothEager2, flatMapEager2, fnUntracedEager2;
17562
17597
  var init_Effect = __esm(() => {
17563
17598
  init_effect();
17599
+ promise2 = promise;
17564
17600
  tryPromise2 = tryPromise;
17565
17601
  succeed5 = succeed3;
17566
17602
  suspend2 = suspend;
17603
+ gen2 = gen;
17567
17604
  fail5 = fail3;
17568
17605
  failCauseSync2 = failCauseSync;
17569
17606
  die3 = die;
@@ -21885,7 +21922,17 @@ var init_Boolean = __esm(() => {
21885
21922
  });
21886
21923
 
21887
21924
  // ../../node_modules/.pnpm/effect@4.1.0/node_modules/effect/dist/Brand.js
21888
- var init_Brand = () => {};
21925
+ function nominal() {
21926
+ return Object.assign((input) => input, {
21927
+ option: (input) => some2(input),
21928
+ result: (input) => succeed2(input),
21929
+ is: (_) => true
21930
+ });
21931
+ }
21932
+ var init_Brand = __esm(() => {
21933
+ init_Option();
21934
+ init_Result();
21935
+ });
21889
21936
 
21890
21937
  // ../../node_modules/.pnpm/effect@4.1.0/node_modules/effect/dist/Cache.js
21891
21938
  var TypeId24 = "~effect/Cache", Proto5;
@@ -32583,6 +32630,9 @@ var init_dsh_blue = __esm(() => {
32583
32630
  $hovered: "$background.raised.high"
32584
32631
  }
32585
32632
  }
32633
+ },
32634
+ text: {
32635
+ muted: "$hue.neutral.300"
32586
32636
  }
32587
32637
  }
32588
32638
  },
@@ -41542,6 +41592,134 @@ var init_interactivity = __esm(() => {
41542
41592
  Context4 = createContext(() => true);
41543
41593
  });
41544
41594
 
41595
+ // ../tui-base/src/context/input-ownership.tsx
41596
+ function InputOwnershipProvider(props) {
41597
+ const page = {
41598
+ id: Symbol("page"),
41599
+ kind: "page"
41600
+ };
41601
+ const [stack, setStack] = createSignal([page]);
41602
+ const top = () => stack().at(-1) ?? page;
41603
+ const value = {
41604
+ top,
41605
+ pageFrame: () => page,
41606
+ push(kind) {
41607
+ const frame = {
41608
+ id: Symbol(kind),
41609
+ kind
41610
+ };
41611
+ setStack((items) => [...items, frame]);
41612
+ return frame;
41613
+ },
41614
+ pop(frame) {
41615
+ if (!frame || frame === page)
41616
+ return;
41617
+ setStack((items) => items.some((item) => item.id === frame.id) ? items.filter((item) => item.id !== frame.id) : items);
41618
+ },
41619
+ owns(frame) {
41620
+ return frame !== undefined && top().id === frame.id;
41621
+ }
41622
+ };
41623
+ return createComponent2(Context5.Provider, {
41624
+ value,
41625
+ get children() {
41626
+ return props.children;
41627
+ }
41628
+ });
41629
+ }
41630
+ function useInputOwnership() {
41631
+ const value = useContext(Context5);
41632
+ if (!value)
41633
+ throw new Error("InputOwnership.Provider is missing");
41634
+ return value;
41635
+ }
41636
+ function useInputOwnershipOptional() {
41637
+ return useContext(Context5);
41638
+ }
41639
+ function useIsPageOwner() {
41640
+ const ownership = useInputOwnershipOptional();
41641
+ return () => ownership === undefined || ownership.owns(ownership.pageFrame());
41642
+ }
41643
+ var Context5;
41644
+ var init_input_ownership = __esm(() => {
41645
+ init_index_bun();
41646
+ init_server();
41647
+ Context5 = createContext(undefined);
41648
+ });
41649
+
41650
+ // ../tui-base/src/context/focus-router.tsx
41651
+ function tierOfFrame(frame) {
41652
+ if (!frame)
41653
+ return;
41654
+ switch (frame.kind) {
41655
+ case "dialog":
41656
+ return "modal";
41657
+ case "panel":
41658
+ case "dock":
41659
+ return "overlay";
41660
+ case "page":
41661
+ return "main";
41662
+ }
41663
+ }
41664
+ function resolveCapture(top, tier, frame) {
41665
+ if (!top)
41666
+ return false;
41667
+ if (tier === "main" || tier === "global")
41668
+ return top.kind === "page";
41669
+ const tierMatches = tierOfFrame(top) === tier;
41670
+ if (!tierMatches)
41671
+ return false;
41672
+ return frame === undefined || top.id === frame.id;
41673
+ }
41674
+ function createFocusRouter(ownership) {
41675
+ const top = ownership.top;
41676
+ return {
41677
+ top,
41678
+ topTier: () => tierOfFrame(top()),
41679
+ allows(tier, frame) {
41680
+ return resolveCapture(top(), tier, frame);
41681
+ },
41682
+ ownership
41683
+ };
41684
+ }
41685
+ function useFocusRouterOptional() {
41686
+ return useContext(Context6);
41687
+ }
41688
+ function useIsPageOwner2() {
41689
+ const router = useFocusRouterOptional();
41690
+ if (router)
41691
+ return () => router.allows("main");
41692
+ const ownership = useInputOwnershipOptional();
41693
+ return () => ownership === undefined || ownership.owns(ownership.pageFrame());
41694
+ }
41695
+ function Scope2(props) {
41696
+ const router = createFocusRouter(useInputOwnership());
41697
+ return createComponent2(Context6.Provider, {
41698
+ value: router,
41699
+ get children() {
41700
+ return props.children;
41701
+ }
41702
+ });
41703
+ }
41704
+ function FocusRouterProvider(props) {
41705
+ return createComponent2(InputOwnershipProvider, {
41706
+ get children() {
41707
+ return createComponent2(Scope2, {
41708
+ get children() {
41709
+ return props.children;
41710
+ }
41711
+ });
41712
+ }
41713
+ });
41714
+ }
41715
+ var Context6;
41716
+ var init_focus_router = __esm(() => {
41717
+ init_index_bun();
41718
+ init_server();
41719
+ init_input_ownership();
41720
+ Context6 = createContext(undefined);
41721
+ });
41722
+
41545
41723
  // ../tui-base/src/context/keymap.tsx
41546
41724
  import { InputRenderable as InputRenderable4, TextareaRenderable as TextareaRenderable3 } from "@opentui/core";
41547
41725
  function Provider(props) {
@@ -41597,7 +41775,7 @@ function Provider(props) {
41597
41775
  return createComponent2(KeymapProvider, {
41598
41776
  keymap,
41599
41777
  get children() {
41600
- return createComponent2(Context5.Provider, {
41778
+ return createComponent2(Context7.Provider, {
41601
41779
  value: {
41602
41780
  keymap,
41603
41781
  config,
@@ -41635,6 +41813,7 @@ function use2() {
41635
41813
  function createLayer(input) {
41636
41814
  const value = useValue();
41637
41815
  const enabled = useInteractivity();
41816
+ const focus = useFocusRouterOptional();
41638
41817
  const stable = new Map;
41639
41818
  useBindings(() => {
41640
41819
  const layer = input();
@@ -41642,12 +41821,20 @@ function createLayer(input) {
41642
41821
  commands,
41643
41822
  bindings,
41644
41823
  mode,
41824
+ capture,
41825
+ captureFrame,
41645
41826
  ...options
41646
41827
  } = layer;
41647
41828
  const grouped = groupCommands(commands);
41829
+ const resolvedEnabled = focus && capture !== undefined ? () => {
41830
+ const base = typeof options.enabled === "function" ? options.enabled() : options.enabled === undefined ? true : options.enabled;
41831
+ if (!base)
41832
+ return false;
41833
+ return focus.allows(capture, captureFrame?.());
41834
+ } : options.enabled;
41648
41835
  return {
41649
41836
  ...options,
41650
- enabled: enabled() ? options.enabled : false,
41837
+ enabled: enabled() ? resolvedEnabled : false,
41651
41838
  ...mode === "global" ? {} : {
41652
41839
  mode: mode ?? MODE.base
41653
41840
  },
@@ -41871,13 +42058,13 @@ function useState() {
41871
42058
  };
41872
42059
  }
41873
42060
  function useValue() {
41874
- const value = useContext(Context5);
42061
+ const value = useContext(Context7);
41875
42062
  if (!value)
41876
42063
  throw new Error("Keymap.Provider is missing");
41877
42064
  return value;
41878
42065
  }
41879
42066
  function useOptional() {
41880
- return useContext(Context5) ? use2() : undefined;
42067
+ return useContext(Context7) ? use2() : undefined;
41881
42068
  }
41882
42069
  function createMode(keymap) {
41883
42070
  const [stack, setStack] = createSignal([]);
@@ -41934,7 +42121,7 @@ function formatOptions(config) {
41934
42121
  }
41935
42122
  };
41936
42123
  }
41937
- var MODE, Context5, Keymap2;
42124
+ var MODE, Context7, Keymap2;
41938
42125
  var init_keymap = __esm(() => {
41939
42126
  init_index_bun();
41940
42127
  init_src2();
@@ -41947,11 +42134,12 @@ var init_keymap = __esm(() => {
41947
42134
  init_config();
41948
42135
  init_keybind();
41949
42136
  init_interactivity();
42137
+ init_focus_router();
41950
42138
  MODE = {
41951
42139
  key: "opencode.mode",
41952
42140
  base: "base"
41953
42141
  };
41954
- Context5 = createContext();
42142
+ Context7 = createContext();
41955
42143
  Keymap2 = {
41956
42144
  Provider,
41957
42145
  use: use2,
@@ -43540,55 +43728,6 @@ var require_fuzzysort = __commonJS(function(exports, module) {
43540
43728
  });
43541
43729
  });
43542
43730
 
43543
- // ../tui-base/src/context/input-ownership.tsx
43544
- function InputOwnershipProvider(props) {
43545
- const page = {
43546
- id: Symbol("page"),
43547
- kind: "page"
43548
- };
43549
- const [stack, setStack] = createSignal([page]);
43550
- const top = () => stack().at(-1) ?? page;
43551
- const value = {
43552
- top,
43553
- pageFrame: () => page,
43554
- push(kind) {
43555
- const frame = {
43556
- id: Symbol(kind),
43557
- kind
43558
- };
43559
- setStack((items) => [...items, frame]);
43560
- return frame;
43561
- },
43562
- pop(frame) {
43563
- if (!frame || frame === page)
43564
- return;
43565
- setStack((items) => items.some((item) => item.id === frame.id) ? items.filter((item) => item.id !== frame.id) : items);
43566
- },
43567
- owns(frame) {
43568
- return frame !== undefined && top().id === frame.id;
43569
- }
43570
- };
43571
- return createComponent2(Context6.Provider, {
43572
- value,
43573
- get children() {
43574
- return props.children;
43575
- }
43576
- });
43577
- }
43578
- function useInputOwnershipOptional() {
43579
- return useContext(Context6);
43580
- }
43581
- function useIsPageOwner() {
43582
- const ownership = useInputOwnershipOptional();
43583
- return () => ownership === undefined || ownership.owns(ownership.pageFrame());
43584
- }
43585
- var Context6;
43586
- var init_input_ownership = __esm(() => {
43587
- init_index_bun();
43588
- init_server();
43589
- Context6 = createContext(undefined);
43590
- });
43591
-
43592
43731
  // ../tui-base/src/ui/border.ts
43593
43732
  var EmptyBorder, SplitBorder;
43594
43733
  var init_border = __esm(() => {
@@ -44238,6 +44377,8 @@ function init2() {
44238
44377
  }
44239
44378
  Keymap2.createLayer(() => ({
44240
44379
  mode: "modal",
44380
+ capture: "modal",
44381
+ captureFrame: () => store.stack.at(-1)?.frame,
44241
44382
  enabled: store.stack.length > 0 && (ownership === undefined || ownership.owns(store.stack.at(-1)?.frame)),
44242
44383
  commands: [{
44243
44384
  bind: "escape",
@@ -47520,12 +47661,6 @@ function subagentHardStopGlyph(view) {
47520
47661
  return "\u23FB!";
47521
47662
  return view.hardStopRound !== undefined ? "\u23FB" : "";
47522
47663
  }
47523
- function foldSubagentMarkerViews(views) {
47524
- setSubagentViews(views);
47525
- }
47526
- function registerSubagentSteer(fn) {
47527
- steerImpl = fn;
47528
- }
47529
47664
  function steerSubagent(id, text) {
47530
47665
  return steerImpl?.(id, text);
47531
47666
  }
@@ -49281,8 +49416,7 @@ function buildMergedDock(data, options) {
49281
49416
  lowerRaw = [];
49282
49417
  } else {
49283
49418
  upperLines = tools.slice(-MERGED_DOCK_TOOL_ONLY_MAX).map((tool) => toolOnlyLine(tool, now, spin));
49284
- const summary = todosSummaryFromTodos(data.todos);
49285
- lowerRaw = summary === "" ? [] : [{ kind: "todo", segments: [{ text: summary, tone: "running" }] }];
49419
+ lowerRaw = todoTreeLines(data.todos);
49286
49420
  }
49287
49421
  const assembled = assembleZones(upperLines, lowerRaw, options.totalLines ?? MERGED_DOCK_TOTAL_LINES, options.cursor);
49288
49422
  return { lines: fitAll(assembled.lines, options.innerWidth), info: assembled.info };
@@ -49531,17 +49665,24 @@ function skinDockLineFg(ctx, target, line) {
49531
49665
  function resetMergedDockCursor() {
49532
49666
  setMergedDockCursor(0);
49533
49667
  }
49534
- function todoArray(text) {
49535
- if (text === undefined || text.trim() === "")
49668
+ function todoArray(value) {
49669
+ if (value === undefined || value === null)
49536
49670
  return;
49537
- try {
49538
- const parsed = JSON.parse(text);
49539
- if (Array.isArray(parsed))
49540
- return parsed;
49541
- if (parsed !== null && typeof parsed === "object" && Array.isArray(parsed.todos)) {
49542
- return parsed.todos;
49671
+ let parsed = value;
49672
+ if (typeof value === "string") {
49673
+ if (value.trim() === "")
49674
+ return;
49675
+ try {
49676
+ parsed = JSON.parse(value);
49677
+ } catch {
49678
+ return;
49543
49679
  }
49544
- } catch {}
49680
+ }
49681
+ if (Array.isArray(parsed))
49682
+ return parsed;
49683
+ if (parsed !== null && typeof parsed === "object" && Array.isArray(parsed.todos)) {
49684
+ return parsed.todos;
49685
+ }
49545
49686
  return;
49546
49687
  }
49547
49688
  function latestTodos(rows) {
@@ -49567,6 +49708,35 @@ function todosSummaryFromTodos(todos) {
49567
49708
  });
49568
49709
  return active ? `${head} \xB7 ${active.content}` : head;
49569
49710
  }
49711
+ function todoTreeLines(todos) {
49712
+ if (todos.length === 0)
49713
+ return [];
49714
+ const done = todos.filter((todo) => todo.status === "completed").length;
49715
+ if (done === todos.length)
49716
+ return [];
49717
+ const lines = [{
49718
+ kind: "todo",
49719
+ segments: [{
49720
+ text: t("overlay.widgets.todosHeader", {
49721
+ done,
49722
+ total: todos.length
49723
+ }),
49724
+ tone: "running"
49725
+ }]
49726
+ }];
49727
+ todos.forEach((todo, i) => {
49728
+ const branch = i === todos.length - 1 ? "\u2514\u2500 " : "\u251C\u2500 ";
49729
+ const glyph = TODO_STATUS_GLYPHS[todo.status] ?? TODO_STATUS_GLYPHS.pending;
49730
+ lines.push({
49731
+ kind: "todo",
49732
+ segments: [{
49733
+ text: `${branch}${glyph} ${todo.content}`,
49734
+ tone: "running"
49735
+ }]
49736
+ });
49737
+ });
49738
+ return lines;
49739
+ }
49570
49740
  function todoSetStartedAt(todos, now = Date.now()) {
49571
49741
  const sig = todoSetSignature(todos);
49572
49742
  const first = todoSetFirstSeen.get(sig);
@@ -49581,7 +49751,11 @@ function todoBriefLine(todos, now = Date.now(), startedAt) {
49581
49751
  const done = todos.filter((todo) => todo.status === "completed").length;
49582
49752
  const anchor = startedAt ?? todoSetStartedAt(todos, now);
49583
49753
  const secs = Math.max(0, Math.floor((now - anchor) / 1000));
49584
- return `todo ${done}/${todos.length} ${secs}s`;
49754
+ return t("overlay.widgets.todosBrief", {
49755
+ done,
49756
+ total: todos.length,
49757
+ secs
49758
+ });
49585
49759
  }
49586
49760
  function resetTodoBriefClock() {
49587
49761
  todoSetFirstSeen.clear();
@@ -49933,6 +50107,22 @@ function mergedLowerHasContent(rows) {
49933
50107
  function mergedCompactSummary(rows) {
49934
50108
  return todosSummaryLine(rows);
49935
50109
  }
50110
+ function mergedCompactLowerLines(rows) {
50111
+ const tree = todoTreeLines(latestTodos(rows));
50112
+ if (tree.length === 0)
50113
+ return [];
50114
+ if (tree.length > COMPACT_TREE_MAX_LINES) {
50115
+ const summary = mergedCompactSummary(rows);
50116
+ return summary === "" ? [] : [{
50117
+ kind: "todo",
50118
+ segments: [{
50119
+ text: summary,
50120
+ tone: "muted"
50121
+ }]
50122
+ }];
50123
+ }
50124
+ return tree;
50125
+ }
49936
50126
  function WidgetsDock(props) {
49937
50127
  const dimensions = useTerminalSize();
49938
50128
  const theme = useThemeOptional();
@@ -49954,7 +50144,7 @@ function WidgetsDock(props) {
49954
50144
  });
49955
50145
  const width = () => Math.max(16, dimensions().width - 4);
49956
50146
  const turnActive = () => props.turnActive?.() ?? dockTurnActive(props.rows);
49957
- createEffect(() => activityFrameLatch.push(turnActive() || mergedLowerHasContent(props.rows)));
50147
+ createEffect(() => activityFrameLatch.push(turnActive() || mergedLowerHasContent(props.rows) || mergedThinkRows(props.rows, Date.now(), motionDecorationsEnabled()).length > 0 || mergedToolRows(props.rows, Date.now(), motionDecorationsEnabled()).length > 0));
49958
50148
  onCleanup(activityFrameLatch.dispose);
49959
50149
  const frame = () => activityFrameMode(dimensions().height);
49960
50150
  const capSpec = () => activityPanelCapSpec(activityPanelGear(), dimensions().height);
@@ -49984,7 +50174,11 @@ function WidgetsDock(props) {
49984
50174
  info: mergedWindowInfo(data, options)
49985
50175
  };
49986
50176
  };
49987
- createEffect(() => setDockHeightTarget(mergedFrame().lines.length));
50177
+ createEffect(() => {
50178
+ if (!activityFrameLatch.shown())
50179
+ return;
50180
+ setDockHeightTarget(mergedFrame().lines.length);
50181
+ });
49988
50182
  onCleanup(() => {
49989
50183
  resetDockHeight();
49990
50184
  resetTodoBriefClock();
@@ -50052,8 +50246,8 @@ function WidgetsDock(props) {
50052
50246
  return lines.slice(0, count);
50053
50247
  };
50054
50248
  const frameHeight = () => 2 + frameLines().length;
50055
- const compactSummary = () => mergedCompactSummary(props.rows);
50056
- const compactHeight = () => 2 + (compactSummary() === "" ? 0 : 1);
50249
+ const compactLower = () => mergedCompactLowerLines(props.rows);
50250
+ const compactHeight = () => 2 + compactLower().length;
50057
50251
  const accentFg = (accent) => dockAccentColor(theme, accent);
50058
50252
  const lineView = (line) => dockLineNode(line, width(), skinCtx(), fgFor, accentFg);
50059
50253
  const mergedLineView = (line) => {
@@ -50134,17 +50328,11 @@ function WidgetsDock(props) {
50134
50328
  },
50135
50329
  children: lineView
50136
50330
  }), null);
50137
- insert(_el$5, createComponent2(Show, {
50138
- get when() {
50139
- return compactSummary() !== "";
50331
+ insert(_el$5, createComponent2(For, {
50332
+ get each() {
50333
+ return compactLower();
50140
50334
  },
50141
- get children() {
50142
- var _el$6 = createElement("text");
50143
- setProp(_el$6, "wrapMode", "none");
50144
- insert(_el$6, () => takeWidth(compactSummary(), width()));
50145
- effect((_$p) => setProp(_el$6, "fg", fgFor("muted"), _$p));
50146
- return _el$6;
50147
- }
50335
+ children: mergedLineView
50148
50336
  }), null);
50149
50337
  effect((_$p) => setProp(_el$5, "height", compactHeight(), _$p));
50150
50338
  return _el$5;
@@ -50189,20 +50377,30 @@ function FlatDock(props) {
50189
50377
  maxLines: props.maxLines,
50190
50378
  thinkMaxLines: props.thinkMaxLines
50191
50379
  });
50380
+ const allLines = () => dockLines(props.rows, dockOptions());
50381
+ createEffect(() => setDockHeightTarget(allLines().length));
50382
+ const flatLines = () => {
50383
+ const lines = allLines();
50384
+ const target = lines.length;
50385
+ const tweened = Math.max(0, dockHeightContentLines(target, dockFrameNow));
50386
+ const animating = untrack(dockHeightAnimating);
50387
+ const count = !animating || tweened >= target ? target : Math.min(target, tweened);
50388
+ return lines.slice(0, count);
50389
+ };
50192
50390
  return (() => {
50193
- var _el$7 = createElement("box");
50194
- setProp(_el$7, "flexShrink", 0);
50195
- setProp(_el$7, "flexDirection", "column");
50196
- setProp(_el$7, "width", "100%");
50197
- setProp(_el$7, "paddingLeft", 3);
50198
- insert(_el$7, createComponent2(For, {
50391
+ var _el$6 = createElement("box");
50392
+ setProp(_el$6, "flexShrink", 0);
50393
+ setProp(_el$6, "flexDirection", "column");
50394
+ setProp(_el$6, "width", "100%");
50395
+ setProp(_el$6, "paddingLeft", 3);
50396
+ insert(_el$6, createComponent2(For, {
50199
50397
  get each() {
50200
- return dockLines(props.rows, dockOptions());
50398
+ return flatLines();
50201
50399
  },
50202
50400
  children: (line) => dockLineNode(line, props.width, props.skinCtx, props.fgFor, props.accentFg)
50203
50401
  }));
50204
- effect((_$p) => setProp(_el$7, "height", dockLines(props.rows, dockOptions()).length, _$p));
50205
- return _el$7;
50402
+ effect((_$p) => setProp(_el$6, "height", flatLines().length, _$p));
50403
+ return _el$6;
50206
50404
  })();
50207
50405
  }
50208
50406
  function dockLineNode(line, width, ctx, fgFor, accentFg) {
@@ -50213,12 +50411,12 @@ function dockLineNode(line, width, ctx, fgFor, accentFg) {
50213
50411
  const markerAt = line.markerAt ?? 0;
50214
50412
  if (marker === undefined || line.text.slice(markerAt, markerAt + marker.length) !== marker) {
50215
50413
  return (() => {
50216
- var _el$8 = createElement("text");
50217
- setProp(_el$8, "fg", bodyFg);
50218
- setProp(_el$8, "attributes", attributes);
50219
- setProp(_el$8, "wrapMode", "none");
50220
- insert(_el$8, () => clipToWidth(line.text, width));
50221
- return _el$8;
50414
+ var _el$7 = createElement("text");
50415
+ setProp(_el$7, "fg", bodyFg);
50416
+ setProp(_el$7, "attributes", attributes);
50417
+ setProp(_el$7, "wrapMode", "none");
50418
+ insert(_el$7, () => clipToWidth(line.text, width));
50419
+ return _el$7;
50222
50420
  })();
50223
50421
  }
50224
50422
  const before = clipToWidth(line.text.slice(0, markerAt), width);
@@ -50227,21 +50425,21 @@ function dockLineNode(line, width, ctx, fgFor, accentFg) {
50227
50425
  const after = clipToWidth(line.text.slice(markerAt + marker.length), Math.max(0, markerBudget - stringWidth(clippedMarker)));
50228
50426
  const markerFg = skinDockLineFg(ctx, toneFg, line);
50229
50427
  return (() => {
50230
- var _el$9 = createElement("text"), _el$0 = createElement("span");
50231
- insertNode(_el$9, _el$0);
50232
- setProp(_el$9, "fg", bodyFg);
50233
- setProp(_el$9, "attributes", attributes);
50234
- setProp(_el$9, "wrapMode", "none");
50235
- insert(_el$9, before, _el$0);
50236
- setProp(_el$0, "style", {
50428
+ var _el$8 = createElement("text"), _el$9 = createElement("span");
50429
+ insertNode(_el$8, _el$9);
50430
+ setProp(_el$8, "fg", bodyFg);
50431
+ setProp(_el$8, "attributes", attributes);
50432
+ setProp(_el$8, "wrapMode", "none");
50433
+ insert(_el$8, before, _el$9);
50434
+ setProp(_el$9, "style", {
50237
50435
  fg: markerFg
50238
50436
  });
50239
- insert(_el$0, clippedMarker);
50240
- insert(_el$9, after, null);
50241
- return _el$9;
50437
+ insert(_el$9, clippedMarker);
50438
+ insert(_el$8, after, null);
50439
+ return _el$8;
50242
50440
  })();
50243
50441
  }
50244
- var SKIN_FADE_IN_MS = 400, SKIN_NOTICE_FADE_MS = 500, SKIN_PULSE_MS = 1200, SKIN_PULSE_CYCLES = 3, SKIN_PULSE_DIM = 0.45, SKIN_FAINT_MIX = 0.78, ACTIVITY_PANEL_GEARS, ACTIVITY_PANEL_ALL_LINES = 10, activityPanelGear, setActivityPanelGear, DOCK_HEIGHT_ANIM_MS = 200, dockHeightTween, setDockHeightTween, dockHeightSettled = undefined, dockFrameNow = 0, LINE_FIRST_SEEN_MAX = 512, lineFirstSeen, dockSpin, setDockSpin, mergedDockCursor, setMergedDockCursor, todoSetSignature = (todos) => todos.map((todo) => todo.content).sort().join("\x01"), todoSetFirstSeen, TODO_TOOL_NAMES, ACTIVITY_FRAME_BORDER_FALLBACK = "#7aa2f7", ACTIVITY_FRAME_MIN_CONTRAST = 6, ACTIVITY_BLUE_STEPS, BLUE_HUE_MIN = 190, BLUE_HUE_MAX = 250, BLUE_MIN_SATURATION = 0.25, AUTO_POLE_LIGHT = "#ffffff", AUTO_POLE_DARK = "#000000", DOCK_ACCENT_STEPS, DOCK_ACCENT_HUES, DOCK_ACCENT_FALLBACK, ACTIVITY_FRAME_DEFER_MS = 60, activityFrameLatch;
50442
+ var SKIN_FADE_IN_MS = 400, SKIN_NOTICE_FADE_MS = 500, SKIN_PULSE_MS = 1200, SKIN_PULSE_CYCLES = 3, SKIN_PULSE_DIM = 0.45, SKIN_FAINT_MIX = 0.78, ACTIVITY_PANEL_GEARS, ACTIVITY_PANEL_ALL_LINES = 10, activityPanelGear, setActivityPanelGear, DOCK_HEIGHT_ANIM_MS = 200, dockHeightTween, setDockHeightTween, dockHeightSettled = undefined, dockFrameNow = 0, LINE_FIRST_SEEN_MAX = 512, lineFirstSeen, dockSpin, setDockSpin, mergedDockCursor, setMergedDockCursor, todoSetSignature = (todos) => todos.map((todo) => todo.content).sort().join("\x01"), todoSetFirstSeen, TODO_TOOL_NAMES, ACTIVITY_FRAME_BORDER_FALLBACK = "#7aa2f7", ACTIVITY_FRAME_MIN_CONTRAST = 6, ACTIVITY_BLUE_STEPS, BLUE_HUE_MIN = 190, BLUE_HUE_MAX = 250, BLUE_MIN_SATURATION = 0.25, AUTO_POLE_LIGHT = "#ffffff", AUTO_POLE_DARK = "#000000", DOCK_ACCENT_STEPS, DOCK_ACCENT_HUES, DOCK_ACCENT_FALLBACK, ACTIVITY_FRAME_DEFER_MS = 60, activityFrameLatch, COMPACT_TREE_MAX_LINES = 8;
50245
50443
  var init_widgets_dock = __esm(() => {
50246
50444
  init_index_bun();
50247
50445
  init_index_bun();
@@ -50254,7 +50452,6 @@ var init_widgets_dock = __esm(() => {
50254
50452
  init_terminal_size();
50255
50453
  init_tool_summarize();
50256
50454
  init_todo();
50257
- init_locale();
50258
50455
  init_string_width();
50259
50456
  init_theme3();
50260
50457
  init_i18n();
@@ -51616,6 +51813,232 @@ var init_hints_line = __esm(() => {
51616
51813
  [hintsLocale, setHintsLocale] = createSignal("en");
51617
51814
  });
51618
51815
 
51816
+ // ../tui-base/src/vendor/util/src/global-roots.ts
51817
+ import os2 from "os";
51818
+ import path4 from "path";
51819
+ function roots(app) {
51820
+ return {
51821
+ data: path4.join(data, app),
51822
+ cache: path4.join(cache2, app),
51823
+ config: path4.join(config, app),
51824
+ state: path4.join(state2, app),
51825
+ tmp: path4.join(os2.tmpdir(), app)
51826
+ };
51827
+ }
51828
+ var home2, data, cache2, config, state2;
51829
+ var init_global_roots = __esm(() => {
51830
+ home2 = os2.homedir();
51831
+ data = process.env.XDG_DATA_HOME || (home2 ? path4.join(home2, ".local", "share") : undefined);
51832
+ cache2 = process.env.XDG_CACHE_HOME || (home2 ? path4.join(home2, ".cache") : undefined);
51833
+ config = process.env.XDG_CONFIG_HOME || (home2 ? path4.join(home2, ".config") : undefined);
51834
+ state2 = process.env.XDG_STATE_HOME || (home2 ? path4.join(home2, ".local", "state") : undefined);
51835
+ });
51836
+
51837
+ // ../tui-base/src/vendor/util/src/teardown.ts
51838
+ var entries;
51839
+ var init_teardown = __esm(() => {
51840
+ init_teardown();
51841
+ entries = new Set;
51842
+ });
51843
+
51844
+ // ../tui-base/src/vendor/util/src/effect/layer-node.ts
51845
+ function tags(config) {
51846
+ const names = Object.keys(config);
51847
+ const values = Object.fromEntries(names.map((name) => [name, makeTag(name)]));
51848
+ return {
51849
+ values,
51850
+ make: (name) => (input) => makeProvider2(input, values[name])
51851
+ };
51852
+ }
51853
+ function makeProvider2(input, tag) {
51854
+ if (!isLayer(input.layer))
51855
+ throw new Error("A layer node requires an Effect Layer");
51856
+ return new ProviderNode({
51857
+ kind: "layer",
51858
+ name: input.service !== undefined ? input.service.key : input.name,
51859
+ implementation: input.layer,
51860
+ dependencies: [...input.deps]
51861
+ }, tag);
51862
+ }
51863
+ var GraphTypeId, VarianceTypeId, NodeTypeId, ReplacementTypeId, makeTag, GraphValue, NodeValue, ProviderNode, ReplacementValue, BuildResult;
51864
+ var init_layer_node = __esm(() => {
51865
+ init_dist();
51866
+ init_teardown();
51867
+ init_layer_node();
51868
+ GraphTypeId = Symbol("LayerNode.Graph");
51869
+ VarianceTypeId = Symbol("LayerNode.Variance");
51870
+ NodeTypeId = Symbol("LayerNode.Node");
51871
+ ReplacementTypeId = Symbol("LayerNode.Replacement");
51872
+ makeTag = nominal();
51873
+ GraphValue = class GraphValue {
51874
+ [GraphTypeId];
51875
+ constructor(definition) {
51876
+ this[GraphTypeId] = definition;
51877
+ }
51878
+ get name() {
51879
+ return this[GraphTypeId].name;
51880
+ }
51881
+ };
51882
+ NodeValue = class NodeValue extends GraphValue {
51883
+ tag;
51884
+ constructor(definition, tag) {
51885
+ super(definition);
51886
+ this.tag = tag;
51887
+ }
51888
+ replace(replacement) {
51889
+ if (replacement instanceof NodeValue) {
51890
+ if (replacement.tag !== this.tag)
51891
+ throw new Error(`Cannot replace ${this.name} across tags`);
51892
+ return new ReplacementValue(this, replacement);
51893
+ }
51894
+ if (!isLayer(replacement))
51895
+ throw new Error("A replacement must be a node or an Effect Layer");
51896
+ return new ReplacementValue(this, makeProvider2({ name: this.name, layer: replacement, deps: [] }, this.tag));
51897
+ }
51898
+ };
51899
+ ProviderNode = class ProviderNode extends NodeValue {
51900
+ mapLayer(f) {
51901
+ const definition = this[GraphTypeId];
51902
+ if (definition.kind !== "layer")
51903
+ throw new Error(`Cannot map unbound layer node: ${this.name}`);
51904
+ return new ProviderNode({ ...definition, implementation: f(definition.implementation) }, this.tag);
51905
+ }
51906
+ };
51907
+ ReplacementValue = class ReplacementValue {
51908
+ [ReplacementTypeId];
51909
+ constructor(source, target) {
51910
+ this[ReplacementTypeId] = { source, target };
51911
+ }
51912
+ };
51913
+ BuildResult = class BuildResult extends Service2()("@opencode/LayerNode/BuildResult") {
51914
+ };
51915
+ });
51916
+
51917
+ // ../tui-base/src/vendor/util/src/effect/app-node.ts
51918
+ var tags2, makeGlobalNode, makeLocationNode;
51919
+ var init_app_node = __esm(() => {
51920
+ init_layer_node();
51921
+ init_app_node();
51922
+ tags2 = tags({
51923
+ location: ["global"],
51924
+ global: []
51925
+ });
51926
+ makeGlobalNode = tags2.make("global");
51927
+ makeLocationNode = tags2.make("location");
51928
+ });
51929
+
51930
+ // ../tui-base/src/vendor/util/src/global.ts
51931
+ import path5 from "path";
51932
+ import fs from "fs";
51933
+ import os3 from "os";
51934
+ function make12(input = {}) {
51935
+ return {
51936
+ home: Path.home,
51937
+ data: Path.data,
51938
+ cache: Path.cache,
51939
+ config: Path.config,
51940
+ state: Path.state,
51941
+ tmp: input.tmp ?? Path.tmp,
51942
+ bin: Path.bin,
51943
+ log: Path.log,
51944
+ repos: Path.repos,
51945
+ ...input
51946
+ };
51947
+ }
51948
+ var app = "opencode", data2, cache3, config2, state3, tmp, paths, Path, Service3, acquire = (input) => gen2(function* () {
51949
+ const service = Service3.of(make12(input));
51950
+ yield* promise2(() => Promise.all([service.data, service.config, service.state, service.log, service.bin, service.repos, service.tmp].map((directory) => fs.promises.mkdir(directory, { recursive: true }))));
51951
+ const canonicalTmp = yield* promise2(() => fs.promises.realpath(service.tmp));
51952
+ return Service3.of({ ...service, tmp: input.tmp ?? canonicalTmp });
51953
+ }), layer, node;
51954
+ var init_global = __esm(() => {
51955
+ init_dist();
51956
+ init_global_roots();
51957
+ init_flock();
51958
+ init_app_node();
51959
+ init_global();
51960
+ ({ data: data2, cache: cache3, config: config2, state: state3, tmp } = roots(app));
51961
+ paths = {
51962
+ get home() {
51963
+ return process.env.OPENCODE_TEST_HOME ?? os3.homedir();
51964
+ },
51965
+ data: data2,
51966
+ bin: path5.join(cache3, "bin"),
51967
+ log: path5.join(data2, "log"),
51968
+ repos: path5.join(data2, "repos"),
51969
+ cache: cache3,
51970
+ config: config2,
51971
+ state: state3,
51972
+ tmp
51973
+ };
51974
+ Path = paths;
51975
+ Flock.setGlobal({ state: state3 });
51976
+ Service3 = class Service3 extends Service2()("@opencode/Global") {
51977
+ };
51978
+ layer = effect2(Service3, suspend2(() => acquire({ config: process.env.OPENCODE_CONFIG_DIR ?? Path.config })));
51979
+ node = makeGlobalNode({ service: Service3, layer, deps: [] });
51980
+ });
51981
+
51982
+ // ../tui-base/src/util/ui-state.ts
51983
+ import path6 from "path";
51984
+ import { readFileSync as readFileSync11 } from "fs";
51985
+ import { mkdir as mkdir2, readFile as readFile3, rename, rm as rm2, writeFile as writeFile2 } from "fs/promises";
51986
+ function defaultUiStatePath() {
51987
+ return path6.join(Path.state, UI_STATE_FILE);
51988
+ }
51989
+ function decodeUiState(value) {
51990
+ if (typeof value !== "object" || value === null || Array.isArray(value))
51991
+ return {};
51992
+ const root = value;
51993
+ const session = root.session;
51994
+ if (typeof session !== "object" || session === null || Array.isArray(session))
51995
+ return {};
51996
+ const stored = session.activity_panel_height;
51997
+ if (activityPanelHeightFromConfig(stored) === undefined)
51998
+ return {};
51999
+ return { session: { activity_panel_height: stored } };
52000
+ }
52001
+ function localActivityPanelGear(state) {
52002
+ return activityPanelHeightFromConfig(state.session?.activity_panel_height);
52003
+ }
52004
+ function resolveBootGear(config, local) {
52005
+ const localGear = localActivityPanelGear(local);
52006
+ if (localGear !== undefined)
52007
+ return localGear;
52008
+ const session = config?.session;
52009
+ const stored = typeof session === "object" && session !== null ? session.activity_panel_height : undefined;
52010
+ return activityPanelHeightFromConfig(stored);
52011
+ }
52012
+ function readUiStateSync(filePath) {
52013
+ try {
52014
+ return decodeUiState(JSON.parse(readFileSync11(filePath, "utf8")));
52015
+ } catch {
52016
+ return EMPTY_UI_STATE;
52017
+ }
52018
+ }
52019
+ async function writeUiState(filePath, state) {
52020
+ await mkdir2(path6.dirname(filePath), { recursive: true });
52021
+ const temporary = `${filePath}.${process.pid}.${crypto.randomUUID()}.tmp`;
52022
+ await writeFile2(temporary, JSON.stringify(decodeUiState(state))).catch(async (error) => {
52023
+ await rm2(temporary, { force: true }).catch(() => {
52024
+ return;
52025
+ });
52026
+ throw error;
52027
+ });
52028
+ await rename(temporary, filePath).catch(async (error) => {
52029
+ await rm2(temporary, { force: true }).catch(() => {
52030
+ return;
52031
+ });
52032
+ throw error;
52033
+ });
52034
+ }
52035
+ var UI_STATE_FILE = "ui-state.json", EMPTY_UI_STATE;
52036
+ var init_ui_state = __esm(() => {
52037
+ init_global();
52038
+ init_widgets_dock();
52039
+ EMPTY_UI_STATE = {};
52040
+ });
52041
+
51619
52042
  // ../tui-base/src/routes/session/search-overlay.tsx
51620
52043
  function rowSearchText(row) {
51621
52044
  switch (row.kind) {
@@ -51855,6 +52278,7 @@ function TranscriptScrollKeys(props) {
51855
52278
  };
51856
52279
  Keymap2.createLayer(() => ({
51857
52280
  mode: "global",
52281
+ capture: "main",
51858
52282
  enabled: props.enabled(),
51859
52283
  commands: [{
51860
52284
  id: "session.page.up",
@@ -51883,6 +52307,7 @@ function TranscriptScrollKeys(props) {
51883
52307
  scroll.scrollTo(Infinity);
51884
52308
  };
51885
52309
  Keymap2.createLayer(() => ({
52310
+ capture: "main",
51886
52311
  enabled: () => props.enabled() && renderer.currentFocusedEditor === null,
51887
52312
  commands: [{
51888
52313
  id: "session.first",
@@ -51987,6 +52412,7 @@ function PaneFocusKeys(props) {
51987
52412
  Keymap2.createLayer(() => ({
51988
52413
  mode: "global",
51989
52414
  priority: 1,
52415
+ capture: "main",
51990
52416
  enabled: paneToggleEnabled({
51991
52417
  pane: props.pane(),
51992
52418
  keysEnabled: props.keysEnabled(),
@@ -52007,6 +52433,7 @@ function PaneFocusKeys(props) {
52007
52433
  Keymap2.createLayer(() => ({
52008
52434
  mode: "global",
52009
52435
  priority: 1,
52436
+ capture: "main",
52010
52437
  enabled: transcriptKeysEnabled({
52011
52438
  pane: props.pane(),
52012
52439
  keysEnabled: props.keysEnabled()
@@ -52423,7 +52850,7 @@ function DockProvider(props) {
52423
52850
  }
52424
52851
  setQueue([]);
52425
52852
  });
52426
- return createComponent2(Context7.Provider, {
52853
+ return createComponent2(Context8.Provider, {
52427
52854
  value: api,
52428
52855
  get children() {
52429
52856
  return props.children;
@@ -52431,7 +52858,7 @@ function DockProvider(props) {
52431
52858
  });
52432
52859
  }
52433
52860
  function useDock() {
52434
- const value = useContext(Context7);
52861
+ const value = useContext(Context8);
52435
52862
  if (!value)
52436
52863
  throw new Error("Dock.Provider is missing");
52437
52864
  return value;
@@ -52562,7 +52989,7 @@ function DockSeat(props) {
52562
52989
  return _el$;
52563
52990
  })();
52564
52991
  }
52565
- var DOCK_MAX_ROWS_RATIO = 0.6, Context7, ordinal2 = 0;
52992
+ var DOCK_MAX_ROWS_RATIO = 0.6, Context8, ordinal2 = 0;
52566
52993
  var init_dock_host = __esm(() => {
52567
52994
  init_index_bun();
52568
52995
  init_index_bun();
@@ -52577,7 +53004,7 @@ var init_dock_host = __esm(() => {
52577
53004
  init_input_ownership();
52578
53005
  init_theme3();
52579
53006
  init_terminal_size();
52580
- Context7 = createContext(undefined);
53007
+ Context8 = createContext(undefined);
52581
53008
  });
52582
53009
 
52583
53010
  // ../tui-base/src/routes/session/ask-panel.tsx
@@ -53729,6 +54156,7 @@ function TurnCancelKeys(props) {
53729
54156
  onCleanup(() => cancel.dispose());
53730
54157
  Keymap2.createLayer(() => ({
53731
54158
  mode: "global",
54159
+ capture: "main",
53732
54160
  enabled: props.enabled(),
53733
54161
  commands: [{
53734
54162
  bind: "escape",
@@ -54585,7 +55013,7 @@ function journalToJSONL(entries) {
54585
55013
  var init_export = () => {};
54586
55014
 
54587
55015
  // ../tui-base/src/routes/session/commands.ts
54588
- import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
55016
+ import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
54589
55017
  import { dirname as dirname5 } from "path";
54590
55018
  function persistHints(seam) {
54591
55019
  try {
@@ -55141,10 +55569,6 @@ function coreCommands() {
55141
55569
  name: "/agents",
55142
55570
  description: t("command.agents.description"),
55143
55571
  run(ctx, argText) {
55144
- if (!ctx.seam.agents) {
55145
- ctx.say(t("command.agents.unavailable"));
55146
- return;
55147
- }
55148
55572
  if (!ctx.openAgents) {
55149
55573
  ctx.say(t("command.agents.panelNotMounted"));
55150
55574
  return;
@@ -55191,8 +55615,8 @@ function coreCommands() {
55191
55615
  try {
55192
55616
  const entries = await ctx.seam.sessionJournal(sessionId);
55193
55617
  const target = exportTargetPath(sessionId, argText);
55194
- await mkdir2(dirname5(target), { recursive: true });
55195
- await writeFile2(target, journalToJSONL(entries));
55618
+ await mkdir3(dirname5(target), { recursive: true });
55619
+ await writeFile3(target, journalToJSONL(entries));
55196
55620
  ctx.say(t("command.export.done", { count: entries.length, target }));
55197
55621
  } catch (error) {
55198
55622
  ctx.say(t("command.export.failed", { reason: seamFailureReason(error) }));
@@ -55725,7 +56149,7 @@ var init_slash_usage = __esm(() => {
55725
56149
  });
55726
56150
 
55727
56151
  // ../tui-base/src/routes/session/skills-source.ts
55728
- import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync11, statSync as statSync4 } from "fs";
56152
+ import { existsSync as existsSync10, readdirSync as readdirSync3, readFileSync as readFileSync12, statSync as statSync4 } from "fs";
55729
56153
  import { homedir as homedir8 } from "os";
55730
56154
  import { dirname as dirname6, join as join13, resolve as resolve7 } from "path";
55731
56155
  import { TextAttributes as TextAttributes8 } from "@opentui/core";
@@ -55841,7 +56265,7 @@ function oneLine(value) {
55841
56265
  function readSkillFile(path) {
55842
56266
  let raw;
55843
56267
  try {
55844
- raw = readFileSync11(path, "utf8");
56268
+ raw = readFileSync12(path, "utf8");
55845
56269
  } catch {
55846
56270
  return;
55847
56271
  }
@@ -56267,7 +56691,7 @@ var init_slash_palette = __esm(() => {
56267
56691
 
56268
56692
  // ../tui-base/src/routes/session/skills-manage.ts
56269
56693
  import { existsSync as existsSync11 } from "fs";
56270
- import { lstat, mkdir as mkdir3, readFile as readFile3, readdir, realpath, symlink, unlink } from "fs/promises";
56694
+ import { lstat, mkdir as mkdir4, readFile as readFile4, readdir, realpath, symlink, unlink } from "fs/promises";
56271
56695
  import { join as join14, sep } from "path";
56272
56696
  function skillSymlinkPaths(publicDir, curatedDir, name) {
56273
56697
  const srcMd = join14(publicDir, `${name}.md`);
@@ -56410,7 +56834,7 @@ function oneLine2(value) {
56410
56834
  }
56411
56835
  async function readSkillDescription(path) {
56412
56836
  try {
56413
- const text = await readFile3(path, "utf8");
56837
+ const text = await readFile4(path, "utf8");
56414
56838
  const front = parseFrontmatter(text);
56415
56839
  if (front === undefined)
56416
56840
  return "";
@@ -56457,7 +56881,7 @@ function skillStateText(row, pendingState) {
56457
56881
  }
56458
56882
  async function ensureCuratedDir(curatedDir) {
56459
56883
  try {
56460
- await mkdir3(curatedDir, { recursive: true });
56884
+ await mkdir4(curatedDir, { recursive: true });
56461
56885
  } catch {}
56462
56886
  }
56463
56887
  var SKILL_SUMMARY_MAX_ITEMS = 3, DESCRIPTION_MAX2 = 90;
@@ -61897,6 +62321,7 @@ function AgentsPanel(props) {
61897
62321
  const ownTop = layers().at(-1)?.handle;
61898
62322
  return {
61899
62323
  mode: "global",
62324
+ capture: "overlay",
61900
62325
  enabled: open() && ownTop?.ownsInput() === true,
61901
62326
  priority: 2,
61902
62327
  commands: [
@@ -63704,7 +64129,7 @@ var init_subagents_viewer = __esm(() => {
63704
64129
  import { TextAttributes as TextAttributes12 } from "@opentui/core";
63705
64130
  function resolveVersion() {
63706
64131
  try {
63707
- return "0.23.2";
64132
+ return "0.24.0";
63708
64133
  } catch {
63709
64134
  return "dev";
63710
64135
  }
@@ -63760,6 +64185,19 @@ function naRow(id, label, note) {
63760
64185
  note
63761
64186
  };
63762
64187
  }
64188
+ function hostSettingsAvailable(ctx) {
64189
+ return ctx.host;
64190
+ }
64191
+ function settingsRowsForMode(rows, ctx) {
64192
+ if (hostSettingsAvailable(ctx))
64193
+ return [...rows];
64194
+ return rows.filter((row) => row.kind === "jump" || row.editable && row.write !== undefined);
64195
+ }
64196
+ function visibleSettingsSections(ctx) {
64197
+ if (hostSettingsAvailable(ctx))
64198
+ return SETTINGS_SECTIONS;
64199
+ return SETTINGS_SECTIONS.filter((section) => section.id !== "host");
64200
+ }
63763
64201
  function buildGeneralRows(ctx) {
63764
64202
  const hostRows = buildHostItems(ctx.document, ctx.host, ctx.catalog);
63765
64203
  const permission = hostRows.find((row) => row.id === "permission.defaultPreset");
@@ -63792,7 +64230,7 @@ function buildGeneralRows(ctx) {
63792
64230
  id: "general.session-log",
63793
64231
  label: t("settings.row.sessionLogUpload")
63794
64232
  };
63795
- return [permissionRow, {
64233
+ const rows = [permissionRow, {
63796
64234
  id: "general.language",
63797
64235
  label: t("settings.row.language"),
63798
64236
  value: hintsLocaleFromConfig(ctx.merged.lang) ?? hintsLocaleFromConfig(ctx.merged.hintsLocale) ?? "en",
@@ -63852,9 +64290,10 @@ function buildGeneralRows(ctx) {
63852
64290
  kind: "readonly",
63853
64291
  editable: false
63854
64292
  }];
64293
+ return settingsRowsForMode(rows, ctx);
63855
64294
  }
63856
64295
  function buildOpentuiRows(ctx) {
63857
- return buildLocalItems({
64296
+ const rows = buildLocalItems({
63858
64297
  merged: ctx.merged,
63859
64298
  profile: ctx.profile,
63860
64299
  workspace: ctx.workspace,
@@ -63862,16 +64301,20 @@ function buildOpentuiRows(ctx) {
63862
64301
  themeNames: ctx.themeNames
63863
64302
  } : {},
63864
64303
  writable: ctx.local
63865
- }).filter((item) => item.id !== "lang").map(fromItem);
64304
+ }).filter((item) => item.id !== "lang").map((row) => row.id === "activityPanelHeight" ? {
64305
+ ...row,
64306
+ note: t("settings.row.activityPanelHeightNote")
64307
+ } : row).map(fromItem);
64308
+ return settingsRowsForMode(rows, ctx);
63866
64309
  }
63867
64310
  function buildHostRows(ctx) {
63868
- return buildHostItems(ctx.document, ctx.host, ctx.catalog).map(fromItem);
64311
+ return settingsRowsForMode(buildHostItems(ctx.document, ctx.host, ctx.catalog).map(fromItem), ctx);
63869
64312
  }
63870
64313
  function buildOtherRows(ctx) {
63871
- return buildOtherItems(ctx.document).map((item) => ({
64314
+ return settingsRowsForMode(buildOtherItems(ctx.document).map((item) => ({
63872
64315
  ...fromItem(item),
63873
64316
  kind: "readonly"
63874
- }));
64317
+ })), ctx);
63875
64318
  }
63876
64319
  function settingsCommandSpec(id) {
63877
64320
  switch (id) {
@@ -63978,16 +64421,43 @@ async function writeSetting(row, value, deps) {
63978
64421
  ok: false,
63979
64422
  error: `\u2718 ${plan.error}`
63980
64423
  };
63981
- try {
63982
- deps.seam.configSave?.(plan.patch);
63983
- } catch (error) {
64424
+ const isLocalGear = row.write.key === "session.activity_panel_height";
64425
+ const locallyPersisted = isLocalGear && deps.uiStatePath !== undefined;
64426
+ if (locallyPersisted) {
64427
+ try {
64428
+ await writeUiState(deps.uiStatePath, {
64429
+ session: {
64430
+ activity_panel_height: plan.applied === undefined ? undefined : String(plan.applied)
64431
+ }
64432
+ });
64433
+ } catch (error) {
64434
+ return {
64435
+ ok: false,
64436
+ error: t("settings.error.writeFailed", {
64437
+ detail: error instanceof Error ? error.message : String(error)
64438
+ })
64439
+ };
64440
+ }
64441
+ }
64442
+ if (deps.seam.configSave === undefined && !locallyPersisted) {
64443
+ applySettingsLive(row, plan.applied, hints, deps.themes);
63984
64444
  return {
63985
64445
  ok: false,
63986
- error: t("settings.error.writeFailed", {
63987
- detail: error instanceof Error ? error.message : String(error)
63988
- })
64446
+ error: t("settings.error.configNotPersistable")
63989
64447
  };
63990
64448
  }
64449
+ if (deps.seam.configSave !== undefined) {
64450
+ try {
64451
+ deps.seam.configSave(plan.patch);
64452
+ } catch (error) {
64453
+ return {
64454
+ ok: false,
64455
+ error: t("settings.error.writeFailed", {
64456
+ detail: error instanceof Error ? error.message : String(error)
64457
+ })
64458
+ };
64459
+ }
64460
+ }
63991
64461
  applySettingsLive(row, plan.applied, hints, deps.themes);
63992
64462
  return {
63993
64463
  ok: true,
@@ -64101,6 +64571,7 @@ function SettingsModalBody(props) {
64101
64571
  const [editorRow, setEditorRow] = createSignal(undefined);
64102
64572
  const [editorValue, setEditorValue] = createSignal("");
64103
64573
  const [optionCursor, setOptionCursor] = createSignal(0);
64574
+ const localUiStatePath = defaultUiStatePath();
64104
64575
  const [merged, setMerged] = createSignal({});
64105
64576
  const [profile, setProfile] = createSignal({});
64106
64577
  const [workspace, setWorkspace] = createSignal({});
@@ -64131,7 +64602,7 @@ function SettingsModalBody(props) {
64131
64602
  }));
64132
64603
  const sections = createMemo(() => {
64133
64604
  const ctx = rowContext();
64134
- return SETTINGS_SECTIONS.map((section) => ({
64605
+ return visibleSettingsSections(ctx).map((section) => ({
64135
64606
  ...section,
64136
64607
  rows: buildSectionRows(section.id, ctx)
64137
64608
  }));
@@ -64178,7 +64649,19 @@ function SettingsModalBody(props) {
64178
64649
  }
64179
64650
  function reloadLocal() {
64180
64651
  const snapshot = readLocalSnapshot(props.seam);
64181
- setMerged(snapshot.merged);
64652
+ const local = readUiStateSync(localUiStatePath);
64653
+ const localGear = local.session?.activity_panel_height;
64654
+ const merged = {
64655
+ ...snapshot.merged
64656
+ };
64657
+ if (localGear !== undefined) {
64658
+ const session = typeof merged.session === "object" && merged.session !== null ? merged.session : {};
64659
+ merged.session = {
64660
+ ...session,
64661
+ activity_panel_height: localGear
64662
+ };
64663
+ }
64664
+ setMerged(merged);
64182
64665
  setProfile(snapshot.profile);
64183
64666
  setWorkspace(snapshot.workspace);
64184
64667
  }
@@ -64261,7 +64744,8 @@ function SettingsModalBody(props) {
64261
64744
  document: document()
64262
64745
  } : {},
64263
64746
  local: writable().local,
64264
- host: writable().host
64747
+ host: writable().host,
64748
+ uiStatePath: localUiStatePath
64265
64749
  });
64266
64750
  if (result.document !== undefined)
64267
64751
  setDocument(result.document);
@@ -64980,6 +65464,7 @@ var init_settings_modal = __esm(() => {
64980
65464
  init_i18n();
64981
65465
  init_hints_line();
64982
65466
  init_settings_panel();
65467
+ init_ui_state();
64983
65468
  SETTINGS_SECTIONS = [
64984
65469
  {
64985
65470
  id: "general"
@@ -65397,6 +65882,7 @@ function createTuiPanelKeymapHost(keymap) {
65397
65882
  return Keymap2.createLayer(() => {
65398
65883
  const layer = input();
65399
65884
  return {
65885
+ capture: "overlay",
65400
65886
  ...layer.mode === undefined ? {} : {
65401
65887
  mode: layer.mode
65402
65888
  },
@@ -65495,440 +65981,15 @@ var init_jsx_dev_runtime = __esm(() => {
65495
65981
  init_jsx_runtime();
65496
65982
  });
65497
65983
 
65498
- // src/client/session-seam-adapter.ts
65499
- var exports_session_seam_adapter = {};
65500
- __export(exports_session_seam_adapter, {
65501
- NOTICE_SOURCE_KINDS: () => NOTICE_SOURCE_KINDS,
65502
- RemoteSessionSeam: () => RemoteSessionSeam,
65503
- projectJournalRecord: () => projectJournalRecord
65504
- });
65505
-
65506
- class RemoteSessionSeam {
65507
- #session;
65508
- #listeners = [];
65509
- #turnInFlight = false;
65510
- #unjournal;
65511
- #pluginsRevision = createSignal(0);
65512
- #unplugins;
65513
- #pluginsPushListeners = [];
65514
- constructor(session) {
65515
- this.#session = session;
65516
- registerSubagentSteer((id, text) => this.#session.steerChild(id, text));
65517
- this.#unplugins = session.onPluginsChanged?.(() => {
65518
- this.#pluginsRevision[1]((n) => n + 1);
65519
- for (const listener of this.#pluginsPushListeners) {
65520
- try {
65521
- listener();
65522
- } catch {}
65523
- }
65524
- }) ?? undefined;
65525
- }
65526
- status() {
65527
- const s = this.#session.status;
65528
- return { connection: s.connection, turn: s.turn, sessionAttached: s.sessionAttached };
65529
- }
65530
- async listSessions(limit) {
65531
- const rows = await this.#session.listSessions(limit);
65532
- return rows.map((row) => ({
65533
- id: row.id,
65534
- title: row.title,
65535
- ...row.updatedAt !== undefined ? { updatedAt: row.updatedAt } : {},
65536
- ...row.cwd !== undefined ? { cwd: row.cwd } : {},
65537
- ...row.sizeBytes !== undefined ? { sizeBytes: row.sizeBytes } : {},
65538
- ...row.blank !== undefined ? { blank: row.blank } : {}
65539
- }));
65540
- }
65541
- async searchSessions(query) {
65542
- return this.#session.searchSessions(query);
65543
- }
65544
- async sessionJournal(sessionId) {
65545
- return this.#session.sessionJournal(sessionId);
65546
- }
65547
- async forkSession(sessionId, seqEnd) {
65548
- return this.#session.forkSession(sessionId, seqEnd);
65549
- }
65550
- async storedTranscript(id, skip) {
65551
- const rows = await this.#session.storedTranscript(id, skip);
65552
- return rows.map((row) => {
65553
- if (row.kind === "ask") {
65554
- return { kind: row.kind, text: "", final: true, entries: row.entries };
65555
- }
65556
- if (row.kind === "tool") {
65557
- return { kind: "tool", text: row.name, final: true, args: row.args, output: row.brief, ok: row.ok };
65558
- }
65559
- return {
65560
- kind: row.kind,
65561
- text: row.text,
65562
- final: row.kind === "assistant" ? row.final ?? true : true
65563
- };
65564
- });
65565
- }
65566
- currentSessionId() {
65567
- return this.#session.currentSessionId();
65568
- }
65569
- stagedSessionId() {
65570
- return this.#session.stagedSessionId();
65571
- }
65572
- cacheHitRate(mode) {
65573
- return this.#session.cacheHitRate(mode);
65574
- }
65575
- contextTokens() {
65576
- return this.#session.contextTokens();
65577
- }
65578
- contextWindow() {
65579
- return this.#session.contextWindow() ?? null;
65580
- }
65581
- configLoad() {
65582
- return this.#session.configLoad();
65583
- }
65584
- configSave(patch) {
65585
- return this.#session.configSave(patch);
65586
- }
65587
- configRaw() {
65588
- return this.#session.configRaw();
65589
- }
65590
- workspaceConfig() {
65591
- return this.#session.workspaceConfig();
65592
- }
65593
- async sessionInfo() {
65594
- const base = this.#session.sessionInfo();
65595
- const sessionId = base.sessionId ?? this.#session.stagedSessionId?.();
65596
- if (sessionId === undefined)
65597
- return;
65598
- let messageCount = 0;
65599
- let turnCount = 0;
65600
- try {
65601
- const rows = await this.#session.storedTranscript(sessionId);
65602
- messageCount = rows.filter((row) => row.kind === "user" || row.kind === "assistant").length;
65603
- turnCount = rows.filter((row) => row.kind === "user").length;
65604
- } catch {}
65605
- const msgCount = base.sessionId === undefined ? undefined : base.msgCount;
65606
- return {
65607
- ...base,
65608
- sessionId,
65609
- model: base.model ?? null,
65610
- messageCount,
65611
- turnCount,
65612
- msgCount,
65613
- contextTokens: base.contextTokens,
65614
- contextWindow: base.contextWindow ?? null
65615
- };
65616
- }
65617
- resumeSession(id) {
65618
- return this.#session.resumeSession(id);
65619
- }
65620
- repairScanBroken() {
65621
- return this.#session.repairScanBroken();
65622
- }
65623
- repairSessionLog(path) {
65624
- return this.#session.repairSessionLog(path);
65625
- }
65626
- newSession() {
65627
- this.#session.newSession();
65628
- }
65629
- async renameSession(title) {
65630
- return this.#session.renameSession(title);
65631
- }
65632
- async turn(userText, cb) {
65633
- this.#turnInFlight = true;
65634
- try {
65635
- await this.#session.turn(userText, {
65636
- onThinkingDelta: (text) => cb.onThinkingDelta(text),
65637
- onContentDelta: (text) => cb.onContentDelta(text),
65638
- onTurnEnd: () => {},
65639
- onApprove: async (name, args) => await cb.onApprove(name, args) === "allowed-once",
65640
- onToolStart: (start) => cb.onToolStart?.(start),
65641
- onToolRun: (run) => cb.onToolRun?.(run),
65642
- onError: (message) => cb.onError(message)
65643
- });
65644
- } finally {
65645
- this.#turnInFlight = false;
65646
- }
65647
- }
65648
- steer(text) {
65649
- this.#session.steer(text);
65650
- }
65651
- interrupt() {
65652
- this.#session.abort();
65653
- }
65654
- registerAskProvider(onAsk) {
65655
- this.#session.registerAskProvider(async (questions) => onAsk(questions));
65656
- }
65657
- async listProviders() {
65658
- return this.#session.listProviders();
65659
- }
65660
- async modelCatalog(force) {
65661
- const catalog = await this.#session.modelCatalog(force ?? false);
65662
- const rows = [];
65663
- for (const group of Array.isArray(catalog.groups) ? catalog.groups : []) {
65664
- const providerID = String(group?.id ?? "");
65665
- if (!providerID)
65666
- continue;
65667
- for (const model of Array.isArray(group.models) ? group.models : []) {
65668
- const modelID = String(model?.id ?? "");
65669
- if (modelID)
65670
- rows.push({ providerID, modelID });
65671
- }
65672
- }
65673
- return rows;
65674
- }
65675
- async currentModelSelection() {
65676
- const selection = await this.#session.currentModelSelection();
65677
- if (!selection)
65678
- return;
65679
- return { providerID: selection.provider, modelID: selection.model };
65680
- }
65681
- selectModel(providerID, modelID) {
65682
- return this.#session.selectModel({ provider: providerID, model: modelID }).then(() => {
65683
- return;
65684
- });
65685
- }
65686
- lastSelectionError() {
65687
- return this.#session.lastSelectionError();
65688
- }
65689
- thinking = {
65690
- efforts: async () => {
65691
- try {
65692
- const selection = await this.#session.currentModelSelection();
65693
- if (!selection)
65694
- return [];
65695
- const catalog = await this.#session.modelCatalog(false);
65696
- const group = Array.isArray(catalog.groups) ? catalog.groups.find((g) => String(g?.id ?? "") === selection.provider) : undefined;
65697
- const model = Array.isArray(group?.models) ? group.models.find((m) => String(m?.id ?? "") === selection.model) : undefined;
65698
- const efforts = model?.reasoning?.efforts;
65699
- if (!Array.isArray(efforts) || efforts.length === 0)
65700
- return [];
65701
- return efforts.map((e) => ({
65702
- id: String(typeof e === "object" && e !== null ? e?.id ?? "" : e ?? ""),
65703
- name: String(typeof e === "object" && e !== null ? e?.name ?? e?.id ?? "" : e ?? ""),
65704
- ...typeof e === "object" && e !== null && typeof e?.description === "string" && e.description ? { description: e.description } : {}
65705
- })).filter((e) => e.id);
65706
- } catch {
65707
- return [];
65708
- }
65709
- },
65710
- effortsFor: (providerID, modelID) => this.#session.modelEfforts(providerID, modelID),
65711
- currentEffort: async () => {
65712
- const selection = await this.#session.currentModelSelection();
65713
- return selection?.reasoningEffort;
65714
- },
65715
- selectEffort: (effort) => {
65716
- return this.#session.currentModelSelection().then((selection) => {
65717
- if (!selection)
65718
- return;
65719
- return this.#session.selectModel({
65720
- provider: selection.provider,
65721
- model: selection.model,
65722
- ...effort ? { reasoningEffort: effort } : {}
65723
- });
65724
- }).then(() => {
65725
- return;
65726
- });
65727
- }
65728
- };
65729
- usageSummary() {
65730
- return this.#session.usageSummary();
65731
- }
65732
- btwAsk(question, snapshot, onDelta) {
65733
- return this.#session.btwAsk(question, snapshot, onDelta);
65734
- }
65735
- plugins() {
65736
- this.#pluginsRevision[0]();
65737
- return this.#session.listPlugins();
65738
- }
65739
- onPluginsChanged(listener) {
65740
- this.#pluginsPushListeners.push(listener);
65741
- return () => {
65742
- const index = this.#pluginsPushListeners.indexOf(listener);
65743
- if (index >= 0)
65744
- this.#pluginsPushListeners.splice(index, 1);
65745
- };
65746
- }
65747
- pluginBundles() {
65748
- this.#pluginsRevision[0]();
65749
- return this.#session.listBundles();
65750
- }
65751
- setPluginBundleEnabled(name, enabled) {
65752
- return this.#session.setBundleEnabled(name, enabled);
65753
- }
65754
- removePluginBundle(name) {
65755
- return this.#session.removeBundle(name);
65756
- }
65757
- inspectPluginSpec(spec) {
65758
- return this.#session.inspectBundle(spec);
65759
- }
65760
- installPluginSpec(spec) {
65761
- return this.#session.installBundle(spec);
65762
- }
65763
- async refreshSkills() {
65764
- return this.#session.refreshSkills();
65765
- }
65766
- onSkillsChanged(listener) {
65767
- return this.#session.onSkillsChanged(listener);
65768
- }
65769
- preset = {
65770
- list: () => this.#session.listPresets(),
65771
- currentId: async () => this.#session.resolveCurrentPresetId(),
65772
- select: async (presetId) => {
65773
- try {
65774
- this.#session.switchPreset(presetId);
65775
- return true;
65776
- } catch (error) {
65777
- console.error("[session-seam-adapter] preset switch failed:", error);
65778
- return false;
65779
- }
65780
- }
65781
- };
65782
- agents = {
65783
- list: () => this.#session.listAgents(),
65784
- dir: () => this.#session.agentsDir(),
65785
- set: (name, field, value) => {
65786
- const result = this.#session.agentSet(name, field, value);
65787
- return { target: result.target, ...result.error !== undefined ? { error: result.error } : {} };
65788
- },
65789
- body: (name) => this.#session.agentBody(name),
65790
- modelEfforts: (providerID, modelID) => this.#session.modelEfforts(providerID, modelID),
65791
- officialCaps: () => this.#session.agentOfficialCaps()
65792
- };
65793
- settings = {
65794
- describe: async () => {
65795
- const doc = await this.#session.settingsDocument();
65796
- return {
65797
- writable: doc.writable,
65798
- hasDocument: doc.hasDocument,
65799
- namespaces: doc.namespaces.map(asSeamSettingsRow)
65800
- };
65801
- },
65802
- mutate: async (ns, ops, revision) => {
65803
- try {
65804
- await this.#session.settingsMutate(ns, ops, revision);
65805
- return { ok: true };
65806
- } catch (error) {
65807
- return {
65808
- ok: false,
65809
- conflict: error?.code === "settings/conflict",
65810
- error: error instanceof Error ? error.message : String(error)
65811
- };
65812
- }
65813
- },
65814
- onChanged: (listener) => this.#session.onSettingsUpdated(listener),
65815
- identity: () => ({
65816
- profile: this.#session.profileName(),
65817
- dshHome: this.#session.homeDir()
65818
- }),
65819
- permissionCatalog: () => this.#session.permissionCatalog()
65820
- };
65821
- login = {
65822
- credentialStatus: (ref) => this.#session.credentialStatus(ref),
65823
- login: (ref, apiKey) => this.#session.login(ref, apiKey),
65824
- logout: (ref) => this.#session.logout(ref),
65825
- routes: async () => {
65826
- const rows = await this.#session.settingsSeam.describe();
65827
- const ns = Array.isArray(rows) ? rows.find((row) => row?.ns === "llm-pi-ai") : undefined;
65828
- const providers = ns?.value?.providers ?? {};
65829
- return Object.entries(providers).map(([id, profile]) => {
65830
- const p = typeof profile === "object" && profile !== null ? profile : {};
65831
- const apiKeyEnv = p.apiKeyEnv;
65832
- const displayName = p.displayName;
65833
- return {
65834
- id,
65835
- ...typeof apiKeyEnv === "string" && apiKeyEnv !== "" ? { apiKeyEnv } : {},
65836
- ...typeof displayName === "string" && displayName !== "" ? { displayName } : {},
65837
- ...typeof p.api === "string" || typeof p.baseURL === "string" || Array.isArray(p.models) ? { declared: true } : {}
65838
- };
65839
- });
65840
- },
65841
- registerRoute: async (providerId, profile) => {
65842
- try {
65843
- const rows = await this.#session.settingsSeam.describe();
65844
- const ns = Array.isArray(rows) ? rows.find((row) => row?.ns === "llm-pi-ai") : undefined;
65845
- const ops = profile ? [{ op: "set", path: ["providers", providerId], value: profile }] : [{ op: "unset", path: ["providers", providerId] }];
65846
- await this.#session.settingsSeam.mutate("llm-pi-ai", ops, ns?.revision);
65847
- return true;
65848
- } catch (error) {
65849
- console.error("[session-seam-adapter] login route registration failed:", error);
65850
- return false;
65851
- }
65852
- }
65853
- };
65854
- #projectSubagentViews(views) {
65855
- return views.map((v) => ({
65856
- id: v.id,
65857
- label: v.label,
65858
- ...v.model ? { model: v.model } : {},
65859
- status: v.status,
65860
- rounds: v.rounds,
65861
- ...v.startedAt !== undefined ? v.status === "running" ? { startedAt: v.startedAt } : { elapsedSec: Number(((Date.now() - v.startedAt) / 1000).toFixed(1)) } : {},
65862
- ...v.status !== "running" && v.endedAt !== undefined ? { endedAt: v.endedAt } : {},
65863
- ...v.injectedRound !== undefined ? { injectedRound: v.injectedRound } : {},
65864
- ...v.hardStopRound !== undefined ? { hardStopRound: v.hardStopRound } : {},
65865
- ...v.spinStopRound !== undefined ? { spinStopRound: v.spinStopRound } : {},
65866
- ...v.lastLine !== undefined ? { lastLine: v.lastLine } : {}
65867
- }));
65868
- }
65869
- subagentViews() {
65870
- return this.#projectSubagentViews(this.#session.subagentViews());
65871
- }
65872
- onSubagentViews(listener) {
65873
- foldSubagentMarkerViews(this.subagentViews());
65874
- return this.#session.onSubagentViews((views) => {
65875
- const projected = this.#projectSubagentViews(views);
65876
- foldSubagentMarkerViews(projected);
65877
- listener(projected);
65878
- });
65879
- }
65880
- steerChild(id, text) {
65881
- return this.#session.steerChild(id, text);
65882
- }
65883
- subagentTranscript(id) {
65884
- return this.#session.childTranscript(id);
65885
- }
65886
- async interruptChild(id) {
65887
- await this.#session.interruptChild(id);
65888
- }
65889
- onSessionEvent(listener) {
65890
- this.#listeners.push(listener);
65891
- this.#ensureJournalFeed();
65892
- return () => {
65893
- const index = this.#listeners.indexOf(listener);
65894
- if (index >= 0)
65895
- this.#listeners.splice(index, 1);
65896
- };
65897
- }
65898
- async dispose() {
65899
- this.#unjournal?.();
65900
- this.#unjournal = undefined;
65901
- this.#unplugins?.();
65902
- this.#unplugins = undefined;
65903
- this.#listeners.length = 0;
65904
- this.#pluginsPushListeners.length = 0;
65905
- await this.#session.dispose();
65906
- }
65907
- #ensureJournalFeed() {
65908
- if (this.#unjournal !== undefined)
65909
- return;
65910
- const hook = this.#session;
65911
- if (typeof hook.onJournalRecord !== "function")
65912
- return;
65913
- this.#unjournal = hook.onJournalRecord((entry) => {
65914
- if (this.#turnInFlight)
65915
- return;
65916
- for (const event of projectJournalRecord(entry, this.#session.currentSessionId() ?? "")) {
65917
- this.#emit(event);
65918
- }
65919
- });
65920
- }
65921
- #emit(event) {
65922
- for (const listener of this.#listeners) {
65923
- try {
65924
- listener(event);
65925
- } catch {}
65926
- }
65927
- }
65984
+ // src/client/journal-projection.ts
65985
+ function assistantTextValue(data) {
65986
+ if (typeof data.text === "string")
65987
+ return data.text.trim();
65988
+ return blocksText(data.content ?? data.parts);
65928
65989
  }
65929
65990
  function projectJournalRecord(entry, sessionId) {
65930
65991
  if (entry.type === "user/message") {
65931
- const text = blocksText3(entry.data.content);
65992
+ const text = blocksText(entry.data.content);
65932
65993
  if (!text)
65933
65994
  return [];
65934
65995
  const id = typeof entry.data.messageID === "string" ? entry.data.messageID : `journal-${entry.seq}`;
@@ -65962,42 +66023,377 @@ function projectJournalRecord(entry, sessionId) {
65962
66023
  }
65963
66024
  return [];
65964
66025
  }
65965
- function blocksText3(content) {
65966
- const blocks = Array.isArray(content) ? content : [];
65967
- let text = "";
65968
- for (const block of blocks) {
65969
- if (typeof block === "object" && block !== null && block.type === "text") {
65970
- const value = block.text;
65971
- if (typeof value === "string")
65972
- text += (text === "" ? "" : `
65973
- `) + value;
66026
+ var NOTICE_SOURCE_KINDS;
66027
+ var init_journal_projection = __esm(() => {
66028
+ init_remote_follow();
66029
+ NOTICE_SOURCE_KINDS = new Set(["subagent-settled", "agent-message", "team-message", "webhook"]);
66030
+ });
66031
+
66032
+ // src/client/local-config-faces.ts
66033
+ import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync13, renameSync as renameSync9, rmSync as rmSync5, writeFileSync as writeFileSync9 } from "fs";
66034
+ import { dirname as dirname7, join as join15 } from "path";
66035
+ function asRecord5(value) {
66036
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
66037
+ }
66038
+ function parseScalar(raw) {
66039
+ const v = raw.trim();
66040
+ if (v === "true")
66041
+ return true;
66042
+ if (v === "false")
66043
+ return false;
66044
+ if (v === "null" || v === "~")
66045
+ return null;
66046
+ if (/^-?\d+$/.test(v))
66047
+ return Number(v);
66048
+ if (/^-?\d+\.\d+$/.test(v))
66049
+ return Number(v);
66050
+ return v.replace(/^["']|["']$/g, "");
66051
+ }
66052
+ function nsEntrySpan(lines, ns) {
66053
+ const start = lines.findIndex((line) => new RegExp(`^- id:\\s*${ns}\\s*$`).test(line));
66054
+ if (start < 0)
66055
+ return;
66056
+ let end = lines.length;
66057
+ for (let i = start + 1;i < lines.length; i++) {
66058
+ if (/^- /.test(lines[i]) || /^-insert:/.test(lines[i]) || /^-\s+insert:/.test(lines[i])) {
66059
+ end = i;
66060
+ break;
65974
66061
  }
65975
66062
  }
65976
- return text.trim();
66063
+ return [start, end];
65977
66064
  }
65978
- function assistantTextValue(data) {
65979
- if (typeof data.text === "string")
65980
- return data.text.trim();
65981
- return blocksText3(data.content ?? data.parts);
66065
+ function readNsValue(lines, ns) {
66066
+ const span = nsEntrySpan(lines, ns);
66067
+ const out = {};
66068
+ const fields = NS_VALUE_FIELDS[ns];
66069
+ if (span === undefined)
66070
+ return out;
66071
+ let inConfig = false;
66072
+ for (let i = span[0] + 1;i < span[1]; i++) {
66073
+ const line = lines[i];
66074
+ if (/^\s{2}config:\s*$/.test(line)) {
66075
+ inConfig = true;
66076
+ continue;
66077
+ }
66078
+ if (inConfig && /^\s{2}\S/.test(line))
66079
+ break;
66080
+ if (!inConfig)
66081
+ continue;
66082
+ const m = /^\s{4}([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/.exec(line);
66083
+ if (m && fields.includes(m[1]))
66084
+ out[m[1]] = parseScalar(m[2]);
66085
+ }
66086
+ return out;
65982
66087
  }
65983
- function asSeamSettingsRow(row) {
65984
- return {
65985
- ns: row.ns,
65986
- ...row.revision !== undefined ? { revision: row.revision } : {},
65987
- ...row.value !== undefined ? { value: row.value } : {},
65988
- ...row.base !== undefined ? { base: row.base } : {},
65989
- ...row.autoGenerate !== undefined ? { autoGenerate: row.autoGenerate } : {},
65990
- ...row.schema !== undefined ? { schema: row.schema } : {},
65991
- ...row.user !== undefined ? { user: row.user } : {},
65992
- ...row.secrets !== undefined ? { secrets: row.secrets.map((secret) => ({ path: [...secret.path], set: secret.set })) } : {}
65993
- };
66088
+ function writeNsField(lines, ns, key, raw) {
66089
+ const fields = NS_VALUE_FIELDS[ns];
66090
+ if (!fields.includes(key))
66091
+ return false;
66092
+ const yaml = /^(true|false|null|~|-?\d+(?:\.\d+)?)$/.test(raw.trim()) || /^["']/.test(raw.trim()) ? raw.trim() : JSON.stringify(raw);
66093
+ const span = nsEntrySpan(lines, ns);
66094
+ if (span === undefined) {
66095
+ lines.push("", `- id: ${ns}`, ` name: '${NS_PACKAGE[ns]}'`, " config:", ` ${key}: ${yaml}`);
66096
+ return true;
66097
+ }
66098
+ let configLine = -1;
66099
+ for (let i = span[0] + 1;i < span[1]; i++) {
66100
+ if (/^\s{2}config:\s*$/.test(lines[i])) {
66101
+ configLine = i;
66102
+ break;
66103
+ }
66104
+ }
66105
+ if (configLine < 0) {
66106
+ lines.splice(span[0] + 1, 0, " config:", ` ${key}: ${yaml}`);
66107
+ return true;
66108
+ }
66109
+ for (let i = configLine + 1;i < span[1]; i++) {
66110
+ const m = /^(\s{4})([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/.exec(lines[i]);
66111
+ if (!m)
66112
+ continue;
66113
+ if (/^\s{2}\S/.test(lines[i]))
66114
+ break;
66115
+ if (m[2] === key) {
66116
+ lines[i] = ` ${key}: ${yaml}`;
66117
+ return true;
66118
+ }
66119
+ }
66120
+ lines.splice(configLine + 1, 0, ` ${key}: ${yaml}`);
66121
+ return true;
65994
66122
  }
65995
- var NOTICE_SOURCE_KINDS;
65996
- var init_session_seam_adapter = __esm(() => {
65997
- init_remote_follow();
65998
- init_subagent_markers();
65999
- init_server();
66000
- NOTICE_SOURCE_KINDS = new Set(["subagent-settled", "agent-message", "team-message", "webhook"]);
66123
+ function atomicWrite2(path, text) {
66124
+ mkdirSync7(dirname7(path), { recursive: true });
66125
+ const tmp = `${path}.${process.pid}.s5.tmp`;
66126
+ try {
66127
+ writeFileSync9(tmp, text);
66128
+ renameSync9(tmp, path);
66129
+ } catch (err) {
66130
+ try {
66131
+ rmSync5(tmp, { force: true });
66132
+ } catch {}
66133
+ throw err;
66134
+ }
66135
+ }
66136
+
66137
+ class LocalSettingsStore {
66138
+ #patchPath;
66139
+ constructor(home, profile) {
66140
+ this.#patchPath = join15(home, "profiles", profile, "cordis.patch.yml");
66141
+ }
66142
+ describe() {
66143
+ let lines = [];
66144
+ try {
66145
+ lines = readFileSync13(this.#patchPath, "utf8").split(`
66146
+ `);
66147
+ } catch {}
66148
+ const namespaces = SETTINGS_NAMESPACES.map((ns) => {
66149
+ const patchValue = readNsValue(lines, ns);
66150
+ const value = {};
66151
+ for (const field of NS_VALUE_FIELDS[ns]) {
66152
+ const v = patchValue[field] ?? NS_DEFAULTS[ns][field];
66153
+ if (v !== undefined)
66154
+ value[field] = v;
66155
+ }
66156
+ const schema = {};
66157
+ for (const field of NS_VALUE_FIELDS[ns])
66158
+ schema[field] = { type: typeof value[field] };
66159
+ if (ns === "permission") {
66160
+ const presets = value.presets;
66161
+ if (presets && typeof presets === "object") {
66162
+ schema.defaultPreset = { type: "string", enum: Object.keys(presets) };
66163
+ }
66164
+ }
66165
+ return { ns, revision: 1, value, base: { ...value }, schema, secrets: [] };
66166
+ });
66167
+ const hidden = new Set([...SETTINGS_NAMESPACES, "dsh-tui"]);
66168
+ const seen = new Set(SETTINGS_NAMESPACES);
66169
+ const others = [];
66170
+ for (const line of lines) {
66171
+ const m = /^- id:\s*([A-Za-z0-9_.\-@/]+)\s*$/.exec(line);
66172
+ if (!m)
66173
+ continue;
66174
+ const ns = m[1];
66175
+ if (hidden.has(ns) || seen.has(ns))
66176
+ continue;
66177
+ seen.add(ns);
66178
+ others.push({ ns, revision: 1 });
66179
+ }
66180
+ others.sort((a, b) => a.ns === "agent-default-model" ? -1 : b.ns === "agent-default-model" ? 1 : 0);
66181
+ namespaces.push(...others);
66182
+ return { writable: true, hasDocument: existsSync12(this.#patchPath), namespaces };
66183
+ }
66184
+ mutate(ns, ops, _revision) {
66185
+ if (!SETTINGS_NAMESPACES.includes(ns)) {
66186
+ return { ok: false, conflict: false, error: `settings.mutate: namespace '${ns}' is not whitelisted` };
66187
+ }
66188
+ const allow = NS_VALUE_FIELDS[ns];
66189
+ for (const op of ops) {
66190
+ if (!Array.isArray(op.path) || op.path.length !== 1 || !allow.includes(op.path[0])) {
66191
+ return { ok: false, conflict: false, error: `settings.mutate: path not whitelisted for '${ns}'` };
66192
+ }
66193
+ }
66194
+ let text = "";
66195
+ try {
66196
+ text = readFileSync13(this.#patchPath, "utf8");
66197
+ } catch {}
66198
+ const lines = text.length > 0 ? text.split(`
66199
+ `) : [];
66200
+ for (const op of ops) {
66201
+ const key = op.path[0];
66202
+ if (op.op === "unset") {
66203
+ const fallback = NS_DEFAULTS[ns][key];
66204
+ if (fallback !== undefined)
66205
+ writeNsField(lines, ns, key, String(fallback));
66206
+ continue;
66207
+ }
66208
+ const value = op.value;
66209
+ if (typeof value === "object" && value !== null) {
66210
+ return { ok: false, conflict: false, error: "settings.mutate: nested value not whitelisted" };
66211
+ }
66212
+ writeNsField(lines, ns, key, String(value));
66213
+ }
66214
+ try {
66215
+ atomicWrite2(this.#patchPath, lines.join(`
66216
+ `).replace(/\n*$/, `
66217
+ `));
66218
+ } catch (err) {
66219
+ return { ok: false, conflict: false, error: err instanceof Error ? err.message : String(err) };
66220
+ }
66221
+ return { ok: true };
66222
+ }
66223
+ }
66224
+
66225
+ class LocalConfigStore {
66226
+ #configPath;
66227
+ #overlayPath;
66228
+ #overlayCache;
66229
+ constructor(home, profile, workspaceDir) {
66230
+ this.#configPath = join15(home, "profiles", profile, "config.json");
66231
+ this.#overlayPath = workspaceConfigPath(workspaceDir);
66232
+ this.#overlayCache = loadWorkspaceConfigState(workspaceDir);
66233
+ }
66234
+ #readProfile() {
66235
+ try {
66236
+ return asRecord5(JSON.parse(readFileSync13(this.#configPath, "utf8")));
66237
+ } catch {
66238
+ return {};
66239
+ }
66240
+ }
66241
+ configRaw() {
66242
+ return this.#readProfile();
66243
+ }
66244
+ configLoad() {
66245
+ const base = this.#readProfile();
66246
+ const merged = mergeConfig({ theme: typeof base.theme === "string" ? base.theme : undefined }, this.#overlayCache, process.env);
66247
+ const out = {};
66248
+ for (const key of CONFIG_KEYS)
66249
+ if (base[key] !== undefined)
66250
+ out[key] = base[key];
66251
+ if (merged.theme !== undefined)
66252
+ out.theme = merged.theme;
66253
+ if (merged.themeMode !== undefined)
66254
+ out.themeMode = merged.themeMode;
66255
+ if (merged.model !== undefined)
66256
+ out.model = merged.model;
66257
+ return out;
66258
+ }
66259
+ workspaceConfig() {
66260
+ return { ...this.#overlayCache };
66261
+ }
66262
+ configSave(patch) {
66263
+ const current = this.#readProfile();
66264
+ const next = {};
66265
+ for (const [key, value] of Object.entries(patch)) {
66266
+ if (CONFIG_KEY_SET.has(key))
66267
+ next[key] = value;
66268
+ }
66269
+ if (Object.keys(next).length === 0)
66270
+ return this.configLoad();
66271
+ const merged = { ...current, ...next };
66272
+ atomicWrite2(this.#configPath, JSON.stringify(merged, null, 2) + `
66273
+ `);
66274
+ return this.configLoad();
66275
+ }
66276
+ }
66277
+ function loadWorkspaceConfigState(workspaceDir) {
66278
+ try {
66279
+ const raw = JSON.parse(readFileSync13(join15(workspaceDir, ".dsh", "config.yml"), "utf8"));
66280
+ return asRecord5(raw);
66281
+ } catch {
66282
+ try {
66283
+ const text = readFileSync13(join15(workspaceDir, ".dsh", "config.yml"), "utf8");
66284
+ const out = {};
66285
+ const m = /^\s*theme:\s*(.+)$/m.exec(text);
66286
+ if (m)
66287
+ out.theme = parseScalar(m[1]);
66288
+ return out;
66289
+ } catch {
66290
+ return {};
66291
+ }
66292
+ }
66293
+ }
66294
+
66295
+ class LocalAgentsFace {
66296
+ #home;
66297
+ #workspaceDir;
66298
+ #settings;
66299
+ #modelCatalog;
66300
+ constructor(options) {
66301
+ this.#home = options.home;
66302
+ this.#workspaceDir = options.workspaceDir;
66303
+ this.#settings = options.settings;
66304
+ this.#modelCatalog = options.modelCatalog;
66305
+ }
66306
+ #rows() {
66307
+ return listComposedAgents(this.#home, this.#workspaceDir);
66308
+ }
66309
+ list() {
66310
+ return this.#rows().map((row) => ({
66311
+ name: row.name,
66312
+ ...row.displayName ? { displayName: row.displayName } : {},
66313
+ ...row.description ? { description: row.description } : {},
66314
+ ...row.model ? { model: row.model } : {},
66315
+ ...row.thinking ? { thinking: row.thinking } : {},
66316
+ deep: row.deep,
66317
+ ...row.maxRounds !== undefined ? { maxRounds: row.maxRounds } : {},
66318
+ ...row.background !== undefined ? { background: row.background } : {},
66319
+ file: row.file,
66320
+ ...row.pin ? { pin: row.pin } : {},
66321
+ ...row.broken ? { broken: row.broken } : {}
66322
+ }));
66323
+ }
66324
+ dir() {
66325
+ return join15(this.#home, "agents");
66326
+ }
66327
+ body(name) {
66328
+ return this.#rows().find((row) => row.name === name && row.broken === undefined)?.body ?? "";
66329
+ }
66330
+ set(name, field, value) {
66331
+ if (field === "deep" || field === "maxRounds" || field === "background") {
66332
+ const error = setAgentField(name, field, value, this.#home);
66333
+ return { target: { kind: "frontmatter" }, ...error ? { error } : {} };
66334
+ }
66335
+ const row = this.#rows().find((agent) => agent.name === name && agent.broken === undefined);
66336
+ if (row === undefined)
66337
+ return { target: { kind: "frontmatter" }, error: `agent "${name}" not found` };
66338
+ const result = commitAgentModelEdit(this.#home, this.#workspaceDir, row.file, name, { [field]: value });
66339
+ return { target: result.target, ...result.error ? { error: result.error } : {} };
66340
+ }
66341
+ async modelEfforts(providerID, modelID) {
66342
+ const catalog = await this.#modelCatalog();
66343
+ const model = catalog.groups.find((g) => g.id === providerID)?.models.find((m) => m.id === modelID);
66344
+ return model?.reasoning?.efforts ?? [];
66345
+ }
66346
+ async officialCaps() {
66347
+ const doc = this.#settings.describe();
66348
+ const row = doc.namespaces.find((n) => n.ns === "subagent");
66349
+ const value = asRecord5(row?.value);
66350
+ const caps = {};
66351
+ if (typeof value.maxActiveSubagents === "number" && Number.isFinite(value.maxActiveSubagents))
66352
+ caps.maxActiveSubagents = value.maxActiveSubagents;
66353
+ if (typeof value.maxDepth === "number" && Number.isFinite(value.maxDepth))
66354
+ caps.maxDepth = value.maxDepth;
66355
+ return caps;
66356
+ }
66357
+ }
66358
+ var SETTINGS_NAMESPACES, NS_VALUE_FIELDS, NS_PACKAGE, NS_DEFAULTS, CONFIG_KEYS, CONFIG_KEY_SET;
66359
+ var init_local_config_faces = __esm(() => {
66360
+ init_remote_agent_profiles();
66361
+ init_remote_local_fs();
66362
+ init_workspace_config();
66363
+ SETTINGS_NAMESPACES = ["subagent", "permission", "session-log-deepseek"];
66364
+ NS_VALUE_FIELDS = {
66365
+ subagent: ["maxActiveSubagents", "maxDepth"],
66366
+ permission: ["defaultPreset", "presets"],
66367
+ "session-log-deepseek": ["enabled"]
66368
+ };
66369
+ NS_PACKAGE = {
66370
+ subagent: "@deepseek-ai/dsh-subagent",
66371
+ permission: "@deepseek-ai/dsh-permission-presets",
66372
+ "session-log-deepseek": "@deepseek-ai/dsh-session-log-deepseek"
66373
+ };
66374
+ NS_DEFAULTS = {
66375
+ subagent: { maxActiveSubagents: 1, maxDepth: 1 },
66376
+ permission: { defaultPreset: "workspace-write" },
66377
+ "session-log-deepseek": { enabled: true }
66378
+ };
66379
+ CONFIG_KEYS = [
66380
+ "lang",
66381
+ "motion",
66382
+ "theme",
66383
+ "themeMode",
66384
+ "skin",
66385
+ "cacheHitMode",
66386
+ "footerHints",
66387
+ "hintsLocale",
66388
+ "autoResume",
66389
+ "autoResumeDays",
66390
+ "maxRoundsGrace",
66391
+ "activity_panel_height",
66392
+ "stepsDisplay",
66393
+ "stepsCollapse",
66394
+ "stepsFolded"
66395
+ ];
66396
+ CONFIG_KEY_SET = new Set(CONFIG_KEYS);
66001
66397
  });
66002
66398
 
66003
66399
  // src/client/bridge-session-seam.ts
@@ -66010,7 +66406,7 @@ function optionalStringField(row, key) {
66010
66406
  return typeof value === "string" && value !== "" ? value : undefined;
66011
66407
  }
66012
66408
  function parseAskRequest(value) {
66013
- const row = asRecord5(value);
66409
+ const row = asRecord6(value);
66014
66410
  const eventId = optionalStringField(row, "eventId");
66015
66411
  const sessionId = optionalStringField(row, "sessionId");
66016
66412
  const kind = row.kind;
@@ -66033,14 +66429,14 @@ function parseAskRequest(value) {
66033
66429
  if (Array.isArray(row.questions)) {
66034
66430
  const questions = [];
66035
66431
  for (const raw of row.questions) {
66036
- const q = asRecord5(raw);
66432
+ const q = asRecord6(raw);
66037
66433
  const id = optionalStringField(q, "id");
66038
66434
  const prompt = optionalStringField(q, "prompt");
66039
66435
  if (id === undefined || prompt === undefined || !Array.isArray(q.options))
66040
66436
  continue;
66041
66437
  const options = [];
66042
66438
  for (const rawOpt of q.options) {
66043
- const opt = asRecord5(rawOpt);
66439
+ const opt = asRecord6(rawOpt);
66044
66440
  const label = optionalStringField(opt, "label");
66045
66441
  if (label === undefined)
66046
66442
  continue;
@@ -66110,7 +66506,7 @@ function answersFor(request, picks) {
66110
66506
  function unavailableResponse(request) {
66111
66507
  return request.kind === "questions" ? { eventId: request.eventId, kind: "questions", verdict: "unavailable", answers: answersFor(request, []) } : { eventId: request.eventId, kind: "approval", verdict: "unavailable" };
66112
66508
  }
66113
- function asRecord5(value) {
66509
+ function asRecord6(value) {
66114
66510
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
66115
66511
  }
66116
66512
  function unsupported(capability) {
@@ -66120,14 +66516,14 @@ function projectBridgeSessionList(items, limit = 12) {
66120
66516
  const rows = Array.isArray(items) ? items : [];
66121
66517
  const out = [];
66122
66518
  for (const item of rows) {
66123
- const row = asRecord5(item);
66519
+ const row = asRecord6(item);
66124
66520
  if (row.origin === "subagent")
66125
66521
  continue;
66126
66522
  const id = typeof row.sessionId === "string" ? row.sessionId : "";
66127
66523
  if (!id)
66128
66524
  continue;
66129
66525
  const updatedAt = typeof row.updatedAt === "number" ? String(row.updatedAt) : "";
66130
- const values = asRecord5(asRecord5(row.projections).values);
66526
+ const values = asRecord6(asRecord6(row.projections).values);
66131
66527
  const title = typeof values.title === "string" ? values.title : "";
66132
66528
  out.push({
66133
66529
  id,
@@ -66145,7 +66541,7 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
66145
66541
  type: row.type,
66146
66542
  seq: row.seq,
66147
66543
  time: 0,
66148
- data: asRecord5(row.payload)
66544
+ data: asRecord6(row.payload)
66149
66545
  }));
66150
66546
  const durable = journalToTranscriptRows(entries, skip);
66151
66547
  return durable.map((row) => {
@@ -66159,8 +66555,8 @@ function bridgeReplayRowsToSeamTranscript(rows, skip = 0) {
66159
66555
  });
66160
66556
  }
66161
66557
  function seamReplayEventKey(event) {
66162
- const details = asRecord5(event.details);
66163
- return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord5(details.part).id ?? "")}`;
66558
+ const details = asRecord6(event.details);
66559
+ return `${event.type}:${String(details.id ?? details.messageID ?? "")}:${String(asRecord6(details.part).id ?? "")}`;
66164
66560
  }
66165
66561
  function bridgeReplayRowsToSeamEvents(rows, sessionId) {
66166
66562
  const events = [];
@@ -66174,7 +66570,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
66174
66570
  };
66175
66571
  const toolCalls = new Map;
66176
66572
  for (const row of rows) {
66177
- const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord5(row.payload) };
66573
+ const entry = { type: row.type, seq: row.seq, time: 0, data: asRecord6(row.payload) };
66178
66574
  for (const event of projectJournalRecord(entry, sessionId))
66179
66575
  push(event);
66180
66576
  const data = entry.data;
@@ -66188,7 +66584,7 @@ function bridgeReplayRowsToSeamEvents(rows, sessionId) {
66188
66584
  });
66189
66585
  }
66190
66586
  } else if (row.type === "tool/result") {
66191
- const message = asRecord5(data.message);
66587
+ const message = asRecord6(data.message);
66192
66588
  const callId = data.callId !== undefined ? String(data.callId) : message.toolCallId !== undefined ? String(message.toolCallId) : "";
66193
66589
  const call = callId ? toolCalls.get(callId) : undefined;
66194
66590
  if (call !== undefined) {
@@ -66242,7 +66638,7 @@ function bridgeSettleChild(existing, outcome, startedAt, now) {
66242
66638
  }
66243
66639
  function bridgeFoldAgentRecord(children, runSeq, liveStarts, type, data, now, live) {
66244
66640
  if (type === "user/message") {
66245
- const source = asRecord5(data.source);
66641
+ const source = asRecord6(data.source);
66246
66642
  if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
66247
66643
  return false;
66248
66644
  const childId = typeof source.senderSessionId === "string" ? source.senderSessionId : "";
@@ -66337,7 +66733,7 @@ function bridgeSweepSettledChildIds(rows, parentId, locallyRunning) {
66337
66733
  return [];
66338
66734
  const settled = [];
66339
66735
  for (const raw of rows) {
66340
- const row = asRecord5(raw);
66736
+ const row = asRecord6(raw);
66341
66737
  if (row.origin !== "subagent")
66342
66738
  continue;
66343
66739
  if (row.parentSessionId !== parentId)
@@ -66387,16 +66783,16 @@ function bridgeChildJournalMeta(rows) {
66387
66783
  let contextModel;
66388
66784
  let descriptorModel;
66389
66785
  for (const row of rows) {
66390
- const data = asRecord5(row.payload);
66786
+ const data = asRecord6(row.payload);
66391
66787
  if (row.type === "assistant/message") {
66392
66788
  rounds += 1;
66393
- const message = asRecord5(data.message);
66789
+ const message = asRecord6(data.message);
66394
66790
  const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
66395
66791
  if (tail !== undefined)
66396
66792
  lastLine = tail;
66397
66793
  } else if (row.type === "tool/result") {
66398
66794
  if (data.isError !== true) {
66399
- const message = asRecord5(data.message);
66795
+ const message = asRecord6(data.message);
66400
66796
  const tail = bridgeLastContentLine(bridgeBlocksText(message.content ?? data.content));
66401
66797
  if (tail !== undefined)
66402
66798
  lastLine = tail;
@@ -66423,7 +66819,7 @@ function bridgeChildStopReason(rows) {
66423
66819
  const row = rows[i];
66424
66820
  if (row.type !== "user/message")
66425
66821
  continue;
66426
- const source = asRecord5(asRecord5(row.payload).source);
66822
+ const source = asRecord6(asRecord6(row.payload).source);
66427
66823
  if (source.kind !== BRIDGE_SUBAGENT_SETTLED)
66428
66824
  continue;
66429
66825
  const reason = source.stopReason;
@@ -66434,7 +66830,7 @@ function bridgeChildStopReason(rows) {
66434
66830
  const row = rows[i];
66435
66831
  if (row.type !== "turn/end")
66436
66832
  continue;
66437
- const reason = asRecord5(asRecord5(row.payload).reason);
66833
+ const reason = asRecord6(asRecord6(row.payload).reason);
66438
66834
  const kind = reason.kind;
66439
66835
  if (typeof kind === "string" && kind !== "")
66440
66836
  return kind;
@@ -66492,7 +66888,7 @@ function lastJournalTurnTerminal(rows, startOutsideWindow = false) {
66492
66888
  return latest;
66493
66889
  }
66494
66890
  function journalTurnId(row) {
66495
- const payload = asRecord5(row.payload);
66891
+ const payload = asRecord6(row.payload);
66496
66892
  if (typeof payload.turn === "number" && Number.isFinite(payload.turn))
66497
66893
  return payload.turn;
66498
66894
  if (typeof payload.turnId === "string" && payload.turnId !== "")
@@ -66500,7 +66896,7 @@ function journalTurnId(row) {
66500
66896
  return;
66501
66897
  }
66502
66898
  function projectBridgeEvent(frame, sessionId) {
66503
- const payload = asRecord5(frame.payload);
66899
+ const payload = asRecord6(frame.payload);
66504
66900
  const turnId = typeof payload.turnId === "string" ? payload.turnId : "";
66505
66901
  if (frame.type === "turn.start") {
66506
66902
  return [{ type: "session.updated", details: { sessionID: sessionId, turnId, turn: "starting" } }];
@@ -66522,7 +66918,7 @@ function projectBridgeEvent(frame, sessionId) {
66522
66918
  return [];
66523
66919
  }
66524
66920
  function parseUsage(value) {
66525
- const u = asRecord5(value);
66921
+ const u = asRecord6(value);
66526
66922
  const num = (...aliases) => {
66527
66923
  let present = false;
66528
66924
  let best = 0;
@@ -66551,7 +66947,7 @@ function parseUsage(value) {
66551
66947
  return out;
66552
66948
  }
66553
66949
  function journalUsage(payload) {
66554
- const usage = asRecord5(asRecord5(payload).usage);
66950
+ const usage = asRecord6(asRecord6(payload).usage);
66555
66951
  const parsed = parseUsage(usage);
66556
66952
  if (Object.keys(parsed).length === 0)
66557
66953
  return;
@@ -66561,7 +66957,7 @@ function journalUsage(payload) {
66561
66957
  return { ...parsed, total };
66562
66958
  }
66563
66959
  function asDeadCause(value) {
66564
- const r = asRecord5(value);
66960
+ const r = asRecord6(value);
66565
66961
  const stage = r.stage;
66566
66962
  const stages = ["spawn", "handshake", "runtime", "closed"];
66567
66963
  return {
@@ -66577,6 +66973,24 @@ function asDeadCause(value) {
66577
66973
  class BridgeSessionSeam {
66578
66974
  #transport;
66579
66975
  #ctx;
66976
+ #dshHome;
66977
+ #profile;
66978
+ #configStore;
66979
+ #settingsStore;
66980
+ #localAgents;
66981
+ settings = {
66982
+ describe: () => Promise.resolve(this.#settingsStore.describe()),
66983
+ mutate: (ns, ops, revision) => Promise.resolve(this.#settingsStore.mutate(ns, ops, revision)),
66984
+ identity: () => ({ profile: this.#profile, dshHome: this.#dshHome })
66985
+ };
66986
+ agents = {
66987
+ list: () => this.#localAgents.list(),
66988
+ dir: () => this.#localAgents.dir(),
66989
+ set: (name, field, value) => this.#localAgents.set(name, field, value),
66990
+ body: (name) => this.#localAgents.body(name),
66991
+ modelEfforts: (providerID, modelID) => this.#localAgents.modelEfforts(providerID, modelID),
66992
+ officialCaps: () => this.#localAgents.officialCaps()
66993
+ };
66580
66994
  #unsubEvent;
66581
66995
  #listeners = [];
66582
66996
  #onDead;
@@ -66609,6 +67023,9 @@ class BridgeSessionSeam {
66609
67023
  #turnGeneration = 0;
66610
67024
  #inFlightGeneration = 0;
66611
67025
  #degradedOnce = new Set;
67026
+ #capPushListeners = new Map;
67027
+ #capPushStatus = new Map;
67028
+ #capPushDrops = new Map;
66612
67029
  #usage = { turns: 0, prompt: 0, completion: 0, cacheRead: 0, cacheWrite: 0 };
66613
67030
  #decodeWindowStart;
66614
67031
  #lastTurnDecode;
@@ -66629,6 +67046,17 @@ class BridgeSessionSeam {
66629
67046
  constructor(options) {
66630
67047
  this.#transport = options.transport;
66631
67048
  this.#ctx = options.ctx;
67049
+ this.#dshHome = options.dshHome ?? resolveDshHome();
67050
+ this.#profile = options.profile ?? DEFAULT_PROFILE;
67051
+ const workspaceDir = options.workspaceDir ?? process.cwd();
67052
+ this.#settingsStore = new LocalSettingsStore(this.#dshHome, this.#profile);
67053
+ this.#configStore = new LocalConfigStore(this.#dshHome, this.#profile, workspaceDir);
67054
+ this.#localAgents = new LocalAgentsFace({
67055
+ home: this.#dshHome,
67056
+ workspaceDir,
67057
+ settings: this.#settingsStore,
67058
+ modelCatalog: () => this.#transport.request("modelCatalog")
67059
+ });
66632
67060
  this.#onDead = options.onDead;
66633
67061
  this.#onPermissionUnavailable = options.onPermissionUnavailable;
66634
67062
  this.#confirmClock = options.confirmClock ?? {
@@ -66642,7 +67070,7 @@ class BridgeSessionSeam {
66642
67070
  }
66643
67071
  async connect() {
66644
67072
  try {
66645
- const reply = asRecord5(await this.#transport.request("bridge.ping"));
67073
+ const reply = asRecord6(await this.#transport.request("bridge.ping"));
66646
67074
  this.#recordBridgeCapabilities(reply.capabilities);
66647
67075
  this.#connection = "connected";
66648
67076
  } catch (err) {
@@ -66729,7 +67157,7 @@ class BridgeSessionSeam {
66729
67157
  this.#replayDrainPending = true;
66730
67158
  let opened;
66731
67159
  try {
66732
- opened = asRecord5(await this.#transport.request("session.open", { mode: "resume", id: sessionId }));
67160
+ opened = asRecord6(await this.#transport.request("session.open", { mode: "resume", id: sessionId }));
66733
67161
  } catch (err) {
66734
67162
  const code = err instanceof BridgeProtocolError ? err.code : "SESSION_OPEN_FAILED";
66735
67163
  const message = err instanceof Error ? err.message : String(err);
@@ -66739,7 +67167,7 @@ class BridgeSessionSeam {
66739
67167
  this.#bufferedPendingSnapshot = undefined;
66740
67168
  this.#replayDrainPending = false;
66741
67169
  this.#settleSuspendedTurn();
66742
- const errorDetail = err instanceof BridgeProtocolError ? asRecord5(err.detail) : {};
67170
+ const errorDetail = err instanceof BridgeProtocolError ? asRecord6(err.detail) : {};
66743
67171
  const holder = typeof errorDetail.holder === "string" && errorDetail.holder.trim() !== "" ? errorDetail.holder : undefined;
66744
67172
  const result = {
66745
67173
  state: "locked",
@@ -66814,7 +67242,7 @@ class BridgeSessionSeam {
66814
67242
  turnId: dead.turnId,
66815
67243
  seq: terminal.seq,
66816
67244
  terminalType: terminal.type,
66817
- reason: asRecord5(terminal.payload).reason,
67245
+ reason: asRecord6(terminal.payload).reason,
66818
67246
  payload: terminal.payload,
66819
67247
  source: "journal"
66820
67248
  }
@@ -66848,6 +67276,11 @@ class BridgeSessionSeam {
66848
67276
  this.#connection = "connected";
66849
67277
  this.#bridgeLink = "ready";
66850
67278
  this.#recoveryState = "attached";
67279
+ for (const [key, status] of this.#capPushStatus) {
67280
+ if (status.sessionId !== boundId)
67281
+ continue;
67282
+ this.#capPushStatus.set(key, { ...status, state: "attached", lastSeq: 0 });
67283
+ }
66851
67284
  const result = {
66852
67285
  state: "attached",
66853
67286
  sessionId: boundId,
@@ -66867,7 +67300,7 @@ class BridgeSessionSeam {
66867
67300
  const seen = new Set;
66868
67301
  const collected = [];
66869
67302
  for (;; ) {
66870
- const value = asRecord5(await this.#transport.request("journal.replay", { sessionId, from }));
67303
+ const value = asRecord6(await this.#transport.request("journal.replay", { sessionId, from }));
66871
67304
  const rawRows = Array.isArray(value.rows) ? value.rows : [];
66872
67305
  if (typeof value.cursor === "number" && Number.isFinite(value.cursor))
66873
67306
  cursor = value.cursor;
@@ -66880,7 +67313,7 @@ class BridgeSessionSeam {
66880
67313
  let added = 0;
66881
67314
  let pageMax = from - 1;
66882
67315
  for (const raw of rawRows) {
66883
- const row = asRecord5(raw);
67316
+ const row = asRecord6(raw);
66884
67317
  const seq = row.seq;
66885
67318
  if (typeof seq !== "number" || !Number.isFinite(seq) || seq < floor || seen.has(seq))
66886
67319
  continue;
@@ -66929,7 +67362,7 @@ class BridgeSessionSeam {
66929
67362
  };
66930
67363
  const attempt = (remaining) => {
66931
67364
  this.#transport.request("turn.abort", { turnId }).then((result) => {
66932
- if (asRecord5(result).noop === true) {
67365
+ if (asRecord6(result).noop === true) {
66933
67366
  fail(`turn.abort was a noop for turn ${turnId}; turn may still be running`, "TURN_ABORT_NOOP");
66934
67367
  }
66935
67368
  }).catch((err) => {
@@ -67065,7 +67498,7 @@ class BridgeSessionSeam {
67065
67498
  stats.contextTokens = usage.total;
67066
67499
  }
67067
67500
  } else if (row.type === "request/context") {
67068
- const data = asRecord5(row.payload);
67501
+ const data = asRecord6(row.payload);
67069
67502
  const window = data.contextWindow;
67070
67503
  if (typeof window === "number" && Number.isFinite(window) && window > 0) {
67071
67504
  const provider = typeof data.provider === "string" ? data.provider : "";
@@ -67116,6 +67549,49 @@ class BridgeSessionSeam {
67116
67549
  contextWindow: this.#liveContextWindow()
67117
67550
  };
67118
67551
  }
67552
+ onCapPush(sessionId, listener) {
67553
+ let set = this.#capPushListeners.get(sessionId);
67554
+ if (set === undefined) {
67555
+ set = new Set;
67556
+ this.#capPushListeners.set(sessionId, set);
67557
+ }
67558
+ set.add(listener);
67559
+ return () => {
67560
+ const current = this.#capPushListeners.get(sessionId);
67561
+ if (current === undefined)
67562
+ return;
67563
+ current.delete(listener);
67564
+ if (current.size === 0)
67565
+ this.#capPushListeners.delete(sessionId);
67566
+ };
67567
+ }
67568
+ capPushStatus(sessionId) {
67569
+ let seen = false;
67570
+ let state = "attached";
67571
+ let lastSeq = 0;
67572
+ for (const status of this.#capPushStatus.values()) {
67573
+ if (status.sessionId !== sessionId)
67574
+ continue;
67575
+ seen = true;
67576
+ lastSeq = Math.max(lastSeq, status.lastSeq);
67577
+ if (status.state === "disconnected")
67578
+ state = "disconnected";
67579
+ else if (status.state === "degraded" && state === "attached")
67580
+ state = "degraded";
67581
+ }
67582
+ return seen ? { sessionId, state, lastSeq } : undefined;
67583
+ }
67584
+ capPushDropCount(sessionId, methodId) {
67585
+ if (methodId !== undefined) {
67586
+ return this.#capPushDrops.get(`${sessionId}|${methodId}`)?.count ?? 0;
67587
+ }
67588
+ let total = 0;
67589
+ for (const drop of this.#capPushDrops.values()) {
67590
+ if (drop.sessionId === sessionId)
67591
+ total += drop.count;
67592
+ }
67593
+ return total;
67594
+ }
67119
67595
  onSessionEvent(listener) {
67120
67596
  this.#degradeOnce("onSessionEvent", "only turn.* lifecycle/error events project; permission.asked / bridge.shutdown absent");
67121
67597
  this.#listeners.push(listener);
@@ -67138,7 +67614,7 @@ class BridgeSessionSeam {
67138
67614
  this.#interruptInFlight.set(childId, generation);
67139
67615
  let value;
67140
67616
  try {
67141
- value = asRecord5(await this.#transport.request("subagents.interrupt", { parentSessionId, childId }));
67617
+ value = asRecord6(await this.#transport.request("subagents.interrupt", { parentSessionId, childId }));
67142
67618
  } catch (err) {
67143
67619
  if (this.#interruptInFlight.get(childId) === generation)
67144
67620
  this.#interruptInFlight.delete(childId);
@@ -67164,13 +67640,13 @@ class BridgeSessionSeam {
67164
67640
  if (parentSessionId === undefined || parentSessionId === "") {
67165
67641
  throw new BridgeProtocolError("NO_SESSION", "cannot stop children: no session is bound to this bridge connection");
67166
67642
  }
67167
- const value = asRecord5(await this.#transport.request("subagents.stopChildren", { parentSessionId }));
67643
+ const value = asRecord6(await this.#transport.request("subagents.stopChildren", { parentSessionId }));
67168
67644
  const children = value.children;
67169
67645
  if (!Array.isArray(children))
67170
67646
  return [];
67171
67647
  const sessionAtStart = this.#subagentSessionId;
67172
67648
  const rows = children.map((row) => {
67173
- const r = asRecord5(row);
67649
+ const r = asRecord6(row);
67174
67650
  return {
67175
67651
  childId: typeof r.childId === "string" ? r.childId : "",
67176
67652
  disposition: typeof r.disposition === "string" ? r.disposition : "failed"
@@ -67196,10 +67672,10 @@ class BridgeSessionSeam {
67196
67672
  return;
67197
67673
  let stopped = false;
67198
67674
  try {
67199
- const items = asRecord5(await this.#transport.request("session.list", { _request: {} })).items;
67675
+ const items = asRecord6(await this.#transport.request("session.list", { _request: {} })).items;
67200
67676
  if (Array.isArray(items)) {
67201
67677
  stopped = items.some((row) => {
67202
- const item = asRecord5(row);
67678
+ const item = asRecord6(row);
67203
67679
  return item.sessionId === childId && item.running === false;
67204
67680
  });
67205
67681
  }
@@ -67209,7 +67685,7 @@ class BridgeSessionSeam {
67209
67685
  if (stopped) {
67210
67686
  let reason = "aborted";
67211
67687
  try {
67212
- const rows = asRecord5(await this.#transport.request("journal.replay", { sessionId: childId })).rows;
67688
+ const rows = asRecord6(await this.#transport.request("journal.replay", { sessionId: childId })).rows;
67213
67689
  if (Array.isArray(rows)) {
67214
67690
  const clean = rows.filter((row) => row !== null && typeof row === "object" && !Array.isArray(row));
67215
67691
  reason = bridgeChildStopReason(clean) ?? "aborted";
@@ -67268,7 +67744,7 @@ class BridgeSessionSeam {
67268
67744
  } catch {
67269
67745
  return;
67270
67746
  }
67271
- const items = asRecord5(value).items;
67747
+ const items = asRecord6(value).items;
67272
67748
  if (!Array.isArray(items))
67273
67749
  return;
67274
67750
  const locallyRunning = new Set;
@@ -67313,7 +67789,7 @@ class BridgeSessionSeam {
67313
67789
  this.#subagentJournalLoaded.add(key);
67314
67790
  const sessionAtStart = this.#subagentSessionId;
67315
67791
  try {
67316
- const value = asRecord5(await this.#transport.request("journal.replay", { sessionId: childId }));
67792
+ const value = asRecord6(await this.#transport.request("journal.replay", { sessionId: childId }));
67317
67793
  const rows = value.rows;
67318
67794
  if (!Array.isArray(rows))
67319
67795
  return;
@@ -67419,7 +67895,7 @@ class BridgeSessionSeam {
67419
67895
  }
67420
67896
  }
67421
67897
  #foldAgentFrame(frame) {
67422
- const payload = asRecord5(frame.payload);
67898
+ const payload = asRecord6(frame.payload);
67423
67899
  const frameSession = typeof payload.sessionId === "string" ? payload.sessionId : "";
67424
67900
  if (this.#subagentSessionId !== undefined && frameSession !== "" && frameSession !== this.#subagentSessionId)
67425
67901
  return;
@@ -67455,7 +67931,7 @@ class BridgeSessionSeam {
67455
67931
  let changed = false;
67456
67932
  const now = Date.now();
67457
67933
  for (const row of rows) {
67458
- if (this.#foldWithFrozenSettle(row.type, asRecord5(row.payload), now, false))
67934
+ if (this.#foldWithFrozenSettle(row.type, asRecord6(row.payload), now, false))
67459
67935
  changed = true;
67460
67936
  }
67461
67937
  if (rosterReset || changed) {
@@ -67464,16 +67940,16 @@ class BridgeSessionSeam {
67464
67940
  }
67465
67941
  }
67466
67942
  configLoad() {
67467
- this.#degradeOnce("configLoad", "no config frame on the in-process bridge; returning {} (no stored override)");
67468
- return {};
67943
+ return this.#configStore.configLoad();
67469
67944
  }
67470
67945
  configRaw() {
67471
- this.#degradeOnce("configRaw", "no config frame on the in-process bridge; returning {} (no profile layer)");
67472
- return {};
67946
+ return this.#configStore.configRaw();
67473
67947
  }
67474
67948
  workspaceConfig() {
67475
- this.#degradeOnce("workspaceConfig", "no config frame on the in-process bridge; returning {} (no workspace overlay)");
67476
- return {};
67949
+ return this.#configStore.workspaceConfig();
67950
+ }
67951
+ configSave(patch) {
67952
+ return this.#configStore.configSave(patch);
67477
67953
  }
67478
67954
  async permissionCatalog() {
67479
67955
  const answererReady = this.#askProvider !== undefined || this.#inFlightGeneration !== 0 && this.#activeCallbacks !== undefined || this.#askFrameSeen;
@@ -67489,11 +67965,11 @@ class BridgeSessionSeam {
67489
67965
  }
67490
67966
  async listSessions(limit) {
67491
67967
  const value = await this.#transport.request("session.list");
67492
- return projectBridgeSessionList(asRecord5(value).items, limit);
67968
+ return projectBridgeSessionList(asRecord6(value).items, limit);
67493
67969
  }
67494
67970
  async storedTranscript(id, skip = 0) {
67495
67971
  const value = await this.#transport.request("journal.replay", { sessionId: id });
67496
- const rows = Array.isArray(asRecord5(value).rows) ? asRecord5(value).rows : [];
67972
+ const rows = Array.isArray(asRecord6(value).rows) ? asRecord6(value).rows : [];
67497
67973
  this.#foldAgentReplayRows(rows, id);
67498
67974
  this.#sweepSubagents(id);
67499
67975
  return bridgeReplayRowsToSeamTranscript(rows, skip);
@@ -67502,7 +67978,7 @@ class BridgeSessionSeam {
67502
67978
  const selection = await this.#transport.request("model.currentSelection");
67503
67979
  if (selection === undefined || selection === null)
67504
67980
  return;
67505
- const s = asRecord5(selection);
67981
+ const s = asRecord6(selection);
67506
67982
  const providerID = typeof s.provider === "string" ? s.provider : "";
67507
67983
  const modelID = typeof s.model === "string" ? s.model : "";
67508
67984
  if (!providerID || !modelID)
@@ -67539,7 +68015,7 @@ class BridgeSessionSeam {
67539
68015
  this.#pendingOpen = undefined;
67540
68016
  const params = pending.mode === "resume" ? { mode: "resume", id: pending.id, ...this.#sessionAttached ? { replace: true } : {} } : { mode: "new", ...this.#sessionAttached ? { replace: true } : {} };
67541
68017
  try {
67542
- const opened = asRecord5(await this.#transport.request("session.open", params));
68018
+ const opened = asRecord6(await this.#transport.request("session.open", params));
67543
68019
  if (typeof opened.sessionId === "string")
67544
68020
  this.#currentSessionId = opened.sessionId;
67545
68021
  if (this.#lastAppliedSessionId !== this.#currentSessionId) {
@@ -67556,7 +68032,7 @@ class BridgeSessionSeam {
67556
68032
  const done = new Promise((resolve) => {
67557
68033
  this.#turnDone = resolve;
67558
68034
  });
67559
- const sent = asRecord5(await this.#transport.request("session.send", { text: userText }));
68035
+ const sent = asRecord6(await this.#transport.request("session.send", { text: userText }));
67560
68036
  if (typeof sent.turnId === "string") {
67561
68037
  this.#inFlightTurnId = sent.turnId;
67562
68038
  this.#emitEvent({
@@ -67642,10 +68118,35 @@ class BridgeSessionSeam {
67642
68118
  return unsupported("listProviders");
67643
68119
  }
67644
68120
  async modelCatalog(_force) {
67645
- return unsupported("modelCatalog");
68121
+ const raw = await this.#transport.request("modelCatalog");
68122
+ if (raw === undefined || raw === null || !Array.isArray(raw.groups)) {
68123
+ return unsupported("modelCatalog");
68124
+ }
68125
+ const rows = [];
68126
+ for (const group of raw.groups) {
68127
+ const providerID = typeof group?.id === "string" ? group.id : "";
68128
+ if (!providerID)
68129
+ continue;
68130
+ for (const model of Array.isArray(group.models) ? group.models : []) {
68131
+ const modelID = typeof model?.id === "string" ? model.id : "";
68132
+ if (modelID)
68133
+ rows.push({ providerID, modelID });
68134
+ }
68135
+ }
68136
+ return rows;
67646
68137
  }
67647
- selectModel(_providerID, _modelID) {
67648
- return Promise.reject(new BridgeProtocolError("UNSUPPORTED", "selectModel is not backed by the in-process bridge", { capability: "selectModel" }));
68138
+ selectModel(providerID, modelID) {
68139
+ const sessionId = this.#currentSessionId ?? this.stagedSessionId();
68140
+ return this.#transport.request("selectModel", {
68141
+ provider: providerID,
68142
+ model: modelID,
68143
+ ...sessionId !== undefined && sessionId !== "" ? { sessionId } : {}
68144
+ }).then((reply) => {
68145
+ const r = reply;
68146
+ if (r === undefined || r === null || r.selected === undefined) {
68147
+ return unsupported("selectModel");
68148
+ }
68149
+ });
67649
68150
  }
67650
68151
  #approvalParams(request, verdict) {
67651
68152
  const base = { eventId: request.eventId, kind: "approval" };
@@ -67772,7 +68273,7 @@ class BridgeSessionSeam {
67772
68273
  this.#settlePendingAsk(eventId);
67773
68274
  }
67774
68275
  #onAskEvent(frame) {
67775
- const payload = asRecord5(frame.payload);
68276
+ const payload = asRecord6(frame.payload);
67776
68277
  if (frame.type === "ask.request" || frame.type === "ask.pending")
67777
68278
  this.#askFrameSeen = true;
67778
68279
  switch (frame.type) {
@@ -67829,9 +68330,60 @@ class BridgeSessionSeam {
67829
68330
  this.#degradedOnce.add(member);
67830
68331
  this.#degrade(member, reason);
67831
68332
  }
68333
+ #onCapPushEvent(frame) {
68334
+ if (frame.type !== "cap.event" && frame.type !== "cap.end")
68335
+ return false;
68336
+ const payload = asRecord6(frame.payload);
68337
+ const sessionId = optionalStringField(payload, "sessionId");
68338
+ if (sessionId === undefined || sessionId === "")
68339
+ return true;
68340
+ const methodId = optionalStringField(payload, "methodId") ?? "unknown";
68341
+ const key = `${sessionId}|${methodId}`;
68342
+ if (frame.type === "cap.end") {
68343
+ const current = this.#capPushStatus.get(key);
68344
+ this.#capPushStatus.set(key, {
68345
+ sessionId,
68346
+ methodId,
68347
+ state: "degraded",
68348
+ lastSeq: current?.lastSeq ?? 0
68349
+ });
68350
+ const code = optionalStringField(payload, "code");
68351
+ this.#degradeOnce("cap.end", `push stream ${methodId} ended for ${sessionId}${code === undefined ? "" : ` (code=${code})`}`);
68352
+ return true;
68353
+ }
68354
+ const seq = typeof payload.seq === "number" && Number.isInteger(payload.seq) ? payload.seq : 0;
68355
+ const current = this.#capPushStatus.get(key) ?? {
68356
+ sessionId,
68357
+ methodId,
68358
+ state: "attached",
68359
+ lastSeq: 0
68360
+ };
68361
+ if (seq <= current.lastSeq) {
68362
+ const drop = this.#capPushDrops.get(key) ?? { sessionId, methodId, count: 0 };
68363
+ drop.count += 1;
68364
+ this.#capPushDrops.set(key, drop);
68365
+ return true;
68366
+ }
68367
+ const status = { ...current, lastSeq: seq };
68368
+ this.#capPushStatus.set(key, status);
68369
+ const event = {
68370
+ methodId,
68371
+ sessionId,
68372
+ seq,
68373
+ eventType: optionalStringField(payload, "eventType") ?? "event"
68374
+ };
68375
+ for (const listener of [...this.#capPushListeners.get(sessionId) ?? []]) {
68376
+ try {
68377
+ listener(event);
68378
+ } catch {}
68379
+ }
68380
+ return true;
68381
+ }
67832
68382
  #onBridgeEvent(frame) {
67833
68383
  if (this.#onAskEvent(frame))
67834
68384
  return;
68385
+ if (this.#onCapPushEvent(frame))
68386
+ return;
67835
68387
  if (frame.type === "agent.spawn" || frame.type === "agent.settle") {
67836
68388
  this.#foldAgentFrame(frame);
67837
68389
  return;
@@ -67844,6 +68396,9 @@ class BridgeSessionSeam {
67844
68396
  this.#bridgeLink = "dead";
67845
68397
  this.#connection = "disconnected";
67846
68398
  this.#turn = "idle";
68399
+ for (const [key, status] of this.#capPushStatus) {
68400
+ this.#capPushStatus.set(key, { ...status, state: "disconnected" });
68401
+ }
67847
68402
  this.#onDead?.(cause);
67848
68403
  for (const listener of [...this.#listeners]) {
67849
68404
  try {
@@ -67852,7 +68407,7 @@ class BridgeSessionSeam {
67852
68407
  }
67853
68408
  return;
67854
68409
  }
67855
- const payload = asRecord5(frame.payload);
68410
+ const payload = asRecord6(frame.payload);
67856
68411
  if (frame.type === "turn.start") {
67857
68412
  this.#turn = "starting";
67858
68413
  this.#decodeWindowStart = undefined;
@@ -67936,8 +68491,11 @@ class BridgeSessionSeam {
67936
68491
  var BridgeProtocolError, BRIDGE_AGENT_START = "tool-workflow/agent-start", BRIDGE_AGENT_END = "tool-workflow/agent-end", BRIDGE_SUBAGENT_CATALOG = "subagent/catalog", BRIDGE_SUBAGENT_SETTLED = "subagent-settled", BRIDGE_CATALOG_RUN_PREFIX = "catalog:", CONFIRM_POLL_INITIAL_MS = 250, CONFIRM_POLL_MAX_MS = 1000, CONFIRM_TIMEOUT_MS = 45000, fmtTokens = (n) => n >= 1000 ? `${(n / 1000).toFixed(1)}k` : `${n}`;
67937
68492
  var init_bridge_session_seam = __esm(() => {
67938
68493
  init_remote_session_ops();
67939
- init_session_seam_adapter();
68494
+ init_journal_projection();
67940
68495
  init_loop();
68496
+ init_local_config_faces();
68497
+ init_remote_local_fs();
68498
+ init_lifecycle();
67941
68499
  BridgeProtocolError = class BridgeProtocolError extends Error {
67942
68500
  code;
67943
68501
  detail;
@@ -67956,10 +68514,9 @@ function formatBridgeFailFastMessage(diagnosis, repairCommand = BRIDGE_REPAIR_CO
67956
68514
  return [diagnosis, `Fix: ${repairCommand}`, BRIDGE_APPEND_PRESET_NOTICE].join(`
67957
68515
  `);
67958
68516
  }
67959
- 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_LEGACY_REMOTE_HINT = "To keep the legacy remote thin client for this launch: DSH_OPENTUI_INPROC=0", BRIDGE_REPAIR_HINT;
68517
+ 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;
67960
68518
  var init_bridge_failfast_text = __esm(() => {
67961
- BRIDGE_REPAIR_HINT = `Run \`${BRIDGE_REPAIR_COMMAND}\` to rebuild the bridge symlink / manifest (it fixes links, not corrupted artifact contents).
67962
- ${BRIDGE_LEGACY_REMOTE_HINT}`;
68519
+ BRIDGE_REPAIR_HINT = `Run \`${BRIDGE_REPAIR_COMMAND}\` to rebuild the bridge manifest (it fixes links, not corrupted artifact contents).`;
67963
68520
  });
67964
68521
 
67965
68522
  // scripts/lib/host-compat.mjs
@@ -68033,22 +68590,13 @@ __export(exports_seam_bootstrap, {
68033
68590
  BRIDGE_REPAIR_HINT: () => BRIDGE_REPAIR_HINT,
68034
68591
  BridgeBootstrapError: () => BridgeBootstrapError,
68035
68592
  createBridgeSessionSeam: () => createBridgeSessionSeam,
68036
- createSessionSeam: () => createSessionSeam,
68037
68593
  formatBridgeBootstrapMessage: () => formatBridgeBootstrapMessage,
68038
68594
  formatDeadNotice: () => formatDeadNotice,
68039
- isInprocMode: () => isInprocMode,
68040
68595
  recoverBridgeSession: () => recoverBridgeSession,
68041
- selectSeamKind: () => selectSeamKind,
68042
68596
  toBridgeBootstrapError: () => toBridgeBootstrapError,
68043
68597
  verifyBridgeFingerprint: () => verifyBridgeFingerprint,
68044
68598
  verifyRecoveryHandshake: () => verifyRecoveryHandshake
68045
68599
  });
68046
- function selectSeamKind(input) {
68047
- return input.inproc ? "bridge" : "remote";
68048
- }
68049
- function isInprocMode(env = process.env) {
68050
- return env.DSH_OPENTUI_INPROC !== "0";
68051
- }
68052
68600
  function formatBridgeBootstrapMessage(options) {
68053
68601
  return formatBridgeFailFastMessage(`dsh-opentui inproc bridge seam failed [${options.code}]: ${options.diagnosis}`, options.repairCommand ?? BRIDGE_REPAIR_COMMAND);
68054
68602
  }
@@ -68065,11 +68613,11 @@ function toBridgeBootstrapError(err, fallbackCode = "BRIDGE_HANDSHAKE_FAILED") {
68065
68613
  const message = err instanceof Error ? err.message : String(err);
68066
68614
  return new BridgeBootstrapError({ code: fallbackCode, diagnosis: `bridge handshake failed: ${message}` });
68067
68615
  }
68068
- function asRecord6(value) {
68616
+ function asRecord7(value) {
68069
68617
  return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
68070
68618
  }
68071
68619
  function verifyBridgeFingerprint(hello, expectedProtocolVersion = BRIDGE_PROTOCOL_VERSION) {
68072
- const h = asRecord6(hello);
68620
+ const h = asRecord7(hello);
68073
68621
  const protocolVersion = h.protocolVersion;
68074
68622
  if (protocolVersion !== expectedProtocolVersion) {
68075
68623
  throw new BridgeBootstrapError({
@@ -68147,11 +68695,6 @@ async function createBridgeSessionSeam(options) {
68147
68695
  await seam.connect();
68148
68696
  return seam;
68149
68697
  }
68150
- async function createSessionSeam(options) {
68151
- if (options.kind === "remote")
68152
- return options.createRemote();
68153
- return options.createBridge();
68154
- }
68155
68698
  async function recoverBridgeSession(options) {
68156
68699
  await options.transport.recover();
68157
68700
  return options.seam.recoverSession();
@@ -68177,31 +68720,30 @@ var init_seam_bootstrap = __esm(() => {
68177
68720
  });
68178
68721
 
68179
68722
  // ../tui-base/examples/v2-entry.tsx
68180
- import { join as join15 } from "path";
68181
- import { existsSync as existsSync12 } from "fs";
68723
+ import { join as join16 } from "path";
68724
+ import { existsSync as existsSync13 } from "fs";
68182
68725
  function resolveWatchdogScript() {
68183
68726
  const candidates = [
68184
- join15(import.meta.dir, "..", "watchdog.mjs"),
68185
- join15(import.meta.dir, "..", "..", "shell", "dist", "watchdog.mjs"),
68186
- join15(import.meta.dir, "..", "..", "..", "shell", "dist", "watchdog.mjs")
68727
+ join16(import.meta.dir, "..", "watchdog.mjs"),
68728
+ join16(import.meta.dir, "..", "..", "shell", "dist", "watchdog.mjs"),
68729
+ join16(import.meta.dir, "..", "..", "..", "shell", "dist", "watchdog.mjs")
68187
68730
  ];
68188
68731
  for (const candidate of candidates)
68189
- if (existsSync12(candidate))
68732
+ if (existsSync13(candidate))
68190
68733
  return candidate;
68191
68734
  return null;
68192
68735
  }
68193
68736
  async function loadShell() {
68194
- const [shared, lifecycle, clifecycle, transport, rhs, adapter, git, seamBootstrap] = await Promise.all([
68737
+ const [shared, lifecycle, clifecycle, transport, rhs, git, seamBootstrap] = await Promise.all([
68195
68738
  Promise.resolve().then(() => (init_boot_shared(), exports_boot_shared)),
68196
68739
  Promise.resolve().then(() => (init_lifecycle(), exports_lifecycle)),
68197
68740
  Promise.resolve().then(() => (init_client_lifecycle(), exports_client_lifecycle)),
68198
68741
  Promise.resolve().then(() => (init_transport(), exports_transport)),
68199
68742
  Promise.resolve().then(() => (init_remote_host_session(), exports_remote_host_session)),
68200
- Promise.resolve().then(() => (init_session_seam_adapter(), exports_session_seam_adapter)),
68201
68743
  Promise.resolve().then(() => (init_remote_git(), exports_remote_git)),
68202
68744
  Promise.resolve().then(() => (init_seam_bootstrap(), exports_seam_bootstrap))
68203
68745
  ]);
68204
- return { shared, lifecycle, clifecycle, transport, rhs, adapter, git, seamBootstrap };
68746
+ return { shared, lifecycle, clifecycle, transport, rhs, git, seamBootstrap };
68205
68747
  }
68206
68748
  function V2SessionPage(props) {
68207
68749
  return createComponent2(DockProvider, {
@@ -68233,7 +68775,7 @@ function V2SessionPageBody(props) {
68233
68775
  }
68234
68776
  });
68235
68777
  const dialog = useDialog();
68236
- const pageOwns = useIsPageOwner();
68778
+ const pageOwns = useIsPageOwner2();
68237
68779
  const dock = useDock();
68238
68780
  const theme = useTheme();
68239
68781
  const themeService = useThemes();
@@ -68906,7 +69448,7 @@ function appendDiagnostic(line) {
68906
69448
  } catch {}
68907
69449
  }
68908
69450
  async function bootClientV2(options = {}) {
68909
- const { shared, lifecycle, clifecycle, transport, rhs, adapter, git, seamBootstrap } = await loadShell();
69451
+ const { shared, lifecycle, clifecycle, transport, rhs, git, seamBootstrap } = await loadShell();
68910
69452
  const workspace = process.cwd();
68911
69453
  const profile = lifecycle.DEFAULT_PROFILE;
68912
69454
  const idleExitMs = lifecycle.resolveIdleExitMs();
@@ -68955,31 +69497,22 @@ async function bootClientV2(options = {}) {
68955
69497
  }
68956
69498
  }
68957
69499
  const launchArgs = parseLaunchArgs(options.argv ?? process.argv.slice(2));
68958
- const seamKind = seamBootstrap.selectSeamKind({
68959
- inproc: seamBootstrap.isInprocMode()
68960
- });
68961
- const seam = await seamBootstrap.createSessionSeam({
68962
- kind: seamKind,
68963
- createBridge: async () => {
68964
- if (options.bridgeTransport === undefined) {
68965
- throw new seamBootstrap.BridgeBootstrapError({
68966
- code: "BRIDGE_TRANSPORT_MISSING",
68967
- diagnosis: "bridge seam is selected (DSH_OPENTUI_INPROC is not 0) but no bridge transport was injected at the synthetic root"
68968
- });
68969
- }
68970
- return seamBootstrap.createBridgeSessionSeam({
68971
- transport: options.bridgeTransport,
68972
- ctx: options.bridgeCtx ?? { logger: console },
68973
- onDead: (cause) => void showNotice(`${seamBootstrap.formatDeadNotice(cause)} \xB7 ${t("recovery.action.reconnect")}`, undefined, "error"),
68974
- onPermissionUnavailable: (reason) => void showNotice(`${t("notice.permission.unavailable")} \xB7 ${t(`notice.permission.reason.${reason}`)}`, undefined, "error")
68975
- });
68976
- },
68977
- createRemote: () => new adapter.RemoteSessionSeam(session)
69500
+ if (options.bridgeTransport === undefined) {
69501
+ throw new seamBootstrap.BridgeBootstrapError({
69502
+ code: "BRIDGE_TRANSPORT_MISSING",
69503
+ diagnosis: "no bridge transport was injected at the synthetic root"
69504
+ });
69505
+ }
69506
+ const seam = await seamBootstrap.createBridgeSessionSeam({
69507
+ transport: options.bridgeTransport,
69508
+ ctx: options.bridgeCtx ?? { logger: console },
69509
+ onDead: (cause) => void showNotice(`${seamBootstrap.formatDeadNotice(cause)} \xB7 ${t("recovery.action.reconnect")}`, undefined, "error"),
69510
+ onPermissionUnavailable: (reason) => void showNotice(`${t("notice.permission.unavailable")} \xB7 ${t(`notice.permission.reason.${reason}`)}`, undefined, "error")
68978
69511
  });
68979
- const recoverBridge = seamKind === "bridge" && options.bridgeTransport !== undefined ? () => seamBootstrap.recoverBridgeSession({
69512
+ const recoverBridge = () => seamBootstrap.recoverBridgeSession({
68980
69513
  transport: options.bridgeTransport,
68981
69514
  seam
68982
- }) : undefined;
69515
+ });
68983
69516
  registerTurnOverlays(seam, overlays, {
68984
69517
  deadReason: (details) => {
68985
69518
  const cause = details;
@@ -69010,8 +69543,8 @@ async function bootClientV2(options = {}) {
69010
69543
  agentsHome: agentsHomeForSkills
69011
69544
  });
69012
69545
  const skillsManagerRoots = {
69013
- source: join15(agentsHomeForSkills, "skills"),
69014
- curated: join15(host.dshHome, "skills")
69546
+ source: join16(agentsHomeForSkills, "skills"),
69547
+ curated: join16(host.dshHome, "skills")
69015
69548
  };
69016
69549
  const envTheme = process.env[shared.ENV_THEME];
69017
69550
  const workspaceConfig = seam.workspaceConfig?.() ?? {};
@@ -69038,7 +69571,10 @@ async function bootClientV2(options = {}) {
69038
69571
  const themeModeLock = shared.themeModeFromConfig(session);
69039
69572
  setMotionTier(resolveMotionPreference(process.env[shared.ENV_MOTION], shared.motionFromConfig(session)));
69040
69573
  applyHintsConfig(seam.configLoad?.());
69041
- applyActivityPanelConfig(seam.configLoad?.());
69574
+ const bootLocalUi = readUiStateSync(defaultUiStatePath());
69575
+ const bootGear = resolveBootGear(seam.configLoad?.(), bootLocalUi);
69576
+ if (bootGear !== undefined)
69577
+ applyActivityPanelConfig({ session: { activity_panel_height: bootGear } });
69042
69578
  applyI18nConfig(seam.configLoad?.());
69043
69579
  let shutdownPromise = null;
69044
69580
  const shutdown = () => {
@@ -69047,12 +69583,10 @@ async function bootClientV2(options = {}) {
69047
69583
  try {
69048
69584
  await Promise.race([session.dispose(), new Promise((resolve) => setTimeout(resolve, shared.SHUTDOWN_GRACE_MS))]);
69049
69585
  } catch {}
69050
- if (seamKind === "bridge") {
69051
- try {
69052
- await Promise.race([seam.dispose(), new Promise((resolve) => setTimeout(resolve, shared.SHUTDOWN_GRACE_MS))]);
69053
- } catch {}
69054
- options.bridgeTransport?.close?.();
69055
- }
69586
+ try {
69587
+ await Promise.race([seam.dispose(), new Promise((resolve) => setTimeout(resolve, shared.SHUTDOWN_GRACE_MS))]);
69588
+ } catch {}
69589
+ options.bridgeTransport?.close?.();
69056
69590
  if (clientHeartbeat) {
69057
69591
  clientHeartbeat.stop();
69058
69592
  clientHeartbeat.remove();
@@ -69084,7 +69618,7 @@ async function bootClientV2(options = {}) {
69084
69618
  get children() {
69085
69619
  return createComponent2(ClipboardHost, {
69086
69620
  get children() {
69087
- return createComponent2(InputOwnershipProvider, {
69621
+ return createComponent2(FocusRouterProvider, {
69088
69622
  get children() {
69089
69623
  return createComponent2(DialogProvider, {
69090
69624
  get children() {
@@ -69174,6 +69708,7 @@ var init_v2_entry = __esm(() => {
69174
69708
  init_recovery_banner();
69175
69709
  init_hints_line();
69176
69710
  init_widgets_dock();
69711
+ init_ui_state();
69177
69712
  init_src();
69178
69713
  init_i18n();
69179
69714
  init_search_overlay();
@@ -69207,7 +69742,7 @@ var init_v2_entry = __esm(() => {
69207
69742
  init_keymap();
69208
69743
  init_theme3();
69209
69744
  init_panel_kit_host();
69210
- init_input_ownership();
69745
+ init_focus_router();
69211
69746
  init_config();
69212
69747
  init_selection();
69213
69748
  init_theme2();
@@ -69222,7 +69757,7 @@ var init_v2_entry = __esm(() => {
69222
69757
  // src/client/bridge-transport.ts
69223
69758
  import { spawn as nodeSpawn2 } from "child_process";
69224
69759
  import { homedir as homedir9 } from "os";
69225
- import { join as join16 } from "path";
69760
+ import { join as join17 } from "path";
69226
69761
  function recoveryCause(err, phase) {
69227
69762
  if (err instanceof BridgeBootstrapError) {
69228
69763
  return {
@@ -69235,7 +69770,7 @@ function recoveryCause(err, phase) {
69235
69770
  };
69236
69771
  }
69237
69772
  if (err instanceof BridgeProtocolError && err.code === "BRIDGE_DEAD") {
69238
- const detail = asRecord7(err.detail);
69773
+ const detail = asRecord8(err.detail);
69239
69774
  return {
69240
69775
  stage: phase,
69241
69776
  code: typeof detail.code === "number" ? detail.code : null,
@@ -69286,7 +69821,7 @@ class StdioBridgeTransport {
69286
69821
  #spawn() {
69287
69822
  if (this.#child !== undefined)
69288
69823
  return this.#child;
69289
- const dshHome = this.#opts.dshHome ?? process.env.DSH_HOME ?? join16(homedir9(), ".dsh");
69824
+ const dshHome = this.#opts.dshHome ?? process.env.DSH_HOME ?? join17(homedir9(), ".dsh");
69290
69825
  const env = {
69291
69826
  ...process.env,
69292
69827
  ...this.#opts.env ?? {},
@@ -69350,7 +69885,7 @@ class StdioBridgeTransport {
69350
69885
  } catch {
69351
69886
  return;
69352
69887
  }
69353
- const rec = asRecord7(frame);
69888
+ const rec = asRecord8(frame);
69354
69889
  if (typeof rec.id === "number") {
69355
69890
  const pending = this.#pending.get(rec.id);
69356
69891
  if (pending === undefined)
@@ -69362,7 +69897,7 @@ class StdioBridgeTransport {
69362
69897
  this.#setState("ready");
69363
69898
  pending.resolve(rec.result);
69364
69899
  } else {
69365
- const error = asRecord7(rec.error);
69900
+ const error = asRecord8(rec.error);
69366
69901
  pending.reject(new BridgeProtocolError(typeof error.code === "string" ? error.code : "BRIDGE_ERROR", typeof error.message === "string" ? error.message : "bridge request failed", error.detail));
69367
69902
  }
69368
69903
  return;
@@ -69494,7 +70029,7 @@ class StdioBridgeTransport {
69494
70029
  } catch {}
69495
70030
  }
69496
70031
  }
69497
- var asRecord7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
70032
+ var asRecord8 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
69498
70033
  var init_bridge_transport = __esm(() => {
69499
70034
  init_bridge_session_seam();
69500
70035
  init_seam_bootstrap();
@@ -69507,16 +70042,16 @@ init_boot_shared();
69507
70042
  init_lifecycle();
69508
70043
  init_transport();
69509
70044
  init_remote_host_session();
69510
- import { existsSync as existsSync13 } from "fs";
69511
- import { join as join17 } from "path";
70045
+ import { existsSync as existsSync14 } from "fs";
70046
+ import { join as join18 } from "path";
69512
70047
  function resolveWatchdogScript2() {
69513
70048
  const candidates = [
69514
- join17(import.meta.dir, "..", "watchdog.mjs"),
69515
- join17(import.meta.dir, "..", "dist", "watchdog.mjs"),
69516
- join17(import.meta.dir, "..", "scripts", "watchdog.mjs")
70049
+ join18(import.meta.dir, "..", "watchdog.mjs"),
70050
+ join18(import.meta.dir, "..", "dist", "watchdog.mjs"),
70051
+ join18(import.meta.dir, "..", "scripts", "watchdog.mjs")
69517
70052
  ];
69518
70053
  for (const candidate of candidates) {
69519
- if (existsSync13(candidate))
70054
+ if (existsSync14(candidate))
69520
70055
  return candidate;
69521
70056
  }
69522
70057
  return null;
@@ -69661,16 +70196,12 @@ async function main() {
69661
70196
  const v2Specifier = "../../" + "tui-base/examples/v2-entry.tsx";
69662
70197
  const mod = await Promise.resolve().then(() => (init_v2_entry(), {}));
69663
70198
  const argv = process.argv.slice(2);
69664
- let bootOptions = { argv };
69665
- if (process.env.DSH_OPENTUI_INPROC !== "0") {
69666
- const bridgeMod = await Promise.resolve().then(() => (init_bridge_transport(), {}));
69667
- bootOptions = {
69668
- ...bootOptions,
69669
- bridgeTransport: new StdioBridgeTransport,
69670
- bridgeCtx: { logger: console }
69671
- };
69672
- }
69673
- await bootClientV2(bootOptions);
70199
+ const bridgeMod = await Promise.resolve().then(() => (init_bridge_transport(), {}));
70200
+ await bootClientV2({
70201
+ argv,
70202
+ bridgeTransport: new StdioBridgeTransport,
70203
+ bridgeCtx: { logger: console }
70204
+ });
69674
70205
  } catch (error) {
69675
70206
  const message = error instanceof Error ? error.stack ?? error.message : String(error);
69676
70207
  process.stderr.write(`dsh-opentui client boot failed: ${message}
@@ -69691,5 +70222,5 @@ export {
69691
70222
  themeNameFromConfig
69692
70223
  };
69693
70224
 
69694
- //# debugId=A551D22BBC95CF9464756E2164756E21
70225
+ //# debugId=02978B65DF730BBE64756E2164756E21
69695
70226
  //# sourceMappingURL=index.js.map