@opengeni/runtime 3.0.2-canary.38894290271001 → 3.1.2

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.
@@ -76,6 +76,7 @@ import {
76
76
  import {
77
77
  MODEL_ATTACHMENT_CATALOG_MARKER,
78
78
  MODEL_ATTACHMENT_CATALOG_RENDERED_FIELD,
79
+ MODEL_ATTACHMENT_IMAGE_MAX_DIMENSION_FIELD,
79
80
  MODEL_ATTACHMENT_REFS_FIELD,
80
81
  MODEL_TIMELINE_ANNOTATIONS_FIELD
81
82
  } from "@opengeni/contracts";
@@ -239,12 +240,13 @@ function sanitizeHistoryItemsForModel(items, toolOutputTruncationTokens = DEFAUL
239
240
  var INTERNAL_RESUME_MESSAGE_MARKER = "opengeni_internal_resume";
240
241
  function stripInternalModelMetadata(item) {
241
242
  const withoutResume = stripInternalResumeMarker(item);
242
- if (!(MODEL_ATTACHMENT_CATALOG_MARKER in withoutResume) && !(MODEL_ATTACHMENT_CATALOG_RENDERED_FIELD in withoutResume) && !(MODEL_ATTACHMENT_REFS_FIELD in withoutResume) && !(MODEL_TIMELINE_ANNOTATIONS_FIELD in withoutResume)) {
243
+ if (!(MODEL_ATTACHMENT_CATALOG_MARKER in withoutResume) && !(MODEL_ATTACHMENT_CATALOG_RENDERED_FIELD in withoutResume) && !(MODEL_ATTACHMENT_IMAGE_MAX_DIMENSION_FIELD in withoutResume) && !(MODEL_ATTACHMENT_REFS_FIELD in withoutResume) && !(MODEL_TIMELINE_ANNOTATIONS_FIELD in withoutResume)) {
243
244
  return withoutResume;
244
245
  }
245
246
  const clone = { ...withoutResume };
246
247
  delete clone[MODEL_ATTACHMENT_CATALOG_MARKER];
247
248
  delete clone[MODEL_ATTACHMENT_CATALOG_RENDERED_FIELD];
249
+ delete clone[MODEL_ATTACHMENT_IMAGE_MAX_DIMENSION_FIELD];
248
250
  delete clone[MODEL_ATTACHMENT_REFS_FIELD];
249
251
  delete clone[MODEL_TIMELINE_ANNOTATIONS_FIELD];
250
252
  return clone;
@@ -490,6 +492,7 @@ import {
490
492
  FileResourceRef,
491
493
  MODEL_ATTACHMENT_CATALOG_MARKER as MODEL_ATTACHMENT_CATALOG_MARKER2,
492
494
  MODEL_ATTACHMENT_CATALOG_RENDERED_FIELD as MODEL_ATTACHMENT_CATALOG_RENDERED_FIELD2,
495
+ MODEL_ATTACHMENT_IMAGE_MAX_DIMENSION_FIELD as MODEL_ATTACHMENT_IMAGE_MAX_DIMENSION_FIELD2,
493
496
  MODEL_ATTACHMENT_REFS_FIELD as MODEL_ATTACHMENT_REFS_FIELD2,
494
497
  collapseRepeatedSessionGoalContexts,
495
498
  expandUnchangedSessionGoalContexts,
@@ -1056,13 +1059,9 @@ function isCanonicalArrayIndex(property, length) {
1056
1059
  return Number.isSafeInteger(index) && index >= 0 && index < length && String(index) === property;
1057
1060
  }
1058
1061
  var IMAGE_LOW_DETAIL_TOKENS = 85;
1059
- var IMAGE_HIGH_DETAIL_BASE_TOKENS = 85;
1060
- var IMAGE_HIGH_DETAIL_TILE_TOKENS = 170;
1061
- var IMAGE_HIGH_DETAIL_TILE_SIZE = 512;
1062
- var IMAGE_HIGH_DETAIL_MAX_SIDE = 2048;
1063
- var IMAGE_HIGH_DETAIL_TARGET_SHORT_SIDE = 768;
1062
+ var IMAGE_PATCH_SIZE = 28;
1064
1063
  var UNKNOWN_IMAGE_TOKENS = 4096;
1065
- var MAX_NATIVE_IMAGE_TOKENS = 8192;
1064
+ var MAX_NATIVE_IMAGE_TOKENS = 36e3;
1066
1065
  function finitePositiveInteger(value) {
1067
1066
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : null;
1068
1067
  }
@@ -1168,25 +1167,10 @@ function dimensionsFromImageSource(source) {
1168
1167
  const rawDataDimensions = rawData instanceof Uint8Array ? dimensionsFromImageBytes(rawData) : typeof rawData === "string" && typeof mediaType === "string" && mediaType.toLowerCase().startsWith("image/") ? dimensionsFromImageBytes(base64BytesPrefix(rawData) ?? new Uint8Array()) : null;
1169
1168
  return dimensionsFromRecord(record3) ?? rawDataDimensions ?? dimensionsFromImageSource(record3.url) ?? dimensionsFromImageSource(rawData);
1170
1169
  }
1171
- function highDetailImageTokens(width, height) {
1172
- let scaledWidth = width;
1173
- let scaledHeight = height;
1174
- const longest = Math.max(scaledWidth, scaledHeight);
1175
- if (longest > IMAGE_HIGH_DETAIL_MAX_SIDE) {
1176
- const scale = IMAGE_HIGH_DETAIL_MAX_SIDE / longest;
1177
- scaledWidth *= scale;
1178
- scaledHeight *= scale;
1179
- }
1180
- const shortest = Math.min(scaledWidth, scaledHeight);
1181
- if (shortest > IMAGE_HIGH_DETAIL_TARGET_SHORT_SIDE) {
1182
- const scale = IMAGE_HIGH_DETAIL_TARGET_SHORT_SIDE / shortest;
1183
- scaledWidth *= scale;
1184
- scaledHeight *= scale;
1185
- }
1186
- const tiles = Math.ceil(scaledWidth / IMAGE_HIGH_DETAIL_TILE_SIZE) * Math.ceil(scaledHeight / IMAGE_HIGH_DETAIL_TILE_SIZE);
1170
+ function patchImageTokens(width, height) {
1187
1171
  return Math.min(
1188
1172
  MAX_NATIVE_IMAGE_TOKENS,
1189
- IMAGE_HIGH_DETAIL_BASE_TOKENS + IMAGE_HIGH_DETAIL_TILE_TOKENS * Math.max(1, tiles)
1173
+ Math.max(1, Math.ceil(width / IMAGE_PATCH_SIZE) * Math.ceil(height / IMAGE_PATCH_SIZE))
1190
1174
  );
1191
1175
  }
1192
1176
  function estimateNativeImageTokens(input) {
@@ -1209,7 +1193,7 @@ function estimateNativeImageTokens(input) {
1209
1193
  };
1210
1194
  }
1211
1195
  return {
1212
- tokens: highDetailImageTokens(width, height),
1196
+ tokens: patchImageTokens(width, height),
1213
1197
  width,
1214
1198
  height,
1215
1199
  detail,
@@ -1792,13 +1776,37 @@ function prepareRetainedInputs(items, isCandidate) {
1792
1776
  function isPortableRetentionCandidate(item) {
1793
1777
  return isPortableInputMessage(item) && !isCompactionSummary(item) && !isAttachmentCatalog(item);
1794
1778
  }
1779
+ function hasAttachmentRefs(item) {
1780
+ const raw = item[MODEL_ATTACHMENT_REFS_FIELD2];
1781
+ return Array.isArray(raw) && raw.length > 0;
1782
+ }
1783
+ function withOnlyNewestAttachmentsInline(items) {
1784
+ let newest = -1;
1785
+ for (let index = items.length - 1; index >= 0; index -= 1) {
1786
+ const item = items[index];
1787
+ if (itemRole(item) === "user" && !isAttachmentCatalog(item) && hasAttachmentRefs(item)) {
1788
+ newest = index;
1789
+ break;
1790
+ }
1791
+ }
1792
+ return items.map((item, index) => {
1793
+ if (index === newest || isAttachmentCatalog(item) || !hasAttachmentRefs(item)) return item;
1794
+ const stripped = { ...item };
1795
+ delete stripped[MODEL_ATTACHMENT_REFS_FIELD2];
1796
+ delete stripped[MODEL_ATTACHMENT_IMAGE_MAX_DIMENSION_FIELD2];
1797
+ return stripped;
1798
+ });
1799
+ }
1795
1800
  function buildCompactionReplacementHistory(items, summaryBody, retainedItemTokens = (item) => estimateTokens([item]), retainedMessageBudgetTokens = COMPACT_USER_MESSAGE_MAX_TOKENS, attachmentUploadTimes = /* @__PURE__ */ new Map()) {
1796
1801
  const retainedReversed = [];
1797
1802
  let remaining = Math.max(
1798
1803
  0,
1799
1804
  Math.min(COMPACT_USER_MESSAGE_MAX_TOKENS, retainedMessageBudgetTokens)
1800
1805
  );
1801
- const prepared = prepareRetainedInputs(items, isPortableRetentionCandidate);
1806
+ const prepared = prepareRetainedInputs(
1807
+ withOnlyNewestAttachmentsInline(items),
1808
+ isPortableRetentionCandidate
1809
+ );
1802
1810
  for (let index = prepared.charged.length - 1; index >= 0 && remaining > 0; index -= 1) {
1803
1811
  const item = prepared.charged[index];
1804
1812
  if (!isPortableRetentionCandidate(item) || prepared.skip(index)) {
@@ -1853,7 +1861,7 @@ function buildRemoteV2ReplacementHistory(items, compactionItem, retainedItemToke
1853
1861
  const retainedReversed = [];
1854
1862
  let remaining = REMOTE_V2_RETAINED_MESSAGE_TOKEN_BUDGET;
1855
1863
  const prepared = prepareRetainedInputs(
1856
- items,
1864
+ withOnlyNewestAttachmentsInline(items),
1857
1865
  (item) => readSkillCatalogContext(item) === null && isRetainedRemoteV2Message(item)
1858
1866
  );
1859
1867
  for (let index = prepared.charged.length - 1; index >= 0 && remaining > 0; index -= 1) {
@@ -8940,6 +8948,100 @@ function captureClaudeRequestToken(input, init) {
8940
8948
  return headers.get("authorization")?.match(/^Bearer (.+)$/i)?.[1] ?? null;
8941
8949
  }
8942
8950
 
8951
+ // src/model-image-sizing.ts
8952
+ import { createHash as createHash3 } from "crypto";
8953
+ import sharp from "sharp";
8954
+ function createModelImageSizer(maxDimension, maxEncodedBytes = 10 * 1024 * 1024, options = {}) {
8955
+ if (!Number.isSafeInteger(maxDimension) || maxDimension < 1) {
8956
+ throw new RangeError("Model image dimension must be a positive integer.");
8957
+ }
8958
+ if (!Number.isSafeInteger(maxEncodedBytes) || maxEncodedBytes < 1) {
8959
+ throw new RangeError("Model image byte limit must be a positive integer.");
8960
+ }
8961
+ const jpegQuality = options.jpegQuality;
8962
+ if (jpegQuality !== void 0 && (!Number.isSafeInteger(jpegQuality) || jpegQuality < 1 || jpegQuality > 100)) {
8963
+ throw new RangeError("Model image JPEG quality must be an integer from 1 to 100.");
8964
+ }
8965
+ const cache = /* @__PURE__ */ new Map();
8966
+ let cacheBytes = 0;
8967
+ const maxCacheBytes = 32 * 1024 * 1024;
8968
+ return async (data, mediaType) => {
8969
+ const key = createHash3("sha256").update(mediaType).update(data).digest("hex");
8970
+ const prior = cache.get(key);
8971
+ if (prior) return prior;
8972
+ try {
8973
+ if (data.length > Math.ceil(64 * 1024 * 1024 / 3) * 4) throw new Error();
8974
+ const bytes = Buffer.from(data, "base64");
8975
+ const signature = bytes.subarray(0, 12);
8976
+ const matches = mediaType === "image/png" && signature.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])) || mediaType === "image/jpeg" && signature[0] === 255 && signature[1] === 216 && signature[2] === 255 || mediaType === "image/webp" && signature.toString("ascii", 0, 4) === "RIFF" && signature.toString("ascii", 8, 12) === "WEBP" || mediaType === "image/gif" && ["GIF87a", "GIF89a"].includes(signature.toString("ascii", 0, 6));
8977
+ if (!matches) throw new Error();
8978
+ const decoder = sharp(bytes, { limitInputPixels: 64e6, failOn: "error" });
8979
+ const metadata = await decoder.metadata();
8980
+ if (!metadata.width || !metadata.height) throw new Error();
8981
+ let result = {
8982
+ data,
8983
+ mediaType,
8984
+ originalWidth: metadata.width,
8985
+ originalHeight: metadata.height,
8986
+ width: metadata.width,
8987
+ height: metadata.height
8988
+ };
8989
+ if (metadata.width > maxDimension || metadata.height > maxDimension || data.length > maxEncodedBytes) {
8990
+ const oriented = (metadata.orientation ?? 1) >= 5;
8991
+ const pipeline = decoder.autoOrient().resize({
8992
+ width: maxDimension,
8993
+ height: maxDimension,
8994
+ fit: "inside",
8995
+ withoutEnlargement: true
8996
+ });
8997
+ const encodedBudget = Math.min(maxEncodedBytes, data.length);
8998
+ const asJpeg = jpegQuality !== void 0 && mediaType === "image/jpeg";
8999
+ let resized = asJpeg ? await pipeline.clone().jpeg({ quality: jpegQuality }).toBuffer({ resolveWithObject: true }) : await pipeline.clone().png().toBuffer({ resolveWithObject: true });
9000
+ let outputType = asJpeg ? "image/jpeg" : "image/png";
9001
+ for (const quality of [90, 65, 45]) {
9002
+ if (Math.ceil(resized.data.length / 3) * 4 <= encodedBudget) break;
9003
+ resized = await pipeline.clone().webp({ quality }).toBuffer({ resolveWithObject: true });
9004
+ outputType = "image/webp";
9005
+ }
9006
+ let dimension = Math.min(maxDimension, Math.max(metadata.width, metadata.height));
9007
+ while (Math.ceil(resized.data.length / 3) * 4 > encodedBudget && dimension > 1) {
9008
+ dimension = Math.max(1, Math.floor(dimension * 0.75));
9009
+ resized = await decoder.clone().autoOrient().resize({
9010
+ width: dimension,
9011
+ height: dimension,
9012
+ fit: "inside",
9013
+ withoutEnlargement: true
9014
+ }).webp({ quality: 75 }).toBuffer({ resolveWithObject: true });
9015
+ outputType = "image/webp";
9016
+ }
9017
+ if (Math.ceil(resized.data.length / 3) * 4 > encodedBudget) throw new Error();
9018
+ result = {
9019
+ ...result,
9020
+ data: resized.data.toString("base64"),
9021
+ mediaType: outputType,
9022
+ originalWidth: oriented ? metadata.height : metadata.width,
9023
+ originalHeight: oriented ? metadata.width : metadata.height,
9024
+ width: resized.info.width,
9025
+ height: resized.info.height
9026
+ };
9027
+ }
9028
+ const size = result.data.length;
9029
+ if (size <= maxCacheBytes) {
9030
+ while (cache.size && (cacheBytes + size > maxCacheBytes || cache.size >= 256)) {
9031
+ const oldest = cache.keys().next().value;
9032
+ cacheBytes -= cache.get(oldest).data.length;
9033
+ cache.delete(oldest);
9034
+ }
9035
+ cache.set(key, result);
9036
+ cacheBytes += size;
9037
+ }
9038
+ return result;
9039
+ } catch {
9040
+ throw new Error("Model image could not be decoded within the image sizing limit.");
9041
+ }
9042
+ };
9043
+ }
9044
+
8943
9045
  // src/provider-history-adapter.ts
8944
9046
  import { collapseRepeatedSessionGoalContexts as collapseRepeatedSessionGoalContexts2 } from "@opengeni/contracts";
8945
9047
 
@@ -9360,7 +9462,7 @@ function splitStableSystemPromptPrefix(instructions) {
9360
9462
  import { createHash as createHash5, randomUUID as randomUUID2 } from "crypto";
9361
9463
 
9362
9464
  // src/claude-code-identity.ts
9363
- import { createHash as createHash3, randomUUID } from "crypto";
9465
+ import { createHash as createHash4, randomUUID } from "crypto";
9364
9466
  var CLAUDE_CODE_HEADERS = {
9365
9467
  "user-agent": "claude-cli/2.1.285 (external, sdk-ts, agent-sdk/0.3.276)",
9366
9468
  "x-app": "cli",
@@ -9383,7 +9485,7 @@ function claudeCodeFingerprint(input) {
9383
9485
  const first = typeof content === "string" ? content : Array.isArray(content) ? content.find((block) => block.type === "input_text" || String(block.type) === "text") : void 0;
9384
9486
  const prompt = typeof first === "string" ? first : first && "text" in first ? String(first.text) : "";
9385
9487
  const sample = [4, 7, 20].map((index) => prompt[index] || "0").join("");
9386
- return createHash3("sha256").update(`59cf53e54c78${sample}2.1.285`).digest("hex").slice(0, 3);
9488
+ return createHash4("sha256").update(`59cf53e54c78${sample}2.1.285`).digest("hex").slice(0, 3);
9387
9489
  }
9388
9490
  function applyClaudeCodeIdentity(body, headers, url, request, account, identity) {
9389
9491
  url.searchParams.set("beta", "true");
@@ -9423,97 +9525,6 @@ function applyClaudeCodeIdentity(body, headers, url, request, account, identity)
9423
9525
 
9424
9526
  // src/anthropic-messages.ts
9425
9527
  import { claudeNativeModelProfile } from "@opengeni/config";
9426
-
9427
- // src/model-image-sizing.ts
9428
- import { createHash as createHash4 } from "crypto";
9429
- import sharp from "sharp";
9430
- function createModelImageSizer(maxDimension, maxEncodedBytes = 10 * 1024 * 1024) {
9431
- if (!Number.isSafeInteger(maxDimension) || maxDimension < 1) {
9432
- throw new RangeError("Model image dimension must be a positive integer.");
9433
- }
9434
- if (!Number.isSafeInteger(maxEncodedBytes) || maxEncodedBytes < 1) {
9435
- throw new RangeError("Model image byte limit must be a positive integer.");
9436
- }
9437
- const cache = /* @__PURE__ */ new Map();
9438
- let cacheBytes = 0;
9439
- const maxCacheBytes = 32 * 1024 * 1024;
9440
- return async (data, mediaType) => {
9441
- const key = createHash4("sha256").update(mediaType).update(data).digest("hex");
9442
- const prior = cache.get(key);
9443
- if (prior) return prior;
9444
- try {
9445
- if (data.length > Math.ceil(64 * 1024 * 1024 / 3) * 4) throw new Error();
9446
- const bytes = Buffer.from(data, "base64");
9447
- const signature = bytes.subarray(0, 12);
9448
- const matches = mediaType === "image/png" && signature.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10])) || mediaType === "image/jpeg" && signature[0] === 255 && signature[1] === 216 && signature[2] === 255 || mediaType === "image/webp" && signature.toString("ascii", 0, 4) === "RIFF" && signature.toString("ascii", 8, 12) === "WEBP" || mediaType === "image/gif" && ["GIF87a", "GIF89a"].includes(signature.toString("ascii", 0, 6));
9449
- if (!matches) throw new Error();
9450
- const decoder = sharp(bytes, { limitInputPixels: 64e6, failOn: "error" });
9451
- const metadata = await decoder.metadata();
9452
- if (!metadata.width || !metadata.height) throw new Error();
9453
- let result = {
9454
- data,
9455
- mediaType,
9456
- originalWidth: metadata.width,
9457
- originalHeight: metadata.height,
9458
- width: metadata.width,
9459
- height: metadata.height
9460
- };
9461
- if (metadata.width > maxDimension || metadata.height > maxDimension || data.length > maxEncodedBytes) {
9462
- const oriented = (metadata.orientation ?? 1) >= 5;
9463
- const pipeline = decoder.autoOrient().resize({
9464
- width: maxDimension,
9465
- height: maxDimension,
9466
- fit: "inside",
9467
- withoutEnlargement: true
9468
- });
9469
- const encodedBudget = Math.min(maxEncodedBytes, data.length);
9470
- let resized = await pipeline.clone().png().toBuffer({ resolveWithObject: true });
9471
- let outputType = "image/png";
9472
- for (const quality of [90, 65, 45]) {
9473
- if (Math.ceil(resized.data.length / 3) * 4 <= encodedBudget) break;
9474
- resized = await pipeline.clone().webp({ quality }).toBuffer({ resolveWithObject: true });
9475
- outputType = "image/webp";
9476
- }
9477
- let dimension = Math.min(maxDimension, Math.max(metadata.width, metadata.height));
9478
- while (Math.ceil(resized.data.length / 3) * 4 > encodedBudget && dimension > 1) {
9479
- dimension = Math.max(1, Math.floor(dimension * 0.75));
9480
- resized = await decoder.clone().autoOrient().resize({
9481
- width: dimension,
9482
- height: dimension,
9483
- fit: "inside",
9484
- withoutEnlargement: true
9485
- }).webp({ quality: 75 }).toBuffer({ resolveWithObject: true });
9486
- outputType = "image/webp";
9487
- }
9488
- if (Math.ceil(resized.data.length / 3) * 4 > encodedBudget) throw new Error();
9489
- result = {
9490
- ...result,
9491
- data: resized.data.toString("base64"),
9492
- mediaType: outputType,
9493
- originalWidth: oriented ? metadata.height : metadata.width,
9494
- originalHeight: oriented ? metadata.width : metadata.height,
9495
- width: resized.info.width,
9496
- height: resized.info.height
9497
- };
9498
- }
9499
- const size = result.data.length;
9500
- if (size <= maxCacheBytes) {
9501
- while (cache.size && (cacheBytes + size > maxCacheBytes || cache.size >= 256)) {
9502
- const oldest = cache.keys().next().value;
9503
- cacheBytes -= cache.get(oldest).data.length;
9504
- cache.delete(oldest);
9505
- }
9506
- cache.set(key, result);
9507
- cacheBytes += size;
9508
- }
9509
- return result;
9510
- } catch {
9511
- throw new Error("Model image could not be decoded within the image sizing limit.");
9512
- }
9513
- };
9514
- }
9515
-
9516
- // src/anthropic-messages.ts
9517
9528
  var ANTHROPIC_PAUSE_TURN_MAX_REQUESTS = 8;
9518
9529
  var AnthropicProtocolError = class extends Error {
9519
9530
  code = "anthropic_protocol_error";
@@ -13090,6 +13101,30 @@ var HARNESS_CONTROL_MODEL_TOOL_NAMES = new Set(
13090
13101
  function isHarnessControlMcpToolName(registryId, modelName) {
13091
13102
  return registryId === HARNESS_CONTROL_MCP_SERVER_ID && HARNESS_CONTROL_MODEL_TOOL_NAMES.has(modelName);
13092
13103
  }
13104
+ var INTERACTION_MCP_SERVER_ID = "interaction";
13105
+ var INTERACTION_TOOL_FAMILIES = [
13106
+ ["browser_open", "browser_observe", "browser_act", "browser_screenshot", "browser_tabs"],
13107
+ ["computer_open", "computer_observe", "computer_act"]
13108
+ ];
13109
+ function interactionToolName(name) {
13110
+ const prefix = `${INTERACTION_MCP_SERVER_ID}${MCP_TOOL_NAME_SEPARATOR}`;
13111
+ return name.startsWith(prefix) ? name.slice(prefix.length) : null;
13112
+ }
13113
+ function familyCompanions(disclosed, pool) {
13114
+ const disclosedShort = new Set(
13115
+ disclosed.map((tool2) => interactionToolName(tool2.name)).filter((name) => name !== null)
13116
+ );
13117
+ const wanted = INTERACTION_TOOL_FAMILIES.filter(
13118
+ (family) => family.some((member) => disclosedShort.has(member))
13119
+ ).flat();
13120
+ const companions = [];
13121
+ for (const member of wanted) {
13122
+ if (disclosedShort.has(member)) continue;
13123
+ const tool2 = pool.find((candidate) => interactionToolName(candidate.name) === member);
13124
+ if (tool2 && !companions.includes(tool2)) companions.push(tool2);
13125
+ }
13126
+ return companions;
13127
+ }
13093
13128
  function isHarnessControlMcpFunctionTool(tool2, mcpServerIds = NO_MCP_SERVER_IDS, modelServerIds) {
13094
13129
  const serverId = mcpServerIdForTool(tool2, mcpServerIds, modelServerIds);
13095
13130
  return serverId !== null && isHarnessControlMcpToolName(serverId, tool2.name);
@@ -13257,6 +13292,14 @@ function searchToolPool(availableTools, rawArguments) {
13257
13292
  bounded2.push(tool2);
13258
13293
  if (bounded2.length >= limit) break;
13259
13294
  }
13295
+ for (const tool2 of familyCompanions(bounded2, searchable)) {
13296
+ if (bounded2.includes(tool2)) continue;
13297
+ const toolBytes = mcpSerializedSizeBytes(tool2);
13298
+ if (toolBytes > MCP_MAX_TOOL_DEFINITION_BYTES) continue;
13299
+ if (disclosedBytes + toolBytes > MCP_MAX_TOOL_SEARCH_DISCLOSURE_BYTES) continue;
13300
+ disclosedBytes += toolBytes;
13301
+ bounded2.push(tool2);
13302
+ }
13260
13303
  return bounded2;
13261
13304
  }
13262
13305
 
@@ -16084,6 +16127,7 @@ export {
16084
16127
  OpenAIResponsesModel,
16085
16128
  OpenAIChatCompletionsModel,
16086
16129
  withClaudeUsageObserver,
16130
+ createModelImageSizer,
16087
16131
  ProviderHistoryIncompatibleError,
16088
16132
  projectHistoryForProvider,
16089
16133
  recordStableSystemPromptPrefix,
@@ -16174,4 +16218,4 @@ export {
16174
16218
  normalizeModelCallUsage,
16175
16219
  modelCallUsageTelemetry
16176
16220
  };
16177
- //# sourceMappingURL=chunk-EQQ3YOKR.js.map
16221
+ //# sourceMappingURL=chunk-7OUG7WBV.js.map