@kabmo-labs/kabmo 0.23.0 → 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.
Files changed (151) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +679 -679
  3. package/dist/client/static/js/{index-ph0q59rs.js → index-jcr5twtp.js} +769 -767
  4. package/dist/client/static/js/index-z3w7n85q.css +1 -0
  5. package/package.json +1 -1
  6. package/src/client/components/common/Modal.tsx +2 -6
  7. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
  8. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +20 -0
  9. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +23 -7
  10. package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
  11. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +27 -11
  12. package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +31 -0
  13. package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +49 -0
  14. package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
  15. package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
  16. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +4 -3
  17. package/src/client/components/workspace/chat-timeline/index.tsx +2 -1
  18. package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +1 -1
  19. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
  20. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
  21. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
  22. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
  23. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
  24. package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
  25. package/src/client/components/workspace/file-explorer/index.tsx +9 -3
  26. package/src/client/components/workspace/model-dropdown/harness-models.test.ts +17 -0
  27. package/src/client/components/workspace/model-dropdown/harness-models.ts +33 -18
  28. package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
  29. package/src/client/components/workspace/model-dropdown/popover-metrics.ts +4 -1
  30. package/src/client/data/settings/omp-schema.json +4 -4
  31. package/src/client/hooks/chat/timeline/actions.ts +2 -2
  32. package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
  33. package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
  34. package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
  35. package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
  36. package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
  37. package/src/client/hooks/chat/timeline/rewind-actions.test.ts +24 -1
  38. package/src/client/hooks/chat/timeline/rewind-actions.ts +15 -11
  39. package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
  40. package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
  41. package/src/client/hooks/chat/timeline/send-execute.test.ts +17 -0
  42. package/src/client/hooks/chat/timeline/send-props.ts +5 -3
  43. package/src/client/hooks/chat/timeline/send-steer.test.ts +1 -3
  44. package/src/client/hooks/chat/timeline/send.test-util.ts +1 -1
  45. package/src/client/hooks/chat/timeline/send.test.ts +1 -3
  46. package/src/client/hooks/chat/timeline/send.ts +8 -3
  47. package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
  48. package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
  49. package/src/client/hooks/chat/timeline/session-load.ts +6 -14
  50. package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
  51. package/src/client/hooks/models/harness-catalog.ts +114 -0
  52. package/src/client/hooks/models/provider-writes.test.ts +81 -0
  53. package/src/client/hooks/models/provider-writes.ts +10 -3
  54. package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
  55. package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
  56. package/src/client/hooks/models/use-harnesses.test.ts +2 -1
  57. package/src/client/hooks/models/use-harnesses.ts +48 -114
  58. package/src/client/tailwind.css +9 -1
  59. package/src/server/lib/harness/acp/activation.test.ts +81 -0
  60. package/src/server/lib/harness/acp/activation.ts +72 -0
  61. package/src/server/lib/harness/acp/frames.test.ts +50 -1
  62. package/src/server/lib/harness/acp/frames.ts +17 -5
  63. package/src/server/lib/harness/acp/mapper.ts +6 -4
  64. package/src/server/lib/harness/acp/session-config.test.ts +73 -0
  65. package/src/server/lib/harness/acp/session-config.ts +87 -6
  66. package/src/server/lib/harness/acp/session-handshake.ts +9 -2
  67. package/src/server/lib/harness/acp/session-idle.ts +51 -0
  68. package/src/server/lib/harness/acp/session-notifications.ts +19 -3
  69. package/src/server/lib/harness/acp/session-observers.test.ts +9 -0
  70. package/src/server/lib/harness/acp/session-options.ts +33 -0
  71. package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
  72. package/src/server/lib/harness/acp/session.test-util.ts +31 -2
  73. package/src/server/lib/harness/acp/session.test.ts +65 -3
  74. package/src/server/lib/harness/acp/session.ts +20 -20
  75. package/src/server/lib/harness/acp/turn.ts +31 -7
  76. package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
  77. package/src/server/lib/harness/auto-probe.server.ts +178 -0
  78. package/src/server/lib/harness/config.server.test.ts +1 -1
  79. package/src/server/lib/harness/config.server.ts +1 -1
  80. package/src/server/lib/harness/launch-table.ts +195 -0
  81. package/src/server/lib/harness/launch.test.ts +37 -0
  82. package/src/server/lib/harness/launch.ts +13 -115
  83. package/src/server/lib/harness/provider-entry.ts +32 -0
  84. package/src/server/lib/harness/provider-file.server.ts +3 -0
  85. package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
  86. package/src/server/lib/harness/provider-sources.server.ts +26 -2
  87. package/src/server/lib/harness/provider-write.server.ts +21 -32
  88. package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
  89. package/src/server/lib/harness/provider-zcode.server.ts +324 -0
  90. package/src/server/lib/harness/update-state.server.ts +15 -20
  91. package/src/server/lib/lifecycle/after-listen.ts +7 -0
  92. package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
  93. package/src/server/lib/models/registry-refresh.server.ts +98 -0
  94. package/src/server/lib/omp/rpc/child-config.ts +5 -4
  95. package/src/server/lib/omp/rpc/constants.test.ts +2 -1
  96. package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
  97. package/src/server/lib/omp/session/delete-flow.server.ts +15 -8
  98. package/src/server/lib/omp/session/delete.server.ts +12 -0
  99. package/src/server/routes/chat/rewind.test.ts +147 -0
  100. package/src/server/routes/chat/rewind.ts +29 -7
  101. package/src/server/routes/chat/session.test.ts +165 -10
  102. package/src/server/routes/chat/session.ts +60 -7
  103. package/src/server/routes/harness/import-action.ts +18 -4
  104. package/src/server/routes/harness/root.ts +8 -49
  105. package/src/server/routes/harness/toggle.test.ts +20 -0
  106. package/src/server/routes/harness/update.ts +49 -7
  107. package/src/server/routes/harness/versions.ts +5 -1
  108. package/src/server/routes/sessions/delete-acp.test.ts +227 -0
  109. package/src/server/routes/settings/model-override.ts +5 -2
  110. package/src/server/routes/settings/provider-entry.ts +2 -2
  111. package/src/server/routes/settings/provider-model.ts +2 -2
  112. package/src/server/routes/settings/provider-models.ts +2 -2
  113. package/src/server/routes/settings/provider-refresh.ts +6 -4
  114. package/src/server/routes/settings/providers.ts +3 -1
  115. package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
  116. package/src/shared/lib/chat/ask-form/fields.ts +76 -0
  117. package/src/shared/lib/chat/ask-form/index.ts +323 -0
  118. package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
  119. package/src/shared/lib/chat/ask-form/types.ts +43 -0
  120. package/src/shared/lib/chat/ask-form.test.ts +137 -0
  121. package/src/shared/lib/chat/ask-questions.test.ts +65 -1
  122. package/src/shared/lib/chat/ask-questions.ts +51 -145
  123. package/src/shared/lib/chat/ask-results.ts +198 -0
  124. package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
  125. package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
  126. package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
  127. package/src/shared/lib/harness/catalog.test.ts +1 -1
  128. package/src/shared/lib/harness/config-fields.test.ts +4 -0
  129. package/src/shared/lib/harness/config-fields.ts +19 -4
  130. package/src/shared/lib/harness/dialects.test.ts +8 -0
  131. package/src/shared/lib/harness/dialects.ts +12 -0
  132. package/src/shared/lib/harness/provider-facts.test.ts +32 -8
  133. package/src/shared/lib/harness/provider-facts.ts +46 -11
  134. package/src/shared/lib/harness/providers.ts +9 -0
  135. package/src/shared/lib/harness/rewind.ts +24 -0
  136. package/src/shared/lib/harness/update-plan.test.ts +51 -1
  137. package/src/shared/lib/harness/update-plan.ts +47 -7
  138. package/src/shared/lib/harness/updates.test.ts +22 -0
  139. package/src/shared/lib/harness/updates.ts +24 -1
  140. package/src/shared/lib/models/client.ts +10 -1
  141. package/src/shared/lib/omp/dialog-methods.ts +4 -3
  142. package/src/shared/lib/theme/css.ts +2 -0
  143. package/src/shared/lib/theme/ink-scale.ts +21 -1
  144. package/src/shared/lib/theme/theme.test.ts +25 -9
  145. package/src/shared/lib/ui/safe-area.test.ts +28 -0
  146. package/src/shared/lib/ui/safe-area.ts +42 -0
  147. package/src/shared/types/harness.ts +30 -4
  148. package/src/test-support/file-explorer-render.test-util.ts +37 -0
  149. package/src/test-support/file-explorer.test-util.ts +20 -18
  150. package/src/test-support/harness-table.test-util.ts +6 -3
  151. package/dist/client/static/js/index-jhmg4w91.css +0 -1
