@opencow-ai/opencow-agent-sdk 0.4.11 → 0.4.13
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/capabilities/adapters/callToolResultAdapter.d.ts +8 -0
- package/dist/capabilities/tools/FileReadTool/FileReadTool.d.ts +8 -0
- package/dist/cli.mjs +197 -128
- package/dist/client.js +198 -121
- package/dist/controller/compact/autoCompact.d.ts +4 -0
- package/dist/controller/loop.d.ts +1 -0
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +41 -4
- package/dist/providers/codex/shim.d.ts +3 -3
- package/dist/providers/openai/shim.d.ts +8 -19
- package/dist/providers/shared/config.d.ts +4 -3
- package/dist/providers/shared/model/maxTokens.d.ts +1 -0
- package/dist/providers/shared/routing.d.ts +3 -1
- package/dist/query.d.ts +1 -0
- package/dist/sdk.js +198 -121
- package/dist/session/canonical/imageSource.d.ts +37 -0
- package/dist/session/canonical/index.d.ts +2 -1
- package/dist/session/canonical/types.d.ts +5 -1
- package/dist/types/toolRuntime.d.ts +24 -0
- package/package.json +1 -1
package/dist/sdk.js
CHANGED
|
@@ -31267,6 +31267,27 @@ var init_types3 = __esm(() => {
|
|
|
31267
31267
|
CanonicalUserAbortError = APIUserAbortError;
|
|
31268
31268
|
});
|
|
31269
31269
|
|
|
31270
|
+
// src/session/canonical/imageSource.ts
|
|
31271
|
+
function normalizeCanonicalImageSource(source) {
|
|
31272
|
+
if (!source || typeof source !== "object")
|
|
31273
|
+
return null;
|
|
31274
|
+
const s = source;
|
|
31275
|
+
if (s.type === "base64" && typeof s.data === "string") {
|
|
31276
|
+
return {
|
|
31277
|
+
kind: "base64",
|
|
31278
|
+
mediaType: typeof s.media_type === "string" ? s.media_type : "image/png",
|
|
31279
|
+
data: s.data
|
|
31280
|
+
};
|
|
31281
|
+
}
|
|
31282
|
+
if (s.type === "url" && typeof s.url === "string") {
|
|
31283
|
+
return { kind: "url", url: s.url };
|
|
31284
|
+
}
|
|
31285
|
+
return null;
|
|
31286
|
+
}
|
|
31287
|
+
function imageSourceToDataUri(img) {
|
|
31288
|
+
return img.kind === "base64" ? `data:${img.mediaType};base64,${img.data}` : img.url;
|
|
31289
|
+
}
|
|
31290
|
+
|
|
31270
31291
|
// src/session/canonical/index.ts
|
|
31271
31292
|
var init_canonical = __esm(() => {
|
|
31272
31293
|
init_types3();
|
|
@@ -34930,7 +34951,7 @@ function parseReasoningEffort(value) {
|
|
|
34930
34951
|
if (!value)
|
|
34931
34952
|
return;
|
|
34932
34953
|
const normalized = value.trim().toLowerCase();
|
|
34933
|
-
if (normalized === "low" || normalized === "medium" || normalized === "high" || normalized === "xhigh") {
|
|
34954
|
+
if (normalized === "none" || normalized === "minimal" || normalized === "low" || normalized === "medium" || normalized === "high" || normalized === "xhigh") {
|
|
34934
34955
|
return normalized;
|
|
34935
34956
|
}
|
|
34936
34957
|
return;
|
|
@@ -35051,7 +35072,10 @@ function resolveProviderRequest(options) {
|
|
|
35051
35072
|
transportOverride: options?.transportOverride
|
|
35052
35073
|
});
|
|
35053
35074
|
const resolvedModel = transport === "chat_completions" && isEnvTruthy(getQueryEnvVar("CLAUDE_CODE_USE_GITHUB")) ? normalizeGithubModelsApiModel(requestedModel) : descriptor.baseModel;
|
|
35054
|
-
const
|
|
35075
|
+
const hasReasoningEffortOverride = !!options && Object.prototype.hasOwnProperty.call(options, "reasoningEffortOverride");
|
|
35076
|
+
const rawEnvReasoningEffortOverride = getQueryEnvVar(QUERY_ENV_KEY_REASONING_EFFORT_OVERRIDE);
|
|
35077
|
+
const envReasoningEffortOverride = parseReasoningEffort(rawEnvReasoningEffortOverride);
|
|
35078
|
+
const reasoning = hasReasoningEffortOverride ? options?.reasoningEffortOverride ? { effort: options.reasoningEffortOverride } : undefined : rawEnvReasoningEffortOverride === QUERY_ENV_VALUE_REASONING_EFFORT_CLEAR ? undefined : envReasoningEffortOverride ? { effort: envReasoningEffortOverride } : descriptor.reasoning;
|
|
35055
35079
|
return {
|
|
35056
35080
|
transport,
|
|
35057
35081
|
requestedModel,
|
|
@@ -35155,7 +35179,7 @@ function resolveCodexApiCredentials(env2 = process.env) {
|
|
|
35155
35179
|
originator: "opencow"
|
|
35156
35180
|
};
|
|
35157
35181
|
}
|
|
35158
|
-
var DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1", DEFAULT_CODEX_BASE_URL = "https://chatgpt.com/backend-api/codex", DEFAULT_GITHUB_MODELS_API_MODEL = "openai/gpt-4.1", CODEX_ALIAS_MODELS, QUERY_ENV_KEY_TRANSPORT_OVERRIDE = "__OPENCOW_TRANSPORT_OVERRIDE", QUERY_ENV_KEY_PROVIDER_SPECIFIC_OPENAI_RESPONSES = "__OPENCOW_PROVIDER_SPECIFIC_OPENAI_RESPONSES", LOCALHOST_HOSTNAMES, warnedCodexAliasOnce = false, MissingProviderModelError;
|
|
35182
|
+
var DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1", DEFAULT_CODEX_BASE_URL = "https://chatgpt.com/backend-api/codex", DEFAULT_GITHUB_MODELS_API_MODEL = "openai/gpt-4.1", CODEX_ALIAS_MODELS, QUERY_ENV_KEY_TRANSPORT_OVERRIDE = "__OPENCOW_TRANSPORT_OVERRIDE", QUERY_ENV_KEY_REASONING_EFFORT_OVERRIDE = "__OPENCOW_REASONING_EFFORT_OVERRIDE", QUERY_ENV_VALUE_REASONING_EFFORT_CLEAR = "__OPENCOW_CLEAR_REASONING_EFFORT__", QUERY_ENV_KEY_PROVIDER_SPECIFIC_OPENAI_RESPONSES = "__OPENCOW_PROVIDER_SPECIFIC_OPENAI_RESPONSES", LOCALHOST_HOSTNAMES, warnedCodexAliasOnce = false, MissingProviderModelError;
|
|
35159
35183
|
var init_config2 = __esm(() => {
|
|
35160
35184
|
init_envUtils();
|
|
35161
35185
|
init_state2();
|
|
@@ -95407,19 +95431,9 @@ function splitToolResultMedia(content) {
|
|
|
95407
95431
|
continue;
|
|
95408
95432
|
}
|
|
95409
95433
|
if (block?.type === "image") {
|
|
95410
|
-
const
|
|
95411
|
-
if (
|
|
95412
|
-
images.push(
|
|
95413
|
-
kind: "base64",
|
|
95414
|
-
mediaType: src.media_type ?? "image/png",
|
|
95415
|
-
data: src.data
|
|
95416
|
-
});
|
|
95417
|
-
continue;
|
|
95418
|
-
}
|
|
95419
|
-
if (src?.type === "url" && typeof src.url === "string") {
|
|
95420
|
-
images.push({ kind: "url", url: src.url });
|
|
95421
|
-
continue;
|
|
95422
|
-
}
|
|
95434
|
+
const img = normalizeCanonicalImageSource(block.source);
|
|
95435
|
+
if (img)
|
|
95436
|
+
images.push(img);
|
|
95423
95437
|
continue;
|
|
95424
95438
|
}
|
|
95425
95439
|
if (typeof block?.text === "string") {
|
|
@@ -95430,8 +95444,7 @@ function splitToolResultMedia(content) {
|
|
|
95430
95444
|
`), images };
|
|
95431
95445
|
}
|
|
95432
95446
|
function toResponsesInputImagePart(img) {
|
|
95433
|
-
|
|
95434
|
-
return { type: "input_image", image_url: url3 };
|
|
95447
|
+
return { type: "input_image", image_url: imageSourceToDataUri(img) };
|
|
95435
95448
|
}
|
|
95436
95449
|
function convertContentBlocksToResponsesParts(content, role) {
|
|
95437
95450
|
const textType = role === "assistant" ? "output_text" : "input_text";
|
|
@@ -95450,18 +95463,9 @@ function convertContentBlocksToResponsesParts(content, role) {
|
|
|
95450
95463
|
case "image": {
|
|
95451
95464
|
if (role === "assistant")
|
|
95452
95465
|
break;
|
|
95453
|
-
const
|
|
95454
|
-
if (
|
|
95455
|
-
parts.push(
|
|
95456
|
-
type: "input_image",
|
|
95457
|
-
image_url: `data:${source.media_type};base64,${source.data}`
|
|
95458
|
-
});
|
|
95459
|
-
} else if (source?.type === "url" && source.url) {
|
|
95460
|
-
parts.push({
|
|
95461
|
-
type: "input_image",
|
|
95462
|
-
image_url: source.url
|
|
95463
|
-
});
|
|
95464
|
-
}
|
|
95466
|
+
const img = normalizeCanonicalImageSource(block.source);
|
|
95467
|
+
if (img)
|
|
95468
|
+
parts.push(toResponsesInputImagePart(img));
|
|
95465
95469
|
break;
|
|
95466
95470
|
}
|
|
95467
95471
|
case "thinking":
|
|
@@ -96049,6 +96053,7 @@ var init_shim = __esm(() => {
|
|
|
96049
96053
|
init_sdk();
|
|
96050
96054
|
init_schema();
|
|
96051
96055
|
init_capabilities2();
|
|
96056
|
+
init_canonical();
|
|
96052
96057
|
});
|
|
96053
96058
|
|
|
96054
96059
|
// src/providers/shared/providerRecommendation.ts
|
|
@@ -96191,19 +96196,9 @@ function splitToolResultMedia2(content) {
|
|
|
96191
96196
|
continue;
|
|
96192
96197
|
}
|
|
96193
96198
|
if (block?.type === "image") {
|
|
96194
|
-
const
|
|
96195
|
-
if (
|
|
96196
|
-
images.push(
|
|
96197
|
-
kind: "base64",
|
|
96198
|
-
mediaType: source.media_type ?? "image/png",
|
|
96199
|
-
data: source.data
|
|
96200
|
-
});
|
|
96201
|
-
continue;
|
|
96202
|
-
}
|
|
96203
|
-
if (source?.type === "url" && typeof source.url === "string") {
|
|
96204
|
-
images.push({ kind: "url", url: source.url });
|
|
96205
|
-
continue;
|
|
96206
|
-
}
|
|
96199
|
+
const img = normalizeCanonicalImageSource(block.source);
|
|
96200
|
+
if (img)
|
|
96201
|
+
images.push(img);
|
|
96207
96202
|
continue;
|
|
96208
96203
|
}
|
|
96209
96204
|
if (block?.type === "tool_reference" && typeof block.tool_name === "string") {
|
|
@@ -96218,8 +96213,7 @@ function splitToolResultMedia2(content) {
|
|
|
96218
96213
|
`), images };
|
|
96219
96214
|
}
|
|
96220
96215
|
function toOpenAIImageUrl(img) {
|
|
96221
|
-
|
|
96222
|
-
return { type: "image_url", image_url: { url: url3 } };
|
|
96216
|
+
return { type: "image_url", image_url: { url: imageSourceToDataUri(img) } };
|
|
96223
96217
|
}
|
|
96224
96218
|
function convertContentBlocks(content) {
|
|
96225
96219
|
if (typeof content === "string")
|
|
@@ -96233,17 +96227,9 @@ function convertContentBlocks(content) {
|
|
|
96233
96227
|
parts.push({ type: "text", text: block.text ?? "" });
|
|
96234
96228
|
break;
|
|
96235
96229
|
case "image": {
|
|
96236
|
-
const
|
|
96237
|
-
if (
|
|
96238
|
-
parts.push(
|
|
96239
|
-
type: "image_url",
|
|
96240
|
-
image_url: {
|
|
96241
|
-
url: `data:${src.media_type};base64,${src.data}`
|
|
96242
|
-
}
|
|
96243
|
-
});
|
|
96244
|
-
} else if (src?.type === "url") {
|
|
96245
|
-
parts.push({ type: "image_url", image_url: { url: src.url } });
|
|
96246
|
-
}
|
|
96230
|
+
const img = normalizeCanonicalImageSource(block.source);
|
|
96231
|
+
if (img)
|
|
96232
|
+
parts.push(toOpenAIImageUrl(img));
|
|
96247
96233
|
break;
|
|
96248
96234
|
}
|
|
96249
96235
|
case "tool_use":
|
|
@@ -96402,7 +96388,7 @@ function convertChunkUsage(usage) {
|
|
|
96402
96388
|
return openaiUsageToAnthropicUsage(usage);
|
|
96403
96389
|
}
|
|
96404
96390
|
function toOpenAIChatReasoningEffort(effort) {
|
|
96405
|
-
return effort
|
|
96391
|
+
return effort;
|
|
96406
96392
|
}
|
|
96407
96393
|
function getOpenAIChatProviderCapabilities(model) {
|
|
96408
96394
|
return {
|
|
@@ -96847,7 +96833,14 @@ class OpenAIShimMessages {
|
|
|
96847
96833
|
let httpResponse;
|
|
96848
96834
|
const promise3 = (async () => {
|
|
96849
96835
|
const overrideTransport = self2.providerOverride?.transport === "anthropic" ? undefined : self2.providerOverride?.transport;
|
|
96850
|
-
const
|
|
96836
|
+
const hasProviderReasoningEffortOverride = !!self2.providerOverride && Object.prototype.hasOwnProperty.call(self2.providerOverride, "reasoningEffort");
|
|
96837
|
+
const reasoningEffortOverride = hasProviderReasoningEffortOverride ? self2.providerOverride?.reasoningEffort ?? null : self2.reasoningEffort;
|
|
96838
|
+
const request = resolveProviderRequest({
|
|
96839
|
+
model: self2.providerOverride?.model ?? params.model,
|
|
96840
|
+
baseUrl: self2.providerOverride?.baseURL,
|
|
96841
|
+
...reasoningEffortOverride !== undefined ? { reasoningEffortOverride } : {},
|
|
96842
|
+
transportOverride: overrideTransport
|
|
96843
|
+
});
|
|
96851
96844
|
const response = await self2._doRequest(request, params, options);
|
|
96852
96845
|
httpResponse = response;
|
|
96853
96846
|
if (params.stream) {
|
|
@@ -97120,6 +97113,7 @@ var init_shim2 = __esm(() => {
|
|
|
97120
97113
|
init_schemaSanitizer();
|
|
97121
97114
|
init_providerProfile();
|
|
97122
97115
|
init_capabilities2();
|
|
97116
|
+
init_canonical();
|
|
97123
97117
|
OpenAIShimStream = class OpenAIShimStream {
|
|
97124
97118
|
generator;
|
|
97125
97119
|
controller = new AbortController;
|
|
@@ -130236,15 +130230,16 @@ function isMaxTokensCapEnabled() {
|
|
|
130236
130230
|
}
|
|
130237
130231
|
function getMaxOutputTokensForModel(model, opts) {
|
|
130238
130232
|
const maxOutputTokens = getModelMaxOutputTokens(model);
|
|
130239
|
-
const
|
|
130233
|
+
const upperLimit = opts?.upperLimitOverride !== undefined && Number.isFinite(opts.upperLimitOverride) && opts.upperLimitOverride >= 1 ? Math.floor(opts.upperLimitOverride) : maxOutputTokens.upperLimit;
|
|
130234
|
+
const defaultTokens = isMaxTokensCapEnabled() ? Math.min(maxOutputTokens.default, CAPPED_DEFAULT_MAX_TOKENS, upperLimit) : Math.min(maxOutputTokens.default, upperLimit);
|
|
130240
130235
|
if (opts?.override !== undefined) {
|
|
130241
|
-
if (!Number.isFinite(opts.override) || opts.override < 1 || opts.override >
|
|
130242
|
-
console.warn(`[opencow] Options.maxOutputTokens=${opts.override} out of range ` + `[1, ${
|
|
130236
|
+
if (!Number.isFinite(opts.override) || opts.override < 1 || opts.override > upperLimit) {
|
|
130237
|
+
console.warn(`[opencow] Options.maxOutputTokens=${opts.override} out of range ` + `[1, ${upperLimit}] for model ${model}; clamping.`);
|
|
130243
130238
|
}
|
|
130244
|
-
const clamped = Math.min(Math.max(1, Math.floor(opts.override)),
|
|
130239
|
+
const clamped = Math.min(Math.max(1, Math.floor(opts.override)), upperLimit);
|
|
130245
130240
|
return clamped;
|
|
130246
130241
|
}
|
|
130247
|
-
const result = validateBoundedIntEnvVar("CLAUDE_CODE_MAX_OUTPUT_TOKENS", resolveEnvVar("MAX_OUTPUT_TOKENS"), defaultTokens,
|
|
130242
|
+
const result = validateBoundedIntEnvVar("CLAUDE_CODE_MAX_OUTPUT_TOKENS", resolveEnvVar("MAX_OUTPUT_TOKENS"), defaultTokens, upperLimit);
|
|
130248
130243
|
return result.effective;
|
|
130249
130244
|
}
|
|
130250
130245
|
var init_maxTokens = __esm(() => {
|
|
@@ -255986,6 +255981,13 @@ function getDisableExtglobCommand(shellPath) {
|
|
|
255986
255981
|
}
|
|
255987
255982
|
return null;
|
|
255988
255983
|
}
|
|
255984
|
+
function getHostProvidedPathCommand() {
|
|
255985
|
+
const path11 = getHostProvidedEnvVar("PATH");
|
|
255986
|
+
if (!path11) {
|
|
255987
|
+
return null;
|
|
255988
|
+
}
|
|
255989
|
+
return `export PATH=${quote([path11])}`;
|
|
255990
|
+
}
|
|
255989
255991
|
async function createBashShellProvider(shellPath, options2) {
|
|
255990
255992
|
let currentSandboxTmpDir;
|
|
255991
255993
|
const snapshotPromise = options2?.skipSnapshot ? Promise.resolve(undefined) : createAndSaveSnapshot(shellPath).catch((error41) => {
|
|
@@ -256026,6 +256028,10 @@ async function createBashShellProvider(shellPath, options2) {
|
|
|
256026
256028
|
const finalPath = getPlatform() === "windows" ? windowsPathToPosixPath(snapshotFilePath) : snapshotFilePath;
|
|
256027
256029
|
commandParts.push(`source ${quote([finalPath])} 2>/dev/null || true`);
|
|
256028
256030
|
}
|
|
256031
|
+
const hostPathCommand = getHostProvidedPathCommand();
|
|
256032
|
+
if (hostPathCommand) {
|
|
256033
|
+
commandParts.push(hostPathCommand);
|
|
256034
|
+
}
|
|
256029
256035
|
const sessionEnvScript2 = await getSessionEnvironmentScript();
|
|
256030
256036
|
if (sessionEnvScript2) {
|
|
256031
256037
|
commandParts.push(sessionEnvScript2);
|
|
@@ -273622,9 +273628,21 @@ var init_mcpWebSocketTransport = __esm(() => {
|
|
|
273622
273628
|
});
|
|
273623
273629
|
|
|
273624
273630
|
// src/capabilities/adapters/callToolResultAdapter.ts
|
|
273631
|
+
async function buildImageBlock(bytes, mediaType, uploadMedia) {
|
|
273632
|
+
let url3 = null;
|
|
273633
|
+
if (uploadMedia) {
|
|
273634
|
+
try {
|
|
273635
|
+
url3 = await uploadMedia({ bytes, mediaType });
|
|
273636
|
+
} catch (e) {
|
|
273637
|
+
logError(e);
|
|
273638
|
+
}
|
|
273639
|
+
}
|
|
273640
|
+
const source = url3 ? { type: "url", url: url3 } : { type: "base64", media_type: mediaType, data: bytes.toString("base64") };
|
|
273641
|
+
return { type: "image", source };
|
|
273642
|
+
}
|
|
273625
273643
|
async function translateMcpContentItem(input) {
|
|
273626
273644
|
const { item, options: options2 } = input;
|
|
273627
|
-
const { sourceName } = options2;
|
|
273645
|
+
const { sourceName, uploadMedia } = options2;
|
|
273628
273646
|
switch (item.type) {
|
|
273629
273647
|
case "text":
|
|
273630
273648
|
return [{ type: "text", text: item.text }];
|
|
@@ -273642,14 +273660,7 @@ async function translateMcpContentItem(input) {
|
|
|
273642
273660
|
const ext = item.mimeType?.split("/")[1] || "png";
|
|
273643
273661
|
const resized = await maybeResizeAndDownsampleImageBuffer(imageBuffer, imageBuffer.length, ext);
|
|
273644
273662
|
return [
|
|
273645
|
-
{
|
|
273646
|
-
type: "image",
|
|
273647
|
-
source: {
|
|
273648
|
-
data: resized.buffer.toString("base64"),
|
|
273649
|
-
media_type: `image/${resized.mediaType}`,
|
|
273650
|
-
type: "base64"
|
|
273651
|
-
}
|
|
273652
|
-
}
|
|
273663
|
+
await buildImageBlock(resized.buffer, `image/${resized.mediaType}`, uploadMedia)
|
|
273653
273664
|
];
|
|
273654
273665
|
}
|
|
273655
273666
|
case "resource": {
|
|
@@ -273666,14 +273677,7 @@ async function translateMcpContentItem(input) {
|
|
|
273666
273677
|
const resized = await maybeResizeAndDownsampleImageBuffer(imageBuffer, imageBuffer.length, ext);
|
|
273667
273678
|
return [
|
|
273668
273679
|
{ type: "text", text: prefix },
|
|
273669
|
-
{
|
|
273670
|
-
type: "image",
|
|
273671
|
-
source: {
|
|
273672
|
-
data: resized.buffer.toString("base64"),
|
|
273673
|
-
media_type: `image/${resized.mediaType}`,
|
|
273674
|
-
type: "base64"
|
|
273675
|
-
}
|
|
273676
|
-
}
|
|
273680
|
+
await buildImageBlock(resized.buffer, `image/${resized.mediaType}`, uploadMedia)
|
|
273677
273681
|
];
|
|
273678
273682
|
}
|
|
273679
273683
|
return await persistBlobToTextBlock({
|
|
@@ -273727,6 +273731,7 @@ var IMAGE_MIME_TYPES;
|
|
|
273727
273731
|
var init_callToolResultAdapter = __esm(() => {
|
|
273728
273732
|
init_imageResizer();
|
|
273729
273733
|
init_mcpOutputStorage();
|
|
273734
|
+
init_log2();
|
|
273730
273735
|
IMAGE_MIME_TYPES = new Set([
|
|
273731
273736
|
"image/jpeg",
|
|
273732
273737
|
"image/png",
|
|
@@ -281974,7 +281979,11 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
281974
281979
|
if (false) {}
|
|
281975
281980
|
const mediaRecoveryEnabled = reactiveCompact?.isReactiveCompactEnabled() ?? false;
|
|
281976
281981
|
if (!compactionResult && querySource !== "compact" && querySource !== "session_memory" && !(reactiveCompact?.isReactiveCompactEnabled() && isAutoCompactEnabled()) && !collapseOwnsIt) {
|
|
281977
|
-
const { isAtBlockingLimit } = calculateTokenWarningState(tokenCountWithEstimation(messagesForQuery) - snipTokensFreed, toolUseContext.options.mainLoopModel
|
|
281982
|
+
const { isAtBlockingLimit } = calculateTokenWarningState(tokenCountWithEstimation(messagesForQuery) - snipTokensFreed, toolUseContext.options.mainLoopModel, {
|
|
281983
|
+
contextWindow: toolUseContext.options.contextWindow,
|
|
281984
|
+
maxOutputTokens: toolUseContext.options.maxOutputTokens,
|
|
281985
|
+
maxOutputTokensLimit: toolUseContext.options.maxOutputTokensLimit
|
|
281986
|
+
});
|
|
281978
281987
|
if (isAtBlockingLimit) {
|
|
281979
281988
|
yield createAssistantAPIErrorMessage({
|
|
281980
281989
|
content: PROMPT_TOO_LONG_ERROR_MESSAGE,
|
|
@@ -282017,6 +282026,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
282017
282026
|
allowedAgentTypes: toolUseContext.options.agentDefinitions.allowedAgentTypes,
|
|
282018
282027
|
hasAppendSystemPrompt: !!toolUseContext.options.appendSystemPrompt,
|
|
282019
282028
|
maxOutputTokensOverride,
|
|
282029
|
+
maxOutputTokensLimitOverride: params.maxOutputTokensLimitOverride,
|
|
282020
282030
|
fetchOverride: dumpPromptsFetch,
|
|
282021
282031
|
mcpTools: appState.mcp.tools,
|
|
282022
282032
|
hasPendingMcpServers: appState.mcp.clients.some((c6) => c6.type === "pending"),
|
|
@@ -282692,7 +282702,7 @@ function getAnthropicEnvMetadata() {
|
|
|
282692
282702
|
function getBuildAgeMinutes() {
|
|
282693
282703
|
if (false)
|
|
282694
282704
|
;
|
|
282695
|
-
const buildTime = new Date("2026-06-
|
|
282705
|
+
const buildTime = new Date("2026-06-25T12:29:02.938Z").getTime();
|
|
282696
282706
|
if (isNaN(buildTime))
|
|
282697
282707
|
return;
|
|
282698
282708
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -283274,6 +283284,7 @@ async function runForkedAgent({
|
|
|
283274
283284
|
toolUseContext: isolatedToolUseContext,
|
|
283275
283285
|
querySource,
|
|
283276
283286
|
maxOutputTokensOverride: maxOutputTokens,
|
|
283287
|
+
maxOutputTokensLimitOverride: isolatedToolUseContext.options.maxOutputTokensLimit,
|
|
283277
283288
|
maxTurns,
|
|
283278
283289
|
skipCacheWrite
|
|
283279
283290
|
})) {
|
|
@@ -283512,7 +283523,17 @@ ${formattedSummary}`;
|
|
|
283512
283523
|
if (transcriptPath) {
|
|
283513
283524
|
baseSummary += `
|
|
283514
283525
|
|
|
283515
|
-
|
|
283526
|
+
IMPORTANT — Transcript recovery protocol:
|
|
283527
|
+
The full pre-compaction conversation is preserved at: ${transcriptPath}
|
|
283528
|
+
When you encounter ANY of these situations, you MUST use the Read tool to search the transcript for the missing context BEFORE responding:
|
|
283529
|
+
- You are unsure about a specific detail (file path, function name, error message, code snippet, user preference)
|
|
283530
|
+
- The user references something you cannot find in the summary above
|
|
283531
|
+
- You need exact code that was previously read or written
|
|
283532
|
+
- You are about to make a decision but feel uncertain whether the user already gave guidance on it
|
|
283533
|
+
- A tool name, skill name, or configuration was discussed but is not in the summary
|
|
283534
|
+
|
|
283535
|
+
The transcript is a JSONL file. Read its tail (last 500–2000 lines) first for the most recent context; if that doesn't resolve the gap, read earlier sections.
|
|
283536
|
+
Do NOT guess or hallucinate details that might have been discussed — read the transcript instead.`;
|
|
283516
283537
|
}
|
|
283517
283538
|
if (recentMessagesPreserved) {
|
|
283518
283539
|
baseSummary += `
|
|
@@ -283579,6 +283600,7 @@ Your summary should include the following sections:
|
|
|
283579
283600
|
8. Current Work: Describe in detail precisely what was being worked on immediately before this summary request, paying special attention to the most recent messages from both user and assistant. Include file names and code snippets where applicable.
|
|
283580
283601
|
9. Optional Next Step: List the next step that you will take that is related to the most recent work you were doing. IMPORTANT: ensure that this step is DIRECTLY in line with the user's most recent explicit requests, and the task you were working on immediately before this summary request. If your last task was concluded, then only list next steps if they are explicitly in line with the users request. Do not start on tangential requests or really old requests that were already completed without confirming with the user first.
|
|
283581
283602
|
If there is a next step, include direct quotes from the most recent conversation showing exactly what task you were working on and where you left off. This should be verbatim to ensure there's no drift in task interpretation.
|
|
283603
|
+
10. Uncertain or Incomplete Context: List any items where you are not fully confident in the details — e.g., a tool/skill name you vaguely recall but cannot confirm, a user preference you think was stated but cannot pinpoint, or a decision whose rationale is unclear. Mark each with [NEEDS_TRANSCRIPT_LOOKUP] so the post-compaction assistant knows to read the transcript file for these specific items before acting on them.
|
|
283582
283604
|
|
|
283583
283605
|
Here's an example of how your output should be structured:
|
|
283584
283606
|
|
|
@@ -283629,10 +283651,14 @@ Here's an example of how your output should be structured:
|
|
|
283629
283651
|
9. Optional Next Step:
|
|
283630
283652
|
[Optional Next step to take]
|
|
283631
283653
|
|
|
283654
|
+
10. Uncertain or Incomplete Context:
|
|
283655
|
+
- [Item with unclear details] [NEEDS_TRANSCRIPT_LOOKUP]
|
|
283656
|
+
- [...]
|
|
283657
|
+
|
|
283632
283658
|
</summary>
|
|
283633
283659
|
</example>
|
|
283634
283660
|
|
|
283635
|
-
Please provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response.
|
|
283661
|
+
Please provide your summary based on the conversation so far, following this structure and ensuring precision and thoroughness in your response.
|
|
283636
283662
|
|
|
283637
283663
|
There may be additional summarization instructions provided in the included context. If so, remember to follow these instructions when creating the above summary. Examples of instructions include:
|
|
283638
283664
|
<example>
|
|
@@ -283660,6 +283686,7 @@ Your summary should include the following sections:
|
|
|
283660
283686
|
7. Pending Tasks: Outline any pending tasks from the recent messages.
|
|
283661
283687
|
8. Current Work: Describe precisely what was being worked on immediately before this summary request.
|
|
283662
283688
|
9. Optional Next Step: List the next step related to the most recent work. Include direct quotes from the most recent conversation.
|
|
283689
|
+
10. Uncertain or Incomplete Context: List any items where details are unclear or potentially missing from the recent messages. Mark each with [NEEDS_TRANSCRIPT_LOOKUP].
|
|
283663
283690
|
|
|
283664
283691
|
Here's an example of how your output should be structured:
|
|
283665
283692
|
|
|
@@ -283700,6 +283727,9 @@ Here's an example of how your output should be structured:
|
|
|
283700
283727
|
9. Optional Next Step:
|
|
283701
283728
|
[Optional Next step to take]
|
|
283702
283729
|
|
|
283730
|
+
10. Uncertain or Incomplete Context:
|
|
283731
|
+
- [Item with unclear details] [NEEDS_TRANSCRIPT_LOOKUP]
|
|
283732
|
+
|
|
283703
283733
|
</summary>
|
|
283704
283734
|
</example>
|
|
283705
283735
|
|
|
@@ -283720,6 +283750,7 @@ Your summary should include the following sections:
|
|
|
283720
283750
|
7. Pending Tasks: Outline any pending tasks.
|
|
283721
283751
|
8. Work Completed: Describe what was accomplished by the end of this portion.
|
|
283722
283752
|
9. Context for Continuing Work: Summarize any context, decisions, or state that would be needed to understand and continue the work in subsequent messages.
|
|
283753
|
+
10. Uncertain or Incomplete Context: List any items where details are unclear or potentially incomplete. Mark each with [NEEDS_TRANSCRIPT_LOOKUP] so the continuing session knows to look them up in the transcript before acting.
|
|
283723
283754
|
|
|
283724
283755
|
Here's an example of how your output should be structured:
|
|
283725
283756
|
|
|
@@ -283760,6 +283791,9 @@ Here's an example of how your output should be structured:
|
|
|
283760
283791
|
9. Context for Continuing Work:
|
|
283761
283792
|
[Key context, decisions, or state needed to continue the work]
|
|
283762
283793
|
|
|
283794
|
+
10. Uncertain or Incomplete Context:
|
|
283795
|
+
- [Item with unclear details] [NEEDS_TRANSCRIPT_LOOKUP]
|
|
283796
|
+
|
|
283763
283797
|
</summary>
|
|
283764
283798
|
</example>
|
|
283765
283799
|
|
|
@@ -284211,7 +284245,10 @@ async function streamCompactSummary({
|
|
|
284211
284245
|
toolChoice: undefined,
|
|
284212
284246
|
isNonInteractiveSession: context4.options.isNonInteractiveSession,
|
|
284213
284247
|
hasAppendSystemPrompt: !!context4.options.appendSystemPrompt,
|
|
284214
|
-
maxOutputTokensOverride: Math.min(COMPACT_MAX_OUTPUT_TOKENS, getMaxOutputTokensForModel(context4.options.mainLoopModel
|
|
284248
|
+
maxOutputTokensOverride: Math.min(COMPACT_MAX_OUTPUT_TOKENS, getMaxOutputTokensForModel(context4.options.mainLoopModel, {
|
|
284249
|
+
upperLimitOverride: context4.options.maxOutputTokensLimit
|
|
284250
|
+
})),
|
|
284251
|
+
maxOutputTokensLimitOverride: context4.options.maxOutputTokensLimit,
|
|
284215
284252
|
querySource: "compact",
|
|
284216
284253
|
agents: context4.options.agentDefinitions.activeAgents,
|
|
284217
284254
|
mcpTools: [],
|
|
@@ -284945,7 +284982,10 @@ var init_sessionMemoryCompact = __esm(() => {
|
|
|
284945
284982
|
|
|
284946
284983
|
// src/controller/compact/autoCompact.ts
|
|
284947
284984
|
function getEffectiveContextWindowSize(model, opts) {
|
|
284948
|
-
const reservedTokensForSummary = Math.min(getMaxOutputTokensForModel(model, {
|
|
284985
|
+
const reservedTokensForSummary = Math.min(getMaxOutputTokensForModel(model, {
|
|
284986
|
+
override: opts?.maxOutputTokens,
|
|
284987
|
+
upperLimitOverride: opts?.maxOutputTokensLimit
|
|
284988
|
+
}), MAX_OUTPUT_TOKENS_FOR_SUMMARY);
|
|
284949
284989
|
let contextWindow = getContextWindowForModel(model, getSdkBetas(), {
|
|
284950
284990
|
override: opts?.contextWindow
|
|
284951
284991
|
});
|
|
@@ -285031,7 +285071,8 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
|
|
|
285031
285071
|
const model = toolUseContext.options.mainLoopModel;
|
|
285032
285072
|
const opts = {
|
|
285033
285073
|
contextWindow: toolUseContext.options.contextWindow,
|
|
285034
|
-
maxOutputTokens: toolUseContext.options.maxOutputTokens
|
|
285074
|
+
maxOutputTokens: toolUseContext.options.maxOutputTokens,
|
|
285075
|
+
maxOutputTokensLimit: toolUseContext.options.maxOutputTokensLimit
|
|
285035
285076
|
};
|
|
285036
285077
|
const shouldCompact = await shouldAutoCompact(messages, model, querySource, snipTokensFreed, opts);
|
|
285037
285078
|
if (!shouldCompact) {
|
|
@@ -286016,6 +286057,16 @@ async function validateContentTokens(content, ext, maxTokens) {
|
|
|
286016
286057
|
throw new MaxFileReadTokenExceededError(effectiveCount, effectiveMaxTokens);
|
|
286017
286058
|
}
|
|
286018
286059
|
}
|
|
286060
|
+
async function maybeUploadBytes(uploadMedia, bytes, mediaType) {
|
|
286061
|
+
if (!uploadMedia)
|
|
286062
|
+
return null;
|
|
286063
|
+
try {
|
|
286064
|
+
return await uploadMedia({ bytes, mediaType });
|
|
286065
|
+
} catch (e) {
|
|
286066
|
+
logError(e);
|
|
286067
|
+
return null;
|
|
286068
|
+
}
|
|
286069
|
+
}
|
|
286019
286070
|
function createImageResponse(buffer, mediaType, originalSize, dimensions) {
|
|
286020
286071
|
return {
|
|
286021
286072
|
type: "image",
|
|
@@ -286063,6 +286114,10 @@ async function callInner(file_path, fullFilePath, resolvedFilePath, ext, offset,
|
|
|
286063
286114
|
if (IMAGE_EXTENSIONS.has(ext)) {
|
|
286064
286115
|
const data2 = await readImageWithTokenBudget(resolvedFilePath, maxTokens);
|
|
286065
286116
|
context4.nestedMemoryAttachmentTriggers?.add(fullFilePath);
|
|
286117
|
+
const uploadedUrl = await maybeUploadBytes(context4.uploadMedia, Buffer.from(data2.file.base64, "base64"), data2.file.type);
|
|
286118
|
+
if (uploadedUrl) {
|
|
286119
|
+
data2.file.url = uploadedUrl;
|
|
286120
|
+
}
|
|
286066
286121
|
logFileOperation({
|
|
286067
286122
|
operation: "read",
|
|
286068
286123
|
tool: "FileReadTool",
|
|
@@ -286104,14 +286159,14 @@ async function callInner(file_path, fullFilePath, resolvedFilePath, ext, offset,
|
|
|
286104
286159
|
const imgPath = path11.join(extractResult.data.file.outputDir, f);
|
|
286105
286160
|
const imgBuffer = await getFsImplementation().readFile(imgPath);
|
|
286106
286161
|
const resized = await maybeResizeAndDownsampleImageBuffer(imgBuffer, imgBuffer.length, "jpeg");
|
|
286107
|
-
|
|
286108
|
-
|
|
286109
|
-
|
|
286110
|
-
|
|
286111
|
-
|
|
286112
|
-
|
|
286113
|
-
}
|
|
286162
|
+
const mediaType = `image/${resized.mediaType}`;
|
|
286163
|
+
const uploadedUrl2 = await maybeUploadBytes(context4.uploadMedia, resized.buffer, mediaType);
|
|
286164
|
+
const source = uploadedUrl2 ? { type: "url", url: uploadedUrl2 } : {
|
|
286165
|
+
type: "base64",
|
|
286166
|
+
media_type: mediaType,
|
|
286167
|
+
data: resized.buffer.toString("base64")
|
|
286114
286168
|
};
|
|
286169
|
+
return { type: "image", source };
|
|
286115
286170
|
}));
|
|
286116
286171
|
return {
|
|
286117
286172
|
data: extractResult.data,
|
|
@@ -286159,20 +286214,17 @@ async function callInner(file_path, fullFilePath, resolvedFilePath, ext, offset,
|
|
|
286159
286214
|
filePath: fullFilePath,
|
|
286160
286215
|
content: pdfData.file.base64
|
|
286161
286216
|
});
|
|
286217
|
+
const uploadedUrl = await maybeUploadBytes(context4.uploadMedia, Buffer.from(pdfData.file.base64, "base64"), "application/pdf");
|
|
286218
|
+
const documentSource = uploadedUrl ? { type: "url", url: uploadedUrl } : {
|
|
286219
|
+
type: "base64",
|
|
286220
|
+
media_type: "application/pdf",
|
|
286221
|
+
data: pdfData.file.base64
|
|
286222
|
+
};
|
|
286162
286223
|
return {
|
|
286163
286224
|
data: pdfData,
|
|
286164
286225
|
newMessages: [
|
|
286165
286226
|
createUserMessage({
|
|
286166
|
-
content: [
|
|
286167
|
-
{
|
|
286168
|
-
type: "document",
|
|
286169
|
-
source: {
|
|
286170
|
-
type: "base64",
|
|
286171
|
-
media_type: "application/pdf",
|
|
286172
|
-
data: pdfData.file.base64
|
|
286173
|
-
}
|
|
286174
|
-
}
|
|
286175
|
-
],
|
|
286227
|
+
content: [{ type: "document", source: documentSource }],
|
|
286176
286228
|
isMeta: true
|
|
286177
286229
|
})
|
|
286178
286230
|
]
|
|
@@ -286379,6 +286431,7 @@ var init_FileReadTool = __esm(() => {
|
|
|
286379
286431
|
base64: exports_external2.string().describe("Base64-encoded image data"),
|
|
286380
286432
|
type: imageMediaTypes.describe("The MIME type of the image"),
|
|
286381
286433
|
originalSize: exports_external2.number().describe("Original file size in bytes"),
|
|
286434
|
+
url: exports_external2.string().optional().describe("Fetchable URL for the (compressed) image when a host uploader is configured; takes precedence over base64 for rendering"),
|
|
286382
286435
|
dimensions: exports_external2.object({
|
|
286383
286436
|
originalWidth: exports_external2.number().optional().describe("Original image width in pixels"),
|
|
286384
286437
|
originalHeight: exports_external2.number().optional().describe("Original image height in pixels"),
|
|
@@ -286607,17 +286660,18 @@ var init_FileReadTool = __esm(() => {
|
|
|
286607
286660
|
mapToolResultToToolResultBlockParam(data, toolUseID) {
|
|
286608
286661
|
switch (data.type) {
|
|
286609
286662
|
case "image": {
|
|
286663
|
+
const source = data.file.url ? { type: "url", url: data.file.url } : {
|
|
286664
|
+
type: "base64",
|
|
286665
|
+
data: data.file.base64,
|
|
286666
|
+
media_type: data.file.type
|
|
286667
|
+
};
|
|
286610
286668
|
return {
|
|
286611
286669
|
tool_use_id: toolUseID,
|
|
286612
286670
|
type: "tool_result",
|
|
286613
286671
|
content: [
|
|
286614
286672
|
{
|
|
286615
286673
|
type: "image",
|
|
286616
|
-
source
|
|
286617
|
-
type: "base64",
|
|
286618
|
-
data: data.file.base64,
|
|
286619
|
-
media_type: data.file.type
|
|
286620
|
-
}
|
|
286674
|
+
source
|
|
286621
286675
|
}
|
|
286622
286676
|
]
|
|
286623
286677
|
};
|
|
@@ -293772,7 +293826,10 @@ ${deferredToolList}
|
|
|
293772
293826
|
betasParams.push(STRUCTURED_OUTPUTS_BETA_HEADER);
|
|
293773
293827
|
}
|
|
293774
293828
|
}
|
|
293775
|
-
const maxOutputTokens2 = retryContext?.maxTokensOverride ||
|
|
293829
|
+
const maxOutputTokens2 = retryContext?.maxTokensOverride || getMaxOutputTokensForModel(options2.model, {
|
|
293830
|
+
override: options2.maxOutputTokensOverride,
|
|
293831
|
+
upperLimitOverride: options2.maxOutputTokensLimitOverride
|
|
293832
|
+
});
|
|
293776
293833
|
const hasThinking = thinkingConfig.type !== "disabled" && !isEnvTruthy(resolveEnvVar("DISABLE_THINKING"));
|
|
293777
293834
|
let thinking = undefined;
|
|
293778
293835
|
if (hasThinking && modelSupportsThinking(options2.model)) {
|
|
@@ -299734,8 +299791,10 @@ async function processUserInputBase(input, mode, setToolJSX, context4, pastedCon
|
|
|
299734
299791
|
}
|
|
299735
299792
|
}
|
|
299736
299793
|
}
|
|
299794
|
+
const processSlashCommand = getProcessSlashCommand();
|
|
299737
299795
|
if (false) {}
|
|
299738
|
-
const
|
|
299796
|
+
const shouldFallbackSlashToPrompt = inputString !== null && mode === "prompt" && !effectiveSkipSlash && inputString.startsWith("/") && !processSlashCommand;
|
|
299797
|
+
const shouldExtractAttachments = !skipAttachments && inputString !== null && (mode !== "prompt" || effectiveSkipSlash || !inputString.startsWith("/") || shouldFallbackSlashToPrompt);
|
|
299739
299798
|
queryCheckpoint("query_attachment_loading_start");
|
|
299740
299799
|
const attachmentMessages = shouldExtractAttachments ? await toArray2(getAttachmentMessages(inputString, context4, ideSelection ?? null, [], messages, querySource)) : [];
|
|
299741
299800
|
queryCheckpoint("query_attachment_loading_end");
|
|
@@ -299746,11 +299805,10 @@ async function processUserInputBase(input, mode, setToolJSX, context4, pastedCon
|
|
|
299746
299805
|
return addImageMetadataMessage(await processBashCommand(inputString, precedingInputBlocks, attachmentMessages, context4, setToolJSX), imageMetadataTexts);
|
|
299747
299806
|
}
|
|
299748
299807
|
if (inputString !== null && !effectiveSkipSlash && inputString.startsWith("/")) {
|
|
299749
|
-
|
|
299750
|
-
|
|
299751
|
-
|
|
299752
|
-
|
|
299753
|
-
return addImageMetadataMessage(slashResult, imageMetadataTexts);
|
|
299808
|
+
if (processSlashCommand) {
|
|
299809
|
+
const slashResult = await processSlashCommand(inputString, precedingInputBlocks, imageContentBlocks, attachmentMessages, context4, setToolJSX, uuid3, isAlreadyProcessing, canUseTool);
|
|
299810
|
+
return addImageMetadataMessage(slashResult, imageMetadataTexts);
|
|
299811
|
+
}
|
|
299754
299812
|
}
|
|
299755
299813
|
if (inputString !== null && mode === "prompt") {
|
|
299756
299814
|
const trimmedInput = inputString.trim();
|
|
@@ -299997,6 +300055,7 @@ class QueryEngine {
|
|
|
299997
300055
|
maxTurns,
|
|
299998
300056
|
maxBudgetUsd,
|
|
299999
300057
|
maxOutputTokens,
|
|
300058
|
+
maxOutputTokensLimit,
|
|
300000
300059
|
contextWindow,
|
|
300001
300060
|
compact,
|
|
300002
300061
|
taskBudget,
|
|
@@ -300013,6 +300072,7 @@ class QueryEngine {
|
|
|
300013
300072
|
agents = [],
|
|
300014
300073
|
setSDKStatus,
|
|
300015
300074
|
onToolInvoke,
|
|
300075
|
+
uploadMedia,
|
|
300016
300076
|
orphanedPermission
|
|
300017
300077
|
} = this.config;
|
|
300018
300078
|
this.discoveredSkillNames.clear();
|
|
@@ -300085,6 +300145,7 @@ class QueryEngine {
|
|
|
300085
300145
|
theme: resolveThemeSetting(getGlobalConfig().theme),
|
|
300086
300146
|
maxBudgetUsd,
|
|
300087
300147
|
maxOutputTokens,
|
|
300148
|
+
maxOutputTokensLimit,
|
|
300088
300149
|
contextWindow,
|
|
300089
300150
|
modelProviders: this.config.modelProviders,
|
|
300090
300151
|
subagentDisallowedTools: this.config.subagentDisallowedTools
|
|
@@ -300116,7 +300177,8 @@ class QueryEngine {
|
|
|
300116
300177
|
});
|
|
300117
300178
|
},
|
|
300118
300179
|
setSDKStatus,
|
|
300119
|
-
onToolInvoke
|
|
300180
|
+
onToolInvoke,
|
|
300181
|
+
uploadMedia
|
|
300120
300182
|
};
|
|
300121
300183
|
if (orphanedPermission && !this.hasHandledOrphanedPermission) {
|
|
300122
300184
|
this.hasHandledOrphanedPermission = true;
|
|
@@ -300189,6 +300251,7 @@ class QueryEngine {
|
|
|
300189
300251
|
agentDefinitions: { activeAgents: agents, allAgents: [] },
|
|
300190
300252
|
maxBudgetUsd,
|
|
300191
300253
|
maxOutputTokens,
|
|
300254
|
+
maxOutputTokensLimit,
|
|
300192
300255
|
contextWindow,
|
|
300193
300256
|
modelProviders: this.config.modelProviders,
|
|
300194
300257
|
subagentDisallowedTools: this.config.subagentDisallowedTools
|
|
@@ -300205,7 +300268,8 @@ class QueryEngine {
|
|
|
300205
300268
|
setResponseLength: () => {},
|
|
300206
300269
|
updateFileHistoryState: processUserInputContext.updateFileHistoryState,
|
|
300207
300270
|
updateAttributionState: processUserInputContext.updateAttributionState,
|
|
300208
|
-
setSDKStatus
|
|
300271
|
+
setSDKStatus,
|
|
300272
|
+
uploadMedia
|
|
300209
300273
|
};
|
|
300210
300274
|
headlessProfilerCheckpoint("before_skills_plugins");
|
|
300211
300275
|
const [skills, { enabled: enabledPlugins }] = await Promise.all([
|
|
@@ -300308,6 +300372,7 @@ class QueryEngine {
|
|
|
300308
300372
|
querySource: "sdk",
|
|
300309
300373
|
maxTurns,
|
|
300310
300374
|
maxOutputTokensOverride: maxOutputTokens,
|
|
300375
|
+
maxOutputTokensLimitOverride: maxOutputTokensLimit,
|
|
300311
300376
|
compactRequest: compact,
|
|
300312
300377
|
taskBudget
|
|
300313
300378
|
})) {
|
|
@@ -300678,6 +300743,7 @@ async function* ask({
|
|
|
300678
300743
|
maxTurns,
|
|
300679
300744
|
maxBudgetUsd,
|
|
300680
300745
|
maxOutputTokens,
|
|
300746
|
+
maxOutputTokensLimit,
|
|
300681
300747
|
contextWindow,
|
|
300682
300748
|
compact,
|
|
300683
300749
|
taskBudget,
|
|
@@ -300700,6 +300766,7 @@ async function* ask({
|
|
|
300700
300766
|
agents = [],
|
|
300701
300767
|
setSDKStatus,
|
|
300702
300768
|
onToolInvoke,
|
|
300769
|
+
uploadMedia,
|
|
300703
300770
|
orphanedPermission
|
|
300704
300771
|
}) {
|
|
300705
300772
|
const engine = new QueryEngine({
|
|
@@ -300722,6 +300789,7 @@ async function* ask({
|
|
|
300722
300789
|
maxTurns,
|
|
300723
300790
|
maxBudgetUsd,
|
|
300724
300791
|
maxOutputTokens,
|
|
300792
|
+
maxOutputTokensLimit,
|
|
300725
300793
|
contextWindow,
|
|
300726
300794
|
compact,
|
|
300727
300795
|
taskBudget,
|
|
@@ -300732,6 +300800,7 @@ async function* ask({
|
|
|
300732
300800
|
includePartialMessages,
|
|
300733
300801
|
setSDKStatus,
|
|
300734
300802
|
onToolInvoke,
|
|
300803
|
+
uploadMedia,
|
|
300735
300804
|
abortController,
|
|
300736
300805
|
orphanedPermission,
|
|
300737
300806
|
...{}
|
|
@@ -329479,7 +329548,7 @@ function toInternalTool(sdkTool) {
|
|
|
329479
329548
|
});
|
|
329480
329549
|
const content = await translateCallToolResultContent({
|
|
329481
329550
|
content: result.content,
|
|
329482
|
-
options: { sourceName: sdkTool.name }
|
|
329551
|
+
options: { sourceName: sdkTool.name, uploadMedia: context4.uploadMedia }
|
|
329483
329552
|
});
|
|
329484
329553
|
return { data: content };
|
|
329485
329554
|
}
|
|
@@ -329742,14 +329811,20 @@ function normalizeInitialMessages(raw) {
|
|
|
329742
329811
|
}
|
|
329743
329812
|
function optionsWithProviderRoutingEnv(options2) {
|
|
329744
329813
|
const transport = options2.transport;
|
|
329814
|
+
const reasoningEffort = options2.reasoningEffort;
|
|
329745
329815
|
const openaiResponses = options2.providerSpecific?.openaiResponses;
|
|
329746
|
-
if (transport === undefined && openaiResponses === undefined) {
|
|
329816
|
+
if (transport === undefined && reasoningEffort === undefined && openaiResponses === undefined) {
|
|
329747
329817
|
return options2;
|
|
329748
329818
|
}
|
|
329749
329819
|
const mergedEnv = { ...options2.env ?? {} };
|
|
329750
329820
|
if (typeof transport === "string" && transport.length > 0) {
|
|
329751
329821
|
mergedEnv[QUERY_ENV_KEY_TRANSPORT_OVERRIDE] = transport;
|
|
329752
329822
|
}
|
|
329823
|
+
if (reasoningEffort === null) {
|
|
329824
|
+
mergedEnv[QUERY_ENV_KEY_REASONING_EFFORT_OVERRIDE] = QUERY_ENV_VALUE_REASONING_EFFORT_CLEAR;
|
|
329825
|
+
} else if (typeof reasoningEffort === "string" && reasoningEffort.length > 0) {
|
|
329826
|
+
mergedEnv[QUERY_ENV_KEY_REASONING_EFFORT_OVERRIDE] = reasoningEffort;
|
|
329827
|
+
}
|
|
329753
329828
|
if (openaiResponses && typeof openaiResponses === "object") {
|
|
329754
329829
|
mergedEnv[QUERY_ENV_KEY_PROVIDER_SPECIFIC_OPENAI_RESPONSES] = JSON.stringify(openaiResponses);
|
|
329755
329830
|
}
|
|
@@ -329979,6 +330054,7 @@ function runSdkQueryRuntime(params) {
|
|
|
329979
330054
|
maxTurns: options2.maxTurns,
|
|
329980
330055
|
maxBudgetUsd: options2.maxBudgetUsd,
|
|
329981
330056
|
maxOutputTokens: options2.maxOutputTokens,
|
|
330057
|
+
maxOutputTokensLimit: options2.maxOutputTokensLimit,
|
|
329982
330058
|
contextWindow: options2.contextWindow,
|
|
329983
330059
|
compact: options2.compact,
|
|
329984
330060
|
taskBudget: options2.taskBudget,
|
|
@@ -330002,6 +330078,7 @@ function runSdkQueryRuntime(params) {
|
|
|
330002
330078
|
includePartialMessages: Boolean(options2.includePartialMessages),
|
|
330003
330079
|
agents: mergedAgents,
|
|
330004
330080
|
onToolInvoke: typeof options2.onToolInvoke === "function" ? options2.onToolInvoke : undefined,
|
|
330081
|
+
uploadMedia: typeof options2.uploadMedia === "function" ? options2.uploadMedia : undefined,
|
|
330005
330082
|
setSDKStatus: (status) => {
|
|
330006
330083
|
turnStatusStream.enqueue({
|
|
330007
330084
|
type: "system",
|
|
@@ -336055,4 +336132,4 @@ export {
|
|
|
336055
336132
|
AbortError2 as AbortError
|
|
336056
336133
|
};
|
|
336057
336134
|
|
|
336058
|
-
//# debugId=
|
|
336135
|
+
//# debugId=2C32974032B2A71264756E2164756E21
|