@desplega.ai/agent-swarm 1.152.2 → 1.153.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{acp-adapter-pfeje2v5.js → acp-adapter-ahmjxhek.js} +4 -4
- package/dist/{actions-0sttc7f5.js → actions-jzrfpkmn.js} +30 -26
- package/dist/{anthropic-messages-2y8nktar.js → anthropic-messages-9vqsbznt.js} +112 -84
- package/dist/{app-p8teva95.js → app-03na2vwb.js} +9 -6
- package/dist/{assistant-r45jnsrt.js → assistant-hfkxvhgt.js} +31 -27
- package/dist/{azure-openai-responses-f38x2avq.js → azure-openai-responses-04qwdwfq.js} +27 -13
- package/dist/{boot-reembed-je26h5y7.js → boot-reembed-c98xrad3.js} +8 -6
- package/dist/{boot-reembed-1qmybsd4.js → boot-reembed-zt3qm9xn.js} +9 -7
- package/dist/{boot-scrub-logs-gte3h1mm.js → boot-scrub-logs-jcqd8ksj.js} +6 -4
- package/dist/{claude-adapter-csc1mzka.js → claude-adapter-mgryg8g3.js} +17 -15
- package/dist/{claude-managed-adapter-dsmkcrjy.js → claude-managed-adapter-ea2aga6w.js} +3 -3
- package/dist/{claude-sdk-session-fcd6f078.js → claude-sdk-session-jjf4zss1.js} +17 -15
- package/dist/{cli-r2fpe7cx.js → cli-00w2c66p.js} +61 -55
- package/dist/{cli-fm4ytsdk.js → cli-0d9nbqxf.js} +1 -1
- package/dist/cli-0x5qzvkg.js +4279 -0
- package/dist/{cli-d3p82erb.js → cli-18amys3y.js} +9 -9
- package/dist/{cli-wbyk465z.js → cli-1hwnb4hc.js} +1 -1
- package/dist/{cli-xw7vak96.js → cli-3bcmp015.js} +5 -5
- package/dist/cli-3er6gcsn.js +1849 -0
- package/dist/{cli-c4eeb5q2.js → cli-5b6b62tz.js} +1 -1
- package/dist/{cli-4ahpr4sw.js → cli-5mbmvxnn.js} +5 -5
- package/dist/{cli-xy1cchaf.js → cli-5taqtpze.js} +235 -8
- package/dist/{cli-fmy65jdn.js → cli-6ks9xf1n.js} +7 -5
- package/dist/cli-7g9s78jf.js +2827 -0
- package/dist/{cli-jew3jda5.js → cli-7pnz2v6s.js} +2 -2
- package/dist/{cli-r84ctdxn.js → cli-83wkg402.js} +2 -2
- package/dist/{cli-jvy9qgjs.js → cli-a9scg8sv.js} +4 -4
- package/dist/{cli-4yc5d8fk.js → cli-avkd6mqv.js} +50 -0
- package/dist/{cli-ht5rs63n.js → cli-b2g6mzjc.js} +15 -6
- package/dist/{cli-jbmc0r7r.js → cli-bw0dfwkr.js} +1 -1
- package/dist/{cli-8wrympd7.js → cli-bzr0ftht.js} +26 -7
- package/dist/{cli-wpv5rgg2.js → cli-cdq08v3r.js} +2 -2
- package/dist/cli-cgj4hc12.js +18902 -0
- package/dist/cli-d6hk10xx.js +14075 -0
- package/dist/{cli-zvgj5zg8.js → cli-djvxhnc4.js} +31 -3324
- package/dist/{cli-s25avqg9.js → cli-e781c6f9.js} +1 -0
- package/dist/{cli-3bpzj8me.js → cli-eazstkad.js} +2 -2
- package/dist/{cli-s2qjdd6z.js → cli-eetrvv91.js} +1 -1
- package/dist/cli-h38x0qhg.js +6912 -0
- package/dist/{cli-9xvdm3bx.js → cli-h60qfasa.js} +742 -278
- package/dist/{pi-mono-adapter-jcqt71cg.js → cli-ja7mrygn.js} +67343 -101083
- package/dist/{cli-j8dggbcr.js → cli-k0g1sjzm.js} +23 -31
- package/dist/{cli-gphgnvpf.js → cli-m04pt18h.js} +2 -2
- package/dist/{cli-rgvp6r2x.js → cli-mcnhgnn1.js} +193 -4
- package/dist/{cli-j4nv2wqy.js → cli-mzgyhxbe.js} +10 -4
- package/dist/{cli-qn042eh7.js → cli-n0q9b7j4.js} +46 -1870
- package/dist/cli-n7h1kqpf.js +29 -0
- package/dist/{cli-ckz5t2hb.js → cli-nq0kgyxe.js} +5 -5
- package/dist/{cli-z3wkng35.js → cli-qrqhc31j.js} +151 -125
- package/dist/{cli-56h18ng2.js → cli-r8tdds6s.js} +1 -1
- package/dist/{cli-ch38q5z4.js → cli-rj7de4b2.js} +6788 -2541
- package/dist/{cli-qd65dvr6.js → cli-s5s1f2yn.js} +56 -40
- package/dist/{cli-kj76p1ez.js → cli-scwq51gn.js} +13 -7
- package/dist/{cli-2nnd56zt.js → cli-tdh4hjr2.js} +3 -2
- package/dist/{cli-c2mk1kgf.js → cli-v4en75c5.js} +8 -1
- package/dist/{cli-b9dd0h3k.js → cli-vw03hg5t.js} +3 -2
- package/dist/{cli-zvkq5csn.js → cli-ybpp1srm.js} +6 -6
- package/dist/cli-yn0a417a.js +4069 -0
- package/dist/{cli-gpqcs935.js → cli-ysc1kbet.js} +2 -2
- package/dist/{cli-zfzznn7c.js → cli-ytxs7mn1.js} +26 -2
- package/dist/cli-zcsyfw2z.js +3335 -0
- package/dist/{cli-4j8k1m4w.js → cli-zt1227k1.js} +1162 -192
- package/dist/cli-zy5w9gpt.js +230 -0
- package/dist/cli.js +26 -34
- package/dist/{codex-adapter-fxmpsabw.js → codex-adapter-8548daap.js} +12 -11
- package/dist/{codex-session-runner-rr1e47ea.js → codex-session-runner-2dad8p4x.js} +12 -11
- package/dist/{commands-0f5rxz51.js → commands-355dbpa8.js} +6 -4
- package/dist/{db-r3jxf3wy.js → db-4jjvwz1s.js} +6 -4
- package/dist/{dispatcher-06vph6q4.js → dispatcher-ca590nkz.js} +29 -25
- package/dist/dsh-adapter-rgvj6ykp.js +19 -0
- package/dist/{e2b-413b8t4v.js → e2b-93x1k0j5.js} +6 -7
- package/dist/{google-generative-ai-ndjmj5fa.js → google-generative-ai-xtw7tggr.js} +33 -73
- package/dist/{google-vertex-fr665tqs.js → google-vertex-zdqpms6n.js} +38 -68
- package/dist/{handlers-0hgtc910.js → handlers-2y6dqpvf.js} +32 -28
- package/dist/{hook-9kvrv1er.js → hook-0s8knepr.js} +11 -9
- package/dist/{hook-fbfhkat3.js → hook-k0gec254.js} +12 -10
- package/dist/{http-xbyx8k5j.js → http-jp2nb4zw.js} +300 -237
- package/dist/{index-tfsdxyv6.js → index-0wzg3sp3.js} +39 -24
- package/dist/{index-rnyahfn5.js → index-3mq6ce93.js} +29 -25
- package/dist/{index-jsw3aynb.js → index-42s7eezq.js} +29 -25
- package/dist/{cli-pdz9qde4.js → index-9ch1n761.js} +10 -11
- package/dist/{index-gpfn1741.js → index-b56xkbc7.js} +8 -6
- package/dist/{index-66xz5e9j.js → index-h5gs261z.js} +521 -9
- package/dist/{index-2sp0384z.js → index-kkeftv5h.js} +738 -21
- package/dist/{index-sgk50mbg.js → index-s37dbevy.js} +30 -26
- package/dist/index-w097eg0x.js +5 -0
- package/dist/jiti-loader-b4837mtm.js +34 -0
- package/dist/jiti-static-loader-q2g5ds0y.js +31267 -0
- package/dist/{keepalive-s3xpr7sw.js → keepalive-9pfw7t02.js} +8 -6
- package/dist/{lead-rq4n5r16.js → lead-7vcmcdq4.js} +44 -39
- package/dist/{maintenance-f0atj1ab.js → maintenance-x277jbpd.js} +9 -7
- package/dist/{mistral-conversations-qhr84ph3.js → mistral-conversations-zx0kn554.js} +24 -18
- package/dist/{node-x1g4v0pq.js → node-5qtycf6a.js} +16 -11
- package/dist/{oauth-refresh-sweep-q0t3bxre.js → oauth-refresh-sweep-5fwa7th2.js} +7 -5
- package/dist/{onboard-br5j1kch.js → onboard-17sv0f51.js} +103 -35
- package/dist/{openai-codex-responses-wy6a43wd.js → openai-codex-responses-4vjqzvjp.js} +33 -27
- package/dist/{openai-completions-32rdwmze.js → openai-completions-pxsmym7g.js} +52 -64
- package/dist/{openai-responses-6xwf7bzg.js → openai-responses-tmn0rqp0.js} +23 -24
- package/dist/{opencode-adapter-28axqa09.js → opencode-adapter-qbmv4tpy.js} +6 -6
- package/dist/{otel-impl-vdqge2nt.js → otel-impl-srjy4be4.js} +4 -4
- package/dist/{pi-messages-b1mbr6gp.js → pi-messages-txpjj39q.js} +3 -3
- package/dist/pi-mono-adapter-946a0sdd.js +1316 -0
- package/dist/{pricing-refresh-hb3691fd.js → pricing-refresh-vetcm563.js} +8 -6
- package/dist/{rbac-roles-jh280k9g.js → rbac-roles-cfzgr6r1.js} +8 -6
- package/dist/{rbac-roles-t78xt39b.js → rbac-roles-cmxaddmy.js} +7 -5
- package/dist/{render-v2-7p8r2ymg.js → render-v2-f9hzff72.js} +9 -6
- package/dist/{seed-pricing-hf889enh.js → seed-pricing-jggk6rsy.js} +7 -5
- package/dist/{setup-w6mb03jv.js → setup-8mfceb9t.js} +4 -5
- package/dist/virtual-modules-ax661xp0.js +54 -0
- package/dist/{work-objects-nt8gy1kj.js → work-objects-vdsdcczj.js} +32 -28
- package/dist/{worker-dwy617t0.js → worker-cd0nhyv1.js} +44 -39
- package/openapi.json +36 -14
- package/package.json +6 -6
- package/src/be/automation-preflight.ts +6 -4
- package/src/be/extensions/db.ts +35 -4
- package/src/be/models-catalog.ts +2 -0
- package/src/be/modelsdev-cache.json +213 -0
- package/src/be/rbac-audit.ts +2 -0
- package/src/be/seed-pricing.ts +3 -1
- package/src/be/swarm-config-guard.ts +1 -0
- package/src/commands/onboard/compose-generator.ts +6 -1
- package/src/commands/onboard/env-generator.ts +6 -1
- package/src/commands/onboard/manifest.ts +1 -0
- package/src/commands/onboard/steps/integration-slack.tsx +56 -16
- package/src/commands/onboard/steps/review.tsx +5 -0
- package/src/commands/onboard/types.ts +6 -0
- package/src/commands/onboard.tsx +5 -1
- package/src/commands/provider-credentials.ts +14 -2
- package/src/extensions/lifecycle.ts +15 -21
- package/src/http/agents.ts +2 -2
- package/src/http/config.ts +1 -1
- package/src/http/core.ts +5 -3
- package/src/http/extensions.ts +108 -34
- package/src/http/status.ts +22 -10
- package/src/prompts/base-prompt.ts +15 -7
- package/src/providers/claude-managed-models.ts +8 -0
- package/src/providers/codex-models.ts +15 -1
- package/src/providers/dsh-adapter.ts +248 -0
- package/src/providers/index.ts +5 -1
- package/src/providers/modelsdev-reasoning.json +50 -0
- package/src/rbac/legacy-policy.ts +15 -1
- package/src/rbac/types.ts +2 -0
- package/src/server.ts +7 -1
- package/src/slack/app.ts +32 -10
- package/src/slack/config.ts +29 -0
- package/src/telemetry.ts +2 -3
- package/src/tests/agents-harness-provider.test.ts +19 -0
- package/src/tests/agents-list-model-display.test.ts +60 -1
- package/src/tests/base-prompt.test.ts +25 -0
- package/src/tests/claude-managed-adapter.test.ts +6 -0
- package/src/tests/codex-gpt6-release.test.ts +97 -0
- package/src/tests/config-api-only-keys.test.ts +9 -0
- package/src/tests/context-window.test.ts +1 -0
- package/src/tests/dsh-adapter.test.ts +276 -0
- package/src/tests/e2e-nightly-report.test.ts +3 -3
- package/src/tests/e2e-redact.test.ts +2 -0
- package/src/tests/env-flag.test.ts +6 -0
- package/src/tests/extensions-db.test.ts +41 -0
- package/src/tests/extensions-http.test.ts +148 -4
- package/src/tests/extensions-lifecycle.test.ts +18 -0
- package/src/tests/extensions-mcp-tools.test.ts +9 -5
- package/src/tests/internal-ai/complete-structured.test.ts +32 -9
- package/src/tests/internal-ai/credentials.test.ts +4 -4
- package/src/tests/internal-ai/models.test.ts +20 -0
- package/src/tests/migration-046-budgets.test.ts +2 -0
- package/src/tests/model-control.test.ts +2 -2
- package/src/tests/onboard-compose.test.ts +14 -0
- package/src/tests/onboard-env.test.ts +17 -0
- package/src/tests/onboard-manifest.test.ts +12 -0
- package/src/tests/opus-5-5-registry.test.ts +48 -0
- package/src/tests/pricing-refresh.test.ts +1 -1
- package/src/tests/pricing-routes.test.ts +15 -3
- package/src/tests/provider-registration.test.ts +5 -2
- package/src/tests/rbac-admission-e2e.test.ts +54 -0
- package/src/tests/rbac-e2e-helpers.ts +2 -0
- package/src/tests/rbac-engine.test.ts +32 -0
- package/src/tests/rbac-wire-e2e.test.ts +33 -0
- package/src/tests/reasoning-effort.test.ts +8 -0
- package/src/tests/reload-config.test.ts +33 -0
- package/src/tests/session-costs-model-key-normalize.test.ts +1 -0
- package/src/tests/slack-config.test.ts +136 -0
- package/src/tests/slack-mode-lifecycle.test.ts +69 -0
- package/src/tests/status.test.ts +22 -2
- package/src/tests/task-tool-preload-mcp.test.ts +3 -1
- package/src/tests/telemetry-init.test.ts +18 -0
- package/src/tests/workflow-llm.test.ts +3 -3
- package/src/tools/extension-common.ts +4 -0
- package/src/tools/extension-install.ts +1 -1
- package/src/tools/extension-list.ts +4 -3
- package/src/types.ts +17 -8
- package/src/utils/context-window.ts +1 -0
- package/src/utils/credentials.ts +8 -0
- package/src/utils/internal-ai/complete-structured.ts +8 -0
- package/src/utils/internal-ai/models.ts +5 -5
- package/templates/schedules/daily-status-report/content.md +25 -12
- package/templates/schedules/daily-workflow-health-audit/content.md +1 -1
- package/templates/skills/swarm-extensions/content.md +9 -5
- package/dist/cli-4wppfkcm.js +0 -16384
- package/dist/cli-55qrx3q8.js +0 -6041
- package/dist/cli-cg4vnyh4.js +0 -305
- package/dist/cli-jyetr64j.js +0 -52
- package/dist/cli-pp9ax9pa.js +0 -520
- package/dist/cli-qa66qaf0.js +0 -6076
- package/dist/cli-qghpvca2.js +0 -590
- package/dist/cli-rembwgt8.js +0 -861
- package/dist/cli-tcvj7j2r.js +0 -1971
- package/dist/cli-vfcth11k.js +0 -36
- package/dist/cli-w1d1bgkk.js +0 -1422
- package/dist/cli-y6x0gqtg.js +0 -5977
- package/dist/es5-tj3tn4jj.js +0 -844
- package/dist/index-1kq5hw2p.js +0 -467
- package/dist/index-1p8wdstt.js +0 -7
- package/dist/index-8fdjzb2f.js +0 -100
- package/dist/index-bxmwzbgw.js +0 -365
- package/dist/index-nzerxd5z.js +0 -7
- package/dist/index-pyymnzat.js +0 -1168
- package/dist/index-qv6atbab.js +0 -619
- package/dist/index-rja32qa7.js +0 -801
- package/dist/index-tzg5srfp.js +0 -211
- package/dist/index-vhncw983.js +0 -90
- package/dist/index-xk036zsk.js +0 -859
- package/dist/index-zyazbzcb.js +0 -6
- package/dist/{claude-managed-setup-48dwg9bv.js → claude-managed-setup-f5pmsyrp.js} +3 -3
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
splitDeferredTools
|
|
3
|
-
} from "./cli-vfcth11k.js";
|
|
4
1
|
import {
|
|
5
2
|
convertResponsesMessages,
|
|
6
3
|
convertResponsesTools,
|
|
7
4
|
processResponsesStream
|
|
8
|
-
} from "./cli-
|
|
5
|
+
} from "./cli-00w2c66p.js";
|
|
9
6
|
import {
|
|
10
7
|
clampOpenAIPromptCacheKey
|
|
11
8
|
} from "./cli-mrptpp86.js";
|
|
@@ -27,22 +24,28 @@ import {
|
|
|
27
24
|
import {
|
|
28
25
|
buildBaseOptions,
|
|
29
26
|
createGrammarToolInputProperties
|
|
30
|
-
} from "./cli-
|
|
27
|
+
} from "./cli-k0g1sjzm.js";
|
|
31
28
|
import"./cli-y2apkfe2.js";
|
|
32
29
|
import {
|
|
33
30
|
headersToRecord
|
|
34
31
|
} from "./cli-vapyk8sw.js";
|
|
35
|
-
import {
|
|
36
|
-
clampThinkingLevel
|
|
37
|
-
} from "./cli-rgvp6r2x.js";
|
|
38
32
|
import"./cli-btbzvq95.js";
|
|
39
33
|
import"./cli-1m2e086m.js";
|
|
34
|
+
import {
|
|
35
|
+
clampThinkingLevel,
|
|
36
|
+
getDeclaredTools,
|
|
37
|
+
getInitialSystemMessage,
|
|
38
|
+
getSystemMessageText,
|
|
39
|
+
normalizeContext,
|
|
40
|
+
resolveTranscript,
|
|
41
|
+
resolveTranscriptTools
|
|
42
|
+
} from "./cli-mcnhgnn1.js";
|
|
40
43
|
import {
|
|
41
44
|
AssistantMessageEventStream,
|
|
42
45
|
appendAssistantMessageDiagnostic,
|
|
43
46
|
createAssistantMessageDiagnostic,
|
|
44
47
|
formatThrownValue
|
|
45
|
-
} from "./cli-
|
|
48
|
+
} from "./cli-bzr0ftht.js";
|
|
46
49
|
import"./cli-bc05qbss.js";
|
|
47
50
|
|
|
48
51
|
// node_modules/@earendil-works/pi-ai/dist/utils/abort-signals.js
|
|
@@ -195,6 +198,7 @@ function compressRequestBodyZstd(bodyJson) {
|
|
|
195
198
|
}
|
|
196
199
|
var stream = (model, context, options) => {
|
|
197
200
|
const stream2 = new AssistantMessageEventStream;
|
|
201
|
+
const normalizedContext = resolveTranscript(context, model.compat?.supportsMidConvoSystemMessages);
|
|
198
202
|
(async () => {
|
|
199
203
|
const output = {
|
|
200
204
|
role: "assistant",
|
|
@@ -219,10 +223,10 @@ var stream = (model, context, options) => {
|
|
|
219
223
|
throw new Error(`No API key for provider: ${model.provider}`);
|
|
220
224
|
}
|
|
221
225
|
const accountId = extractAccountId(apiKey);
|
|
222
|
-
const grammarToolInputProperties = createGrammarToolInputProperties(
|
|
226
|
+
const grammarToolInputProperties = createGrammarToolInputProperties(getDeclaredTools(normalizedContext.messages), model.compat?.supportsOpenAIGrammarTools ?? false);
|
|
223
227
|
const cacheSessionId = options?.cacheRetention === "none" ? undefined : options?.sessionId;
|
|
224
228
|
const codexSessionId = clampOpenAIPromptCacheKey(cacheSessionId);
|
|
225
|
-
let body = buildRequestBody(model,
|
|
229
|
+
let body = buildRequestBody(model, normalizedContext, options, codexSessionId, grammarToolInputProperties);
|
|
226
230
|
const nextBody = await options?.onPayload?.(body, model);
|
|
227
231
|
if (nextBody !== undefined) {
|
|
228
232
|
body = nextBody;
|
|
@@ -281,7 +285,7 @@ var stream = (model, context, options) => {
|
|
|
281
285
|
}
|
|
282
286
|
appendAssistantMessageDiagnostic(output, createAssistantMessageDiagnostic("provider_transport_failure", error, {
|
|
283
287
|
configuredTransport: transport,
|
|
284
|
-
|
|
288
|
+
...websocketStarted ? {} : { fallbackTransport: "sse" },
|
|
285
289
|
eventsEmitted: websocketStarted,
|
|
286
290
|
phase: websocketStarted ? "after_message_stream_start" : "before_message_stream_start",
|
|
287
291
|
requestBytes: new TextEncoder().encode(bodyJson).byteLength
|
|
@@ -403,27 +407,27 @@ var streamSimple = (model, context, options) => {
|
|
|
403
407
|
reasoningEffort
|
|
404
408
|
});
|
|
405
409
|
};
|
|
406
|
-
function buildRequestBody(model, context, options, cacheSessionId, grammarToolInputProperties = createGrammarToolInputProperties(context.
|
|
410
|
+
function buildRequestBody(model, context, options, cacheSessionId, grammarToolInputProperties = createGrammarToolInputProperties(getDeclaredTools(context.messages), model.compat?.supportsOpenAIGrammarTools ?? false)) {
|
|
407
411
|
const supportsStrictMode = model.compat?.supportsStrictMode ?? true;
|
|
408
412
|
const supportsOpenAIGrammarTools = model.compat?.supportsOpenAIGrammarTools ?? false;
|
|
409
|
-
const
|
|
410
|
-
const
|
|
413
|
+
const supportsAdditionalTools = model.compat?.supportsAdditionalTools ?? false;
|
|
414
|
+
const supportsToolSearch = model.compat?.supportsToolSearch ?? false;
|
|
415
|
+
const transcriptTools = resolveTranscriptTools(context.messages, supportsAdditionalTools || supportsToolSearch);
|
|
411
416
|
const messages = convertResponsesMessages(model, context, CODEX_TOOL_CALL_PROVIDERS, {
|
|
412
417
|
includeSystemPrompt: false,
|
|
413
418
|
grammarToolInputProperties,
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
supportsStrictMode,
|
|
419
|
-
supportsOpenAIGrammarTools
|
|
420
|
-
}
|
|
419
|
+
supportsMidConvoSystemMessages: model.compat?.supportsMidConvoSystemMessages ?? false,
|
|
420
|
+
supportsAdditionalTools,
|
|
421
|
+
supportsToolSearch,
|
|
422
|
+
toolOptions: { strict: null, supportsStrictMode, supportsOpenAIGrammarTools }
|
|
421
423
|
});
|
|
424
|
+
const initialSystemMessage = getInitialSystemMessage(context.messages);
|
|
425
|
+
const instructions = initialSystemMessage ? getSystemMessageText(initialSystemMessage) : "";
|
|
422
426
|
const body = {
|
|
423
427
|
model: model.id,
|
|
424
428
|
store: false,
|
|
425
429
|
stream: true,
|
|
426
|
-
instructions:
|
|
430
|
+
instructions: instructions || "You are a helpful assistant.",
|
|
427
431
|
input: messages,
|
|
428
432
|
text: { verbosity: options?.textVerbosity || "low" },
|
|
429
433
|
include: ["reasoning.encrypted_content"],
|
|
@@ -437,21 +441,23 @@ function buildRequestBody(model, context, options, cacheSessionId, grammarToolIn
|
|
|
437
441
|
if (options?.serviceTier !== undefined) {
|
|
438
442
|
body.service_tier = options.serviceTier;
|
|
439
443
|
}
|
|
440
|
-
if (
|
|
441
|
-
body.tools = convertResponsesTools(
|
|
444
|
+
if (transcriptTools.requestTools.length > 0) {
|
|
445
|
+
body.tools = convertResponsesTools(transcriptTools.requestTools, {
|
|
442
446
|
strict: null,
|
|
443
447
|
supportsStrictMode,
|
|
444
448
|
supportsOpenAIGrammarTools
|
|
445
449
|
});
|
|
446
450
|
}
|
|
447
451
|
if (options?.reasoningEffort !== undefined) {
|
|
448
|
-
const effort = options.reasoningEffort === "none" ? model.thinkingLevelMap?.off
|
|
452
|
+
const effort = options.reasoningEffort === "none" ? model.thinkingLevelMap?.off === undefined ? "none" : model.thinkingLevelMap.off : model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort;
|
|
449
453
|
if (effort !== null) {
|
|
450
454
|
body.reasoning = {
|
|
451
455
|
effort,
|
|
452
456
|
summary: options.reasoningSummary ?? "auto"
|
|
453
457
|
};
|
|
454
458
|
}
|
|
459
|
+
} else if (model.reasoning && model.thinkingLevelMap?.off !== null) {
|
|
460
|
+
body.reasoning = { effort: model.thinkingLevelMap?.off ?? "none" };
|
|
455
461
|
}
|
|
456
462
|
return body;
|
|
457
463
|
}
|
|
@@ -1197,7 +1203,7 @@ async function processWebSocketStream(url, body, headers, output, stream2, model
|
|
|
1197
1203
|
if (options?.signal?.aborted) {
|
|
1198
1204
|
keepConnection = false;
|
|
1199
1205
|
} else if (useCachedContext && entry && output.responseId) {
|
|
1200
|
-
const responseItems = convertResponsesMessages(model, { messages: [output] }, CODEX_TOOL_CALL_PROVIDERS, {
|
|
1206
|
+
const responseItems = convertResponsesMessages(model, normalizeContext({ messages: [output] }), CODEX_TOOL_CALL_PROVIDERS, {
|
|
1201
1207
|
includeSystemPrompt: false,
|
|
1202
1208
|
grammarToolInputProperties
|
|
1203
1209
|
}).filter((item) => item.type !== "function_call_output" && item.type !== "custom_tool_call_output");
|
|
@@ -5,12 +5,12 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
clampOpenAIPromptCacheKey
|
|
7
7
|
} from "./cli-mrptpp86.js";
|
|
8
|
-
import {
|
|
9
|
-
shortHash
|
|
10
|
-
} from "./cli-5m9j2spm.js";
|
|
11
8
|
import {
|
|
12
9
|
retryProviderRequest
|
|
13
10
|
} from "./cli-s8s499xy.js";
|
|
11
|
+
import {
|
|
12
|
+
shortHash
|
|
13
|
+
} from "./cli-5m9j2spm.js";
|
|
14
14
|
import {
|
|
15
15
|
getPiUserAgent
|
|
16
16
|
} from "./cli-et1bbwqf.js";
|
|
@@ -33,26 +33,31 @@ import {
|
|
|
33
33
|
resolveJsonSchemaStrictSampling,
|
|
34
34
|
thinkingBudgetForLevel,
|
|
35
35
|
transformMessages
|
|
36
|
-
} from "./cli-
|
|
36
|
+
} from "./cli-k0g1sjzm.js";
|
|
37
37
|
import {
|
|
38
38
|
sanitizeSurrogates
|
|
39
39
|
} from "./cli-y2apkfe2.js";
|
|
40
40
|
import {
|
|
41
41
|
headersToRecord
|
|
42
42
|
} from "./cli-vapyk8sw.js";
|
|
43
|
-
import {
|
|
44
|
-
calculateCost,
|
|
45
|
-
clampThinkingLevel
|
|
46
|
-
} from "./cli-rgvp6r2x.js";
|
|
47
43
|
import {
|
|
48
44
|
getProviderEnvValue
|
|
49
45
|
} from "./cli-btbzvq95.js";
|
|
50
46
|
import {
|
|
51
47
|
parseStreamingJson
|
|
52
48
|
} from "./cli-1m2e086m.js";
|
|
49
|
+
import {
|
|
50
|
+
calculateCost,
|
|
51
|
+
clampThinkingLevel,
|
|
52
|
+
getDeclaredTools,
|
|
53
|
+
getSystemMessageText,
|
|
54
|
+
renderSystemMessageUpdate,
|
|
55
|
+
resolveTranscript,
|
|
56
|
+
resolveTranscriptTools
|
|
57
|
+
} from "./cli-mcnhgnn1.js";
|
|
53
58
|
import {
|
|
54
59
|
AssistantMessageEventStream
|
|
55
|
-
} from "./cli-
|
|
60
|
+
} from "./cli-bzr0ftht.js";
|
|
56
61
|
import"./cli-bc05qbss.js";
|
|
57
62
|
|
|
58
63
|
// node_modules/@earendil-works/pi-ai/dist/api/openai-completions.js
|
|
@@ -87,23 +92,6 @@ function hasToolHistory(messages) {
|
|
|
87
92
|
}
|
|
88
93
|
return false;
|
|
89
94
|
}
|
|
90
|
-
function getDeferredToolNames(messages) {
|
|
91
|
-
const names = new Set;
|
|
92
|
-
for (const message of messages) {
|
|
93
|
-
if (message.role === "toolResult") {
|
|
94
|
-
for (const name of message.addedToolNames ?? []) {
|
|
95
|
-
names.add(name);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return names;
|
|
100
|
-
}
|
|
101
|
-
function getToolsByName(tools, names) {
|
|
102
|
-
if (!tools)
|
|
103
|
-
return [];
|
|
104
|
-
const toolsByName = new Map(tools.map((tool) => [tool.name, tool]));
|
|
105
|
-
return Array.from(names).map((name) => toolsByName.get(name)).filter((tool) => tool !== undefined);
|
|
106
|
-
}
|
|
107
95
|
function isTextContentBlock(block) {
|
|
108
96
|
return block.type === "text";
|
|
109
97
|
}
|
|
@@ -192,6 +180,7 @@ function resolveCacheRetention(cacheRetention, env) {
|
|
|
192
180
|
}
|
|
193
181
|
var stream = (model, context, options) => {
|
|
194
182
|
const stream2 = new AssistantMessageEventStream;
|
|
183
|
+
const normalizedContext = resolveTranscript(context, getCompat(model).supportsMidConvoSystemMessages);
|
|
195
184
|
(async () => {
|
|
196
185
|
const output = {
|
|
197
186
|
role: "assistant",
|
|
@@ -219,11 +208,11 @@ var stream = (model, context, options) => {
|
|
|
219
208
|
try {
|
|
220
209
|
const apiKey = getClientApiKey(model.provider, options?.apiKey, options?.headers);
|
|
221
210
|
const compat = getCompat(model);
|
|
222
|
-
const grammarToolInputProperties = createGrammarToolInputProperties(
|
|
211
|
+
const grammarToolInputProperties = createGrammarToolInputProperties(getDeclaredTools(normalizedContext.messages), compat.supportsOpenAIGrammarTools);
|
|
223
212
|
const cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env);
|
|
224
213
|
const cacheSessionId = cacheRetention === "none" ? undefined : options?.sessionId;
|
|
225
|
-
const client = createClient(model,
|
|
226
|
-
let params = buildParams(model,
|
|
214
|
+
const client = createClient(model, normalizedContext, apiKey, options?.headers, options?.fetch, cacheSessionId, compat);
|
|
215
|
+
let params = buildParams(model, normalizedContext, options, compat, cacheRetention, grammarToolInputProperties);
|
|
227
216
|
const nextParams = await options?.onPayload?.(params, model);
|
|
228
217
|
if (nextParams !== undefined) {
|
|
229
218
|
params = nextParams;
|
|
@@ -569,8 +558,11 @@ function createClient(model, context, apiKey, optionsHeaders, fetch, sessionId,
|
|
|
569
558
|
defaultHeaders: headers
|
|
570
559
|
});
|
|
571
560
|
}
|
|
572
|
-
function buildParams(model, context, options, compat = getCompat(model), cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env), grammarToolInputProperties = createGrammarToolInputProperties(context.
|
|
573
|
-
const
|
|
561
|
+
function buildParams(model, context, options, compat = getCompat(model), cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env), grammarToolInputProperties = createGrammarToolInputProperties(getDeclaredTools(context.messages), compat.supportsOpenAIGrammarTools)) {
|
|
562
|
+
const transcriptTools = resolveTranscriptTools(context.messages, compat.supportsMidConvoSystemMessages === true && compat.supportsMidConvoToolAdditions === true);
|
|
563
|
+
const messages = convertMessages(model, context, compat, {
|
|
564
|
+
grammarToolInputProperties
|
|
565
|
+
});
|
|
574
566
|
const cacheControl = getCompatCacheControl(compat, cacheRetention);
|
|
575
567
|
const params = {
|
|
576
568
|
model: model.id,
|
|
@@ -595,10 +587,8 @@ function buildParams(model, context, options, compat = getCompat(model), cacheRe
|
|
|
595
587
|
if (options?.temperature !== undefined) {
|
|
596
588
|
params.temperature = options.temperature;
|
|
597
589
|
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
if (activeTools && activeTools.length > 0) {
|
|
601
|
-
params.tools = convertTools(activeTools, compat);
|
|
590
|
+
if (transcriptTools.requestTools.length > 0) {
|
|
591
|
+
params.tools = convertTools(transcriptTools.requestTools, compat);
|
|
602
592
|
if (compat.zaiToolStream) {
|
|
603
593
|
params.tool_stream = true;
|
|
604
594
|
}
|
|
@@ -840,6 +830,7 @@ function addCacheControlToTextContent(message, cacheControl) {
|
|
|
840
830
|
return false;
|
|
841
831
|
}
|
|
842
832
|
function convertMessages(model, context, compat, options) {
|
|
833
|
+
const normalizedContext = resolveTranscript(context, compat.supportsMidConvoSystemMessages);
|
|
843
834
|
const params = [];
|
|
844
835
|
const normalizeToolCallId = (id) => {
|
|
845
836
|
if (id.includes("|")) {
|
|
@@ -858,12 +849,9 @@ function convertMessages(model, context, compat, options) {
|
|
|
858
849
|
return id.length > 40 ? id.slice(0, 40) : id;
|
|
859
850
|
return id;
|
|
860
851
|
};
|
|
861
|
-
const transformedMessages = transformMessages(
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
const role = useDeveloperRole ? "developer" : "system";
|
|
865
|
-
params.push({ role, content: sanitizeSurrogates(context.systemPrompt) });
|
|
866
|
-
}
|
|
852
|
+
const transformedMessages = transformMessages(normalizedContext.messages, model, (id) => normalizeToolCallId(id));
|
|
853
|
+
const transcriptTools = resolveTranscriptTools(normalizedContext.messages, compat.supportsMidConvoSystemMessages === true && compat.supportsMidConvoToolAdditions === true);
|
|
854
|
+
const instructionRole = model.reasoning && compat.supportsDeveloperRole ? "developer" : "system";
|
|
867
855
|
let lastRole = null;
|
|
868
856
|
for (let i = 0;i < transformedMessages.length; i++) {
|
|
869
857
|
const msg = transformedMessages[i];
|
|
@@ -873,14 +861,27 @@ function convertMessages(model, context, compat, options) {
|
|
|
873
861
|
content: "I have processed the tool results."
|
|
874
862
|
});
|
|
875
863
|
}
|
|
876
|
-
if (msg.role === "
|
|
864
|
+
if (msg.role === "system") {
|
|
865
|
+
const addedTools = i > 0 && transcriptTools.anchorsAdditions ? msg.toolsAdded ?? [] : [];
|
|
866
|
+
if (addedTools.length > 0) {
|
|
867
|
+
const kimiToolMessage = {
|
|
868
|
+
role: "system",
|
|
869
|
+
tools: convertTools(addedTools, compat)
|
|
870
|
+
};
|
|
871
|
+
params.push(kimiToolMessage);
|
|
872
|
+
}
|
|
873
|
+
const text = i === 0 ? getSystemMessageText(msg) : renderSystemMessageUpdate(msg);
|
|
874
|
+
if (text.length > 0) {
|
|
875
|
+
params.push({ role: instructionRole, content: sanitizeSurrogates(text) });
|
|
876
|
+
}
|
|
877
|
+
} else if (msg.role === "user") {
|
|
877
878
|
if (typeof msg.content === "string") {
|
|
878
879
|
params.push({
|
|
879
880
|
role: "user",
|
|
880
881
|
content: sanitizeSurrogates(msg.content)
|
|
881
882
|
});
|
|
882
883
|
} else {
|
|
883
|
-
const content = msg.content.map((item) => {
|
|
884
|
+
const content = msg.content.filter((item) => item.type !== "text" || item.text.length > 0).map((item) => {
|
|
884
885
|
if (item.type === "text") {
|
|
885
886
|
return {
|
|
886
887
|
type: "text",
|
|
@@ -979,7 +980,6 @@ function convertMessages(model, context, compat, options) {
|
|
|
979
980
|
params.push(assistantMsg);
|
|
980
981
|
} else if (msg.role === "toolResult") {
|
|
981
982
|
const imageBlocks = [];
|
|
982
|
-
const deferredToolNames = new Set;
|
|
983
983
|
let j = i;
|
|
984
984
|
for (;j < transformedMessages.length && transformedMessages[j].role === "toolResult"; j++) {
|
|
985
985
|
const toolMsg = transformedMessages[j];
|
|
@@ -997,11 +997,6 @@ function convertMessages(model, context, compat, options) {
|
|
|
997
997
|
toolResultMsg.name = toolMsg.toolName;
|
|
998
998
|
}
|
|
999
999
|
params.push(toolResultMsg);
|
|
1000
|
-
if (compat.deferredToolsMode === "kimi") {
|
|
1001
|
-
for (const name of toolMsg.addedToolNames ?? []) {
|
|
1002
|
-
deferredToolNames.add(name);
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
1000
|
if (hasImages && model.input.includes("image")) {
|
|
1006
1001
|
for (const block of toolMsg.content) {
|
|
1007
1002
|
if (isImageContentBlock(block)) {
|
|
@@ -1037,16 +1032,6 @@ function convertMessages(model, context, compat, options) {
|
|
|
1037
1032
|
} else {
|
|
1038
1033
|
lastRole = "toolResult";
|
|
1039
1034
|
}
|
|
1040
|
-
if (deferredToolNames.size > 0) {
|
|
1041
|
-
const deferredTools = getToolsByName(context.tools, deferredToolNames);
|
|
1042
|
-
if (deferredTools.length > 0) {
|
|
1043
|
-
const kimiToolMessage = {
|
|
1044
|
-
role: "system",
|
|
1045
|
-
tools: convertTools(deferredTools, compat)
|
|
1046
|
-
};
|
|
1047
|
-
params.push(kimiToolMessage);
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
1035
|
continue;
|
|
1051
1036
|
}
|
|
1052
1037
|
lastRole = msg.role;
|
|
@@ -1136,8 +1121,9 @@ function detectCompat(model) {
|
|
|
1136
1121
|
const isCloudflareAiGateway = provider === "cloudflare-ai-gateway" || baseUrl.includes("gateway.ai.cloudflare.com");
|
|
1137
1122
|
const isNvidia = provider === "nvidia" || baseUrl.includes("integrate.api.nvidia.com");
|
|
1138
1123
|
const isAntLing = provider === "ant-ling" || baseUrl.includes("api.ant-ling.com");
|
|
1124
|
+
const isCerebras = provider === "cerebras" || baseUrl.includes("cerebras.ai");
|
|
1139
1125
|
const isDeepSeek = provider === "deepseek" || baseUrl.toLowerCase().includes("deepseek.com");
|
|
1140
|
-
const isNonStandard = isNvidia ||
|
|
1126
|
+
const isNonStandard = isNvidia || isCerebras || provider === "xai" || baseUrl.includes("api.x.ai") || isTogether || baseUrl.includes("chutes.ai") || isDeepSeek || isZai || isMoonshot || provider === "opencode" || baseUrl.includes("opencode.ai") || isCloudflareWorkersAI || isCloudflareAiGateway || isAntLing;
|
|
1141
1127
|
const useMaxTokens = baseUrl.includes("chutes.ai") || isDeepSeek || isMoonshot || isCloudflareAiGateway || isTogether || isNvidia || isAntLing || isZai;
|
|
1142
1128
|
const isGrok = provider === "xai" || baseUrl.includes("api.x.ai");
|
|
1143
1129
|
const isOpenRouterDeveloperRoleModel = isOpenRouter && (model.id.startsWith("anthropic/") || model.id.startsWith("openai/"));
|
|
@@ -1161,11 +1147,12 @@ function detectCompat(model) {
|
|
|
1161
1147
|
zaiToolStream: false,
|
|
1162
1148
|
supportsThinkingTokenBudget: false,
|
|
1163
1149
|
thinkingTokenBudgetField: undefined,
|
|
1164
|
-
supportsStrictMode:
|
|
1150
|
+
supportsStrictMode: false,
|
|
1165
1151
|
supportsOpenAIGrammarTools: false,
|
|
1152
|
+
supportsMidConvoSystemMessages: false,
|
|
1153
|
+
supportsMidConvoToolAdditions: false,
|
|
1166
1154
|
cacheControlFormat,
|
|
1167
|
-
sendSessionAffinityHeaders:
|
|
1168
|
-
deferredToolsMode: undefined,
|
|
1155
|
+
sendSessionAffinityHeaders: isOpenRouter,
|
|
1169
1156
|
sessionAffinityFormat: isOpenRouter ? "openrouter" : "openai",
|
|
1170
1157
|
supportsLongCacheRetention: !(isTogether || isCloudflareWorkersAI || isCloudflareAiGateway || isNvidia || isAntLing)
|
|
1171
1158
|
};
|
|
@@ -1195,9 +1182,10 @@ function getCompat(model) {
|
|
|
1195
1182
|
thinkingTokenBudgetField: model.compat.thinkingTokenBudgetField ?? detected.thinkingTokenBudgetField,
|
|
1196
1183
|
supportsStrictMode: model.compat.supportsStrictMode ?? detected.supportsStrictMode,
|
|
1197
1184
|
supportsOpenAIGrammarTools: model.compat.supportsOpenAIGrammarTools ?? detected.supportsOpenAIGrammarTools,
|
|
1185
|
+
supportsMidConvoSystemMessages: model.compat.supportsMidConvoSystemMessages ?? detected.supportsMidConvoSystemMessages,
|
|
1186
|
+
supportsMidConvoToolAdditions: model.compat.supportsMidConvoToolAdditions ?? detected.supportsMidConvoToolAdditions,
|
|
1198
1187
|
cacheControlFormat: model.compat.cacheControlFormat ?? detected.cacheControlFormat,
|
|
1199
1188
|
sendSessionAffinityHeaders: model.compat.sendSessionAffinityHeaders ?? detected.sendSessionAffinityHeaders,
|
|
1200
|
-
deferredToolsMode: model.compat.deferredToolsMode ?? detected.deferredToolsMode,
|
|
1201
1189
|
sessionAffinityFormat: model.compat.sessionAffinityFormat ?? detected.sessionAffinityFormat,
|
|
1202
1190
|
supportsLongCacheRetention: model.compat.supportsLongCacheRetention ?? detected.supportsLongCacheRetention,
|
|
1203
1191
|
vllmPriority: model.compat.vllmPriority
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
splitDeferredTools
|
|
3
|
-
} from "./cli-vfcth11k.js";
|
|
4
1
|
import {
|
|
5
2
|
buildCopilotDynamicHeaders,
|
|
6
3
|
hasCopilotVisionInput
|
|
@@ -9,14 +6,14 @@ import {
|
|
|
9
6
|
convertResponsesMessages,
|
|
10
7
|
convertResponsesTools,
|
|
11
8
|
processResponsesStream
|
|
12
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-00w2c66p.js";
|
|
13
10
|
import {
|
|
14
11
|
clampOpenAIPromptCacheKey
|
|
15
12
|
} from "./cli-mrptpp86.js";
|
|
16
|
-
import"./cli-5m9j2spm.js";
|
|
17
13
|
import {
|
|
18
14
|
retryProviderRequest
|
|
19
15
|
} from "./cli-s8s499xy.js";
|
|
16
|
+
import"./cli-5m9j2spm.js";
|
|
20
17
|
import {
|
|
21
18
|
getPiUserAgent
|
|
22
19
|
} from "./cli-et1bbwqf.js";
|
|
@@ -31,21 +28,24 @@ import {
|
|
|
31
28
|
import {
|
|
32
29
|
buildBaseOptions,
|
|
33
30
|
createGrammarToolInputProperties
|
|
34
|
-
} from "./cli-
|
|
31
|
+
} from "./cli-k0g1sjzm.js";
|
|
35
32
|
import"./cli-y2apkfe2.js";
|
|
36
33
|
import {
|
|
37
34
|
headersToRecord
|
|
38
35
|
} from "./cli-vapyk8sw.js";
|
|
39
|
-
import {
|
|
40
|
-
clampThinkingLevel
|
|
41
|
-
} from "./cli-rgvp6r2x.js";
|
|
42
36
|
import {
|
|
43
37
|
getProviderEnvValue
|
|
44
38
|
} from "./cli-btbzvq95.js";
|
|
45
39
|
import"./cli-1m2e086m.js";
|
|
40
|
+
import {
|
|
41
|
+
clampThinkingLevel,
|
|
42
|
+
getDeclaredTools,
|
|
43
|
+
resolveTranscript,
|
|
44
|
+
resolveTranscriptTools
|
|
45
|
+
} from "./cli-mcnhgnn1.js";
|
|
46
46
|
import {
|
|
47
47
|
AssistantMessageEventStream
|
|
48
|
-
} from "./cli-
|
|
48
|
+
} from "./cli-bzr0ftht.js";
|
|
49
49
|
import"./cli-bc05qbss.js";
|
|
50
50
|
|
|
51
51
|
// node_modules/@earendil-works/pi-ai/dist/api/openai-responses.js
|
|
@@ -84,6 +84,7 @@ function resolveCacheRetention(cacheRetention, env) {
|
|
|
84
84
|
function getCompat(model) {
|
|
85
85
|
return {
|
|
86
86
|
supportsDeveloperRole: model.compat?.supportsDeveloperRole ?? true,
|
|
87
|
+
supportsMidConvoSystemMessages: model.compat?.supportsMidConvoSystemMessages ?? false,
|
|
87
88
|
sessionAffinityFormat: model.compat?.sessionAffinityFormat ?? detectSessionAffinityFormat(model),
|
|
88
89
|
supportsLongCacheRetention: model.compat?.supportsLongCacheRetention ?? true,
|
|
89
90
|
supportsStrictMode: model.compat?.supportsStrictMode ?? false,
|
|
@@ -106,11 +107,9 @@ function getPromptCacheOptions(compat, cacheRetention) {
|
|
|
106
107
|
return { ttl: "30m" };
|
|
107
108
|
return;
|
|
108
109
|
}
|
|
109
|
-
function formatOpenAIResponsesError(error) {
|
|
110
|
-
return formatProviderError(normalizeProviderError(error), "OpenAI API error");
|
|
111
|
-
}
|
|
112
110
|
var stream = (model, context, options) => {
|
|
113
111
|
const stream2 = new AssistantMessageEventStream;
|
|
112
|
+
const normalizedContext = resolveTranscript(context, getCompat(model).supportsMidConvoSystemMessages);
|
|
114
113
|
(async () => {
|
|
115
114
|
const output = {
|
|
116
115
|
role: "assistant",
|
|
@@ -134,9 +133,9 @@ var stream = (model, context, options) => {
|
|
|
134
133
|
const cacheRetention = resolveCacheRetention(options?.cacheRetention, options?.env);
|
|
135
134
|
const cacheSessionId = cacheRetention === "none" ? undefined : options?.sessionId;
|
|
136
135
|
const compat = getCompat(model);
|
|
137
|
-
const grammarToolInputProperties = createGrammarToolInputProperties(
|
|
138
|
-
const client = createClient(model,
|
|
139
|
-
let params = buildParams(model,
|
|
136
|
+
const grammarToolInputProperties = createGrammarToolInputProperties(getDeclaredTools(normalizedContext.messages), compat.supportsOpenAIGrammarTools);
|
|
137
|
+
const client = createClient(model, normalizedContext, apiKey, options?.headers, options?.fetch, cacheSessionId);
|
|
138
|
+
let params = buildParams(model, normalizedContext, options, compat, grammarToolInputProperties);
|
|
140
139
|
const nextParams = await options?.onPayload?.(params, model);
|
|
141
140
|
if (nextParams !== undefined) {
|
|
142
141
|
params = nextParams;
|
|
@@ -176,7 +175,7 @@ var stream = (model, context, options) => {
|
|
|
176
175
|
delete block.customInput;
|
|
177
176
|
}
|
|
178
177
|
output.stopReason = options?.signal?.aborted ? "aborted" : "error";
|
|
179
|
-
output.errorMessage =
|
|
178
|
+
output.errorMessage = formatProviderError(normalizeProviderError(error), `${model.provider === "openai" ? "OpenAI" : model.provider} API error`);
|
|
180
179
|
stream2.push({ type: "error", reason: output.stopReason, error: output });
|
|
181
180
|
stream2.end();
|
|
182
181
|
}
|
|
@@ -228,13 +227,13 @@ function createClient(model, context, apiKey, optionsHeaders, fetch, sessionId)
|
|
|
228
227
|
defaultHeaders: headers
|
|
229
228
|
});
|
|
230
229
|
}
|
|
231
|
-
function buildParams(model, context, options, compat = getCompat(model), grammarToolInputProperties = createGrammarToolInputProperties(context.
|
|
232
|
-
const
|
|
233
|
-
const toolPlacement = splitDeferredTools(context, deferredToolsMode !== undefined);
|
|
230
|
+
function buildParams(model, context, options, compat = getCompat(model), grammarToolInputProperties = createGrammarToolInputProperties(getDeclaredTools(context.messages), compat.supportsOpenAIGrammarTools)) {
|
|
231
|
+
const transcriptTools = resolveTranscriptTools(context.messages, compat.supportsAdditionalTools || compat.supportsToolSearch);
|
|
234
232
|
const messages = convertResponsesMessages(model, context, OPENAI_TOOL_CALL_PROVIDERS, {
|
|
235
233
|
grammarToolInputProperties,
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
supportsMidConvoSystemMessages: compat.supportsMidConvoSystemMessages,
|
|
235
|
+
supportsAdditionalTools: compat.supportsAdditionalTools,
|
|
236
|
+
supportsToolSearch: compat.supportsToolSearch,
|
|
238
237
|
toolOptions: {
|
|
239
238
|
supportsStrictMode: compat.supportsStrictMode,
|
|
240
239
|
supportsOpenAIGrammarTools: compat.supportsOpenAIGrammarTools
|
|
@@ -259,8 +258,8 @@ function buildParams(model, context, options, compat = getCompat(model), grammar
|
|
|
259
258
|
if (options?.serviceTier !== undefined) {
|
|
260
259
|
params.service_tier = options.serviceTier;
|
|
261
260
|
}
|
|
262
|
-
if (
|
|
263
|
-
params.tools = convertResponsesTools(
|
|
261
|
+
if (transcriptTools.requestTools.length > 0) {
|
|
262
|
+
params.tools = convertResponsesTools(transcriptTools.requestTools, {
|
|
264
263
|
supportsStrictMode: compat.supportsStrictMode,
|
|
265
264
|
supportsOpenAIGrammarTools: compat.supportsOpenAIGrammarTools
|
|
266
265
|
});
|
|
@@ -5,17 +5,17 @@ import {
|
|
|
5
5
|
applyOpenRouterBaseUrlOverride,
|
|
6
6
|
checkOpencodeCredentials,
|
|
7
7
|
resolveContextModePluginPath
|
|
8
|
-
} from "./cli-
|
|
9
|
-
import"./cli-tng3131n.js";
|
|
8
|
+
} from "./cli-18amys3y.js";
|
|
10
9
|
import"./cli-5bfdm1ah.js";
|
|
11
10
|
import"./cli-r94z9p1z.js";
|
|
12
|
-
import"./cli-zm7njwzd.js";
|
|
13
|
-
import"./cli-s25avqg9.js";
|
|
14
11
|
import"./cli-2djtr51b.js";
|
|
15
|
-
import"./cli-
|
|
12
|
+
import"./cli-tng3131n.js";
|
|
13
|
+
import"./cli-zm7njwzd.js";
|
|
14
|
+
import"./cli-e781c6f9.js";
|
|
15
|
+
import"./cli-avkd6mqv.js";
|
|
16
16
|
import"./cli-re8z5p8p.js";
|
|
17
17
|
import"./cli-3dpj7atn.js";
|
|
18
|
-
import"./cli-
|
|
18
|
+
import"./cli-v4en75c5.js";
|
|
19
19
|
import"./cli-ej6gbxfb.js";
|
|
20
20
|
import"./cli-r2ap2czm.js";
|
|
21
21
|
import"./cli-bc05qbss.js";
|
|
@@ -4,18 +4,18 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
init_package,
|
|
6
6
|
package_default
|
|
7
|
-
} from "./cli-
|
|
7
|
+
} from "./cli-ybpp1srm.js";
|
|
8
8
|
import {
|
|
9
9
|
init_secret_scrubber,
|
|
10
10
|
scrubSecrets
|
|
11
11
|
} from "./cli-r2ap2czm.js";
|
|
12
|
-
import {
|
|
13
|
-
require_src
|
|
14
|
-
} from "./cli-knd276ed.js";
|
|
15
12
|
import {
|
|
16
13
|
exports_supports_color,
|
|
17
14
|
init_supports_color
|
|
18
15
|
} from "./cli-bd957dgb.js";
|
|
16
|
+
import {
|
|
17
|
+
require_src
|
|
18
|
+
} from "./cli-knd276ed.js";
|
|
19
19
|
import {
|
|
20
20
|
__commonJS,
|
|
21
21
|
__require,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
AssistantMessageEventStream,
|
|
13
13
|
appendAssistantMessageDiagnostic,
|
|
14
14
|
createAssistantMessageDiagnostic
|
|
15
|
-
} from "./cli-
|
|
15
|
+
} from "./cli-bzr0ftht.js";
|
|
16
16
|
import"./cli-bc05qbss.js";
|
|
17
17
|
|
|
18
18
|
// node_modules/@earendil-works/pi-ai/dist/api/pi-messages.js
|
|
@@ -56,8 +56,8 @@ function createPiMessagesResponseError(model, url, response, body) {
|
|
|
56
56
|
url: url.toString(),
|
|
57
57
|
status: response.status,
|
|
58
58
|
statusText: response.statusText,
|
|
59
|
-
error: errorBody
|
|
60
|
-
|
|
59
|
+
...errorBody?.error === undefined ? {} : { error: errorBody.error },
|
|
60
|
+
...errorBody ? {} : { body: truncateDiagnosticString(body) },
|
|
61
61
|
timestampMs: Date.now()
|
|
62
62
|
});
|
|
63
63
|
}
|