@kabmo-labs/kabmo 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +679 -679
- package/dist/client/static/js/{index-ph0q59rs.js → index-jcr5twtp.js} +769 -767
- package/dist/client/static/js/index-z3w7n85q.css +1 -0
- package/package.json +1 -1
- package/src/client/components/common/Modal.tsx +2 -6
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +7 -1
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.test.tsx +20 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +23 -7
- package/src/client/components/layout/session-sidebar/about-modal/index.test.tsx +122 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +27 -11
- package/src/client/components/settings/categories/harness-settings/EnvProviderForm.tsx +31 -0
- package/src/client/components/settings/categories/harness-settings/provider-panel.test.tsx +49 -0
- package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +5 -2
- package/src/client/components/workspace/chat-timeline/MessageList.test.ts +14 -0
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/index.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/pending-harness.test.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +11 -20
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/GroupedAsk.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/drafts.ts +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -1
- package/src/client/components/workspace/file-explorer/index.test.ts +25 -0
- package/src/client/components/workspace/file-explorer/index.tsx +9 -3
- package/src/client/components/workspace/model-dropdown/harness-models.test.ts +17 -0
- package/src/client/components/workspace/model-dropdown/harness-models.ts +33 -18
- package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
- package/src/client/components/workspace/model-dropdown/popover-metrics.ts +4 -1
- package/src/client/data/settings/omp-schema.json +4 -4
- package/src/client/hooks/chat/timeline/actions.ts +2 -2
- package/src/client/hooks/chat/timeline/ask-frames.ts +5 -4
- package/src/client/hooks/chat/timeline/new-chat-open.test.ts +86 -0
- package/src/client/hooks/chat/timeline/new-chat-open.ts +23 -5
- package/src/client/hooks/chat/timeline/new-chat.test.ts +32 -4
- package/src/client/hooks/chat/timeline/new-chat.ts +18 -6
- package/src/client/hooks/chat/timeline/rewind-actions.test.ts +24 -1
- package/src/client/hooks/chat/timeline/rewind-actions.ts +15 -11
- package/src/client/hooks/chat/timeline/run-identity.test.ts +52 -0
- package/src/client/hooks/chat/timeline/run-identity.ts +23 -11
- package/src/client/hooks/chat/timeline/send-execute.test.ts +17 -0
- package/src/client/hooks/chat/timeline/send-props.ts +5 -3
- package/src/client/hooks/chat/timeline/send-steer.test.ts +1 -3
- package/src/client/hooks/chat/timeline/send.test-util.ts +1 -1
- package/src/client/hooks/chat/timeline/send.test.ts +1 -3
- package/src/client/hooks/chat/timeline/send.ts +8 -3
- package/src/client/hooks/chat/timeline/session-load.test-util.ts +6 -2
- package/src/client/hooks/chat/timeline/session-load.test.ts +31 -0
- package/src/client/hooks/chat/timeline/session-load.ts +6 -14
- package/src/client/hooks/chat/timeline/session-shapes.ts +32 -0
- package/src/client/hooks/models/harness-catalog.ts +114 -0
- package/src/client/hooks/models/provider-writes.test.ts +81 -0
- package/src/client/hooks/models/provider-writes.ts +10 -3
- package/src/client/hooks/models/use-harnesses-controller.ts +57 -0
- package/src/client/hooks/models/use-harnesses-signal.test.ts +128 -0
- package/src/client/hooks/models/use-harnesses.test.ts +2 -1
- package/src/client/hooks/models/use-harnesses.ts +48 -114
- package/src/client/tailwind.css +9 -1
- package/src/server/lib/harness/acp/activation.test.ts +81 -0
- package/src/server/lib/harness/acp/activation.ts +72 -0
- package/src/server/lib/harness/acp/frames.test.ts +50 -1
- package/src/server/lib/harness/acp/frames.ts +17 -5
- package/src/server/lib/harness/acp/mapper.ts +6 -4
- package/src/server/lib/harness/acp/session-config.test.ts +73 -0
- package/src/server/lib/harness/acp/session-config.ts +87 -6
- package/src/server/lib/harness/acp/session-handshake.ts +9 -2
- package/src/server/lib/harness/acp/session-idle.ts +51 -0
- package/src/server/lib/harness/acp/session-notifications.ts +19 -3
- package/src/server/lib/harness/acp/session-observers.test.ts +9 -0
- package/src/server/lib/harness/acp/session-options.ts +33 -0
- package/src/server/lib/harness/acp/session-reaper.test.ts +96 -0
- package/src/server/lib/harness/acp/session.test-util.ts +31 -2
- package/src/server/lib/harness/acp/session.test.ts +65 -3
- package/src/server/lib/harness/acp/session.ts +20 -20
- package/src/server/lib/harness/acp/turn.ts +31 -7
- package/src/server/lib/harness/auto-probe.server.test.ts +121 -0
- package/src/server/lib/harness/auto-probe.server.ts +178 -0
- package/src/server/lib/harness/config.server.test.ts +1 -1
- package/src/server/lib/harness/config.server.ts +1 -1
- package/src/server/lib/harness/launch-table.ts +195 -0
- package/src/server/lib/harness/launch.test.ts +37 -0
- package/src/server/lib/harness/launch.ts +13 -115
- package/src/server/lib/harness/provider-entry.ts +32 -0
- package/src/server/lib/harness/provider-file.server.ts +3 -0
- package/src/server/lib/harness/provider-sources.server.test.ts +45 -0
- package/src/server/lib/harness/provider-sources.server.ts +26 -2
- package/src/server/lib/harness/provider-write.server.ts +21 -32
- package/src/server/lib/harness/provider-zcode.server.test.ts +270 -0
- package/src/server/lib/harness/provider-zcode.server.ts +324 -0
- package/src/server/lib/harness/update-state.server.ts +15 -20
- package/src/server/lib/lifecycle/after-listen.ts +7 -0
- package/src/server/lib/models/registry-refresh.server.test.ts +87 -0
- package/src/server/lib/models/registry-refresh.server.ts +98 -0
- package/src/server/lib/omp/rpc/child-config.ts +5 -4
- package/src/server/lib/omp/rpc/constants.test.ts +2 -1
- package/src/server/lib/omp/rpc/forked-resume.test.ts +14 -3
- package/src/server/lib/omp/session/delete-flow.server.ts +15 -8
- package/src/server/lib/omp/session/delete.server.ts +12 -0
- package/src/server/routes/chat/rewind.test.ts +147 -0
- package/src/server/routes/chat/rewind.ts +29 -7
- package/src/server/routes/chat/session.test.ts +165 -10
- package/src/server/routes/chat/session.ts +60 -7
- package/src/server/routes/harness/import-action.ts +18 -4
- package/src/server/routes/harness/root.ts +8 -49
- package/src/server/routes/harness/toggle.test.ts +20 -0
- package/src/server/routes/harness/update.ts +49 -7
- package/src/server/routes/harness/versions.ts +5 -1
- package/src/server/routes/sessions/delete-acp.test.ts +227 -0
- package/src/server/routes/settings/model-override.ts +5 -2
- package/src/server/routes/settings/provider-entry.ts +2 -2
- package/src/server/routes/settings/provider-model.ts +2 -2
- package/src/server/routes/settings/provider-models.ts +2 -2
- package/src/server/routes/settings/provider-refresh.ts +6 -4
- package/src/server/routes/settings/providers.ts +3 -1
- package/src/server/routes/settings/settings-config-routes.test.ts +10 -2
- package/src/shared/lib/chat/ask-form/fields.ts +76 -0
- package/src/shared/lib/chat/ask-form/index.ts +323 -0
- package/src/shared/lib/chat/ask-form/tokens.ts +199 -0
- package/src/shared/lib/chat/ask-form/types.ts +43 -0
- package/src/shared/lib/chat/ask-form.test.ts +137 -0
- package/src/shared/lib/chat/ask-questions.test.ts +65 -1
- package/src/shared/lib/chat/ask-questions.ts +51 -145
- package/src/shared/lib/chat/ask-results.ts +198 -0
- package/src/shared/lib/chat/timeline/omp-callbacks.ts +13 -1
- package/src/shared/lib/chat/timeline/prompt-error.test.ts +146 -0
- package/src/shared/lib/chat/timeline/prompt-error.ts +88 -0
- package/src/shared/lib/harness/catalog.test.ts +1 -1
- package/src/shared/lib/harness/config-fields.test.ts +4 -0
- package/src/shared/lib/harness/config-fields.ts +19 -4
- package/src/shared/lib/harness/dialects.test.ts +8 -0
- package/src/shared/lib/harness/dialects.ts +12 -0
- package/src/shared/lib/harness/provider-facts.test.ts +32 -8
- package/src/shared/lib/harness/provider-facts.ts +46 -11
- package/src/shared/lib/harness/providers.ts +9 -0
- package/src/shared/lib/harness/rewind.ts +24 -0
- package/src/shared/lib/harness/update-plan.test.ts +51 -1
- package/src/shared/lib/harness/update-plan.ts +47 -7
- package/src/shared/lib/harness/updates.test.ts +22 -0
- package/src/shared/lib/harness/updates.ts +24 -1
- package/src/shared/lib/models/client.ts +10 -1
- package/src/shared/lib/omp/dialog-methods.ts +4 -3
- package/src/shared/lib/theme/css.ts +2 -0
- package/src/shared/lib/theme/ink-scale.ts +21 -1
- package/src/shared/lib/theme/theme.test.ts +25 -9
- package/src/shared/lib/ui/safe-area.test.ts +28 -0
- package/src/shared/lib/ui/safe-area.ts +42 -0
- package/src/shared/types/harness.ts +30 -4
- package/src/test-support/file-explorer-render.test-util.ts +37 -0
- package/src/test-support/file-explorer.test-util.ts +20 -18
- package/src/test-support/harness-table.test-util.ts +6 -3
- package/dist/client/static/js/index-jhmg4w91.css +0 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A config write must leave the session naming the model the agent is actually
|
|
8
|
+
* serving.
|
|
9
|
+
*
|
|
10
|
+
* The protocol says `session/set_config_option` replies with the complete list,
|
|
11
|
+
* and the agent's `currentValue` is authoritative (an alias or fallback may
|
|
12
|
+
* differ from the request). This suite pins the fallback for a harness that
|
|
13
|
+
* answers `{}` — the shape that left a chat's footer and sidebar row on the
|
|
14
|
+
* model from `session/new` for the rest of its life.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { describe, expect, test } from 'bun:test';
|
|
18
|
+
import { adoptConfigAnswer, adoptConfigList, publishConfigChange } from '@/server/lib/harness/acp/session-config';
|
|
19
|
+
import type { AcpConfigOption } from '@/server/lib/harness/acp/protocol';
|
|
20
|
+
|
|
21
|
+
const option = (id: string, category: string, currentValue: string, values: string[]): AcpConfigOption => ({
|
|
22
|
+
id,
|
|
23
|
+
category,
|
|
24
|
+
type: 'select',
|
|
25
|
+
currentValue,
|
|
26
|
+
options: values.map((value) => ({ value })),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const target = () => ({
|
|
30
|
+
harness: 'claude' as const,
|
|
31
|
+
configOptions: [option('sel-model', 'model', 'p/old', ['p/old', 'p/new'])],
|
|
32
|
+
runModel: { provider: 'p', modelId: 'old' },
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('ACP config adoption', () => {
|
|
36
|
+
test('a reply that omits the list adopts the value that was written', () => {
|
|
37
|
+
const session = target();
|
|
38
|
+
adoptConfigAnswer(session, {}, { configId: 'sel-model', value: 'p/new' });
|
|
39
|
+
expect(session.configOptions[0]?.currentValue).toBe('p/new');
|
|
40
|
+
expect(session.runModel).toEqual({ provider: 'p', modelId: 'new' });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('the agent’s resolved list wins over the request', () => {
|
|
44
|
+
const session = target();
|
|
45
|
+
adoptConfigAnswer(
|
|
46
|
+
session,
|
|
47
|
+
{ configOptions: [option('sel-model', 'model', 'p/resolved', ['p/old', 'p/new', 'p/resolved'])] },
|
|
48
|
+
{ configId: 'sel-model', value: 'p/new' },
|
|
49
|
+
);
|
|
50
|
+
expect(session.runModel).toEqual({ provider: 'p', modelId: 'resolved' });
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('the array-shaped value some harnesses publish keeps its provider', () => {
|
|
54
|
+
const session = target();
|
|
55
|
+
adoptConfigList(session, [option('sel-model', 'model', '["kenari","deepseek-v4-flash"]', ['["kenari","deepseek-v4-flash"]'])]);
|
|
56
|
+
expect(session.runModel).toEqual({ provider: 'kenari', modelId: 'deepseek-v4-flash' });
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('a pushed list announces the identity the client must re-read', () => {
|
|
60
|
+
const emitted: Array<Record<string, unknown> & { type: string }> = [];
|
|
61
|
+
const session = {
|
|
62
|
+
...target(),
|
|
63
|
+
sessionId: 's1',
|
|
64
|
+
isStreaming: false,
|
|
65
|
+
emit: (event: Record<string, unknown> & { type: string }) => {
|
|
66
|
+
emitted.push(event);
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
adoptConfigList(session, [option('sel-model', 'model', 'p/new', ['p/new'])]);
|
|
70
|
+
publishConfigChange(session);
|
|
71
|
+
expect(emitted).toContainEqual({ type: 'model_changed' });
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
* from this field, so a session that kept its own request would announce a model
|
|
17
17
|
* the answer did not come from.
|
|
18
18
|
*
|
|
19
|
+
* A harness that answers with no list is the exception: the write succeeded, so
|
|
20
|
+
* the requested value is adopted and a later `config_option_update` corrects it.
|
|
21
|
+
* Leaving the session on its `session/new` model made the footer and the sidebar
|
|
22
|
+
* row name the first model the chat ever picked for the rest of its life.
|
|
23
|
+
*
|
|
19
24
|
* ## Why every approval exit answers
|
|
20
25
|
*
|
|
21
26
|
* The agent is PARKED on `session/request_permission` until it hears back: a
|
|
@@ -27,7 +32,9 @@
|
|
|
27
32
|
import { configOption, modelFromOption } from '@/server/lib/harness/acp/prompt';
|
|
28
33
|
import type { AcpConfigOption } from '@/server/lib/harness/acp/protocol';
|
|
29
34
|
import type { PendingPermissions } from '@/server/lib/harness/acp/permissions';
|
|
35
|
+
import { markStreamModel } from '@/shared/lib/omp/session/stream-state.server';
|
|
30
36
|
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
37
|
+
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
31
38
|
|
|
32
39
|
/** The fields a config answer rewrites. */
|
|
33
40
|
export interface AcpConfigTarget {
|
|
@@ -36,14 +43,88 @@ export interface AcpConfigTarget {
|
|
|
36
43
|
runModel: { provider: string; modelId: string } | null;
|
|
37
44
|
}
|
|
38
45
|
|
|
39
|
-
/**
|
|
40
|
-
|
|
46
|
+
/** The target plus what publishing a change needs: a live run row to rename and
|
|
47
|
+
* a frame stream the client folds. */
|
|
48
|
+
export interface AcpConfigNotice extends AcpConfigTarget {
|
|
49
|
+
readonly sessionId: string;
|
|
50
|
+
readonly isStreaming: boolean;
|
|
51
|
+
emit(event: Record<string, unknown> & { type: string }): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Write the agent's COMPLETE config list into the session. */
|
|
55
|
+
export function adoptConfigList(target: AcpConfigTarget, options: AcpConfigOption[]): void {
|
|
56
|
+
target.configOptions = options;
|
|
57
|
+
const resolved = modelFromOption(configOption(options, 'model'), target.harness);
|
|
58
|
+
if (resolved) target.runModel = resolved;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Adopt `session/set_config_option`'s reply when it carries a config list. */
|
|
62
|
+
export function adoptConfigOptions(target: AcpConfigTarget, result: unknown): boolean {
|
|
41
63
|
if (!result || typeof result !== 'object' || !('configOptions' in result) || !Array.isArray(result.configOptions)) {
|
|
42
|
-
return;
|
|
64
|
+
return false;
|
|
43
65
|
}
|
|
44
|
-
target
|
|
45
|
-
|
|
46
|
-
|
|
66
|
+
adoptConfigList(target, result.configOptions as AcpConfigOption[]);
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Adopt a config WRITE even when the agent omitted the reply list.
|
|
72
|
+
*
|
|
73
|
+
* The protocol says the reply MUST carry the complete list, and every measured
|
|
74
|
+
* adapter does — but a harness that answers `{}` left the session naming the
|
|
75
|
+
* model from `session/new`, so the run footer and the sidebar row reported the
|
|
76
|
+
* first model the chat ever picked for the rest of its life. The write itself
|
|
77
|
+
* succeeded, so the requested value is the best state we have; a later
|
|
78
|
+
* `config_option_update` (or the next reply) replaces it with the agent's own.
|
|
79
|
+
*/
|
|
80
|
+
export function adoptConfigAnswer(
|
|
81
|
+
target: AcpConfigTarget,
|
|
82
|
+
result: unknown,
|
|
83
|
+
requested: { configId: string; value: string | boolean },
|
|
84
|
+
): void {
|
|
85
|
+
if (adoptConfigOptions(target, result)) return;
|
|
86
|
+
if (!target.configOptions.some((option) => option.id === requested.configId)) return;
|
|
87
|
+
adoptConfigList(
|
|
88
|
+
target,
|
|
89
|
+
target.configOptions.map((option) =>
|
|
90
|
+
option.id === requested.configId ? { ...option, currentValue: requested.value } : option,
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Announce a written config option on the session's own frame stream — the
|
|
97
|
+
* vocabulary omp already uses, so the client's existing `model_changed`
|
|
98
|
+
* handler refreshes the session metadata (and thus the footer/composer) with
|
|
99
|
+
* no second path. A live run row is renamed here too: a `set_model` can land
|
|
100
|
+
* while a turn is streaming, and the sidebar/indicator read that row, not
|
|
101
|
+
* `get_state`.
|
|
102
|
+
*/
|
|
103
|
+
export function publishConfigChange(target: AcpConfigNotice, configId?: string): void {
|
|
104
|
+
if (target.runModel && target.isStreaming) {
|
|
105
|
+
void markStreamModel(target.sessionId, target.runModel).catch(() => {});
|
|
106
|
+
}
|
|
107
|
+
const written = configId ? target.configOptions.find((option) => option.id === configId) : null;
|
|
108
|
+
// No id means the agent pushed a fresh list (`config_option_update`): any of
|
|
109
|
+
// its selectors may have moved, so name both known identities.
|
|
110
|
+
if (!written || written.category === 'model') {
|
|
111
|
+
if (target.runModel) target.emit({ type: 'model_changed' });
|
|
112
|
+
}
|
|
113
|
+
const thinking = configOption(target.configOptions, 'thought_level');
|
|
114
|
+
if ((!written || written.category === 'thought_level') && typeof thinking?.currentValue === 'string') {
|
|
115
|
+
target.emit({ type: 'thinking_level_changed', thinkingLevel: thinking.currentValue });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The model fields the footer/indicator read, or the frame unchanged. */
|
|
120
|
+
export function stampMessageModel(event: AgentEvent, model: { provider: string; modelId: string } | null): AgentEvent {
|
|
121
|
+
if (!model) return event;
|
|
122
|
+
if (event.type !== 'message_update' && event.type !== 'message_end') return event;
|
|
123
|
+
if (!event.message || typeof event.message !== 'object') return event;
|
|
124
|
+
return {
|
|
125
|
+
...event,
|
|
126
|
+
message: { ...event.message, model: model.modelId, provider: model.provider },
|
|
127
|
+
};
|
|
47
128
|
}
|
|
48
129
|
|
|
49
130
|
/** The process slice answering a dialog needs; `AcpProcess` satisfies it. */
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* string as the model id — which is what the generating indicator names.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
+
import { newSessionAfterActivation } from '@/server/lib/harness/acp/activation';
|
|
27
28
|
import { applySelections, configOption, modelFromOption } from '@/server/lib/harness/acp/prompt';
|
|
28
29
|
import { capabilitiesFrom } from '@/server/lib/harness/launch';
|
|
29
30
|
import type {
|
|
@@ -66,13 +67,19 @@ export async function handshakeAcpSession(
|
|
|
66
67
|
sessionIdToLoad?: string,
|
|
67
68
|
): Promise<void> {
|
|
68
69
|
const init = await proc.initialize({}, 60_000);
|
|
70
|
+
/** opencode's plugin activation gate: the first `session/new`s refuse with
|
|
71
|
+
* `ServiceUnavailableError` until the agent's plugins finish booting. */
|
|
72
|
+
const newSession = (cwd: string, timeoutMs?: number) =>
|
|
73
|
+
newSessionAfterActivation(target.harness, cwd, (dir, ms) => proc.newSession(dir, ms), {
|
|
74
|
+
...(timeoutMs !== undefined ? { perAttemptMs: timeoutMs } : {}),
|
|
75
|
+
});
|
|
69
76
|
let session: AcpSessionNewResult;
|
|
70
77
|
if (sessionIdToLoad) {
|
|
71
78
|
await proc.loadSession(sessionIdToLoad, target.cwd, 120_000);
|
|
72
|
-
const reloaded = await
|
|
79
|
+
const reloaded = await newSession(target.cwd).catch(() => null);
|
|
73
80
|
session = reloaded ?? { sessionId: sessionIdToLoad };
|
|
74
81
|
} else {
|
|
75
|
-
session = await
|
|
82
|
+
session = await newSession(target.cwd, 120_000);
|
|
76
83
|
}
|
|
77
84
|
target.sessionId = session.sessionId || sessionIdToLoad || '';
|
|
78
85
|
target.configOptions = session.configOptions ?? [];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The idle reclaim for one ACP child.
|
|
8
|
+
*
|
|
9
|
+
* The omp wrapper has always reclaimed an idle `omp --mode rpc-ui` child; this
|
|
10
|
+
* transport had no clock at all, so an `omp acp` (or any ACP adapter) outlived
|
|
11
|
+
* the tab that spawned it by hours — measured: a live `omp acp` from a chat the
|
|
12
|
+
* user had not touched since the morning. The clock itself is `IdleReaper`,
|
|
13
|
+
* shared so both transports release an idle agent after the same window, and
|
|
14
|
+
* the decision is here because only the session can answer "is this still
|
|
15
|
+
* wanted?".
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { IdleReaper } from '@/server/lib/omp/rpc/idle-reaper';
|
|
19
|
+
import { IDLE_REAP_MS } from '@/server/lib/omp/rpc/constants';
|
|
20
|
+
import type { HarnessCapabilities } from '@/server/lib/harness/capabilities';
|
|
21
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
22
|
+
|
|
23
|
+
/** What the reclaim decision reads; `AcpSession` satisfies it as-is. */
|
|
24
|
+
export interface AcpIdleHost {
|
|
25
|
+
readonly harness: HarnessId;
|
|
26
|
+
readonly capabilities: HarnessCapabilities;
|
|
27
|
+
isBusy(): boolean;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A working or dialog-blocked session is never reclaimed (the child would take
|
|
33
|
+
* the user's question with it), and the answer is `false` so `IdleReaper`
|
|
34
|
+
* re-arms instead of waiting for a frame that a parked dialog will not send.
|
|
35
|
+
*
|
|
36
|
+
* A child that cannot be restored is also left alone: a non-`session/load`
|
|
37
|
+
* agent has no way back, and `resumeRecordedHarnessSession` refuses to spawn a
|
|
38
|
+
* fresh agent under a chat's id, so reclaiming one would leave a chat that can
|
|
39
|
+
* never take another prompt. `omp-acp` is the exception — it writes a session
|
|
40
|
+
* file, so the chat is restored over RPC.
|
|
41
|
+
*/
|
|
42
|
+
export function reclaimIdleAcpSession(host: AcpIdleHost): boolean {
|
|
43
|
+
if (host.isBusy()) return false;
|
|
44
|
+
if (!host.capabilities.loadSession && host.harness !== 'omp-acp') return true;
|
|
45
|
+
host.destroy();
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function acpIdleReaper(host: AcpIdleHost, timeoutMs?: number): IdleReaper {
|
|
50
|
+
return new IdleReaper(timeoutMs ?? IDLE_REAP_MS, () => reclaimIdleAcpSession(host));
|
|
51
|
+
}
|
|
@@ -20,9 +20,17 @@ import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
|
20
20
|
import type { HarnessCapabilities } from '@/server/lib/harness/capabilities';
|
|
21
21
|
import { noteAgentTitle } from '@/server/lib/harness/session-title.server';
|
|
22
22
|
import { metadataCapabilities, parseAgentCommands, type AgentCommand } from '@/server/lib/harness/acp/session-facts';
|
|
23
|
+
import {
|
|
24
|
+
adoptConfigList,
|
|
25
|
+
publishConfigChange,
|
|
26
|
+
stampMessageModel,
|
|
27
|
+
type AcpConfigNotice,
|
|
28
|
+
} from '@/server/lib/harness/acp/session-config';
|
|
29
|
+
import type { AcpConfigOption } from '@/server/lib/harness/acp/protocol';
|
|
30
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
23
31
|
|
|
24
|
-
export interface AcpNotificationHost {
|
|
25
|
-
readonly
|
|
32
|
+
export interface AcpNotificationHost extends AcpConfigNotice {
|
|
33
|
+
readonly harness: HarnessId;
|
|
26
34
|
agentCommands: AgentCommand[];
|
|
27
35
|
planEntries: unknown[];
|
|
28
36
|
capabilities: HarnessCapabilities;
|
|
@@ -63,6 +71,14 @@ export function handleSessionNotification(
|
|
|
63
71
|
if (kind === 'session_info_update' && typeof record.title === 'string' && host.sessionId) {
|
|
64
72
|
void noteAgentTitle(host.sessionId, record.title);
|
|
65
73
|
}
|
|
74
|
+
// The agent can move a selector itself (a fallback, a dependent option after a
|
|
75
|
+
// model switch). Its list is authoritative and arrives between turns, so it
|
|
76
|
+
// is adopted BEFORE the turn gate below — the session, telemetry and the goal
|
|
77
|
+
// audit must read the same model the client's `config_option_update` names.
|
|
78
|
+
if (kind === 'config_option_update' && Array.isArray(record.configOptions)) {
|
|
79
|
+
adoptConfigList(host, record.configOptions as AcpConfigOption[]);
|
|
80
|
+
publishConfigChange(host);
|
|
81
|
+
}
|
|
66
82
|
|
|
67
83
|
// No turn open: the user stopped it (or one is still queued), and anything
|
|
68
84
|
// the agent keeps emitting belongs to work nobody is watching. Forwarding it
|
|
@@ -70,7 +86,7 @@ export function handleSessionNotification(
|
|
|
70
86
|
// a transcript the client had already finalized.
|
|
71
87
|
if (!host.acceptingFrames()) return;
|
|
72
88
|
for (const event of host.mapUpdate(record)) {
|
|
73
|
-
host.emit(event);
|
|
89
|
+
host.emit(stampMessageModel(event, host.runModel));
|
|
74
90
|
if (event.type === 'message_end') {
|
|
75
91
|
host.messageCount += 1;
|
|
76
92
|
host.assistantCount += 1;
|
|
@@ -53,6 +53,15 @@ describe('ACP silent turn', () => {
|
|
|
53
53
|
expect(error).toMatchObject({ errorMessage: 'The agent ended the turn without sending an answer' });
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
+
test('a whitespace-only chunk is the same silent failure', async () => {
|
|
57
|
+
// The row renders no text, so a frame that carries only spaces looks exactly
|
|
58
|
+
// like an empty bubble — reporting it is the only way the operator learns
|
|
59
|
+
// the turn failed.
|
|
60
|
+
const events = await finishWith('Say DUMMY_OK', ' \n ');
|
|
61
|
+
const error = events.find((event) => event.type === 'prompt_error');
|
|
62
|
+
expect(error).toMatchObject({ errorMessage: 'The agent ended the turn without sending an answer' });
|
|
63
|
+
});
|
|
64
|
+
|
|
56
65
|
test('an answered turn reports no error', async () => {
|
|
57
66
|
const events = await finishWith('Say DUMMY_OK', 'DUMMY_OK');
|
|
58
67
|
expect(events.some((event) => event.type === 'prompt_error')).toBe(false);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How one ACP session is spawned.
|
|
8
|
+
*
|
|
9
|
+
* Its own module because the type is the transport's spawn contract, read by
|
|
10
|
+
* `AcpSession` and handed to it by both callers (`spawn.server.ts` for a chat,
|
|
11
|
+
* `acp-audit.server.ts` for a disposable reader); keeping it in `session.ts`
|
|
12
|
+
* made that file carry a second responsibility past its size ceiling.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
|
|
16
|
+
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
17
|
+
|
|
18
|
+
export interface AcpSessionOptions {
|
|
19
|
+
harness: HarnessId;
|
|
20
|
+
command: string[];
|
|
21
|
+
env?: Record<string, string>;
|
|
22
|
+
/** Provider/model this session starts on, applied with
|
|
23
|
+
* `session/set_config_option` right after `session/new`. */
|
|
24
|
+
model?: { provider: string; modelId: string } | null;
|
|
25
|
+
thinkingLevel?: string | null;
|
|
26
|
+
mode?: string | null;
|
|
27
|
+
/** The composer's access pick. ACP has no spawn flag for it, so the session
|
|
28
|
+
* answers `session/request_permission` itself according to this tier. */
|
|
29
|
+
accessMode?: ApprovalMode | null;
|
|
30
|
+
/** Quiet window before the child is reclaimed; defaults to the omp window so
|
|
31
|
+
* both transports release an idle agent after the same time. */
|
|
32
|
+
idleDestroyMs?: number;
|
|
33
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The ACP idle reclaim.
|
|
8
|
+
*
|
|
9
|
+
* `omp acp` children used to outlive the tab that spawned them by hours: unlike
|
|
10
|
+
* the omp wrapper, this transport had no idle clock, and nothing else ends a
|
|
11
|
+
* child it is not actively driving. These cases pin the two halves of the fix —
|
|
12
|
+
* the decision (never reclaim a working or dialog-blocked session) and the
|
|
13
|
+
* wiring (commands and frames defer the deadline; a destroy stops it).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { describe, expect, test } from 'bun:test';
|
|
17
|
+
|
|
18
|
+
import { reclaimIdleAcpSession } from '@/server/lib/harness/acp/session-idle';
|
|
19
|
+
import { UNPROBED_CAPABILITIES } from '@/server/lib/harness/capabilities';
|
|
20
|
+
import { mountSession, notify } from '@/server/lib/harness/acp/session.test-util';
|
|
21
|
+
|
|
22
|
+
describe('ACP idle reclaim decision', () => {
|
|
23
|
+
const restorable = { ...UNPROBED_CAPABILITIES, loadSession: true };
|
|
24
|
+
|
|
25
|
+
test('an idle restorable session is destroyed', () => {
|
|
26
|
+
let destroyed = 0;
|
|
27
|
+
const reclaimed = reclaimIdleAcpSession({
|
|
28
|
+
harness: 'claude',
|
|
29
|
+
capabilities: { ...restorable },
|
|
30
|
+
isBusy: () => false,
|
|
31
|
+
destroy: () => { destroyed += 1; },
|
|
32
|
+
});
|
|
33
|
+
expect(reclaimed).toBe(true);
|
|
34
|
+
expect(destroyed).toBe(1);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('a busy session survives and the clock re-arms instead', () => {
|
|
38
|
+
let destroyed = 0;
|
|
39
|
+
const reclaimed = reclaimIdleAcpSession({
|
|
40
|
+
harness: 'claude',
|
|
41
|
+
capabilities: { ...restorable },
|
|
42
|
+
isBusy: () => true,
|
|
43
|
+
destroy: () => { destroyed += 1; },
|
|
44
|
+
});
|
|
45
|
+
// `false` is what makes `IdleReaper` re-arm from now: answering `true`
|
|
46
|
+
// would let it fire again on an unchanged session.
|
|
47
|
+
expect(reclaimed).toBe(false);
|
|
48
|
+
expect(destroyed).toBe(0);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('an idle session whose agent cannot session/load is left alive', () => {
|
|
52
|
+
// There is no way back: `resumeRecordedHarnessSession` refuses to spawn a
|
|
53
|
+
// fresh agent under the chat's id, so reclaiming would strand the chat.
|
|
54
|
+
let destroyed = 0;
|
|
55
|
+
reclaimIdleAcpSession({
|
|
56
|
+
harness: 'dsh',
|
|
57
|
+
capabilities: { ...UNPROBED_CAPABILITIES, loadSession: false },
|
|
58
|
+
isBusy: () => false,
|
|
59
|
+
destroy: () => { destroyed += 1; },
|
|
60
|
+
});
|
|
61
|
+
expect(destroyed).toBe(0);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
test('omp-acp is reclaimed even without loadSession, because its session file restores it', () => {
|
|
65
|
+
let destroyed = 0;
|
|
66
|
+
reclaimIdleAcpSession({
|
|
67
|
+
harness: 'omp-acp',
|
|
68
|
+
capabilities: { ...UNPROBED_CAPABILITIES, loadSession: false },
|
|
69
|
+
isBusy: () => false,
|
|
70
|
+
destroy: () => { destroyed += 1; },
|
|
71
|
+
});
|
|
72
|
+
expect(destroyed).toBe(1);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('ACP idle reclaim wiring', () => {
|
|
77
|
+
test('a dispatched command defers the deadline', async () => {
|
|
78
|
+
const { session, turn, idleResets } = mountSession();
|
|
79
|
+
expect(idleResets()).toBe(0);
|
|
80
|
+
await session.send({ type: 'get_state' });
|
|
81
|
+
expect(idleResets()).toBe(1);
|
|
82
|
+
turn.finish({ stopReason: 'end_turn' });
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('a frame defers the deadline', () => {
|
|
86
|
+
const { session, idleResets } = mountSession();
|
|
87
|
+
notify(session, { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: 'hi' } });
|
|
88
|
+
expect(idleResets()).toBe(1);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('destroy stops the clock', async () => {
|
|
92
|
+
const { session, idleStopped } = mountSession();
|
|
93
|
+
await session.destroyAndWait();
|
|
94
|
+
expect(idleStopped()).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
@@ -23,6 +23,7 @@ import { AcpUsageMeter } from '@/server/lib/harness/acp/session-usage';
|
|
|
23
23
|
import { AcpFrameMapper } from '@/server/lib/harness/acp/frames';
|
|
24
24
|
import { AcpTurns } from '@/server/lib/harness/acp/turn';
|
|
25
25
|
import { PendingPermissions } from '@/server/lib/harness/acp/permissions';
|
|
26
|
+
import { stampMessageModel } from '@/server/lib/harness/acp/session-config';
|
|
26
27
|
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
27
28
|
|
|
28
29
|
export interface Turn {
|
|
@@ -45,6 +46,10 @@ export interface MountedSession {
|
|
|
45
46
|
turnEnds: () => number;
|
|
46
47
|
/** The durable run markers written for this session, in order. */
|
|
47
48
|
streamMarks: () => string[];
|
|
49
|
+
/** How many times a command or frame deferred the idle reclaim. */
|
|
50
|
+
idleResets: () => number;
|
|
51
|
+
/** Whether a destroy stopped the reclaim clock. */
|
|
52
|
+
idleStopped: () => boolean;
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
/** One in-flight `session/prompt` the stub can settle. */
|
|
@@ -68,6 +73,17 @@ export function mountSession(): MountedSession {
|
|
|
68
73
|
const session = Object.create(AcpSession.prototype) as AcpSession;
|
|
69
74
|
const mapper = new AcpFrameMapper();
|
|
70
75
|
let turnEndCount = 0;
|
|
76
|
+
let idleResets = 0;
|
|
77
|
+
let idleStopped = false;
|
|
78
|
+
const idle = {
|
|
79
|
+
timeoutMs: 0,
|
|
80
|
+
reset: () => {
|
|
81
|
+
idleResets += 1;
|
|
82
|
+
},
|
|
83
|
+
stop: () => {
|
|
84
|
+
idleStopped = true;
|
|
85
|
+
},
|
|
86
|
+
};
|
|
71
87
|
const proc = {
|
|
72
88
|
prompt: async (_message: string, _images: unknown) => {
|
|
73
89
|
const pending = Promise.withResolvers<unknown>();
|
|
@@ -77,6 +93,10 @@ export function mountSession(): MountedSession {
|
|
|
77
93
|
},
|
|
78
94
|
cancel: () => {},
|
|
79
95
|
abandonPrompt: () => calls.at(-1)?.resolve({ stopReason: 'cancelled' }),
|
|
96
|
+
// A config write; the default reply omits the list, which is the shape a
|
|
97
|
+
// harness that ignores the protocol's "complete list" rule returns.
|
|
98
|
+
setConfigOption: async (_sessionId: string, _configId: string, _value: string | boolean) => ({}),
|
|
99
|
+
dispose: async () => {},
|
|
80
100
|
isAlive: true,
|
|
81
101
|
};
|
|
82
102
|
const turns = new AcpTurns({
|
|
@@ -85,7 +105,7 @@ export function mountSession(): MountedSession {
|
|
|
85
105
|
cancelAgent: () => proc.cancel(),
|
|
86
106
|
abandonPrompt: () => proc.abandonPrompt(),
|
|
87
107
|
resetMapper: () => mapper.reset(),
|
|
88
|
-
closeMessage: () => mapper.closeMessage(),
|
|
108
|
+
closeMessage: () => mapper.closeMessage().map((event) => stampMessageModel(event, session.runModel)),
|
|
89
109
|
openCalls: () => mapper.openCalls(),
|
|
90
110
|
onTurnEnd: (info) => {
|
|
91
111
|
(session as unknown as { onTurnEnded: (info: { stopReason?: string; closedMessage: boolean }) => void })
|
|
@@ -116,9 +136,18 @@ export function mountSession(): MountedSession {
|
|
|
116
136
|
runModel: null,
|
|
117
137
|
listeners: new Set<(event: AgentEvent) => void>([(event) => events.push(event)]),
|
|
118
138
|
proc,
|
|
139
|
+
idle,
|
|
119
140
|
destroyed: false,
|
|
120
141
|
});
|
|
121
|
-
return {
|
|
142
|
+
return {
|
|
143
|
+
session,
|
|
144
|
+
events,
|
|
145
|
+
turn,
|
|
146
|
+
turnEnds: () => turnEndCount,
|
|
147
|
+
streamMarks: () => marks,
|
|
148
|
+
idleResets: () => idleResets,
|
|
149
|
+
idleStopped: () => idleStopped,
|
|
150
|
+
};
|
|
122
151
|
}
|
|
123
152
|
|
|
124
153
|
/** Push one `session/update` at the session, as the process would. */
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
15
15
|
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
16
|
-
import { mountSession } from '@/server/lib/harness/acp/session.test-util';
|
|
16
|
+
import { mountSession, notify } from '@/server/lib/harness/acp/session.test-util';
|
|
17
|
+
import type { AcpConfigOption } from '@/server/lib/harness/acp/protocol';
|
|
17
18
|
|
|
18
19
|
// A prompt reaches the title writer (`harness/session-title.server.ts`), which
|
|
19
20
|
// opens the database. Isolate it: the handle is process-wide, and a suite that
|
|
@@ -52,13 +53,16 @@ describe('ACP prompt dispatch', () => {
|
|
|
52
53
|
expect(session.isPromptRunning).toBe(false);
|
|
53
54
|
});
|
|
54
55
|
|
|
55
|
-
test('a failed turn reports its error and still closes the turn', async () => {
|
|
56
|
+
test('a failed turn reports its error once, and still closes the turn', async () => {
|
|
56
57
|
const { session, events, turn } = mountSession();
|
|
57
58
|
await session.send({ type: 'prompt', message: 'hello' });
|
|
58
59
|
await turn.started;
|
|
59
60
|
turn.fail(new Error('agent exploded'));
|
|
60
61
|
for (let i = 0; i < 4; i += 1) await Promise.resolve();
|
|
61
|
-
|
|
62
|
+
const errors = events.filter((event) => event.type === 'prompt_error');
|
|
63
|
+
// The generic "no answer" verdict must not land on top of the agent's own
|
|
64
|
+
// reason: it was emitted SECOND, so the client kept the useless one.
|
|
65
|
+
expect(errors).toEqual([{ type: 'prompt_error', errorMessage: 'agent exploded' }]);
|
|
62
66
|
expect(session.isPromptRunning).toBe(false);
|
|
63
67
|
});
|
|
64
68
|
|
|
@@ -169,3 +173,61 @@ describe('ACP turn serialization', () => {
|
|
|
169
173
|
expect(session.isRunning()).toBe(false);
|
|
170
174
|
});
|
|
171
175
|
});
|
|
176
|
+
|
|
177
|
+
const modelOption = (currentValue: string, values: string[]): AcpConfigOption => ({
|
|
178
|
+
id: 'sel-model',
|
|
179
|
+
category: 'model',
|
|
180
|
+
type: 'select',
|
|
181
|
+
currentValue,
|
|
182
|
+
options: values.map((value) => ({ value })),
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* The footer and the sidebar name a chat by the model the live session is
|
|
187
|
+
* serving. An ACP model pick is a config write, not a respawn, so the identity
|
|
188
|
+
* has to travel three ways: the session's own `runModel`, a frame the client
|
|
189
|
+
* re-reads, and the model fields on the message itself.
|
|
190
|
+
*/
|
|
191
|
+
describe('ACP model identity', () => {
|
|
192
|
+
test('set_model without a reply list still renames the session and announces it', async () => {
|
|
193
|
+
const { session, events } = mountSession();
|
|
194
|
+
session.configOptions = [modelOption('p/old', ['p/old', 'p/new'])];
|
|
195
|
+
session.runModel = { provider: 'p', modelId: 'old' };
|
|
196
|
+
|
|
197
|
+
await session.send({ type: 'set_model', provider: 'p', modelId: 'new' });
|
|
198
|
+
|
|
199
|
+
expect(session.runModel).toEqual({ provider: 'p', modelId: 'new' });
|
|
200
|
+
expect(events.some((event) => event.type === 'model_changed')).toBe(true);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test('config_option_update adopts the agent’s list and announces it', () => {
|
|
204
|
+
const { session, events } = mountSession();
|
|
205
|
+
session.configOptions = [modelOption('p/old', ['p/old'])];
|
|
206
|
+
session.runModel = { provider: 'p', modelId: 'old' };
|
|
207
|
+
|
|
208
|
+
notify(session, { sessionUpdate: 'config_option_update', configOptions: [modelOption('p/next', ['p/old', 'p/next'])] });
|
|
209
|
+
|
|
210
|
+
expect(session.runModel).toEqual({ provider: 'p', modelId: 'next' });
|
|
211
|
+
expect(events.some((event) => event.type === 'model_changed')).toBe(true);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test('assistant frames carry the model that served them', async () => {
|
|
215
|
+
const { session, events, turn } = mountSession();
|
|
216
|
+
session.runModel = { provider: 'kenari', modelId: 'qwen3-8-27b:free' };
|
|
217
|
+
await session.send({ type: 'prompt', message: 'hi' });
|
|
218
|
+
await turn.started;
|
|
219
|
+
|
|
220
|
+
notify(session, { sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: 'hi' } });
|
|
221
|
+
expect(events.find((event) => event.type === 'message_update')?.message).toMatchObject({
|
|
222
|
+
model: 'qwen3-8-27b:free',
|
|
223
|
+
provider: 'kenari',
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
turn.finish({ stopReason: 'end_turn' });
|
|
227
|
+
for (let i = 0; i < 8; i += 1) await Promise.resolve();
|
|
228
|
+
expect(events.find((event) => event.type === 'message_end')?.message).toMatchObject({
|
|
229
|
+
model: 'qwen3-8-27b:free',
|
|
230
|
+
provider: 'kenari',
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|