@roj-ai/sdk 0.1.34 → 0.1.36
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/bootstrap.d.ts +36 -0
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/core/agents/agent.d.ts +11 -0
- package/dist/core/agents/agent.d.ts.map +1 -1
- package/dist/core/agents/agent.js +26 -5
- package/dist/core/agents/agent.js.map +1 -1
- package/dist/core/agents/state.d.ts +24 -0
- package/dist/core/agents/state.d.ts.map +1 -1
- package/dist/core/agents/state.js.map +1 -1
- package/dist/core/context/state.d.ts.map +1 -1
- package/dist/core/context/state.js +4 -0
- package/dist/core/context/state.js.map +1 -1
- package/dist/core/llm/anthropic.d.ts.map +1 -1
- package/dist/core/llm/anthropic.js +49 -8
- package/dist/core/llm/anthropic.js.map +1 -1
- package/dist/core/llm/model-shortlist-live.test.d.ts +35 -0
- package/dist/core/llm/model-shortlist-live.test.d.ts.map +1 -0
- package/dist/core/llm/model-shortlist-live.test.js +452 -0
- package/dist/core/llm/model-shortlist-live.test.js.map +1 -0
- package/dist/core/llm/openrouter-mapping.test.js +18 -0
- package/dist/core/llm/openrouter-mapping.test.js.map +1 -1
- package/dist/core/llm/openrouter.d.ts.map +1 -1
- package/dist/core/llm/openrouter.js +20 -11
- package/dist/core/llm/openrouter.js.map +1 -1
- package/dist/core/llm/provider.d.ts +34 -3
- package/dist/core/llm/provider.d.ts.map +1 -1
- package/dist/core/llm/provider.js.map +1 -1
- package/dist/core/llm/reasoning-details.test.d.ts +2 -0
- package/dist/core/llm/reasoning-details.test.d.ts.map +1 -0
- package/dist/core/llm/reasoning-details.test.js +144 -0
- package/dist/core/llm/reasoning-details.test.js.map +1 -0
- package/dist/core/llm/state.d.ts +2 -0
- package/dist/core/llm/state.d.ts.map +1 -1
- package/dist/core/llm/state.js +11 -0
- package/dist/core/llm/state.js.map +1 -1
- package/dist/core/llm/thinking-blocks.test.d.ts +2 -0
- package/dist/core/llm/thinking-blocks.test.d.ts.map +1 -0
- package/dist/core/llm/thinking-blocks.test.js +291 -0
- package/dist/core/llm/thinking-blocks.test.js.map +1 -0
- package/dist/core/preset/index.d.ts +1 -0
- package/dist/core/preset/index.d.ts.map +1 -1
- package/dist/core/preset/index.js +2 -0
- package/dist/core/preset/index.js.map +1 -1
- package/dist/core/preset/overrides.d.ts +14 -0
- package/dist/core/preset/overrides.d.ts.map +1 -0
- package/dist/core/preset/overrides.js +20 -0
- package/dist/core/preset/overrides.js.map +1 -0
- package/dist/core/reasoning-round-trip.integration.test.d.ts +2 -0
- package/dist/core/reasoning-round-trip.integration.test.d.ts.map +1 -0
- package/dist/core/reasoning-round-trip.integration.test.js +150 -0
- package/dist/core/reasoning-round-trip.integration.test.js.map +1 -0
- package/dist/core/sessions/session-manager.d.ts +2 -0
- package/dist/core/sessions/session-manager.d.ts.map +1 -1
- package/dist/core/sessions/session-manager.js +17 -5
- package/dist/core/sessions/session-manager.js.map +1 -1
- package/dist/core/sessions/session-overrides.integration.test.d.ts +2 -0
- package/dist/core/sessions/session-overrides.integration.test.d.ts.map +1 -0
- package/dist/core/sessions/session-overrides.integration.test.js +154 -0
- package/dist/core/sessions/session-overrides.integration.test.js.map +1 -0
- package/dist/core/sessions/session.d.ts +10 -1
- package/dist/core/sessions/session.d.ts.map +1 -1
- package/dist/core/sessions/session.js +15 -0
- package/dist/core/sessions/session.js.map +1 -1
- package/dist/core/sessions/state.d.ts +57 -0
- package/dist/core/sessions/state.d.ts.map +1 -1
- package/dist/core/sessions/state.js +53 -0
- package/dist/core/sessions/state.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/services/plugin.d.ts +3 -0
- package/dist/plugins/services/plugin.d.ts.map +1 -1
- package/dist/plugins/services/plugin.js +50 -14
- package/dist/plugins/services/plugin.js.map +1 -1
- package/dist/plugins/services/prompt.d.ts.map +1 -1
- package/dist/plugins/services/prompt.js +8 -0
- package/dist/plugins/services/prompt.js.map +1 -1
- package/dist/plugins/services/schema.d.ts +33 -0
- package/dist/plugins/services/schema.d.ts.map +1 -1
- package/dist/plugins/services/service.d.ts +20 -0
- package/dist/plugins/services/service.d.ts.map +1 -1
- package/dist/plugins/services/service.js +88 -1
- package/dist/plugins/services/service.js.map +1 -1
- package/dist/plugins/services/services.integration.test.js +254 -0
- package/dist/plugins/services/services.integration.test.js.map +1 -1
- package/dist/plugins/session-lifecycle/plugin.d.ts +36 -0
- package/dist/plugins/session-lifecycle/plugin.d.ts.map +1 -1
- package/dist/plugins/session-lifecycle/plugin.js +53 -1
- package/dist/plugins/session-lifecycle/plugin.js.map +1 -1
- package/dist/testing/test-harness.d.ts +12 -2
- package/dist/testing/test-harness.d.ts.map +1 -1
- package/dist/testing/test-harness.js +13 -2
- package/dist/testing/test-harness.js.map +1 -1
- package/package.json +3 -3
- package/src/core/agents/agent.ts +28 -5
- package/src/core/agents/state.ts +26 -0
- package/src/core/context/state.ts +4 -0
- package/src/core/llm/anthropic.ts +71 -10
- package/src/core/llm/model-shortlist-live.test.ts +577 -0
- package/src/core/llm/openrouter-mapping.test.ts +24 -0
- package/src/core/llm/openrouter.ts +28 -12
- package/src/core/llm/provider.ts +44 -3
- package/src/core/llm/reasoning-details.test.ts +177 -0
- package/src/core/llm/state.ts +12 -0
- package/src/core/llm/thinking-blocks.test.ts +345 -0
- package/src/core/preset/index.ts +3 -0
- package/src/core/preset/overrides.ts +24 -0
- package/src/core/reasoning-round-trip.integration.test.ts +188 -0
- package/src/core/sessions/session-manager.ts +22 -3
- package/src/core/sessions/session-overrides.integration.test.ts +210 -0
- package/src/core/sessions/session.ts +19 -1
- package/src/core/sessions/state.ts +82 -0
- package/src/index.ts +9 -1
- package/src/plugins/services/plugin.ts +50 -14
- package/src/plugins/services/prompt.ts +8 -0
- package/src/plugins/services/schema.ts +33 -0
- package/src/plugins/services/service.ts +113 -1
- package/src/plugins/services/services.integration.test.ts +270 -0
- package/src/plugins/session-lifecycle/plugin.ts +59 -1
- package/src/testing/test-harness.ts +22 -3
|
@@ -1,21 +1,46 @@
|
|
|
1
1
|
import { ToolCallId } from '../../core/tools/schema.js';
|
|
2
2
|
import { Err, Ok } from '../../lib/utils/result.js';
|
|
3
3
|
import { ProviderMessageValidationError, sanitizeProviderMessages } from './message-sanitization.js';
|
|
4
|
+
const isThinkingBlock = (block) => block.type === 'thinking' || block.type === 'redacted_thinking';
|
|
4
5
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Narrow a stored block back to a thinking block on the way out.
|
|
7
|
+
*
|
|
8
|
+
* `AssistantLLMMessage.thinkingBlocks` is `unknown[]` — the domain layer does not model
|
|
9
|
+
* provider shapes. This provider wrote those blocks, so it is entitled to recognise them,
|
|
10
|
+
* but it validates every field it declares rather than assuming. Anything else the API
|
|
11
|
+
* added travels along untouched, because the block is passed by reference and never rebuilt.
|
|
12
|
+
*/
|
|
13
|
+
const isEchoableThinkingBlock = (value) => {
|
|
14
|
+
if (typeof value !== 'object' || value === null || !('type' in value))
|
|
15
|
+
return false;
|
|
16
|
+
if (value.type === 'thinking')
|
|
17
|
+
return 'thinking' in value && 'signature' in value && typeof value.signature === 'string';
|
|
18
|
+
if (value.type === 'redacted_thinking')
|
|
19
|
+
return 'data' in value && typeof value.data === 'string';
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
22
|
+
const isCacheableBlock = (block) => block.type !== 'thinking' && block.type !== 'redacted_thinking';
|
|
23
|
+
/**
|
|
24
|
+
* Add `cache_control` to the LAST content block of an AnthropicMessageParam that can carry
|
|
25
|
+
* it. Converts string content to a single text block first so the mark has a place to live.
|
|
26
|
+
* Mutates in place so the cache breakpoint survives subsequent `mergeConsecutiveMessages`.
|
|
27
|
+
*
|
|
28
|
+
* Thinking blocks are skipped: they are replayed byte-for-byte and the API rejects an extra
|
|
29
|
+
* key on them. They lead the assistant message, so the only case where none of the blocks is
|
|
30
|
+
* cacheable is a message made of nothing but thinking — which then gets no breakpoint.
|
|
9
31
|
*/
|
|
10
32
|
function applyCacheControlToLastBlock(msg, cacheControl) {
|
|
11
33
|
if (typeof msg.content === 'string') {
|
|
12
34
|
msg.content = [{ type: 'text', text: msg.content, cache_control: cacheControl }];
|
|
13
35
|
return;
|
|
14
36
|
}
|
|
15
|
-
|
|
37
|
+
for (let i = msg.content.length - 1; i >= 0; i--) {
|
|
38
|
+
const block = msg.content[i];
|
|
39
|
+
if (!isCacheableBlock(block))
|
|
40
|
+
continue;
|
|
41
|
+
msg.content[i] = { ...block, cache_control: cacheControl };
|
|
16
42
|
return;
|
|
17
|
-
|
|
18
|
-
msg.content[lastIdx] = { ...msg.content[lastIdx], cache_control: cacheControl };
|
|
43
|
+
}
|
|
19
44
|
}
|
|
20
45
|
// ============================================================================
|
|
21
46
|
// AnthropicProvider
|
|
@@ -118,7 +143,10 @@ export class AnthropicProvider {
|
|
|
118
143
|
.filter((block) => block.type === 'text')
|
|
119
144
|
.map((block) => block.text)
|
|
120
145
|
.join('');
|
|
121
|
-
|
|
146
|
+
// Kept whole, in order, signatures included: the API verifies them on replay.
|
|
147
|
+
// `redacted_thinking` has no readable text but still has to travel.
|
|
148
|
+
const thinkingBlocks = data.content.filter(isThinkingBlock);
|
|
149
|
+
const reasoning = thinkingBlocks
|
|
122
150
|
.filter((block) => block.type === 'thinking')
|
|
123
151
|
.map((block) => block.thinking)
|
|
124
152
|
.join('');
|
|
@@ -147,6 +175,8 @@ export class AnthropicProvider {
|
|
|
147
175
|
metrics,
|
|
148
176
|
providerRequestId: data.id,
|
|
149
177
|
reasoning: reasoning || undefined,
|
|
178
|
+
// Normalized to undefined so an empty array never reaches the wire on the way back.
|
|
179
|
+
thinkingBlocks: thinkingBlocks.length > 0 ? thinkingBlocks : undefined,
|
|
150
180
|
});
|
|
151
181
|
}
|
|
152
182
|
catch (error) {
|
|
@@ -223,6 +253,17 @@ export class AnthropicProvider {
|
|
|
223
253
|
}
|
|
224
254
|
case 'assistant': {
|
|
225
255
|
const contentBlocks = [];
|
|
256
|
+
// Thinking goes first — the API requires the block order the model produced, and
|
|
257
|
+
// during tool use it requires the blocks to be there at all. All or nothing: a
|
|
258
|
+
// partial sequence is rejected, so anything unrecognisable drops the whole set
|
|
259
|
+
// rather than sending a truncated one.
|
|
260
|
+
const thinking = msg.thinkingBlocks ?? [];
|
|
261
|
+
if (thinking.length > 0 && thinking.every(isEchoableThinkingBlock)) {
|
|
262
|
+
contentBlocks.push(...thinking);
|
|
263
|
+
}
|
|
264
|
+
else if (thinking.length > 0) {
|
|
265
|
+
this.logger?.warn('Dropping unrecognisable thinking blocks from an assistant message', { count: thinking.length });
|
|
266
|
+
}
|
|
226
267
|
if (msg.content) {
|
|
227
268
|
contentBlocks.push({ type: 'text', text: msg.content });
|
|
228
269
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../../src/core/llm/anthropic.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGnD,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAA;AAa/C,OAAO,EAAE,8BAA8B,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAmHpG;;;;;GAKG;AACH,SAAS,4BAA4B,CAAC,GAA0B,EAAE,YAAmC;IACpG,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;QACrC,GAAG,CAAC,OAAO,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC,CAAA;QAChF,OAAM;IACP,CAAC;IACD,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAM;IACpC,MAAM,OAAO,GAAG,GAAG,CAAC,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,EAAE,CAAA;IACjF,CAAC;IAEO,QAAQ,CAAC,GAAY;QAC5B,IAAI,GAAG,YAAY,8BAA8B,EAAE,CAAC;YACnD,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAA;QACzD,CAAC;QACD,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YACvD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAA;QAC3D,CAAC;QACD,IAAI,GAAG,YAAY,SAAS,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YACpG,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;QACnE,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAA;IACxG,CAAC;CACD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live verification of the webmaster model shortlist against the real OpenRouter API.
|
|
3
|
+
*
|
|
4
|
+
* The list mirrors `AGENT_MODEL_OPTIONS` in webmaster `packages/api/feature-flags.ts` — the
|
|
5
|
+
* models an org admin can pin an edit-session agent to. Every entry there had only ever been
|
|
6
|
+
* read off a screenshot; this exercises each one through the SDK's real path:
|
|
7
|
+
*
|
|
8
|
+
* SessionManager → Session → Agent → OpenRouterProvider → openrouter.ai
|
|
9
|
+
*
|
|
10
|
+
* so a pass means *our runtime* works with the model, not merely that the model exists. The
|
|
11
|
+
* agent loop is forced through a tool call whose answer cannot be guessed (a made-up
|
|
12
|
+
* identifier), then through `tell_user`, so the assertions cover: tool call with correct
|
|
13
|
+
* arguments → tool result consumed → final user-visible answer containing the looked-up value.
|
|
14
|
+
*
|
|
15
|
+
* Every outbound HTTP body is recorded, which is what makes the secondary checks real rather
|
|
16
|
+
* than assumed:
|
|
17
|
+
*
|
|
18
|
+
* - `cache_control` — `buildHttpRequest` attaches Anthropic-shaped markers unconditionally.
|
|
19
|
+
* Recorded per request, and on a 4xx the same body is replayed with the markers stripped to
|
|
20
|
+
* prove whether they were the cause.
|
|
21
|
+
* - `reasoning_details` — the branch echoes them back on the next request. Proven by finding
|
|
22
|
+
* the key in a *later* outbound body, not by trusting the code path.
|
|
23
|
+
* - `stop` — the agent always sends `['<message']`; several shortlist models do not list
|
|
24
|
+
* `stop` in `supported_parameters`.
|
|
25
|
+
* - vision — separate one-shot requests with real PNG bytes, asserting the model names the
|
|
26
|
+
* colour rather than merely that the request shape was accepted.
|
|
27
|
+
*
|
|
28
|
+
* Opt-in, so a plain `bun test` stays hermetic and offline:
|
|
29
|
+
*
|
|
30
|
+
* LIVE_TESTS=1 OPENROUTER_API_KEY=… bun test model-shortlist-live
|
|
31
|
+
*
|
|
32
|
+
* `LIVE_MODELS` (comma-separated slugs) narrows the run to a subset.
|
|
33
|
+
*/
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=model-shortlist-live.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-shortlist-live.test.d.ts","sourceRoot":"","sources":["../../../src/core/llm/model-shortlist-live.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG"}
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live verification of the webmaster model shortlist against the real OpenRouter API.
|
|
3
|
+
*
|
|
4
|
+
* The list mirrors `AGENT_MODEL_OPTIONS` in webmaster `packages/api/feature-flags.ts` — the
|
|
5
|
+
* models an org admin can pin an edit-session agent to. Every entry there had only ever been
|
|
6
|
+
* read off a screenshot; this exercises each one through the SDK's real path:
|
|
7
|
+
*
|
|
8
|
+
* SessionManager → Session → Agent → OpenRouterProvider → openrouter.ai
|
|
9
|
+
*
|
|
10
|
+
* so a pass means *our runtime* works with the model, not merely that the model exists. The
|
|
11
|
+
* agent loop is forced through a tool call whose answer cannot be guessed (a made-up
|
|
12
|
+
* identifier), then through `tell_user`, so the assertions cover: tool call with correct
|
|
13
|
+
* arguments → tool result consumed → final user-visible answer containing the looked-up value.
|
|
14
|
+
*
|
|
15
|
+
* Every outbound HTTP body is recorded, which is what makes the secondary checks real rather
|
|
16
|
+
* than assumed:
|
|
17
|
+
*
|
|
18
|
+
* - `cache_control` — `buildHttpRequest` attaches Anthropic-shaped markers unconditionally.
|
|
19
|
+
* Recorded per request, and on a 4xx the same body is replayed with the markers stripped to
|
|
20
|
+
* prove whether they were the cause.
|
|
21
|
+
* - `reasoning_details` — the branch echoes them back on the next request. Proven by finding
|
|
22
|
+
* the key in a *later* outbound body, not by trusting the code path.
|
|
23
|
+
* - `stop` — the agent always sends `['<message']`; several shortlist models do not list
|
|
24
|
+
* `stop` in `supported_parameters`.
|
|
25
|
+
* - vision — separate one-shot requests with real PNG bytes, asserting the model names the
|
|
26
|
+
* colour rather than merely that the request shape was accepted.
|
|
27
|
+
*
|
|
28
|
+
* Opt-in, so a plain `bun test` stays hermetic and offline:
|
|
29
|
+
*
|
|
30
|
+
* LIVE_TESTS=1 OPENROUTER_API_KEY=… bun test model-shortlist-live
|
|
31
|
+
*
|
|
32
|
+
* `LIVE_MODELS` (comma-separated slugs) narrows the run to a subset.
|
|
33
|
+
*/
|
|
34
|
+
import { describe, expect, test } from 'bun:test';
|
|
35
|
+
import z4 from 'zod/v4';
|
|
36
|
+
import { MemoryEventStore } from '../../core/events/memory.js';
|
|
37
|
+
import { SessionFileStore } from '../../core/file-store/file-store.js';
|
|
38
|
+
import { SessionManager } from '../../core/sessions/session-manager.js';
|
|
39
|
+
import { createTool } from '../../core/tools/definition.js';
|
|
40
|
+
import { ToolExecutor } from '../../core/tools/executor.js';
|
|
41
|
+
import { silentLogger } from '../../lib/logger/logger.js';
|
|
42
|
+
import { agentStatusPlugin } from '../../plugins/agent-status/plugin.js';
|
|
43
|
+
import { agentsPlugin } from '../../plugins/agents/plugin.js';
|
|
44
|
+
import { filesystemPlugin } from '../../plugins/filesystem/index.js';
|
|
45
|
+
import { gitStatusPlugin } from '../../plugins/git-status/index.js';
|
|
46
|
+
import { llmDebugPlugin } from '../../plugins/llm-debug/plugin.js';
|
|
47
|
+
import { logsPlugin } from '../../plugins/logs/index.js';
|
|
48
|
+
import { mailboxPlugin } from '../../plugins/mailbox/plugin.js';
|
|
49
|
+
import { resourcesPlugin } from '../../plugins/resources/plugin.js';
|
|
50
|
+
import { servicePlugin } from '../../plugins/services/plugin.js';
|
|
51
|
+
import { presetsPlugin, sessionLifecyclePlugin } from '../../plugins/session-lifecycle/index.js';
|
|
52
|
+
import { sessionStatePlugin } from '../../plugins/session-state/plugin.js';
|
|
53
|
+
import { sessionStatsPlugin } from '../../plugins/session-stats/index.js';
|
|
54
|
+
import { uploadsPlugin } from '../../plugins/uploads/plugin.js';
|
|
55
|
+
import { userChatPlugin } from '../../plugins/user-chat/plugin.js';
|
|
56
|
+
import { createNodePlatform } from '../../testing/node-platform.js';
|
|
57
|
+
import { createTestPreset } from '../../testing/preset-helpers.js';
|
|
58
|
+
import { waitForAllAgentsIdle } from '../../testing/wait-helpers.js';
|
|
59
|
+
import { OpenRouterProvider } from './openrouter.js';
|
|
60
|
+
import { ModelId } from './schema.js';
|
|
61
|
+
// ============================================================================
|
|
62
|
+
// Gating
|
|
63
|
+
// ============================================================================
|
|
64
|
+
const liveEnabled = process.env.LIVE_TESTS === '1';
|
|
65
|
+
const openRouterApiKey = liveEnabled ? process.env.OPENROUTER_API_KEY : undefined;
|
|
66
|
+
/** Mirrors webmaster `AGENT_MODEL_OPTIONS`. Keep in sync by hand — the repos do not share code. */
|
|
67
|
+
const SHORTLIST = [
|
|
68
|
+
'anthropic/claude-haiku-4.5',
|
|
69
|
+
'anthropic/claude-sonnet-5',
|
|
70
|
+
'anthropic/claude-sonnet-4.6',
|
|
71
|
+
'anthropic/claude-opus-5',
|
|
72
|
+
'openai/gpt-5.6-luna',
|
|
73
|
+
'openai/gpt-5.6-terra',
|
|
74
|
+
'openai/gpt-5.6-sol',
|
|
75
|
+
'google/gemini-3.6-flash',
|
|
76
|
+
'x-ai/grok-4.5',
|
|
77
|
+
'moonshotai/kimi-k2.7-code',
|
|
78
|
+
'moonshotai/kimi-k3',
|
|
79
|
+
];
|
|
80
|
+
const selectedModels = process.env.LIVE_MODELS ? process.env.LIVE_MODELS.split(',').map((s) => s.trim()).filter(Boolean) : SHORTLIST;
|
|
81
|
+
/**
|
|
82
|
+
* The constant from provider-integration.test.ts, where it is commented "1x1 red pixel". It is
|
|
83
|
+
* actually a 1x1 RGBA pixel of #FFFF00 at alpha 127. Kept because xAI rejects it outright
|
|
84
|
+
* (min 8x8), which is worth knowing before someone reuses it as a vision fixture.
|
|
85
|
+
*/
|
|
86
|
+
const TINY_PNG = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==';
|
|
87
|
+
/**
|
|
88
|
+
* 32x32 opaque #0000FF — unambiguous to name, and above every provider's minimum. xAI is the
|
|
89
|
+
* binding constraint: it rejects anything under 8px per side or under 512 total pixels, so 16x16
|
|
90
|
+
* (256 px) is still too small.
|
|
91
|
+
*/
|
|
92
|
+
const BLUE_PNG_32 = 'iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAJklEQVR42u3NsQkAAAjAsP7/tF7hIASyp5pjAoFAIBAIBAKB4EmwOkv8Lom8x/sAAAAASUVORK5CYII=';
|
|
93
|
+
const noopImageProcessor = {
|
|
94
|
+
resolveContent: async (content) => content,
|
|
95
|
+
};
|
|
96
|
+
/** Wraps real fetch and keeps the parsed request/response pair. Auth headers are never stored. */
|
|
97
|
+
const createRecordingFetch = (sink) => {
|
|
98
|
+
return async (input, init) => {
|
|
99
|
+
const requestBody = JSON.parse(typeof init?.body === 'string' ? init.body : '{}');
|
|
100
|
+
const response = await globalThis.fetch(input, init);
|
|
101
|
+
const rawResponse = await response.text();
|
|
102
|
+
let parsed;
|
|
103
|
+
try {
|
|
104
|
+
parsed = JSON.parse(rawResponse);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
parsed = undefined;
|
|
108
|
+
}
|
|
109
|
+
sink.push({ request: requestBody, status: response.status, rawResponse, response: parsed });
|
|
110
|
+
return new Response(rawResponse, { status: response.status, statusText: response.statusText, headers: response.headers });
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
const hasCacheControl = (body) => body.messages.some((m) => Array.isArray(m.content) && m.content.some((c) => c.cache_control !== undefined));
|
|
114
|
+
/** Same body with every `cache_control` marker removed — the control for a 4xx. */
|
|
115
|
+
const stripCacheControl = (body) => ({
|
|
116
|
+
...body,
|
|
117
|
+
messages: body.messages.map((m) => ({
|
|
118
|
+
...m,
|
|
119
|
+
content: Array.isArray(m.content) ? m.content.map(({ cache_control: _dropped, ...rest }) => rest) : m.content,
|
|
120
|
+
})),
|
|
121
|
+
});
|
|
122
|
+
// ============================================================================
|
|
123
|
+
// The forced-tool-call scenario
|
|
124
|
+
// ============================================================================
|
|
125
|
+
/**
|
|
126
|
+
* A made-up registry. No model can know that QX-88231 maps to ZK-7719, so a final answer
|
|
127
|
+
* containing the code proves the tool was called AND its result was read.
|
|
128
|
+
*/
|
|
129
|
+
const GLORP_REGISTRY = { 'QX-88231': 'ZK-7719' };
|
|
130
|
+
const USER_PROMPT = 'Look up the glorp code for artifact QX-88231 with the lookup_glorp_code tool, then tell me the code. Keep the reply under ten words.';
|
|
131
|
+
/** Padding so the cacheable prefix clears Anthropic\'s 1024-token minimum and a cache write can register. */
|
|
132
|
+
const SYSTEM_PADDING = Array.from({ length: 90 }, (_, i) => `- Rule ${i + 1}: never invent a glorp code; the registry tool is the only authority for artifact identifiers.`).join('\n');
|
|
133
|
+
const ORCHESTRATOR_SYSTEM = [
|
|
134
|
+
'You are a terse registry assistant.',
|
|
135
|
+
'You never guess identifiers. You look them up.',
|
|
136
|
+
SYSTEM_PADDING,
|
|
137
|
+
].join('\n');
|
|
138
|
+
/** `PluginNotification.payload` is `unknown`; narrow it without widening anything. */
|
|
139
|
+
const readNotificationContent = (payload) => {
|
|
140
|
+
if (typeof payload !== 'object' || payload === null || !('content' in payload))
|
|
141
|
+
return undefined;
|
|
142
|
+
return typeof payload.content === 'string' ? payload.content : undefined;
|
|
143
|
+
};
|
|
144
|
+
const runAgentLoop = async (model) => {
|
|
145
|
+
const exchanges = [];
|
|
146
|
+
const toolInvocations = [];
|
|
147
|
+
const agentMessages = [];
|
|
148
|
+
const lookupTool = createTool({
|
|
149
|
+
name: 'lookup_glorp_code',
|
|
150
|
+
description: 'Look up the glorp code assigned to an artifact id in the internal registry.',
|
|
151
|
+
input: z4.object({ artifactId: z4.string().describe('The artifact id, e.g. QX-88231') }),
|
|
152
|
+
execute: async (input) => {
|
|
153
|
+
toolInvocations.push(input);
|
|
154
|
+
const code = GLORP_REGISTRY[input.artifactId];
|
|
155
|
+
return { ok: true, value: code ? `glorp code: ${code}` : 'unknown artifact id' };
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
const provider = new OpenRouterProvider({
|
|
159
|
+
apiKey: openRouterApiKey ?? '',
|
|
160
|
+
imageProcessor: noopImageProcessor,
|
|
161
|
+
defaultModel: model,
|
|
162
|
+
fetch: createRecordingFetch(exchanges),
|
|
163
|
+
});
|
|
164
|
+
const preset = createTestPreset({
|
|
165
|
+
id: 'shortlist',
|
|
166
|
+
orchestratorSystem: ORCHESTRATOR_SYSTEM,
|
|
167
|
+
});
|
|
168
|
+
preset.orchestrator.model = ModelId(model);
|
|
169
|
+
preset.orchestrator.tools = [lookupTool];
|
|
170
|
+
const basePath = `/tmp/roj-shortlist-${Math.random().toString(36).slice(2)}`;
|
|
171
|
+
const platform = createNodePlatform();
|
|
172
|
+
const sessionManager = new SessionManager({
|
|
173
|
+
eventStore: new MemoryEventStore(),
|
|
174
|
+
llmProvider: provider,
|
|
175
|
+
toolExecutor: new ToolExecutor(silentLogger),
|
|
176
|
+
presets: new Map([[preset.id, preset]]),
|
|
177
|
+
logger: silentLogger,
|
|
178
|
+
basePath,
|
|
179
|
+
dataFileStore: new SessionFileStore(basePath, undefined, false, platform.fs, 'session'),
|
|
180
|
+
platform,
|
|
181
|
+
onUserOutput: (notification) => {
|
|
182
|
+
if (notification.pluginName !== 'user-chat' || notification.type !== 'agentMessage')
|
|
183
|
+
return;
|
|
184
|
+
const content = readNotificationContent(notification.payload);
|
|
185
|
+
if (content !== undefined)
|
|
186
|
+
agentMessages.push(content);
|
|
187
|
+
},
|
|
188
|
+
systemPlugins: [
|
|
189
|
+
sessionLifecyclePlugin,
|
|
190
|
+
presetsPlugin,
|
|
191
|
+
mailboxPlugin,
|
|
192
|
+
agentsPlugin,
|
|
193
|
+
agentStatusPlugin,
|
|
194
|
+
userChatPlugin,
|
|
195
|
+
uploadsPlugin,
|
|
196
|
+
resourcesPlugin,
|
|
197
|
+
llmDebugPlugin,
|
|
198
|
+
servicePlugin,
|
|
199
|
+
filesystemPlugin,
|
|
200
|
+
logsPlugin,
|
|
201
|
+
sessionStatsPlugin,
|
|
202
|
+
sessionStatePlugin,
|
|
203
|
+
gitStatusPlugin,
|
|
204
|
+
],
|
|
205
|
+
});
|
|
206
|
+
const created = await sessionManager.createSession(preset.id);
|
|
207
|
+
if (!created.ok)
|
|
208
|
+
throw new Error(`createSession failed: ${created.error.type} — ${created.error.message}`);
|
|
209
|
+
const session = created.value;
|
|
210
|
+
const entryAgentId = session.getEntryAgentId();
|
|
211
|
+
if (!entryAgentId)
|
|
212
|
+
throw new Error('no entry agent');
|
|
213
|
+
const sent = await session.callPluginMethod('user-chat.sendMessage', {
|
|
214
|
+
sessionId: String(session.id),
|
|
215
|
+
content: USER_PROMPT,
|
|
216
|
+
agentId: String(entryAgentId),
|
|
217
|
+
});
|
|
218
|
+
if (!sent.ok)
|
|
219
|
+
throw new Error(`sendMessage failed: ${sent.error.type} — ${sent.error.message}`);
|
|
220
|
+
let idleTimedOut = false;
|
|
221
|
+
try {
|
|
222
|
+
await waitForAllAgentsIdle(session, { timeoutMs: 150_000 });
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
// A non-retryable 4xx parks the agent in `error`, which never becomes idle. The recorded
|
|
226
|
+
// exchanges are the evidence either way, so this is reported rather than thrown.
|
|
227
|
+
idleTimedOut = true;
|
|
228
|
+
}
|
|
229
|
+
const agentState = session.getAgent(entryAgentId)?.state;
|
|
230
|
+
const assistantTexts = (agentState?.conversationHistory ?? [])
|
|
231
|
+
.filter((m) => m.role === 'assistant')
|
|
232
|
+
.map((m) => (typeof m.content === 'string' ? m.content : ''))
|
|
233
|
+
.filter((text) => text.length > 0);
|
|
234
|
+
await sessionManager.shutdown();
|
|
235
|
+
const toolsOffered = (exchanges[0]?.request.tools ?? []).map((t) => t.function.name);
|
|
236
|
+
return { model, toolInvocations, agentMessages, assistantTexts, toolsOffered, exchanges, idleTimedOut };
|
|
237
|
+
};
|
|
238
|
+
// ============================================================================
|
|
239
|
+
// Reporting
|
|
240
|
+
// ============================================================================
|
|
241
|
+
/** Stable short identity for a reasoning_details array, for matching returned blocks to echoed ones. */
|
|
242
|
+
const reasoningFingerprint = (details) => {
|
|
243
|
+
if (!details?.length)
|
|
244
|
+
return null;
|
|
245
|
+
const serialized = JSON.stringify(details);
|
|
246
|
+
return `${details.length}b/${serialized.length}c/${serialized.slice(0, 24)}`;
|
|
247
|
+
};
|
|
248
|
+
/** One machine-readable line per model, so the run can be turned into a matrix afterwards. */
|
|
249
|
+
const reportOutcome = (outcome) => {
|
|
250
|
+
const { exchanges } = outcome;
|
|
251
|
+
const failures = exchanges.filter((e) => e.status >= 400);
|
|
252
|
+
const reasoningTurns = exchanges.filter((e) => (e.response?.choices?.[0]?.message?.reasoning_details?.length ?? 0) > 0).length;
|
|
253
|
+
const echoTurns = exchanges.filter((e) => e.request.messages.some((m) => m.role === 'assistant' && m.reasoning_details !== undefined)).length;
|
|
254
|
+
const assistantTurns = exchanges.flatMap((e) => e.request.messages.filter((m) => m.role === 'assistant')).length;
|
|
255
|
+
const cost = exchanges.reduce((sum, e) => sum + (e.response?.usage?.cost ?? 0), 0);
|
|
256
|
+
const cached = exchanges.reduce((sum, e) => sum + (e.response?.usage?.prompt_tokens_details?.cached_tokens ?? 0), 0);
|
|
257
|
+
const cacheWrites = exchanges.reduce((sum, e) => sum + (e.response?.usage?.prompt_tokens_details?.cache_write_tokens ?? 0), 0);
|
|
258
|
+
console.log(`RESULT ${JSON.stringify({
|
|
259
|
+
model: outcome.model,
|
|
260
|
+
requests: exchanges.length,
|
|
261
|
+
httpFailures: failures.map((f) => ({ status: f.status, body: f.rawResponse.slice(0, 400) })),
|
|
262
|
+
cacheControlSent: exchanges.every((e) => hasCacheControl(e.request)),
|
|
263
|
+
stopSent: exchanges[0]?.request.stop,
|
|
264
|
+
promptTokens: exchanges.map((e) => e.response?.usage?.prompt_tokens ?? 0),
|
|
265
|
+
cachedTokens: cached,
|
|
266
|
+
cacheWriteTokens: cacheWrites,
|
|
267
|
+
reasoningReturnedOnTurns: reasoningTurns,
|
|
268
|
+
assistantMessagesSentBack: assistantTurns,
|
|
269
|
+
assistantMessagesCarryingReasoningDetails: echoTurns,
|
|
270
|
+
reasoningTrace: exchanges.map((e, i) => ({
|
|
271
|
+
turn: i,
|
|
272
|
+
returned: reasoningFingerprint(e.response?.choices?.[0]?.message?.reasoning_details),
|
|
273
|
+
sentBack: e.request.messages.filter((m) => m.role === 'assistant').map((m) => reasoningFingerprint(m.reasoning_details)),
|
|
274
|
+
})),
|
|
275
|
+
toolInvocations: outcome.toolInvocations,
|
|
276
|
+
tellUserOffered: outcome.toolsOffered.includes('tell_user'),
|
|
277
|
+
usedTellUser: outcome.agentMessages.length > 0,
|
|
278
|
+
agentMessages: outcome.agentMessages,
|
|
279
|
+
assistantTexts: outcome.assistantTexts,
|
|
280
|
+
idleTimedOut: outcome.idleTimedOut,
|
|
281
|
+
cost,
|
|
282
|
+
})}`);
|
|
283
|
+
};
|
|
284
|
+
// ============================================================================
|
|
285
|
+
// Tests
|
|
286
|
+
// ============================================================================
|
|
287
|
+
const describeLive = (name, fn) => {
|
|
288
|
+
if (!openRouterApiKey) {
|
|
289
|
+
describe.skip(`${name} (skipped — LIVE_TESTS=1 + OPENROUTER_API_KEY required)`, fn);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
describe(name, fn);
|
|
293
|
+
};
|
|
294
|
+
describeLive('OpenRouter shortlist — agent loop', () => {
|
|
295
|
+
for (const model of selectedModels) {
|
|
296
|
+
test(`${model} runs a tool-calling agent turn`, async () => {
|
|
297
|
+
const outcome = await runAgentLoop(model);
|
|
298
|
+
reportOutcome(outcome);
|
|
299
|
+
const failed = outcome.exchanges.filter((e) => e.status >= 400);
|
|
300
|
+
if (failed.length > 0) {
|
|
301
|
+
// Isolate the cause: replay the same body without the cache_control markers.
|
|
302
|
+
const first = failed[0];
|
|
303
|
+
const control = await globalThis.fetch('https://openrouter.ai/api/v1/chat/completions', {
|
|
304
|
+
method: 'POST',
|
|
305
|
+
headers: { 'content-type': 'application/json', 'Authorization': `Bearer ${openRouterApiKey}` },
|
|
306
|
+
body: JSON.stringify(stripCacheControl(first.request)),
|
|
307
|
+
});
|
|
308
|
+
const controlBody = await control.text();
|
|
309
|
+
console.log(`CONTROL ${JSON.stringify({ model, withoutCacheControl: control.status, body: controlBody.slice(0, 400) })}`);
|
|
310
|
+
}
|
|
311
|
+
expect(failed.map((f) => `${f.status} ${f.rawResponse.slice(0, 300)}`)).toEqual([]);
|
|
312
|
+
// The agent loop actually ran: correct tool, correct argument, result used in the answer.
|
|
313
|
+
// The answer counts whether it came back as assistant text or through `tell_user` —
|
|
314
|
+
// which one a model picks is instruction-following, not runtime compatibility.
|
|
315
|
+
expect(outcome.toolInvocations).toContainEqual({ artifactId: 'QX-88231' });
|
|
316
|
+
expect([...outcome.assistantTexts, ...outcome.agentMessages].join('\n')).toContain('ZK-7719');
|
|
317
|
+
// cache_control travelled on every request — the point of the exercise.
|
|
318
|
+
for (const exchange of outcome.exchanges) {
|
|
319
|
+
expect(hasCacheControl(exchange.request)).toBe(true);
|
|
320
|
+
}
|
|
321
|
+
// The agent always sends stop sequences, whatever the model advertises.
|
|
322
|
+
expect(outcome.exchanges[0].request.stop).toEqual(['<message']);
|
|
323
|
+
// reasoning_details round trip. The negative control comes first: a model that never
|
|
324
|
+
// reasons must produce no `reasoning_details` key anywhere on the wire, because the prompt
|
|
325
|
+
// cache is keyed on the serialized prefix and the pre-fix bytes had no such key.
|
|
326
|
+
const producedReasoning = outcome.exchanges.some((e) => (e.response?.choices?.[0]?.message?.reasoning_details?.length ?? 0) > 0);
|
|
327
|
+
const echoed = outcome.exchanges.some((e) => e.request.messages.some((m) => m.role === 'assistant' && m.reasoning_details !== undefined));
|
|
328
|
+
if (!producedReasoning) {
|
|
329
|
+
expect(echoed).toBe(false);
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
// Verbatim, on the wire: every block set that goes back out must be byte-identical to one
|
|
333
|
+
// the provider returned earlier — nothing invented, reordered or edited, which is exactly
|
|
334
|
+
// what OpenRouter rejects. All these requests came back 200 (asserted above), so the echo
|
|
335
|
+
// was also accepted.
|
|
336
|
+
//
|
|
337
|
+
// The converse does not hold and must not be asserted: an auxiliary inference
|
|
338
|
+
// (`runAuxiliaryInference`) and an empty-response retry both discard their response
|
|
339
|
+
// without committing it to history, so some returned blocks legitimately never come back.
|
|
340
|
+
const returnedFingerprints = new Set();
|
|
341
|
+
let verbatimEchoes = 0;
|
|
342
|
+
for (const exchange of outcome.exchanges) {
|
|
343
|
+
for (const message of exchange.request.messages) {
|
|
344
|
+
if (message.reasoning_details === undefined)
|
|
345
|
+
continue;
|
|
346
|
+
expect(returnedFingerprints).toContain(JSON.stringify(message.reasoning_details));
|
|
347
|
+
verbatimEchoes++;
|
|
348
|
+
}
|
|
349
|
+
const returned = exchange.response?.choices?.[0]?.message?.reasoning_details;
|
|
350
|
+
if (returned?.length)
|
|
351
|
+
returnedFingerprints.add(JSON.stringify(returned));
|
|
352
|
+
}
|
|
353
|
+
console.log(`ROUNDTRIP ${JSON.stringify({ model, verbatimEchoes, roundTripProven: verbatimEchoes > 0 })}`);
|
|
354
|
+
}, 200_000);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
/**
|
|
358
|
+
* `stop` is sent on every agent inference (`agent.ts` hardcodes `['<message']` to stop the model
|
|
359
|
+
* hallucinating message tags), but several shortlist models do not list `stop` in
|
|
360
|
+
* `supported_parameters`. OpenRouter drops unsupported parameters instead of erroring, so the
|
|
361
|
+
* question is not "does the request fail" but "is the guard actually in force". Asking the model
|
|
362
|
+
* to emit text that straddles the stop sequence answers it: truncated → honored, intact → dropped.
|
|
363
|
+
*/
|
|
364
|
+
describeLive('OpenRouter shortlist — stop sequences', () => {
|
|
365
|
+
for (const model of selectedModels) {
|
|
366
|
+
test(`${model} stop sequence behaviour`, async () => {
|
|
367
|
+
const exchanges = [];
|
|
368
|
+
const provider = new OpenRouterProvider({
|
|
369
|
+
apiKey: openRouterApiKey ?? '',
|
|
370
|
+
imageProcessor: noopImageProcessor,
|
|
371
|
+
defaultModel: model,
|
|
372
|
+
fetch: createRecordingFetch(exchanges),
|
|
373
|
+
});
|
|
374
|
+
const result = await provider.inference({
|
|
375
|
+
model: ModelId(model),
|
|
376
|
+
systemPrompt: 'You echo text literally. No preamble, no commentary, no markdown.',
|
|
377
|
+
messages: [{ role: 'user', content: 'Repeat this line exactly, and nothing else: ALPHA<message>BRAVO' }],
|
|
378
|
+
stopSequences: ['<message'],
|
|
379
|
+
// Generous: a reasoning model spends most of its budget before the first visible token.
|
|
380
|
+
maxTokens: 512,
|
|
381
|
+
});
|
|
382
|
+
const content = result.ok ? (result.value.content ?? '') : '';
|
|
383
|
+
const reasoning = result.ok ? (result.value.reasoning ?? '') : '';
|
|
384
|
+
// `honored_killed_turn` is the dangerous one: the sequence also applies to the reasoning
|
|
385
|
+
// stream, so the model stops mid-thought and the turn yields no content at all.
|
|
386
|
+
const verdict = content.includes('ALPHA') && !content.includes('BRAVO')
|
|
387
|
+
? 'honored'
|
|
388
|
+
: content.includes('ALPHA') && content.includes('BRAVO')
|
|
389
|
+
? 'ignored'
|
|
390
|
+
: content === '' && reasoning.includes('ALPHA') && !reasoning.includes('BRAVO')
|
|
391
|
+
? 'honored_killed_turn'
|
|
392
|
+
: 'inconclusive';
|
|
393
|
+
console.log(`STOP ${JSON.stringify({
|
|
394
|
+
model,
|
|
395
|
+
status: exchanges[0]?.status,
|
|
396
|
+
stopInRequest: exchanges[0]?.request.stop,
|
|
397
|
+
verdict,
|
|
398
|
+
content,
|
|
399
|
+
reasoning: reasoning.slice(0, 200),
|
|
400
|
+
finishReason: result.ok ? result.value.finishReason : undefined,
|
|
401
|
+
error: result.ok ? undefined : result.error,
|
|
402
|
+
cost: exchanges[0]?.response?.usage?.cost,
|
|
403
|
+
})}`);
|
|
404
|
+
// The only hard requirement: sending `stop` must never break the request.
|
|
405
|
+
expect(exchanges[0]?.request.stop).toEqual(['<message']);
|
|
406
|
+
expect(exchanges[0]?.status).toBe(200);
|
|
407
|
+
}, 120_000);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
const probeVision = async (model, imageBase64, maxTokens) => {
|
|
411
|
+
const exchanges = [];
|
|
412
|
+
const provider = new OpenRouterProvider({
|
|
413
|
+
apiKey: openRouterApiKey ?? '',
|
|
414
|
+
imageProcessor: noopImageProcessor,
|
|
415
|
+
defaultModel: model,
|
|
416
|
+
fetch: createRecordingFetch(exchanges),
|
|
417
|
+
});
|
|
418
|
+
const result = await provider.inference({
|
|
419
|
+
model: ModelId(model),
|
|
420
|
+
systemPrompt: 'You describe images. Answer with a single colour word and nothing else.',
|
|
421
|
+
messages: [{
|
|
422
|
+
role: 'user',
|
|
423
|
+
content: [
|
|
424
|
+
{ type: 'text', text: 'What colour fills this image? Answer with one colour word.' },
|
|
425
|
+
{ type: 'image_url', imageUrl: { url: `data:image/png;base64,${imageBase64}` } },
|
|
426
|
+
],
|
|
427
|
+
}],
|
|
428
|
+
maxTokens,
|
|
429
|
+
});
|
|
430
|
+
return {
|
|
431
|
+
status: exchanges[0]?.status,
|
|
432
|
+
content: result.ok ? result.value.content : undefined,
|
|
433
|
+
error: result.ok ? undefined : result.error,
|
|
434
|
+
body: result.ok ? undefined : exchanges[0]?.rawResponse.slice(0, 300),
|
|
435
|
+
cost: exchanges[0]?.response?.usage?.cost,
|
|
436
|
+
};
|
|
437
|
+
};
|
|
438
|
+
describeLive('OpenRouter shortlist — vision', () => {
|
|
439
|
+
for (const model of selectedModels) {
|
|
440
|
+
test(`${model} accepts an inline image`, async () => {
|
|
441
|
+
// Two fixtures: the existing 1x1 constant (some providers reject it on size), then a
|
|
442
|
+
// 32x32 solid blue that clears every minimum. Answering "blue" is behavioural proof the
|
|
443
|
+
// pixels arrived; a 200 with empty content only proves the request shape was accepted.
|
|
444
|
+
const tiny = await probeVision(model, TINY_PNG, 64);
|
|
445
|
+
const blue = await probeVision(model, BLUE_PNG_32, 512);
|
|
446
|
+
console.log(`VISION ${JSON.stringify({ model, tiny1x1: tiny, blue32x32: blue, sawBlue: (blue.content ?? '').toLowerCase().includes('blue') })}`);
|
|
447
|
+
expect(blue.status).toBe(200);
|
|
448
|
+
expect((blue.content ?? '').toLowerCase()).toContain('blue');
|
|
449
|
+
}, 180_000);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
//# sourceMappingURL=model-shortlist-live.test.js.map
|