zcode-app-cli 3.9.1-16 → 3.9.2-16

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.
@@ -63268,6 +63268,25 @@ function parseOfficialMcpToolError(text) {
63268
63268
  };
63269
63269
  }
63270
63270
 
63271
+ // ../../../../packages/shared/src/zcode-protocol-v4/cuaPermission.ts
63272
+ var cuaRequestAccessStatusSchema = external_exports3.object({
63273
+ schemaVersion: external_exports3.literal(1),
63274
+ platform: external_exports3.literal("darwin"),
63275
+ grantOwner: external_exports3.string().min(1),
63276
+ accessibility: external_exports3.enum(["granted", "stale", "denied"]),
63277
+ screenRecording: external_exports3.enum(["granted", "denied", "unknown"])
63278
+ }).strict();
63279
+ var cuaPermissionObservationSchema = external_exports3.object({
63280
+ schemaVersion: external_exports3.literal(1),
63281
+ eventId: external_exports3.string().min(1),
63282
+ eventSeq: external_exports3.number().int().nonnegative(),
63283
+ occurredAt: timestampSchema,
63284
+ sessionId: external_exports3.string().min(1),
63285
+ turnId: external_exports3.string().min(1).optional(),
63286
+ toolCallId: external_exports3.string().min(1),
63287
+ permissionStatus: cuaRequestAccessStatusSchema
63288
+ }).strict();
63289
+
63271
63290
  // ../../../../packages/shared/src/zcode-protocol-v4/toolDisplay.ts