@@ -12,13 +12,63 @@
12
12
  * (or, after a restart, the last run's stream row) is the only truthful source.
13
13
  */
14
14
 
15
- import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
15
+ import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
16
+ import fs from 'node:fs';
17
+ import { tmpdir } from 'node:os';
18
+ import { join } from 'node:path';
16
19
  import { isolateDb, releaseDb } from '@/test-support/isolated-db';
17
20
  import { loader } from '@/server/routes/chat/session';
18
21
  import { registerAcpSession } from '@/server/lib/harness/register.server';
19
22
  import { claimHarness } from '@/server/lib/harness/registry';
23
+ import { clearSessionFileCaches } from '@/server/lib/omp/session/files';
20
24
  import type { HarnessSession } from '@/server/lib/harness/session';
21
25
 
26
+ /** The temp agent dir an on-disk transcript needs, since `findSessionFileById`
27
+ * resolves through the real sessions root. */
28
+ const previousAgentDir = Bun.env.PI_CODING_AGENT_DIR;
29
+ const previousXdg = Bun.env.XDG_DATA_HOME;
30
+ let agentRoot = '';
31
+ let sessionsRoot = '';
32
+
33
+ beforeEach(async () => {
34
+ agentRoot = await fs.promises.mkdtemp(join(tmpdir(), 'kabmo-acp-session-'));
35
+ sessionsRoot = join(agentRoot, 'sessions');
36
+ await fs.promises.mkdir(sessionsRoot, { recursive: true });
37
+ Bun.env.PI_CODING_AGENT_DIR = agentRoot;
38
+ // An existing XDG root redirects the sessions dir away from the temp one.
39
+ delete Bun.env.XDG_DATA_HOME;
40
+ clearSessionFileCaches();
41
+ delete Bun.env.MOCK;
42
+ await isolateDb();
43
+ });
44
+
45
+ afterEach(async () => {
46
+ clearSessionFileCaches();
47
+ await fs.promises.rm(agentRoot, { recursive: true, force: true });
48
+ await releaseDb();
49
+ });
50
+
51
+ afterAll(() => {
52
+ if (previousAgentDir === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
53
+ else Bun.env.PI_CODING_AGENT_DIR = previousAgentDir;
54
+ if (previousXdg === undefined) delete Bun.env.XDG_DATA_HOME;
55
+ else Bun.env.XDG_DATA_HOME = previousXdg;
56
+ });
57
+
58
+ /** Write `<id>.jsonl` under the sessions root, with omp's own header line. */
59
+ async function writeSessionFile(id: string, entries: Array<Record<string, unknown>>): Promise<string> {
60
+ const dir = join(sessionsRoot, 'project');
61
+ await fs.promises.mkdir(dir, { recursive: true });
62
+ const path = join(dir, `${id}.jsonl`);
63
+ const lines = [
64
+ JSON.stringify({ type: 'session', id, cwd: '/work', timestamp: '2026-11-09T00:00:00.000Z' }),
65
+ ...entries.map((entry) => JSON.stringify(entry)),
66
+ ];
67
+ await Bun.write(path, `${lines.join('\n')}\n`);
68
+ clearSessionFileCaches();
69
+ return path;
70
+ }
71
+
22
72
  function registerAgent(id: string, state: Record<string, unknown>): () => void {
23
73
  let release: (() => void) | null = null;
24
74
  const session = {
@@ -57,15 +107,6 @@ function load(sessionId: string): Promise<Response> {
57
107
  } as never) as Promise<Response>;
58
108
  }
59
109
 
60
- beforeEach(async () => {
61
- delete Bun.env.MOCK;
62
- await isolateDb();
63
- });
64
-
65
- afterEach(async () => {
66
- await releaseDb();
67
- });
68
-
69
110
  describe('chat session loader on a live ACP chat', () => {
70
111
  test('reports the session model and thinking level from get_state', async () => {
71
112
  const release = registerAgent('acp-live-chat', {
@@ -82,4 +123,118 @@ describe('chat session loader on a live ACP chat', () => {
82
123
  release();
83
124
  }
84
125
  });
126
+
127
+ test('reports the selectors the LIVE session published, not a probe', async () => {
128
+ // codex refuses a probe spawn while a chat is already running, yet that chat
129
+ // offers its models — so the session's own lists are the only honest ones.
130
+ const release = registerAgent('acp-live-selectors', {
131
+ model: { provider: 'openai', id: 'gpt-5' },
132
+ thinkingLevel: 'medium',
133
+ configOptions: [
134
+ {
135
+ id: 'model',
136
+ name: 'Model',
137
+ category: 'model',
138
+ currentValue: 'gpt-5',
139
+ options: [
140
+ { value: 'gpt-5', name: 'GPT-5' },
141
+ { value: 'gpt-5-mini', name: 'GPT-5 mini' },
142
+ ],
143
+ },
144
+ {
145
+ id: 'thought_level',
146
+ name: 'Thinking',
147
+ category: 'thought_level',
148
+ currentValue: 'medium',
149
+ options: [{ value: 'medium', name: 'Medium' }],
150
+ },
151
+ ],
152
+ });
153
+ try {
154
+ const body = (await (await load('acp-live-selectors')).json()) as {
155
+ session: {
156
+ harness?: string;
157
+ liveModels?: {
158
+ models: { value: string; name: string }[];
159
+ thinking?: { value: string; name: string }[];
160
+ };
161
+ };
162
+ };
163
+ expect(body.session.harness).toBe('claude');
164
+ expect(body.session.liveModels).toEqual({
165
+ models: [
166
+ { value: 'gpt-5', name: 'GPT-5' },
167
+ { value: 'gpt-5-mini', name: 'GPT-5 mini' },
168
+ ],
169
+ thinking: [{ value: 'medium', name: 'Medium' }],
170
+ });
171
+ } finally {
172
+ release();
173
+ }
174
+ });
175
+
176
+ /**
177
+ * An ACP harness can own an on-disk transcript: omp's own ACP server writes
178
+ * the same JSONL omp RPC does. The file branch used to return without the live
179
+ * session's fields, so that tab published NO selectors — the picker for it
180
+ * could only ever list a probe snapshot instead of the list the running agent
181
+ * offers, and the composer named whatever model the file last recorded.
182
+ */
183
+ test('a live ACP chat with an on-disk transcript still publishes its own selectors', async () => {
184
+ const id = 'acp-live-on-disk';
185
+ const release = registerAgent(id, {
186
+ model: { provider: 'claude', id: 'opus' },
187
+ thinkingLevel: 'high',
188
+ configOptions: [
189
+ {
190
+ id: 'model',
191
+ name: 'Model',
192
+ category: 'model',
193
+ currentValue: 'opus',
194
+ options: [{ value: 'opus', name: 'Opus 5.5' }],
195
+ },
196
+ ],
197
+ });
198
+ try {
199
+ await writeSessionFile(id, [
200
+ { id: 'm1', parentId: null, type: 'model_change', model: 'omp/deepseek-v4.1-flash' },
201
+ { id: 'm2', parentId: 'm1', type: 'thinking_level_change', thinkingLevel: 'low' },
202
+ { id: 'm3', parentId: 'm2', type: 'message', message: { role: 'user', content: 'halo' } },
203
+ ]);
204
+
205
+ const body = (await (await load(id)).json()) as {
206
+ session: {
207
+ harness?: string;
208
+ model?: { provider: string; modelId: string };
209
+ thinkingLevel?: string;
210
+ liveModels?: { models: { value: string; name: string }[] };
211
+ };
212
+ source?: string;
213
+ };
214
+
215
+ // The file-backed branch, and the live halves still win over the file's.
216
+ expect(body.source).toBe('omp-jsonl');
217
+ expect(body.session.harness).toBe('claude');
218
+ expect(body.session.model).toEqual({ provider: 'claude', modelId: 'opus' });
219
+ expect(body.session.thinkingLevel).toBe('high');
220
+ expect(body.session.liveModels?.models).toEqual([{ value: 'opus', name: 'Opus 5.5' }]);
221
+ } finally {
222
+ release();
223
+ }
224
+ });
225
+
226
+ test('once the live session is gone the file answers for it', async () => {
227
+ const id = 'acp-dead-on-disk';
228
+ await writeSessionFile(id, [
229
+ { id: 'm1', parentId: null, type: 'model_change', model: 'claude/sonnet' },
230
+ { id: 'm2', parentId: 'm1', type: 'thinking_level_change', thinkingLevel: 'medium' },
231
+ ]);
232
+
233
+ const body = (await (await load(id)).json()) as {
234
+ session: { harness?: string; model?: { provider: string; modelId: string }; liveModels?: unknown };
235
+ };
236
+ expect(body.session.harness).toBeUndefined();
237
+ expect(body.session.liveModels).toBeUndefined();
238
+ expect(body.session.model).toEqual({ provider: 'claude', modelId: 'sonnet' });
239
+ });
85
240
  });
@@ -11,6 +11,9 @@ import { readRawHeaderLine } from '@/server/lib/omp/session/files';
11
11
  import { formatNewSessionTitle } from '@/shared/lib/omp/session/default-title';
12
12
  import { getLiveRunSessionIds, getLiveSession, harnessOfSession } from '@/server/lib/omp/rpc/session-registry';
13
13
  import { loadStreamStates } from '@/shared/lib/omp/session/stream-state.server';
14
+ import { configByCategory, selectValues } from '@/server/lib/harness/launch';
15
+ import type { AcpConfigOption } from '@/server/lib/harness/acp/protocol';
16
+ import type { LiveHarnessModels } from '@/shared/types/harness';
14
17
 
15
18
  /** Newest-message window served by default for omp JSONL sessions; the client
16
19
  * pages further back via `?before=` when the user scrolls to the top. Large
@@ -36,6 +39,33 @@ function windowMessages<T>(
36
39
  return { messages: messages.slice(start, end), total, hasMore: start > 0, oldestIndex: start };
37
40
  }
38
41
 
42
+ /** What a LIVE non-omp session adds to the session payload: its resolved model,
43
+ * its thinking level, and the selector lists it published. */
44
+ interface LiveSessionMeta {
45
+ model?: { provider: string; modelId: string };
46
+ thinkingLevel?: string;
47
+ harness?: string;
48
+ liveModels?: LiveHarnessModels;
49
+ }
50
+
51
+ /** Spread into the `session` payload so every branch states these fields once.
52
+ * `recorded` is the last run's model from `session_stream_state`, used only
53
+ * when no live session can answer. */
54
+ function liveMetaFields(
55
+ liveMeta: LiveSessionMeta | null,
56
+ recorded?: { provider: string; modelId: string },
57
+ recordedThinkingLevel?: string,
58
+ ): Record<string, unknown> {
59
+ const model = liveMeta?.model ?? recorded;
60
+ const thinkingLevel = liveMeta?.thinkingLevel ?? recordedThinkingLevel;
61
+ return {
62
+ ...(model ? { model } : {}),
63
+ ...(thinkingLevel ? { thinkingLevel } : {}),
64
+ ...(liveMeta?.harness ? { harness: liveMeta.harness } : {}),
65
+ ...(liveMeta?.liveModels?.models.length ? { liveModels: liveMeta.liveModels } : {}),
66
+ };
67
+ }
68
+
39
69
  export async function loader({ params, request }: LoaderFunctionArgs) {
40
70
  const { sessionId } = params;
41
71
  if (!sessionId) {
@@ -64,21 +94,36 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
64
94
  // omp's catalog and name a model the agent never ran. The LIVE session's
65
95
  // own selector is the only honest source — and `get_state` on the ACP
66
96
  // driver is an in-process read, not a round trip to the agent.
67
- let liveMeta: { model?: { provider: string; modelId: string }; thinkingLevel?: string } | null = null;
97
+ let liveMeta: LiveSessionMeta | null = null;
68
98
  if (!mock) {
69
99
  const live = getLiveSession(sessionId);
70
100
  if (live?.isAlive() && harnessOfSession(live) !== 'omp-rpc') {
101
+ const harness = harnessOfSession(live);
71
102
  const state = (await live.send({ type: 'get_state' }).catch(() => null)) as {
72
103
  model?: { provider?: unknown; id?: unknown };
73
104
  thinkingLevel?: unknown;
105
+ configOptions?: unknown;
74
106
  } | null;
75
107
  const provider = typeof state?.model?.provider === 'string' ? state.model.provider : '';
76
108
  const modelId = typeof state?.model?.id === 'string' ? state.model.id : '';
109
+ const selectors: AcpConfigOption[] = Array.isArray(state?.configOptions)
110
+ ? (state.configOptions as AcpConfigOption[])
111
+ : [];
112
+ // The session's OWN selector lists, so the picker lists exactly what
113
+ // this agent offers — a probe is one throwaway spawn that a chat already
114
+ // running can contradict (codex refuses the probe while offering models).
115
+ const models = selectValues(configByCategory(selectors, 'model'));
116
+ const thinking = selectValues(configByCategory(selectors, 'thought_level'));
77
117
  liveMeta = {
78
118
  ...(provider && modelId ? { model: { provider, modelId } } : {}),
79
119
  ...(typeof state?.thinkingLevel === 'string' && state.thinkingLevel
80
120
  ? { thinkingLevel: state.thinkingLevel }
81
121
  : {}),
122
+ harness,
123
+ liveModels: {
124
+ models,
125
+ ...(thinking.length > 0 ? { thinking } : {}),
126
+ },
82
127
  };
83
128
  }
84
129
  }
@@ -117,13 +162,23 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
117
162
  || (headerTimestamp ? formatNewSessionTitle(new Date(headerTimestamp)) : undefined)
118
163
  || `Session ${sessionId}`;
119
164
  const win = windowMessages(overlaid, limit, before);
165
+ // An ACP harness can own an on-disk transcript too — omp's own ACP server
166
+ // writes the same JSONL — and this branch used to return without the live
167
+ // session's own fields. The tab then published no selectors at all, so the
168
+ // picker for that harness could only ever list a probe snapshot instead of
169
+ // the list the RUNNING agent offers (`get_state` → `configOptions`), and
170
+ // the composer named the file's model rather than the one in force. The
171
+ // live halves win; the file answers once the session is gone.
120
172
  return json({
121
173
  session: {
122
174
  id: sessionId,
123
175
  title,
124
176
  messages: win.messages,
125
- model: await loadSessionModel(filePath),
126
- thinkingLevel: await loadSessionThinkingLevel(filePath),
177
+ ...liveMetaFields(
178
+ liveMeta,
179
+ await loadSessionModel(filePath),
180
+ await loadSessionThinkingLevel(filePath),
181
+ ),
127
182
  },
128
183
  isMock: false,
129
184
  source: 'omp-jsonl',
@@ -172,8 +227,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
172
227
  id: existing.session_id,
173
228
  title: (hasDefaultTitle && firstUserContent ? firstUserContent.slice(0, 120) : existing.title) || `Session ${sessionId}`,
174
229
  messages: parsedMessages,
175
- ...((liveMeta?.model ?? recordedModel) ? { model: liveMeta?.model ?? recordedModel } : {}),
176
- ...(liveMeta?.thinkingLevel ? { thinkingLevel: liveMeta.thinkingLevel } : {}),
230
+ ...liveMetaFields(liveMeta, recordedModel),
177
231
  },
178
232
  isMock: mock,
179
233
  });
@@ -194,8 +248,7 @@ export async function loader({ params, request }: LoaderFunctionArgs) {
194
248
  return json({
195
249
  session: {
196
250
  ...initial,
197
- ...((liveMeta?.model ?? recordedModel) ? { model: liveMeta?.model ?? recordedModel } : {}),
198
- ...(liveMeta?.thinkingLevel ? { thinkingLevel: liveMeta.thinkingLevel } : {}),
251
+ ...liveMetaFields(liveMeta, recordedModel),
199
252
  },
200
253
  isMock: mock,
201
254
  });
@@ -34,7 +34,8 @@ import { loadHarnessConfig, saveHarnessConfig } from '@/server/lib/harness/confi
34
34
  import { forgetProbe } from '@/server/lib/harness/probe-cache.server';
35
35
  import { probeEndpointProtocols, type EndpointProbe } from '@/server/lib/harness/provider-probe.server';
36
36
  import { writeProvider, type ListedProvider, type ProviderDraft } from '@/server/lib/harness/provider-write.server';
37
- import { readProviderKey } from '@/server/lib/harness/provider-sources.server';
37
+ import { readProviderKey, harnessesSharingRegistry } from '@/server/lib/harness/provider-sources.server';
38
+ import { refreshModelRegistryAfterWrite } from '@/server/lib/models/registry-refresh.server';
38
39
 
39
40
  /** A provider about to be written, from any source. */
40
41
  interface Candidate extends ListedProvider {
@@ -142,13 +143,24 @@ export async function applyProvider(target: HarnessId, candidate: Candidate, sou
142
143
  try {
143
144
  const written = await writeProvider(target, draft);
144
145
  // A variable-name format (codex's `env_key`) stores ONLY the name, so the
145
- // value is saved into the harness env — where the spawn reads it — and the
146
- // probe is dropped because the env is part of what it measured.
146
+ // value is saved into the harness env — where the spawn reads it.
147
147
  let config = null;
148
148
  if (Object.keys(written.env).length > 0) {
149
149
  config = withEnvValues(await loadHarnessConfig(target), written.env);
150
150
  await saveHarnessConfig(target, config);
151
- await forgetProbe(target);
151
+ }
152
+ // WHICH harnesses read this file, not just the one the card named:
153
+ // omp-rpc and omp-acp are two transports over one models.yml, so an add
154
+ // made on either tab has to invalidate both pickers.
155
+ const sharing = harnessesSharingRegistry(written.path);
156
+ const invalidated = sharing.length > 0 ? sharing : [target];
157
+ if (sharing.includes('omp-rpc') || sharing.includes('omp-acp')) {
158
+ // The omp registry is read by the pooled RPC child AND by every ACP
159
+ // probe. Recycle the child and drop the stale probe records here; the
160
+ // browser re-probes the tabs it reads (the response names them).
161
+ await refreshModelRegistryAfterWrite({ path: written.path, probes: true, reprobe: false });
162
+ } else {
163
+ for (const id of invalidated) await forgetProbe(id);
152
164
  }
153
165
  return json({
154
166
  imported: written,
@@ -156,6 +168,7 @@ export async function applyProvider(target: HarnessId, candidate: Candidate, sou
156
168
  target: registryLabel(target),
157
169
  protocol: planned,
158
170
  probe,
171
+ probeInvalidated: invalidated,
159
172
  ...(config ? { config } : {}),
160
173
  });
161
174
  } catch (cause) {
@@ -186,6 +199,7 @@ export async function applyProvider(target: HarnessId, candidate: Candidate, sou
186
199
  protocol: planned,
187
200
  probe,
188
201
  provider: candidate.id,
202
+ probeInvalidated: [target],
189
203
  });
190
204
  }
191
205
 
@@ -19,12 +19,13 @@ import { json } from '@/server/lib/remix-compat';
19
19
  import type { ActionFunctionArgs, LoaderFunctionArgs } from '@/server/lib/remix-compat';
20
20
  import { methodNotAllowed } from '@/server/lib/route-adapter';
21
21
  import { HARNESS_IDS, harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog';
22
- import { HARNESS_LAUNCH, blockedProbe, probeHarness } from '@/server/lib/harness/launch';
22
+ import { HARNESS_LAUNCH } from '@/server/lib/harness/launch-table';
23
23
  import type { HarnessProbe } from '@/server/lib/harness/capabilities';
24
24
  import { forgetProbe, loadProbes, rememberProbe } from '@/server/lib/harness/probe-cache.server';
25
25
  import { loadDisabledHarnesses, saveHarnessEnabled } from '@/server/lib/harness/enabled.server';
26
26
  import { harnessEnabled } from '@/shared/lib/harness/enabled';
27
- import { launchFromConfig, loadHarnessConfig, probeInvalidatedBy, resolveLaunch, saveHarnessConfig } from '@/server/lib/harness/config.server';
27
+ import { commandAvailable, probeWithConfig } from '@/server/lib/harness/auto-probe.server';
28
+ import { loadHarnessConfig, probeInvalidatedBy, saveHarnessConfig } from '@/server/lib/harness/config.server';
28
29
  import { importableProvidersFor, readRegistryProviders } from '@/server/lib/harness/provider-sources.server';
29
30
  import { addProviderAction, importProviderAction, importSourceOf, isImportBody } from '@/server/routes/harness/import-action';
30
31
  import { supportedProtocols } from '@/shared/lib/harness/dialects';
@@ -36,7 +37,6 @@ import {
36
37
  import { providerFacts } from '@/shared/lib/harness/provider-facts';
37
38
  import type { HarnessProviderSupport } from '@/shared/types/harness';
38
39
  import { parseHarnessConfig, type HarnessConfig } from '@/shared/lib/harness/config';
39
- import { resolveOmpBin } from '@/server/lib/omp/core/cli';
40
40
 
41
41
  /**
42
42
  * The probe cache lives in `probe-cache.server.ts`: the SPAWN reads it too, to
@@ -61,33 +61,6 @@ export interface HarnessSummary {
61
61
  unavailable?: string;
62
62
  }
63
63
 
64
- /**
65
- * Is a launch command first-token resolvable? The omp binary has its own
66
- * resolver (KABMO_OMP_BIN, then PATH) and is never "missing" through PATH alone.
67
- *
68
- * The USER's command override decides this, not the build's table: a harness
69
- * whose binary lives behind a wrapper, a container (`docker run … agy acp`) or an
70
- * absolute path read as "not installed" and could not even be switched on, while
71
- * a spawn of that same configured command worked.
72
- */
73
- function commandAvailable(id: HarnessId, config?: HarnessConfig): boolean {
74
- if (id === 'omp-acp') return Boolean(resolveOmpBin());
75
- let command = HARNESS_LAUNCH[id]?.command;
76
- if (config) {
77
- try {
78
- const configured = launchFromConfig(id, config);
79
- if (configured?.command.length) command = configured.command;
80
- } catch {
81
- // An unusable env line is reported by the probe; availability falls back
82
- // to the build's table rather than claiming "not installed".
83
- }
84
- }
85
- const [binary] = command ?? [];
86
- if (!binary) return false;
87
- if (binary === 'npx') return Boolean(Bun.which('npx') ?? Bun.which('node'));
88
- return Boolean(Bun.which(binary));
89
- }
90
-
91
64
  export async function listHarnesses(): Promise<HarnessSummary[]> {
92
65
  // ONE read for the whole catalog, from disk when memory is cold: the probe
93
66
  // cache used to be process-only, so every restart — every `bun --hot` reload —
@@ -121,29 +94,15 @@ export async function listHarnesses(): Promise<HarnessSummary[]> {
121
94
  ...(launch?.install ? { install: launch.install } : {}),
122
95
  ...(launch?.note ? { note: launch.note } : {}),
123
96
  probe: fresh,
124
- ...(available ? {} : { unavailable: `\`${launch?.command[0] ?? id}\` is not installed` }),
97
+ ...(available ? {} : {
98
+ unavailable: launch?.requires
99
+ ? `${launch.requires.label} is not installed`
100
+ : `\`${launch?.command[0] ?? id}\` is not installed`,
101
+ }),
125
102
  };
126
103
  });
127
104
  }
128
105
 
129
- /**
130
- * Probe a harness the way a SPAWN would launch it: the user's command and env
131
- * override are part of what is being measured.
132
- *
133
- * Without this, a harness that only works with its configured env — `CODEX_HOME`,
134
- * a provider base URL, a wrapper that logs in — probed as "Authentication
135
- * required" in Settings while its chats ran fine. A launch line that cannot even
136
- * be resolved (an invalid env line) answers a `blocked` record instead of a 500.
137
- */
138
- async function probeWithConfig(id: HarnessId, cwd: string): Promise<HarnessProbe> {
139
- try {
140
- const configured = await loadHarnessConfig(id);
141
- return await probeHarness(id, cwd, resolveLaunch(id, configured));
142
- } catch (cause) {
143
- return blockedProbe(id, cause instanceof Error ? cause.message : String(cause));
144
- }
145
- }
146
-
147
106
  export async function loader({ request }: LoaderFunctionArgs) {
148
107
  const url = new URL(request.url);
149
108
  const target = url.searchParams.get('probe');
@@ -20,6 +20,9 @@
20
20
  */
21
21
 
22
22
  import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
23
+ import { mkdtempSync, rmSync } from 'node:fs';
24
+ import { tmpdir } from 'node:os';
25
+ import { join } from 'node:path';
23
26
  import { isolateDb, releaseDb } from '@/test-support/isolated-db';
24
27
  import { probes } from '@/server/lib/harness/probe-cache.server';
25
28
  import { loadDisabledHarnesses } from '@/server/lib/harness/enabled.server';
@@ -39,7 +42,21 @@ function toggle(id: string, enabled: boolean): Request {
39
42
  });
40
43
  }
41
44
 
45
+ /**
46
+ * The probe below is REAL: when `omp` is installed, enabling `omp-acp` spawns
47
+ * `omp acp`, and that child writes a session file into the agent directory it
48
+ * resolves — `~/.omp/agent/sessions/-projects-kabmo/` when this suite runs from
49
+ * the repo. The file has no title, so Kabmo's sidebar draws it as
50
+ * `New Session - <timestamp>`: every `bun test` left one more row behind in the
51
+ * developer's own install (observed at 11:47 and 11:50, matching this suite's
52
+ * `acp` spawns in the process table). Point the child's agent dir at a throwaway
53
+ * tree so the probe still measures the real binary without touching real state.
54
+ */
55
+ const AGENT_DIR = mkdtempSync(join(tmpdir(), 'kabmo-toggle-agent-'));
56
+ const savedAgentDir = Bun.env.PI_CODING_AGENT_DIR;
57
+
42
58
  beforeEach(async () => {
59
+ Bun.env.PI_CODING_AGENT_DIR = AGENT_DIR;
43
60
  await isolateDb();
44
61
  probes().clear();
45
62
  });
@@ -51,6 +68,9 @@ afterEach(async () => {
51
68
 
52
69
  afterAll(async () => {
53
70
  await releaseDb();
71
+ if (savedAgentDir === undefined) delete Bun.env.PI_CODING_AGENT_DIR;
72
+ else Bun.env.PI_CODING_AGENT_DIR = savedAgentDir;
73
+ rmSync(AGENT_DIR, { recursive: true, force: true });
54
74
  });
55
75
 
56
76
  describe('switching a harness on', () => {
@@ -42,10 +42,12 @@ import { json } from '@/server/lib/remix-compat';
42
42
  import type { ActionFunctionArgs } from '@/server/lib/remix-compat';
43
43
  import { methodNotAllowed } from '@/server/lib/route-adapter';
44
44
  import { HARNESS_IDS, harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog';
45
- import { harnessUpdateFacts, latestSourceFor } from '@/shared/lib/harness/updates';
45
+ import { harnessUpdateFacts, latestSourceFor, type HarnessUpdateFacts } from '@/shared/lib/harness/updates';
46
46
  import { forgetProbe, loadProbes } from '@/server/lib/harness/probe-cache.server';
47
47
  import { forgetCliVersion, harnessVersionState } from '@/server/lib/harness/update-state.server';
48
- import { planHarnessUpdate } from '@/shared/lib/harness/update-plan';
48
+ import { planHarnessUpdate, repointAdapterLaunch, type HarnessUpdateStep } from '@/shared/lib/harness/update-plan';
49
+ import { loadHarnessConfig, saveHarnessConfig } from '@/server/lib/harness/config.server';
50
+ import { resolveOmpBin } from '@/server/lib/omp/core/cli';
49
51
  import { harnessVersionRows } from '@/server/routes/harness/versions';
50
52
 
51
53
  /** Longest one update may run before it is killed and reported as a timeout. */
@@ -87,6 +89,37 @@ function tail(output: string, lines = 12): string {
87
89
  return all.slice(Math.max(0, all.length - lines)).join('\n').trim();
88
90
  }
89
91
 
92
+ /**
93
+ * Make an adapter install the one the next spawn runs.
94
+ *
95
+ * The launch table starts an npm adapter through a PINNED `npx -y pkg@x.y.z`
96
+ * (measured versions), while the update installs the package GLOBALLY. Those are
97
+ * two different resolvers: `npm i -g` writes a binary onto PATH that `npx` never
98
+ * consults, so the press reported success while every new session still started
99
+ * the old pinned build — measured on `claude` (global 0.101.0, launch requested
100
+ * 0.100.0) and reproduced for codex/pi/zcode by construction.
101
+ *
102
+ * Once the install succeeded AND the binary is on PATH, the harness's launch
103
+ * line is pointed at it. A user's own configured command is never replaced: it
104
+ * is an explicit choice about how this machine launches the harness.
105
+ */
106
+ async function pointAtInstalledAdapter(
107
+ harness: HarnessId,
108
+ facts: HarnessUpdateFacts,
109
+ steps: HarnessUpdateStep[],
110
+ ): Promise<string | null> {
111
+ const config = await loadHarnessConfig(harness);
112
+ const bin = repointAdapterLaunch(
113
+ facts,
114
+ steps,
115
+ config.command,
116
+ facts.agentBin ? Boolean(Bun.which(facts.agentBin)) : false,
117
+ );
118
+ if (!bin) return null;
119
+ await saveHarnessConfig(harness, { ...config, command: bin });
120
+ return bin;
121
+ }
122
+
90
123
  export async function action({ request, params }: ActionFunctionArgs) {
91
124
  if (request.method !== 'POST') return methodNotAllowed({ request, params });
92
125
 
@@ -120,10 +153,14 @@ export async function action({ request, params }: ActionFunctionArgs) {
120
153
  if (facts.kind === 'self') {
121
154
  const command = facts.command?.split(' ') ?? [];
122
155
  const binary = command[0];
123
- if (!binary || !Bun.which(binary)) {
156
+ // `omp` has its own resolver (`KABMO_OMP_BIN`, then PATH): a custom install
157
+ // is launchable and already reported as installed by `commandAvailable`, so
158
+ // checking PATH alone refused the one updater the harness actually has.
159
+ const resolved = harness === 'omp-acp' ? resolveOmpBin() : binary ? Bun.which(binary) : null;
160
+ if (!binary || !resolved) {
124
161
  return json({ error: `${label}: \`${binary ?? 'the updater'}\` is not on PATH` }, { status: 400 });
125
162
  }
126
- const result = await run(command);
163
+ const result = await run([resolved, ...command.slice(1)]);
127
164
  const ok = result.code === 0;
128
165
  const outcome: HarnessUpdateOutcome = {
129
166
  success: ok,
@@ -136,9 +173,11 @@ export async function action({ request, params }: ActionFunctionArgs) {
136
173
  }
137
174
 
138
175
  // `npm`: install the package at the version the registry reports NOW, so the
139
- // number on screen and the install cannot disagree.
176
+ // number on screen and the install cannot disagree. A harness can have no
177
+ // AGENT package while its CLI has one (`dsh`): the CLI step is then the whole
178
+ // update, so the missing agent package is not a refusal.
140
179
  const pkg = latestSourceFor(harness);
141
- if (!pkg) return json({ error: `${label} has no package to install` }, { status: 400 });
180
+ if (!pkg && !facts.cli?.pkg) return json({ error: `${label} has no package to install` }, { status: 400 });
142
181
 
143
182
  const probe = (await loadProbes()).get(harness);
144
183
  const agentVersion = probe?.capabilities.agentVersion ?? null;
@@ -198,13 +237,16 @@ export async function action({ request, params }: ActionFunctionArgs) {
198
237
  // minutes, so the row would keep claiming the old number after it moved.
199
238
  if (facts.cli) forgetCliVersion(facts.cli.bin);
200
239
  }
240
+ // Only after the install succeeded: the launch line is repointed at the binary
241
+ // that install wrote, or the next session would start the pinned one forever.
242
+ const repointed = ok ? await pointAtInstalledAdapter(harness, facts, steps) : null;
201
243
 
202
244
  const moved = steps.map((step) => step.part);
203
245
  return json({
204
246
  success: ok,
205
247
  id: harness,
206
248
  message: ok
207
- ? `${label} updated (${moved.join(' + ')}) — check its status to read the new version`
249
+ ? `${label} updated (${moved.join(' + ')})${repointed ? ` — launches now run \`${repointed}\`` : ''} — check its status to read the new version`
208
250
  : `${label} update failed`,
209
251
  command: steps.map((step) => step.command).join(' && '),
210
252
  ...(outputs.length > 0 ? { output: tail(outputs.join('\n')) } : {}),
@@ -66,7 +66,11 @@ function toRow(
66
66
  else if (!facts) note = 'Kabmo knows nothing about updating this harness.';
67
67
  else if (!state.agent.version) note = 'Not probed yet — check its status to learn the version it runs.';
68
68
  else if (facts.kind !== 'npm') note = facts.command ? `Updated by \`${facts.command}\`.` : note;
69
- else if (!state.agent.latest) note = `Could not read ${facts.pkg} from the registry.`;
69
+ // An npm harness can have no AGENT package (`dsh`: the probe reports the ACP
70
+ // surface, the package is the CLI). The note names whichever package was
71
+ // actually read, instead of "Could not read undefined".
72
+ else if (facts.pkg && !state.agent.latest) note = `Could not read ${facts.pkg} from the registry.`;
73
+ else if (facts.cli?.pkg && state.cli?.version && !state.cli.latest) note = `Could not read ${facts.cli.pkg} from the registry.`;
70
74
 
71
75
  return {
72
76
  id,