omnius 1.0.849 → 1.0.850
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/library.js +261 -178
- package/docs/DISCOVERY.json +183 -1
- package/docs/DISCOVERY.md +6 -1
- package/docs/work-orders/WO-opencode-production-compatibility-20261012.md +90 -0
- package/docs/work-orders/WO-telegram-progress-presentation-20261012.md +27 -10
- package/docs/work-orders/evidence/opencode-installed-production-stream-live-20261012.json +218 -0
- package/docs/work-orders/evidence/opencode-production-cascade-live-20261012.json +214 -0
- package/docs/work-orders/evidence/opencode-production-pre-recovery-live-20261012.json +167 -0
- package/docs/work-orders/evidence/opencode-step-rate-limited-diagnostic-20261012.json +88 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/index.js
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 37197306 bytes
|
|
4
|
+
sha256: d8636120a09b01e5510cb048c5cafcbb0598474653831174196e6e708de3c33e
|
package/dist/library.js
CHANGED
|
@@ -342626,6 +342626,14 @@ var OPENCODE_MODEL_CATALOG_URL = "https://models.opencode.ai/api.json";
|
|
|
342626
342626
|
var OPENCODE_INFERENCE_BASE_URL = "https://opencode.ai/inference/v1";
|
|
342627
342627
|
var OPENCODE_AVAILABLE_MODELS_URL = `${OPENCODE_INFERENCE_BASE_URL}/models`;
|
|
342628
342628
|
var OPENCODE_COMPATIBILITY_CLIENT_VERSION = "2.0.27";
|
|
342629
|
+
var observedModelCompatibility = Object.freeze({
|
|
342630
|
+
// Exact public Responses rejection observed 2026-10-12. Do not generalize
|
|
342631
|
+
// this limitation to an untested model, alias, version, or chat transport.
|
|
342632
|
+
"muse-spark-1.3-contributor-free": Object.freeze({ responsesToolChoice: "auto_only" })
|
|
342633
|
+
});
|
|
342634
|
+
function openCodeModelCompatibility(model) {
|
|
342635
|
+
return typeof model === "string" && Object.hasOwn(observedModelCompatibility, model) ? observedModelCompatibility[model] : void 0;
|
|
342636
|
+
}
|
|
342629
342637
|
function createOpenCodeCompatibilityHeaders(omniusVersion) {
|
|
342630
342638
|
if (omniusVersion !== "unknown" && !/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(omniusVersion))
|
|
342631
342639
|
throw new Error("Invalid Omnius version");
|
|
@@ -342756,6 +342764,7 @@ function parseOpenCodeFreeModelCatalog(json5) {
|
|
|
342756
342764
|
anonymousSentinel: "public",
|
|
342757
342765
|
admission: "catalog_only",
|
|
342758
342766
|
nativeTools: model.tool_call === true,
|
|
342767
|
+
...protocol === "openai-responses" ? openCodeModelCompatibility(id5) : {},
|
|
342759
342768
|
...typeof model.structured_output === "boolean" ? { structuredOutput: model.structured_output } : {},
|
|
342760
342769
|
contextWindow: model.limit.context,
|
|
342761
342770
|
maxOutputTokens: model.limit.output,
|
|
@@ -342803,6 +342812,7 @@ function normalizeOpenCodeFreeModelCatalog(json5, availabilityJson) {
|
|
|
342803
342812
|
name: model.name,
|
|
342804
342813
|
model_type: "chat",
|
|
342805
342814
|
...model.protocol === "openai-responses" ? { openCodeApiShape: "responses" } : {},
|
|
342815
|
+
...model.responsesToolChoice ? { openCodeResponsesToolChoice: model.responsesToolChoice } : {},
|
|
342806
342816
|
modalities: { input: ["text"], output: ["text"] },
|
|
342807
342817
|
context_length: model.contextWindow,
|
|
342808
342818
|
...model.maxInputTokens !== void 0 ? { max_input_tokens: model.maxInputTokens } : {},
|
|
@@ -343021,6 +343031,8 @@ var status = (value) => {
|
|
|
343021
343031
|
function unsupportedGrammarKeywords(message) {
|
|
343022
343032
|
if (typeof message !== "string" || message.length > 16384)
|
|
343023
343033
|
return [];
|
|
343034
|
+
if (message === "JSON schema keyword `uniqueItems` is not supported for structured outputs")
|
|
343035
|
+
return ["uniqueItems"];
|
|
343024
343036
|
const match2 = /Grammar error:\s*Unimplemented keys:\s*(\[[^\]\r\n]{0,2048}\])/.exec(message);
|
|
343025
343037
|
if (!match2)
|
|
343026
343038
|
return [];
|
|
@@ -343076,6 +343088,18 @@ function normalizeInferenceProviderError(value, headers) {
|
|
|
343076
343088
|
return new InferenceProviderError(400, "unsupported_schema", void 0, unsupportedKeywords);
|
|
343077
343089
|
return new InferenceProviderError(knownStatus ?? inferredStatus, reason, reason === "rate" ? retryAfterMs : void 0);
|
|
343078
343090
|
}
|
|
343091
|
+
function normalizeInferenceHttpSchemaError(httpStatus, responseBody, headers) {
|
|
343092
|
+
if (httpStatus !== 400 || Buffer.byteLength(responseBody) > 65536)
|
|
343093
|
+
return void 0;
|
|
343094
|
+
let value;
|
|
343095
|
+
try {
|
|
343096
|
+
value = JSON.parse(responseBody);
|
|
343097
|
+
} catch {
|
|
343098
|
+
return void 0;
|
|
343099
|
+
}
|
|
343100
|
+
const normalized4 = normalizeInferenceProviderError(value, headers);
|
|
343101
|
+
return normalized4?.reason === "unsupported_schema" && normalized4.unsupportedKeywords.length ? normalized4 : void 0;
|
|
343102
|
+
}
|
|
343079
343103
|
|
|
343080
343104
|
// packages/orchestrator/dist/openai-chat-stream-parser.js
|
|
343081
343105
|
var object5 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -343631,8 +343655,161 @@ async function collectOpenCodeCompatibilityPackets(stream) {
|
|
|
343631
343655
|
};
|
|
343632
343656
|
}
|
|
343633
343657
|
|
|
343634
|
-
// packages/orchestrator/dist/
|
|
343658
|
+
// packages/orchestrator/dist/expected-inference-response.js
|
|
343659
|
+
var InputValidationFailure;
|
|
343660
|
+
(function(InputValidationFailure2) {
|
|
343661
|
+
InputValidationFailure2["JsonSyntax"] = "json_syntax";
|
|
343662
|
+
InputValidationFailure2["SchemaMismatch"] = "schema_mismatch";
|
|
343663
|
+
InputValidationFailure2["UnsupportedSchema"] = "unsupported_schema";
|
|
343664
|
+
InputValidationFailure2["ToolChoice"] = "tool_choice";
|
|
343665
|
+
InputValidationFailure2["UnknownTool"] = "unknown_tool";
|
|
343666
|
+
InputValidationFailure2["ToolArguments"] = "tool_arguments";
|
|
343667
|
+
InputValidationFailure2["Truncated"] = "truncated";
|
|
343668
|
+
})(InputValidationFailure || (InputValidationFailure = {}));
|
|
343635
343669
|
var object7 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
343670
|
+
var reasons2 = new Set(Object.values(InputValidationFailure));
|
|
343671
|
+
var kinds2 = /* @__PURE__ */ new Set(["text", "native_tools", "json_object", "json_schema"]);
|
|
343672
|
+
var ExpectedInferenceResponseError = class extends Error {
|
|
343673
|
+
reason;
|
|
343674
|
+
expectedKind;
|
|
343675
|
+
constructor(reason, expectedKind) {
|
|
343676
|
+
const safeReason = reasons2.has(reason) ? reason : InputValidationFailure.UnsupportedSchema;
|
|
343677
|
+
const safeKind = kinds2.has(expectedKind) ? expectedKind : "text";
|
|
343678
|
+
super(`Inference response failed the expected ${safeKind} contract (${safeReason}).`);
|
|
343679
|
+
this.name = "ExpectedInferenceResponseError";
|
|
343680
|
+
this.reason = safeReason;
|
|
343681
|
+
this.expectedKind = safeKind;
|
|
343682
|
+
}
|
|
343683
|
+
};
|
|
343684
|
+
function expectedInferenceResponseKind(contract) {
|
|
343685
|
+
const format = contract.responseFormat ?? contract.response_format;
|
|
343686
|
+
if (format?.type === "json_schema")
|
|
343687
|
+
return "json_schema";
|
|
343688
|
+
if (format?.type === "json_object")
|
|
343689
|
+
return "json_object";
|
|
343690
|
+
return contract.tools?.length || contract.toolChoice === "required" || object7(contract.toolChoice) ? "native_tools" : "text";
|
|
343691
|
+
}
|
|
343692
|
+
function fail2(reason, contract) {
|
|
343693
|
+
throw new ExpectedInferenceResponseError(reason, expectedInferenceResponseKind(contract));
|
|
343694
|
+
}
|
|
343695
|
+
function schemaMatches(value, schema, contract, tool = false) {
|
|
343696
|
+
try {
|
|
343697
|
+
const unsupported = unsupportedStructuredResponseSchemaKeywords(schema);
|
|
343698
|
+
if (tool && unsupported.length)
|
|
343699
|
+
return;
|
|
343700
|
+
if (unsupported.length || schema === void 0 || schema === null || !object7(schema) && typeof schema !== "boolean")
|
|
343701
|
+
fail2(InputValidationFailure.UnsupportedSchema, contract);
|
|
343702
|
+
if (!matchesStructuredResponseSchema(value, schema))
|
|
343703
|
+
fail2(tool ? InputValidationFailure.ToolArguments : InputValidationFailure.SchemaMismatch, contract);
|
|
343704
|
+
} catch (error) {
|
|
343705
|
+
if (error instanceof ExpectedInferenceResponseError)
|
|
343706
|
+
throw error;
|
|
343707
|
+
fail2(InputValidationFailure.UnsupportedSchema, contract);
|
|
343708
|
+
}
|
|
343709
|
+
}
|
|
343710
|
+
function parseExpectedInferenceJson(content, contract) {
|
|
343711
|
+
const expectedKind = expectedInferenceResponseKind(contract);
|
|
343712
|
+
if (expectedKind !== "json_object" && expectedKind !== "json_schema")
|
|
343713
|
+
fail2(InputValidationFailure.UnsupportedSchema, contract);
|
|
343714
|
+
if (typeof content !== "string")
|
|
343715
|
+
fail2(InputValidationFailure.JsonSyntax, contract);
|
|
343716
|
+
let text12 = content.trim();
|
|
343717
|
+
if (text12.startsWith("```")) {
|
|
343718
|
+
const fence2 = /^```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]*$/i.exec(text12);
|
|
343719
|
+
if (!fence2 || /(?:^|\r?\n)[ \t]*```/.test(fence2[1]))
|
|
343720
|
+
fail2(InputValidationFailure.JsonSyntax, contract);
|
|
343721
|
+
text12 = fence2[1].trim();
|
|
343722
|
+
}
|
|
343723
|
+
let value;
|
|
343724
|
+
try {
|
|
343725
|
+
value = JSON.parse(text12);
|
|
343726
|
+
} catch {
|
|
343727
|
+
fail2(InputValidationFailure.JsonSyntax, contract);
|
|
343728
|
+
}
|
|
343729
|
+
const format = contract.responseFormat ?? contract.response_format;
|
|
343730
|
+
if (expectedKind === "json_object") {
|
|
343731
|
+
if (!object7(value))
|
|
343732
|
+
fail2(InputValidationFailure.SchemaMismatch, contract);
|
|
343733
|
+
} else
|
|
343734
|
+
schemaMatches(value, object7(format?.json_schema) ? format.json_schema.schema : void 0, contract);
|
|
343735
|
+
if (contract.completeStructuredResponse) {
|
|
343736
|
+
let accepted = false;
|
|
343737
|
+
try {
|
|
343738
|
+
accepted = contract.completeStructuredResponse(value) === true;
|
|
343739
|
+
} catch {
|
|
343740
|
+
}
|
|
343741
|
+
if (!accepted)
|
|
343742
|
+
fail2(InputValidationFailure.SchemaMismatch, contract);
|
|
343743
|
+
}
|
|
343744
|
+
return { expectedKind, structuredValue: value, normalizedContent: text12 };
|
|
343745
|
+
}
|
|
343746
|
+
function validateExpectedInferenceResponse(message, contract, options = {}) {
|
|
343747
|
+
if (options.outputTruncated)
|
|
343748
|
+
fail2(InputValidationFailure.Truncated, contract);
|
|
343749
|
+
const expectedKind = expectedInferenceResponseKind(contract), choice = contract.toolChoice;
|
|
343750
|
+
const calls = message?.toolCalls ?? [];
|
|
343751
|
+
if (!Array.isArray(calls))
|
|
343752
|
+
fail2(InputValidationFailure.ToolArguments, contract);
|
|
343753
|
+
if (choice === "none" && calls.length || (choice === "required" || object7(choice)) && !calls.length)
|
|
343754
|
+
fail2(InputValidationFailure.ToolChoice, contract);
|
|
343755
|
+
for (const call2 of calls) {
|
|
343756
|
+
const tool = contract.tools?.find((tool2) => tool2.function.name === call2?.name);
|
|
343757
|
+
if (!tool)
|
|
343758
|
+
fail2(InputValidationFailure.UnknownTool, contract);
|
|
343759
|
+
if (object7(choice) && (!object7(choice.function) || call2.name !== choice.function.name))
|
|
343760
|
+
fail2(InputValidationFailure.ToolChoice, contract);
|
|
343761
|
+
if (typeof call2.id !== "string" || !call2.id.trim())
|
|
343762
|
+
fail2(InputValidationFailure.ToolArguments, contract);
|
|
343763
|
+
let args;
|
|
343764
|
+
try {
|
|
343765
|
+
args = typeof call2.arguments === "string" ? JSON.parse(call2.arguments) : call2.arguments;
|
|
343766
|
+
} catch {
|
|
343767
|
+
fail2(InputValidationFailure.ToolArguments, contract);
|
|
343768
|
+
}
|
|
343769
|
+
if (!object7(args))
|
|
343770
|
+
fail2(InputValidationFailure.ToolArguments, contract);
|
|
343771
|
+
schemaMatches(args, tool.function.parameters, contract, true);
|
|
343772
|
+
}
|
|
343773
|
+
if (calls.length)
|
|
343774
|
+
return { expectedKind };
|
|
343775
|
+
if (expectedKind === "json_object" || expectedKind === "json_schema")
|
|
343776
|
+
return parseExpectedInferenceJson(message?.content, contract);
|
|
343777
|
+
const format = contract.responseFormat ?? contract.response_format;
|
|
343778
|
+
if (format && format.type !== "text")
|
|
343779
|
+
fail2(InputValidationFailure.UnsupportedSchema, contract);
|
|
343780
|
+
if (message?.content !== void 0 && message.content !== null && typeof message.content !== "string")
|
|
343781
|
+
fail2(InputValidationFailure.SchemaMismatch, contract);
|
|
343782
|
+
return { expectedKind };
|
|
343783
|
+
}
|
|
343784
|
+
function formatExpectedInferenceInstructions(contract) {
|
|
343785
|
+
const kind = expectedInferenceResponseKind(contract), choice = contract.toolChoice;
|
|
343786
|
+
let native = "";
|
|
343787
|
+
if (choice === "none")
|
|
343788
|
+
native = "Do not call tools. ";
|
|
343789
|
+
else if (contract.tools?.length || choice === "required" || object7(choice)) {
|
|
343790
|
+
native = object7(choice) && object7(choice.function) ? `Call the offered native function ${JSON.stringify(choice.function.name)}. ` : choice === "required" ? "Call an offered native function. " : "Use offered native functions when needed. ";
|
|
343791
|
+
native += "Native calls require the provider's actual function-call fields and complete JSON-object arguments; prose, XML or a JSON imitation is not a tool call. ";
|
|
343792
|
+
}
|
|
343793
|
+
if (kind === "json_schema") {
|
|
343794
|
+
const format = contract.responseFormat ?? contract.response_format;
|
|
343795
|
+
const schema = object7(format?.json_schema) ? format.json_schema.schema : void 0;
|
|
343796
|
+
let serialized;
|
|
343797
|
+
try {
|
|
343798
|
+
serialized = JSON.stringify(schema);
|
|
343799
|
+
} catch {
|
|
343800
|
+
}
|
|
343801
|
+
if (!serialized)
|
|
343802
|
+
fail2(InputValidationFailure.UnsupportedSchema, contract);
|
|
343803
|
+
return `${native}For the final visible answer, return exactly one complete JSON value matching this unchanged JSON schema, without prose or Markdown fences:
|
|
343804
|
+
${serialized}`;
|
|
343805
|
+
}
|
|
343806
|
+
if (kind === "json_object")
|
|
343807
|
+
return `${native}For the final visible answer, return exactly one complete JSON object without prose or Markdown fences.`;
|
|
343808
|
+
return native || "Return a visible text response.";
|
|
343809
|
+
}
|
|
343810
|
+
|
|
343811
|
+
// packages/orchestrator/dist/opencode-responses-compatibility.js
|
|
343812
|
+
var object8 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
343636
343813
|
var MAX_RESPONSE_BYTES4 = 8 * 1048576;
|
|
343637
343814
|
function inputContent(value, assistant = false) {
|
|
343638
343815
|
if (typeof value === "string")
|
|
@@ -343642,11 +343819,11 @@ function inputContent(value, assistant = false) {
|
|
|
343642
343819
|
if (!Array.isArray(value))
|
|
343643
343820
|
throw new OpenAIChatResponseError();
|
|
343644
343821
|
return value.map((part) => {
|
|
343645
|
-
if (!
|
|
343822
|
+
if (!object8(part))
|
|
343646
343823
|
throw new OpenAIChatResponseError();
|
|
343647
343824
|
if (part.type === "text" && typeof part.text === "string")
|
|
343648
343825
|
return { type: assistant ? "output_text" : "input_text", text: part.text };
|
|
343649
|
-
if (!assistant && part.type === "image_url" &&
|
|
343826
|
+
if (!assistant && part.type === "image_url" && object8(part.image_url) && typeof part.image_url.url === "string")
|
|
343650
343827
|
return { type: "input_image", image_url: part.image_url.url, ...part.image_url.detail ? { detail: part.image_url.detail } : {} };
|
|
343651
343828
|
throw new OpenAIChatResponseError();
|
|
343652
343829
|
});
|
|
@@ -343655,7 +343832,7 @@ function prepareOpenCodeResponsesRequest(chatBody) {
|
|
|
343655
343832
|
const chat = prepareOpenCodeCompatibilityRequest(chatBody);
|
|
343656
343833
|
const instructions = [], input = [];
|
|
343657
343834
|
for (const value of chat.messages) {
|
|
343658
|
-
if (!
|
|
343835
|
+
if (!object8(value))
|
|
343659
343836
|
throw new OpenAIChatResponseError();
|
|
343660
343837
|
if (value.role === "system") {
|
|
343661
343838
|
if (typeof value.content !== "string")
|
|
@@ -343682,7 +343859,7 @@ function prepareOpenCodeResponsesRequest(chatBody) {
|
|
|
343682
343859
|
if (value.role !== "assistant" || !Array.isArray(value.tool_calls))
|
|
343683
343860
|
throw new OpenAIChatResponseError();
|
|
343684
343861
|
for (const call2 of value.tool_calls) {
|
|
343685
|
-
if (!
|
|
343862
|
+
if (!object8(call2) || !object8(call2.function) || typeof call2.id !== "string" || !call2.id.trim() || typeof call2.function.name !== "string" || typeof call2.function.arguments !== "string")
|
|
343686
343863
|
throw new OpenAIChatResponseError();
|
|
343687
343864
|
input.push({ type: "function_call", call_id: call2.id, name: call2.function.name, arguments: call2.function.arguments });
|
|
343688
343865
|
}
|
|
@@ -343696,12 +343873,24 @@ function prepareOpenCodeResponsesRequest(chatBody) {
|
|
|
343696
343873
|
strict: false
|
|
343697
343874
|
}));
|
|
343698
343875
|
const choice = chat.tool_choice;
|
|
343876
|
+
const autoOnly = openCodeModelCompatibility(chat.model)?.responsesToolChoice === "auto_only";
|
|
343877
|
+
if (autoOnly) {
|
|
343878
|
+
const hostToolCount = Array.isArray(chatBody.tools) ? chatBody.tools.length : 0;
|
|
343879
|
+
const hostNames = chat.tools.slice(0, hostToolCount).map((tool) => tool.function.name);
|
|
343880
|
+
instructions.push([
|
|
343881
|
+
"This model's Responses wire supports only tool_choice=auto. This compatibility setting does not change the original host contract.",
|
|
343882
|
+
`Original host tool choice: ${JSON.stringify(chatBody.tool_choice ?? (hostToolCount ? "auto" : "none"))}.`,
|
|
343883
|
+
`The only host-authorized function names on this wire are: ${JSON.stringify(hostNames)}.`,
|
|
343884
|
+
!hostToolCount || choice === "none" ? "Do not call any function. Return only the requested visible answer in its original format." : object8(choice) && object8(choice.function) ? `Call the exact offered native function ${JSON.stringify(choice.function.name)}. A prose answer cannot satisfy this required function-call contract.` : choice === "required" ? "Call at least one of the offered host-authorized native functions. A prose answer cannot satisfy this required function-call contract." : "Use only the host-authorized functions when needed.",
|
|
343885
|
+
"Additional read/shell protocol definitions are compatibility metadata and grant no permission to call an unoffered host function."
|
|
343886
|
+
].join("\n"));
|
|
343887
|
+
}
|
|
343699
343888
|
const format = chat.response_format;
|
|
343700
343889
|
let text12;
|
|
343701
343890
|
if (format !== void 0) {
|
|
343702
|
-
if (!
|
|
343891
|
+
if (!object8(format))
|
|
343703
343892
|
throw new OpenAIChatResponseError();
|
|
343704
|
-
if (format.type === "json_schema" &&
|
|
343893
|
+
if (format.type === "json_schema" && object8(format.json_schema))
|
|
343705
343894
|
text12 = { format: { ...format.json_schema, type: "json_schema" } };
|
|
343706
343895
|
else if (format.type === "json_object" || format.type === "text")
|
|
343707
343896
|
text12 = { format: { ...format } };
|
|
@@ -343715,7 +343904,7 @@ function prepareOpenCodeResponsesRequest(chatBody) {
|
|
|
343715
343904
|
tools,
|
|
343716
343905
|
stream: true,
|
|
343717
343906
|
store: false,
|
|
343718
|
-
tool_choice:
|
|
343907
|
+
tool_choice: autoOnly ? "auto" : object8(choice) && object8(choice.function) ? { type: "function", name: choice.function.name } : choice,
|
|
343719
343908
|
...chat.max_tokens !== void 0 ? { max_output_tokens: chat.max_tokens } : {},
|
|
343720
343909
|
...chat.temperature !== void 0 ? { temperature: chat.temperature } : {},
|
|
343721
343910
|
...text12 ? { text: text12 } : {}
|
|
@@ -343726,6 +343915,39 @@ var packet2 = (delta, finish, usage) => ({
|
|
|
343726
343915
|
...usage !== void 0 ? { usage } : {}
|
|
343727
343916
|
});
|
|
343728
343917
|
async function* parseOpenCodeResponsesStream(response, request, options) {
|
|
343918
|
+
const forced = request.toolChoice === "required" || object8(request.toolChoice);
|
|
343919
|
+
const pending = [];
|
|
343920
|
+
const fence2 = () => {
|
|
343921
|
+
options?.signal?.throwIfAborted();
|
|
343922
|
+
options?.assertCurrent?.();
|
|
343923
|
+
};
|
|
343924
|
+
let bytes3 = 0;
|
|
343925
|
+
for await (const value of parseOpenCodeResponsesPackets(response, request, options)) {
|
|
343926
|
+
fence2();
|
|
343927
|
+
if (!forced) {
|
|
343928
|
+
yield value;
|
|
343929
|
+
continue;
|
|
343930
|
+
}
|
|
343931
|
+
bytes3 += Buffer.byteLength(JSON.stringify(value));
|
|
343932
|
+
if (bytes3 > MAX_RESPONSE_BYTES4)
|
|
343933
|
+
throw new OpenAIChatResponseError();
|
|
343934
|
+
pending.push(value);
|
|
343935
|
+
const choice = value.choices[0];
|
|
343936
|
+
if (!choice?.finish_reason)
|
|
343937
|
+
continue;
|
|
343938
|
+
if (choice.finish_reason === "length")
|
|
343939
|
+
continue;
|
|
343940
|
+
const calls = object8(choice.delta) && choice.delta.tool_calls;
|
|
343941
|
+
if (!Array.isArray(calls) || !calls.length)
|
|
343942
|
+
throw new ExpectedInferenceResponseError(InputValidationFailure.ToolChoice, "native_tools");
|
|
343943
|
+
for (const packet3 of pending) {
|
|
343944
|
+
fence2();
|
|
343945
|
+
yield packet3;
|
|
343946
|
+
}
|
|
343947
|
+
pending.length = 0;
|
|
343948
|
+
}
|
|
343949
|
+
}
|
|
343950
|
+
async function* parseOpenCodeResponsesPackets(response, request, options) {
|
|
343729
343951
|
const texts = /* @__PURE__ */ new Map(), items = /* @__PURE__ */ new Map();
|
|
343730
343952
|
let bytes3 = 0, finished = false;
|
|
343731
343953
|
const index = (value) => {
|
|
@@ -343745,7 +343967,7 @@ async function* parseOpenCodeResponsesStream(response, request, options) {
|
|
|
343745
343967
|
return text12.slice(previous.length);
|
|
343746
343968
|
};
|
|
343747
343969
|
const readItem = (item) => {
|
|
343748
|
-
if (!
|
|
343970
|
+
if (!object8(item) || !["message", "function_call", "reasoning"].includes(String(item.type)))
|
|
343749
343971
|
throw new OpenAIChatResponseError();
|
|
343750
343972
|
return item;
|
|
343751
343973
|
};
|
|
@@ -343755,7 +343977,7 @@ async function* parseOpenCodeResponsesStream(response, request, options) {
|
|
|
343755
343977
|
if (item.role !== "assistant" || !Array.isArray(item.content))
|
|
343756
343978
|
throw new OpenAIChatResponseError();
|
|
343757
343979
|
for (const [content, part] of item.content.entries()) {
|
|
343758
|
-
if (!
|
|
343980
|
+
if (!object8(part))
|
|
343759
343981
|
throw new OpenAIChatResponseError();
|
|
343760
343982
|
const text12 = part.type === "output_text" ? part.text : part.type === "refusal" ? part.refusal : void 0;
|
|
343761
343983
|
const tail = completeText(text12, output, content);
|
|
@@ -343810,7 +344032,7 @@ async function* parseOpenCodeResponsesStream(response, request, options) {
|
|
|
343810
344032
|
if (!terminal && !event.completeResponse)
|
|
343811
344033
|
continue;
|
|
343812
344034
|
const result = terminal ? value.response : value;
|
|
343813
|
-
if (!
|
|
344035
|
+
if (!object8(result) || result.error || !terminal && result.status !== "completed" && result.status !== "incomplete")
|
|
343814
344036
|
throw new OpenAIChatResponseError();
|
|
343815
344037
|
if (value.type === "response.completed" && result.status !== "completed" || value.type === "response.incomplete" && result.status !== "incomplete")
|
|
343816
344038
|
throw new OpenAIChatResponseError();
|
|
@@ -343834,7 +344056,7 @@ async function* parseOpenCodeResponsesStream(response, request, options) {
|
|
|
343834
344056
|
...restoreOpenCodeCompatibilityToolCall({ id: item.call_id, function: { name: item.name, arguments: item.arguments } }, request)
|
|
343835
344057
|
});
|
|
343836
344058
|
}
|
|
343837
|
-
const usage =
|
|
344059
|
+
const usage = object8(result.usage) ? {
|
|
343838
344060
|
prompt_tokens: result.usage.input_tokens,
|
|
343839
344061
|
completion_tokens: result.usage.output_tokens,
|
|
343840
344062
|
total_tokens: result.usage.total_tokens,
|
|
@@ -343855,7 +344077,7 @@ function collectOpenCodeResponsesResponse(response, request, options) {
|
|
|
343855
344077
|
|
|
343856
344078
|
// packages/orchestrator/dist/provider-schema-adapter.js
|
|
343857
344079
|
var SUPPORTED_PROVIDER_SCHEMA_ADAPTATIONS = Object.freeze(["uniqueItems"]);
|
|
343858
|
-
var
|
|
344080
|
+
var object9 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
343859
344081
|
function lowerProviderSchema(schema, unsupportedKeywords) {
|
|
343860
344082
|
const lowered = structuredClone(schema);
|
|
343861
344083
|
const adaptations = new Set(unsupportedKeywords.filter((keyword) => SUPPORTED_PROVIDER_SCHEMA_ADAPTATIONS.includes(keyword)));
|
|
@@ -343863,13 +344085,13 @@ function lowerProviderSchema(schema, unsupportedKeywords) {
|
|
|
343863
344085
|
return lowered;
|
|
343864
344086
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
343865
344087
|
const visitSchema = (value) => {
|
|
343866
|
-
if (!
|
|
344088
|
+
if (!object9(value) || seen.has(value))
|
|
343867
344089
|
return;
|
|
343868
344090
|
seen.add(value);
|
|
343869
344091
|
for (const keyword of adaptations)
|
|
343870
344092
|
delete value[keyword];
|
|
343871
344093
|
for (const keyword of ["properties", "patternProperties", "$defs", "definitions", "dependentSchemas", "dependencies"]) {
|
|
343872
|
-
if (
|
|
344094
|
+
if (object9(value[keyword]))
|
|
343873
344095
|
for (const child of Object.values(value[keyword]))
|
|
343874
344096
|
visitSchema(child);
|
|
343875
344097
|
}
|
|
@@ -343905,9 +344127,9 @@ function lowerProviderResponseFormat(format, unsupportedKeywords) {
|
|
|
343905
344127
|
const lowered = structuredClone(format);
|
|
343906
344128
|
if (lowered.type !== "json_schema")
|
|
343907
344129
|
return lowered;
|
|
343908
|
-
if (
|
|
344130
|
+
if (object9(lowered.json_schema) && object9(lowered.json_schema.schema))
|
|
343909
344131
|
lowered.json_schema.schema = lowerProviderSchema(lowered.json_schema.schema, unsupportedKeywords);
|
|
343910
|
-
else if (lowered.json_schema === void 0 &&
|
|
344132
|
+
else if (lowered.json_schema === void 0 && object9(lowered.schema))
|
|
343911
344133
|
lowered.schema = lowerProviderSchema(lowered.schema, unsupportedKeywords);
|
|
343912
344134
|
return lowered;
|
|
343913
344135
|
}
|
|
@@ -343945,7 +344167,7 @@ var POLICY_FIELDS = /* @__PURE__ */ new Set([
|
|
|
343945
344167
|
"totalTimeoutMs",
|
|
343946
344168
|
"localTimeoutMs"
|
|
343947
344169
|
]);
|
|
343948
|
-
function
|
|
344170
|
+
function object10(value) {
|
|
343949
344171
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
343950
344172
|
}
|
|
343951
344173
|
function configPath(env) {
|
|
@@ -343961,7 +344183,7 @@ function readConfiguration(path7) {
|
|
|
343961
344183
|
throw error;
|
|
343962
344184
|
}
|
|
343963
344185
|
const parsed = JSON.parse(readFileSync22(path7, "utf8"));
|
|
343964
|
-
if (!
|
|
344186
|
+
if (!object10(parsed))
|
|
343965
344187
|
throw new Error("Invalid configuration.");
|
|
343966
344188
|
return parsed;
|
|
343967
344189
|
}
|
|
@@ -343982,7 +344204,7 @@ function canonicalRemoteTransport(providerId) {
|
|
|
343982
344204
|
}
|
|
343983
344205
|
}
|
|
343984
344206
|
function profile(value) {
|
|
343985
|
-
if (!
|
|
344207
|
+
if (!object10(value) || Object.keys(value).length !== 3 || !Object.keys(value).every((key) => ["providerId", "model", "apiKeyEnv"].includes(key)) || typeof value.providerId !== "string" || typeof value.model !== "string" || typeof value.apiKeyEnv !== "string")
|
|
343986
344208
|
return false;
|
|
343987
344209
|
return MODEL.test(value.model) && ENV_NAME.test(value.apiKeyEnv) && !GENERIC_KEYS.has(value.apiKeyEnv.toUpperCase()) && canonicalRemoteTransport(value.providerId) !== null;
|
|
343988
344210
|
}
|
|
@@ -344006,10 +344228,10 @@ function loadRemoteInferencePolicy(options = {}) {
|
|
|
344006
344228
|
try {
|
|
344007
344229
|
const configuration = readConfiguration(options.configPath ?? configPath(env));
|
|
344008
344230
|
const selected = configuration["inferenceFallback"];
|
|
344009
|
-
if (selected !== void 0 && (!
|
|
344231
|
+
if (selected !== void 0 && (!object10(selected) || Object.keys(selected).some((key) => !POLICY_FIELDS.has(key))))
|
|
344010
344232
|
return disabled();
|
|
344011
344233
|
const result = { ...DEFAULTS, providers: [] };
|
|
344012
|
-
if (
|
|
344234
|
+
if (object10(selected)) {
|
|
344013
344235
|
if (selected["mode"] !== void 0) {
|
|
344014
344236
|
if (selected["mode"] !== "auto" && selected["mode"] !== "manual")
|
|
344015
344237
|
return disabled();
|
|
@@ -344104,9 +344326,9 @@ function createFallbackScrubber(primaryKey, options = {}) {
|
|
|
344104
344326
|
if (typeof configuration["apiKeyEnv"] === "string" && ENV_NAME.test(configuration["apiKeyEnv"]))
|
|
344105
344327
|
add(env[configuration["apiKeyEnv"]]);
|
|
344106
344328
|
const policy = configuration["inferenceFallback"];
|
|
344107
|
-
if (
|
|
344329
|
+
if (object10(policy) && Array.isArray(policy["providers"])) {
|
|
344108
344330
|
for (const item of policy["providers"])
|
|
344109
|
-
if (
|
|
344331
|
+
if (object10(item) && typeof item["apiKeyEnv"] === "string" && ENV_NAME.test(item["apiKeyEnv"]))
|
|
344110
344332
|
add(env[item["apiKeyEnv"]]);
|
|
344111
344333
|
}
|
|
344112
344334
|
} catch {
|
|
@@ -344115,7 +344337,7 @@ function createFallbackScrubber(primaryKey, options = {}) {
|
|
|
344115
344337
|
const configured = JSON.parse(env["OMNIUS_INFERENCE_FALLBACK_PROVIDERS"] ?? "[]");
|
|
344116
344338
|
if (Array.isArray(configured)) {
|
|
344117
344339
|
for (const item of configured)
|
|
344118
|
-
if (
|
|
344340
|
+
if (object10(item) && typeof item["apiKeyEnv"] === "string" && ENV_NAME.test(item["apiKeyEnv"]))
|
|
344119
344341
|
add(env[item["apiKeyEnv"]]);
|
|
344120
344342
|
}
|
|
344121
344343
|
} catch {
|
|
@@ -350022,159 +350244,6 @@ var StructuredMemoryExtractionQueue = class {
|
|
|
350022
350244
|
init_dist5();
|
|
350023
350245
|
import { createHash as createHash54 } from "node:crypto";
|
|
350024
350246
|
|
|
350025
|
-
// packages/orchestrator/dist/expected-inference-response.js
|
|
350026
|
-
var InputValidationFailure;
|
|
350027
|
-
(function(InputValidationFailure2) {
|
|
350028
|
-
InputValidationFailure2["JsonSyntax"] = "json_syntax";
|
|
350029
|
-
InputValidationFailure2["SchemaMismatch"] = "schema_mismatch";
|
|
350030
|
-
InputValidationFailure2["UnsupportedSchema"] = "unsupported_schema";
|
|
350031
|
-
InputValidationFailure2["ToolChoice"] = "tool_choice";
|
|
350032
|
-
InputValidationFailure2["UnknownTool"] = "unknown_tool";
|
|
350033
|
-
InputValidationFailure2["ToolArguments"] = "tool_arguments";
|
|
350034
|
-
InputValidationFailure2["Truncated"] = "truncated";
|
|
350035
|
-
})(InputValidationFailure || (InputValidationFailure = {}));
|
|
350036
|
-
var object10 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
350037
|
-
var reasons2 = new Set(Object.values(InputValidationFailure));
|
|
350038
|
-
var kinds2 = /* @__PURE__ */ new Set(["text", "native_tools", "json_object", "json_schema"]);
|
|
350039
|
-
var ExpectedInferenceResponseError = class extends Error {
|
|
350040
|
-
reason;
|
|
350041
|
-
expectedKind;
|
|
350042
|
-
constructor(reason, expectedKind) {
|
|
350043
|
-
const safeReason = reasons2.has(reason) ? reason : InputValidationFailure.UnsupportedSchema;
|
|
350044
|
-
const safeKind = kinds2.has(expectedKind) ? expectedKind : "text";
|
|
350045
|
-
super(`Inference response failed the expected ${safeKind} contract (${safeReason}).`);
|
|
350046
|
-
this.name = "ExpectedInferenceResponseError";
|
|
350047
|
-
this.reason = safeReason;
|
|
350048
|
-
this.expectedKind = safeKind;
|
|
350049
|
-
}
|
|
350050
|
-
};
|
|
350051
|
-
function expectedInferenceResponseKind(contract) {
|
|
350052
|
-
const format = contract.responseFormat ?? contract.response_format;
|
|
350053
|
-
if (format?.type === "json_schema")
|
|
350054
|
-
return "json_schema";
|
|
350055
|
-
if (format?.type === "json_object")
|
|
350056
|
-
return "json_object";
|
|
350057
|
-
return contract.tools?.length || contract.toolChoice === "required" || object10(contract.toolChoice) ? "native_tools" : "text";
|
|
350058
|
-
}
|
|
350059
|
-
function fail2(reason, contract) {
|
|
350060
|
-
throw new ExpectedInferenceResponseError(reason, expectedInferenceResponseKind(contract));
|
|
350061
|
-
}
|
|
350062
|
-
function schemaMatches(value, schema, contract, tool = false) {
|
|
350063
|
-
try {
|
|
350064
|
-
const unsupported = unsupportedStructuredResponseSchemaKeywords(schema);
|
|
350065
|
-
if (tool && unsupported.length)
|
|
350066
|
-
return;
|
|
350067
|
-
if (unsupported.length || schema === void 0 || schema === null || !object10(schema) && typeof schema !== "boolean")
|
|
350068
|
-
fail2(InputValidationFailure.UnsupportedSchema, contract);
|
|
350069
|
-
if (!matchesStructuredResponseSchema(value, schema))
|
|
350070
|
-
fail2(tool ? InputValidationFailure.ToolArguments : InputValidationFailure.SchemaMismatch, contract);
|
|
350071
|
-
} catch (error) {
|
|
350072
|
-
if (error instanceof ExpectedInferenceResponseError)
|
|
350073
|
-
throw error;
|
|
350074
|
-
fail2(InputValidationFailure.UnsupportedSchema, contract);
|
|
350075
|
-
}
|
|
350076
|
-
}
|
|
350077
|
-
function parseExpectedInferenceJson(content, contract) {
|
|
350078
|
-
const expectedKind = expectedInferenceResponseKind(contract);
|
|
350079
|
-
if (expectedKind !== "json_object" && expectedKind !== "json_schema")
|
|
350080
|
-
fail2(InputValidationFailure.UnsupportedSchema, contract);
|
|
350081
|
-
if (typeof content !== "string")
|
|
350082
|
-
fail2(InputValidationFailure.JsonSyntax, contract);
|
|
350083
|
-
let text12 = content.trim();
|
|
350084
|
-
if (text12.startsWith("```")) {
|
|
350085
|
-
const fence2 = /^```(?:json)?[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]*$/i.exec(text12);
|
|
350086
|
-
if (!fence2 || /(?:^|\r?\n)[ \t]*```/.test(fence2[1]))
|
|
350087
|
-
fail2(InputValidationFailure.JsonSyntax, contract);
|
|
350088
|
-
text12 = fence2[1].trim();
|
|
350089
|
-
}
|
|
350090
|
-
let value;
|
|
350091
|
-
try {
|
|
350092
|
-
value = JSON.parse(text12);
|
|
350093
|
-
} catch {
|
|
350094
|
-
fail2(InputValidationFailure.JsonSyntax, contract);
|
|
350095
|
-
}
|
|
350096
|
-
const format = contract.responseFormat ?? contract.response_format;
|
|
350097
|
-
if (expectedKind === "json_object") {
|
|
350098
|
-
if (!object10(value))
|
|
350099
|
-
fail2(InputValidationFailure.SchemaMismatch, contract);
|
|
350100
|
-
} else
|
|
350101
|
-
schemaMatches(value, object10(format?.json_schema) ? format.json_schema.schema : void 0, contract);
|
|
350102
|
-
if (contract.completeStructuredResponse) {
|
|
350103
|
-
let accepted = false;
|
|
350104
|
-
try {
|
|
350105
|
-
accepted = contract.completeStructuredResponse(value) === true;
|
|
350106
|
-
} catch {
|
|
350107
|
-
}
|
|
350108
|
-
if (!accepted)
|
|
350109
|
-
fail2(InputValidationFailure.SchemaMismatch, contract);
|
|
350110
|
-
}
|
|
350111
|
-
return { expectedKind, structuredValue: value, normalizedContent: text12 };
|
|
350112
|
-
}
|
|
350113
|
-
function validateExpectedInferenceResponse(message, contract, options = {}) {
|
|
350114
|
-
if (options.outputTruncated)
|
|
350115
|
-
fail2(InputValidationFailure.Truncated, contract);
|
|
350116
|
-
const expectedKind = expectedInferenceResponseKind(contract), choice = contract.toolChoice;
|
|
350117
|
-
const calls = message?.toolCalls ?? [];
|
|
350118
|
-
if (!Array.isArray(calls))
|
|
350119
|
-
fail2(InputValidationFailure.ToolArguments, contract);
|
|
350120
|
-
if (choice === "none" && calls.length || (choice === "required" || object10(choice)) && !calls.length)
|
|
350121
|
-
fail2(InputValidationFailure.ToolChoice, contract);
|
|
350122
|
-
for (const call2 of calls) {
|
|
350123
|
-
const tool = contract.tools?.find((tool2) => tool2.function.name === call2?.name);
|
|
350124
|
-
if (!tool)
|
|
350125
|
-
fail2(InputValidationFailure.UnknownTool, contract);
|
|
350126
|
-
if (object10(choice) && (!object10(choice.function) || call2.name !== choice.function.name))
|
|
350127
|
-
fail2(InputValidationFailure.ToolChoice, contract);
|
|
350128
|
-
if (typeof call2.id !== "string" || !call2.id.trim())
|
|
350129
|
-
fail2(InputValidationFailure.ToolArguments, contract);
|
|
350130
|
-
let args;
|
|
350131
|
-
try {
|
|
350132
|
-
args = typeof call2.arguments === "string" ? JSON.parse(call2.arguments) : call2.arguments;
|
|
350133
|
-
} catch {
|
|
350134
|
-
fail2(InputValidationFailure.ToolArguments, contract);
|
|
350135
|
-
}
|
|
350136
|
-
if (!object10(args))
|
|
350137
|
-
fail2(InputValidationFailure.ToolArguments, contract);
|
|
350138
|
-
schemaMatches(args, tool.function.parameters, contract, true);
|
|
350139
|
-
}
|
|
350140
|
-
if (calls.length)
|
|
350141
|
-
return { expectedKind };
|
|
350142
|
-
if (expectedKind === "json_object" || expectedKind === "json_schema")
|
|
350143
|
-
return parseExpectedInferenceJson(message?.content, contract);
|
|
350144
|
-
const format = contract.responseFormat ?? contract.response_format;
|
|
350145
|
-
if (format && format.type !== "text")
|
|
350146
|
-
fail2(InputValidationFailure.UnsupportedSchema, contract);
|
|
350147
|
-
if (message?.content !== void 0 && message.content !== null && typeof message.content !== "string")
|
|
350148
|
-
fail2(InputValidationFailure.SchemaMismatch, contract);
|
|
350149
|
-
return { expectedKind };
|
|
350150
|
-
}
|
|
350151
|
-
function formatExpectedInferenceInstructions(contract) {
|
|
350152
|
-
const kind = expectedInferenceResponseKind(contract), choice = contract.toolChoice;
|
|
350153
|
-
let native = "";
|
|
350154
|
-
if (choice === "none")
|
|
350155
|
-
native = "Do not call tools. ";
|
|
350156
|
-
else if (contract.tools?.length || choice === "required" || object10(choice)) {
|
|
350157
|
-
native = object10(choice) && object10(choice.function) ? `Call the offered native function ${JSON.stringify(choice.function.name)}. ` : choice === "required" ? "Call an offered native function. " : "Use offered native functions when needed. ";
|
|
350158
|
-
native += "Native calls require the provider's actual function-call fields and complete JSON-object arguments; prose, XML or a JSON imitation is not a tool call. ";
|
|
350159
|
-
}
|
|
350160
|
-
if (kind === "json_schema") {
|
|
350161
|
-
const format = contract.responseFormat ?? contract.response_format;
|
|
350162
|
-
const schema = object10(format?.json_schema) ? format.json_schema.schema : void 0;
|
|
350163
|
-
let serialized;
|
|
350164
|
-
try {
|
|
350165
|
-
serialized = JSON.stringify(schema);
|
|
350166
|
-
} catch {
|
|
350167
|
-
}
|
|
350168
|
-
if (!serialized)
|
|
350169
|
-
fail2(InputValidationFailure.UnsupportedSchema, contract);
|
|
350170
|
-
return `${native}For the final visible answer, return exactly one complete JSON value matching this unchanged JSON schema, without prose or Markdown fences:
|
|
350171
|
-
${serialized}`;
|
|
350172
|
-
}
|
|
350173
|
-
if (kind === "json_object")
|
|
350174
|
-
return `${native}For the final visible answer, return exactly one complete JSON object without prose or Markdown fences.`;
|
|
350175
|
-
return native || "Return a visible text response.";
|
|
350176
|
-
}
|
|
350177
|
-
|
|
350178
350247
|
// packages/orchestrator/dist/inference-fallback-priority.js
|
|
350179
350248
|
var object11 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
350180
350249
|
var textOrder = (a, b) => String(a) < String(b) ? -1 : String(a) > String(b) ? 1 : 0;
|
|
@@ -350493,6 +350562,10 @@ var RemoteInferenceFallback = class _RemoteInferenceFallback {
|
|
|
350493
350562
|
this.localCooldown();
|
|
350494
350563
|
}
|
|
350495
350564
|
await this.approveRemoteFallback(request);
|
|
350565
|
+
return this.completeRemote(request);
|
|
350566
|
+
}
|
|
350567
|
+
/** The same remote phase can be exercised live without fabricating a local reply. */
|
|
350568
|
+
async completeRemote(request) {
|
|
350496
350569
|
const deadline = this.now() + this.policy.totalTimeoutMs;
|
|
350497
350570
|
for await (const candidate of this.retryableCandidates(request, deadline)) {
|
|
350498
350571
|
if (this.now() >= deadline)
|
|
@@ -350570,6 +350643,10 @@ var RemoteInferenceFallback = class _RemoteInferenceFallback {
|
|
|
350570
350643
|
this.localCooldown();
|
|
350571
350644
|
}
|
|
350572
350645
|
await this.approveRemoteFallback(request);
|
|
350646
|
+
yield* this.streamRemote(request);
|
|
350647
|
+
}
|
|
350648
|
+
async *streamRemote(request) {
|
|
350649
|
+
let emitted = false;
|
|
350573
350650
|
const deadline = this.now() + this.policy.totalTimeoutMs;
|
|
350574
350651
|
for await (const candidate of this.retryableCandidates(request, deadline)) {
|
|
350575
350652
|
if (this.now() >= deadline)
|
|
@@ -351031,6 +351108,7 @@ var RemoteInferenceFallback = class _RemoteInferenceFallback {
|
|
|
351031
351108
|
request = this.prepareModelContract(request, route);
|
|
351032
351109
|
if (route.openCodeApiShape === "responses" && route.keyless?.clientIdentity === "opencode" && route.baseUrl === OPENCODE_INFERENCE_BASE_URL) {
|
|
351033
351110
|
const wire2 = prepareOpenCodeResponsesRequest({
|
|
351111
|
+
model: route.model,
|
|
351034
351112
|
messages: request.messages,
|
|
351035
351113
|
tools: request.tools,
|
|
351036
351114
|
tool_choice: request.toolChoice,
|
|
@@ -423813,6 +423891,11 @@ var OllamaAgenticBackend = class _OllamaAgenticBackend {
|
|
|
423813
423891
|
return this.usesOpenCodeResponses(request) ? `${OPENCODE_INFERENCE_BASE_URL}/responses` : this.providerRequestUrl(serviceBaseUrl, "chat");
|
|
423814
423892
|
}
|
|
423815
423893
|
brokerHttpError(transport, response, responseBody, request) {
|
|
423894
|
+
if (transport === "openai-compatible" && this._provider.protocol === "openai-chat" && !this._provider.descriptor.local) {
|
|
423895
|
+
const schemaError = normalizeInferenceHttpSchemaError(response.status, responseBody, response.headers);
|
|
423896
|
+
if (schemaError)
|
|
423897
|
+
return schemaError;
|
|
423898
|
+
}
|
|
423816
423899
|
const error = new InferenceHttpError(transport, response.status, responseBody, response.headers);
|
|
423817
423900
|
const logicalRequestId = request.logicalRequestId;
|
|
423818
423901
|
if (this._provider.protocol !== "ollama" || !logicalRequestId) {
|