63272
63291
  var toolResultDisplaySchema = external_exports3.discriminatedUnion("kind", [
63273
63292
  external_exports3.object({
@@ -63322,6 +63341,7 @@ var toolResultDisplaySchema = external_exports3.discriminatedUnion("kind", [
63322
63341
  text: external_exports3.string().optional(),
63323
63342
  errorCode: external_exports3.string().optional(),
63324
63343
  suggestedAction: external_exports3.string().optional(),
63344
+ permissionStatus: cuaRequestAccessStatusSchema.optional(),
63325
63345
  targetApp: external_exports3.object({
63326
63346
  schemaVersion: external_exports3.literal(1),
63327
63347
  displayName: external_exports3.string().trim().min(1).max(512).optional(),
@@ -71811,6 +71831,13 @@ var cuaTargetAppDisplaySchema = external_exports2.object({
71811
71831
  displayName: external_exports2.string().trim().min(1).max(512).optional(),
71812
71832
  iconLocators: external_exports2.array(applicationIconLocatorSchema).max(3)
71813
71833
  }).strict();
71834
+ var cuaRequestAccessStatusDisplaySchema = external_exports2.object({
71835
+ schemaVersion: external_exports2.literal(1),
71836
+ platform: external_exports2.literal("darwin"),
71837
+ grantOwner: external_exports2.string().trim().min(1).max(512),
71838
+ accessibility: external_exports2.enum(["granted", "stale", "denied"]),
71839
+ screenRecording: external_exports2.enum(["granted", "denied", "unknown"])
71840
+ }).strict();
71814
71841
  var toolResultDisplayDiffHunkSchema = external_exports2.object({
71815
71842
  oldStart: external_exports2.number().int(),
71816
71843
  oldLines: external_exports2.number().int(),
@@ -71863,6 +71890,7 @@ var cuaToolResultDisplayPayloadSchema = external_exports2.object({
71863
71890
  errorCode: external_exports2.string().optional(),
71864
71891
  suggestedAction: external_exports2.string().optional(),
71865
71892
  targetApp: cuaTargetAppDisplaySchema.optional(),
71893
+ permissionStatus: cuaRequestAccessStatusDisplaySchema.optional(),
71866
71894
  media: external_exports2.array(external_exports2.object({
71867
71895
  mimeType: external_exports2.string().min(1),
71868
71896
  // 256 KiB 原始图片编码后的最大 base64 长度;总预算由投影器执行。
@@ -80691,6 +80719,16 @@ var countPatchLines = (structuredPatch2) => {
80691
80719
  return { additions, deletions };
80692
80720
  };
80693
80721
 
80722
+ // ../../../../node_modules/@zcode/zcode-cua/dist/request-access-contract/index.js
80723
+ var CUA_REQUEST_ACCESS_STATUS_META_KEY = "zcode.cua/request-access-status-v1";
80724
+ var cuaRequestAccessStatusSchema2 = external_exports.object({
80725
+ schemaVersion: external_exports.literal(1),
80726
+ platform: external_exports.literal("darwin"),
80727
+ grantOwner: external_exports.string().trim().min(1).max(512),
80728
+ accessibility: external_exports.enum(["granted", "stale", "denied"]),
80729
+ screenRecording: external_exports.enum(["granted", "denied", "unknown"])
80730
+ }).strict();
80731
+
80694
80732
  // ../core/dist/tool/executor/result-display.js
80695
80733
  var MAX_DISPLAY_DIFF_HUNKS = 8;
80696
80734
  var MAX_DISPLAY_DIFF_LINES = 160;
@@ -80873,6 +80911,7 @@ function createCuaToolResultDisplay(toolName, output, officialCua) {
80873
80911
  const truncated = mediaTruncated || structuredJson?.truncated === true || boundedText?.truncated === true;
80874
80912
  const meta5 = isRecord4(result._meta) ? result._meta : void 0;
80875
80913
  const targetApp = officialCua ? cuaTargetAppDisplaySchema.safeParse(meta5?.[CUA_TARGET_APP_DISPLAY_META_KEY]) : void 0;
80914
+ const permissionStatus = officialCua && toolName === "request_access" ? cuaRequestAccessStatusSchema2.safeParse(meta5?.[CUA_REQUEST_ACCESS_STATUS_META_KEY]) : void 0;
80876
80915
  return {
80877
80916
  kind: "cua",
80878
80917
  schemaVersion: 1,
@@ -80883,6 +80922,7 @@ function createCuaToolResultDisplay(toolName, output, officialCua) {
80883
80922
  ...typeof errorRecord?.code === "string" ? { errorCode: errorRecord.code } : {},
80884
80923
  ...typeof errorRecord?.suggested_action === "string" ? { suggestedAction: errorRecord.suggested_action } : {},
80885
80924
  ...targetApp?.success ? { targetApp: targetApp.data } : {},
80925
+ ...permissionStatus?.success ? { permissionStatus: permissionStatus.data } : {},
80886
80926
  ...media.length > 0 ? { media } : {},
80887
80927
  ...truncated ? { truncated: true } : {}
80888
80928
  };
@@ -81039,48 +81079,45 @@ function formatDecimalBytes(bytes) {
81039
81079
  }
81040
81080
 
81041
81081
  // ../core/dist/tool/executor/result-content-projection.js
81082
+ var OFFICIAL_CUA_TEXT_TRUNCATION_MARKER = "[Official CUA text truncated by resultBudget. Re-observe with detail=compact or a narrower window before relying on omitted state.]";
81083
+ var OFFICIAL_CUA_FRAME_CONTRACT_ERROR_CODE = "official_cua_frame_pair_not_leading";
81084
+ var OfficialCuaFrameContractError = class extends Error {
81085
+ code = OFFICIAL_CUA_FRAME_CONTRACT_ERROR_CODE;
81086
+ constructor() {
81087
+ super("Official CUA frame pair must be the first two result blocks");
81088
+ this.name = "OfficialCuaFrameContractError";
81089
+ }
81090
+ };
81042
81091
  function projectOfficialCuaStructuredContent(content, maxModelBytes, direction) {
81043
81092
  const pair = findOfficialCuaFrameContentPair(content);
81044
81093
  if (!pair)
81045
81094
  return void 0;
81046
- const pairStart = Math.min(pair.imageIndex, pair.imageRefIndex);
81047
- const pairEnd = Math.max(pair.imageIndex, pair.imageRefIndex);
81048
- const prefixText = joinTextBlocks(content.slice(0, pairStart));
81049
- const suffixText = joinTextBlocks(content.slice(pairEnd + 1));
81095
+ if (pair.imageIndex !== 0 || pair.imageRefIndex !== 1) {
81096
+ throw new OfficialCuaFrameContractError();
81097
+ }
81050
81098
  const pairContent = [pair.image, pair.imageRef];
81051
- const pairBytes = Buffer.byteLength(stringifyModelContentForSerialization(pairContent), "utf8");
81052
- let remainingBytes = Math.max(0, maxModelBytes - pairBytes);
81053
- let projectedPrefix = "";
81054
- let projectedSuffix = "";
81055
- const allocate = (value, placement) => {
81056
- if (value.length === 0 || remainingBytes <= 2)
81057
- return;
81058
- const fitted = fitStringToBytes(value, remainingBytes - 2, direction);
81059
- if (fitted.length === 0)
81060
- return;
81061
- remainingBytes -= Buffer.byteLength(fitted, "utf8") + 2;
81062
- if (placement === "prefix")
81063
- projectedPrefix = fitted;
81064
- else
81065
- projectedSuffix = fitted;
81066
- };
81067
- if (direction === "head") {
81068
- allocate(prefixText, "prefix");
81069
- allocate(suffixText, "suffix");
81070
- } else {
81071
- allocate(suffixText, "suffix");
81072
- allocate(prefixText, "prefix");
81099
+ const suffixBlocks = content.slice(2).filter((block) => block.type === "text" && block.text.length > 0);
81100
+ const hasOtherStructuredBlocks = content.some((block, index) => index !== pair.imageRefIndex && index !== pair.imageIndex && block.type !== "text");
81101
+ const completeContent = [...pairContent, ...suffixBlocks];
81102
+ if (!hasOtherStructuredBlocks && Buffer.byteLength(stringifyModelContentForSerialization(completeContent), "utf8") <= maxModelBytes) {
81103
+ return { content: completeContent, truncated: false };
81073
81104
  }
81105
+ const suffixText = joinTextBlocks(suffixBlocks);
81106
+ const pairBytes = Buffer.byteLength(stringifyModelContentForSerialization(pairContent), "utf8");
81107
+ const remainingAfterPair = Math.max(0, maxModelBytes - pairBytes);
81108
+ const projectedMarker = fitStringToBytes(OFFICIAL_CUA_TEXT_TRUNCATION_MARKER, Math.max(0, remainingAfterPair - 2), "head");
81109
+ const markerCost = projectedMarker.length > 0 ? Buffer.byteLength(projectedMarker, "utf8") + 2 : 0;
81110
+ const suffixBudget = projectedMarker.length > 0 ? Math.max(0, remainingAfterPair - markerCost - 2) : 0;
81111
+ const projectedSuffix = fitStringToBytes(suffixText, suffixBudget, direction);
81074
81112
  const projected = [
81075
81113
  pair.image,
81076
81114
  pair.imageRef,
81077
- ...projectedPrefix ? [{ type: "text", text: projectedPrefix }] : [],
81078
- ...projectedSuffix ? [{ type: "text", text: projectedSuffix }] : []
81115
+ ...projectedSuffix ? [{ type: "text", text: projectedSuffix }] : [],
81116
+ ...projectedMarker ? [{ type: "text", text: projectedMarker }] : []
81079
81117
  ];
81080
- const hasOtherStructuredBlocks = content.some((block, index) => index !== pair.imageRefIndex && index !== pair.imageIndex && block.type !== "text");
81081
81118
  return {
81082
81119
  content: projected,
81083
- truncated: projectedPrefix !== prefixText || projectedSuffix !== suffixText || hasOtherStructuredBlocks
81120
+ truncated: true
81084
81121
  };
81085
81122
  }
81086
81123
  function appendHookWithoutReorderingStructuredContent(serialization, hookContext, suffix, maxModelBytes) {
@@ -81200,132 +81237,6 @@ function fitStringToBytes(value, maxBytes, direction) {
81200
81237
  return direction === "tail" ? chars.slice(chars.length - low).join("") : chars.slice(0, low).join("");
81201
81238
  }
81202
81239
 
81203
- // ../core/dist/mcp/official-cua-action-state.js
81204
- var ACTION_OUTCOME_SCHEMA_VERSION = "zcode-cua-action-outcome-v1";
81205
- var OFFICIAL_CUA_ACTION_STATE_MAX_TEXT_BYTES = 240 * 1024;
81206
- function preserveOfficialCuaActionStateResult(result) {
81207
- const inspection = inspectTextBlocks(result.content, OFFICIAL_CUA_ACTION_STATE_MAX_TEXT_BYTES);
81208
- if (!inspection)
81209
- return result;
81210
- if (result.structuredContent !== void 0) {
81211
- return createRefreshRequiredResult(inspection.outcome, "consumer_state_pair_invalid");
81212
- }
81213
- if (inspection.valid)
81214
- return result;
81215
- return createRefreshRequiredResult(inspection.outcome, inspection.reason);
81216
- }
81217
- function hasOfficialCuaActionState(content) {
81218
- return inspectModelContent(content, Number.POSITIVE_INFINITY) !== void 0;
81219
- }
81220
- function projectOfficialCuaActionStateContent(content, maxTextBytes) {
81221
- const inspection = inspectModelContent(content, maxTextBytes);
81222
- if (!inspection)
81223
- return void 0;
81224
- if (inspection.valid)
81225
- return { content, truncated: false };
81226
- const refresh = createRefreshRequiredOutcome(inspection.outcome, inspection.reason);
81227
- return {
81228
- content: [{ type: "text", text: JSON.stringify(refresh) }],
81229
- truncated: true
81230
- };
81231
- }
81232
- function inspectModelContent(content, maxTextBytes) {
81233
- const blocks = typeof content === "string" ? [{ type: "text", text: content }] : content;
81234
- return inspectTextBlocks(blocks, maxTextBytes);
81235
- }
81236
- function inspectTextBlocks(blocks, maxTextBytes) {
81237
- const candidates = [];
81238
- let textBytes = 0;
81239
- for (const [index, block] of blocks.entries()) {
81240
- if (block.type !== "text" || typeof block.text !== "string")
81241
- continue;
81242
- textBytes += Buffer.byteLength(block.text, "utf8");
81243
- const outcome = parseActionOutcome(block.text);
81244
- if (outcome)
81245
- candidates.push({ index, outcome });
81246
- }
81247
- if (candidates.length === 0)
81248
- return void 0;
81249
- const first = candidates[0];
81250
- if (candidates.length !== 1) {
81251
- return invalidInspection(first, "consumer_state_pair_invalid");
81252
- }
81253
- if (textBytes > maxTextBytes) {
81254
- return invalidInspection(first, "consumer_state_budget_exceeded");
81255
- }
81256
- if (first.outcome.state_sync_status === "refresh_required") {
81257
- return { ...first, valid: true };
81258
- }
81259
- const postStateId = asNonEmptyString(first.outcome.post_state_id);
81260
- if (!postStateId || first.outcome.state_available !== true) {
81261
- return invalidInspection(first, "consumer_state_pair_invalid");
81262
- }
81263
- const matchingStates = blocks.slice(0, first.index).filter((block) => block.type === "text" && typeof block.text === "string" && isMatchingFullState(block.text, postStateId));
81264
- if (matchingStates.length !== 1) {
81265
- return invalidInspection(first, "consumer_state_pair_invalid");
81266
- }
81267
- return { ...first, valid: true };
81268
- }
81269
- function invalidInspection(candidate, reason) {
81270
- return { ...candidate, valid: false, reason };
81271
- }
81272
- function parseActionOutcome(text) {
81273
- let parsed;
81274
- try {
81275
- parsed = JSON.parse(text);
81276
- } catch {
81277
- return void 0;
81278
- }
81279
- if (!isRecord11(parsed))
81280
- return void 0;
81281
- const candidate = isRecord11(parsed.action_outcome) ? parsed.action_outcome : parsed;
81282
- if (candidate.schema_version !== ACTION_OUTCOME_SCHEMA_VERSION || candidate.state_sync_status !== "synced" && candidate.state_sync_status !== "refresh_required") {
81283
- return void 0;
81284
- }
81285
- return candidate;
81286
- }
81287
- function isMatchingFullState(text, expectedStateId) {
81288
- const firstLine = text.split("\n", 1)[0] ?? "";
81289
- const match = /^state_id=([^\s]+)(?:\s|$)/u.exec(firstLine);
81290
- if (match?.[1] !== expectedStateId)
81291
- return false;
81292
- return !/\bmode=(?:delta|no_change)\b/u.test(firstLine);
81293
- }
81294
- function createRefreshRequiredResult(outcome, reason) {
81295
- return {
81296
- content: [
81297
- {
81298
- type: "text",
81299
- text: JSON.stringify(createRefreshRequiredOutcome(outcome, reason))
81300
- }
81301
- ],
81302
- isError: true
81303
- };
81304
- }
81305
- function createRefreshRequiredOutcome(outcome, reason) {
81306
- return {
81307
- schema_version: ACTION_OUTCOME_SCHEMA_VERSION,
81308
- action_sent: true,
81309
- dispatch_status: outcome.dispatch_status === "accepted" || outcome.dispatch_status === "possibly_sent" ? outcome.dispatch_status : "possibly_sent",
81310
- state_sync_status: "refresh_required",
81311
- ...asNonEmptyString(outcome.pre_state_id) ? { pre_state_id: outcome.pre_state_id } : {},
81312
- ...asNonEmptyString(outcome.ax_error) ? { ax_error: outcome.ax_error } : {},
81313
- verification_status: "failed",
81314
- verification_reason: reason ?? "consumer_state_pair_invalid",
81315
- state_available: false,
81316
- retry_action: false,
81317
- effect_status: "unknown",
81318
- effect_attribution: "not_proven",
81319
- state: null
81320
- };
81321
- }
81322
- function asNonEmptyString(value) {
81323
- return typeof value === "string" && value.trim().length > 0 ? value : void 0;
81324
- }
81325
- function isRecord11(value) {
81326
- return typeof value === "object" && value !== null && !Array.isArray(value);
81327
- }
81328
-
81329
81240
  // ../core/dist/tool/executor/result-serialization.js
81330
81241
  var DEFAULT_RESULT_BUDGET = {
81331
81242
  maxInlineBytes: 1e5,
@@ -81335,6 +81246,7 @@ var DEFAULT_RESULT_BUDGET = {
81335
81246
  direction: "head"
81336
81247
  }
81337
81248
  };
81249
+ var OFFICIAL_CUA_INVALID_RASTER_RECOVERY_TEXT = "This CUA raster is invalid and cannot be used in this request. Do not send a coordinate target; capture a new raster first.";
81338
81250
  async function serializeOutput(deps, output, entry, traceContext, toolCallId, signal) {
81339
81251
  const effectiveBudget = entry.resultBudget ?? DEFAULT_RESULT_BUDGET;
81340
81252
  const modelContent = stringifyOutputForModel(output, entry);
@@ -81358,26 +81270,27 @@ async function serializeOutput(deps, output, entry, traceContext, toolCallId, si
81358
81270
  const shouldPersistArtifact = (originalBytes > maxModelBytes || exceedsCharacterBudget) && effectiveBudget.artifact?.enabled === true && effectiveBudget.strategy === "artifact";
81359
81271
  const artifact = shouldPersistArtifact ? await tryWriteToolArtifact(deps, content, contentType, entry, effectiveBudget, traceContext, toolCallId, signal) : void 0;
81360
81272
  const resolvedArtifactPath = artifact?.path ?? artifact?.uri ?? artifactPath;
81361
- if (entry.modelContentProtection === OFFICIAL_CUA_FRAME_MODEL_CONTENT_PROTECTION) {
81362
- const actionStateProjection = projectOfficialCuaActionStateContent(modelContent, Math.min(maxModelBytes, OFFICIAL_CUA_ACTION_STATE_MAX_TEXT_BYTES));
81363
- if (actionStateProjection) {
81364
- const projectedModelContent = actionStateProjection.content;
81365
- const projectedContent = stringifyModelContentForSerialization2(projectedModelContent);
81366
- const projectedBytes = Buffer.byteLength(projectedContent, "utf8");
81367
- const mediaBytes = structuredMediaBytes(projectedModelContent);
81368
- return {
81369
- content: projectedContent,
81370
- modelContent: projectedModelContent,
81371
- originalBytes,
81372
- returnedBytes: projectedBytes + mediaBytes,
81373
- truncated: actionStateProjection.truncated,
81374
- budgetStrategy: effectiveBudget.strategy,
81375
- artifactPath: resolvedArtifactPath
81376
- };
81377
- }
81378
- }
81379
81273
  if (entry.modelContentProtection === OFFICIAL_CUA_FRAME_MODEL_CONTENT_PROTECTION && hasImageBlock(modelContent)) {
81380
- const protectedProjection = projectOfficialCuaStructuredContent(modelContent, maxModelBytes, effectiveBudget.preview?.direction ?? "head");
81274
+ let protectedProjection;
81275
+ try {
81276
+ protectedProjection = projectOfficialCuaStructuredContent(modelContent, maxModelBytes, effectiveBudget.preview?.direction ?? "head");
81277
+ } catch (error98) {
81278
+ if (!(error98 instanceof OfficialCuaFrameContractError))
81279
+ throw error98;
81280
+ deps.logger?.warn("Official CUA frame contract rejected during result serialization", {
81281
+ ...traceContextToLogContext(traceContext),
81282
+ code: error98.code,
81283
+ event: "tool.result.cua_frame_contract_rejected",
81284
+ module: "core.tool.executor",
81285
+ status: "failed",
81286
+ toolCallId,
81287
+ toolName: entry.metadata.name
81288
+ });
81289
+ throw createCoreError(CoreErrorType.ToolExecutionFailed, OFFICIAL_CUA_INVALID_RASTER_RECOVERY_TEXT, {
81290
+ context: { code: error98.code, source: "tool" },
81291
+ recoverable: true
81292
+ });
81293
+ }
81381
81294
  if (protectedProjection) {
81382
81295
  const projectedModelContent = protectedProjection.content;
81383
81296
  const projectedContent = stringifyModelContentForSerialization2(projectedModelContent);
@@ -81451,9 +81364,6 @@ function appendHookAdditionalContexts(serialization, additionalContexts, entry)
81451
81364
  if (filteredAdditionalContexts.length === 0) {
81452
81365
  return omittedFrameCredential ? { ...serialization, truncated: true } : serialization;
81453
81366
  }
81454
- if (entry.modelContentProtection === OFFICIAL_CUA_FRAME_MODEL_CONTENT_PROTECTION && hasOfficialCuaActionState(serialization.modelContent ?? serialization.content)) {
81455
- return { ...serialization, truncated: true };
81456
- }
81457
81367
  const hookContext = formatHookAdditionalContexts(filteredAdditionalContexts);
81458
81368
  const suffix = `
81459
81369
 
@@ -87107,7 +87017,7 @@ var WRITE_USER_MODIFIED_NOTE = " The user modified your proposed content before
87107
87017
  var WRITE_NOT_READ_MESSAGE = "File has not been read yet. Read it first before writing to it.";
87108
87018
  var WRITE_STALE_MESSAGE = "File has been modified since read, either by the user or by a linter. Read it again before attempting to write it.";
87109
87019
  function formatWriteModelContent(output) {
87110
- if (!isRecord12(output)) {
87020
+ if (!isRecord11(output)) {
87111
87021
  return "The file has been written successfully.";
87112
87022
  }
87113
87023
  const filePath = typeof output.filePath === "string" ? output.filePath : "the file";
@@ -87368,7 +87278,7 @@ function recordReadFileStateMetadata2(context, entry) {
87368
87278
  if (metadata)
87369
87279
  context.recordReadFileStateMetadata(metadata);
87370
87280
  }
87371
- function isRecord12(value) {
87281
+ function isRecord11(value) {
87372
87282
  return typeof value === "object" && value !== null && !Array.isArray(value);
87373
87283
  }
87374
87284
 
@@ -87706,9 +87616,9 @@ var EDIT_NOT_READ_MESSAGE = "File has not been read yet. Read it first before wr
87706
87616
  var EDIT_STALE_MESSAGE = "File has been modified since read, either by the user or by a linter. Read it again before attempting to write it.";
87707
87617
  var EDIT_FRESHNESS_SUFFIX = " (file state is current in your context \u2014 no need to Read it back)";
87708
87618
  function formatEditModelContent(output) {
87709
- const filePath = isRecord13(output) && typeof output.filePath === "string" ? output.filePath : "the file";
87710
- const userModified = isRecord13(output) && output.userModified === true;
87711
- const replaceAll = isRecord13(output) && output.replaceAll === true;
87619
+ const filePath = isRecord12(output) && typeof output.filePath === "string" ? output.filePath : "the file";
87620
+ const userModified = isRecord12(output) && output.userModified === true;
87621
+ const replaceAll = isRecord12(output) && output.replaceAll === true;
87712
87622
  const modifiedNote = userModified ? ". The user modified your proposed changes before accepting them. " : "";
87713
87623
  const freshnessSuffix = userModified ? "" : EDIT_FRESHNESS_SUFFIX;
87714
87624
  if (replaceAll) {
@@ -87897,7 +87807,7 @@ var editToolEntry = {
87897
87807
  function editFailure(errorCode, message) {
87898
87808
  return { result: false, errorCode, message };
87899
87809
  }
87900
- function isRecord13(value) {
87810
+ function isRecord12(value) {
87901
87811
  return typeof value === "object" && value !== null && !Array.isArray(value);
87902
87812
  }
87903
87813
  function countOccurrences(content, needle) {
@@ -91648,7 +91558,7 @@ function formatStderrForModel(result) {
91648
91558
  return message;
91649
91559
  }
91650
91560
  function isBashOutputProviderError(output) {
91651
- if (!isRecord14(output))
91561
+ if (!isRecord13(output))
91652
91562
  return false;
91653
91563
  return isBashProviderErrorStatus(output);
91654
91564
  }
@@ -91719,7 +91629,7 @@ function maybeImageContent(result) {
91719
91629
  }
91720
91630
  ];
91721
91631
  }
91722
- function isRecord14(value) {
91632
+ function isRecord13(value) {
91723
91633
  return typeof value === "object" && value !== null && !Array.isArray(value);
91724
91634
  }
91725
91635
 
@@ -102523,11 +102433,20 @@ var FALLBACK_MANIFEST = {
102523
102433
  members: [{ name: "get", kind: "method", signature: "get(name: string): Promise<string>" }]
102524
102434
  },
102525
102435
  Browsers: {
102526
- members: ["list", "get", "getDefault", "getForUrl"].map((name) => ({
102527
- name,
102528
- kind: "method",
102529
- signature: `${name}(...)`
102530
- }))
102436
+ members: [
102437
+ ...["list", "get", "getDefault", "getForUrl"].map((name) => ({
102438
+ name,
102439
+ kind: "method",
102440
+ signature: `${name}(...)`
102441
+ })),
102442
+ // open() 是默认导航入口(同站复用 + 激活 + 原地跳转);不声明会被 hideUnknown
102443
+ // 代理隐藏,REPL 里 agent.browsers.open 变 undefined(与插件 docs/api.json 同步维护)。
102444
+ {
102445
+ name: "open",
102446
+ kind: "method",
102447
+ signature: "open(url?: string, options?: { reuseTab?: boolean }): Promise<Tab>"
102448
+ }
102449
+ ]
102531
102450
  },
102532
102451
  Browser: {
102533
102452
  members: [
@@ -103061,6 +102980,9 @@ var FALLBACK_DOCUMENTATION = [
103061
102980
  "Backend types are `iab | extension | cdp`; Playwright is a tab API surface, not a backend. Never assume an unlisted backend is available.",
103062
102981
  "High-level methods return payloads directly and throw `BrowserCommandError` on failure.",
103063
102982
  "Before each logical tab-operation batch, return the complete `browser.tabs.list()` result in a dedicated observation cell. Each `TabInfo` includes `viewport: BrowserViewportSize`. After the model inspects the list, match by stable id or verified URL/title and call `tabs.get(id)` in the next cell; if no controlled tab matches, inspect and claim `browser.user.openTabs()` before creating a new tab.",
102983
+ // 修复原因:模型每次对同站 URL 都走 tabs.new(),任务结束后 IAB 堆满标签页(用户工单反馈)。
102984
+ // open() 现在内置同站复用(激活 + 原地跳转),文档必须把 open() 教成默认导航入口。
102985
+ "`agent.browsers.open(url)` is the default navigation entry: it reuses an existing same-site controlled tab (same hostname), activates it so the user sees it, and navigates in place instead of stacking new tabs. Only pass `{ reuseTab: false }` (or use `browser.tabs.new()`) when the task genuinely needs a parallel independent tab.",
103064
102986
  // 修复原因:Codex 的模型轨迹会在新 URL 的 goto 后显式确认 DOMContentLoaded;fallback 也必须保留同一顺序。
103065
102987
  'For a genuinely new URL with no intended existing page, use `const tab = await browser.tabs.new()`, run `await tab.goto(url)`, then run `await tab.playwright.waitForLoadState({ state: "domcontentloaded" })` before returning the first title, URL, or DOM observation.',
103066
102988
  'After every successful `tab.goto(url)`, explicitly call `await tab.playwright.waitForLoadState({ state: "domcontentloaded" })` before the first title, URL, or DOM observation. Keep this confirmation in the model-visible trajectory even when goto() has already settled the backend navigation. Do not replace it with networkidle or a fixed sleep; routine URL/load-state waits remain capped at 3000ms.',
@@ -103255,6 +103177,27 @@ function urlMatchRank(target, candidate) {
103255
103177
  return 3;
103256
103178
  return void 0;
103257
103179
  }
103180
+ function selectTabForUrl(targetValue, tabs) {
103181
+ const target = parseUrl(targetValue);
103182
+ let best;
103183
+ for (const tab of tabs) {
103184
+ if (!tab.url)
103185
+ continue;
103186
+ let rank;
103187
+ try {
103188
+ rank = urlMatchRank(target, parseUrl(tab.url));
103189
+ } catch {
103190
+ continue;
103191
+ }
103192
+ if (rank === void 0 || rank > 2)
103193
+ continue;
103194
+ if (best === void 0 || rank < best.rank || // 同 rank:active 优先;都不 active 时列表靠后(更新)的胜出。
103195
+ rank === best.rank && (tab.active === true || best.tab.active !== true)) {
103196
+ best = { tab, rank };
103197
+ }
103198
+ }
103199
+ return best?.tab;
103200
+ }
103258
103201
  function selectBrowserForUrl(infos, targetValue, tabsByBrowserId) {
103259
103202
  if (infos.length === 0) {
103260
103203
  throw new Error("No browser backend is available");
@@ -104391,6 +104334,21 @@ var BrowserTabs = class {
104391
104334
  const summary = expectPayload(command, result, result.tab, "tab");
104392
104335
  return this.tab(summary);
104393
104336
  }
104337
+ /**
104338
+ * open(url) 的复用入口:按 URL 匹配已有 agent-owned tab,命中则激活(activateTab,
104339
+ * 用户立即看到该 tab)并返回,未命中返回 undefined。list/activate 的失败向调用方抛出,
104340
+ * 由 open() 统一降级为 newTab,复用链路绝不阻断任务。
104341
+ */
104342
+ async reuse(url3) {
104343
+ const summaries = await this.summaries();
104344
+ const matched = selectTabForUrl(url3, summaries);
104345
+ if (!matched)
104346
+ return void 0;
104347
+ const command = { method: "activateTab", tabId: matched.tabId };
104348
+ const result = await this.execute(command);
104349
+ const activated = expectPayload(command, result, result.tab, "tab");
104350
+ return this.tab(activated);
104351
+ }
104394
104352
  async finalize(options = {}) {
104395
104353
  const keep = (options.keep ?? []).map(({ tab, status }) => ({
104396
104354
  tabId: typeof tab === "string" ? tab : tab.id,
@@ -104584,8 +104542,16 @@ var BrowsersFacade = class {
104584
104542
  }));
104585
104543
  return this.browserFor(selectBrowserForUrl(infos, url3, tabsByBrowserId));
104586
104544
  }
104587
- async open(url3) {
104588
- const tab = await (await this.getDefault()).tabs.new();
104545
+ async open(url3, options = {}) {
104546
+ const browser = await this.getDefault();
104547
+ if (url3 && options.reuseTab !== false) {
104548
+ const reusable = await browser.tabs.reuse(url3).catch(() => void 0);
104549
+ if (reusable) {
104550
+ await reusable.goto(url3);
104551
+ return reusable;
104552
+ }
104553
+ }
104554
+ const tab = await browser.tabs.new();
104589
104555
  if (url3) {
104590
104556
  await tab.goto(url3);
104591
104557
  }
@@ -104998,9 +104964,11 @@ var jsResetToolEntry = {
104998
104964
  readOnly: false,
104999
104965
  destructive: false,
105000
104966
  concurrentSafe: false,
105001
- sideEffectScope: "system",
104967
+ // 修复原因:守卫要求 metadata.timeoutMs 与 timeout.defaultMs 一致(同 grep/glob 先例)。
104968
+ sideEffectScope: "none",
105002
104969
  riskLevel: "low",
105003
- needsApproval: false
104970
+ needsApproval: false,
104971
+ timeoutMs: 5e3
105004
104972
  },
105005
104973
  handler: jsResetHandler,
105006
104974
  inputSchema: JsResetInputJsonSchema,
@@ -105032,7 +105000,9 @@ var jsAddModuleDirToolEntry = {
105032
105000
  concurrentSafe: false,
105033
105001
  sideEffectScope: "none",
105034
105002
  riskLevel: "low",
105035
- needsApproval: false
105003
+ needsApproval: false,
105004
+ // 修复原因:守卫要求 metadata.timeoutMs 与 timeout.defaultMs(SHORT_TIMEOUT)一致。
105005
+ timeoutMs: 5e3
105036
105006
  },
105037
105007
  handler: jsAddModuleDirHandler,
105038
105008
  inputSchema: JsAddModuleDirInputJsonSchema,
@@ -106449,7 +106419,7 @@ function extractResults(toolResults) {
106449
106419
  function collectResults(value) {
106450
106420
  if (Array.isArray(value))
106451
106421
  return value.flatMap((item) => collectResults(item));
106452
- if (!isRecord15(value))
106422
+ if (!isRecord14(value))
106453
106423
  return [];
106454
106424
  const url3 = stringValue(value.url);
106455
106425
  const type = stringValue(value.type);
@@ -106492,7 +106462,7 @@ function extractSourcesFromSummary(summary) {
106492
106462
  function collectSources(value) {
106493
106463
  if (Array.isArray(value))
106494
106464
  return value.flatMap((item) => collectSources(item));
106495
- if (!isRecord15(value))
106465
+ if (!isRecord14(value))
106496
106466
  return [];
106497
106467
  const url3 = stringValue(value.url);
106498
106468
  if (url3)
@@ -106533,7 +106503,7 @@ function nullableString(value) {
106533
106503
  function stringValue(value) {
106534
106504
  return typeof value === "string" && value.length > 0 ? value : void 0;
106535
106505
  }
106536
- function isRecord15(value) {
106506
+ function isRecord14(value) {
106537
106507
  return typeof value === "object" && value !== null && !Array.isArray(value);
106538
106508
  }
106539
106509
 
@@ -112345,11 +112315,10 @@ var HOST_NODE_REPL_IMAGE_MAX_DIMENSION = 2048;
112345
112315
  var HOST_NODE_REPL_MODEL_IMAGE_MAX_DIMENSION = 2e3;
112346
112316
  async function normalizeMcpToolResultForModel(input) {
112347
112317
  if (input.preserveOfficialCuaFrames) {
112348
- const frameSafeResult = await preserveOfficialCuaFrameResult(input.result, {
112318
+ return preserveOfficialCuaFrameResult(input.result, {
112349
112319
  imageProcessorPort: input.context.imageProcessorPort,
112350
112320
  signal: input.context.abortSignal
112351
112321
  });
112352
- return preserveOfficialCuaActionStateResult(frameSafeResult);
112353
112322
  }
112354
112323
  let changed = false;
112355
112324
  const content = [];
@@ -112685,8 +112654,8 @@ function createMcpToolEntry(name, descriptor2, mcpPort, officialCuaAuthorityVeri
112685
112654
  ...officialCuaAuthorityVerified ? {
112686
112655
  permissionCapabilityGroup: OFFICIAL_CUA_PERMISSION_CAPABILITY_GROUP,
112687
112656
  // 最终栅格和紧随其后的 image_ref 共同定义模型唯一可用的像素坐标系。
112688
- // 通用 resultBudget / hook 投影不能截断、丢弃或重排这组块。
112689
- preserveStructuredModelContent: true,
112657
+ // modelContentProtection 是唯一 Host authority;通用 resultBudget / hook
112658
+ // 投影据此不能截断、丢弃或重排这组块,避免并行 boolean 漂移。
112690
112659
  modelContentProtection: OFFICIAL_CUA_FRAME_MODEL_CONTENT_PROTECTION
112691
112660
  } : {},
112692
112661
  inputSchema: createModelFacingMcpInputSchema(descriptor2, isCuaAppObservation),
@@ -112762,7 +112731,7 @@ function createMcpToolEntry(name, descriptor2, mcpPort, officialCuaAuthorityVeri
112762
112731
  toolName: name
112763
112732
  });
112764
112733
  },
112765
- formatModelContent: (output) => formatMcpToolResult(output, officialCuaAuthorityVerified)
112734
+ formatModelContent: (output) => formatMcpToolResult(output)
112766
112735
  };
112767
112736
  }
112768
112737
  function officialCuaProviderSpellingAliases(name, descriptor2, officialCuaAuthorityVerified) {
@@ -112839,7 +112808,7 @@ function hasInformativeStructuredContent(value) {
112839
112808
  return Object.keys(value).length > 0;
112840
112809
  return true;
112841
112810
  }
112842
- function formatMcpToolResult(output, officialCuaAuthorityVerified = false) {
112811
+ function formatMcpToolResult(output) {
112843
112812
  if (!isMcpToolCallResult(output)) {
112844
112813
  return stringify(output);
112845
112814
  }
@@ -112851,9 +112820,6 @@ function formatMcpToolResult(output, officialCuaAuthorityVerified = false) {
112851
112820
  ${stringify(output.structuredContent)}`
112852
112821
  });
112853
112822
  }
112854
- if (officialCuaAuthorityVerified && hasOfficialCuaActionState(blocks)) {
112855
- return blocks;
112856
- }
112857
112823
  const content = blocks.length > 0 ? collapseModelBlocks(blocks) : stringify(output);
112858
112824
  if (!output.isError)
112859
112825
  return content;
@@ -114683,7 +114649,7 @@ function aggregateModelUsage(events) {
114683
114649
  if (event.type !== SessionEventType.ModelComplete)
114684
114650
  continue;
114685
114651
  const payload = event.payload;
114686
- if (!isRecord16(payload) || !isRecord16(payload.usage)) {
114652
+ if (!isRecord15(payload) || !isRecord15(payload.usage)) {
114687
114653
  continue;
114688
114654
  }
114689
114655
  const modelUsage = payload.usage;
@@ -114698,7 +114664,7 @@ function resolveSubagentToolUseCount(events) {
114698
114664
  let turnCompleteToolCallCount = 0;
114699
114665
  let sawTurnCompleteToolCallCount = false;
114700
114666
  for (const event of events) {
114701
- if (event.type !== SessionEventType.TurnComplete || !isRecord16(event.payload)) {
114667
+ if (event.type !== SessionEventType.TurnComplete || !isRecord15(event.payload)) {
114702
114668
  continue;
114703
114669
  }
114704
114670
  const toolCallCount = event.payload.toolCallCount;
@@ -114741,7 +114707,7 @@ function resolveTotalTokens(usage) {
114741
114707
  }
114742
114708
  return getModelUsageTotalTokens(usage);
114743
114709
  }
114744
- function isRecord16(value) {
114710
+ function isRecord15(value) {
114745
114711
  return typeof value === "object" && value !== null && !Array.isArray(value);
114746
114712
  }
114747
114713
  function resolveAllowedTools(profile, options, executionModelRef2) {
@@ -116845,6 +116811,24 @@ function cloneRuntimeEntry2(entry) {
116845
116811
  return cloneRuntimeMessageEntry(entry);
116846
116812
  }
116847
116813
 
116814
+ // ../core/dist/runtime/helpers/official-cua-media.js
116815
+ var OFFICIAL_CUA_RASTER_UNAVAILABLE_TEXT = "This CUA raster is not visible in this request. Do not send a coordinate target; capture a new raster first.";
116816
+ function officialCuaImageRefIndexesForUnavailableMedia(content, unavailableMediaIndexes) {
116817
+ const imageRefIndexes = /* @__PURE__ */ new Set();
116818
+ for (const mediaIndex of unavailableMediaIndexes) {
116819
+ if (content[mediaIndex]?.type !== "image")
116820
+ continue;
116821
+ const candidate = content[mediaIndex + 1];
116822
+ if (candidate?.type === "text" && containsOfficialCuaImageRefCredentialText(candidate.text)) {
116823
+ imageRefIndexes.add(mediaIndex + 1);
116824
+ }
116825
+ }
116826
+ return imageRefIndexes;
116827
+ }
116828
+ function officialCuaRasterUnavailableBlock() {
116829
+ return { type: "text", text: OFFICIAL_CUA_RASTER_UNAVAILABLE_TEXT };
116830
+ }
116831
+
116848
116832
  // ../core/dist/runtime/helpers/compact-media.js
116849
116833
  function projectCompactMediaForRetry(messages) {
116850
116834
  let replacedMediaCount = 0;
@@ -116887,18 +116871,10 @@ function projectCompactContent(content) {
116887
116871
  replacedIndexes.add(blockIndex);
116888
116872
  return projectedBlock.block;
116889
116873
  });
116890
- for (const mediaIndex of replacedIndexes) {
116891
- for (let index = mediaIndex + 1; index < projectedBlocks.length; index += 1) {
116892
- const candidate = projectedBlocks[index];
116893
- if (candidate.type !== "text")
116894
- break;
116895
- if (candidate.text.trim().length === 0)
116896
- continue;
116897
- if (!containsOfficialCuaImageRefCredentialText(candidate.text))
116898
- break;
116899
- projectedBlocks[index] = { type: "text", text: "" };
116900
- break;
116901
- }
116874
+ const imageRefIndexes = officialCuaImageRefIndexesForUnavailableMedia(content, replacedIndexes);
116875
+ for (const imageRefIndex of imageRefIndexes) {
116876
+ projectedBlocks[imageRefIndex - 1] = officialCuaRasterUnavailableBlock();
116877
+ projectedBlocks[imageRefIndex] = { type: "text", text: "" };
116902
116878
  }
116903
116879
  return {
116904
116880
  content: replacedIndexes.size > 0 ? projectedBlocks : content,
@@ -116982,7 +116958,7 @@ function modelContentForToolResult(result) {
116982
116958
  function isErrorForToolResult(result) {
116983
116959
  if (!result.success)
116984
116960
  return true;
116985
- if (!isRecord18(result.output))
116961
+ if (!isRecord17(result.output))
116986
116962
  return false;
116987
116963
  const explicitIsError = result.output.isError ?? result.output.is_error;
116988
116964
  if (typeof explicitIsError === "boolean")
@@ -117002,7 +116978,7 @@ function stringifyForEstimation(value) {
117002
116978
  return String(value);
117003
116979
  }
117004
116980
  }
117005
- function isRecord18(value) {
116981
+ function isRecord17(value) {
117006
116982
  return typeof value === "object" && value !== null && !Array.isArray(value);
117007
116983
  }
117008
116984
  function parseMcpToolName(name) {
@@ -118345,7 +118321,18 @@ function projectMessagesForMediaCapabilities(messages, capabilities) {
118345
118321
  return message;
118346
118322
  }
118347
118323
  let messageChanged = false;
118348
- const content = message.content.map((block) => {
118324
+ const unavailableMediaIndexes = /* @__PURE__ */ new Set();
118325
+ message.content.forEach((block, index) => {
118326
+ if (unsupportedMediaReplacement(block, capabilities))
118327
+ unavailableMediaIndexes.add(index);
118328
+ });
118329
+ const imageRefIndexes = officialCuaImageRefIndexesForUnavailableMedia(message.content, unavailableMediaIndexes);
118330
+ const content = message.content.map((block, index) => {
118331
+ if (imageRefIndexes.has(index)) {
118332
+ messageChanged = true;
118333
+ changed = true;
118334
+ return { type: "text", text: "" };
118335
+ }
118349
118336
  const replacement = unsupportedMediaReplacement(block, capabilities);
118350
118337
  if (!replacement) {
118351
118338
  if (isProviderVisibleModelInputMediaBlock(block))
@@ -118360,7 +118347,7 @@ function projectMessagesForMediaCapabilities(messages, capabilities) {
118360
118347
  omittedPdfCount++;
118361
118348
  if (block.type === "video")
118362
118349
  omittedVideoCount++;
118363
- return replacement;
118350
+ return imageRefIndexes.has(index + 1) ? officialCuaRasterUnavailableBlock() : replacement;
118364
118351
  });
118365
118352
  if (!messageChanged) {
118366
118353
  return message;
@@ -118569,20 +118556,7 @@ function projectContent(content, messageIndex, retainedKeys) {
118569
118556
  omittedBlockIndexes.add(blockIndex);
118570
118557
  }
118571
118558
  });
118572
- const pairedTextIndexes = /* @__PURE__ */ new Set();
118573
- for (const mediaIndex of omittedBlockIndexes) {
118574
- for (let index = mediaIndex + 1; index < content.length; index += 1) {
118575
- const candidate = content[index];
118576
- if (candidate.type !== "text")
118577
- break;
118578
- if (candidate.text.trim().length === 0)
118579
- continue;
118580
- if (!containsOfficialCuaImageRefCredentialText(candidate.text))
118581
- break;
118582
- pairedTextIndexes.add(index);
118583
- break;
118584
- }
118585
- }
118559
+ const pairedTextIndexes = officialCuaImageRefIndexesForUnavailableMedia(content, omittedBlockIndexes);
118586
118560
  return content.map((block, blockIndex) => {
118587
118561
  if (pairedTextIndexes.has(blockIndex)) {
118588
118562
  return { type: "text", text: "" };
@@ -118590,7 +118564,9 @@ function projectContent(content, messageIndex, retainedKeys) {
118590
118564
  if (mediaPayload(block).bytes === 0)
118591
118565
  return cloneContentBlock2(block);
118592
118566
  const key = mediaKey({ blockIndex, messageIndex });
118593
- return retainedKeys.has(key) ? cloneContentBlock2(block) : mediaOmittedTextBlock(block);
118567
+ if (retainedKeys.has(key))
118568
+ return cloneContentBlock2(block);
118569
+ return pairedTextIndexes.has(blockIndex + 1) ? officialCuaRasterUnavailableBlock() : mediaOmittedTextBlock(block);
118594
118570
  });
118595
118571
  }
118596
118572
  function mediaPayload(block) {
@@ -125242,8 +125218,8 @@ function compactCategoryBreakdown(value) {
125242
125218
  if (!Array.isArray(value)) {
125243
125219
  return void 0;
125244
125220
  }
125245
- return value.filter(isRecord19).map((category) => {
125246
- const contributors = Array.isArray(category.contributors) ? category.contributors.filter(isRecord19) : [];
125221
+ return value.filter(isRecord18).map((category) => {
125222
+ const contributors = Array.isArray(category.contributors) ? category.contributors.filter(isRecord18) : [];
125247
125223
  return {
125248
125224
  ...pickDefined(category, [
125249
125225
  "chars",
@@ -125307,7 +125283,7 @@ function contributorSortValue(contributor) {
125307
125283
  function arrayLength(value) {
125308
125284
  return Array.isArray(value) ? value.length : void 0;
125309
125285
  }
125310
- function isRecord19(value) {
125286
+ function isRecord18(value) {
125311
125287
  return typeof value === "object" && value !== null && !Array.isArray(value);
125312
125288
  }
125313
125289
 
@@ -125443,7 +125419,7 @@ function buildContextUsageBreakdownFromSnapshot(snapshot) {
125443
125419
  const categories = Array.isArray(snapshot.categories) ? snapshot.categories : [];
125444
125420
  const breakdown = [];
125445
125421
  for (const category of categories) {
125446
- if (!isRecord20(category)) {
125422
+ if (!isRecord19(category)) {
125447
125423
  continue;
125448
125424
  }
125449
125425
  const source = contextUsageBreakdownSource(category.source);
@@ -125463,7 +125439,7 @@ function buildContextUsageCategory(name, source, metric) {
125463
125439
  percentTokens: 0
125464
125440
  };
125465
125441
  }
125466
- function isRecord20(value) {
125442
+ function isRecord19(value) {
125467
125443
  return typeof value === "object" && value !== null && !Array.isArray(value);
125468
125444
  }
125469
125445
  function contextUsageBreakdownSource(value) {
@@ -125667,10 +125643,10 @@ function parseMemoryFrontmatter(content) {
125667
125643
  } catch {
125668
125644
  return {};
125669
125645
  }
125670
- if (!isRecord21(parsed))
125646
+ if (!isRecord20(parsed))
125671
125647
  return {};
125672
125648
  const description = typeof parsed.description === "string" ? parsed.description : void 0;
125673
- const metadata = isRecord21(parsed.metadata) ? parsed.metadata : void 0;
125649
+ const metadata = isRecord20(parsed.metadata) ? parsed.metadata : void 0;
125674
125650
  const typeCandidate = metadata?.type ?? parsed.type;
125675
125651
  const type = isMemoryRecallType(typeCandidate) ? typeCandidate : void 0;
125676
125652
  return {
@@ -125678,7 +125654,7 @@ function parseMemoryFrontmatter(content) {
125678
125654
  ...type ? { type } : {}
125679
125655
  };
125680
125656
  }
125681
- function isRecord21(value) {
125657
+ function isRecord20(value) {
125682
125658
  return typeof value === "object" && value !== null && !Array.isArray(value);
125683
125659
  }
125684
125660
  function isMemoryRecallType(value) {
@@ -125810,7 +125786,7 @@ ${formatMemoryManifest(manifest)}`,
125810
125786
  }
125811
125787
  function parseSelectorResponse(text) {
125812
125788
  const parsed = JSON.parse(text);
125813
- if (!isRecord22(parsed))
125789
+ if (!isRecord21(parsed))
125814
125790
  return void 0;
125815
125791
  if (Object.keys(parsed).some((key) => key !== "selected_memories" && key !== "selected_knowledge_ids")) {
125816
125792
  return void 0;
@@ -125825,7 +125801,7 @@ function parseSelectorResponse(text) {
125825
125801
  selectedKnowledgeIds: parsed.selected_knowledge_ids ? [...parsed.selected_knowledge_ids] : []
125826
125802
  };
125827
125803
  }
125828
- function isRecord22(value) {
125804
+ function isRecord21(value) {
125829
125805
  return typeof value === "object" && value !== null && !Array.isArray(value);
125830
125806
  }
125831
125807
  function isStringArray(value) {
@@ -127215,9 +127191,9 @@ async function emitNestedModelUsageEvents(runtime, input) {
127215
127191
  }
127216
127192
  }
127217
127193
  function extractNestedModelUsage(output) {
127218
- if (!isRecord23(output) || !isRecord23(output.modelUsage))
127194
+ if (!isRecord22(output) || !isRecord22(output.modelUsage))
127219
127195
  return void 0;
127220
- const serverToolUse = isRecord23(output.modelUsage.serverToolUse) ? {
127196
+ const serverToolUse = isRecord22(output.modelUsage.serverToolUse) ? {
127221
127197
  webFetchRequests: numberProperty2(output.modelUsage.serverToolUse, "webFetchRequests"),
127222
127198
  webSearchRequests: numberProperty2(output.modelUsage.serverToolUse, "webSearchRequests")
127223
127199
  } : void 0;
@@ -127235,7 +127211,7 @@ function numberProperty2(record3, key) {
127235
127211
  const value = record3[key];
127236
127212
  return typeof value === "number" && Number.isFinite(value) ? value : void 0;
127237
127213
  }
127238
- function isRecord23(value) {
127214
+ function isRecord22(value) {
127239
127215
  return typeof value === "object" && value !== null && !Array.isArray(value);
127240
127216
  }
127241
127217
 
@@ -137642,7 +137618,7 @@ function toMcpRunResult(run) {
137642
137618
 
137643
137619
  // src/mcp/tool-contract.ts
137644
137620
  var NODE_REPL_DEFAULT_TIMEOUT_MS = 6e4;
137645
- var NODE_REPL_SERVER_VERSION = "0.3.1";
137621
+ var NODE_REPL_SERVER_VERSION = "0.4.0";
137646
137622
  var NODE_REPL_SERVER_INSTRUCTIONS = `Browser Use only. Use \`js\` to run JavaScript in a fresh Node-backed kernel only when the Browser Use skill instructs you to control a browser. Do not use this server for non-browser tasks, including general-purpose JavaScript, filesystem, shell, package inspection, or data processing. Calls default to a ${NODE_REPL_DEFAULT_TIMEOUT_MS} ms timeout. Always provide \`title\` as a short user-facing description in the user's language. Every \`js\` call starts fresh; reconstruct browser wrappers and recover persistent tabs from current BrowserControl facts. Use \`js_add_node_module_dir\` before dynamic imports when a skill provides a package directory.`;
137647
137623
  var JS_TOOL_DESCRIPTION = `Browser Use only. Run JavaScript in a fresh Node-backed kernel with top-level await only as instructed by the Browser Use skill to control a browser. Do not use it as a general-purpose JavaScript runtime or for filesystem, shell, package inspection, data processing, or other non-browser work. Always provide the required \`title\` as a short user-facing description in the user's language without implementation terms. If \`timeout_ms\` is omitted, execution times out after ${NODE_REPL_DEFAULT_TIMEOUT_MS} ms. If the code may take more than 30000 ms including all awaited operations, you MUST set \`timeout_ms\` to at least the estimated total runtime plus 15000 ms; split the work into multiple calls if that exceeds the 120000 ms maximum. Use \`nodeRepl.cwd\`, \`nodeRepl.homeDir\`, \`nodeRepl.tmpDir\`, \`nodeRepl.requestMeta\`, \`nodeRepl.setResponseMeta(meta)\`, \`nodeRepl.write(value)\`, and \`await nodeRepl.emitImage(imageLike)\`. Global bindings and module cache do not persist across calls. Use dynamic imports such as \`await import("pkg")\` and bootstrap Browser Use in every call.`;
137648
137624
  var JS_RESET_DESCRIPTION = "Browser Use only. Compatibility barrier for callers that still request a JavaScript kernel reset. Every `js` call already starts in a fresh kernel, so this does not clear per-session module search roots.";