@openclaw/ai 2026.9.7 → 2026.10.1-beta.1
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 +4 -1
- package/dist/{anthropic-Cw2pgccz.mjs → anthropic-CZv6XFER.mjs} +52 -147
- package/dist/{anthropic-payload-policy-NIPVYXPq.d.mts → anthropic-payload-policy-BhCcgNdm.d.mts} +7 -4
- package/dist/{anthropic-stream-reducer-D9MCkl8Z.mjs → anthropic-stream-reducer-BQ1tjd7x.mjs} +369 -233
- package/dist/{api-registry-D-nbmSqr.d.mts → api-registry-DpU0Rj-I.d.mts} +4 -4
- package/dist/{provider-transcript-transform-JbFbHV8h.mjs → assistant-output-OLm-Oln0.mjs} +17 -17
- package/dist/{assistant-text-phase-C20rxWwP.mjs → assistant-text-phase-Bl1aDCB7.mjs} +2 -8
- package/dist/{azure-openai-responses-BwT3-X8P.mjs → azure-openai-responses-DH7bd3QT.mjs} +12 -17
- package/dist/{azure-openai-responses-client-compat-C7K7QfUE.mjs → azure-openai-responses-client-compat-D0dvJMbZ.mjs} +3 -10
- package/dist/{base64-C1PsYcRQ.mjs → base64-C8CdcsjU.mjs} +3 -45
- package/dist/cloudflare-5qSGvIUH.mjs +39 -0
- package/dist/{diagnostics-CJaB6g8J.mjs → diagnostics-Caj-4RBA.mjs} +19 -37
- package/dist/diagnostics.d.mts +4 -4
- package/dist/diagnostics.mjs +2 -2
- package/dist/{event-stream-vd9UnCAU.mjs → event-stream-C5AbCAaZ.mjs} +29 -1
- package/dist/event-stream-DqDQWqiy.d.mts +1 -0
- package/dist/{event-stream-DOPFYVqs.d.mts → event-stream-DrRM_90c.d.mts} +1 -1
- package/dist/event-stream.d.mts +2 -2
- package/dist/event-stream.mjs +1 -1
- package/dist/{github-copilot-request-facts-BTEBMeOv.mjs → github-copilot-request-facts-DEE6gcB9.mjs} +3 -1
- package/dist/{google-BfapkS_K.mjs → google-1WLOtb8w.mjs} +12 -9
- package/dist/{google-interactions-DW3iXzjc.mjs → google-interactions-wrnE6MLw.mjs} +39 -49
- package/dist/{google-messages-CtjVtVot.mjs → google-messages-BwPPycw6.mjs} +11 -17
- package/dist/{google-shared-Y2YfotEu.mjs → google-shared-Eql1OMPU.mjs} +5 -6
- package/dist/{google-vertex-Dov4kBWu.mjs → google-vertex-0LrlRoO3.mjs} +11 -11
- package/dist/{host-rxlNaBwm.d.mts → host-BinBeGcQ.d.mts} +12 -4
- package/dist/{host-CHi3X87F.mjs → host-DCW52iHe.mjs} +57 -9
- package/dist/{host-policy-BOAwRg_M.mjs → host-policy-B3jc4Rpn.mjs} +9 -2
- package/dist/{index-D6KsSE74.d.mts → index-a8e_oKnu.d.mts} +7 -5
- package/dist/index.d.mts +23 -7
- package/dist/index.mjs +7 -7
- package/dist/internal/anthropic.d.mts +6 -6
- package/dist/internal/anthropic.mjs +5 -5
- package/dist/internal/google-model-family.mjs +1 -1
- package/dist/internal/openai-completions-compat.d.mts +1 -1
- package/dist/internal/openai-completions-compat.mjs +1 -1
- package/dist/internal/openai-responses-payload-policy.d.mts +1 -1
- package/dist/internal/openai-responses-payload-policy.mjs +2 -2
- package/dist/internal/openai.d.mts +14 -10
- package/dist/internal/openai.mjs +12 -12
- package/dist/internal/runtime.d.mts +18 -9
- package/dist/internal/runtime.mjs +9 -9
- package/dist/internal/shared.d.mts +6 -4
- package/dist/internal/shared.mjs +6 -6
- package/dist/internal/tool-schema.mjs +1 -1
- package/dist/json-schema-Bp07Qui3.mjs +22 -0
- package/dist/{llm-request-activity-BjtkplhG.mjs → llm-request-activity-D8f_oxHj.mjs} +1 -2
- package/dist/{mistral-RS6mboC-.mjs → mistral-DSt4vQAO.mjs} +18 -29
- package/dist/number-coercion-V8-BhME4.mjs +47 -0
- package/dist/{openai-chatgpt-responses-CYbidtrn.mjs → openai-chatgpt-responses-BC2x0Oqx.mjs} +215 -164
- package/dist/openai-completions-DNyHnXKg.mjs +25 -0
- package/dist/{openai-completions-compat-qJjmqQ71.d.mts → openai-completions-compat-BYdYpXhU.d.mts} +3 -3
- package/dist/{openai-completions-compat-BOVWBZDn.mjs → openai-completions-compat-BdmlhD4u.mjs} +30 -23
- package/dist/{openai-completions-stream-CDCuw3DP.mjs → openai-completions-transport-DWM2mQDB.mjs} +389 -76
- package/dist/{openai-prompt-cache-CouErLh7.d.mts → openai-prompt-cache-45-AH_xv.d.mts} +2 -2
- package/dist/{openai-prompt-cache-D2V7MqR7.mjs → openai-prompt-cache-I8YQTzf8.mjs} +1 -1
- package/dist/{openai-responses-compaction-replay-DiYn-gFM.d.mts → openai-responses-compaction-replay-BClApUIf.d.mts} +4 -4
- package/dist/{openai-responses-compaction-window-UNK1GDpy.mjs → openai-responses-compaction-window-m878aVpU.mjs} +25 -83
- package/dist/{openai-reasoning-effort-ConhwkeX.mjs → openai-responses-contracts-BKu8O7l4.mjs} +106 -7
- package/dist/{openai-responses-contracts-D1iZ0njF.d.mts → openai-responses-contracts-Br5IIw_h.d.mts} +16 -5
- package/dist/openai-responses-prompt-observer-internal-CCg7B6l4.mjs +32 -0
- package/dist/{openai-responses-shared-DL4ulQn7.mjs → openai-responses-shared-C7oVyjED.mjs} +297 -312
- package/dist/{openai-responses-terminal-usage-BE7lf7nW.d.mts → openai-responses-terminal-usage-DgImcyJu.d.mts} +2 -2
- package/dist/{openai-responses-CKCBEc2W.mjs → openai-responses-uZ5oWSp7.mjs} +12 -21
- package/dist/{openai-tool-schema-vsl-cE-n.mjs → openai-tool-schema-DYNePiF8.mjs} +66 -36
- package/dist/{openai-transport-params-BwlpzX-2.mjs → openai-transport-params-JFsnIyto.mjs} +25 -30
- package/dist/openai-web-search-tools-Cfu0uLyN.mjs +14 -0
- package/dist/{positive-integer-CjN5OJbH.mjs → positive-integer-CwLi8LUL.mjs} +1 -1
- package/dist/{provider-error-CwT_j2v0.mjs → provider-error-DQBE1bUQ.mjs} +17 -28
- package/dist/{provider-options-Df7ov0K1.d.mts → provider-options-D5ABCV_l.d.mts} +2 -2
- package/dist/{provider-replay-context-DsyI5jOP.mjs → provider-replay-context-C7Bmi84a.mjs} +6 -2
- package/dist/{provider-transport-turn-state-BheUi_hl.mjs → provider-transport-turn-state-_M2kLdUE.mjs} +25 -3
- package/dist/{provider-types-d4XnoZMd.d.mts → provider-types-F8Mqc9Ma.d.mts} +3 -3
- package/dist/provider-types.d.mts +6 -6
- package/dist/providers.d.mts +2 -2
- package/dist/providers.mjs +14 -26
- package/dist/{reasoning-tag-text-partitioner-B6FIIBt6.mjs → reasoning-tag-text-partitioner-Ju9VpUGl.mjs} +23 -37
- package/dist/required-api-key-D4kn3252.mjs +9 -0
- package/dist/sanitize-unicode-CjDG6jJx.d.mts +5 -0
- package/dist/{session-affinity-Bcunsn4I.mjs → session-affinity-DA4WHv1h.mjs} +2 -6
- package/dist/session-resources-D1wgDQ8C.mjs +40 -0
- package/dist/{simple-options-CGAkCwtM.mjs → simple-options-BkKTXxhp.mjs} +7 -11
- package/dist/{src-H4aXcFuX.mjs → src-B0NIt2UK.mjs} +7 -4
- package/dist/stream-DSdzKsDK.mjs +275 -0
- package/dist/{stream-first-event-timeout-B9o0S4SZ.mjs → stream-first-event-timeout-D9ZmL_s9.mjs} +3 -3
- package/dist/{string-coerce-fsri9iCu.mjs → string-coerce-CtgOVOSv.mjs} +5 -1
- package/dist/{string-normalization-J9ZiLfGO.mjs → string-normalization-PN10hf6d.mjs} +1 -1
- package/dist/{transport-utils-C-4bf2Ok.mjs → text-signature-MLwfi6fq.mjs} +18 -18
- package/dist/{transport-stream-shared-yYhXa4kX.d.mts → transport-stream-shared-BcAKh2XH.d.mts} +6 -19
- package/dist/{transport-stream-shared-Dh5qKJ8e.mjs → transport-stream-shared-CxXXz_Dd.mjs} +171 -56
- package/dist/transports.d.mts +22 -23
- package/dist/transports.mjs +251 -495
- package/dist/types-BuiEBM3u.d.mts +1 -0
- package/dist/types-CQc6JNG4.mjs +69 -0
- package/dist/{types-CLLR3eB4.d.mts → types-DvzmWW8J.d.mts} +58 -6
- package/dist/types.d.mts +6 -6
- package/dist/types.mjs +5 -5
- package/dist/usage-CJH5D6Ea.mjs +19 -0
- package/dist/{validation-Cat2wQsc.d.mts → validation-B3lQt_VE.d.mts} +1 -1
- package/dist/{validation-BFZc40Ig.mjs → validation-DbqlIfDn.mjs} +15 -30
- package/dist/validation.d.mts +1 -1
- package/dist/validation.mjs +1 -1
- package/package.json +4 -4
- package/dist/cache-retention-0x979a5V.mjs +0 -12
- package/dist/event-stream-CMQfX_yr.d.mts +0 -1
- package/dist/github-copilot-headers-B37TB3rB.mjs +0 -30
- package/dist/openai-completions-D14ihPYk.mjs +0 -188
- package/dist/openai-provider-client-CwfsGBbA.mjs +0 -24
- package/dist/openai-responses-contracts-CLxnqS9p.mjs +0 -81
- package/dist/openai-responses-prompt-observer-internal-iAqLb4tk.mjs +0 -198
- package/dist/sanitize-unicode-BZiVbGwK.d.mts +0 -24
- package/dist/session-resources-CkR4WWy1.mjs +0 -21
- package/dist/stream-DDsCBgd-.mjs +0 -68
- package/dist/types-CB-_vNyI.d.mts +0 -1
- package/dist/types-LFWwv0cF.mjs +0 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./index-a8e_oKnu.mjs";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//#region packages/llm-core/src/types.ts
|
|
2
|
+
/** Stable error codes for provider outcomes that cannot be replayed safely. */
|
|
3
|
+
const PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE = "PROVIDER_POST_DISPATCH_AMBIGUITY";
|
|
4
|
+
const PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE = "PROVIDER_FAILURE_WITH_OUTPUT";
|
|
5
|
+
/** Pre-dispatch argument rejection; callers still enforce output and effect guards. */
|
|
6
|
+
const MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE = "malformed_tool_call_arguments";
|
|
7
|
+
const DEFAULT_MISSING_TOOL_RESULT_TEXT = "Tool call interrupted before a result was recorded; its outcome is unknown. Retry only if the operation is read-only or idempotent. If it may have had side effects, verify the current state first instead of repeating it.";
|
|
8
|
+
const RUNTIME_CONTEXT_CUSTOM_TYPE = "openclaw.runtime-context";
|
|
9
|
+
const RUNTIME_CONTEXT_BEGIN_MARKER = "<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>";
|
|
10
|
+
const RUNTIME_CONTEXT_END_MARKER = "<<<END_OPENCLAW_INTERNAL_CONTEXT>>>";
|
|
11
|
+
const RUNTIME_CONTEXT_HEADER = "OpenClaw runtime context:";
|
|
12
|
+
const RUNTIME_CONTEXT_FOOTER = "End OpenClaw runtime context.";
|
|
13
|
+
const ESCAPED_RUNTIME_CONTEXT_FOOTER = "[[RUNTIME_CONTEXT_FOOTER_ESCAPED]]";
|
|
14
|
+
/** Identifies the exact delimiter envelope emitted by shipped transcript carriers. */
|
|
15
|
+
function hasLegacyRuntimeContextEnvelope(content) {
|
|
16
|
+
return content.startsWith(`<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>\n`) && content.endsWith(`\n<<<END_OPENCLAW_INTERNAL_CONTEXT>>>`);
|
|
17
|
+
}
|
|
18
|
+
/** Prevent untrusted carrier content from terminating its provider projection. */
|
|
19
|
+
function escapeRuntimeContextFooter(content) {
|
|
20
|
+
return content.replaceAll(RUNTIME_CONTEXT_FOOTER, ESCAPED_RUNTIME_CONTEXT_FOOTER);
|
|
21
|
+
}
|
|
22
|
+
/** Builds the human-readable projection used only at provider boundaries. */
|
|
23
|
+
function labelRuntimeContextText(content) {
|
|
24
|
+
return `${RUNTIME_CONTEXT_HEADER}\n${escapeRuntimeContextFooter(content)}\n${RUNTIME_CONTEXT_FOOTER}`;
|
|
25
|
+
}
|
|
26
|
+
/** Labels runtime context once while preserving structured text blocks. */
|
|
27
|
+
function labelRuntimeContextContent(content) {
|
|
28
|
+
if (typeof content === "string") return labelRuntimeContextText(content);
|
|
29
|
+
if (content.length === 0) return [{
|
|
30
|
+
type: "text",
|
|
31
|
+
text: `${RUNTIME_CONTEXT_HEADER}\n${RUNTIME_CONTEXT_FOOTER}`
|
|
32
|
+
}];
|
|
33
|
+
return content.map((block, index) => ({
|
|
34
|
+
...block,
|
|
35
|
+
text: [
|
|
36
|
+
...index === 0 ? [RUNTIME_CONTEXT_HEADER] : [],
|
|
37
|
+
escapeRuntimeContextFooter(block.text),
|
|
38
|
+
...index === content.length - 1 ? [RUNTIME_CONTEXT_FOOTER] : []
|
|
39
|
+
].join("\n")
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
/** Flattens already-labeled runtime context for string-only provider messages. */
|
|
43
|
+
function runtimeContextContentToText(content) {
|
|
44
|
+
return typeof content === "string" ? content : content.map((block) => block.text).join("\n");
|
|
45
|
+
}
|
|
46
|
+
/** Identifies trusted runtime context independently of its provider-compatible shape. */
|
|
47
|
+
function hasRuntimeContextMarker(message) {
|
|
48
|
+
return message.role === "user" && (message.runtimeContext !== void 0 || message.runtimeContextCarrier === true);
|
|
49
|
+
}
|
|
50
|
+
/** Distinguishes trusted runtime context while preserving user-role plugin compatibility. */
|
|
51
|
+
function isRuntimeContextMessage(message) {
|
|
52
|
+
return (typeof message.content === "string" || Array.isArray(message.content) && message.content.every((part) => typeof part === "object" && part !== null && "type" in part && part.type === "text" && "text" in part && typeof part.text === "string")) && hasRuntimeContextMarker(message);
|
|
53
|
+
}
|
|
54
|
+
/** Reads canonical metadata while accepting the shipped v2026.9.7 carrier fields. */
|
|
55
|
+
function readRuntimeContextMetadata(message) {
|
|
56
|
+
if (message.runtimeContext !== void 0) return message.runtimeContext;
|
|
57
|
+
return message.runtimeContextCarrierRetained === void 0 ? {} : { retained: message.runtimeContextCarrierRetained };
|
|
58
|
+
}
|
|
59
|
+
/** Updates canonical retention and its shipped compatibility projection together. */
|
|
60
|
+
function setRuntimeContextRetention(message, retained) {
|
|
61
|
+
message.runtimeContext = {
|
|
62
|
+
...readRuntimeContextMetadata(message),
|
|
63
|
+
retained
|
|
64
|
+
};
|
|
65
|
+
message.runtimeContextCarrier = true;
|
|
66
|
+
message.runtimeContextCarrierRetained = retained;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { runtimeContextContentToText as _, RUNTIME_CONTEXT_BEGIN_MARKER as a, RUNTIME_CONTEXT_FOOTER as c, hasLegacyRuntimeContextEnvelope as d, hasRuntimeContextMarker as f, readRuntimeContextMetadata as g, labelRuntimeContextText as h, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE as i, RUNTIME_CONTEXT_HEADER as l, labelRuntimeContextContent as m, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE as n, RUNTIME_CONTEXT_CUSTOM_TYPE as o, isRuntimeContextMessage as p, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE as r, RUNTIME_CONTEXT_END_MARKER as s, DEFAULT_MISSING_TOOL_RESULT_TEXT as t, escapeRuntimeContextFooter as u, setRuntimeContextRetention as v };
|
|
@@ -381,20 +381,72 @@ declare const PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE = "PROVIDER_POST_DISPA
|
|
|
381
381
|
declare const PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE = "PROVIDER_FAILURE_WITH_OUTPUT";
|
|
382
382
|
/** Pre-dispatch argument rejection; callers still enforce output and effect guards. */
|
|
383
383
|
declare const MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE = "malformed_tool_call_arguments";
|
|
384
|
+
declare const DEFAULT_MISSING_TOOL_RESULT_TEXT = "Tool call interrupted before a result was recorded; its outcome is unknown. Retry only if the operation is read-only or idempotent. If it may have had side effects, verify the current state first instead of repeating it.";
|
|
384
385
|
/** User turn in a text-model conversation. */
|
|
385
386
|
interface UserMessage {
|
|
386
387
|
role: "user";
|
|
387
388
|
content: string | (TextContent | ImageContent)[];
|
|
388
389
|
timestamp: number;
|
|
390
|
+
/** Trusted runtime-context metadata; ordinary user messages omit it. */
|
|
391
|
+
runtimeContext?: {
|
|
392
|
+
/** Prefix-bound providers retain these messages across turns. */
|
|
393
|
+
retained?: boolean;
|
|
394
|
+
};
|
|
389
395
|
/**
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
* carriers are stable prompt-cache anchors.
|
|
396
|
+
* @deprecated Shipped through v2026.9.7. Use `runtimeContext`; remove after
|
|
397
|
+
* the minimum supported plugin API no longer includes that release.
|
|
393
398
|
*/
|
|
394
399
|
runtimeContextCarrier?: boolean;
|
|
395
|
-
/**
|
|
400
|
+
/**
|
|
401
|
+
* @deprecated Shipped through v2026.9.7. Use `runtimeContext.retained`;
|
|
402
|
+
* remove with `runtimeContextCarrier`.
|
|
403
|
+
*/
|
|
396
404
|
runtimeContextCarrierRetained?: boolean;
|
|
405
|
+
/** Operator-authored text projected to system authority on capable routes. */
|
|
406
|
+
operatorMessage?: {
|
|
407
|
+
turnScoped: boolean;
|
|
408
|
+
};
|
|
397
409
|
}
|
|
410
|
+
declare const RUNTIME_CONTEXT_CUSTOM_TYPE = "openclaw.runtime-context";
|
|
411
|
+
declare const RUNTIME_CONTEXT_BEGIN_MARKER = "<<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>>";
|
|
412
|
+
declare const RUNTIME_CONTEXT_END_MARKER = "<<<END_OPENCLAW_INTERNAL_CONTEXT>>>";
|
|
413
|
+
declare const RUNTIME_CONTEXT_HEADER = "OpenClaw runtime context:";
|
|
414
|
+
declare const RUNTIME_CONTEXT_FOOTER = "End OpenClaw runtime context.";
|
|
415
|
+
/** Identifies the exact delimiter envelope emitted by shipped transcript carriers. */
|
|
416
|
+
declare function hasLegacyRuntimeContextEnvelope(content: string): boolean;
|
|
417
|
+
/** Prevent untrusted carrier content from terminating its provider projection. */
|
|
418
|
+
declare function escapeRuntimeContextFooter(content: string): string;
|
|
419
|
+
/** Builds the human-readable projection used only at provider boundaries. */
|
|
420
|
+
declare function labelRuntimeContextText(content: string): string;
|
|
421
|
+
/** Labels runtime context once while preserving structured text blocks. */
|
|
422
|
+
declare function labelRuntimeContextContent(content: string | TextContent[]): string | TextContent[];
|
|
423
|
+
/** Flattens already-labeled runtime context for string-only provider messages. */
|
|
424
|
+
declare function runtimeContextContentToText(content: string | TextContent[]): string;
|
|
425
|
+
/** Trusted per-turn OpenClaw context, projected by each provider at its valid authority level. */
|
|
426
|
+
type RuntimeContextMessage = Omit<UserMessage, "content"> & {
|
|
427
|
+
content: string | TextContent[];
|
|
428
|
+
} & ({
|
|
429
|
+
runtimeContext: NonNullable<UserMessage["runtimeContext"]>;
|
|
430
|
+
} | {
|
|
431
|
+
runtimeContextCarrier: true;
|
|
432
|
+
});
|
|
433
|
+
/** Identifies trusted runtime context independently of its provider-compatible shape. */
|
|
434
|
+
declare function hasRuntimeContextMarker(message: {
|
|
435
|
+
role: string;
|
|
436
|
+
runtimeContext?: unknown;
|
|
437
|
+
runtimeContextCarrier?: unknown;
|
|
438
|
+
}): boolean;
|
|
439
|
+
/** Distinguishes trusted runtime context while preserving user-role plugin compatibility. */
|
|
440
|
+
declare function isRuntimeContextMessage(message: {
|
|
441
|
+
role: string;
|
|
442
|
+
content?: unknown;
|
|
443
|
+
runtimeContext?: unknown;
|
|
444
|
+
runtimeContextCarrier?: unknown;
|
|
445
|
+
}): message is RuntimeContextMessage;
|
|
446
|
+
/** Reads canonical metadata while accepting the shipped v2026.9.7 carrier fields. */
|
|
447
|
+
declare function readRuntimeContextMetadata(message: RuntimeContextMessage): NonNullable<UserMessage["runtimeContext"]>;
|
|
448
|
+
/** Updates canonical retention and its shipped compatibility projection together. */
|
|
449
|
+
declare function setRuntimeContextRetention(message: RuntimeContextMessage, retained: boolean | undefined): void;
|
|
398
450
|
/** Assistant turn, including provider identity and final stop state. */
|
|
399
451
|
type AssistantDeliveryTtsFacts = {
|
|
400
452
|
tagged: true;
|
|
@@ -555,7 +607,7 @@ interface AssistantMessageEventStreamContract extends AsyncIterable<AssistantMes
|
|
|
555
607
|
push(event: AssistantMessageEvent): void;
|
|
556
608
|
/** Complete the stream and optionally resolve the final message. */
|
|
557
609
|
end(result?: AssistantMessage): void;
|
|
558
|
-
/** Final assistant message produced
|
|
610
|
+
/** Final assistant message produced independently of event iteration. */
|
|
559
611
|
result(): Promise<AssistantMessage>;
|
|
560
612
|
}
|
|
561
613
|
/** Read-only stream contract accepted by consumers that do not need to push events. */
|
|
@@ -758,4 +810,4 @@ type StreamFn = (model: Model, context: Context, options?: SimpleStreamOptions)
|
|
|
758
810
|
type CompleteSimpleFn = (model: Model, context: Pick<Context, "systemPrompt" | "messages">, options?: SimpleStreamOptions) => Promise<AssistantMessage>;
|
|
759
811
|
type ValidateToolArgumentsFn = (tool: Tool, toolCall: ToolCall) => unknown;
|
|
760
812
|
//#endregion
|
|
761
|
-
export {
|
|
813
|
+
export { StopReason as $, ModelCostConfig as A, extractDiagnosticError as At, ProviderImagesOptions as B, KnownApi as C, readRuntimeContextMetadata as Ct, MaybePromise as D, DiagnosticErrorInfo as Dt, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE as E, AssistantMessageDiagnostic as Et, OpenRouterRouting as F, RUNTIME_CONTEXT_CUSTOM_TYPE as G, ProviderResponse as H, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE as I, RUNTIME_CONTEXT_HEADER as J, RUNTIME_CONTEXT_END_MARKER as K, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE as L, ModelThinkingLevel as M, isProviderRefusalAssistantError as Mt, OpenAICompletionsCompat as N, ModelDataThinkingFormat as Nt, Message as O, appendAssistantMessageDiagnostic as Ot, OpenAIResponsesCompat as P, SimpleStreamOptions as Q, PricingTier as R, ImagesStopReason as S, labelRuntimeContextText as St, KnownImagesProvider as T, setRuntimeContextRetention as Tt, ProviderStreamOptions as U, ProviderReplayState as V, RUNTIME_CONTEXT_BEGIN_MARKER as W, RawPricingTier as X, RawModelCostConfig as Y, RuntimeContextMessage as Z, ImagesInputContent as _, escapeRuntimeContextFooter as _t, AssistantMessage as a, ThinkingBudgets as at, ImagesOutputContent as b, isRuntimeContextMessage as bt, AssistantMessageEventStreamLike as c, ThinkingLevelMap as ct, Context as d, ToolResultMessage as dt, StreamFn as et, DEFAULT_MISSING_TOOL_RESULT_TEXT as f, Transport as ft, ImagesFunction as g, VercelGatewayRouting as gt, ImagesContext as h, ValidateToolArgumentsFn as ht, AssistantImages as i, TextSignatureV1 as it, ModelCostRates as j, formatThrownValue as jt, Model as k, createAssistantMessageDiagnostic as kt, CacheRetention as l, Tool as lt, ImagesApi as m, UserMessage as mt, Api as n, StreamOptions as nt, AssistantMessageEvent as o, ThinkingContent as ot, ImageContent as p, Usage as pt, RUNTIME_CONTEXT_FOOTER as q, AssistantDeliveryTtsFacts as r, TextContent as rt, AssistantMessageEventStreamContract as s, ThinkingLevel as st, AnthropicMessagesCompat as t, StreamFunction as tt, CompleteSimpleFn as u, ToolCall as ut, ImagesModel as v, hasLegacyRuntimeContextEnvelope as vt, KnownImagesApi as w, runtimeContextContentToText as wt, ImagesProvider as x, labelRuntimeContextContent as xt, ImagesOptions as y, hasRuntimeContextMarker as yt, Provider as z };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as resolveClaudeSonnet5ModelIdentity, D as
|
|
2
|
-
import { $ as
|
|
3
|
-
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-
|
|
4
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
5
|
-
import "./types-
|
|
6
|
-
export { AnthropicMessagesCompat, Api, AssistantDeliveryTtsFacts, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_55_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_55_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, Context, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, MaybePromise, Message, Model, ModelCostConfig, ModelCostRates, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, PricingTier, Provider, ProviderImagesOptions, type ProviderRefusalReview, ProviderReplayState, ProviderResponse, ProviderStreamOptions, RawModelCostConfig, RawPricingTier, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, bindsClaudeThinkingPrefix, calculateUsageCost, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, isProviderRefusalAssistantError, normalizeModelCostConfig, normalizeResolvedPricing, readProviderRefusalReview, requiresClaudeBetweenToolsThinking, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus55ModelIdentity, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet55ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
1
|
+
import { C as resolveClaudeSonnet5ModelIdentity, D as supportsClaudeInHistorySystemMessages, E as supportsClaudeFastMode, O as supportsClaudeNativeMaxEffort, S as resolveClaudeSonnet55ModelIdentity, T as supportsClaudeAdaptiveThinking, _ as resolveClaudeModelIdentity, a as ProviderRefusalReview, b as resolveClaudeOpus55ModelIdentity, c as CLAUDE_OPUS_55_THINKING_PROFILE, d as CLAUDE_SONNET_5_THINKING_PROFILE, f as bindsClaudeThinkingPrefix, g as resolveClaudeFable5ModelIdentity, h as requiresClaudeMandatoryAdaptiveThinking, i as normalizeResolvedPricing, k as supportsClaudeNativeXhighEffort, l as CLAUDE_OPUS_5_THINKING_PROFILE, m as requiresClaudeDefaultSampling, n as calculateUsageCost, o as readProviderRefusalReview, p as requiresClaudeBetweenToolsThinking, r as normalizeModelCostConfig, s as CLAUDE_FABLE_5_THINKING_PROFILE, u as CLAUDE_SONNET_55_THINKING_PROFILE, v as resolveClaudeMythos5ModelIdentity, w as supportsClaude1MContext, x as resolveClaudeOpus5ModelIdentity, y as resolveClaudeNativeThinkingLevelMap } from "./index-a8e_oKnu.mjs";
|
|
2
|
+
import { $ as StopReason, A as ModelCostConfig, At as extractDiagnosticError, B as ProviderImagesOptions, C as KnownApi, Ct as readRuntimeContextMetadata, D as MaybePromise, Dt as DiagnosticErrorInfo, E as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, Et as AssistantMessageDiagnostic, F as OpenRouterRouting, G as RUNTIME_CONTEXT_CUSTOM_TYPE, H as ProviderResponse, I as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, J as RUNTIME_CONTEXT_HEADER, K as RUNTIME_CONTEXT_END_MARKER, L as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, M as ModelThinkingLevel, Mt as isProviderRefusalAssistantError, N as OpenAICompletionsCompat, O as Message, Ot as appendAssistantMessageDiagnostic, P as OpenAIResponsesCompat, Q as SimpleStreamOptions, R as PricingTier, S as ImagesStopReason, St as labelRuntimeContextText, T as KnownImagesProvider, Tt as setRuntimeContextRetention, U as ProviderStreamOptions, V as ProviderReplayState, W as RUNTIME_CONTEXT_BEGIN_MARKER, X as RawPricingTier, Y as RawModelCostConfig, Z as RuntimeContextMessage, _ as ImagesInputContent, _t as escapeRuntimeContextFooter, a as AssistantMessage, at as ThinkingBudgets, b as ImagesOutputContent, bt as isRuntimeContextMessage, c as AssistantMessageEventStreamLike, ct as ThinkingLevelMap, d as Context, dt as ToolResultMessage, et as StreamFn, f as DEFAULT_MISSING_TOOL_RESULT_TEXT, ft as Transport, g as ImagesFunction, gt as VercelGatewayRouting, h as ImagesContext, ht as ValidateToolArgumentsFn, i as AssistantImages, it as TextSignatureV1, j as ModelCostRates, jt as formatThrownValue, k as Model, kt as createAssistantMessageDiagnostic, l as CacheRetention, lt as Tool, m as ImagesApi, mt as UserMessage, n as Api, nt as StreamOptions, o as AssistantMessageEvent, ot as ThinkingContent, p as ImageContent, pt as Usage, q as RUNTIME_CONTEXT_FOOTER, r as AssistantDeliveryTtsFacts, rt as TextContent, s as AssistantMessageEventStreamContract, st as ThinkingLevel, t as AnthropicMessagesCompat, tt as StreamFunction, u as CompleteSimpleFn, ut as ToolCall, v as ImagesModel, vt as hasLegacyRuntimeContextEnvelope, w as KnownImagesApi, wt as runtimeContextContentToText, x as ImagesProvider, xt as labelRuntimeContextContent, y as ImagesOptions, yt as hasRuntimeContextMarker, z as Provider } from "./types-DvzmWW8J.mjs";
|
|
3
|
+
import { n as EventStream, r as createAssistantMessageEventStream, t as AssistantMessageEventStream } from "./event-stream-DrRM_90c.mjs";
|
|
4
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-B3lQt_VE.mjs";
|
|
5
|
+
import "./types-BuiEBM3u.mjs";
|
|
6
|
+
export { AnthropicMessagesCompat, Api, AssistantDeliveryTtsFacts, AssistantImages, AssistantMessage, AssistantMessageDiagnostic, AssistantMessageEvent, AssistantMessageEventStream, AssistantMessageEventStreamContract, AssistantMessageEventStreamLike, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_55_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_55_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, CacheRetention, CompleteSimpleFn, Context, DEFAULT_MISSING_TOOL_RESULT_TEXT, DiagnosticErrorInfo, EventStream, ImageContent, ImagesApi, ImagesContext, ImagesFunction, ImagesInputContent, ImagesModel, ImagesOptions, ImagesOutputContent, ImagesProvider, ImagesStopReason, KnownApi, KnownImagesApi, KnownImagesProvider, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, MaybePromise, Message, Model, ModelCostConfig, ModelCostRates, ModelThinkingLevel, OpenAICompletionsCompat, OpenAIResponsesCompat, OpenRouterRouting, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, PricingTier, Provider, ProviderImagesOptions, type ProviderRefusalReview, ProviderReplayState, ProviderResponse, ProviderStreamOptions, RUNTIME_CONTEXT_BEGIN_MARKER, RUNTIME_CONTEXT_CUSTOM_TYPE, RUNTIME_CONTEXT_END_MARKER, RUNTIME_CONTEXT_FOOTER, RUNTIME_CONTEXT_HEADER, RawModelCostConfig, RawPricingTier, RuntimeContextMessage, SimpleStreamOptions, StopReason, StreamFn, StreamFunction, StreamOptions, TextContent, TextSignatureV1, ThinkingBudgets, ThinkingContent, ThinkingLevel, ThinkingLevelMap, Tool, ToolCall, ToolResultMessage, Transport, Usage, UserMessage, ValidateToolArgumentsFn, VercelGatewayRouting, appendAssistantMessageDiagnostic, bindsClaudeThinkingPrefix, calculateUsageCost, createAssistantMessageDiagnostic, createAssistantMessageEventStream, escapeRuntimeContextFooter, extractDiagnosticError, formatThrownValue, hasLegacyRuntimeContextEnvelope, hasRuntimeContextMarker, isProviderRefusalAssistantError, isRuntimeContextMessage, labelRuntimeContextContent, labelRuntimeContextText, normalizeModelCostConfig, normalizeResolvedPricing, readProviderRefusalReview, readRuntimeContextMetadata, requiresClaudeBetweenToolsThinking, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus55ModelIdentity, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet55ModelIdentity, resolveClaudeSonnet5ModelIdentity, runtimeContextContentToText, setRuntimeContextRetention, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeInHistorySystemMessages, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
package/dist/types.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as supportsClaudeFastMode, S as supportsClaudeAdaptiveThinking, T as
|
|
2
|
-
import { n as
|
|
1
|
+
import { C as supportsClaudeFastMode, E as supportsClaudeNativeXhighEffort, S as supportsClaudeAdaptiveThinking, T as supportsClaudeNativeMaxEffort, _ as resolveClaudeOpus55ModelIdentity, a as CLAUDE_OPUS_55_THINKING_PROFILE, b as resolveClaudeSonnet5ModelIdentity, c as CLAUDE_SONNET_5_THINKING_PROFILE, d as requiresClaudeDefaultSampling, f as requiresClaudeMandatoryAdaptiveThinking, g as resolveClaudeNativeThinkingLevelMap, h as resolveClaudeMythos5ModelIdentity, i as CLAUDE_FABLE_5_THINKING_PROFILE, l as bindsClaudeThinkingPrefix, m as resolveClaudeModelIdentity, n as normalizeModelCostConfig, o as CLAUDE_OPUS_5_THINKING_PROFILE, p as resolveClaudeFable5ModelIdentity, r as normalizeResolvedPricing, s as CLAUDE_SONNET_55_THINKING_PROFILE, t as calculateUsageCost, u as requiresClaudeBetweenToolsThinking, v as resolveClaudeOpus5ModelIdentity, w as supportsClaudeInHistorySystemMessages, x as supportsClaude1MContext, y as resolveClaudeSonnet55ModelIdentity } from "./src-B0NIt2UK.mjs";
|
|
2
|
+
import { _ as runtimeContextContentToText, a as RUNTIME_CONTEXT_BEGIN_MARKER, c as RUNTIME_CONTEXT_FOOTER, d as hasLegacyRuntimeContextEnvelope, f as hasRuntimeContextMarker, g as readRuntimeContextMetadata, h as labelRuntimeContextText, i as PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, l as RUNTIME_CONTEXT_HEADER, m as labelRuntimeContextContent, n as MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, o as RUNTIME_CONTEXT_CUSTOM_TYPE, p as isRuntimeContextMessage, r as PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, s as RUNTIME_CONTEXT_END_MARKER, t as DEFAULT_MISSING_TOOL_RESULT_TEXT, u as escapeRuntimeContextFooter, v as setRuntimeContextRetention } from "./types-CQc6JNG4.mjs";
|
|
3
3
|
import { a as isProviderRefusalAssistantError, i as formatThrownValue, n as createAssistantMessageDiagnostic, o as readProviderRefusalReview, r as extractDiagnosticError, t as appendAssistantMessageDiagnostic } from "./diagnostics-DzrF1h4J.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
6
|
-
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_55_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_55_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, EventStream, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, appendAssistantMessageDiagnostic, bindsClaudeThinkingPrefix, calculateUsageCost, createAssistantMessageDiagnostic, createAssistantMessageEventStream, extractDiagnosticError, formatThrownValue, isProviderRefusalAssistantError, normalizeModelCostConfig, normalizeResolvedPricing, readProviderRefusalReview, requiresClaudeBetweenToolsThinking, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus55ModelIdentity, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet55ModelIdentity, resolveClaudeSonnet5ModelIdentity, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
4
|
+
import { a as createAssistantMessageEventStream, n as EventStream, t as AssistantMessageEventStream } from "./event-stream-C5AbCAaZ.mjs";
|
|
5
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-DbqlIfDn.mjs";
|
|
6
|
+
export { AssistantMessageEventStream, CLAUDE_FABLE_5_THINKING_PROFILE, CLAUDE_OPUS_55_THINKING_PROFILE, CLAUDE_OPUS_5_THINKING_PROFILE, CLAUDE_SONNET_55_THINKING_PROFILE, CLAUDE_SONNET_5_THINKING_PROFILE, DEFAULT_MISSING_TOOL_RESULT_TEXT, EventStream, MALFORMED_TOOL_CALL_ARGUMENTS_ERROR_CODE, PROVIDER_FAILURE_WITH_OUTPUT_ERROR_CODE, PROVIDER_POST_DISPATCH_AMBIGUITY_ERROR_CODE, RUNTIME_CONTEXT_BEGIN_MARKER, RUNTIME_CONTEXT_CUSTOM_TYPE, RUNTIME_CONTEXT_END_MARKER, RUNTIME_CONTEXT_FOOTER, RUNTIME_CONTEXT_HEADER, appendAssistantMessageDiagnostic, bindsClaudeThinkingPrefix, calculateUsageCost, createAssistantMessageDiagnostic, createAssistantMessageEventStream, escapeRuntimeContextFooter, extractDiagnosticError, formatThrownValue, hasLegacyRuntimeContextEnvelope, hasRuntimeContextMarker, isProviderRefusalAssistantError, isRuntimeContextMessage, labelRuntimeContextContent, labelRuntimeContextText, normalizeModelCostConfig, normalizeResolvedPricing, readProviderRefusalReview, readRuntimeContextMetadata, requiresClaudeBetweenToolsThinking, requiresClaudeDefaultSampling, requiresClaudeMandatoryAdaptiveThinking, resolveClaudeFable5ModelIdentity, resolveClaudeModelIdentity, resolveClaudeMythos5ModelIdentity, resolveClaudeNativeThinkingLevelMap, resolveClaudeOpus55ModelIdentity, resolveClaudeOpus5ModelIdentity, resolveClaudeSonnet55ModelIdentity, resolveClaudeSonnet5ModelIdentity, runtimeContextContentToText, setRuntimeContextRetention, supportsClaude1MContext, supportsClaudeAdaptiveThinking, supportsClaudeFastMode, supportsClaudeInHistorySystemMessages, supportsClaudeNativeMaxEffort, supportsClaudeNativeXhighEffort, validateToolArguments, validateToolCall };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region packages/ai/src/utils/usage.ts
|
|
2
|
+
function createZeroUsage() {
|
|
3
|
+
return {
|
|
4
|
+
input: 0,
|
|
5
|
+
output: 0,
|
|
6
|
+
cacheRead: 0,
|
|
7
|
+
cacheWrite: 0,
|
|
8
|
+
totalTokens: 0,
|
|
9
|
+
cost: {
|
|
10
|
+
input: 0,
|
|
11
|
+
output: 0,
|
|
12
|
+
cacheRead: 0,
|
|
13
|
+
cacheWrite: 0,
|
|
14
|
+
total: 0
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { createZeroUsage as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { lt as Tool, ut as ToolCall } from "./types-DvzmWW8J.mjs";
|
|
2
2
|
//#region packages/llm-core/src/validation.d.ts
|
|
3
3
|
/** Finds the target tool and validates/coerces a model-emitted tool call. */
|
|
4
4
|
declare function validateToolCall(tools: Tool[], toolCall: ToolCall): unknown;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as parseLocalSchemaRefPointer } from "./json-schema-Bp07Qui3.mjs";
|
|
2
|
+
import { a as parseStrictFiniteNumber } from "./number-coercion-V8-BhME4.mjs";
|
|
2
3
|
import { Pointer } from "typebox/schema";
|
|
4
|
+
import { Compile } from "typebox/compile";
|
|
3
5
|
//#region packages/llm-core/src/validation.ts
|
|
4
6
|
const validatorCache = /* @__PURE__ */ new WeakMap();
|
|
5
7
|
/** Maximum string length accepted for schema-gated JSON coercion. */
|
|
@@ -19,11 +21,10 @@ function hasSchemaScope(schema) {
|
|
|
19
21
|
].some((key) => key in schema);
|
|
20
22
|
}
|
|
21
23
|
function resolveRootSchemaRef(schema, root) {
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
if (!root ||
|
|
25
|
-
const table =
|
|
26
|
-
const name = encodedName.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
24
|
+
const tokens = typeof schema.$ref === "string" ? parseLocalSchemaRefPointer(schema.$ref) : void 0;
|
|
25
|
+
const [tableName, name] = tokens ?? [];
|
|
26
|
+
if (!root || tokens?.length !== 2 || tableName !== "$defs" && tableName !== "definitions" || !name || hasSchemaScope(schema)) return;
|
|
27
|
+
const table = tableName === "$defs" ? root.$defs : root.definitions;
|
|
27
28
|
const target = table && Object.hasOwn(table, name) ? table[name] : void 0;
|
|
28
29
|
return isJsonSchemaObject(target) && !hasSchemaScope(target) ? target : void 0;
|
|
29
30
|
}
|
|
@@ -55,13 +56,6 @@ function matchesJsonType(value, type) {
|
|
|
55
56
|
function isValidatorSchema(value) {
|
|
56
57
|
return isObjectBackedRecord(value);
|
|
57
58
|
}
|
|
58
|
-
const JSON_NUMBER_TOKEN_RE = /^[+-]?(?:(?:\d+\.?\d*)|(?:\.\d+))(?:e[+-]?\d+)?$/iu;
|
|
59
|
-
function parseJsonNumberString(value) {
|
|
60
|
-
const trimmed = value.trim();
|
|
61
|
-
if (!trimmed || !JSON_NUMBER_TOKEN_RE.test(trimmed)) return;
|
|
62
|
-
const parsed = Number(trimmed);
|
|
63
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
64
|
-
}
|
|
65
59
|
function getSubSchemaValidator(schema, root) {
|
|
66
60
|
if (!isValidatorSchema(schema)) return;
|
|
67
61
|
try {
|
|
@@ -76,21 +70,14 @@ function coercePrimitiveByType(value, type) {
|
|
|
76
70
|
case "integer":
|
|
77
71
|
if (value === null) return 0;
|
|
78
72
|
if (typeof value === "string") {
|
|
79
|
-
const parsed =
|
|
73
|
+
const parsed = parseStrictFiniteNumber(value);
|
|
80
74
|
if (parsed !== void 0 && (type === "number" || Number.isSafeInteger(parsed))) return parsed;
|
|
81
75
|
}
|
|
82
76
|
if (typeof value === "boolean") return value ? 1 : 0;
|
|
83
77
|
return value;
|
|
84
78
|
case "boolean":
|
|
85
|
-
if (value === null) return false;
|
|
86
|
-
if (
|
|
87
|
-
if (value === "true") return true;
|
|
88
|
-
if (value === "false") return false;
|
|
89
|
-
}
|
|
90
|
-
if (typeof value === "number") {
|
|
91
|
-
if (value === 1) return true;
|
|
92
|
-
if (value === 0) return false;
|
|
93
|
-
}
|
|
79
|
+
if (value === null || value === "false" || value === 0) return false;
|
|
80
|
+
if (value === "true" || value === 1) return true;
|
|
94
81
|
return value;
|
|
95
82
|
case "string":
|
|
96
83
|
if (value === null) return "";
|
|
@@ -121,14 +108,12 @@ function applySchemaObjectCoercion(value, schema, root) {
|
|
|
121
108
|
}
|
|
122
109
|
}
|
|
123
110
|
function applySchemaArrayCoercion(value, schema, root) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return;
|
|
111
|
+
const items = schema.items;
|
|
112
|
+
if (!isJsonSchemaObject(items)) return;
|
|
113
|
+
for (let index = 0; index < value.length; index++) {
|
|
114
|
+
const itemSchema = Array.isArray(items) ? items[index] : items;
|
|
115
|
+
if (itemSchema) value[index] = coerceWithJsonSchema(value[index], itemSchema, root);
|
|
130
116
|
}
|
|
131
|
-
if (isJsonSchemaObject(schema.items)) for (let index = 0; index < value.length; index++) value[index] = coerceWithJsonSchema(value[index], schema.items, root);
|
|
132
117
|
}
|
|
133
118
|
function coerceWithUnionSchema(value, schemas, root, refs) {
|
|
134
119
|
if (value === null) {
|
package/dist/validation.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
1
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-B3lQt_VE.mjs";
|
|
2
2
|
export { validateToolArguments, validateToolCall };
|
package/dist/validation.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as validateToolCall, t as validateToolArguments } from "./validation-
|
|
1
|
+
import { n as validateToolCall, t as validateToolArguments } from "./validation-DbqlIfDn.mjs";
|
|
2
2
|
export { validateToolArguments, validateToolCall };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/ai",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.10.1-beta.1",
|
|
4
4
|
"description": "Reusable model provider adapters and streaming runtime from OpenClaw",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -118,10 +118,10 @@
|
|
|
118
118
|
}
|
|
119
119
|
},
|
|
120
120
|
"dependencies": {
|
|
121
|
-
"@anthropic-ai/sdk": "0.
|
|
122
|
-
"@google/genai": "2.
|
|
121
|
+
"@anthropic-ai/sdk": "0.128.0",
|
|
122
|
+
"@google/genai": "2.24.0",
|
|
123
123
|
"@mistralai/mistralai": "2.7.0",
|
|
124
|
-
"openai": "7.
|
|
124
|
+
"openai": "7.23.0",
|
|
125
125
|
"partial-json": "0.1.7",
|
|
126
126
|
"typebox": "1.3.34"
|
|
127
127
|
},
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region packages/ai/src/providers/cache-retention.ts
|
|
2
|
-
/**
|
|
3
|
-
* Resolve cache retention preference.
|
|
4
|
-
* Defaults to "short" and uses OPENCLAW_CACHE_RETENTION for backward compatibility.
|
|
5
|
-
*/
|
|
6
|
-
function resolveCacheRetention(cacheRetention) {
|
|
7
|
-
if (cacheRetention === "short" || cacheRetention === "long" || cacheRetention === "none") return cacheRetention;
|
|
8
|
-
if (typeof process !== "undefined" && process.env.OPENCLAW_CACHE_RETENTION === "long") return "long";
|
|
9
|
-
return "short";
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { resolveCacheRetention as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./event-stream-DOPFYVqs.mjs";
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { t as projectCopilotRequestFacts } from "./github-copilot-request-facts-BTEBMeOv.mjs";
|
|
2
|
-
//#region packages/ai/src/providers/cloudflare.ts
|
|
3
|
-
function isCloudflareProvider(provider) {
|
|
4
|
-
return provider === "cloudflare-workers-ai" || provider === "cloudflare-ai-gateway";
|
|
5
|
-
}
|
|
6
|
-
/** Substitute `{VAR}` placeholders in a Cloudflare baseUrl from process.env. */
|
|
7
|
-
function resolveCloudflareBaseUrl(model) {
|
|
8
|
-
const url = model.baseUrl;
|
|
9
|
-
if (!url.includes("{")) return url;
|
|
10
|
-
return url.replace(/\{([A-Z_][A-Z0-9_]*)\}/g, (_match, name) => {
|
|
11
|
-
const value = process.env[name];
|
|
12
|
-
if (!value) throw new Error(`${name} is required for provider ${model.provider} but is not set.`);
|
|
13
|
-
return value;
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
//#endregion
|
|
17
|
-
//#region packages/ai/src/providers/github-copilot-headers.ts
|
|
18
|
-
function hasCopilotVisionInput(messages) {
|
|
19
|
-
return projectCopilotRequestFacts(messages, "direct").hasImages;
|
|
20
|
-
}
|
|
21
|
-
function buildCopilotDynamicHeaders(params) {
|
|
22
|
-
const headers = {
|
|
23
|
-
"X-Initiator": projectCopilotRequestFacts(params.messages, "direct", params.hasImages).initiator,
|
|
24
|
-
"Openai-Intent": "conversation-edits"
|
|
25
|
-
};
|
|
26
|
-
if (params.hasImages) headers["Copilot-Vision-Request"] = "true";
|
|
27
|
-
return headers;
|
|
28
|
-
}
|
|
29
|
-
//#endregion
|
|
30
|
-
export { resolveCloudflareBaseUrl as i, hasCopilotVisionInput as n, isCloudflareProvider as r, buildCopilotDynamicHeaders as t };
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
|
-
import { t as AssistantMessageEventStream } from "./event-stream-vd9UnCAU.mjs";
|
|
3
|
-
import { T as clampThinkingLevel } from "./host-CHi3X87F.mjs";
|
|
4
|
-
import { i as resolveOpenAICompletionsCompat } from "./openai-completions-compat-BOVWBZDn.mjs";
|
|
5
|
-
import { t as resolveCacheRetention } from "./cache-retention-0x979a5V.mjs";
|
|
6
|
-
import { S as withProviderResponseHook, b as transportAbortError, n as assignTransportErrorDetails } from "./transport-stream-shared-Dh5qKJ8e.mjs";
|
|
7
|
-
import { n as buildBaseOptions, s as prepareModelRequestBody, u as reasoningTagTextPolicy } from "./simple-options-CGAkCwtM.mjs";
|
|
8
|
-
import { S as isOpenAICompletionsThinkingEnabled, y as createOpenAIProviderAcceptanceHook } from "./openai-transport-params-BwlpzX-2.mjs";
|
|
9
|
-
import { n as getEnvApiKey } from "./env-api-keys-CyX4VKGO.mjs";
|
|
10
|
-
import { a as tagUnresolvedTextAsCommentary, t as clearPendingCommentaryText } from "./assistant-text-phase-C20rxWwP.mjs";
|
|
11
|
-
import { n as createAssistantOutput } from "./provider-transcript-transform-JbFbHV8h.mjs";
|
|
12
|
-
import { a as convertMessages, i as buildOpenAICompletionsRequest, s as finalizeOpenAICompletionsToolCalls, t as processCompletionsStream } from "./openai-completions-stream-CDCuw3DP.mjs";
|
|
13
|
-
import { i as getFirstStreamEventTimeoutMs, r as getFirstStreamEventTimeoutHandler, t as createFirstStreamEventAbortController } from "./stream-first-event-timeout-B9o0S4SZ.mjs";
|
|
14
|
-
import { n as resolveProviderSimpleCompletionHeaders } from "./provider-transport-turn-state-BheUi_hl.mjs";
|
|
15
|
-
import { n as hasCopilotVisionInput, t as buildCopilotDynamicHeaders } from "./github-copilot-headers-B37TB3rB.mjs";
|
|
16
|
-
import { t as createOpenAIProviderClient } from "./openai-provider-client-CwfsGBbA.mjs";
|
|
17
|
-
//#region packages/ai/src/providers/openai-completions.ts
|
|
18
|
-
var openai_completions_exports = /* @__PURE__ */ __exportAll({
|
|
19
|
-
convertMessages: () => convertMessages,
|
|
20
|
-
streamOpenAICompletions: () => streamOpenAICompletions,
|
|
21
|
-
streamSimpleOpenAICompletions: () => streamSimpleOpenAICompletions
|
|
22
|
-
});
|
|
23
|
-
const streamOpenAICompletions = (model, context, options) => {
|
|
24
|
-
const stream = new AssistantMessageEventStream();
|
|
25
|
-
(async () => {
|
|
26
|
-
const output = createAssistantOutput(model);
|
|
27
|
-
const provisionalCommentaryTags = /* @__PURE__ */ new Map();
|
|
28
|
-
let firstEventAbort;
|
|
29
|
-
try {
|
|
30
|
-
const apiKey = options?.apiKey || getEnvApiKey(model.provider) || "";
|
|
31
|
-
const compat = resolveOpenAICompletionsCompat(model);
|
|
32
|
-
const shouldEmitReasoning = Boolean(model.reasoning && options?.reasoningEffort && isOpenAICompletionsThinkingEnabled(options.reasoningEffort));
|
|
33
|
-
const cacheRetention = resolveCacheRetention(options?.cacheRetention);
|
|
34
|
-
const cacheSessionId = cacheRetention === "none" ? void 0 : options?.sessionId;
|
|
35
|
-
const client = createClient(model, context, apiKey, resolveProviderSimpleCompletionHeaders(model, options), cacheSessionId, compat);
|
|
36
|
-
let params = buildOpenAICompletionsRequest(model, context, options, {
|
|
37
|
-
mode: "direct",
|
|
38
|
-
compat,
|
|
39
|
-
cacheRetention
|
|
40
|
-
});
|
|
41
|
-
const encodeBody = prepareModelRequestBody(options);
|
|
42
|
-
const nextParams = await options?.onPayload?.(params, model);
|
|
43
|
-
if (nextParams !== void 0) params = nextParams;
|
|
44
|
-
firstEventAbort = createFirstStreamEventAbortController(options?.signal);
|
|
45
|
-
const requestOptions = {
|
|
46
|
-
...await encodeBody(params),
|
|
47
|
-
signal: firstEventAbort.signal,
|
|
48
|
-
...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
|
|
49
|
-
maxRetries: 0
|
|
50
|
-
};
|
|
51
|
-
const { data: openaiStream, response } = await client.chat.completions.create(params, requestOptions).withResponse();
|
|
52
|
-
const hookedOpenAIStream = withProviderResponseHook({
|
|
53
|
-
stream: openaiStream,
|
|
54
|
-
signal: firstEventAbort.signal,
|
|
55
|
-
abort: firstEventAbort.abort,
|
|
56
|
-
hook: createOpenAIProviderAcceptanceHook(options, response, model),
|
|
57
|
-
onReady: () => stream.push({
|
|
58
|
-
type: "start",
|
|
59
|
-
partial: output
|
|
60
|
-
})
|
|
61
|
-
});
|
|
62
|
-
const finishedBlocks = /* @__PURE__ */ new Set();
|
|
63
|
-
const contentIndices = /* @__PURE__ */ new WeakMap();
|
|
64
|
-
let openTextBlock;
|
|
65
|
-
let openThinkingBlock;
|
|
66
|
-
const finishBlock = (block) => {
|
|
67
|
-
const contentIndex = contentIndices.get(block);
|
|
68
|
-
if (contentIndex === void 0 || finishedBlocks.has(block)) return;
|
|
69
|
-
finishedBlocks.add(block);
|
|
70
|
-
if (block.type === "text") {
|
|
71
|
-
openTextBlock = void 0;
|
|
72
|
-
stream.push({
|
|
73
|
-
type: "text_end",
|
|
74
|
-
contentIndex,
|
|
75
|
-
content: block.text,
|
|
76
|
-
partial: output
|
|
77
|
-
});
|
|
78
|
-
} else if (block.type === "thinking") {
|
|
79
|
-
openThinkingBlock = void 0;
|
|
80
|
-
stream.push({
|
|
81
|
-
type: "thinking_end",
|
|
82
|
-
contentIndex,
|
|
83
|
-
content: block.thinking,
|
|
84
|
-
partial: output
|
|
85
|
-
});
|
|
86
|
-
} else if (block.type === "toolCall") stream.push({
|
|
87
|
-
type: "toolcall_end",
|
|
88
|
-
contentIndex,
|
|
89
|
-
toolCall: block,
|
|
90
|
-
partial: output
|
|
91
|
-
});
|
|
92
|
-
};
|
|
93
|
-
const directEventStream = { push(event) {
|
|
94
|
-
if (event.type === "text_start" || event.type === "thinking_start" || event.type === "toolcall_start") {
|
|
95
|
-
const block = output.content[event.contentIndex];
|
|
96
|
-
if (block) {
|
|
97
|
-
contentIndices.set(block, event.contentIndex);
|
|
98
|
-
if (block.type === "text") openTextBlock = block;
|
|
99
|
-
else if (block.type === "thinking") openThinkingBlock = block;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
stream.push(event);
|
|
103
|
-
} };
|
|
104
|
-
try {
|
|
105
|
-
await processCompletionsStream(hookedOpenAIStream, output, model, directEventStream, {
|
|
106
|
-
mode: "direct",
|
|
107
|
-
beforeContentBlock(nextType) {
|
|
108
|
-
if (openThinkingBlock) finishBlock(openThinkingBlock);
|
|
109
|
-
if (openTextBlock && nextType !== "toolCall") finishBlock(openTextBlock);
|
|
110
|
-
},
|
|
111
|
-
provisionalCommentaryTags,
|
|
112
|
-
signal: options?.signal,
|
|
113
|
-
emitReasoning: shouldEmitReasoning,
|
|
114
|
-
strictReasoningTags: reasoningTagTextPolicy.isStrict(options),
|
|
115
|
-
firstEventTimeoutMs: getFirstStreamEventTimeoutMs(options),
|
|
116
|
-
abortFirstEventStream: firstEventAbort.abort,
|
|
117
|
-
onFirstEventTimeout: getFirstStreamEventTimeoutHandler(options)
|
|
118
|
-
});
|
|
119
|
-
if (options?.signal?.aborted) throw transportAbortError(options.signal);
|
|
120
|
-
if (output.stopReason === "aborted" || output.stopReason === "error") throw new Error(output.errorMessage || (output.stopReason === "aborted" ? "Request was aborted" : "Provider returned an invalid tool call"));
|
|
121
|
-
} catch (error) {
|
|
122
|
-
for (const block of output.content) if (block.type !== "toolCall") finishBlock(block);
|
|
123
|
-
throw error;
|
|
124
|
-
}
|
|
125
|
-
for (const block of output.content) if (block.type !== "toolCall" || output.stopReason === "toolUse") finishBlock(block);
|
|
126
|
-
stream.push({
|
|
127
|
-
type: "done",
|
|
128
|
-
reason: output.stopReason,
|
|
129
|
-
message: output
|
|
130
|
-
});
|
|
131
|
-
stream.end();
|
|
132
|
-
} catch (error) {
|
|
133
|
-
const terminal = assignTransportErrorDetails(output, error, options?.signal);
|
|
134
|
-
finalizeOpenAICompletionsToolCalls(output, { allowSilentToolCallPromotion: false });
|
|
135
|
-
clearPendingCommentaryText(provisionalCommentaryTags);
|
|
136
|
-
tagUnresolvedTextAsCommentary(output);
|
|
137
|
-
for (const block of output.content) {
|
|
138
|
-
delete block.index;
|
|
139
|
-
delete block.partialArgs;
|
|
140
|
-
delete block.streamIndex;
|
|
141
|
-
}
|
|
142
|
-
stream.push({
|
|
143
|
-
type: "error",
|
|
144
|
-
reason: terminal.stopReason,
|
|
145
|
-
error: output
|
|
146
|
-
});
|
|
147
|
-
stream.end();
|
|
148
|
-
} finally {
|
|
149
|
-
firstEventAbort?.dispose();
|
|
150
|
-
}
|
|
151
|
-
})();
|
|
152
|
-
return stream;
|
|
153
|
-
};
|
|
154
|
-
const streamSimpleOpenAICompletions = (model, context, options) => {
|
|
155
|
-
const apiKey = options?.apiKey || getEnvApiKey(model.provider);
|
|
156
|
-
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
157
|
-
const base = buildBaseOptions(model, options, apiKey);
|
|
158
|
-
const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : void 0;
|
|
159
|
-
const toolChoice = options?.toolChoice;
|
|
160
|
-
return streamOpenAICompletions(model, context, {
|
|
161
|
-
...base,
|
|
162
|
-
reasoningEffort: clampedReasoning,
|
|
163
|
-
toolChoice
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
function createClient(model, context, apiKey, optionsHeaders, sessionId, compat = resolveOpenAICompletionsCompat(model)) {
|
|
167
|
-
if (!apiKey) throw new Error(`No API key for provider: ${model.provider}`);
|
|
168
|
-
const headers = { ...model.headers };
|
|
169
|
-
if (model.provider === "github-copilot") {
|
|
170
|
-
const hasImages = hasCopilotVisionInput(context.messages);
|
|
171
|
-
const copilotHeaders = buildCopilotDynamicHeaders({
|
|
172
|
-
messages: context.messages,
|
|
173
|
-
hasImages
|
|
174
|
-
});
|
|
175
|
-
Object.assign(headers, copilotHeaders);
|
|
176
|
-
}
|
|
177
|
-
if (sessionId && compat.sessionAffinity !== "none") {
|
|
178
|
-
if (compat.sessionAffinity === "openrouter") headers["x-session-id"] = sessionId;
|
|
179
|
-
else {
|
|
180
|
-
headers.session_id = sessionId;
|
|
181
|
-
headers["x-client-request-id"] = sessionId;
|
|
182
|
-
headers["x-session-affinity"] = sessionId;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return createOpenAIProviderClient(model, apiKey, headers, optionsHeaders);
|
|
186
|
-
}
|
|
187
|
-
//#endregion
|
|
188
|
-
export { streamOpenAICompletions as n, streamSimpleOpenAICompletions as r, openai_completions_exports as t };
|