@rarebit-one/harness-kernel 0.10.0 → 0.11.0-next.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/README.md +142 -6
- package/dist/agent.d.ts +80 -8
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +225 -25
- package/dist/agent.js.map +1 -1
- package/dist/engines/native.d.ts +5 -0
- package/dist/engines/native.d.ts.map +1 -1
- package/dist/engines/native.js +28 -10
- package/dist/engines/native.js.map +1 -1
- package/dist/engines/types.d.ts +19 -0
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/events.d.ts +20 -0
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js.map +1 -1
- package/dist/index.d.ts +17 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/loop.d.ts +58 -11
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +7 -5
- package/dist/loop.js.map +1 -1
- package/dist/models/chat.d.ts +2 -1
- package/dist/models/chat.d.ts.map +1 -1
- package/dist/models/chat.js +20 -4
- package/dist/models/chat.js.map +1 -1
- package/dist/models/types.d.ts +16 -0
- package/dist/models/types.d.ts.map +1 -1
- package/dist/models/types.js.map +1 -1
- package/dist/private.d.ts.map +1 -1
- package/dist/private.js +21 -0
- package/dist/private.js.map +1 -1
- package/dist/providers/anthropic.d.ts +27 -3
- package/dist/providers/anthropic.d.ts.map +1 -1
- package/dist/providers/anthropic.js +95 -29
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/index.d.ts +42 -6
- package/dist/providers/index.d.ts.map +1 -1
- package/dist/providers/index.js +132 -48
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/mock.d.ts +6 -3
- package/dist/providers/mock.d.ts.map +1 -1
- package/dist/providers/mock.js +8 -3
- package/dist/providers/mock.js.map +1 -1
- package/dist/providers/openai.d.ts +51 -7
- package/dist/providers/openai.d.ts.map +1 -1
- package/dist/providers/openai.js +128 -30
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/options.d.ts +162 -0
- package/dist/providers/options.d.ts.map +1 -0
- package/dist/providers/options.js +67 -0
- package/dist/providers/options.js.map +1 -0
- package/dist/providers/scripted.d.ts +49 -0
- package/dist/providers/scripted.d.ts.map +1 -0
- package/dist/providers/scripted.js +90 -0
- package/dist/providers/scripted.js.map +1 -0
- package/dist/providers/types.d.ts +34 -0
- package/dist/providers/types.d.ts.map +1 -1
- package/dist/tools/metadata.d.ts +24 -0
- package/dist/tools/metadata.d.ts.map +1 -1
- package/dist/tools/metadata.js +8 -0
- package/dist/tools/metadata.js.map +1 -1
- package/dist/tools/registry.d.ts +10 -3
- package/dist/tools/registry.d.ts.map +1 -1
- package/dist/tools/registry.js +9 -4
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/terminal.d.ts +33 -0
- package/dist/tools/terminal.d.ts.map +1 -0
- package/dist/tools/terminal.js +32 -0
- package/dist/tools/terminal.js.map +1 -0
- package/package.json +5 -4
package/dist/providers/mock.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { CompletionRequest, ConverseOptions, ConverseRequest, ConverseResult, Provider } from "./types.js";
|
|
2
2
|
import type { ProviderSelection } from "./index.js";
|
|
3
3
|
/**
|
|
4
|
-
* Deterministic, offline provider. Used when
|
|
5
|
-
*
|
|
6
|
-
* tests) run without network access
|
|
4
|
+
* Deterministic, offline provider. Used when a workflow explicitly asks for
|
|
5
|
+
* `preferred: mock`, or when a caller opts into `allowMockFallback` and no key
|
|
6
|
+
* is configured, so the end-to-end loop (and tests) run without network access
|
|
7
|
+
* or credentials. It accepts and ignores `providerOptions`: it is the dry run.
|
|
7
8
|
*
|
|
8
9
|
* It cannot call a model, but it is handed the SAME provider selection a real
|
|
9
10
|
* provider would receive (the resolved per-run model + per-org BYO keys) and
|
|
@@ -14,6 +15,8 @@ import type { ProviderSelection } from "./index.js";
|
|
|
14
15
|
*/
|
|
15
16
|
export declare class MockProvider implements Provider {
|
|
16
17
|
readonly name = "mock";
|
|
18
|
+
/** The model the caller resolved, when it resolved one; the mock calls nothing. */
|
|
19
|
+
readonly model?: string;
|
|
17
20
|
private readonly selection;
|
|
18
21
|
constructor(selection?: ProviderSelection);
|
|
19
22
|
private resolvedModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/providers/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,cAAc,EACd,QAAQ,EACT,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../src/providers/mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,cAAc,EACd,QAAQ,EACT,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnD;;;;;;;;;;;;GAYG;AACH,qBAAa,YAAa,YAAW,QAAQ;IAC3C,QAAQ,CAAC,IAAI,UAAS;IACtB,mFAAmF;IACnF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAmB;gBAEjC,SAAS,GAAE,iBAAsB;IAU7C,OAAO,CAAC,aAAa;IAWrB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,cAAc;IAWtB,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IA2B3C,QAAQ,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;CAWtF"}
|
package/dist/providers/mock.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Deterministic, offline provider. Used when
|
|
3
|
-
*
|
|
4
|
-
* tests) run without network access
|
|
2
|
+
* Deterministic, offline provider. Used when a workflow explicitly asks for
|
|
3
|
+
* `preferred: mock`, or when a caller opts into `allowMockFallback` and no key
|
|
4
|
+
* is configured, so the end-to-end loop (and tests) run without network access
|
|
5
|
+
* or credentials. It accepts and ignores `providerOptions`: it is the dry run.
|
|
5
6
|
*
|
|
6
7
|
* It cannot call a model, but it is handed the SAME provider selection a real
|
|
7
8
|
* provider would receive (the resolved per-run model + per-org BYO keys) and
|
|
@@ -12,9 +13,13 @@
|
|
|
12
13
|
*/
|
|
13
14
|
export class MockProvider {
|
|
14
15
|
name = "mock";
|
|
16
|
+
/** The model the caller resolved, when it resolved one; the mock calls nothing. */
|
|
17
|
+
model;
|
|
15
18
|
selection;
|
|
16
19
|
constructor(selection = {}) {
|
|
17
20
|
this.selection = selection;
|
|
21
|
+
if (selection.model)
|
|
22
|
+
this.model = selection.model;
|
|
18
23
|
}
|
|
19
24
|
// "What a real provider would have used" for the model: the model the caller
|
|
20
25
|
// resolved (workflow YAML → org default), else the host's
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../src/providers/mock.ts"],"names":[],"mappings":"AASA
|
|
1
|
+
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../src/providers/mock.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,YAAY;IACd,IAAI,GAAG,MAAM,CAAA;IACtB,mFAAmF;IAC1E,KAAK,CAAS;IACN,SAAS,CAAmB;IAE7C,YAAY,YAA+B,EAAE;QAC3C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,SAAS,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,KAAK,CAAA;IACnD,CAAC;IAED,6EAA6E;IAC7E,0DAA0D;IAC1D,sEAAsE;IACtE,+EA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AA;QACF,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA;QAC9B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAA;IAChC,CAAC;CACF"}
|
|
@@ -1,15 +1,31 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
2
|
import type { TokenUsage } from "../models/types.js";
|
|
3
|
+
import { type CacheTtl } from "./options.js";
|
|
3
4
|
import type { AgentMessage, CompletionRequest, ConverseOptions, ConverseRequest, ConverseResult, Provider } from "./types.js";
|
|
4
|
-
/**
|
|
5
|
-
export
|
|
5
|
+
/** Where to put message breakpoints: how many trailing messages, and the lifetime. */
|
|
6
|
+
export interface OpenAIMessageCache {
|
|
7
|
+
trailingMessages: number;
|
|
8
|
+
ttl?: CacheTtl;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Map provider-neutral messages to OpenAI chat messages (pure; tested).
|
|
12
|
+
*
|
|
13
|
+
* With `cache` set (OpenRouter), the trailing N messages are sent as content
|
|
14
|
+
* parts with a `cache_control` breakpoint on their text. An assistant message
|
|
15
|
+
* with no prose has nowhere to put one and is left as it was; a tool message
|
|
16
|
+
* puts it on its last result. Messages outside the window keep the plain
|
|
17
|
+
* string form.
|
|
18
|
+
*/
|
|
19
|
+
export declare function toOpenAIMessages(messages: AgentMessage[], cache?: OpenAIMessageCache): OpenAI.Chat.Completions.ChatCompletionMessageParam[];
|
|
6
20
|
/** Reduce an OpenAI response message to text + tool calls (pure; tested). */
|
|
7
21
|
export declare function parseOpenAIMessage(message: OpenAI.Chat.Completions.ChatCompletionMessage): ConverseResult;
|
|
8
22
|
/**
|
|
9
|
-
* Map an OpenAI `usage` block to the kernel's token accounting (pure;
|
|
10
|
-
* `prompt_tokens` already includes cached input, so it maps to
|
|
11
|
-
* as-is and `cached_tokens` is the cache-read breakdown. OpenAI
|
|
12
|
-
*
|
|
23
|
+
* Map an OpenAI-dialect `usage` block to the kernel's token accounting (pure;
|
|
24
|
+
* tested). `prompt_tokens` already includes cached input, so it maps to
|
|
25
|
+
* `inputTokens` as-is and `cached_tokens` is the cache-read breakdown. OpenAI
|
|
26
|
+
* reports no write count; OpenRouter does (`cache_write_tokens`), and prices
|
|
27
|
+
* the call (`cost`), so both are carried when present. Reasoning tokens are
|
|
28
|
+
* the `completion_tokens_details` breakdown either side reports.
|
|
13
29
|
*/
|
|
14
30
|
export declare function openAIUsage(usage: OpenAI.Completions.CompletionUsage | null | undefined): TokenUsage | undefined;
|
|
15
31
|
/** Constructor options for an OpenAI-compatible (chat.completions) provider. */
|
|
@@ -25,6 +41,34 @@ export interface OpenAICompatibleOptions {
|
|
|
25
41
|
*/
|
|
26
42
|
defaultHeaders?: Record<string, string | null>;
|
|
27
43
|
}
|
|
44
|
+
/** The adapter names whose dialect differences this core knows about. */
|
|
45
|
+
export declare const OPENAI_ADAPTER = "openai";
|
|
46
|
+
export declare const OPENROUTER_ADAPTER = "openrouter";
|
|
47
|
+
/**
|
|
48
|
+
* The chat.completions request body plus the fields OpenRouter adds to the
|
|
49
|
+
* dialect (`models`, `provider`, `usage`, `transforms`). The SDK forwards
|
|
50
|
+
* unknown body fields untouched, so they are typed here as an extension rather
|
|
51
|
+
* than cast away at the call site.
|
|
52
|
+
*/
|
|
53
|
+
export type OpenAICompatibleBody = OpenAI.Chat.Completions.ChatCompletionCreateParamsNonStreaming & {
|
|
54
|
+
models?: string[];
|
|
55
|
+
provider?: Record<string, unknown>;
|
|
56
|
+
usage?: {
|
|
57
|
+
include: boolean;
|
|
58
|
+
};
|
|
59
|
+
transforms?: string[];
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Build the chat.completions request for one conversation step (pure; tested).
|
|
63
|
+
*
|
|
64
|
+
* `name` selects the dialect: `openrouter` accepts the `openrouter` options
|
|
65
|
+
* block and places prompt-cache breakpoints as content parts; `openai` maps
|
|
66
|
+
* `promptCache.key` onto `prompt_cache_key` (its caching is otherwise
|
|
67
|
+
* automatic, so breakpoints have nothing to attach to); any other name (local
|
|
68
|
+
* servers, custom endpoints) gets the plain dialect and rejects the
|
|
69
|
+
* OpenRouter block.
|
|
70
|
+
*/
|
|
71
|
+
export declare function openAICompatibleRequestBody(name: string, model: string, req: ConverseRequest, fallbackMaxTokens?: number): OpenAICompatibleBody;
|
|
28
72
|
/**
|
|
29
73
|
* Shared core for providers speaking the OpenAI chat.completions dialect
|
|
30
74
|
* (including tools). OpenAI proper and OpenRouter both instantiate this —
|
|
@@ -33,8 +77,8 @@ export interface OpenAICompatibleOptions {
|
|
|
33
77
|
export declare class OpenAICompatibleProvider implements Provider {
|
|
34
78
|
readonly name: string;
|
|
35
79
|
readonly reportsUsage = true;
|
|
80
|
+
readonly model: string;
|
|
36
81
|
private client;
|
|
37
|
-
private model;
|
|
38
82
|
constructor(name: string, opts: OpenAICompatibleOptions);
|
|
39
83
|
complete(req: CompletionRequest): Promise<string>;
|
|
40
84
|
converse(req: ConverseRequest, opts?: ConverseOptions): Promise<ConverseResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,cAAc,EACd,QAAQ,EAET,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,OAAO,EAKL,KAAK,QAAQ,EAEd,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,cAAc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,EAAE,CAAA;CACtB,CAAA;AAEH;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,eAAe,EACpB,iBAAiB,GAAE,MAAoB,GACtC,oBAAoB,CA2CtB;AAED;;;;GAIG;AACH,qBAAa,wBAAyB,YAAW,QAAQ;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,YAAY,QAAO;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,OAAO,CAAC,MAAM,CAAQ;gBAEV,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB;IAejD,QAAQ,CAAC,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgBjD,QAAQ,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;CA6BtF;AAED,qBAAa,cAAe,SAAQ,wBAAwB;gBAC9C,MAAM,EAAE,MAAM,EAAE,KAAK,SAAwC;CAG1E"}
|
package/dist/providers/openai.js
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
2
|
import { maxTokens, providerMaxRetries, providerTimeoutMs } from "./clientOptions.js";
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { rejectOption, resolveMaxRetries, resolveMaxTokens, resolvePromptCache, } from "./options.js";
|
|
4
|
+
function cachedPart(text, ttl) {
|
|
5
|
+
return { type: "text", text, cache_control: { type: "ephemeral", ...(ttl ? { ttl } : {}) } };
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Map provider-neutral messages to OpenAI chat messages (pure; tested).
|
|
9
|
+
*
|
|
10
|
+
* With `cache` set (OpenRouter), the trailing N messages are sent as content
|
|
11
|
+
* parts with a `cache_control` breakpoint on their text. An assistant message
|
|
12
|
+
* with no prose has nowhere to put one and is left as it was; a tool message
|
|
13
|
+
* puts it on its last result. Messages outside the window keep the plain
|
|
14
|
+
* string form.
|
|
15
|
+
*/
|
|
16
|
+
export function toOpenAIMessages(messages, cache) {
|
|
5
17
|
const out = [];
|
|
6
|
-
|
|
18
|
+
const firstCached = cache ? Math.max(0, messages.length - cache.trailingMessages) : Infinity;
|
|
19
|
+
messages.forEach((m, index) => {
|
|
20
|
+
const mark = cache !== undefined && index >= firstCached;
|
|
7
21
|
if (m.role === "user") {
|
|
8
|
-
out.push({ role: "user", content: m.text });
|
|
22
|
+
out.push({ role: "user", content: mark ? [cachedPart(m.text, cache.ttl)] : m.text });
|
|
9
23
|
}
|
|
10
24
|
else if (m.role === "assistant") {
|
|
11
25
|
const msg = {
|
|
12
26
|
role: "assistant",
|
|
13
|
-
content: m.text,
|
|
27
|
+
content: mark && m.text ? [cachedPart(m.text, cache.ttl)] : m.text,
|
|
14
28
|
};
|
|
15
29
|
if (m.toolCalls.length > 0) {
|
|
16
30
|
msg.tool_calls = m.toolCalls.map((tc) => ({
|
|
@@ -22,12 +36,18 @@ export function toOpenAIMessages(messages) {
|
|
|
22
36
|
out.push(msg);
|
|
23
37
|
}
|
|
24
38
|
else {
|
|
25
|
-
// Each tool result becomes its own `tool` message keyed by the call id
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
// Each tool result becomes its own `tool` message keyed by the call id;
|
|
40
|
+
// the breakpoint goes on the last one so the whole batch sits inside it.
|
|
41
|
+
m.results.forEach((r, i) => {
|
|
42
|
+
const last = i === m.results.length - 1;
|
|
43
|
+
out.push({
|
|
44
|
+
role: "tool",
|
|
45
|
+
tool_call_id: r.toolCallId,
|
|
46
|
+
content: mark && last ? [cachedPart(r.content, cache.ttl)] : r.content,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
29
49
|
}
|
|
30
|
-
}
|
|
50
|
+
});
|
|
31
51
|
return out;
|
|
32
52
|
}
|
|
33
53
|
/** Reduce an OpenAI response message to text + tool calls (pure; tested). */
|
|
@@ -48,20 +68,31 @@ export function parseOpenAIMessage(message) {
|
|
|
48
68
|
return { text, toolCalls };
|
|
49
69
|
}
|
|
50
70
|
/**
|
|
51
|
-
* Map an OpenAI `usage` block to the kernel's token accounting (pure;
|
|
52
|
-
* `prompt_tokens` already includes cached input, so it maps to
|
|
53
|
-
* as-is and `cached_tokens` is the cache-read breakdown. OpenAI
|
|
54
|
-
*
|
|
71
|
+
* Map an OpenAI-dialect `usage` block to the kernel's token accounting (pure;
|
|
72
|
+
* tested). `prompt_tokens` already includes cached input, so it maps to
|
|
73
|
+
* `inputTokens` as-is and `cached_tokens` is the cache-read breakdown. OpenAI
|
|
74
|
+
* reports no write count; OpenRouter does (`cache_write_tokens`), and prices
|
|
75
|
+
* the call (`cost`), so both are carried when present. Reasoning tokens are
|
|
76
|
+
* the `completion_tokens_details` breakdown either side reports.
|
|
55
77
|
*/
|
|
56
78
|
export function openAIUsage(usage) {
|
|
57
79
|
if (!usage)
|
|
58
80
|
return undefined;
|
|
81
|
+
const extended = usage;
|
|
59
82
|
const cached = usage.prompt_tokens_details?.cached_tokens ?? 0;
|
|
83
|
+
const written = extended.prompt_tokens_details?.cache_write_tokens ?? 0;
|
|
84
|
+
const reasoning = usage.completion_tokens_details?.reasoning_tokens ?? 0;
|
|
85
|
+
const cost = extended.cost;
|
|
60
86
|
return {
|
|
61
87
|
inputTokens: usage.prompt_tokens,
|
|
62
88
|
outputTokens: usage.completion_tokens,
|
|
63
89
|
totalTokens: usage.total_tokens,
|
|
64
90
|
...(cached > 0 ? { cacheReadTokens: cached } : {}),
|
|
91
|
+
...(written > 0 ? { cacheWriteTokens: written } : {}),
|
|
92
|
+
...(reasoning > 0 ? { reasoningTokens: reasoning } : {}),
|
|
93
|
+
...(typeof cost === "number" && Number.isFinite(cost)
|
|
94
|
+
? { reportedCost: { amount: cost, currency: "USD" } }
|
|
95
|
+
: {}),
|
|
65
96
|
};
|
|
66
97
|
}
|
|
67
98
|
/** Parse a tool-call arguments JSON string, tolerating empty/invalid input. */
|
|
@@ -76,6 +107,64 @@ function parseArguments(raw) {
|
|
|
76
107
|
return {};
|
|
77
108
|
}
|
|
78
109
|
}
|
|
110
|
+
/** The adapter names whose dialect differences this core knows about. */
|
|
111
|
+
export const OPENAI_ADAPTER = "openai";
|
|
112
|
+
export const OPENROUTER_ADAPTER = "openrouter";
|
|
113
|
+
/**
|
|
114
|
+
* Build the chat.completions request for one conversation step (pure; tested).
|
|
115
|
+
*
|
|
116
|
+
* `name` selects the dialect: `openrouter` accepts the `openrouter` options
|
|
117
|
+
* block and places prompt-cache breakpoints as content parts; `openai` maps
|
|
118
|
+
* `promptCache.key` onto `prompt_cache_key` (its caching is otherwise
|
|
119
|
+
* automatic, so breakpoints have nothing to attach to); any other name (local
|
|
120
|
+
* servers, custom endpoints) gets the plain dialect and rejects the
|
|
121
|
+
* OpenRouter block.
|
|
122
|
+
*/
|
|
123
|
+
export function openAICompatibleRequestBody(name, model, req, fallbackMaxTokens = maxTokens()) {
|
|
124
|
+
const options = req.providerOptions;
|
|
125
|
+
const isOpenRouter = name === OPENROUTER_ADAPTER;
|
|
126
|
+
if (!isOpenRouter)
|
|
127
|
+
rejectOption(name, options, "openrouter");
|
|
128
|
+
const cache = options?.promptCache
|
|
129
|
+
? resolvePromptCache(options.promptCache)
|
|
130
|
+
: undefined;
|
|
131
|
+
const ttl = cache?.ttl;
|
|
132
|
+
const tools = req.tools.map((t) => ({
|
|
133
|
+
type: "function",
|
|
134
|
+
function: { name: t.name, description: t.description, parameters: t.inputSchema },
|
|
135
|
+
}));
|
|
136
|
+
const system = isOpenRouter && cache?.system && req.system
|
|
137
|
+
? { role: "system", content: [cachedPart(req.system, ttl)] }
|
|
138
|
+
: { role: "system", content: req.system };
|
|
139
|
+
const messageCache = isOpenRouter && cache && cache.trailingMessages > 0
|
|
140
|
+
? { trailingMessages: cache.trailingMessages, ...(ttl ? { ttl } : {}) }
|
|
141
|
+
: undefined;
|
|
142
|
+
// OpenAI retired `max_tokens` in favour of `max_completion_tokens` (its
|
|
143
|
+
// reasoning models reject the old name); OpenRouter and the local servers
|
|
144
|
+
// document `max_tokens`, so each dialect gets the field it names.
|
|
145
|
+
const cap = resolveMaxTokens(options, fallbackMaxTokens);
|
|
146
|
+
const body = {
|
|
147
|
+
model,
|
|
148
|
+
...(name === OPENAI_ADAPTER ? { max_completion_tokens: cap } : { max_tokens: cap }),
|
|
149
|
+
messages: [system, ...toOpenAIMessages(req.messages, messageCache)],
|
|
150
|
+
...(tools.length > 0 ? { tools } : {}),
|
|
151
|
+
...(options?.responseFormat ? { response_format: options.responseFormat } : {}),
|
|
152
|
+
};
|
|
153
|
+
if (name === OPENAI_ADAPTER && cache?.key)
|
|
154
|
+
body.prompt_cache_key = cache.key;
|
|
155
|
+
if (isOpenRouter && options?.openrouter) {
|
|
156
|
+
const or = options.openrouter;
|
|
157
|
+
if (or.models)
|
|
158
|
+
body.models = or.models;
|
|
159
|
+
if (or.provider)
|
|
160
|
+
body.provider = { ...or.provider };
|
|
161
|
+
if (or.usage)
|
|
162
|
+
body.usage = or.usage;
|
|
163
|
+
if (or.transforms)
|
|
164
|
+
body.transforms = or.transforms;
|
|
165
|
+
}
|
|
166
|
+
return body;
|
|
167
|
+
}
|
|
79
168
|
/**
|
|
80
169
|
* Shared core for providers speaking the OpenAI chat.completions dialect
|
|
81
170
|
* (including tools). OpenAI proper and OpenRouter both instantiate this —
|
|
@@ -84,8 +173,8 @@ function parseArguments(raw) {
|
|
|
84
173
|
export class OpenAICompatibleProvider {
|
|
85
174
|
name;
|
|
86
175
|
reportsUsage = true;
|
|
87
|
-
client;
|
|
88
176
|
model;
|
|
177
|
+
client;
|
|
89
178
|
constructor(name, opts) {
|
|
90
179
|
// The SDK retries transient 429/5xx/network errors with exponential backoff
|
|
91
180
|
// internally, so a blip doesn't fail the whole run; `timeout` bounds each
|
|
@@ -103,7 +192,10 @@ export class OpenAICompatibleProvider {
|
|
|
103
192
|
async complete(req) {
|
|
104
193
|
const completion = await this.client.chat.completions.create({
|
|
105
194
|
model: this.model,
|
|
106
|
-
|
|
195
|
+
// Same field rule as `converse`: OpenAI's current name, the documented one elsewhere.
|
|
196
|
+
...(this.name === OPENAI_ADAPTER
|
|
197
|
+
? { max_completion_tokens: maxTokens() }
|
|
198
|
+
: { max_tokens: maxTokens() }),
|
|
107
199
|
messages: [
|
|
108
200
|
{ role: "system", content: req.system },
|
|
109
201
|
{ role: "user", content: req.prompt },
|
|
@@ -112,27 +204,33 @@ export class OpenAICompatibleProvider {
|
|
|
112
204
|
return completion.choices[0]?.message?.content ?? "";
|
|
113
205
|
}
|
|
114
206
|
async converse(req, opts) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
messages: [{ role: "system", content: req.system }, ...toOpenAIMessages(req.messages)],
|
|
123
|
-
...(tools.length > 0 ? { tools } : {}),
|
|
124
|
-
},
|
|
125
|
-
// Per-request, so an abort cancels THIS call (retries included).
|
|
126
|
-
opts?.signal ? { signal: opts.signal } : undefined);
|
|
207
|
+
// Per-request options, so an abort cancels THIS call (retries included)
|
|
208
|
+
// and a per-call retry count leaves the shared client untouched.
|
|
209
|
+
const retries = resolveMaxRetries(req.providerOptions);
|
|
210
|
+
const completion = await this.client.chat.completions.create(openAICompatibleRequestBody(this.name, this.model, req), {
|
|
211
|
+
...(opts?.signal ? { signal: opts.signal } : {}),
|
|
212
|
+
...(retries !== undefined ? { maxRetries: retries } : {}),
|
|
213
|
+
});
|
|
127
214
|
const usage = openAIUsage(completion.usage);
|
|
128
215
|
const message = completion.choices[0]?.message;
|
|
129
216
|
const parsed = message ? parseOpenAIMessage(message) : { text: "", toolCalls: [] };
|
|
130
|
-
|
|
217
|
+
// OpenRouter adds a top-level `provider` naming the upstream that served
|
|
218
|
+
// the request; the SDK's response type does not know it, so read it loosely.
|
|
219
|
+
const upstream = this.name === OPENROUTER_ADAPTER ? completion.provider : undefined;
|
|
220
|
+
return {
|
|
221
|
+
...parsed,
|
|
222
|
+
...(usage ? { usage } : {}),
|
|
223
|
+
...(typeof completion.model === "string" && completion.model
|
|
224
|
+
? { model: completion.model }
|
|
225
|
+
: {}),
|
|
226
|
+
...(typeof completion.id === "string" && completion.id ? { responseId: completion.id } : {}),
|
|
227
|
+
...(typeof upstream === "string" && upstream ? { upstream } : {}),
|
|
228
|
+
};
|
|
131
229
|
}
|
|
132
230
|
}
|
|
133
231
|
export class OpenAIProvider extends OpenAICompatibleProvider {
|
|
134
232
|
constructor(apiKey, model = process.env.OPENAI_MODEL ?? "gpt-4.1") {
|
|
135
|
-
super(
|
|
233
|
+
super(OPENAI_ADAPTER, { apiKey, model });
|
|
136
234
|
}
|
|
137
235
|
}
|
|
138
236
|
//# sourceMappingURL=openai.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"openai.js","sourceRoot":"","sources":["../../src/providers/openai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAE3B,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACrF,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,GAGnB,MAAM,cAAc,CAAA;AAqBrB,SAAS,UAAU,CAAC,IAAY,EAAE,GAAyB;IACzD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CA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QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClE,CAAA;IACH,CAAC;CACF;AAED,MAAM,OAAO,cAAe,SAAQ,wBAAwB;IAC1D,YAAY,MAAc,EAAE,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,SAAS;QACvE,KAAK,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-call provider options: the typed passthrough from a caller to the adapter
|
|
3
|
+
* that makes the HTTP request.
|
|
4
|
+
*
|
|
5
|
+
* Two kinds of thing live here, and the split is deliberate:
|
|
6
|
+
*
|
|
7
|
+
* - **Neutral options** (`maxTokens`, `promptCache`, `responseFormat`) name an
|
|
8
|
+
* intent, and each adapter maps it onto its own wire format as well as it
|
|
9
|
+
* can. Prompt caching is the clearest case: Anthropic wants explicit
|
|
10
|
+
* `cache_control` breakpoints, OpenRouter wants them inside content parts,
|
|
11
|
+
* OpenAI caches prefixes automatically and only takes a routing key.
|
|
12
|
+
* - **Adapter-addressed options** (`openrouter`) carry one API's own
|
|
13
|
+
* vocabulary verbatim, snake_case and all, because translating them would
|
|
14
|
+
* only add a place for the two to drift.
|
|
15
|
+
*
|
|
16
|
+
* Either way, an option an adapter cannot honour is an error, never a silent
|
|
17
|
+
* drop: a caller that asked for zero-data-retention routing and got a request
|
|
18
|
+
* that said nothing about it would have no way to notice.
|
|
19
|
+
*/
|
|
20
|
+
/** How long a cache breakpoint keeps its entry alive (Anthropic and OpenRouter). */
|
|
21
|
+
export type CacheTtl = "5m" | "1h";
|
|
22
|
+
/**
|
|
23
|
+
* Where to place prompt-cache breakpoints. Every field is optional; passing
|
|
24
|
+
* `promptCache: {}` means "cache this prompt the usual way": the system prompt,
|
|
25
|
+
* the tool definitions and the last message, so the next call in the same
|
|
26
|
+
* conversation reads the whole prefix from cache.
|
|
27
|
+
*
|
|
28
|
+
* Breakpoints exist on Anthropic (`cache_control`) and OpenRouter (content
|
|
29
|
+
* parts). The `openai` adapter has no breakpoints to place (its caching is
|
|
30
|
+
* automatic over the prefix) and honours only `key`; the `local` adapter and
|
|
31
|
+
* any custom OpenAI-compatible endpoint accept the option and leave caching to
|
|
32
|
+
* the server's own prefix cache. Those two are best effort by design rather
|
|
33
|
+
* than an error: "cache this prompt" is an intent every adapter can honour as
|
|
34
|
+
* well as its API allows, unlike an option addressed to a different API.
|
|
35
|
+
*/
|
|
36
|
+
export interface PromptCacheOptions {
|
|
37
|
+
/** Breakpoint after the system prompt. Default `true`. */
|
|
38
|
+
system?: boolean;
|
|
39
|
+
/** Breakpoint after the tool definitions (Anthropic only). Default `true`. */
|
|
40
|
+
tools?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* How many trailing messages get a breakpoint on their last content block.
|
|
43
|
+
* Default 1; clamped to {@link MAX_TRAILING_CACHE_MESSAGES} because Anthropic
|
|
44
|
+
* allows four breakpoints per request and two are spent on system and tools.
|
|
45
|
+
*/
|
|
46
|
+
trailingMessages?: number;
|
|
47
|
+
/** Cache lifetime for every breakpoint this call places. Default is the provider's (`5m`). */
|
|
48
|
+
ttl?: CacheTtl;
|
|
49
|
+
/** OpenAI `prompt_cache_key`: routes requests sharing a prefix to the same cache. */
|
|
50
|
+
key?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Anthropic's breakpoint ceiling is four; two go to system and tools. */
|
|
53
|
+
export declare const MAX_TRAILING_CACHE_MESSAGES = 2;
|
|
54
|
+
/** The resolved form of {@link PromptCacheOptions}: every default applied. */
|
|
55
|
+
export interface ResolvedPromptCache {
|
|
56
|
+
system: boolean;
|
|
57
|
+
tools: boolean;
|
|
58
|
+
trailingMessages: number;
|
|
59
|
+
ttl?: CacheTtl;
|
|
60
|
+
key?: string;
|
|
61
|
+
}
|
|
62
|
+
/** Apply the defaults and the clamp. */
|
|
63
|
+
export declare function resolvePromptCache(options: PromptCacheOptions): ResolvedPromptCache;
|
|
64
|
+
/**
|
|
65
|
+
* The OpenAI chat.completions `response_format` shape, which OpenRouter and most
|
|
66
|
+
* OpenAI-compatible servers accept as-is. The Anthropic adapter rejects it: the
|
|
67
|
+
* Messages API has no equivalent field, and a structured answer there is a
|
|
68
|
+
* terminal tool with a schema.
|
|
69
|
+
*/
|
|
70
|
+
export type ResponseFormat = {
|
|
71
|
+
type: "text";
|
|
72
|
+
} | {
|
|
73
|
+
type: "json_object";
|
|
74
|
+
} | {
|
|
75
|
+
type: "json_schema";
|
|
76
|
+
json_schema: {
|
|
77
|
+
name: string;
|
|
78
|
+
description?: string;
|
|
79
|
+
schema?: Record<string, unknown>;
|
|
80
|
+
strict?: boolean | null;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* OpenRouter's `provider` routing preferences, passed through verbatim (hence
|
|
85
|
+
* snake_case: these are OpenRouter's own field names). `data_collection: "deny"`
|
|
86
|
+
* and `zdr: true` are the data-policy knobs: the first excludes upstreams that
|
|
87
|
+
* may store or train on prompts, the second restricts routing to upstreams
|
|
88
|
+
* with a zero-data-retention policy.
|
|
89
|
+
*/
|
|
90
|
+
export interface OpenRouterProviderPreferences {
|
|
91
|
+
/** Upstreams to try, in order. */
|
|
92
|
+
order?: string[];
|
|
93
|
+
/** Only these upstreams may serve the request. */
|
|
94
|
+
only?: string[];
|
|
95
|
+
/** Never route to these upstreams. */
|
|
96
|
+
ignore?: string[];
|
|
97
|
+
/** Whether to fall back past `order` when those upstreams fail. */
|
|
98
|
+
allow_fallbacks?: boolean;
|
|
99
|
+
/** Only route to upstreams that support every parameter in the request. */
|
|
100
|
+
require_parameters?: boolean;
|
|
101
|
+
/** `deny` excludes upstreams that may store or train on the prompt. */
|
|
102
|
+
data_collection?: "allow" | "deny";
|
|
103
|
+
/** Restrict routing to upstreams with a zero-data-retention policy. */
|
|
104
|
+
zdr?: boolean;
|
|
105
|
+
/** Routing priority when several upstreams qualify. */
|
|
106
|
+
sort?: "price" | "throughput" | "latency" | (string & {});
|
|
107
|
+
/** Acceptable quantization levels, e.g. `["fp16", "bf16"]`. */
|
|
108
|
+
quantizations?: string[];
|
|
109
|
+
/** Price ceilings per million tokens, in OpenRouter's own keys (`prompt`, `completion`, …). */
|
|
110
|
+
max_price?: Record<string, number>;
|
|
111
|
+
}
|
|
112
|
+
/** Options only the OpenRouter adapter can honour. */
|
|
113
|
+
export interface OpenRouterOptions {
|
|
114
|
+
/** Fallback model ids, tried in order when the primary model fails or is unavailable. */
|
|
115
|
+
models?: string[];
|
|
116
|
+
/** Upstream routing and data-policy preferences. */
|
|
117
|
+
provider?: OpenRouterProviderPreferences;
|
|
118
|
+
/** `{ include: true }` asks for token accounting (incl. cache reads) in the response. */
|
|
119
|
+
usage?: {
|
|
120
|
+
include: boolean;
|
|
121
|
+
};
|
|
122
|
+
/** OpenRouter prompt transforms, e.g. `["middle-out"]`. */
|
|
123
|
+
transforms?: string[];
|
|
124
|
+
}
|
|
125
|
+
/** Everything a caller may hand an adapter for one request. */
|
|
126
|
+
export interface ProviderOptions {
|
|
127
|
+
/** Completion token cap for this call; overrides `RUNNER_MAX_TOKENS`. */
|
|
128
|
+
maxTokens?: number;
|
|
129
|
+
/**
|
|
130
|
+
* SDK retry count for this call; overrides `RUNNER_PROVIDER_MAX_RETRIES`.
|
|
131
|
+
* Set `0` when the request carries its own fallback chain (OpenRouter
|
|
132
|
+
* `models`), so a transient upstream failure is not retried by the SDK and
|
|
133
|
+
* then again by the router.
|
|
134
|
+
*/
|
|
135
|
+
maxRetries?: number;
|
|
136
|
+
/** Prompt caching. Each adapter maps it onto its own mechanism. */
|
|
137
|
+
promptCache?: PromptCacheOptions;
|
|
138
|
+
/** Structured-output format (OpenAI-compatible adapters only). */
|
|
139
|
+
responseFormat?: ResponseFormat;
|
|
140
|
+
/** OpenRouter-only routing options; any other adapter rejects them. */
|
|
141
|
+
openrouter?: OpenRouterOptions;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Thrown when an option is addressed to an adapter that cannot honour it. The
|
|
145
|
+
* kernel never drops an option on the floor: silence here is how a request
|
|
146
|
+
* meant for a zero-data-retention route ends up somewhere else.
|
|
147
|
+
*/
|
|
148
|
+
export declare class ProviderOptionsError extends Error {
|
|
149
|
+
readonly adapter: string;
|
|
150
|
+
readonly option: keyof ProviderOptions;
|
|
151
|
+
constructor(adapter: string, option: keyof ProviderOptions, detail?: string);
|
|
152
|
+
}
|
|
153
|
+
/** Throw if `options` carries `option`, for an adapter that cannot honour it. */
|
|
154
|
+
export declare function rejectOption(adapter: string, options: ProviderOptions | undefined, option: keyof ProviderOptions, detail?: string): void;
|
|
155
|
+
/** The per-call retry count when given and non-negative, else undefined (the client's default). */
|
|
156
|
+
export declare function resolveMaxRetries(options: ProviderOptions | undefined): number | undefined;
|
|
157
|
+
/**
|
|
158
|
+
* The per-call completion cap: the option when given and positive, else the
|
|
159
|
+
* caller's fallback (normally the env-resolved `RUNNER_MAX_TOKENS`).
|
|
160
|
+
*/
|
|
161
|
+
export declare function resolveMaxTokens(options: ProviderOptions | undefined, fallback: number): number;
|
|
162
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/providers/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,oFAAoF;AACpF,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,IAAI,CAAA;AAElC;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,8EAA8E;IAC9E,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,8FAA8F;IAC9F,GAAG,C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