narrarium-engine 0.1.7 → 0.1.9
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 +360 -26
- package/dist/ai/body.d.ts +20 -0
- package/dist/ai/body.d.ts.map +1 -0
- package/dist/ai/body.js +112 -0
- package/dist/ai/body.js.map +1 -0
- package/dist/ai/catalog-fetch.d.ts +51 -0
- package/dist/ai/catalog-fetch.d.ts.map +1 -0
- package/dist/ai/catalog-fetch.js +261 -0
- package/dist/ai/catalog-fetch.js.map +1 -0
- package/dist/ai/catalog-support.d.ts +13 -0
- package/dist/ai/catalog-support.d.ts.map +1 -0
- package/dist/ai/catalog-support.js +28 -0
- package/dist/ai/catalog-support.js.map +1 -0
- package/dist/ai/catalog.d.ts +148 -0
- package/dist/ai/catalog.d.ts.map +1 -0
- package/dist/ai/catalog.js +367 -0
- package/dist/ai/catalog.js.map +1 -0
- package/dist/ai/config.d.ts +83 -7
- package/dist/ai/config.d.ts.map +1 -1
- package/dist/ai/config.js +83 -11
- package/dist/ai/config.js.map +1 -1
- package/dist/ai/fetch-client.d.ts +20 -0
- package/dist/ai/fetch-client.d.ts.map +1 -1
- package/dist/ai/fetch-client.js +49 -24
- package/dist/ai/fetch-client.js.map +1 -1
- package/dist/ai/probe.d.ts +40 -0
- package/dist/ai/probe.d.ts.map +1 -0
- package/dist/ai/probe.js +110 -0
- package/dist/ai/probe.js.map +1 -0
- package/dist/ai/request.d.ts +58 -5
- package/dist/ai/request.d.ts.map +1 -1
- package/dist/ai/request.js +96 -7
- package/dist/ai/request.js.map +1 -1
- package/dist/ai/router.d.ts +12 -1
- package/dist/ai/router.d.ts.map +1 -1
- package/dist/ai/router.js +10 -2
- package/dist/ai/router.js.map +1 -1
- package/dist/ai/routing.d.ts +15 -4
- package/dist/ai/routing.d.ts.map +1 -1
- package/dist/ai/routing.js +25 -6
- package/dist/ai/routing.js.map +1 -1
- package/dist/ai/token-limit.d.ts +4 -4
- package/dist/ai/token-limit.d.ts.map +1 -1
- package/dist/ai/token-limit.js +5 -4
- package/dist/ai/token-limit.js.map +1 -1
- package/dist/ai/types.d.ts +12 -1
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/ai/types.js +12 -0
- package/dist/ai/types.js.map +1 -1
- package/dist/autopilot/errors.d.ts +4 -3
- package/dist/autopilot/errors.d.ts.map +1 -1
- package/dist/autopilot/errors.js +21 -5
- package/dist/autopilot/errors.js.map +1 -1
- package/dist/autopilot/frozen.d.ts +169 -0
- package/dist/autopilot/frozen.d.ts.map +1 -0
- package/dist/autopilot/frozen.js +495 -0
- package/dist/autopilot/frozen.js.map +1 -0
- package/dist/autopilot/outline-check.d.ts +39 -0
- package/dist/autopilot/outline-check.d.ts.map +1 -0
- package/dist/autopilot/outline-check.js +81 -0
- package/dist/autopilot/outline-check.js.map +1 -0
- package/dist/autopilot/planner.d.ts +29 -1
- package/dist/autopilot/planner.d.ts.map +1 -1
- package/dist/autopilot/planner.js +78 -8
- package/dist/autopilot/planner.js.map +1 -1
- package/dist/autopilot/profile-check.d.ts +7 -4
- package/dist/autopilot/profile-check.d.ts.map +1 -1
- package/dist/autopilot/profile-check.js +9 -6
- package/dist/autopilot/profile-check.js.map +1 -1
- package/dist/autopilot/runner.d.ts +17 -3
- package/dist/autopilot/runner.d.ts.map +1 -1
- package/dist/autopilot/runner.js +127 -20
- package/dist/autopilot/runner.js.map +1 -1
- package/dist/autopilot/session.d.ts +34 -1
- package/dist/autopilot/session.d.ts.map +1 -1
- package/dist/autopilot/session.js +202 -2
- package/dist/autopilot/session.js.map +1 -1
- package/dist/autopilot/state.d.ts +12 -3
- package/dist/autopilot/state.d.ts.map +1 -1
- package/dist/autopilot/state.js +203 -12
- package/dist/autopilot/state.js.map +1 -1
- package/dist/autopilot/tasks.d.ts +14 -2
- package/dist/autopilot/tasks.d.ts.map +1 -1
- package/dist/autopilot/tasks.js +480 -36
- package/dist/autopilot/tasks.js.map +1 -1
- package/dist/autopilot/types.d.ts +193 -12
- package/dist/autopilot/types.d.ts.map +1 -1
- package/dist/autopilot/types.js +9 -2
- package/dist/autopilot/types.js.map +1 -1
- package/dist/book/context.d.ts +3 -0
- package/dist/book/context.d.ts.map +1 -1
- package/dist/book/context.js +7 -1
- package/dist/book/context.js.map +1 -1
- package/dist/book/freeze.d.ts +115 -0
- package/dist/book/freeze.d.ts.map +1 -0
- package/dist/book/freeze.js +286 -0
- package/dist/book/freeze.js.map +1 -0
- package/dist/book/outline.d.ts +245 -0
- package/dist/book/outline.d.ts.map +1 -0
- package/dist/book/outline.js +488 -0
- package/dist/book/outline.js.map +1 -0
- package/dist/book/paths.d.ts +18 -0
- package/dist/book/paths.d.ts.map +1 -1
- package/dist/book/paths.js +25 -0
- package/dist/book/paths.js.map +1 -1
- package/dist/book/snapshot.d.ts +25 -1
- package/dist/book/snapshot.d.ts.map +1 -1
- package/dist/book/snapshot.js +24 -4
- package/dist/book/snapshot.js.map +1 -1
- package/dist/director/opinion.d.ts +6 -0
- package/dist/director/opinion.d.ts.map +1 -1
- package/dist/director/opinion.js +4 -1
- package/dist/director/opinion.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/profiles/evaluation-style.d.ts +44 -0
- package/dist/profiles/evaluation-style.d.ts.map +1 -0
- package/dist/profiles/evaluation-style.js +152 -0
- package/dist/profiles/evaluation-style.js.map +1 -0
- package/dist/server/client.d.ts +46 -2
- package/dist/server/client.d.ts.map +1 -1
- package/dist/server/client.js +57 -0
- package/dist/server/client.js.map +1 -1
- package/dist/server/protocol.d.ts +120 -2
- package/dist/server/protocol.d.ts.map +1 -1
- package/dist/server/protocol.js +36 -0
- package/dist/server/protocol.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/ai/config.d.ts
CHANGED
|
@@ -11,8 +11,28 @@ export interface AiChatModelConfig {
|
|
|
11
11
|
name: string;
|
|
12
12
|
underlyingModel?: string;
|
|
13
13
|
capabilities: string[];
|
|
14
|
+
/** The model can be asked to answer through a function. Only `false` has an effect: with "Tools only" on, a structured request skips the model. */
|
|
14
15
|
supportsToolCalls?: boolean;
|
|
16
|
+
/** The model streams its replies. Only `false` has an effect: the model is then called without `stream`, whatever the integration's `streamMode` says. */
|
|
17
|
+
supportsStreaming?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* The model reasons. `true`: it gets the margin of output for its reasoning (as a model known to reason by its name), a reply cut before it wrote a
|
|
20
|
+
* word is a reply cut while reasoning, and a thinking level may be sent. `false`: a thinking level is not sent to it. The name of a model that is known
|
|
21
|
+
* to reason is not undone by `false`.
|
|
22
|
+
*/
|
|
23
|
+
supportsReasoning?: boolean;
|
|
24
|
+
/** The model reads images. Data only: nothing in a request depends on it. */
|
|
25
|
+
supportsVision?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* How the thinking level reaches this model ("Thinking parameter"): `reasoning_effort` (the OpenAI field; also what an absent value means, and the requests
|
|
28
|
+
* of a model that does not say are exactly the ones they always were), `chat_template_kwargs.reasoning_strength` (the level as an argument of the chat
|
|
29
|
+
* template: Muse Glimmer takes it so, and does not take `reasoning_effort`) or `none` (no level is sent, even when the task or the integration asks for one).
|
|
30
|
+
* `suggestedReasoningParameter` says what the documented sources know of a model name; the engine never applies it by itself.
|
|
31
|
+
*/
|
|
32
|
+
reasoningParameter?: AiReasoningParameter;
|
|
33
|
+
/** The context window of the model: what a prompt and its answer may be together. The engine subtracts the answer and a margin itself. */
|
|
15
34
|
maxInputTokens?: number;
|
|
35
|
+
/** The largest answer that can be asked of the model. */
|
|
16
36
|
maxOutputTokens?: number;
|
|
17
37
|
pricing?: AiPricingConfig;
|
|
18
38
|
}
|
|
@@ -21,6 +41,25 @@ export interface AiChatModelConfig {
|
|
|
21
41
|
* included, so that a provider that answers slowly is never silent; `off` never streams, for a provider or a proxy that cannot.
|
|
22
42
|
*/
|
|
23
43
|
export type AiStreamMode = "auto" | "off";
|
|
44
|
+
/**
|
|
45
|
+
* How hard a model is asked to think, per integration and per route target. `low`, `medium`, `high` and `xhigh` are sent to the provider as
|
|
46
|
+
* `reasoning_effort` (or as the argument of the chat template that the model's `reasoningParameter` says); `automatic` sends nothing (the provider's
|
|
47
|
+
* own default), even when the integration sets a level. Absent means nothing was chosen: a route target takes the level of its integration, and an
|
|
48
|
+
* integration without one sends nothing.
|
|
49
|
+
*/
|
|
50
|
+
export declare const AI_THINKING_LEVELS: readonly ["automatic", "low", "medium", "high", "xhigh"];
|
|
51
|
+
export type AiThinking = (typeof AI_THINKING_LEVELS)[number];
|
|
52
|
+
/** A thinking level as the engine keeps it: one of `AI_THINKING_LEVELS`, spelled exactly; anything else is no value. */
|
|
53
|
+
export declare function normalizeThinking(value: unknown): AiThinking | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* How a thinking level reaches a model: the setting of the model (`AiChatModelConfig.reasoningParameter`, "Thinking parameter"). `reasoning_effort` is the
|
|
56
|
+
* OpenAI field, and what is sent when a model says nothing; `chat_template_kwargs.reasoning_strength` sends the level as an argument of the model's chat
|
|
57
|
+
* template (`chat_template_kwargs: { reasoning_strength: <level> }`), which is how Muse Glimmer takes it; `none` sends no level to the model at all.
|
|
58
|
+
*/
|
|
59
|
+
export declare const AI_REASONING_PARAMETERS: readonly ["reasoning_effort", "chat_template_kwargs.reasoning_strength", "none"];
|
|
60
|
+
export type AiReasoningParameter = (typeof AI_REASONING_PARAMETERS)[number];
|
|
61
|
+
/** A thinking parameter as the engine keeps it: one of `AI_REASONING_PARAMETERS`, spelled exactly; anything else is no value. */
|
|
62
|
+
export declare function normalizeReasoningParameter(value: unknown): AiReasoningParameter | undefined;
|
|
24
63
|
/** The longest silence the engine waits for between two pieces of a streamed reply, unless the integration says otherwise. */
|
|
25
64
|
export declare const DEFAULT_IDLE_TIMEOUT_MS = 600000;
|
|
26
65
|
/** An integration's idle timeout is kept within these limits. */
|
|
@@ -42,6 +81,8 @@ export interface AiIntegrationConfig {
|
|
|
42
81
|
idleTimeoutMs?: number;
|
|
43
82
|
/** Absent: `auto`. */
|
|
44
83
|
streamMode?: AiStreamMode;
|
|
84
|
+
/** The thinking level of every model of this integration, unless a route target says another. Absent: none is sent. */
|
|
85
|
+
thinking?: AiThinking;
|
|
45
86
|
chatModels?: AiChatModelConfig[];
|
|
46
87
|
/** @deprecated legacy single-model fields, still honored. */
|
|
47
88
|
modelWriting?: string;
|
|
@@ -51,6 +92,8 @@ export interface AiIntegrationConfig {
|
|
|
51
92
|
export interface AiRouteTarget {
|
|
52
93
|
integrationId: string;
|
|
53
94
|
model: string;
|
|
95
|
+
/** The thinking level for this task with this model. Absent: the integration's; `automatic`: none, even when the integration has one. */
|
|
96
|
+
thinking?: AiThinking;
|
|
54
97
|
}
|
|
55
98
|
export interface AiTaskRoute {
|
|
56
99
|
primary?: AiRouteTarget;
|
|
@@ -87,6 +130,11 @@ export interface AiRuntimeConfig {
|
|
|
87
130
|
fallbackDisclosure?: AiFallbackDisclosure;
|
|
88
131
|
/** Absent fields are not limited: a call has no total time, token or cost limit. A configuration sent by the web app has them all. */
|
|
89
132
|
routingExecution?: Partial<AiRoutingExecution>;
|
|
133
|
+
/**
|
|
134
|
+
* "Tools only" (the settings call it `aiToolsOnly`): a structured reply must be the call of its function, and a model marked as without tool
|
|
135
|
+
* calls is not used for one. Absent or true: on. False: a model without tool calls gets the schema in the message, and a JSON in the reply's text is read.
|
|
136
|
+
*/
|
|
137
|
+
toolsOnly?: boolean;
|
|
90
138
|
}
|
|
91
139
|
/** The routing limits with the web app's normalization: whole numbers within the same bounds, the same defaults. */
|
|
92
140
|
export declare function normalizeRoutingExecution(raw: unknown): AiRoutingExecution;
|
|
@@ -102,16 +150,44 @@ export interface RedactedAiIntegration {
|
|
|
102
150
|
idleTimeoutMs?: number;
|
|
103
151
|
/** Whether replies stream, when the integration says (absent: `auto`). */
|
|
104
152
|
streamMode?: AiStreamMode;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}>;
|
|
153
|
+
/** The thinking level of the integration, when it sets one. */
|
|
154
|
+
thinking?: AiThinking;
|
|
155
|
+
models: RedactedAiModel[];
|
|
109
156
|
}
|
|
110
|
-
/**
|
|
111
|
-
export
|
|
157
|
+
/** A model as the safe view shows it: its name and routes, and what its configuration declares of it (only what it declares). */
|
|
158
|
+
export interface RedactedAiModel {
|
|
159
|
+
name: string;
|
|
160
|
+
capabilities: string[];
|
|
161
|
+
supportsToolCalls?: boolean;
|
|
162
|
+
supportsStreaming?: boolean;
|
|
163
|
+
supportsReasoning?: boolean;
|
|
164
|
+
supportsVision?: boolean;
|
|
165
|
+
/** How the thinking level reaches the model, when the model says (absent: `reasoning_effort`). */
|
|
166
|
+
reasoningParameter?: AiReasoningParameter;
|
|
167
|
+
maxInputTokens?: number;
|
|
168
|
+
maxOutputTokens?: number;
|
|
169
|
+
}
|
|
170
|
+
/** A route target as the safe view shows it: which model of which integration, and its thinking level when it sets one. */
|
|
171
|
+
export interface RedactedAiRouteTarget {
|
|
172
|
+
integrationId: string;
|
|
173
|
+
model: string;
|
|
174
|
+
thinking?: AiThinking;
|
|
175
|
+
}
|
|
176
|
+
export interface RedactedAiTaskRoute {
|
|
177
|
+
primary?: RedactedAiRouteTarget;
|
|
178
|
+
fallbacks: RedactedAiRouteTarget[];
|
|
179
|
+
}
|
|
180
|
+
/** What `redactAiRuntimeConfig` says: nothing in it is a secret. */
|
|
181
|
+
export interface RedactedAiRuntimeConfig {
|
|
112
182
|
integrations: RedactedAiIntegration[];
|
|
113
183
|
routedTasks: string[];
|
|
184
|
+
/** The route of every routed task (`{}` when none is), primary first, then the fallbacks in order. */
|
|
185
|
+
taskRouting: Record<string, RedactedAiTaskRoute>;
|
|
186
|
+
/** Whether "Tools only" is in force: true unless the configuration turned it off. */
|
|
187
|
+
toolsOnly: boolean;
|
|
114
188
|
fallbackDisclosure?: AiFallbackDisclosure;
|
|
115
189
|
routingExecution?: Partial<AiRoutingExecution>;
|
|
116
|
-
}
|
|
190
|
+
}
|
|
191
|
+
/** Safe view of a configuration: never exposes API keys. */
|
|
192
|
+
export declare function redactAiRuntimeConfig(config: AiRuntimeConfig): RedactedAiRuntimeConfig;
|
|
117
193
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/ai/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/ai/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,QAAQ,GAAG,eAAe,GAAG,cAAc,CAAC;AAE1F,+EAA+E;AAC/E,eAAO,MAAM,yBAAyB,eAAe,CAAC;AAEtD,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,eAAe,CAAC;CAC3B;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,KAAK,CAAC;AAE1C,8HAA8H;AAC9H,eAAO,MAAM,uBAAuB,SAAU,CAAC;AAC/C,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,QAAS,CAAC;AAC1C,eAAO,MAAM,mBAAmB,UAAY,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,cAAc,CAAC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,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,qBAAqB,CAAC;IAChC,SAAS,EAAE,qBAAqB,EAAE,CAAC;CACpC;AAED,oEAAoE;AACpE,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,qBAAqB,EAAE,CAAC;IACtC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,sGAAsG;IACtG,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACjD,qFAAqF;IACrF,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,oBAAoB,CAAC;IAC1C,gBAAgB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAChD;AAkCD,4DAA4D;AAC5D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,uBAAuB,CA2BtF"}
|
package/dist/ai/config.js
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
/** The Azure OpenAI API version used when an integration does not name one. */
|
|
2
2
|
export const DEFAULT_AZURE_API_VERSION = "2024-10-21";
|
|
3
|
+
/**
|
|
4
|
+
* How hard a model is asked to think, per integration and per route target. `low`, `medium`, `high` and `xhigh` are sent to the provider as
|
|
5
|
+
* `reasoning_effort` (or as the argument of the chat template that the model's `reasoningParameter` says); `automatic` sends nothing (the provider's
|
|
6
|
+
* own default), even when the integration sets a level. Absent means nothing was chosen: a route target takes the level of its integration, and an
|
|
7
|
+
* integration without one sends nothing.
|
|
8
|
+
*/
|
|
9
|
+
export const AI_THINKING_LEVELS = ["automatic", "low", "medium", "high", "xhigh"];
|
|
10
|
+
/** A thinking level as the engine keeps it: one of `AI_THINKING_LEVELS`, spelled exactly; anything else is no value. */
|
|
11
|
+
export function normalizeThinking(value) {
|
|
12
|
+
return typeof value === "string" && AI_THINKING_LEVELS.includes(value) ? value : undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* How a thinking level reaches a model: the setting of the model (`AiChatModelConfig.reasoningParameter`, "Thinking parameter"). `reasoning_effort` is the
|
|
16
|
+
* OpenAI field, and what is sent when a model says nothing; `chat_template_kwargs.reasoning_strength` sends the level as an argument of the model's chat
|
|
17
|
+
* template (`chat_template_kwargs: { reasoning_strength: <level> }`), which is how Muse Glimmer takes it; `none` sends no level to the model at all.
|
|
18
|
+
*/
|
|
19
|
+
export const AI_REASONING_PARAMETERS = ["reasoning_effort", "chat_template_kwargs.reasoning_strength", "none"];
|
|
20
|
+
/** A thinking parameter as the engine keeps it: one of `AI_REASONING_PARAMETERS`, spelled exactly; anything else is no value. */
|
|
21
|
+
export function normalizeReasoningParameter(value) {
|
|
22
|
+
return typeof value === "string" && AI_REASONING_PARAMETERS.includes(value) ? value : undefined;
|
|
23
|
+
}
|
|
3
24
|
/** The longest silence the engine waits for between two pieces of a streamed reply, unless the integration says otherwise. */
|
|
4
25
|
export const DEFAULT_IDLE_TIMEOUT_MS = 600_000;
|
|
5
26
|
/** An integration's idle timeout is kept within these limits. */
|
|
@@ -44,7 +65,8 @@ function target(value) {
|
|
|
44
65
|
const source = record(value);
|
|
45
66
|
const integrationId = text(source.integrationId);
|
|
46
67
|
const model = text(source.model);
|
|
47
|
-
|
|
68
|
+
const thinking = normalizeThinking(source.thinking);
|
|
69
|
+
return integrationId && model ? { integrationId, model, ...(thinking ? { thinking } : {}) } : undefined;
|
|
48
70
|
}
|
|
49
71
|
/** The routing limits with the web app's normalization: whole numbers within the same bounds, the same defaults. */
|
|
50
72
|
export function normalizeRoutingExecution(raw) {
|
|
@@ -85,6 +107,10 @@ export function pickAiRuntimeConfig(settings) {
|
|
|
85
107
|
underlyingModel: text(model.underlyingModel),
|
|
86
108
|
capabilities: Array.isArray(model.capabilities) ? model.capabilities.filter((capability) => typeof capability === "string") : [],
|
|
87
109
|
supportsToolCalls: typeof model.supportsToolCalls === "boolean" ? model.supportsToolCalls : undefined,
|
|
110
|
+
...(typeof model.supportsStreaming === "boolean" ? { supportsStreaming: model.supportsStreaming } : {}),
|
|
111
|
+
...(typeof model.supportsReasoning === "boolean" ? { supportsReasoning: model.supportsReasoning } : {}),
|
|
112
|
+
...(typeof model.supportsVision === "boolean" ? { supportsVision: model.supportsVision } : {}),
|
|
113
|
+
...reasoningParameterOf(model.reasoningParameter),
|
|
88
114
|
maxInputTokens: positive(model.maxInputTokens),
|
|
89
115
|
maxOutputTokens: positive(model.maxOutputTokens),
|
|
90
116
|
pricing: pricing(model.pricing),
|
|
@@ -92,6 +118,7 @@ export function pickAiRuntimeConfig(settings) {
|
|
|
92
118
|
}
|
|
93
119
|
const idleTimeoutMs = idleTimeout(item.idleTimeoutMs);
|
|
94
120
|
const mode = streamMode(item.streamMode);
|
|
121
|
+
const thinking = normalizeThinking(item.thinking);
|
|
95
122
|
integrations.push({
|
|
96
123
|
id,
|
|
97
124
|
name: text(item.name) ?? provider,
|
|
@@ -102,6 +129,7 @@ export function pickAiRuntimeConfig(settings) {
|
|
|
102
129
|
requestTimeoutMs: positive(item.requestTimeoutMs),
|
|
103
130
|
...(idleTimeoutMs !== undefined ? { idleTimeoutMs } : {}),
|
|
104
131
|
...(mode ? { streamMode: mode } : {}),
|
|
132
|
+
...(thinking ? { thinking } : {}),
|
|
105
133
|
chatModels,
|
|
106
134
|
modelWriting: text(item.modelWriting),
|
|
107
135
|
modelReview: text(item.modelReview),
|
|
@@ -118,6 +146,8 @@ export function pickAiRuntimeConfig(settings) {
|
|
|
118
146
|
}
|
|
119
147
|
const routingExecution = isObject(source.routingExecution) ? normalizeRoutingExecution(source.routingExecution) : undefined;
|
|
120
148
|
const disclosure = isObject(source.fallbackDisclosure) ? source.fallbackDisclosure : undefined;
|
|
149
|
+
// The settings say `aiToolsOnly`; a configuration that was already picked (what a personal server stores and reads back) says `toolsOnly`.
|
|
150
|
+
const toolsOnly = typeof source.aiToolsOnly === "boolean" ? source.aiToolsOnly : typeof source.toolsOnly === "boolean" ? source.toolsOnly : undefined;
|
|
121
151
|
return {
|
|
122
152
|
aiIntegrations: integrations,
|
|
123
153
|
taskRouting,
|
|
@@ -127,22 +157,64 @@ export function pickAiRuntimeConfig(settings) {
|
|
|
127
157
|
maxCandidates: routingExecution?.maxCandidates ?? positive(source.maxCandidates),
|
|
128
158
|
...(disclosure ? { fallbackDisclosure: { sameBoundaryOnly: disclosure.sameBoundaryOnly === true, requireAcknowledgement: disclosure.requireAcknowledgement === true } } : {}),
|
|
129
159
|
...(routingExecution ? { routingExecution } : {}),
|
|
160
|
+
...(toolsOnly !== undefined ? { toolsOnly } : {}),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/** The field for a model that says how its thinking level is sent, and nothing for one that does not (or whose word is not one of the three). */
|
|
164
|
+
function reasoningParameterOf(value) {
|
|
165
|
+
const parameter = normalizeReasoningParameter(value);
|
|
166
|
+
return parameter ? { reasoningParameter: parameter } : {};
|
|
167
|
+
}
|
|
168
|
+
function redactedModel(model) {
|
|
169
|
+
const flag = (value) => (typeof value === "boolean" ? value : undefined);
|
|
170
|
+
const supportsToolCalls = flag(model.supportsToolCalls);
|
|
171
|
+
const supportsStreaming = flag(model.supportsStreaming);
|
|
172
|
+
const supportsReasoning = flag(model.supportsReasoning);
|
|
173
|
+
const supportsVision = flag(model.supportsVision);
|
|
174
|
+
const maxInputTokens = positive(model.maxInputTokens);
|
|
175
|
+
const maxOutputTokens = positive(model.maxOutputTokens);
|
|
176
|
+
return {
|
|
177
|
+
name: model.name,
|
|
178
|
+
capabilities: model.capabilities,
|
|
179
|
+
...(supportsToolCalls !== undefined ? { supportsToolCalls } : {}),
|
|
180
|
+
...(supportsStreaming !== undefined ? { supportsStreaming } : {}),
|
|
181
|
+
...(supportsReasoning !== undefined ? { supportsReasoning } : {}),
|
|
182
|
+
...(supportsVision !== undefined ? { supportsVision } : {}),
|
|
183
|
+
...reasoningParameterOf(model.reasoningParameter),
|
|
184
|
+
...(maxInputTokens !== undefined ? { maxInputTokens } : {}),
|
|
185
|
+
...(maxOutputTokens !== undefined ? { maxOutputTokens } : {}),
|
|
130
186
|
};
|
|
131
187
|
}
|
|
188
|
+
function redactedTarget(entry) {
|
|
189
|
+
const thinking = normalizeThinking(entry.thinking);
|
|
190
|
+
return { integrationId: entry.integrationId, model: entry.model, ...(thinking ? { thinking } : {}) };
|
|
191
|
+
}
|
|
132
192
|
/** Safe view of a configuration: never exposes API keys. */
|
|
133
193
|
export function redactAiRuntimeConfig(config) {
|
|
194
|
+
const taskRouting = {};
|
|
195
|
+
for (const [task, route] of Object.entries(config.taskRouting ?? {})) {
|
|
196
|
+
if (!route || (!route.primary && !route.fallbacks?.length))
|
|
197
|
+
continue;
|
|
198
|
+
taskRouting[task] = { ...(route.primary ? { primary: redactedTarget(route.primary) } : {}), fallbacks: (route.fallbacks ?? []).map(redactedTarget) };
|
|
199
|
+
}
|
|
134
200
|
return {
|
|
135
|
-
integrations: config.aiIntegrations.map((integration) =>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
201
|
+
integrations: config.aiIntegrations.map((integration) => {
|
|
202
|
+
const thinking = normalizeThinking(integration.thinking);
|
|
203
|
+
return {
|
|
204
|
+
id: integration.id,
|
|
205
|
+
name: integration.name,
|
|
206
|
+
provider: integration.provider,
|
|
207
|
+
endpoint: integration.endpoint,
|
|
208
|
+
hasApiKey: Boolean(integration.apiKey),
|
|
209
|
+
...(integration.idleTimeoutMs !== undefined ? { idleTimeoutMs: integration.idleTimeoutMs } : {}),
|
|
210
|
+
...(integration.streamMode ? { streamMode: integration.streamMode } : {}),
|
|
211
|
+
...(thinking ? { thinking } : {}),
|
|
212
|
+
models: (integration.chatModels ?? []).map(redactedModel),
|
|
213
|
+
};
|
|
214
|
+
}),
|
|
145
215
|
routedTasks: Object.keys(config.taskRouting ?? {}).sort(),
|
|
216
|
+
taskRouting,
|
|
217
|
+
toolsOnly: config.toolsOnly !== false,
|
|
146
218
|
...(config.fallbackDisclosure ? { fallbackDisclosure: config.fallbackDisclosure } : {}),
|
|
147
219
|
...(config.routingExecution ? { routingExecution: config.routingExecution } : {}),
|
|
148
220
|
};
|
package/dist/ai/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/ai/config.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,yBAAyB,GAAG,YAAY,CAAC;AAyBtD,8HAA8H;AAC9H,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAC/C,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAC1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAmD7C,qDAAqD;AACrD,MAAM,CAAC,MAAM,yBAAyB,GAAiC,MAAM,CAAC,MAAM,CAAC;IACnF,aAAa,EAAE,CAAC;IAChB,kBAAkB,EAAE,OAAO;IAC3B,gBAAgB,EAAE,OAAO;IACzB,gBAAgB,EAAE,CAAC;CACpB,CAAC,CAAC;AAmBH,MAAM,SAAS,GAAqB,CAAC,cAAc,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,CAAC,CAAC;AAEhG,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAgC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7G,CAAC;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9E,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,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,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjC,MAAM,EAAE,CAAC,WAAW,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC;aAC1D,CAAC;QACJ,CAAC,CAAC;QACF,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QACzD,WAAW;QACX,SAAS,EAAE,MAAM,CAAC,SAAS,KAAK,KAAK;QACrC,GAAG,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvF,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClF,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AiPricingConfig, AiRuntimeConfig, AiStreamMode } from "./config.js";
|
|
2
|
+
import { type AiReasoningEffort } from "./request.js";
|
|
2
3
|
import { type AiPort, type AiTimeoutPhase, type AiUsage } from "./types.js";
|
|
3
4
|
export { DEFAULT_REQUEST_TIMEOUT_MS, MIN_REQUEST_TIMEOUT_MS, TOTAL_REQUEST_CAP_MS } from "./deadlines.js";
|
|
4
5
|
/**
|
|
@@ -50,6 +51,25 @@ export interface FetchAiAttempt {
|
|
|
50
51
|
timeouts: FetchAiTimeouts;
|
|
51
52
|
/** What the integration says about streaming (`auto` unless it says `off`). */
|
|
52
53
|
streamMode: AiStreamMode;
|
|
54
|
+
/** "Tools only" was in force for this call: `false` only when the configuration turned it off. */
|
|
55
|
+
toolsOnly: boolean;
|
|
56
|
+
/** The thinking level the request carries: as `reasoning_effort`, or as the chat-template argument when `reasoningParameter` says so. Absent when none is sent (`automatic` sends nothing). */
|
|
57
|
+
thinking?: AiReasoningEffort;
|
|
58
|
+
/** Where the level went, when it went in the chat-template argument (`chat_template_kwargs.reasoning_strength`, the model's "Thinking parameter"). Absent: it went as `reasoning_effort`, or no level was sent. */
|
|
59
|
+
reasoningParameter?: "chat_template_kwargs.reasoning_strength";
|
|
60
|
+
/**
|
|
61
|
+
* The candidates of the route that this call does not ask, and why: with "Tools only" on, a structured request skips every model
|
|
62
|
+
* marked as without tool calls. Absent when none was skipped; the same list on every attempt of the call.
|
|
63
|
+
*/
|
|
64
|
+
skipped?: Array<{
|
|
65
|
+
model: string;
|
|
66
|
+
reason: "no-tool-calls";
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* What this attempt does not do that the configuration asked, because of what the model declares or says: a thinking level that is not sent to a
|
|
70
|
+
* model that does not reason or whose thinking parameter is `none`, a stream that is not asked of a model that does not stream. In English, for a debug panel; absent when there is nothing to say.
|
|
71
|
+
*/
|
|
72
|
+
notes?: string[];
|
|
53
73
|
}
|
|
54
74
|
export interface FetchAiAttemptEnd {
|
|
55
75
|
attemptId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-client.d.ts","sourceRoot":"","sources":["../../src/ai/fetch-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetch-client.d.ts","sourceRoot":"","sources":["../../src/ai/fetch-client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGlF,OAAO,EAAmC,KAAK,iBAAiB,EAAoB,MAAM,cAAc,CAAC;AAIzG,OAAO,EAAiE,KAAK,MAAM,EAAgE,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAGzM,OAAO,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE1G;;;GAGG;AACH,eAAO,MAAM,0BAA0B,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ACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAQlF"}
|
package/dist/ai/fetch-client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { abortError, isAbortError } from "../util/abort.js";
|
|
2
2
|
import { randomId } from "../util/hash.js";
|
|
3
|
+
import { discardBody, release } from "./body.js";
|
|
3
4
|
import { likelyTextTokens } from "./budget.js";
|
|
4
5
|
import { resolveDeadlines, startClock, timeoutMessage } from "./deadlines.js";
|
|
5
6
|
import { redactSecrets } from "./redact.js";
|
|
@@ -45,6 +46,7 @@ export function createFetchAi(config, options = {}) {
|
|
|
45
46
|
let startedAt = Date.now();
|
|
46
47
|
const secrets = config.aiIntegrations.map((integration) => integration.apiKey);
|
|
47
48
|
const plan = planAttempts(config, request, options.githubModelsBaseUrl);
|
|
49
|
+
const skipped = plan.skipped.map((entry) => ({ model: entry.candidate.model, reason: entry.reason }));
|
|
48
50
|
const decisions = new Map();
|
|
49
51
|
const blocked = [];
|
|
50
52
|
const spent = {};
|
|
@@ -93,6 +95,11 @@ export function createFetchAi(config, options = {}) {
|
|
|
93
95
|
timeoutMs: deadlines.startMs,
|
|
94
96
|
timeouts: { startMs: deadlines.startMs, idleMs: deadlines.idleMs, capMs: deadlines.capMs, ...(deadlines.raisedFrom !== undefined ? { raised: { from: deadlines.raisedFrom } } : {}) },
|
|
95
97
|
streamMode: integration.streamMode === "off" ? "off" : "auto",
|
|
98
|
+
toolsOnly: config.toolsOnly !== false,
|
|
99
|
+
...(attempt.built?.thinking ? { thinking: attempt.built.thinking } : {}),
|
|
100
|
+
...(attempt.built?.reasoningParameter ? { reasoningParameter: attempt.built.reasoningParameter } : {}),
|
|
101
|
+
...(skipped.length ? { skipped: skipped.map((entry) => ({ ...entry })) } : {}),
|
|
102
|
+
...(attempt.built?.notes?.length ? { notes: [...attempt.built.notes] } : {}),
|
|
96
103
|
});
|
|
97
104
|
const attemptStarted = Date.now();
|
|
98
105
|
const trace = { startedAt: attemptStarted, streamed: false, toolSeen: false };
|
|
@@ -133,6 +140,8 @@ export function createFetchAi(config, options = {}) {
|
|
|
133
140
|
const notes = [];
|
|
134
141
|
if (plan.excludedByBoundary > 0)
|
|
135
142
|
notes.push(`Fallbacks in other accounts were not tried because "Never send fallback content outside the primary account" (fallbackDisclosure.sameBoundaryOnly) is on.`);
|
|
143
|
+
for (const entry of plan.skipped)
|
|
144
|
+
notes.push(redactSecrets(`Skipped "${entry.candidate.model}" in "${entry.candidate.integration.name}": it is marked as without tool calls and "Tools only" is on.`, secrets));
|
|
136
145
|
if (blocked.length) {
|
|
137
146
|
const names = [...new Set(blocked.map((entry) => `"${entry.candidate.integration.name}"`))].join(", ");
|
|
138
147
|
const from = `"${blocked[0].from.integration.name}"`;
|
|
@@ -260,14 +269,34 @@ function parseRetryAfter(value) {
|
|
|
260
269
|
return Number.isNaN(date) ? undefined : Math.min(MAX_RETRY_AFTER_MS, Math.max(0, date - Date.now()));
|
|
261
270
|
}
|
|
262
271
|
const TRANSIENT_STATUSES = new Set([408, 429, 502, 503, 504]);
|
|
263
|
-
|
|
272
|
+
/**
|
|
273
|
+
* What a refusal of the thinking parameter says: the name of the one that the level travels in, in the provider's message or in the `param` of its error
|
|
274
|
+
* object (some providers say only `"param": "reasoning_effort"`): the OpenAI field, or the chat-template argument (`chat_template_kwargs`, `reasoning_strength`).
|
|
275
|
+
* Either name is a refusal of the level, whichever of the two was sent: a gateway may answer with the name of the one it translated it into, and the remedy is
|
|
276
|
+
* the same setting.
|
|
277
|
+
*/
|
|
278
|
+
const THINKING_PARAMETER = /reasoning[\s_-]?effort|reasoning[\s_-]?strength|chat[\s_-]?template[\s_-]?kwargs/i;
|
|
279
|
+
/** What to change when a model refuses its level: the "Thinking parameter" of the model (to the other of the two, or to none), or the thinking of the task or of the integration. */
|
|
280
|
+
function thinkingRemedy(model, sent) {
|
|
281
|
+
const other = sent.parameter === "reasoning_effort"
|
|
282
|
+
? `"chat_template_kwargs.reasoning_strength" (the level as an argument of the chat template, as Muse Glimmer takes it)`
|
|
283
|
+
: `"reasoning_effort" (the OpenAI field)`;
|
|
284
|
+
return `Set "Thinking parameter" of the model "${model}" in AI Integrations to ${other} or to "none" (no level is sent), or set thinking to "Automatic" for this task in the AI Router, or for the integration "${sent.integration}" in AI Integrations.`;
|
|
285
|
+
}
|
|
286
|
+
/** The error of a response that is not OK. `sent` says where the level went when the request carried a thinking level: a refusal of that parameter is then said in the author's words. */
|
|
287
|
+
async function providerError(response, provider, model, redact, sent) {
|
|
264
288
|
let detail = "";
|
|
289
|
+
/** The parameter the provider says it refuses, when its error object names one. */
|
|
290
|
+
let param = "";
|
|
265
291
|
try {
|
|
266
292
|
const text = await response.text();
|
|
267
293
|
const raw = redact(text.length > 50_000 ? text.slice(0, 50_000) : text).slice(0, 2000);
|
|
268
294
|
try {
|
|
269
295
|
const parsed = JSON.parse(raw);
|
|
270
296
|
const message = typeof parsed.error === "string" ? parsed.error : parsed.error?.message ?? parsed.message;
|
|
297
|
+
const refused = typeof parsed.error === "object" && parsed.error ? parsed.error.param : parsed.param;
|
|
298
|
+
if (typeof refused === "string")
|
|
299
|
+
param = refused;
|
|
271
300
|
detail = typeof message === "string" ? message : raw;
|
|
272
301
|
}
|
|
273
302
|
catch {
|
|
@@ -280,7 +309,12 @@ async function providerError(response, provider, model, redact) {
|
|
|
280
309
|
const status = response.status;
|
|
281
310
|
const retryable = status === 408 || status === 409 || status === 429 || status >= 500;
|
|
282
311
|
const retryAfterMs = status === 429 || status === 503 ? parseRetryAfter(response.headers?.get?.("retry-after")) : undefined;
|
|
283
|
-
|
|
312
|
+
const said = `HTTP ${status}${detail ? ` — ${detail.replace(/\s+/g, " ").slice(0, 400)}` : ""}`;
|
|
313
|
+
// A level was sent and the provider refuses the parameter: the same request would be refused again, so it is no use to repeat it.
|
|
314
|
+
if (sent !== undefined && (status === 400 || status === 422) && THINKING_PARAMETER.test(`${detail} ${param}`)) {
|
|
315
|
+
return new AiProviderError(redact(`${provider} ${model}: the model does not accept a thinking level (${said}). Nothing was applied. ${thinkingRemedy(model, sent)}`), status, false);
|
|
316
|
+
}
|
|
317
|
+
return new AiProviderError(redact(`${provider} ${model}: ${said}`), status, retryable, { ...(TRANSIENT_STATUSES.has(status) ? { transient: true } : {}), ...(retryAfterMs !== undefined ? { retryAfterMs } : {}) });
|
|
284
318
|
}
|
|
285
319
|
/** The connection failed while a stream was being read (as opposed to a deadline, the author's cancel, or what the engine itself found wrong). */
|
|
286
320
|
class StreamReadError extends Error {
|
|
@@ -291,24 +325,6 @@ class StreamReadError extends Error {
|
|
|
291
325
|
this.name = "StreamReadError";
|
|
292
326
|
}
|
|
293
327
|
}
|
|
294
|
-
/** Stops reading without waiting for the other side: whatever it does with the cancel, the call must not hang on it. */
|
|
295
|
-
function release(reader) {
|
|
296
|
-
try {
|
|
297
|
-
void reader.cancel().catch(() => undefined);
|
|
298
|
-
}
|
|
299
|
-
catch {
|
|
300
|
-
// A reader that cannot be cancelled is of no use any more.
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
/** Lets a body go that nobody is going to read (a reply that arrived too late, or that the call gave up). */
|
|
304
|
-
function discardBody(response) {
|
|
305
|
-
try {
|
|
306
|
-
void response.body?.cancel().catch(() => undefined);
|
|
307
|
-
}
|
|
308
|
-
catch {
|
|
309
|
-
// A body that is locked or already read has nothing left to discard.
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
328
|
/**
|
|
313
329
|
* Reads server-sent events; resolves `true` when the provider closed the stream with `[DONE]`. An event is its `data:`
|
|
314
330
|
* lines joined with a newline, ended by a blank line; a value that is complete as it stands (one JSON object, or
|
|
@@ -690,7 +706,7 @@ async function callCandidate(config, attempt, built, request, options, deadlines
|
|
|
690
706
|
stage = "other";
|
|
691
707
|
if (!response.ok) {
|
|
692
708
|
trace.firstByteMs ??= elapsed();
|
|
693
|
-
const failure = await clock.guard(providerError(response, integration.provider, model, redact));
|
|
709
|
+
const failure = await clock.guard(providerError(response, integration.provider, model, redact, built.thinking ? { integration: integration.name, parameter: built.reasoningParameter ?? "reasoning_effort" } : undefined));
|
|
694
710
|
// A provider that cannot stream says so with a 400: tell where to switch streaming off.
|
|
695
711
|
if (built.stream && (failure.status === 400 || failure.status === 422) && /stream/i.test(failure.message.replace(label, ""))) {
|
|
696
712
|
failure.message = redact(`${failure.message}${/[.!?]$/.test(failure.message) ? "" : "."} If this provider cannot stream its replies, set "Streaming" of the integration "${integration.name}" to "off".`);
|
|
@@ -746,8 +762,11 @@ async function callCandidate(config, attempt, built, request, options, deadlines
|
|
|
746
762
|
const toolArguments = callArguments();
|
|
747
763
|
const answered = Boolean(text.trim() || toolArguments.trim());
|
|
748
764
|
if (outcome === "truncated") {
|
|
749
|
-
const
|
|
750
|
-
|
|
765
|
+
const seen = !answered && reasoningCharacters > 0;
|
|
766
|
+
// A model that is declared as reasoning and wrote nothing spent its limit on a reasoning that it does not show: the reply is cut the same way.
|
|
767
|
+
const declared = !answered && !seen && candidate.supportsReasoning === true;
|
|
768
|
+
const reasoned = seen || declared;
|
|
769
|
+
throw new AiProviderError(`${label}: ${seen ? "the model used its output limit while reasoning, before writing the reply" : declared ? "the model, which is declared as reasoning, used its output limit before writing the reply (its reasoning counts in the limit)" : "the reply was cut by the output token limit"}. Nothing was applied.`, undefined, false, details({ truncated: true, ...(reasoned ? { reasoningOnly: true, ...(candidate.maxOutputTokens && (built.outputLimit ?? 0) >= candidate.maxOutputTokens ? { limitReached: true } : {}) } : {}) }));
|
|
751
770
|
}
|
|
752
771
|
if (!answered)
|
|
753
772
|
throw new AiProviderError(`${label}: ${reasoningCharacters > 0 ? "the model finished after reasoning without a reply" : "the provider returned an empty reply"}.`, undefined, true, details());
|
|
@@ -755,8 +774,14 @@ async function callCandidate(config, attempt, built, request, options, deadlines
|
|
|
755
774
|
const measured = measure();
|
|
756
775
|
let json;
|
|
757
776
|
if (request.json) {
|
|
777
|
+
// With "Tools only" (on unless the configuration turned it off) the answer is the call of the function: the text of the reply is never
|
|
778
|
+
// read, neither as the answer nor as a fallback to empty or wrong arguments. A reply with no call at all is refused and the next candidate is tried.
|
|
779
|
+
const toolsOnly = config.toolsOnly !== false;
|
|
780
|
+
if (toolsOnly && !toolArguments.trim()) {
|
|
781
|
+
throw new AiReplyRejectedError(redact(`${label}: the model answered in text instead of calling the function "${request.json.name}": "Tools only" is on, so the text of a reply is never read as the answer. If this model cannot call functions, turn off "Tools only" in the AI Router.`), details());
|
|
782
|
+
}
|
|
758
783
|
try {
|
|
759
|
-
json = structuredFromReply({ toolArguments, content: text, schema: request.json });
|
|
784
|
+
json = structuredFromReply({ toolArguments, content: toolsOnly ? "" : text, schema: request.json });
|
|
760
785
|
}
|
|
761
786
|
catch (error) {
|
|
762
787
|
throw new AiReplyRejectedError(redact(`${label}: ${error instanceof Error ? error.message : "invalid structured reply"}`), details());
|