@kabmo-labs/kabmo 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +579 -510
- package/dist/client/static/js/index-bc9aa4mx.css +1 -0
- package/dist/client/static/js/{index-jcr5twtp.js → index-ga8cbpt4.js} +1072 -1174
- package/package.json +2 -4
- package/src/cli/lib/args.js +24 -1
- package/src/cli/lib/args.test.js +16 -0
- package/src/cli/lib/commands/session.js +233 -0
- package/src/cli/lib/commands/session.test.js +103 -0
- package/src/cli/main.js +1 -1
- package/src/client/components/common/ComposerPicker.tsx +3 -0
- package/src/client/components/common/code-surface/shiki.test.ts +82 -0
- package/src/client/components/common/code-surface/shiki.ts +28 -7
- package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +113 -0
- package/src/client/components/common/session-actions-menu/index.tsx +33 -2
- package/src/client/components/common/session-row/StatusSlot.tsx +4 -4
- package/src/client/components/common/session-row/index.tsx +27 -1
- package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +25 -12
- package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +66 -0
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +28 -3
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +36 -5
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +94 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +120 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +47 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +28 -35
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +18 -5
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +21 -4
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +27 -5
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
- package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +135 -118
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +4 -0
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +3 -1
- package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
- package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
- package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
- package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
- package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
- package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
- package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
- package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
- package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
- package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
- package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
- package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
- package/src/client/data/settings/omp-schema.json +1 -1
- package/src/client/data/theme/terminal.test.ts +25 -0
- package/src/client/data/theme/terminal.ts +96 -79
- package/src/client/hooks/chat/composer/items.test.ts +12 -26
- package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
- package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
- package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
- package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
- package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
- package/src/client/hooks/chat/timeline/send-execute.test.ts +39 -0
- package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
- package/src/client/hooks/chat/timeline/send-steer.test.ts +3 -1
- package/src/client/hooks/chat/timeline/send.test-util.ts +7 -1
- package/src/client/hooks/chat/timeline/send.test.ts +3 -1
- package/src/client/hooks/chat/timeline/send.ts +51 -50
- package/src/client/hooks/chat/timeline/use-fork-session.ts +49 -0
- package/src/client/hooks/models/use-harness-update.test.ts +193 -0
- package/src/client/hooks/models/use-harness-update.ts +202 -0
- package/src/client/hooks/workspace/child-expansion.ts +33 -0
- package/src/client/hooks/workspace/terminal/index.ts +17 -3
- package/src/client/hooks/workspace/terminal/socket.ts +9 -4
- package/src/client/lib/session-tree.test.ts +50 -0
- package/src/client/lib/session-tree.ts +59 -0
- package/src/client/tailwind.css +17 -11
- package/src/server/index.ts +2 -0
- package/src/server/lib/auth/guard.ts +10 -0
- package/src/server/lib/btw/session-copy.server.ts +6 -44
- package/src/server/lib/btw/session-copy.test.ts +2 -1
- package/src/server/lib/db/schema.ts +4 -0
- package/src/server/lib/db/seed-terminal.test.ts +1 -1
- package/src/server/lib/db/seed.test.ts +1 -1
- package/src/server/lib/harness/acp/background-work.test.ts +262 -0
- package/src/server/lib/harness/acp/background-work.ts +320 -0
- package/src/server/lib/harness/acp/client.ts +2 -2
- package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
- package/src/server/lib/harness/acp/gateway-env.ts +70 -0
- package/src/server/lib/harness/acp/prompt.test.ts +20 -0
- package/src/server/lib/harness/acp/prompt.ts +19 -3
- package/src/server/lib/harness/acp/session-background.test.ts +129 -0
- package/src/server/lib/harness/acp/session-exit.ts +31 -0
- package/src/server/lib/harness/acp/session-handshake.test.ts +108 -0
- package/src/server/lib/harness/acp/session-handshake.ts +27 -1
- package/src/server/lib/harness/acp/session-listeners.ts +31 -0
- package/src/server/lib/harness/acp/session-requests.ts +47 -0
- package/src/server/lib/harness/acp/session-turns.ts +20 -5
- package/src/server/lib/harness/acp/session.test-util.ts +23 -1
- package/src/server/lib/harness/acp/session.ts +59 -59
- package/src/server/lib/harness/acp/turn.test.ts +81 -0
- package/src/server/lib/harness/acp/turn.ts +26 -9
- package/src/server/lib/harness/acp/verbs.ts +12 -2
- package/src/server/lib/harness/launch.ts +3 -1
- package/src/server/lib/harness/spawn.server.ts +15 -2
- package/src/server/lib/harness/update-job-store.test.ts +126 -0
- package/src/server/lib/harness/update-job-store.ts +109 -0
- package/src/server/lib/harness/update-job.server.ts +203 -0
- package/src/server/lib/harness/update-worker.test.ts +153 -0
- package/src/server/lib/harness/update-worker.ts +197 -0
- package/src/server/lib/lifecycle/paths.ts +23 -0
- package/src/server/lib/omp/rpc/manager.ts +5 -5
- package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
- package/src/server/lib/omp/rpc/session-registry.ts +14 -2
- package/src/server/lib/omp/rpc/terminal-settle.ts +53 -5
- package/src/server/lib/omp/session/delete-flow.server.ts +47 -0
- package/src/server/lib/omp/session/delete.server.ts +5 -0
- package/src/server/lib/omp/session/rewind-file.ts +39 -21
- package/src/server/lib/omp/session/sidebar-data.server.ts +6 -6
- package/src/server/lib/omp/session/transcript-copy.ts +123 -0
- package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
- package/src/server/lib/sessions/agent-token.server.ts +134 -0
- package/src/server/lib/sessions/answers.server.test.ts +33 -0
- package/src/server/lib/sessions/answers.server.ts +37 -0
- package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
- package/src/server/lib/sessions/dispatch.server.ts +128 -0
- package/src/server/lib/sessions/fork.server.test.ts +209 -0
- package/src/server/lib/sessions/fork.server.ts +304 -0
- package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
- package/src/server/lib/sessions/lifecycle.server.ts +71 -0
- package/src/server/lib/sessions/notify.server.test.ts +112 -0
- package/src/server/lib/sessions/notify.server.ts +212 -0
- package/src/server/lib/sessions/relation-types.ts +76 -0
- package/src/server/lib/sessions/relations.server.test.ts +207 -0
- package/src/server/lib/sessions/relations.server.ts +337 -0
- package/src/server/lib/sessions/resolve.server.ts +106 -0
- package/src/server/lib/sessions/schema.server.ts +82 -0
- package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
- package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
- package/src/server/lib/sessions/spawn.server.test.ts +196 -0
- package/src/server/lib/sessions/spawn.server.ts +310 -0
- package/src/server/lib/terminal/attach-replay.test.ts +2 -2
- package/src/server/lib/terminal/output.test.ts +2 -2
- package/src/server/lib/terminal/output.ts +1 -1
- package/src/server/lib/terminal/resize.test.ts +99 -0
- package/src/server/lib/terminal/runtime.server.ts +26 -6
- package/src/server/lib/terminal/send-result.test.ts +18 -1
- package/src/server/lib/terminal/send-result.ts +26 -2
- package/src/server/lib/terminal/session.server.ts +6 -6
- package/src/server/lib/usage/new-api.test.ts +92 -0
- package/src/server/lib/usage/new-api.ts +131 -0
- package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
- package/src/server/lib/usage/provider-key.ts +33 -0
- package/src/server/lib/usage/providers.server.ts +10 -3
- package/src/server/lib/usage/vendor-balance.server.ts +4 -53
- package/src/server/lib/usage/vendor-http.ts +41 -0
- package/src/server/lib/usage/window.ts +55 -0
- package/src/server/routes/agent/command.ts +14 -1
- package/src/server/routes/agent/harness-command.ts +6 -0
- package/src/server/routes/agent/new.ts +15 -0
- package/src/server/routes/harness/add-provider.test.ts +9 -1
- package/src/server/routes/harness/import-action.ts +4 -0
- package/src/server/routes/harness/import.test.ts +1 -1
- package/src/server/routes/harness/index.ts +5 -1
- package/src/server/routes/harness/update-status.ts +26 -0
- package/src/server/routes/harness/update.test.ts +119 -0
- package/src/server/routes/harness/update.ts +59 -147
- package/src/server/routes/sessions/answer.ts +24 -0
- package/src/server/routes/sessions/batch-delete.ts +11 -5
- package/src/server/routes/sessions/delete.ts +4 -2
- package/src/server/routes/sessions/fork.ts +74 -0
- package/src/server/routes/sessions/index.ts +14 -0
- package/src/server/routes/sessions/relations.ts +85 -0
- package/src/server/routes/sessions/session.ts +4 -0
- package/src/server/routes/sessions/spawn.ts +134 -0
- package/src/server/routes/terminal/ws.ts +3 -3
- package/src/shared/lib/chat/composer/client.ts +31 -2
- package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
- package/src/shared/lib/chat/composer/delegation.ts +206 -0
- package/src/shared/lib/chat/notice-text.ts +1 -1
- package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
- package/src/shared/lib/code/ansi.ts +1 -1
- package/src/shared/lib/fonts/nerd-symbols.css +4 -3
- package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
- package/src/shared/lib/harness/provider-facts.test.ts +27 -0
- package/src/shared/lib/harness/providers.ts +35 -1
- package/src/shared/lib/harness/update-job.ts +33 -0
- package/src/shared/lib/harness/update-plan.test.ts +21 -6
- package/src/shared/lib/harness/update-plan.ts +12 -4
- package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
- package/src/shared/lib/omp/session/wait-idle.ts +12 -2
- package/src/shared/lib/theme/catalog.test.ts +13 -9
- package/src/shared/lib/theme/color.test.ts +2 -2
- package/src/shared/lib/theme/color.ts +4 -4
- package/src/shared/lib/theme/theme.test.ts +1 -1
- package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
- package/src/shared/lib/workspace/terminal/input.ts +33 -0
- package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
- package/src/shared/lib/workspace/terminal/keys.ts +7 -7
- package/src/shared/types/chat.ts +1 -1
- package/src/shared/types/harness-update.ts +65 -0
- package/src/shared/types/omp/agent.ts +19 -2
- package/src/shared/types/workspace.ts +4 -0
- package/src/test-support/fake-omp-fork.ts +16 -2
- package/src/test-support/harness-table.test-util.ts +15 -1
- package/dist/client/static/js/index-z3w7n85q.css +0 -1
- package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
- package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
|
@@ -57,6 +57,31 @@ export function supportsProviderEditor(id: string | null | undefined): boolean {
|
|
|
57
57
|
return providerLevel(id) === 'full';
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* The id an endpoint serves for one picker alias, or null when it serves no
|
|
62
|
+
* model of that family.
|
|
63
|
+
*
|
|
64
|
+
* Claude Code's picker offers FAMILY aliases (`opus`, `sonnet`, `haiku`,
|
|
65
|
+
* `fable`). An alias that is not pinned with `ANTHROPIC_DEFAULT_*_MODEL` keeps
|
|
66
|
+
* resolving to Anthropic's own model id, which a gateway answers with
|
|
67
|
+
* `400 model not found: sonnet` (measured against kenari.id). The model list
|
|
68
|
+
* the endpoint published is what says which id belongs to the family.
|
|
69
|
+
*
|
|
70
|
+
* The id is returned BARE: `kenari/claude-sonnet-5` becomes
|
|
71
|
+
* `claude-sonnet-5`, because the variable names the model the endpoint expects,
|
|
72
|
+
* not the provider-qualified spelling an agent's own list may use.
|
|
73
|
+
*/
|
|
74
|
+
export function aliasModelFor(family: string, models: readonly string[]): string | null {
|
|
75
|
+
const pattern = new RegExp(`\\b${family.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\b`, 'i');
|
|
76
|
+
for (const raw of models) {
|
|
77
|
+
const id = raw.trim();
|
|
78
|
+
if (!id) continue;
|
|
79
|
+
const bare = id.slice(id.lastIndexOf('/') + 1);
|
|
80
|
+
if (pattern.test(bare)) return bare;
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
|
|
60
85
|
/**
|
|
61
86
|
* The env a provider becomes for an `environment` harness.
|
|
62
87
|
*
|
|
@@ -65,10 +90,15 @@ export function supportsProviderEditor(id: string | null | undefined): boolean {
|
|
|
65
90
|
* form labels each field with the variable it becomes. A blank field writes NO
|
|
66
91
|
* variable — an empty env var is a real thing to set, so the form must not do it
|
|
67
92
|
* by accident.
|
|
93
|
+
*
|
|
94
|
+
* `models` is the endpoint's own listing. When given, every picker alias that
|
|
95
|
+
* family serves is PINNED to that id. Without the pin the alias still resolves
|
|
96
|
+
* to the vendor's model, so a picker row the user can see answers a gateway
|
|
97
|
+
* with `400 model not found` (measured on `sonnet` against kenari.id).
|
|
68
98
|
*/
|
|
69
99
|
export function providerEnv(
|
|
70
100
|
id: string | null | undefined,
|
|
71
|
-
provider: { baseUrl: string; apiKey: string; model?: string },
|
|
101
|
+
provider: { baseUrl: string; apiKey: string; model?: string; models?: readonly string[] },
|
|
72
102
|
): Record<string, string> {
|
|
73
103
|
const contract = providerFacts(id).env;
|
|
74
104
|
if (!contract) return {};
|
|
@@ -76,6 +106,10 @@ export function providerEnv(
|
|
|
76
106
|
if (provider.baseUrl.trim()) env[contract.baseUrl] = provider.baseUrl.trim();
|
|
77
107
|
if (provider.apiKey.trim()) env[contract.apiKey] = provider.apiKey.trim();
|
|
78
108
|
if (contract.model && provider.model?.trim()) env[contract.model] = provider.model.trim();
|
|
109
|
+
for (const alias of contract.modelAliases ?? []) {
|
|
110
|
+
const model = aliasModelFor(alias.family, provider.models ?? []);
|
|
111
|
+
if (model) env[alias.env] = model;
|
|
112
|
+
}
|
|
79
113
|
return env;
|
|
80
114
|
}
|
|
81
115
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Narrowing a harness-update record that came from somewhere else.
|
|
8
|
+
*
|
|
9
|
+
* Two readers get one over the wire or off disk — the About card, which parses
|
|
10
|
+
* the status response, and the server, which parses the file a detached worker
|
|
11
|
+
* wrote — and neither may assume the shape: a half-written file or an older
|
|
12
|
+
* build's payload would otherwise reach `job.steps.find(...)` and throw inside a
|
|
13
|
+
* render. The guard IS the check, so a payload that fails it reads as "no run".
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { HarnessUpdateJob } from '@/shared/types/harness-update';
|
|
17
|
+
|
|
18
|
+
export function isHarnessUpdateJob(value: unknown): value is HarnessUpdateJob {
|
|
19
|
+
if (!value || typeof value !== 'object') return false;
|
|
20
|
+
const job = value as Partial<HarnessUpdateJob>;
|
|
21
|
+
return typeof job.harness === 'string'
|
|
22
|
+
&& typeof job.label === 'string'
|
|
23
|
+
&& typeof job.startedAt === 'number'
|
|
24
|
+
&& Array.isArray(job.steps)
|
|
25
|
+
&& (job.finishedAt === null || typeof job.finishedAt === 'number');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The `job` field of a status payload, or null when it is not a record. */
|
|
29
|
+
export function updateJobFrom(payload: unknown): HarnessUpdateJob | null {
|
|
30
|
+
if (!payload || typeof payload !== 'object') return null;
|
|
31
|
+
const found: unknown = (payload as { job?: unknown }).job;
|
|
32
|
+
return isHarnessUpdateJob(found) ? found : null;
|
|
33
|
+
}
|
|
@@ -41,8 +41,11 @@ function state(overrides: Partial<UpdatePlanState> = {}): UpdatePlanState {
|
|
|
41
41
|
describe('repointing a launch line after an adapter install', () => {
|
|
42
42
|
const install: HarnessUpdateStep = {
|
|
43
43
|
part: 'adapter',
|
|
44
|
-
command: 'npm install -g @agentclientprotocol/claude-agent-acp@0.101.0',
|
|
45
|
-
argv: [
|
|
44
|
+
command: 'npm install -g @agentclientprotocol/claude-agent-acp@0.101.0 --allow-scripts=@agentclientprotocol/claude-agent-acp',
|
|
45
|
+
argv: [
|
|
46
|
+
'npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0',
|
|
47
|
+
'--allow-scripts=@agentclientprotocol/claude-agent-acp',
|
|
48
|
+
],
|
|
46
49
|
};
|
|
47
50
|
|
|
48
51
|
test('a pinned npx adapter is pointed at the binary the install wrote', () => {
|
|
@@ -68,7 +71,13 @@ describe('planning a harness update', () => {
|
|
|
68
71
|
test('both parts behind runs the install AND the CLI updater, in that order', () => {
|
|
69
72
|
const steps = planHarnessUpdate('claude', CLAUDE, state(), '0.100.0');
|
|
70
73
|
expect(steps.map((step) => step.argv[0])).toEqual(['npm', 'claude']);
|
|
71
|
-
|
|
74
|
+
// The per-package `--allow-scripts` is part of the plan: npm 11 skips
|
|
75
|
+
// postinstall by default, and a native CLI installed without it is broken on
|
|
76
|
+
// disk (measured: `bin/claude.exe` left as a "native binary not installed" stub).
|
|
77
|
+
expect(steps[0].argv).toEqual([
|
|
78
|
+
'npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0',
|
|
79
|
+
'--allow-scripts=@agentclientprotocol/claude-agent-acp',
|
|
80
|
+
]);
|
|
72
81
|
expect(steps[0].part).toBe('adapter');
|
|
73
82
|
expect(steps[1].argv).toEqual(['claude', 'update']);
|
|
74
83
|
expect(steps[1].part).toBe('Claude Code');
|
|
@@ -95,7 +104,13 @@ describe('planning a harness update', () => {
|
|
|
95
104
|
'0.100.0',
|
|
96
105
|
);
|
|
97
106
|
expect(steps).toHaveLength(1);
|
|
98
|
-
|
|
107
|
+
// The per-package `--allow-scripts` is part of the plan: npm 11 skips
|
|
108
|
+
// postinstall by default, and a native CLI installed without it is broken on
|
|
109
|
+
// disk (measured: `bin/claude.exe` left as a "native binary not installed" stub).
|
|
110
|
+
expect(steps[0].argv).toEqual([
|
|
111
|
+
'npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.101.0',
|
|
112
|
+
'--allow-scripts=@agentclientprotocol/claude-agent-acp',
|
|
113
|
+
]);
|
|
99
114
|
});
|
|
100
115
|
|
|
101
116
|
test('nothing behind plans nothing, so the route can say "already up to date"', () => {
|
|
@@ -146,7 +161,7 @@ describe('planning a harness update', () => {
|
|
|
146
161
|
);
|
|
147
162
|
expect(steps).toHaveLength(1);
|
|
148
163
|
expect(steps[0].part).toBe('deepseek-harness');
|
|
149
|
-
expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@deepseek-ai/dsh@0.3.0']);
|
|
164
|
+
expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@deepseek-ai/dsh@0.3.0', '--allow-scripts=@deepseek-ai/dsh']);
|
|
150
165
|
});
|
|
151
166
|
|
|
152
167
|
test('a plain npm harness names itself, not "adapter"', () => {
|
|
@@ -158,6 +173,6 @@ describe('planning a harness update', () => {
|
|
|
158
173
|
);
|
|
159
174
|
expect(steps).toHaveLength(1);
|
|
160
175
|
expect(steps[0].part).toBe('qwen');
|
|
161
|
-
expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@qwen-code/qwen-code@0.10.0']);
|
|
176
|
+
expect(steps[0].argv).toEqual(['npm', 'install', '-g', '@qwen-code/qwen-code@0.10.0', '--allow-scripts=@qwen-code/qwen-code']);
|
|
162
177
|
});
|
|
163
178
|
});
|
|
@@ -19,6 +19,14 @@
|
|
|
19
19
|
* read (a `self` CLI, a CLI with no package in the facts) is never planned: Kabmo
|
|
20
20
|
* cannot claim it is behind.
|
|
21
21
|
*
|
|
22
|
+
* **The install allows the vendor's own lifecycle scripts, for that package only.**
|
|
23
|
+
* npm 11 blocks postinstall by default, and the packages here need it: measured on
|
|
24
|
+
* this machine, `@anthropic-ai/claude-code` was present with its native binary
|
|
25
|
+
* missing — `bin/claude.exe` was a stub printing "claude native binary not
|
|
26
|
+
* installed", and `claude update` then failed with
|
|
27
|
+
* `update_apply_native_binary_missing`. A per-package `--allow-scripts=<pkg>` is
|
|
28
|
+
* the narrow form; blanket script execution is not.
|
|
29
|
+
*
|
|
22
30
|
* Pure, so the decision is testable without spawning anything — the route only
|
|
23
31
|
* runs the argv this returns.
|
|
24
32
|
*/
|
|
@@ -77,8 +85,8 @@ export function planHarnessUpdate(
|
|
|
77
85
|
// An adapter over a CLI is named `adapter`, so a report cannot be read as
|
|
78
86
|
// "the CLI moved" when only its bridge did.
|
|
79
87
|
part: state.cli ? 'adapter' : label,
|
|
80
|
-
command: `npm install -g ${facts.pkg}@${latest}`,
|
|
81
|
-
argv: ['npm', 'install', '-g', `${facts.pkg}@${latest}`],
|
|
88
|
+
command: `npm install -g ${facts.pkg}@${latest} --allow-scripts=${facts.pkg}`,
|
|
89
|
+
argv: ['npm', 'install', '-g', `${facts.pkg}@${latest}`, `--allow-scripts=${facts.pkg}`],
|
|
82
90
|
});
|
|
83
91
|
}
|
|
84
92
|
}
|
|
@@ -100,8 +108,8 @@ export function planHarnessUpdate(
|
|
|
100
108
|
} else if (facts.cli?.pkg) {
|
|
101
109
|
steps.push({
|
|
102
110
|
part: cli.name,
|
|
103
|
-
command: `npm install -g ${facts.cli.pkg}@${cli.latest}`,
|
|
104
|
-
argv: ['npm', 'install', '-g', `${facts.cli.pkg}@${cli.latest}`],
|
|
111
|
+
command: `npm install -g ${facts.cli.pkg}@${cli.latest} --allow-scripts=${facts.cli.pkg}`,
|
|
112
|
+
argv: ['npm', 'install', '-g', `${facts.cli.pkg}@${cli.latest}`, `--allow-scripts=${facts.cli.pkg}`],
|
|
105
113
|
});
|
|
106
114
|
}
|
|
107
115
|
}
|
|
@@ -25,6 +25,17 @@ describe('the idle ladder', () => {
|
|
|
25
25
|
expect(waitIdleOf('No service finished within 30s. Read proc:// for status.')).toEqual({ windowMs: 30_000 });
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
test('reads the 18.18.6 sentence, which names the next rung instead of ending', () => {
|
|
29
|
+
// 18.18.6 appends a back-to-back hint after a semicolon, and words a
|
|
30
|
+
// timeout that watched jobs the same way (`No job finished …`). A regex
|
|
31
|
+
// demanding the period stopped matching, so both cards lost the idle chip.
|
|
32
|
+
expect(waitIdleOf('No reply within 5.0s; a back-to-back wait allows up to 10s.')).toEqual({ windowMs: 5_000 });
|
|
33
|
+
expect(waitIdleOf('No service finished within 10s; a back-to-back wait allows up to 30s. Read proc:// for status.'))
|
|
34
|
+
.toEqual({ windowMs: 10_000 });
|
|
35
|
+
expect(waitIdleOf('1 background job still running.\n\nNo job finished within 30s; a back-to-back wait allows up to 60s.'))
|
|
36
|
+
.toEqual({ windowMs: 30_000 });
|
|
37
|
+
});
|
|
38
|
+
|
|
28
39
|
test('reads the streak omp names from the second idle wait on', () => {
|
|
29
40
|
// `WAIT_NOTICE_RUNG` appends the notice whose span is the RUNNING TOTAL:
|
|
30
41
|
// 5 s + 10 s, then + 30 s, then + 60 s, then + 300 s.
|
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
* omp's prose, which is what this module parses. It lives beside `wait.ts`
|
|
18
18
|
* rather than inside it because the card's parser (jobs, agents, messages) and
|
|
19
19
|
* the outcomes omp words are separate subjects, and the file ceiling is real.
|
|
20
|
+
*
|
|
21
|
+
* 18.18.6 ends that sentence with the ladder's next rung — `No reply within
|
|
22
|
+
* 5.0s; a back-to-back wait allows up to 10s.` — and words a job-timeout return
|
|
23
|
+
* the same way (`No job finished within …`). The parser accepts both the old
|
|
24
|
+
* period and the new semicolon, because persisted sessions carry the older
|
|
25
|
+
* sentence.
|
|
20
26
|
*/
|
|
21
27
|
|
|
22
28
|
import { formatToolMs } from '@/shared/lib/chat/tool/labels';
|
|
@@ -29,8 +35,12 @@ export const WAIT_LADDER_MS = [5_000, 10_000, 30_000, 60_000, 300_000] as const;
|
|
|
29
35
|
/** A span in omp's `formatDuration` spelling: `250ms`, `5.0s`, `30s`, `1m45s`, `5m`, `2h5m`. */
|
|
30
36
|
const OMP_DURATION = String.raw`(?:\d+d)?(?:\d+h)?(?:\d+m)?(?:[\d.]+s)?(?:\d+ms)?`;
|
|
31
37
|
|
|
32
|
-
/** `No reply within 5.0s.`
|
|
33
|
-
|
|
38
|
+
/** `No reply within 5.0s.` (≤18.18.3) and the 18.18.6 form
|
|
39
|
+
* `No job finished within 5.0s; a back-to-back wait allows up to 10s.` */
|
|
40
|
+
const WAIT_WINDOW_TEXT = new RegExp(
|
|
41
|
+
`^No (?:reply|job finished|service finished) within (${OMP_DURATION})(?:\\.|;)`,
|
|
42
|
+
'm',
|
|
43
|
+
);
|
|
34
44
|
|
|
35
45
|
/** `Nothing new after 15.0s of back-to-back waits.` — appended from the SECOND
|
|
36
46
|
* consecutive idle wait, inside a `<system-notice>` block, and the only place
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from '@/shared/lib/theme/catalog';
|
|
24
24
|
import { themeStyleSheet } from '@/shared/lib/theme/css';
|
|
25
25
|
import { mixHex, parseHexColor } from '@/shared/lib/theme/color';
|
|
26
|
-
import {
|
|
26
|
+
import { getTerminalTheme } from '@/client/data/theme/terminal';
|
|
27
27
|
|
|
28
28
|
const COLOR_KEYS = ['canvas', 'paper', 'ink', 'error', 'success', 'info', 'warning', 'meta'] as const;
|
|
29
29
|
const COLOR_VALUE = /^(#[0-9a-f]{3}|#[0-9a-f]{6}|#[0-9a-f]{8})$/i;
|
|
@@ -143,24 +143,28 @@ describe('color math', () => {
|
|
|
143
143
|
|
|
144
144
|
describe('terminal palette', () => {
|
|
145
145
|
test('follows the active theme rather than a fixed light/dark pair', () => {
|
|
146
|
-
const nord =
|
|
147
|
-
const paper =
|
|
148
|
-
|
|
146
|
+
const nord = getTerminalTheme('nord-dark');
|
|
147
|
+
const paper = getTerminalTheme('paper');
|
|
148
|
+
// No surface of its own: the terminal paints nothing behind the cells, so
|
|
149
|
+
// the panel's chrome (and the glass plane under it) shows through.
|
|
150
|
+
expect(nord.background).toBe('transparent');
|
|
151
|
+
expect(paper.background).toBe('transparent');
|
|
149
152
|
expect(nord.foreground).toBe('#E5E9F0');
|
|
150
|
-
expect(paper.background).toBe('#f4f1ea');
|
|
151
153
|
expect(paper.foreground).toBe('#141310');
|
|
152
154
|
});
|
|
153
155
|
|
|
154
|
-
test('emits literal colors —
|
|
156
|
+
test('emits literal colors — the canvas cannot parse color-mix()', () => {
|
|
155
157
|
for (const theme of THEMES) {
|
|
156
|
-
for (const value of Object.values(
|
|
157
|
-
|
|
158
|
+
for (const value of Object.values(getTerminalTheme(theme.id))) {
|
|
159
|
+
// `transparent` is a CSS keyword `fillStyle` does accept, and it is the
|
|
160
|
+
// only non-hex value the palette is allowed to carry.
|
|
161
|
+
expect(value).toMatch(value === 'transparent' ? /^transparent$/ : COLOR_VALUE);
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
164
|
});
|
|
161
165
|
|
|
162
166
|
test('takes its signal colors from the palette', () => {
|
|
163
|
-
const dracula =
|
|
167
|
+
const dracula = getTerminalTheme('dracula-dark');
|
|
164
168
|
expect(dracula.red).toBe('#FF5555');
|
|
165
169
|
expect(dracula.green).toBe('#50FA7B');
|
|
166
170
|
expect(dracula.yellow).toBe('#FFB86C');
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* Hex color arithmetic for the terminal palette.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
* as literal hex — a wrong blend is a wrong-looking terminal, and a wrong
|
|
9
|
+
* The terminal renderer cannot resolve `color-mix()`, so blends are computed
|
|
10
|
+
* here and handed over as literal hex — a wrong blend is a wrong-looking terminal, and a wrong
|
|
11
11
|
* fallback (returning a broken string instead of the base color) would blank a
|
|
12
12
|
* palette entry. The parser must handle all three spellings the ported palettes
|
|
13
13
|
* use (`#rgb`, `#rrggbb`, and 8-digit `#rrggbbaa`, including OpenChamber's
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* Hex color arithmetic for the places that cannot use CSS.
|
|
8
8
|
*
|
|
9
|
-
* `color-mix()` covers every blend inside the document, but
|
|
10
|
-
* colors
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* `color-mix()` covers every blend inside the document, but the terminal
|
|
10
|
+
* renderer takes only literal colors (it hands them to `ctx.fillStyle`, which
|
|
11
|
+
* does not resolve `color-mix()`), so the terminal palette has to be computed
|
|
12
|
+
* here and handed over as hex.
|
|
13
13
|
*
|
|
14
14
|
* The palette values are ported verbatim from OpenChamber and are therefore not
|
|
15
15
|
* uniform: `#FFF` (jetbrains-light) and 8-digit alpha (`#dbd7caee`,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* Why each case is risky:
|
|
12
12
|
*
|
|
13
|
-
* - `rgbaToHex` feeds
|
|
13
|
+
* - `rgbaToHex` feeds the terminal palette, which takes only literal hex. An
|
|
14
14
|
* out-of-range or unrounded channel emits `#ff0-10`, a color no consumer can
|
|
15
15
|
* parse, so clamping/rounding is pinned here.
|
|
16
16
|
* - `mixHex` composites the blend's own alpha. A palette that carries 8-digit
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, test } from 'bun:test';
|
|
7
|
+
import { terminalInputFrame } from '@/shared/lib/workspace/terminal/input';
|
|
8
|
+
|
|
9
|
+
describe('terminalInputFrame', () => {
|
|
10
|
+
test('keeps ordinary text on the text channel', () => {
|
|
11
|
+
expect(terminalInputFrame('echo ok\r')).toEqual({ text: 'echo ok\r' });
|
|
12
|
+
expect(terminalInputFrame('ả 漢')).toEqual({ text: 'ả 漢' });
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test('routes an X10 mouse report as latin-1 bytes, including values above 127', () => {
|
|
16
|
+
// ESC [ M, button 0, column 188 (+32 = 220), row 3 (+32 = 35).
|
|
17
|
+
const frame = terminalInputFrame('\x1b[M\x20\xdc\x23');
|
|
18
|
+
expect(frame.text).toBeUndefined();
|
|
19
|
+
expect([...(frame.bytes ?? [])]).toEqual([27, 91, 77, 32, 220, 35]);
|
|
20
|
+
expect(frame.bytes?.length).toBe(6);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('does not treat a truncated prefix as a mouse report', () => {
|
|
24
|
+
expect(terminalInputFrame('\x1b[M')).toEqual({ text: '\x1b[M' });
|
|
25
|
+
expect(terminalInputFrame('\x1b[M\x20')).toEqual({ text: '\x1b[M\x20' });
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Split one ghostty-web `onData` payload into the channel the PTY needs.
|
|
8
|
+
*
|
|
9
|
+
* ghostty-web has no `onBinary` (xterm's separate channel for non-UTF-8
|
|
10
|
+
* payloads). Its legacy X10 mouse report is built with `String.fromCharCode`
|
|
11
|
+
* from values up to 255, so `TextEncoder` would turn a 6-byte report into 7+
|
|
12
|
+
* bytes and the shell would receive the wrong sequence. SGR mouse reports are
|
|
13
|
+
* printable ASCII and stay on the text path.
|
|
14
|
+
*
|
|
15
|
+
* X10 is exactly `ESC [ M` followed by three bytes; a payload with that prefix
|
|
16
|
+
* is forwarded through the byte channel unchanged otherwise.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
const X10_MOUSE_PREFIX = '\x1b[M';
|
|
20
|
+
const X10_MOUSE_LENGTH = X10_MOUSE_PREFIX.length + 3;
|
|
21
|
+
|
|
22
|
+
export type TerminalInputFrame = { text: string; bytes?: undefined } | { text?: undefined; bytes: Uint8Array };
|
|
23
|
+
|
|
24
|
+
export function terminalInputFrame(data: string): TerminalInputFrame {
|
|
25
|
+
if (!data.startsWith(X10_MOUSE_PREFIX) || data.length < X10_MOUSE_LENGTH) {
|
|
26
|
+
return { text: data };
|
|
27
|
+
}
|
|
28
|
+
const bytes = new Uint8Array(data.length);
|
|
29
|
+
for (let index = 0; index < data.length; index += 1) {
|
|
30
|
+
bytes[index] = data.charCodeAt(index) & 0xff;
|
|
31
|
+
}
|
|
32
|
+
return { bytes };
|
|
33
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* The bytes the terminal key bar sends.
|
|
8
8
|
*
|
|
9
9
|
* Every expectation here is copied from xterm's own `evaluateKeyboardEvent`
|
|
10
|
-
* (
|
|
10
|
+
* (`Keyboard.ts`), because the shell cannot tell a
|
|
11
11
|
* bar button from a physical key: a sequence that merely looks plausible works
|
|
12
12
|
* in bash and breaks in vim. Three of those rules are the ones this file exists
|
|
13
13
|
* to pin — a modifier is a CSI PARAMETER and not an ESC prefix, application
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* A phone's soft keyboard has no Ctrl, no Alt, no arrows, no Esc and no `|`, so
|
|
10
10
|
* a shell on a phone is unusable without a strip of buttons that emit the raw
|
|
11
11
|
* bytes those keys would. Every sequence here is what xterm's own
|
|
12
|
-
* `evaluateKeyboardEvent` sends for the same physical key
|
|
13
|
-
*
|
|
12
|
+
* `evaluateKeyboardEvent` sends for the same physical key (xterm.js's
|
|
13
|
+
* `Keyboard.ts`) — the shell on the far end
|
|
14
14
|
* cannot tell the two apart, so a bar key that invented its own encoding would
|
|
15
15
|
* work in bash and break in vim.
|
|
16
16
|
*
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
* - Ctrl has no literal spelling: it folds a typed character into a control
|
|
24
24
|
* character (Ctrl+C is `0x03`), so a literal button keeps its own byte.
|
|
25
25
|
*
|
|
26
|
-
* There is deliberately no Cmd key. macOS reports it as `metaKey
|
|
27
|
-
*
|
|
28
|
-
* Cmd
|
|
29
|
-
*
|
|
30
|
-
*
|
|
26
|
+
* There is deliberately no Cmd key. macOS reports it as `metaKey`, and the
|
|
27
|
+
* renderer treats it as the host's modifier rather than the terminal's: a
|
|
28
|
+
* printable Cmd chord sends nothing, and Cmd+C / Cmd+V are its own copy and
|
|
29
|
+
* paste — which is why those are actions in `KeyBar.tsx` rather than bytes
|
|
30
|
+
* here.
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
export type TerminalModifier = 'ctrl' | 'alt';
|
package/src/shared/types/chat.ts
CHANGED
|
@@ -258,7 +258,7 @@ export interface QueuedMessage {
|
|
|
258
258
|
/** Trigger group that opened the composer autocomplete: `@` → mention, `/` → command. */
|
|
259
259
|
export type ComposerPickKind = 'mention' | 'command';
|
|
260
260
|
/** Origin of a pickable item: an `@` mention is an agent or a workspace file. */
|
|
261
|
-
export type ComposerPickSource = 'agent' | 'file' | 'command' | 'skill';
|
|
261
|
+
export type ComposerPickSource = 'agent' | 'harness' | 'file' | 'command' | 'skill';
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* Which part of a slash invocation the popup is completing. oh-my-pi splits
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One harness update, as a BACKGROUND job.
|
|
8
|
+
*
|
|
9
|
+
* The update used to run inside the POST that asked for it: the request held
|
|
10
|
+
* open for minutes, a reload forgot it, and the five-minute child timeout could
|
|
11
|
+
* kill `npm install -g` halfway through writing the package tree — a corrupt
|
|
12
|
+
* install that the dialog still reported as a failure it could retry. The run is
|
|
13
|
+
* now a detached worker (`update-worker.ts`) that owns its steps and writes this
|
|
14
|
+
* record to disk, so the request can answer immediately, the page can close, and
|
|
15
|
+
* the next open reads what actually happened.
|
|
16
|
+
*
|
|
17
|
+
* Stated once, here, because three places read it: the worker writes it, the
|
|
18
|
+
* route answers it, and the About card polls it.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { HarnessUpdateStep } from '@/shared/lib/harness/update-plan';
|
|
22
|
+
|
|
23
|
+
/** Where one step is in its life. `pending` exists on the record before the
|
|
24
|
+
* worker reaches it, so a reader sees the whole plan from the first poll. */
|
|
25
|
+
export type HarnessUpdateStepState = 'pending' | 'running' | 'ok' | 'failed';
|
|
26
|
+
|
|
27
|
+
/** A planned step plus what running it produced. */
|
|
28
|
+
export interface HarnessUpdateJobStep extends HarnessUpdateStep {
|
|
29
|
+
state: HarnessUpdateStepState;
|
|
30
|
+
/** Exit code, or null while it has not run (or was killed). */
|
|
31
|
+
code: number | null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface HarnessUpdateJob {
|
|
35
|
+
harness: string;
|
|
36
|
+
label: string;
|
|
37
|
+
startedAt: number;
|
|
38
|
+
/** Null while running: this is the field that says whether to poll. */
|
|
39
|
+
finishedAt: number | null;
|
|
40
|
+
/** The WORKER process, used to tell a run that is still alive from one that
|
|
41
|
+
* died without writing its result (a crash, a kill, a reboot). */
|
|
42
|
+
pid: number | null;
|
|
43
|
+
steps: HarnessUpdateJobStep[];
|
|
44
|
+
/** The tail of everything the commands printed. */
|
|
45
|
+
output: string;
|
|
46
|
+
/** Null while running; true/false once the worker has decided. */
|
|
47
|
+
ok: boolean | null;
|
|
48
|
+
/** The sentence the dialog shows. Null while running. */
|
|
49
|
+
message: string | null;
|
|
50
|
+
/** True once the SERVER applied the post-install side effects (forget the
|
|
51
|
+
* probe and CLI version caches, repoint the launch line). The worker cannot
|
|
52
|
+
* do those: they read the database, which the server owns. */
|
|
53
|
+
applied: boolean;
|
|
54
|
+
/** The launch command a successful install left behind, when it moved it. */
|
|
55
|
+
repointed: string | null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** What a step needs to run: the plan, and where the worker reads and writes. */
|
|
59
|
+
export interface HarnessUpdateJobSpec {
|
|
60
|
+
harness: string;
|
|
61
|
+
label: string;
|
|
62
|
+
steps: HarnessUpdateStep[];
|
|
63
|
+
statusPath: string;
|
|
64
|
+
lockPath: string;
|
|
65
|
+
}
|
|
@@ -153,6 +153,23 @@ export interface SpawnedSession {
|
|
|
153
153
|
harness?: string | null;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Outcome of a brand-new session spawn.
|
|
158
|
+
*
|
|
159
|
+
* A refusal travels with the server's own reason. The caller must report it —
|
|
160
|
+
* falling through to the simulated stream told the operator an agent had
|
|
161
|
+
* answered when nothing had started at all.
|
|
162
|
+
*/
|
|
163
|
+
export type SpawnPromptResult =
|
|
164
|
+
| { ok: true; session: SpawnedSession }
|
|
165
|
+
/**
|
|
166
|
+
* `code` is the server's own discriminator when there is one. `mock_mode`
|
|
167
|
+
* means there is no agent process to start ON PURPOSE — the caller must take
|
|
168
|
+
* the simulated path instead of reporting a failure the operator cannot act
|
|
169
|
+
* on. Every other failure is reported.
|
|
170
|
+
*/
|
|
171
|
+
| { ok: false; error: string; code?: string };
|
|
172
|
+
|
|
156
173
|
/** Command surface returned by useOmpAgent — the live omp session handle the
|
|
157
174
|
* chat timeline drives. */
|
|
158
175
|
export interface OmpAgentHandle extends OmpAgentState {
|
|
@@ -162,7 +179,7 @@ export interface OmpAgentHandle extends OmpAgentState {
|
|
|
162
179
|
* time and the server reconciles an idle session by respawning it. */
|
|
163
180
|
sendPrompt: (message: string, images?: AgentImage[], options?: { accessMode?: ApprovalMode }) => Promise<PromptDispatchResult>;
|
|
164
181
|
/** Spawn a brand-new omp session and send its first prompt; resolves with the
|
|
165
|
-
* adopted session
|
|
182
|
+
* adopted session or the server's refusal reason. */
|
|
166
183
|
sendNewPrompt: (
|
|
167
184
|
message: string,
|
|
168
185
|
cwd: string,
|
|
@@ -172,7 +189,7 @@ export interface OmpAgentHandle extends OmpAgentState {
|
|
|
172
189
|
* armed goal is started, so the prompt IS its first turn. Resolves true
|
|
173
190
|
* when it consumed the prompt (an interview renders its own). */
|
|
174
191
|
beforePrompt?: (sessionId: string) => Promise<boolean>,
|
|
175
|
-
) => Promise<
|
|
192
|
+
) => Promise<SpawnPromptResult>;
|
|
176
193
|
/** Steer the running agent: deliver the message INTO the turn in flight
|
|
177
194
|
* (omp's `steer` RPC). The run continues; the model sees the message inside
|
|
178
195
|
* the same turn and answers it there.
|
|
@@ -20,6 +20,10 @@ export interface SessionItemData {
|
|
|
20
20
|
hasArrow?: boolean;
|
|
21
21
|
hasSubagents?: boolean;
|
|
22
22
|
subagentCount?: number;
|
|
23
|
+
/** The session's parent in the sidebar tree. A fork has no parent. */
|
|
24
|
+
parentSessionId?: string;
|
|
25
|
+
/** Direct children; the client uses it to decide whether to draw a chevron. */
|
|
26
|
+
childSessionCount?: number;
|
|
23
27
|
/** Server-tracked stream state: `stream` while a run is in flight, then a
|
|
24
28
|
* one-shot `finish`/`abort` badge cleared when the session opens. */
|
|
25
29
|
streamStatus?: 'stream' | 'finish' | 'abort';
|
|
@@ -41,12 +41,16 @@ const forkOnResume = process.env.FAKE_OMP_FORK_ON_RESUME === '1';
|
|
|
41
41
|
* fake is asked to fork, which is what omp 18.10.0 does for a moved session. */
|
|
42
42
|
const requestedId = resume ? (resume.split('/').pop() ?? '').replace(/\.jsonl$/, '') : '';
|
|
43
43
|
const sessionId = forkOnResume && resume ? crypto.randomUUID() : requestedId || crypto.randomUUID();
|
|
44
|
+
const sessionSubdir = process.env.FAKE_OMP_SESSION_SUBDIR ?? '';
|
|
44
45
|
const sessionFile = forkOnResume && resume
|
|
45
46
|
? join(agentDir, 'sessions', `--forked--`, `${sessionId}.jsonl`)
|
|
46
|
-
: resume ?? join(agentDir, 'sessions', `${sessionId}.jsonl`);
|
|
47
|
+
: resume ?? join(agentDir, 'sessions', sessionSubdir, `${sessionId}.jsonl`);
|
|
47
48
|
|
|
48
49
|
mkdirSync(dirname(sessionFile), { recursive: true });
|
|
49
|
-
writeFileSync(
|
|
50
|
+
writeFileSync(
|
|
51
|
+
sessionFile,
|
|
52
|
+
`${JSON.stringify({ type: 'session', id: sessionId, cwd: process.cwd(), timestamp: new Date().toISOString() })}\n`,
|
|
53
|
+
);
|
|
50
54
|
|
|
51
55
|
const forkLog = process.env.FAKE_OMP_FORK_LOG;
|
|
52
56
|
if (forkLog) {
|
|
@@ -134,6 +138,16 @@ for (;;) {
|
|
|
134
138
|
respond(id, String(frame.type), {});
|
|
135
139
|
break;
|
|
136
140
|
case 'prompt':
|
|
141
|
+
if (process.env.FAKE_OMP_PROMPT_LOG) {
|
|
142
|
+
try {
|
|
143
|
+
appendFileSync(
|
|
144
|
+
process.env.FAKE_OMP_PROMPT_LOG,
|
|
145
|
+
`${JSON.stringify({ sessionId, message: String(frame.message ?? '') })}\n`,
|
|
146
|
+
);
|
|
147
|
+
} catch {
|
|
148
|
+
// Recording is a test convenience; never let it break the child.
|
|
149
|
+
}
|
|
150
|
+
}
|
|
137
151
|
respond(id, 'prompt', { agentInvoked: true });
|
|
138
152
|
write({ type: 'agent_start' });
|
|
139
153
|
write({ type: 'agent_end', isTerminal: true });
|
|
@@ -82,6 +82,17 @@ export function mountHarnessTable(
|
|
|
82
82
|
versions: HarnessVersionRow[],
|
|
83
83
|
onOpen?: (id: string) => void,
|
|
84
84
|
onUpdate?: (id: string) => Promise<string | null>,
|
|
85
|
+
/**
|
|
86
|
+
* The in-flight update state and its record. Kept apart from the positional
|
|
87
|
+
* arguments because only the log cases need it, and the earlier callers are
|
|
88
|
+
* about the row's layout.
|
|
89
|
+
*/
|
|
90
|
+
state?: {
|
|
91
|
+
updating?: string | null;
|
|
92
|
+
progress?: string | null;
|
|
93
|
+
log?: { harness: string; message: string | null } | null;
|
|
94
|
+
onOpenLog?: () => void;
|
|
95
|
+
},
|
|
85
96
|
): HTMLElement {
|
|
86
97
|
act(() =>
|
|
87
98
|
render(
|
|
@@ -90,7 +101,10 @@ export function mountHarnessTable(
|
|
|
90
101
|
versions,
|
|
91
102
|
onOpenHarness: onOpen ?? (() => {}),
|
|
92
103
|
onUpdate: onUpdate ?? (async () => null),
|
|
93
|
-
updating: null,
|
|
104
|
+
updating: state?.updating ?? null,
|
|
105
|
+
progress: state?.progress ?? null,
|
|
106
|
+
log: state?.log ?? null,
|
|
107
|
+
onOpenLog: state?.onOpenLog,
|
|
94
108
|
}),
|
|
95
109
|
container,
|
|
96
110
|
),
|