@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
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* POST /api/sessions/spawn — create a session under a parent.
|
|
8
|
+
*
|
|
9
|
+
* Static path, registered before the `:sessionId` routes for the same reason
|
|
10
|
+
* `/api/sessions/batch-archive` is: a parameter route winning the match would
|
|
11
|
+
* answer 405 and hide the real path.
|
|
12
|
+
*
|
|
13
|
+
* The handler owns validation and status mapping only. Everything that decides
|
|
14
|
+
* where the child runs, what it inherits and whether the tree allows it lives in
|
|
15
|
+
* `spawn.server.ts`, because the agent CLI calls the same service.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { json } from '@/server/lib/remix-compat';
|
|
19
|
+
import type { ActionFunctionArgs } from '@/server/lib/remix-compat';
|
|
20
|
+
import { methodNotAllowed, parseJsonBody } from '@/server/lib/route-adapter';
|
|
21
|
+
import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
|
|
22
|
+
import {
|
|
23
|
+
SessionSpawnError,
|
|
24
|
+
spawnChildSession,
|
|
25
|
+
type SpawnChildSessionInput,
|
|
26
|
+
} from '@/server/lib/sessions/spawn.server';
|
|
27
|
+
import { bearerToken, verifyAgentToken } from '@/server/lib/sessions/agent-token.server';
|
|
28
|
+
|
|
29
|
+
type Visibility = 'visible' | 'hidden';
|
|
30
|
+
type ParentNotifications = 'auto' | 'stuck' | 'off';
|
|
31
|
+
|
|
32
|
+
interface SpawnBody {
|
|
33
|
+
parentSessionId?: unknown;
|
|
34
|
+
/** The CLI's `--parent-self`: resolve the parent from the bearer token. */
|
|
35
|
+
parentSelf?: unknown;
|
|
36
|
+
harness?: unknown;
|
|
37
|
+
cwd?: unknown;
|
|
38
|
+
prompt?: unknown;
|
|
39
|
+
model?: unknown;
|
|
40
|
+
thinkingLevel?: unknown;
|
|
41
|
+
lifecycleOwnerSessionId?: unknown;
|
|
42
|
+
visibility?: unknown;
|
|
43
|
+
parentNotifications?: unknown;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function readModel(value: unknown): SpawnChildSessionInput['model'] {
|
|
47
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
|
|
48
|
+
const record = value as Record<string, unknown>;
|
|
49
|
+
return typeof record.provider === 'string' && typeof record.modelId === 'string'
|
|
50
|
+
? { provider: record.provider, modelId: record.modelId }
|
|
51
|
+
: null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function readString(value: unknown): string | null {
|
|
55
|
+
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function statusFor(code: SessionSpawnError['code']): number {
|
|
59
|
+
switch (code) {
|
|
60
|
+
case 'parent_not_found':
|
|
61
|
+
return 404;
|
|
62
|
+
case 'parent_archived':
|
|
63
|
+
case 'parent_folder_mismatch':
|
|
64
|
+
return 409;
|
|
65
|
+
default:
|
|
66
|
+
return 400;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function spawnSession({ request }: ActionFunctionArgs) {
|
|
71
|
+
if (request.method !== 'POST') {
|
|
72
|
+
return methodNotAllowed({ request, params: {} });
|
|
73
|
+
}
|
|
74
|
+
const parsed = await parseJsonBody<SpawnBody>(request);
|
|
75
|
+
if (!parsed.ok) return json({ error: 'Invalid JSON body' }, { status: 400 });
|
|
76
|
+
|
|
77
|
+
const prompt = readString(parsed.body.prompt);
|
|
78
|
+
if (!prompt) return json({ error: 'prompt is required' }, { status: 400 });
|
|
79
|
+
|
|
80
|
+
// An agent may only spawn under itself. The token is the identity (there is
|
|
81
|
+
// no cookie in a subprocess); `--parent-self` is how the CLI asks for it.
|
|
82
|
+
const tokenSession = verifyAgentToken(bearerToken(request));
|
|
83
|
+
let parentSessionId = readString(parsed.body.parentSessionId);
|
|
84
|
+
if (parsed.body.parentSelf === true) {
|
|
85
|
+
if (!tokenSession) {
|
|
86
|
+
return json({ error: 'parentSelf requires an agent token', code: 'agent_token_required' }, { status: 401 });
|
|
87
|
+
}
|
|
88
|
+
parentSessionId = tokenSession;
|
|
89
|
+
}
|
|
90
|
+
if (tokenSession && parentSessionId !== tokenSession) {
|
|
91
|
+
return json(
|
|
92
|
+
{ error: 'An agent may only spawn under its own session', code: 'agent_scope' },
|
|
93
|
+
{ status: 403 },
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const visibility = parsed.body.visibility;
|
|
98
|
+
if (visibility !== undefined && visibility !== 'visible' && visibility !== 'hidden') {
|
|
99
|
+
return json({ error: 'visibility must be "visible" or "hidden"' }, { status: 400 });
|
|
100
|
+
}
|
|
101
|
+
const notifications = parsed.body.parentNotifications;
|
|
102
|
+
if (
|
|
103
|
+
notifications !== undefined &&
|
|
104
|
+
notifications !== 'auto' &&
|
|
105
|
+
notifications !== 'stuck' &&
|
|
106
|
+
notifications !== 'off'
|
|
107
|
+
) {
|
|
108
|
+
return json({ error: 'parentNotifications must be auto, stuck or off' }, { status: 400 });
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
const result = await spawnChildSession({
|
|
113
|
+
parentSessionId,
|
|
114
|
+
harness: readString(parsed.body.harness),
|
|
115
|
+
cwd: readString(parsed.body.cwd),
|
|
116
|
+
prompt,
|
|
117
|
+
model: readModel(parsed.body.model),
|
|
118
|
+
thinkingLevel: readString(parsed.body.thinkingLevel),
|
|
119
|
+
lifecycleOwnerSessionId: readString(parsed.body.lifecycleOwnerSessionId),
|
|
120
|
+
...(visibility ? { visibility: visibility as Visibility } : {}),
|
|
121
|
+
...(notifications ? { parentNotifications: notifications as ParentNotifications } : {}),
|
|
122
|
+
});
|
|
123
|
+
emitRealtimeSignal('sidebar-structure');
|
|
124
|
+
return json(result, { status: 201 });
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (error instanceof SessionSpawnError) {
|
|
127
|
+
return json({ error: error.message, code: error.code }, { status: statusFor(error.code) });
|
|
128
|
+
}
|
|
129
|
+
return json(
|
|
130
|
+
{ error: error instanceof Error ? error.message : 'Could not spawn the session' },
|
|
131
|
+
{ status: 500 },
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
writeTerminalInput,
|
|
32
32
|
} from '@/server/lib/terminal/runtime.server';
|
|
33
33
|
import { TerminalRuntimeError, type TerminalViewer } from '@/server/lib/terminal/session.server';
|
|
34
|
-
import { frameAccepted } from '@/server/lib/terminal/send-result';
|
|
34
|
+
import { asBinaryFrame, frameAccepted } from '@/server/lib/terminal/send-result';
|
|
35
35
|
import {
|
|
36
36
|
decodeClientFrame,
|
|
37
37
|
encodeServerFrame,
|
|
@@ -71,8 +71,8 @@ export const terminalWsRoutes = new Elysia({ prefix: '/api/terminal' }).ws('/:te
|
|
|
71
71
|
// Only `0` is a drop; `-1` means "queued, draining". See
|
|
72
72
|
// `send-result.ts` for the measured contract — reading `-1` as
|
|
73
73
|
// failure closed healthy viewers at the first burst, and reading
|
|
74
|
-
// `0` as success left
|
|
75
|
-
return frameAccepted(ws.send(frame));
|
|
74
|
+
// `0` as success left the panel attached to a stream with a hole.
|
|
75
|
+
return frameAccepted(ws.send(asBinaryFrame(frame)));
|
|
76
76
|
} catch {
|
|
77
77
|
// Socket closed mid-send; the close handler detaches.
|
|
78
78
|
return false;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HARNESS_CATALOG } from '@/shared/lib/harness/catalog';
|
|
1
2
|
import type { AgentItem, CommandItem, ComposerPickItem, ComposerPickKind, FsFileEntry, SkillItem } from '@/shared/types';
|
|
2
3
|
import { KABMO_COMMANDS } from '@/shared/lib/chat/composer/trigger';
|
|
3
4
|
|
|
@@ -38,6 +39,25 @@ export function toAgentPickItems(agents: AgentItem[]): ComposerPickItem[] {
|
|
|
38
39
|
}));
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
/**
|
|
43
|
+
* Map the harness catalog into `@harness:<id>` mention tokens.
|
|
44
|
+
*
|
|
45
|
+
* These rows are what turns a mention into a delegation rather than a prose
|
|
46
|
+
* hint: the picker inserts the namespaced token, and the send path compiles it
|
|
47
|
+
* into the exact `kabmo session spawn` command. The token carries no model, so
|
|
48
|
+
* the spawn uses that harness's configured default (or the agent's own).
|
|
49
|
+
*/
|
|
50
|
+
export function toHarnessPickItems(): ComposerPickItem[] {
|
|
51
|
+
return Object.values(HARNESS_CATALOG).map((harness) => ({
|
|
52
|
+
id: `harness-${harness.id}`,
|
|
53
|
+
name: `harness:${harness.id}`,
|
|
54
|
+
description: `${harness.label} · default model · type :<model> to pin one`,
|
|
55
|
+
kind: 'harness',
|
|
56
|
+
source: 'harness',
|
|
57
|
+
token: `@harness:${harness.id}`,
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
|
|
41
61
|
/**
|
|
42
62
|
* Map workspace files into `@file:<path>` mention tokens. The `file:` namespace
|
|
43
63
|
* means a file token can never collide with a bare `@agent` (e.g. a root-level
|
|
@@ -211,8 +231,17 @@ export function loadComposerItems(
|
|
|
211
231
|
): Promise<ComposerPickItem[]> {
|
|
212
232
|
if (kind === 'mention') {
|
|
213
233
|
const files = loadFileItems(root ?? null);
|
|
214
|
-
|
|
215
|
-
|
|
234
|
+
const harnesses = toHarnessPickItems();
|
|
235
|
+
// Harness rows survive `includeAgents: false`: that flag exists because an
|
|
236
|
+
// ACP chat has no omp `@agent` vocabulary, not because it cannot delegate.
|
|
237
|
+
if (options.includeAgents === false) {
|
|
238
|
+
return files.then((fileItems) => [...harnesses, ...fileItems]);
|
|
239
|
+
}
|
|
240
|
+
return Promise.all([loadAgentItems(), files]).then(([agents, fileItems]) => [
|
|
241
|
+
...agents,
|
|
242
|
+
...harnesses,
|
|
243
|
+
...fileItems,
|
|
244
|
+
]);
|
|
216
245
|
}
|
|
217
246
|
return loadCommandItems(root ?? null, sessionId);
|
|
218
247
|
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import {
|
|
3
|
+
delegationCommand,
|
|
4
|
+
delegationErrorText,
|
|
5
|
+
formatDelegationPrompt,
|
|
6
|
+
parseHarnessMentions,
|
|
7
|
+
} from '@/shared/lib/chat/composer/delegation';
|
|
8
|
+
|
|
9
|
+
describe('parseHarnessMentions', () => {
|
|
10
|
+
test('a bare harness mention uses the harness default model', () => {
|
|
11
|
+
const plan = parseHarnessMentions('@claude review src/auth');
|
|
12
|
+
expect(plan.errors).toEqual([]);
|
|
13
|
+
expect(plan.delegations).toEqual([
|
|
14
|
+
{ harness: 'claude', model: null, task: 'review src/auth', token: '@claude' },
|
|
15
|
+
]);
|
|
16
|
+
expect(plan.orchestratorText).toBe('');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('an explicit model rides the mention', () => {
|
|
20
|
+
const plan = parseHarnessMentions('@harness:claude:opus review this');
|
|
21
|
+
expect(plan.delegations[0]).toMatchObject({
|
|
22
|
+
harness: 'claude',
|
|
23
|
+
model: 'opus',
|
|
24
|
+
task: 'review this',
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('one mention per paragraph, two paragraphs are two workers', () => {
|
|
29
|
+
const plan = parseHarnessMentions(
|
|
30
|
+
'@harness:claude review the diff.\n\n@harness:omp fix the tests.',
|
|
31
|
+
);
|
|
32
|
+
expect(plan.delegations.map((entry) => entry.harness)).toEqual(['claude', 'omp-rpc']);
|
|
33
|
+
expect(plan.delegations[0].task).toBe('review the diff.');
|
|
34
|
+
expect(plan.delegations[1].task).toBe('fix the tests.');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('a paragraph with no mention stays with the orchestrator', () => {
|
|
38
|
+
const plan = parseHarnessMentions(
|
|
39
|
+
'Coordinate this work.\n\n@claude review the diff.\n\nThen report back.',
|
|
40
|
+
);
|
|
41
|
+
expect(plan.delegations).toHaveLength(1);
|
|
42
|
+
expect(plan.orchestratorText).toBe('Coordinate this work.\n\nThen report back.');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('two mentions in one paragraph are refused', () => {
|
|
46
|
+
const plan = parseHarnessMentions('@claude and @omp fix this', { agentNames: [] });
|
|
47
|
+
expect(plan.errors[0]?.code).toBe('multiple_mentions');
|
|
48
|
+
expect(delegationErrorText(plan)).toContain('blank line');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('an unknown namespaced harness is refused', () => {
|
|
52
|
+
const plan = parseHarnessMentions('@harness:nope do it');
|
|
53
|
+
expect(plan.errors[0]?.code).toBe('unknown_harness');
|
|
54
|
+
expect(delegationErrorText(plan)).toContain('nope');
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('a known omp agent name is not a bare harness mention', () => {
|
|
58
|
+
const plan = parseHarnessMentions('@architect review this', { agentNames: ['architect'] });
|
|
59
|
+
expect(plan.delegations).toEqual([]);
|
|
60
|
+
expect(plan.orchestratorText).toBe('@architect review this');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('@file: is not a harness mention', () => {
|
|
64
|
+
const plan = parseHarnessMentions('look at @file:src/a.ts', { agentNames: [] });
|
|
65
|
+
expect(plan.delegations).toEqual([]);
|
|
66
|
+
expect(plan.orchestratorText).toBe('look at @file:src/a.ts');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('a mention with no task is refused', () => {
|
|
70
|
+
const plan = parseHarnessMentions('@claude');
|
|
71
|
+
expect(plan.errors[0]?.code).toBe('empty_task');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('delegation prompt', () => {
|
|
76
|
+
test('the command omits --model for a default and includes it when named', () => {
|
|
77
|
+
const plan = parseHarnessMentions(
|
|
78
|
+
'@harness:claude review.\n\n@harness:claude:opus check.',
|
|
79
|
+
);
|
|
80
|
+
expect(delegationCommand(plan.delegations[0], 0)).toContain(
|
|
81
|
+
'--harness claude --prompt-file -',
|
|
82
|
+
);
|
|
83
|
+
expect(delegationCommand(plan.delegations[1], 1)).toContain('--model opus');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('the orchestrator prompt names the worker and the end-turn rule', () => {
|
|
87
|
+
const prompt = formatDelegationPrompt(parseHarnessMentions('@claude review this'));
|
|
88
|
+
expect(prompt).toContain('[kabmo orchestration contract]');
|
|
89
|
+
expect(prompt).toContain('end your turn');
|
|
90
|
+
expect(prompt).toContain('--harness claude');
|
|
91
|
+
expect(prompt.toLowerCase()).toContain('do not poll');
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `@harness` delegation mentions in the composer.
|
|
8
|
+
*
|
|
9
|
+
* A mention is a commitment, not a suggestion: `@harness:claude` (or bare
|
|
10
|
+
* `@claude`) names the agent that must do the paragraph's work, and the text of
|
|
11
|
+
* that paragraph is its whole brief. The parser turns a message into a
|
|
12
|
+
* delegation plan the orchestrator can execute with the CLI, so the model never
|
|
13
|
+
* has to guess a harness, a model or which words were the task.
|
|
14
|
+
*
|
|
15
|
+
* Namespaced `harness:` cannot collide with `@file:` or an omp `@agent`; a bare
|
|
16
|
+
* `@claude` is accepted only when the token is a known harness id and is not a
|
|
17
|
+
* known agent name.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { HARNESS_CATALOG, HARNESS_IDS, type HarnessId } from '@/shared/lib/harness/catalog';
|
|
21
|
+
|
|
22
|
+
export interface HarnessDelegation {
|
|
23
|
+
harness: HarnessId;
|
|
24
|
+
/** The agent's own model value, or null for the harness default. */
|
|
25
|
+
model: string | null;
|
|
26
|
+
task: string;
|
|
27
|
+
/** The exact token the user typed, for diagnostics and display. */
|
|
28
|
+
token: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type DelegationErrorCode = 'unknown_harness' | 'empty_task' | 'multiple_mentions';
|
|
32
|
+
|
|
33
|
+
export interface DelegationError {
|
|
34
|
+
code: DelegationErrorCode;
|
|
35
|
+
message: string;
|
|
36
|
+
paragraph: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface DelegationPlan {
|
|
40
|
+
delegations: HarnessDelegation[];
|
|
41
|
+
/** The paragraphs that stay with the orchestrator, mentions removed. */
|
|
42
|
+
orchestratorText: string;
|
|
43
|
+
errors: DelegationError[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ParseDelegationOptions {
|
|
47
|
+
/** Bare `@name` is an omp agent when it matches one of these. */
|
|
48
|
+
agentNames?: readonly string[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** `@harness:<id>[:<model>]` or bare `@<harnessId>`. */
|
|
52
|
+
const MENTION_RE = /(^|[\s([{])@(?:(harness):)?([a-z0-9][a-z0-9-]*)(?::([^\s#]+))?/gi;
|
|
53
|
+
|
|
54
|
+
/** The names users type that are not catalog ids. `omp` is the default RPC
|
|
55
|
+
* surface; `claude-code` is the vendor's name for the `claude` adapter. */
|
|
56
|
+
const HARNESS_ALIASES: Readonly<Record<string, HarnessId>> = {
|
|
57
|
+
omp: 'omp-rpc',
|
|
58
|
+
'claude-code': 'claude',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
function harnessIdFor(name: string): HarnessId | null {
|
|
62
|
+
return HARNESS_ALIASES[name] ?? (HARNESS_IDS.includes(name as HarnessId) ? (name as HarnessId) : null);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Parse one message. The error list is non-empty when the message cannot be
|
|
67
|
+
* delegated as written; the caller refuses the send rather than guessing.
|
|
68
|
+
*/
|
|
69
|
+
export function parseHarnessMentions(
|
|
70
|
+
text: string,
|
|
71
|
+
options: ParseDelegationOptions = {},
|
|
72
|
+
): DelegationPlan {
|
|
73
|
+
const agentNames = new Set((options.agentNames ?? []).map((name) => name.toLowerCase()));
|
|
74
|
+
const paragraphs = text.split(/\n\s*\n/);
|
|
75
|
+
const delegations: HarnessDelegation[] = [];
|
|
76
|
+
const kept: string[] = [];
|
|
77
|
+
const errors: DelegationError[] = [];
|
|
78
|
+
|
|
79
|
+
for (const paragraph of paragraphs) {
|
|
80
|
+
const matches: { start: number; end: number; harness: HarnessId; model: string | null; token: string }[] = [];
|
|
81
|
+
MENTION_RE.lastIndex = 0;
|
|
82
|
+
for (const match of paragraph.matchAll(MENTION_RE)) {
|
|
83
|
+
const namespace = match[2]?.toLowerCase();
|
|
84
|
+
const name = match[3]?.toLowerCase();
|
|
85
|
+
if (!name) continue;
|
|
86
|
+
const isBare = namespace === undefined;
|
|
87
|
+
const known = harnessIdFor(name);
|
|
88
|
+
if (namespace && !known) {
|
|
89
|
+
errors.push({
|
|
90
|
+
code: 'unknown_harness',
|
|
91
|
+
message: `Unknown harness "${name}"`,
|
|
92
|
+
paragraph,
|
|
93
|
+
});
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (!known) continue;
|
|
97
|
+
if (isBare && agentNames.has(name)) continue;
|
|
98
|
+
const tokenStart = (match.index ?? 0) + (match[1]?.length ?? 0);
|
|
99
|
+
const token = match[0].slice(match[1]?.length ?? 0);
|
|
100
|
+
matches.push({
|
|
101
|
+
start: tokenStart,
|
|
102
|
+
end: tokenStart + token.length,
|
|
103
|
+
harness: known,
|
|
104
|
+
model: match[4] ?? null,
|
|
105
|
+
token,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (matches.length === 0) {
|
|
110
|
+
if (paragraph.trim()) kept.push(paragraph.trim());
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (matches.length > 1) {
|
|
114
|
+
errors.push({
|
|
115
|
+
code: 'multiple_mentions',
|
|
116
|
+
message: 'One paragraph can delegate to one harness; separate workers with a blank line',
|
|
117
|
+
paragraph,
|
|
118
|
+
});
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const mention = matches[0];
|
|
123
|
+
const task = `${paragraph.slice(0, mention.start)}${paragraph.slice(mention.end)}`
|
|
124
|
+
.replace(/\s+/g, ' ')
|
|
125
|
+
.replace(/^[\s,;:-]+/, '')
|
|
126
|
+
.trim();
|
|
127
|
+
if (!task) {
|
|
128
|
+
errors.push({
|
|
129
|
+
code: 'empty_task',
|
|
130
|
+
message: `@${mention.token.replace(/^@/, '')} needs a task in the same paragraph`,
|
|
131
|
+
paragraph,
|
|
132
|
+
});
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
delegations.push({
|
|
136
|
+
harness: mention.harness,
|
|
137
|
+
model: mention.model,
|
|
138
|
+
task,
|
|
139
|
+
token: mention.token,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// A message that is only an unknown `@harness:` is an error, not prose.
|
|
144
|
+
if (errors.length > 0) {
|
|
145
|
+
return { delegations: [], orchestratorText: text.trim(), errors };
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
delegations,
|
|
149
|
+
orchestratorText: kept.join('\n\n'),
|
|
150
|
+
errors,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** The exact command an orchestrator runs, with the task in a heredoc. */
|
|
155
|
+
export function delegationCommand(delegation: HarnessDelegation, index: number): string {
|
|
156
|
+
const tag = `KABMO_TASK_${index + 1}`;
|
|
157
|
+
const model = delegation.model ? ` --model ${delegation.model}` : '';
|
|
158
|
+
return [
|
|
159
|
+
`kabmo session spawn --parent-self --harness ${delegation.harness}${model} --prompt-file - <<'${tag}'`,
|
|
160
|
+
delegation.task,
|
|
161
|
+
tag,
|
|
162
|
+
].join('\n');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The block prepended to the orchestrator's own prompt. It names every worker,
|
|
167
|
+
* gives the exact spawn command, and states the one behaviour the host cannot
|
|
168
|
+
* enforce by itself: end the turn instead of polling.
|
|
169
|
+
*/
|
|
170
|
+
export function formatDelegationPrompt(plan: DelegationPlan): string {
|
|
171
|
+
const lines = [
|
|
172
|
+
'[kabmo orchestration contract]',
|
|
173
|
+
'You are the orchestrator for this message. Start each worker below with the exact command,',
|
|
174
|
+
'then end your turn. A worker sees nothing of this conversation: its TASK is the whole brief.',
|
|
175
|
+
'Kabmo adds the dispatched-worker preamble and sends each worker outcome back as a new',
|
|
176
|
+
'message. Do not poll, do not resend the same task, and do not delegate work that is not',
|
|
177
|
+
'listed here unless the user asks.',
|
|
178
|
+
'',
|
|
179
|
+
'Workers:',
|
|
180
|
+
];
|
|
181
|
+
plan.delegations.forEach((delegation, index) => {
|
|
182
|
+
const model = delegation.model ?? 'default model';
|
|
183
|
+
lines.push(
|
|
184
|
+
'',
|
|
185
|
+
`${index + 1}. ${HARNESS_CATALOG[delegation.harness]?.label ?? delegation.harness} · ${model}`,
|
|
186
|
+
delegationCommand(delegation, index),
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
lines.push(
|
|
190
|
+
'',
|
|
191
|
+
'When a worker finishes, read its output with `kabmo session output <id>` and report the',
|
|
192
|
+
'result to the user. Reconcile conflicting reports; do not relay one verbatim.',
|
|
193
|
+
'[/kabmo orchestration contract]',
|
|
194
|
+
);
|
|
195
|
+
if (plan.orchestratorText) lines.push('', plan.orchestratorText);
|
|
196
|
+
return lines.join('\n');
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** A user-facing refusal, or null when the message can be sent. */
|
|
200
|
+
export function delegationErrorText(plan: DelegationPlan): string | null {
|
|
201
|
+
if (plan.errors.length === 0) return null;
|
|
202
|
+
return plan.errors
|
|
203
|
+
.map((error) => error.message)
|
|
204
|
+
.filter((message, index, all) => all.indexOf(message) === index)
|
|
205
|
+
.join(' · ');
|
|
206
|
+
}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* runs and half-block progress bars. The notice card renders markdown through
|
|
18
18
|
* Shiki, which treats `\x1b[38;2;…m` as literal text, so `/context` drew 48
|
|
19
19
|
* escape bytes as `38;2;107;114;128m████…`. True colour stays available in the
|
|
20
|
-
* realtime
|
|
20
|
+
* realtime terminal panel, which parses ANSI natively.
|
|
21
21
|
* - **`<system-notice>` wrappers.** omp tags its own notices; the tag is
|
|
22
22
|
* scaffolding, not content. (The runtime-notice wrappers —
|
|
23
23
|
* `<system-reminder>`, `<system-interrupt>`, `<task-result>` — are NOT
|
|
@@ -93,6 +93,17 @@ describe('toolSummary — wait', () => {
|
|
|
93
93
|
expect(summary?.line).toBe('15s · idle 15s total');
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
+
test('the 18.18.6 hint after the window does not hide the idle chip', () => {
|
|
97
|
+
// omp 18.18.6: `No reply within 10s; a back-to-back wait allows up to 30s.`
|
|
98
|
+
const summary = toolSummary(tool({
|
|
99
|
+
type: 'wait',
|
|
100
|
+
durationMs: 10_000,
|
|
101
|
+
output: 'No reply within 10s; a back-to-back wait allows up to 30s.',
|
|
102
|
+
details: { op: 'wait', jobs: [] },
|
|
103
|
+
}));
|
|
104
|
+
expect(summary?.line).toBe('10s · idle 10s');
|
|
105
|
+
});
|
|
106
|
+
|
|
96
107
|
test('an unreadable result keeps the generic fallback', () => {
|
|
97
108
|
// No `details.op`, so this is not a wait result at all — the output's first
|
|
98
109
|
// line is the only thing worth saying.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* Timeline cards render with Shiki (`Bash`, `FallbackOutput`), which treats
|
|
10
10
|
* raw `\x1b[…m` sequences as literal text — so escapes are dropped here
|
|
11
11
|
* first and the clean text goes to the highlighter. True terminal colors
|
|
12
|
-
* stay available in the realtime
|
|
12
|
+
* stay available in the realtime terminal panel, which parses ANSI natively.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
/** Any ANSI escape: OSC hyperlink, charset select, or CSI sequence. */
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* contains. `@fontsource/fira-code`'s latin subset maps 226 codepoints and not
|
|
12
12
|
* one of them is above U+FFFF, so the terminal's stack can only reach them
|
|
13
13
|
* through a Nerd Font. Until now the stack named installed families only
|
|
14
|
-
* (`
|
|
14
|
+
* (`TERMINAL_GLYPH_FALLBACKS`), which means the glyphs appeared on the machine
|
|
15
15
|
* that had one installed and were hollow tofu boxes on every other device — a
|
|
16
16
|
* phone, a second laptop, a colleague's browser.
|
|
17
17
|
*
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
*
|
|
30
30
|
* `font-display: block` rather than `swap`, unlike the text faces beside it: a
|
|
31
31
|
* swapped symbol paints a tofu box first and repaints, and in a terminal that
|
|
32
|
-
* box is exactly the artifact this face exists to remove. `mount.ts`
|
|
33
|
-
* face before opening
|
|
32
|
+
* box is exactly the artifact this face exists to remove. `mount.ts` waits for
|
|
33
|
+
* the face before opening the terminal for the same reason — see
|
|
34
|
+
* `ensureNerdGlyphs`.
|
|
34
35
|
*
|
|
35
36
|
* Generated by `bun run scripts/nerd-symbols-font.mjs` from
|
|
36
37
|
* `SymbolsNerdFontMono-Regular.ttf` (Nerd Fonts v3.5.1). See NOTICE.md in this
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* and every way it can break is silent at runtime:
|
|
9
9
|
*
|
|
10
10
|
* - The bundled face's family name is written twice — in the stack
|
|
11
|
-
* (`
|
|
11
|
+
* (`TERMINAL_FONT_FAMILY`) and in the `@font-face` (`nerd-symbols.css`). If they
|
|
12
12
|
* drift, the face loads and nothing uses it: prompts render as tofu boxes
|
|
13
13
|
* with no error anywhere.
|
|
14
14
|
* - The face must stay LAST in the stack. Moved ahead of the installed families
|
|
@@ -30,8 +30,8 @@ import { join } from 'node:path';
|
|
|
30
30
|
|
|
31
31
|
import {
|
|
32
32
|
NERD_SYMBOLS_FAMILY,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
TERMINAL_FONT_FAMILY,
|
|
34
|
+
TERMINAL_GLYPH_FALLBACKS,
|
|
35
35
|
} from '@/client/data/theme/terminal';
|
|
36
36
|
|
|
37
37
|
const FONT_DIR = import.meta.dir;
|
|
@@ -67,19 +67,19 @@ describe('bundled Nerd Font symbols face', () => {
|
|
|
67
67
|
// machine that has none — which is also what keeps the desktop from
|
|
68
68
|
// downloading it (its unicode-range is PUA-only, so it is never fetched
|
|
69
69
|
// when another family supplies the glyph).
|
|
70
|
-
expect(
|
|
71
|
-
|
|
70
|
+
expect(TERMINAL_FONT_FAMILY.indexOf(NERD_SYMBOLS_FAMILY)).toBeGreaterThan(
|
|
71
|
+
TERMINAL_FONT_FAMILY.indexOf('PowerlineSymbols'),
|
|
72
72
|
);
|
|
73
73
|
// Only the generic fallbacks may follow it.
|
|
74
|
-
const after =
|
|
74
|
+
const after = TERMINAL_FONT_FAMILY.slice(TERMINAL_FONT_FAMILY.indexOf(NERD_SYMBOLS_FAMILY));
|
|
75
75
|
expect(after).not.toMatch(/Nerd Font Mono'/);
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
test('every installed family is still offered before the bundled one', () => {
|
|
79
79
|
for (const family of ['FiraCode Nerd Font Mono', 'JetBrainsMono Nerd Font', 'Symbols Nerd Font Mono']) {
|
|
80
|
-
expect(
|
|
81
|
-
expect(
|
|
82
|
-
|
|
80
|
+
expect(TERMINAL_GLYPH_FALLBACKS).toContain(family);
|
|
81
|
+
expect(TERMINAL_FONT_FAMILY.indexOf(family)).toBeLessThan(
|
|
82
|
+
TERMINAL_FONT_FAMILY.indexOf(NERD_SYMBOLS_FAMILY),
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
85
|
});
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
|
|
27
27
|
import { describe, expect, test } from 'bun:test';
|
|
28
28
|
import {
|
|
29
|
+
aliasModelFor,
|
|
29
30
|
credentialFieldLabel,
|
|
30
31
|
credentialIsEnvName,
|
|
31
32
|
dialectChoices,
|
|
@@ -187,6 +188,32 @@ describe('providerEnv', () => {
|
|
|
187
188
|
]);
|
|
188
189
|
});
|
|
189
190
|
|
|
191
|
+
test('a versioned provider id is reduced to the id the endpoint expects', () => {
|
|
192
|
+
// The gateway's own list may spell the model provider-qualified; the env
|
|
193
|
+
// variable names the model, not the route.
|
|
194
|
+
expect(aliasModelFor('sonnet', ['kenari/claude-sonnet-5'])).toBe('claude-sonnet-5');
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test('an endpoint with no model of the family pins nothing', () => {
|
|
198
|
+
expect(aliasModelFor('opus', ['qwen3-8-27b:free', 'glm-5-3-flash'])).toBeNull();
|
|
199
|
+
expect(providerEnv('claude', { baseUrl: 'https://gw', apiKey: 'sk-1', models: ['qwen3-8-27b:free'] }))
|
|
200
|
+
.not.toHaveProperty('ANTHROPIC_DEFAULT_OPUS_MODEL');
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test('every alias the endpoint serves is pinned, and none it does not', () => {
|
|
204
|
+
// Measured on kenari: `sonnet` and `opus` are answered 400 as literal ids
|
|
205
|
+
// while their family ids complete. The list is the authority.
|
|
206
|
+
const env = providerEnv('claude', {
|
|
207
|
+
baseUrl: 'https://gw',
|
|
208
|
+
apiKey: 'sk-1',
|
|
209
|
+
models: ['claude-sonnet-5', 'claude-opus-5', 'deepseek-v4-pro'],
|
|
210
|
+
});
|
|
211
|
+
expect(env.ANTHROPIC_DEFAULT_SONNET_MODEL).toBe('claude-sonnet-5');
|
|
212
|
+
expect(env.ANTHROPIC_DEFAULT_OPUS_MODEL).toBe('claude-opus-5');
|
|
213
|
+
expect(env).not.toHaveProperty('ANTHROPIC_DEFAULT_HAIKU_MODEL');
|
|
214
|
+
expect(env).not.toHaveProperty('ANTHROPIC_DEFAULT_FABLE_MODEL');
|
|
215
|
+
});
|
|
216
|
+
|
|
190
217
|
test('a blank field writes no variable at all', () => {
|
|
191
218
|
// An empty env var is a real thing to set, so the form must not do it by
|
|
192
219
|
// accident.
|