@kabmo-labs/kabmo 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +440 -436
- package/dist/client/static/js/{index-ga8cbpt4.js → index-95b3n20k.js} +945 -945
- package/dist/client/static/js/index-p2yw9ywf.css +1 -0
- package/package.json +1 -1
- package/src/client/components/common/session-actions-menu/index.tsx +38 -12
- package/src/client/components/common/session-branch/BranchGuides.tsx +93 -0
- package/src/client/components/common/session-branch/SubagentRow.tsx +77 -0
- package/src/client/components/common/session-branch/index.tsx +169 -0
- package/src/client/components/common/session-branch/session-branch.test.tsx +240 -0
- package/src/client/components/common/session-branch/style.ts +29 -0
- package/src/client/components/common/session-row/StatusSlot.tsx +15 -3
- package/src/client/components/common/session-row/index.tsx +24 -25
- package/src/client/components/common/session-row/session-row.test.tsx +11 -0
- package/src/client/components/common/session-state-provider/index.tsx +1 -1
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +64 -68
- package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -3
- package/src/client/components/layout/session-sidebar/SessionItem.test.ts +25 -2
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +33 -30
- package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +35 -225
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +36 -16
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +11 -3
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +13 -4
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +28 -13
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +59 -57
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +57 -61
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +33 -30
- package/src/client/components/settings/Sidebar.tsx +1 -1
- package/src/client/components/settings/categories/NotificationSettings.test.tsx +92 -0
- package/src/client/components/settings/categories/NotificationSettings.tsx +112 -2
- package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +94 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +31 -5
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +28 -39
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +7 -5
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +10 -0
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +15 -1
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +85 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +84 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +10 -21
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +115 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
- package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
- package/src/client/hooks/chat/composer/items.test.ts +19 -0
- package/src/client/hooks/chat/omp/folder-auto-expand.ts +1 -1
- package/src/client/hooks/chat/omp/pending-adoption.ts +51 -0
- package/src/client/hooks/chat/omp/pending-child.test.ts +73 -0
- package/src/client/hooks/chat/omp/pending-entry.ts +59 -0
- package/src/client/hooks/chat/omp/pending-rows.ts +6 -2
- package/src/client/hooks/chat/omp/pending-sessions.test.ts +1 -2
- package/src/client/hooks/chat/omp/pending-sessions.ts +45 -69
- package/src/client/hooks/chat/omp/pending-waiting.ts +1 -1
- package/src/client/hooks/chat/omp/run-switch.ts +1 -1
- package/src/client/hooks/chat/omp/session-list.tsx +4 -0
- package/src/client/hooks/chat/subagents/roster.ts +122 -0
- package/src/client/hooks/chat/timeline/child-spawn.test.ts +55 -0
- package/src/client/hooks/chat/timeline/child-spawn.ts +45 -0
- package/src/client/hooks/chat/timeline/fork-request.test.ts +54 -0
- package/src/client/hooks/chat/timeline/fork-request.ts +43 -0
- package/src/client/hooks/chat/timeline/mode-availability.test.ts +1 -1
- package/src/client/hooks/chat/timeline/mode-availability.ts +33 -0
- package/src/client/hooks/chat/timeline/mode-markers.ts +7 -1
- package/src/client/hooks/chat/timeline/mode-post.ts +15 -3
- package/src/client/hooks/chat/timeline/modes-contract.ts +9 -4
- package/src/client/hooks/chat/timeline/modes.test.ts +56 -18
- package/src/client/hooks/chat/timeline/modes.ts +42 -29
- package/src/client/hooks/chat/timeline/pending-branch.ts +205 -0
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +253 -0
- package/src/client/hooks/chat/timeline/send.ts +17 -103
- package/src/client/hooks/chat/timeline/session-harness.ts +6 -0
- package/src/client/hooks/chat/timeline/stop-with-queue.ts +42 -0
- package/src/client/hooks/chat/timeline/use-fork-session.ts +40 -31
- package/src/client/hooks/models/use-harness-update.test.ts +137 -44
- package/src/client/hooks/models/use-harness-update.ts +133 -85
- package/src/client/hooks/ui/input-required-alert.ts +12 -5
- package/src/client/hooks/ui/notifications.ts +45 -0
- package/src/client/hooks/ui/run-outcome-alert.ts +48 -0
- package/src/client/hooks/workspace/expanded-sessions.ts +36 -7
- package/src/client/lib/native/open-session.ts +33 -0
- package/src/client/lib/notifications/os.test.ts +125 -0
- package/src/client/lib/notifications/os.ts +130 -0
- package/src/client/lib/plugins/sidebar-bridge.ts +2 -20
- package/src/client/lib/router/open-session.test.ts +75 -0
- package/src/client/lib/router/open-session.ts +34 -0
- package/src/client/lib/signals.ts +5 -1
- package/src/client/main.tsx +6 -0
- package/src/server/lib/db/schema.ts +1 -0
- package/src/server/lib/harness/acp/calls.ts +15 -1
- package/src/server/lib/harness/acp/client-capabilities.test.ts +55 -0
- package/src/server/lib/harness/acp/client-capabilities.ts +61 -0
- package/src/server/lib/harness/acp/client-fs.test.ts +135 -0
- package/src/server/lib/harness/acp/client-fs.ts +131 -0
- package/src/server/lib/harness/acp/client-initialize.test.ts +70 -0
- package/src/server/lib/harness/acp/client-initialize.ts +84 -0
- package/src/server/lib/harness/acp/client.ts +31 -21
- package/src/server/lib/harness/acp/commands.test.ts +5 -5
- package/src/server/lib/harness/acp/commands.ts +14 -2
- package/src/server/lib/harness/acp/frames-timing.test.ts +68 -0
- package/src/server/lib/harness/acp/frames-v2.test.ts +85 -0
- package/src/server/lib/harness/acp/frames.ts +71 -158
- package/src/server/lib/harness/acp/mapper.test.ts +40 -0
- package/src/server/lib/harness/acp/mapper.ts +12 -0
- package/src/server/lib/harness/acp/permissions.ts +6 -0
- package/src/server/lib/harness/acp/protocol.ts +41 -2
- package/src/server/lib/harness/acp/session-facts.ts +1 -1
- package/src/server/lib/harness/acp/session-handshake.test.ts +90 -1
- package/src/server/lib/harness/acp/session-handshake.ts +83 -6
- package/src/server/lib/harness/acp/session-idle.ts +7 -6
- package/src/server/lib/harness/acp/session-notifications.ts +41 -2
- package/src/server/lib/harness/acp/session-observers.test.ts +63 -0
- package/src/server/lib/harness/acp/session-permissions.test.ts +29 -0
- package/src/server/lib/harness/acp/session-permissions.ts +36 -0
- package/src/server/lib/harness/acp/session-requests.test.ts +92 -0
- package/src/server/lib/harness/acp/session-requests.ts +48 -6
- package/src/server/lib/harness/acp/session-turns.ts +8 -3
- package/src/server/lib/harness/acp/session-usage.ts +4 -0
- package/src/server/lib/harness/acp/session-web-state.ts +30 -2
- package/src/server/lib/harness/acp/session.test-util.ts +19 -1
- package/src/server/lib/harness/acp/session.ts +60 -60
- package/src/server/lib/harness/acp/tool-calls.ts +223 -0
- package/src/server/lib/harness/acp/turn.test.ts +102 -0
- package/src/server/lib/harness/acp/turn.ts +81 -6
- package/src/server/lib/harness/acp/v2.test.ts +144 -0
- package/src/server/lib/harness/acp/v2.ts +220 -0
- package/src/server/lib/harness/acp/verbs.ts +46 -6
- package/src/server/lib/harness/launch.test.ts +25 -0
- package/src/server/lib/harness/launch.ts +21 -9
- package/src/server/lib/harness/session.ts +3 -0
- package/src/server/lib/harness/update-job-store.test.ts +37 -12
- package/src/server/lib/harness/update-job-store.ts +22 -16
- package/src/server/lib/harness/update-job.server.ts +66 -175
- package/src/server/lib/harness/update-queue.server.ts +292 -0
- package/src/server/lib/harness/update-queue.test.ts +265 -0
- package/src/server/lib/harness/update-spawn.server.ts +96 -0
- package/src/server/lib/harness/update-worker.ts +8 -3
- package/src/server/lib/lifecycle/after-listen.ts +9 -0
- package/src/server/lib/lifecycle/paths.ts +14 -9
- package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
- package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
- package/src/server/lib/omp/rpc/terminal-settle.ts +5 -1
- package/src/server/lib/omp/session/delete-flow.server.ts +1 -0
- package/src/server/lib/omp/session/sidebar-data.server.ts +10 -12
- package/src/server/lib/sessions/fork.server.test.ts +68 -0
- package/src/server/lib/sessions/fork.server.ts +31 -6
- package/src/server/lib/sessions/spawn.server.test.ts +41 -0
- package/src/server/lib/sessions/spawn.server.ts +27 -2
- package/src/server/routes/agent/harness-command.ts +6 -5
- package/src/server/routes/chat/stream.ts +7 -2
- package/src/server/routes/harness/update-status.ts +18 -12
- package/src/server/routes/harness/update.test.ts +53 -16
- package/src/server/routes/harness/update.ts +13 -8
- package/src/server/routes/sessions/body-readers.ts +43 -0
- package/src/server/routes/sessions/fork.ts +19 -4
- package/src/server/routes/sessions/routes.test.ts +1 -2
- package/src/server/routes/sessions/session.ts +19 -0
- package/src/server/routes/sessions/spawn.ts +16 -13
- package/src/shared/lib/chat/omp/agent-events.ts +11 -0
- package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
- package/src/shared/lib/harness/mode-signal.ts +20 -0
- package/src/shared/lib/harness/session-modes.ts +24 -0
- package/src/shared/lib/harness/update-job.ts +53 -6
- package/src/shared/lib/icons/tint-hues.generated.ts +34 -34
- package/src/shared/lib/notifications/outcomes.test.ts +96 -0
- package/src/shared/lib/notifications/outcomes.ts +64 -0
- package/src/shared/lib/notifications/settings.test.ts +49 -0
- package/src/shared/lib/notifications/settings.ts +34 -0
- package/src/shared/lib/omp/session/default-title.ts +5 -4
- package/src/shared/lib/omp/session/prewarm-misc.test.ts +3 -2
- package/src/shared/lib/omp/session/schema-migrations.ts +4 -0
- package/src/shared/lib/omp/session/stream-state.server.test.ts +19 -0
- package/src/shared/lib/omp/session/stream-state.server.ts +24 -4
- package/src/shared/lib/settings/defaults.ts +3 -0
- package/src/shared/types/harness-update.ts +24 -0
- package/src/shared/types/realtime.ts +2 -0
- package/src/shared/types/settings/state.ts +10 -0
- package/src/shared/types/workspace.ts +4 -0
- package/src/test-support/harness-table.test-util.ts +25 -9
- package/dist/client/static/js/index-bc9aa4mx.css +0 -1
- package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +0 -113
- package/src/client/components/common/subagent-list/index.tsx +0 -165
- package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +0 -66
- package/src/client/hooks/workspace/child-expansion.ts +0 -33
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Two harnesses, one install at a time.
|
|
8
|
+
*
|
|
9
|
+
* The press for a second harness used to be refused outright while the first
|
|
10
|
+
* installed — "update these two" was impossible without waiting and pressing
|
|
11
|
+
* again. It is now ACCEPTED as a waiting record, and this suite pins the three
|
|
12
|
+
* properties that make that safe rather than a second concurrent `npm install -g`
|
|
13
|
+
* over the same prefix:
|
|
14
|
+
*
|
|
15
|
+
* - the refusal is per HARNESS (the same harness is still a `409`);
|
|
16
|
+
* - a press while another installs W R I T E S a waiting record and starts
|
|
17
|
+
* nothing;
|
|
18
|
+
* - the queue starts the OLDEST waiting record, and only when nothing runs.
|
|
19
|
+
*
|
|
20
|
+
* The last case spawns the real worker, because that is the thing being tested:
|
|
21
|
+
* a detached install nobody awaits finishing on its own.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
25
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
26
|
+
import { tmpdir } from 'node:os';
|
|
27
|
+
import { join } from 'node:path';
|
|
28
|
+
import {
|
|
29
|
+
nextQueuedJob,
|
|
30
|
+
pumpUpdateQueue,
|
|
31
|
+
readAllUpdateJobs,
|
|
32
|
+
} from '@/server/lib/harness/update-queue.server';
|
|
33
|
+
import { startHarnessUpdateJob, unfinishedUpdateJob } from '@/server/lib/harness/update-job.server';
|
|
34
|
+
import { readUpdateJob, writeUpdateJob } from '@/server/lib/harness/update-job-store';
|
|
35
|
+
import { getHarnessUpdateStatusPath } from '@/server/lib/lifecycle/paths';
|
|
36
|
+
import { jobQueued, jobRunning } from '@/shared/lib/harness/update-job';
|
|
37
|
+
import { UNPROBED_CAPABILITIES, type HarnessProbe } from '@/server/lib/harness/capabilities';
|
|
38
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
39
|
+
import { describePosix } from '@/test-support/platform';
|
|
40
|
+
import type { HarnessUpdateStep } from '@/shared/lib/harness/update-plan';
|
|
41
|
+
import type { HarnessUpdateJob } from '@/shared/types/harness-update';
|
|
42
|
+
|
|
43
|
+
let dir = '';
|
|
44
|
+
let originalDataDir: string | undefined;
|
|
45
|
+
|
|
46
|
+
beforeEach(async () => {
|
|
47
|
+
originalDataDir = Bun.env.KABMO_DATA_DIR;
|
|
48
|
+
dir = mkdtempSync(join(tmpdir(), 'kabmo-update-queue-'));
|
|
49
|
+
Bun.env.KABMO_DATA_DIR = dir;
|
|
50
|
+
// The queue applies a finished run's side effects, and those read the
|
|
51
|
+
// harness config from the database: never the developer's own file.
|
|
52
|
+
await isolateDb();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
afterEach(async () => {
|
|
56
|
+
await releaseDb();
|
|
57
|
+
if (originalDataDir === undefined) delete Bun.env.KABMO_DATA_DIR;
|
|
58
|
+
else Bun.env.KABMO_DATA_DIR = originalDataDir;
|
|
59
|
+
rmSync(dir, { recursive: true, force: true });
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function job(overrides: Partial<HarnessUpdateJob> = {}): HarnessUpdateJob {
|
|
63
|
+
return {
|
|
64
|
+
harness: 'claude',
|
|
65
|
+
label: 'claude',
|
|
66
|
+
startedAt: Date.now(),
|
|
67
|
+
finishedAt: null,
|
|
68
|
+
queuedAt: null,
|
|
69
|
+
pid: process.pid,
|
|
70
|
+
steps: [{ part: 'adapter', command: 'npm install -g x', argv: ['npm', 'install', '-g', 'x'], state: 'pending', code: null }],
|
|
71
|
+
output: '',
|
|
72
|
+
ok: null,
|
|
73
|
+
message: null,
|
|
74
|
+
applied: false,
|
|
75
|
+
repointed: null,
|
|
76
|
+
...overrides,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** A probe answer, without spawning an agent. */
|
|
81
|
+
function probeAnswer(harness: string, agentVersion: string | null): HarnessProbe {
|
|
82
|
+
return {
|
|
83
|
+
harness,
|
|
84
|
+
capabilities: { ...UNPROBED_CAPABILITIES, ...(agentVersion ? { agentVersion } : {}) },
|
|
85
|
+
models: [],
|
|
86
|
+
thinking: [],
|
|
87
|
+
modes: [],
|
|
88
|
+
probedAt: Date.now(),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Wait for a record to reach a condition. No external process is involved, so
|
|
93
|
+
* this settles in milliseconds — it exists because the probe write is the LAST
|
|
94
|
+
* step of a background task the queue deliberately does not await. */
|
|
95
|
+
async function until(
|
|
96
|
+
harness: string,
|
|
97
|
+
condition: (job: HarnessUpdateJob | null) => boolean,
|
|
98
|
+
): Promise<HarnessUpdateJob | null> {
|
|
99
|
+
let job = await readUpdateJob(getHarnessUpdateStatusPath(harness));
|
|
100
|
+
for (let attempt = 0; attempt < 200 && !condition(job); attempt += 1) {
|
|
101
|
+
await Bun.sleep(5);
|
|
102
|
+
job = await readUpdateJob(getHarnessUpdateStatusPath(harness));
|
|
103
|
+
}
|
|
104
|
+
return job;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** A step that does nothing, for the cases that only care about the handover. */
|
|
108
|
+
function noopStep(): HarnessUpdateStep {
|
|
109
|
+
return {
|
|
110
|
+
part: 'adapter',
|
|
111
|
+
command: `${process.execPath} -e process.exit(0)`,
|
|
112
|
+
argv: [process.execPath, '-e', 'process.exit(0)'],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
describe('the refusal is per harness', () => {
|
|
117
|
+
test('the harness that is installing is refused, another one is accepted', async () => {
|
|
118
|
+
await writeUpdateJob(job(), getHarnessUpdateStatusPath('claude'));
|
|
119
|
+
|
|
120
|
+
expect((await unfinishedUpdateJob('claude'))?.harness).toBe('claude');
|
|
121
|
+
// Null is what makes the route accept a press for codex instead of a 409.
|
|
122
|
+
expect(await unfinishedUpdateJob('codex')).toBeNull();
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('a press while another harness installs waits, and starts nothing', async () => {
|
|
126
|
+
await writeUpdateJob(job(), getHarnessUpdateStatusPath('claude'));
|
|
127
|
+
|
|
128
|
+
const waiting = await startHarnessUpdateJob('codex', 'codex', [noopStep()]);
|
|
129
|
+
|
|
130
|
+
expect(jobQueued(waiting)).toBe(true);
|
|
131
|
+
expect(waiting.pid).toBeNull();
|
|
132
|
+
expect(waiting.queuedAt).toBeNumber();
|
|
133
|
+
// The record is on disk, because the dialog reads it from there.
|
|
134
|
+
const stored = await readUpdateJob(getHarnessUpdateStatusPath('codex'));
|
|
135
|
+
expect(jobQueued(stored)).toBe(true);
|
|
136
|
+
// …and the install in front of it was not disturbed.
|
|
137
|
+
const claude = await readUpdateJob(getHarnessUpdateStatusPath('claude'));
|
|
138
|
+
expect(jobRunning(claude)).toBe(true);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('the post-install probe', () => {
|
|
143
|
+
test('a settled run reports `pending` while the agent is being asked, then `done`', async () => {
|
|
144
|
+
const { promise, resolve } = Promise.withResolvers<HarnessProbe>();
|
|
145
|
+
let asked = 0;
|
|
146
|
+
await writeUpdateJob(job({
|
|
147
|
+
pid: null,
|
|
148
|
+
finishedAt: Date.now(),
|
|
149
|
+
ok: true,
|
|
150
|
+
applied: false,
|
|
151
|
+
message: 'claude updated (adapter)',
|
|
152
|
+
steps: [noopStep()].map((step) => ({ ...step, state: 'ok', code: 0 })),
|
|
153
|
+
}), getHarnessUpdateStatusPath('claude'));
|
|
154
|
+
|
|
155
|
+
const jobs = await pumpUpdateQueue({
|
|
156
|
+
probe: () => { asked += 1; return promise; },
|
|
157
|
+
});
|
|
158
|
+
// The install's own report is not held up by the probe: the record answers
|
|
159
|
+
// immediately, with the probe marked so a dialog keeps polling.
|
|
160
|
+
expect(jobs.find((entry) => entry.harness === 'claude')?.probe).toBe('pending');
|
|
161
|
+
expect(asked).toBe(1);
|
|
162
|
+
|
|
163
|
+
resolve(probeAnswer('claude', '0.103.0'));
|
|
164
|
+
const done = await until('claude', (job) => job?.probe === 'done');
|
|
165
|
+
expect(done?.probe).toBe('done');
|
|
166
|
+
expect(done?.message).toContain('it now reports 0.103.0');
|
|
167
|
+
// Asked once, even though every pass re-kicks a record that still says
|
|
168
|
+
// `pending`: a probe is an agent process, not a cheap read.
|
|
169
|
+
await pumpUpdateQueue({ probe: () => { asked += 1; return promise; } });
|
|
170
|
+
expect(asked).toBe(1);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('a FAILED run is not probed, and says nothing about a version', async () => {
|
|
174
|
+
await writeUpdateJob(job({
|
|
175
|
+
pid: null,
|
|
176
|
+
finishedAt: Date.now(),
|
|
177
|
+
ok: false,
|
|
178
|
+
applied: false,
|
|
179
|
+
message: 'claude update failed (exit 1)',
|
|
180
|
+
steps: [noopStep()].map((step) => ({ ...step, state: 'failed', code: 1 })),
|
|
181
|
+
}), getHarnessUpdateStatusPath('claude'));
|
|
182
|
+
|
|
183
|
+
let asked = 0;
|
|
184
|
+
await pumpUpdateQueue({ probe: async (id) => { asked += 1; return probeAnswer(id, null); } });
|
|
185
|
+
const record = await readUpdateJob(getHarnessUpdateStatusPath('claude'));
|
|
186
|
+
expect(asked).toBe(0);
|
|
187
|
+
expect(record?.probe).toBeNull();
|
|
188
|
+
expect(record?.message).toBe('claude update failed (exit 1)');
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
describe('the queue', () => {
|
|
193
|
+
test('the oldest waiting record goes next', () => {
|
|
194
|
+
const older = job({ harness: 'codex', label: 'codex', pid: null, queuedAt: 1_000 });
|
|
195
|
+
const newer = job({ harness: 'pi', label: 'pi', pid: null, queuedAt: 2_000 });
|
|
196
|
+
const done = job({ harness: 'opencode', label: 'opencode', pid: null, finishedAt: Date.now() });
|
|
197
|
+
|
|
198
|
+
expect(nextQueuedJob([newer, done, older])?.harness).toBe('codex');
|
|
199
|
+
expect(nextQueuedJob([done])).toBeNull();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test('records are read per harness: one file each, nothing shared', async () => {
|
|
203
|
+
await writeUpdateJob(job(), getHarnessUpdateStatusPath('claude'));
|
|
204
|
+
await writeUpdateJob(job({ harness: 'codex', label: 'codex', pid: null, queuedAt: Date.now() }), getHarnessUpdateStatusPath('codex'));
|
|
205
|
+
|
|
206
|
+
const jobs = await readAllUpdateJobs();
|
|
207
|
+
expect(jobs.map((entry) => entry.harness).sort()).toEqual(['claude', 'codex']);
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describePosix('starting the waiting run once the install ahead settles', () => {
|
|
211
|
+
test('a waiting codex run is handed to a worker after claude finishes', async () => {
|
|
212
|
+
// Claude's run is over; its record has not been finalized yet.
|
|
213
|
+
await writeUpdateJob(job({
|
|
214
|
+
pid: null,
|
|
215
|
+
finishedAt: Date.now(),
|
|
216
|
+
ok: true,
|
|
217
|
+
applied: true,
|
|
218
|
+
message: 'claude updated (adapter)',
|
|
219
|
+
}), getHarnessUpdateStatusPath('claude'));
|
|
220
|
+
await writeUpdateJob(
|
|
221
|
+
job({
|
|
222
|
+
harness: 'codex',
|
|
223
|
+
label: 'codex',
|
|
224
|
+
pid: null,
|
|
225
|
+
queuedAt: Date.now(),
|
|
226
|
+
steps: [noopStep()].map((step) => ({ ...step, state: 'pending', code: null })),
|
|
227
|
+
}),
|
|
228
|
+
getHarnessUpdateStatusPath('codex'),
|
|
229
|
+
);
|
|
230
|
+
|
|
231
|
+
const probed: string[] = [];
|
|
232
|
+
const jobs = await pumpUpdateQueue({
|
|
233
|
+
probe: async (id) => { probed.push(id); return probeAnswer(id, '0.2.0'); },
|
|
234
|
+
});
|
|
235
|
+
const codex = jobs.find((entry) => entry.harness === 'codex');
|
|
236
|
+
// Handed over: a worker owns it now, so it is no longer waiting.
|
|
237
|
+
expect(codex?.queuedAt).toBeNull();
|
|
238
|
+
expect(codex?.pid).toBeNumber();
|
|
239
|
+
|
|
240
|
+
// The worker is a DETACHED process with no handle to await, so the only
|
|
241
|
+
// way to observe the install finishing is its own record. Bounded, and the
|
|
242
|
+
// step is a no-op that exits immediately.
|
|
243
|
+
let settled: HarnessUpdateJob | null = null;
|
|
244
|
+
for (let attempt = 0; attempt < 200; attempt += 1) {
|
|
245
|
+
settled = await readUpdateJob(getHarnessUpdateStatusPath('codex'));
|
|
246
|
+
if (settled?.finishedAt != null) break;
|
|
247
|
+
await Bun.sleep(25);
|
|
248
|
+
}
|
|
249
|
+
expect(settled?.finishedAt).not.toBeNull();
|
|
250
|
+
expect(settled?.ok).toBe(true);
|
|
251
|
+
|
|
252
|
+
// The worker finishing is not the queue moving: the next pass — the
|
|
253
|
+
// ticker in production — applies the side effects and probes the binary it
|
|
254
|
+
// just installed. A successful run is not finished with the READER until
|
|
255
|
+
// that answer lands, or the row keeps quoting the replaced version.
|
|
256
|
+
await pumpUpdateQueue({ probe: async (id) => { probed.push(id); return probeAnswer(id, '0.2.0'); } });
|
|
257
|
+
const afterProbe = await until('codex', (job) => job?.probe === 'done');
|
|
258
|
+
expect(probed).toEqual(['codex']);
|
|
259
|
+
expect(afterProbe?.message).toContain('it now reports 0.2.0');
|
|
260
|
+
// Nothing is moving now, so one more pass applies what is left and stops
|
|
261
|
+
// the ticker the queue started — inside this test's isolated DB.
|
|
262
|
+
await pumpUpdateQueue({ probe: async (id) => probeAnswer(id, null) });
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Spawning the detached worker that installs one harness update, and returning
|
|
8
|
+
* the record it will fill.
|
|
9
|
+
*
|
|
10
|
+
* Its own module because two callers start a run and neither may own the other:
|
|
11
|
+
* the update route, when nothing else is installing, and the queue, when the run
|
|
12
|
+
* ahead of a waiting one has finished. Both go through here, so the record and
|
|
13
|
+
* the spec are written in the same order in both places:
|
|
14
|
+
*
|
|
15
|
+
* 1. the spec (what to run) — the worker reads it, never the record's steps;
|
|
16
|
+
* 2. the record with `pid: null` — a poll arriving in between sees "running"
|
|
17
|
+
* rather than "no update", and the start grace covers the gap;
|
|
18
|
+
* 3. the record with the pid, immediately after the spawn.
|
|
19
|
+
*
|
|
20
|
+
* The worker is DETACHED and never adopted: it has to survive a server exit.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { existsSync } from 'node:fs';
|
|
24
|
+
import { join } from 'node:path';
|
|
25
|
+
import { resolveBunBin } from '@/server/lib/lifecycle/bun';
|
|
26
|
+
import { packageDir } from '@/server/lib/fs/package-root';
|
|
27
|
+
import { getHarnessUpdateLockPath, getHarnessUpdateSpecPath, getHarnessUpdateStatusPath } from '@/server/lib/lifecycle/paths';
|
|
28
|
+
import { writeUpdateJob } from '@/server/lib/harness/update-job-store';
|
|
29
|
+
import type { HarnessUpdateJob, HarnessUpdateJobSpec } from '@/shared/types/harness-update';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Where the worker's source lives inside this package.
|
|
33
|
+
*
|
|
34
|
+
* Derived from the package root rather than `import.meta.dir`: in production the
|
|
35
|
+
* server runs the AOT bundle in `dist/client`, so this module's own directory is
|
|
36
|
+
* not the source tree. `src/` ships in the tarball (`package.json#files`), which
|
|
37
|
+
* is what makes the path valid in an installed copy too.
|
|
38
|
+
*/
|
|
39
|
+
function workerPath(): string {
|
|
40
|
+
return join(packageDir(), 'src', 'server', 'lib', 'harness', 'update-worker.ts');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Start the worker for `job`'s steps and return the record it will fill.
|
|
45
|
+
*
|
|
46
|
+
* `job` may be a record that was WAITING (the queue hands it over): the run's
|
|
47
|
+
* clock starts here, and `queuedAt` is cleared because the wait is over.
|
|
48
|
+
*/
|
|
49
|
+
export async function spawnUpdateWorker(job: HarnessUpdateJob): Promise<HarnessUpdateJob> {
|
|
50
|
+
const worker = workerPath();
|
|
51
|
+
if (!existsSync(worker)) {
|
|
52
|
+
throw new Error(`The update worker is missing from ${worker} — reinstall Kabmo to restore it`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const spec: HarnessUpdateJobSpec = {
|
|
56
|
+
harness: job.harness,
|
|
57
|
+
label: job.label,
|
|
58
|
+
steps: job.steps,
|
|
59
|
+
statusPath: getHarnessUpdateStatusPath(job.harness),
|
|
60
|
+
lockPath: getHarnessUpdateLockPath(),
|
|
61
|
+
};
|
|
62
|
+
await Bun.write(getHarnessUpdateSpecPath(job.harness), JSON.stringify(spec, null, 2));
|
|
63
|
+
|
|
64
|
+
const running: HarnessUpdateJob = {
|
|
65
|
+
...job,
|
|
66
|
+
startedAt: Date.now(),
|
|
67
|
+
finishedAt: null,
|
|
68
|
+
pid: null,
|
|
69
|
+
queuedAt: null,
|
|
70
|
+
steps: job.steps.map((step) => ({ ...step, state: 'pending', code: null })),
|
|
71
|
+
output: '',
|
|
72
|
+
ok: null,
|
|
73
|
+
message: null,
|
|
74
|
+
applied: false,
|
|
75
|
+
repointed: null,
|
|
76
|
+
};
|
|
77
|
+
await writeUpdateJob(running, spec.statusPath);
|
|
78
|
+
|
|
79
|
+
const child = Bun.spawn({
|
|
80
|
+
cmd: [resolveBunBin(), worker, getHarnessUpdateSpecPath(job.harness)],
|
|
81
|
+
cwd: packageDir(),
|
|
82
|
+
stdin: 'ignore',
|
|
83
|
+
// Nothing is read back from stdio: the worker reports through the record, so
|
|
84
|
+
// the install cannot be wedged by a parent that stopped draining a pipe.
|
|
85
|
+
stdout: 'ignore',
|
|
86
|
+
stderr: 'ignore',
|
|
87
|
+
detached: true,
|
|
88
|
+
});
|
|
89
|
+
// Never adopted by this process: the worker has to survive a server exit, and
|
|
90
|
+
// `unref` is what keeps the event loop from waiting on it.
|
|
91
|
+
child.unref();
|
|
92
|
+
|
|
93
|
+
const started: HarnessUpdateJob = { ...running, pid: child.pid ?? null };
|
|
94
|
+
await writeUpdateJob(started, spec.statusPath);
|
|
95
|
+
return started;
|
|
96
|
+
}
|
|
@@ -18,12 +18,14 @@
|
|
|
18
18
|
* - **One install at a time.** `flock` on a lock file is held for the run and
|
|
19
19
|
* released by the kernel if this process dies, so a second server (or a
|
|
20
20
|
* second press after a reload) cannot run a competing `npm install -g` over
|
|
21
|
-
* the same prefix.
|
|
21
|
+
* the same prefix. A second harness's press is not refused any more — its
|
|
22
|
+
* record waits in the queue and this worker is spawned for it when the run
|
|
23
|
+
* ahead finishes.
|
|
22
24
|
*
|
|
23
25
|
* It writes the same record the server reads (`update-job-store.ts`), atomically,
|
|
24
26
|
* at every state change and throttled while output streams. It cannot apply the
|
|
25
27
|
* post-install side effects itself: those read the database, which the server
|
|
26
|
-
* owns — `
|
|
28
|
+
* owns — `update-queue.server.ts` does that on its next pass.
|
|
27
29
|
*
|
|
28
30
|
* Run as: `bun <this file> <spec.json>`.
|
|
29
31
|
*/
|
|
@@ -58,6 +60,9 @@ function freshJob(spec: HarnessUpdateJobSpec): HarnessUpdateJob {
|
|
|
58
60
|
label: spec.label,
|
|
59
61
|
startedAt: Date.now(),
|
|
60
62
|
finishedAt: null,
|
|
63
|
+
// This process IS the worker: a record that said it was waiting has been
|
|
64
|
+
// taken over, so the stamp must not survive into the run.
|
|
65
|
+
queuedAt: null,
|
|
61
66
|
pid: process.pid,
|
|
62
67
|
steps: spec.steps.map((step): HarnessUpdateJobStep => ({ ...step, state: 'pending', code: null })),
|
|
63
68
|
output: '',
|
|
@@ -88,7 +93,7 @@ async function pump(
|
|
|
88
93
|
async function runSteps(spec: HarnessUpdateJobSpec, lock: FlockHandle | null): Promise<void> {
|
|
89
94
|
const existing = await readUpdateJob(spec.statusPath);
|
|
90
95
|
const job: HarnessUpdateJob = existing?.harness === spec.harness
|
|
91
|
-
? { ...existing, pid: process.pid, finishedAt: null, ok: null, applied: false }
|
|
96
|
+
? { ...existing, pid: process.pid, finishedAt: null, queuedAt: null, ok: null, applied: false }
|
|
92
97
|
: freshJob(spec);
|
|
93
98
|
// The plan always comes from the spec: the record on disk may be from an
|
|
94
99
|
// earlier run of the same harness, and its steps must not be replayed.
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
import { getDb } from '@/server/db.server';
|
|
22
22
|
import { startHarnessAutoProbe } from '@/server/lib/harness/auto-probe.server';
|
|
23
|
+
import { pumpUpdateQueue } from '@/server/lib/harness/update-queue.server';
|
|
23
24
|
import { compactChatOverlayRows } from '@/server/lib/db/compact-chat-overlay';
|
|
24
25
|
import { packageDir } from '@/server/lib/fs/package-root';
|
|
25
26
|
import { isTrayEnabledByArgv } from '@/server/lib/lifecycle/argv-flags';
|
|
@@ -72,6 +73,14 @@ export async function runAfterListenTasks(target: AfterListenTarget): Promise<vo
|
|
|
72
73
|
// listener is already serving tabs and chats. The pass is per PROCESS, so a
|
|
73
74
|
// `bun --hot` reload does not start every agent again — see the module header.
|
|
74
75
|
startHarnessAutoProbe();
|
|
76
|
+
|
|
77
|
+
// The harness-update queue. A run accepted before a restart (or one harness
|
|
78
|
+
// waiting behind an install) must not need a browser tab to move: this pass
|
|
79
|
+
// settles what died, applies a finished run's side effects, and starts the
|
|
80
|
+
// next waiting worker. Never awaited — it spawns a detached child.
|
|
81
|
+
void pumpUpdateQueue().catch((cause) => {
|
|
82
|
+
console.error('[harness-update] queue pump failed:', cause);
|
|
83
|
+
});
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
/**
|
|
@@ -112,24 +112,29 @@ export function getLockPath(port: number | string): string {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
|
-
* `<data>/run/harness-update
|
|
116
|
-
*
|
|
115
|
+
* `<data>/run/harness-update.<id>.json` — the state of THAT harness's update:
|
|
116
|
+
* waiting in the queue, installing, or the last one that ran.
|
|
117
117
|
*
|
|
118
118
|
* On disk, not in memory, because the run outlives the request that started it:
|
|
119
119
|
* a reloaded page, a restarted server and a second tab all have to read the same
|
|
120
120
|
* answer, and a run killed by a reboot has to be distinguishable from one still
|
|
121
|
-
* installing.
|
|
121
|
+
* installing. One file PER HARNESS, because two presses are two records: the
|
|
122
|
+
* second waits in its own record while the first installs, and each row keeps
|
|
123
|
+
* the log of its own last run instead of overwriting its neighbour's.
|
|
122
124
|
*/
|
|
123
|
-
export function getHarnessUpdateStatusPath(): string {
|
|
124
|
-
return path.join(getRunDir(),
|
|
125
|
+
export function getHarnessUpdateStatusPath(harness: string): string {
|
|
126
|
+
return path.join(getRunDir(), `harness-update.${harness}.json`);
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
/** `<data>/run/harness-update
|
|
128
|
-
export function getHarnessUpdateSpecPath(): string {
|
|
129
|
-
return path.join(getRunDir(),
|
|
129
|
+
/** `<data>/run/harness-update.<id>.spec.json` — what that harness's worker was asked to run. */
|
|
130
|
+
export function getHarnessUpdateSpecPath(harness: string): string {
|
|
131
|
+
return path.join(getRunDir(), `harness-update.${harness}.spec.json`);
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
/** `<data>/run/harness-update.lock` — one harness install at a time, across processes.
|
|
134
|
+
/** `<data>/run/harness-update.lock` — one harness install at a time, across processes.
|
|
135
|
+
* ONE lock for every harness, not one each: the installs share the global npm
|
|
136
|
+
* prefix, and two `npm install -g` over the same prefix is how a tree is
|
|
137
|
+
* corrupted. The queue above it is what lets a second press be accepted. */
|
|
133
138
|
export function getHarnessUpdateLockPath(): string {
|
|
134
139
|
return path.join(getRunDir(), 'harness-update.lock');
|
|
135
140
|
}
|
|
@@ -302,7 +302,16 @@ export function handleChildExit(host: ChildExitHost, stderrTail: string): void {
|
|
|
302
302
|
});
|
|
303
303
|
if (host.streaming || host.promptRunning) {
|
|
304
304
|
host.emit({ type: 'agent_end', isTerminal: true, messages: [] });
|
|
305
|
-
|
|
305
|
+
// The run's own process died mid-flight: that is a failure, not a normal
|
|
306
|
+
// finish, and the reason the notification shows is the one above.
|
|
307
|
+
if (host.sessionId) {
|
|
308
|
+
void markStreamStatus(
|
|
309
|
+
host.sessionId,
|
|
310
|
+
'finish',
|
|
311
|
+
undefined,
|
|
312
|
+
`The omp process for this session exited unexpectedly${detail ? `: ${detail}` : '.'}`,
|
|
313
|
+
);
|
|
314
|
+
}
|
|
306
315
|
}
|
|
307
316
|
host.destroy();
|
|
308
317
|
}
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
* the idle reaper. Used only for lifecycle decisions (idle reclaim, spawn-mode
|
|
15
15
|
* reconcile), never for the UI's running set.
|
|
16
16
|
*
|
|
17
|
-
* Identity mirrors the
|
|
18
|
-
* lifecycle may also carry `index`, and progress frames
|
|
19
|
-
* then matched by index — hence the index→key alias, so
|
|
20
|
-
* tracked under two keys (a leftover key would pin the
|
|
21
|
-
* goes stale).
|
|
17
|
+
* Identity mirrors the sidebar's roster fold (`hooks/chat/subagents/roster.ts`):
|
|
18
|
+
* frames carry an id, a lifecycle may also carry `index`, and progress frames
|
|
19
|
+
* may be id-less and are then matched by index — hence the index→key alias, so
|
|
20
|
+
* one subagent is never tracked under two keys (a leftover key would pin the
|
|
21
|
+
* session alive until it goes stale).
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { parseSubagentLifecycle, readSubagentProgressFrame } from '@/shared/lib/omp/subagent/parse';
|
|
@@ -106,7 +106,11 @@ async function markEndStatus(sessionId: string, host: TerminalSettleHost, messag
|
|
|
106
106
|
if (!sessionId) return;
|
|
107
107
|
const current = await loadStreamStatuses();
|
|
108
108
|
if (current[sessionId] !== 'stream') return;
|
|
109
|
-
|
|
109
|
+
if (endedAborted(host, messages)) {
|
|
110
|
+
await markStreamStatus(sessionId, 'abort');
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
await markStreamStatus(sessionId, 'finish', undefined, endedFailure(messages));
|
|
110
114
|
}
|
|
111
115
|
|
|
112
116
|
/**
|
|
@@ -80,6 +80,7 @@ export async function removeSession(sessionId: string): Promise<SessionRemoval>
|
|
|
80
80
|
error: 'This session is working. Stop the run before deleting it.',
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
+
if ('deleteAgentSession' in live && live.deleteAgentSession) await live.deleteAgentSession();
|
|
83
84
|
await live.destroyAndWait();
|
|
84
85
|
}
|
|
85
86
|
|
|
@@ -22,10 +22,11 @@ import { DEFAULT_SESSION_SORT_OPTION, isValidSessionSortOption, sortFolders } fr
|
|
|
22
22
|
import { groupSessionsByRoot, sessionTitleFor } from '@/shared/lib/omp/session/sidebar';
|
|
23
23
|
import { loadOmpSidebarData } from '@/server/lib/omp/session/reader';
|
|
24
24
|
import { sessionHasSubagents } from '@/server/lib/omp/session/subagent-presence';
|
|
25
|
-
import { loadStreamStates
|
|
25
|
+
import { loadStreamStates } from '@/shared/lib/omp/session/stream-state.server';
|
|
26
26
|
import { healStaleStreamStatuses } from '@/shared/lib/omp/session/stream-heal.server';
|
|
27
27
|
import { getAwaitingInputSessionIds, getLiveRunSessionIds, listRpcSessions } from '@/server/lib/omp/rpc/session-registry';
|
|
28
28
|
import type { SessionItemData, SessionSortOption, WorkspaceFolderData } from '@/shared/types';
|
|
29
|
+
import type { SidebarStatusEntry } from '@/shared/types/realtime';
|
|
29
30
|
import { sessionWorktreeMap } from '@/server/lib/fs/worktree/topology';
|
|
30
31
|
import { DEFAULT_HARNESS_ID, HARNESS_IDS } from '@/shared/lib/harness/catalog';
|
|
31
32
|
import { knownHarness, loadAcpSessions, loadHarnessBySession } from '@/server/lib/harness/session-store.server';
|
|
@@ -153,13 +154,10 @@ export async function loadSidebarStructure(): Promise<SessionListPayload> {
|
|
|
153
154
|
* belongs to the subscribe-time snapshot, which is the moment the old sidebar
|
|
154
155
|
* poll used to provide it.
|
|
155
156
|
*/
|
|
157
|
+
/** One session's volatile sidebar fields, as the status topic carries them. */
|
|
156
158
|
export async function loadSidebarStatus(
|
|
157
159
|
options: { repair?: boolean } = {},
|
|
158
|
-
): Promise<Record<string, {
|
|
159
|
-
streamStatus?: 'stream' | 'finish' | 'abort';
|
|
160
|
-
awaitingInput?: boolean;
|
|
161
|
-
runModel?: SessionRunModel;
|
|
162
|
-
}>> {
|
|
160
|
+
): Promise<Record<string, SidebarStatusEntry>> {
|
|
163
161
|
// No MOCK short-circuit: the simulated stream writes the same `stream` row a
|
|
164
162
|
// real run does (`routes/chat/stream.ts`), so the sidebar spinner and the
|
|
165
163
|
// chat's generating indicator have one source in every mode. Returning `{}`
|
|
@@ -182,13 +180,13 @@ export async function loadSidebarStatus(
|
|
|
182
180
|
for (const session of listRpcSessions()) void session.runSettle.reconcile('request');
|
|
183
181
|
}
|
|
184
182
|
|
|
185
|
-
const status: Record<string, {
|
|
186
|
-
streamStatus?: 'stream' | 'finish' | 'abort';
|
|
187
|
-
awaitingInput?: boolean;
|
|
188
|
-
runModel?: SessionRunModel;
|
|
189
|
-
}> = {};
|
|
183
|
+
const status: Record<string, SidebarStatusEntry> = {};
|
|
190
184
|
for (const [id, state] of Object.entries(await loadStreamStates())) {
|
|
191
|
-
status[id] = {
|
|
185
|
+
status[id] = {
|
|
186
|
+
streamStatus: state.status,
|
|
187
|
+
...(state.model ? { runModel: state.model } : {}),
|
|
188
|
+
...(state.failure ? { runFailure: state.failure } : {}),
|
|
189
|
+
};
|
|
192
190
|
}
|
|
193
191
|
// Sessions blocked on a dialog nobody has answered yet. Read live from the
|
|
194
192
|
// process registry (never persisted): the child that owns the question is the
|
|
@@ -155,6 +155,47 @@ describe('forkSession (omp)', () => {
|
|
|
155
155
|
expect(lines.some((line) => line.includes('"id":"a1"'))).toBe(true);
|
|
156
156
|
expect(lines.some((line) => line.includes('"id":"u2"'))).toBe(false);
|
|
157
157
|
});
|
|
158
|
+
|
|
159
|
+
test('an RPC fork applies the composer picks before its first prompt', async () => {
|
|
160
|
+
await writeSource();
|
|
161
|
+
const forked = fakeForked('child');
|
|
162
|
+
let capturedMode: string | undefined;
|
|
163
|
+
const deps: ForkSessionDeps = {
|
|
164
|
+
async startRpc(id, _file, _cwd, accessMode) {
|
|
165
|
+
capturedMode = accessMode;
|
|
166
|
+
return { session: forked, realSessionId: id };
|
|
167
|
+
},
|
|
168
|
+
async startAcp() {
|
|
169
|
+
throw new Error('not used');
|
|
170
|
+
},
|
|
171
|
+
async probeForkSupported() {
|
|
172
|
+
return false;
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
await forkSession(
|
|
177
|
+
{
|
|
178
|
+
sourceSessionId: 'src',
|
|
179
|
+
prompt: 'try another angle',
|
|
180
|
+
model: { provider: 'acme', modelId: 'big' },
|
|
181
|
+
thinkingLevel: 'high',
|
|
182
|
+
accessMode: 'yolo',
|
|
183
|
+
images: [{ type: 'image', data: 'aGk=', mimeType: 'image/png' }],
|
|
184
|
+
},
|
|
185
|
+
deps,
|
|
186
|
+
);
|
|
187
|
+
|
|
188
|
+
expect(capturedMode).toBe('yolo');
|
|
189
|
+
expect(forked.sent).toEqual([
|
|
190
|
+
{ type: 'set_model', provider: 'acme', modelId: 'big' },
|
|
191
|
+
{ type: 'set_thinking_level', level: 'high' },
|
|
192
|
+
{
|
|
193
|
+
type: 'prompt',
|
|
194
|
+
message: 'try another angle',
|
|
195
|
+
images: [{ type: 'image', data: 'aGk=', mimeType: 'image/png' }],
|
|
196
|
+
},
|
|
197
|
+
]);
|
|
198
|
+
});
|
|
158
199
|
});
|
|
159
200
|
|
|
160
201
|
describe('forkSession (ACP)', () => {
|
|
@@ -177,6 +218,33 @@ describe('forkSession (ACP)', () => {
|
|
|
177
218
|
});
|
|
178
219
|
});
|
|
179
220
|
|
|
221
|
+
test('an ACP fork receives the composer model, thinking level and access mode', async () => {
|
|
222
|
+
await saveHarnessSession({
|
|
223
|
+
sessionId: 'acp-source',
|
|
224
|
+
harness: 'claude',
|
|
225
|
+
agentSessionId: 'agent-1',
|
|
226
|
+
cwd: '/tmp/project',
|
|
227
|
+
});
|
|
228
|
+
const deps = fakeDeps('acp-fork', { forkSupported: true });
|
|
229
|
+
await forkSession(
|
|
230
|
+
{
|
|
231
|
+
sourceSessionId: 'acp-source',
|
|
232
|
+
model: { provider: 'claude', modelId: 'opus' },
|
|
233
|
+
thinkingLevel: 'high',
|
|
234
|
+
accessMode: 'write',
|
|
235
|
+
},
|
|
236
|
+
deps,
|
|
237
|
+
);
|
|
238
|
+
expect(deps.acpCalls).toEqual([
|
|
239
|
+
expect.objectContaining({
|
|
240
|
+
harness: 'claude',
|
|
241
|
+
model: { provider: 'claude', modelId: 'opus' },
|
|
242
|
+
thinkingLevel: 'high',
|
|
243
|
+
accessMode: 'write',
|
|
244
|
+
}),
|
|
245
|
+
]);
|
|
246
|
+
});
|
|
247
|
+
|
|
180
248
|
test('a harness without fork support is refused before spawning', async () => {
|
|
181
249
|
await saveHarnessSession({
|
|
182
250
|
sessionId: 'acp-source',
|