@opengeni/runtime 4.0.1 → 4.0.3-canary.36079201993001

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.
Files changed (48) hide show
  1. package/dist/{agent-RJQLKFIW.js → agent-ME6HT4DH.js} +2 -2
  2. package/dist/assets/codemode-client.json +1 -1
  3. package/dist/browser-action-json-schema.d.ts +4 -0
  4. package/dist/{chunk-J5AR5XAJ.js → chunk-GBVN7WSK.js} +377 -210
  5. package/dist/chunk-GBVN7WSK.js.map +1 -0
  6. package/dist/{chunk-ZG2YH25H.js → chunk-JAYHA6BF.js} +2 -2
  7. package/dist/{chunk-UNICCRW5.js → chunk-LZIXCZUV.js} +6 -3
  8. package/dist/{chunk-UNICCRW5.js.map → chunk-LZIXCZUV.js.map} +1 -1
  9. package/dist/{chunk-J6J3VYFW.js → chunk-OGG5NQLA.js} +597 -65
  10. package/dist/chunk-OGG5NQLA.js.map +1 -0
  11. package/dist/{chunk-SPT3PLMX.js → chunk-PRHMSM6C.js} +2 -2
  12. package/dist/context-compaction.d.ts +4 -2
  13. package/dist/index.d.ts +8 -6
  14. package/dist/index.js +9 -7
  15. package/dist/interaction-tools.d.ts +1 -1
  16. package/dist/{lazy-manifest-OEYEHNVY.js → lazy-manifest-GCGUFIWP.js} +3 -3
  17. package/dist/{localSources-TWHTEKGO.js → localSources-FDH65AFI.js} +4 -4
  18. package/dist/operational-instructions.d.ts +1 -1
  19. package/dist/sandbox/browser-control-client.d.ts +28 -1
  20. package/dist/sandbox/index.d.ts +2 -2
  21. package/dist/sandbox/index.js +6 -6
  22. package/dist/sandbox/providers/modal-command-router-wire.d.ts +8 -0
  23. package/dist/sandbox/providers/modal.d.ts +5 -6
  24. package/dist/workspace-tool-gateway.js +5 -5
  25. package/package.json +11 -11
  26. package/src/browser-action-json-schema.ts +10 -0
  27. package/src/bundled_artifact_skills/opengeni-documents/SKILL.md +4 -1
  28. package/src/bundled_artifact_skills/opengeni-documents/references/api.md +20 -0
  29. package/src/bundled_default_skills/opengeni-client/SKILL.md +4 -1
  30. package/src/bundled_default_skills/opengeni-client/references/discovery-and-autonomy.md +31 -0
  31. package/src/bundled_default_skills/opengeni-client/references/runtime-profile-and-verification.md +32 -0
  32. package/src/context-compaction.ts +19 -3
  33. package/src/index.ts +100 -36
  34. package/src/interaction-tools.ts +656 -48
  35. package/src/operational-instructions.ts +1 -1
  36. package/src/sandbox/browser-control-client.ts +241 -26
  37. package/src/sandbox/index.ts +3 -1
  38. package/src/sandbox/providers/modal-command-control.ts +7 -1
  39. package/src/sandbox/providers/modal-command-router-wire.ts +47 -6
  40. package/src/sandbox/providers/modal.ts +16 -24
  41. package/src/sandbox/routing/routing-session.ts +4 -2
  42. package/dist/chunk-J5AR5XAJ.js.map +0 -1
  43. package/dist/chunk-J6J3VYFW.js.map +0 -1
  44. /package/dist/{agent-RJQLKFIW.js.map → agent-ME6HT4DH.js.map} +0 -0
  45. /package/dist/{chunk-ZG2YH25H.js.map → chunk-JAYHA6BF.js.map} +0 -0
  46. /package/dist/{chunk-SPT3PLMX.js.map → chunk-PRHMSM6C.js.map} +0 -0
  47. /package/dist/{lazy-manifest-OEYEHNVY.js.map → lazy-manifest-GCGUFIWP.js.map} +0 -0
  48. /package/dist/{localSources-TWHTEKGO.js.map → localSources-FDH65AFI.js.map} +0 -0
@@ -8,6 +8,7 @@ import {
8
8
  createTurnToolCancellationController,
9
9
  installManagedCodemodeClient,
10
10
  isDefinitePathNotFoundError,
11
+ isModalTaskExecStartPreDispatchUnavailableError,
11
12
  isRoutingMutationOutcomeUnknownError,
12
13
  loadManagedCodemodeClient,
13
14
  managedCodemodeClientDirectory,
@@ -26,11 +27,11 @@ import {
26
27
  withRunCredentialsClient,
27
28
  withRunCredentialsSession,
28
29
  wrapCapabilityToolsForTurnCancellation
29
- } from "./chunk-J5AR5XAJ.js";
30
+ } from "./chunk-GBVN7WSK.js";
30
31
  import {
31
32
  MemorySession,
32
33
  connectMcpServers
33
- } from "./chunk-SPT3PLMX.js";
34
+ } from "./chunk-PRHMSM6C.js";
34
35
  import {
35
36
  SKILL_MAX_FILES,
36
37
  SKILL_READ_MAX_OUTPUT_BYTES,
@@ -114,7 +115,7 @@ import {
114
115
  tool,
115
116
  withGenerationSpan,
116
117
  withResponseSpan
117
- } from "./chunk-UNICCRW5.js";
118
+ } from "./chunk-LZIXCZUV.js";
118
119
 
119
120
  // src/prepared-compaction-request.ts
120
121
  import { AsyncLocalStorage } from "async_hooks";
@@ -580,6 +581,9 @@ import {
580
581
  } from "@opengeni/codex";
581
582
  var COMPACTION_SUMMARY_MARKER = "opengeni_context_summary";
582
583
  var SUMMARY_BUFFER_TOKENS = 2e4;
584
+ function compactionSummaryOutputTokens(contextWindowTokens) {
585
+ return Math.min(SUMMARY_BUFFER_TOKENS, Math.max(1, Math.floor(contextWindowTokens / 4)));
586
+ }
583
587
  var COMPACT_USER_MESSAGE_MAX_TOKENS = 2e4;
584
588
  var REMOTE_V2_RETAINED_MESSAGE_TOKEN_BUDGET = 64e3;
585
589
  var REMOTE_COMPACTION_V2_IMPLEMENTATION = "responses_compaction_v2";
@@ -1324,7 +1328,7 @@ var EmptyCompactionSummaryError = class extends Error {
1324
1328
  constructor(diagnostics = {}) {
1325
1329
  const compact = JSON.stringify(diagnostics).slice(0, 2e3);
1326
1330
  super(
1327
- `Compaction summarizer returned no assistant text; active history was preserved${compact ? ` (${compact})` : ""}`
1331
+ `Compaction could not produce a usable checkpoint; active history was preserved${compact ? ` (${compact})` : ""}`
1328
1332
  );
1329
1333
  this.name = "EmptyCompactionSummaryError";
1330
1334
  this.diagnostics = diagnostics;
@@ -1480,10 +1484,18 @@ function omitOpaqueArtifactsFromPortableCompactionHistory(items) {
1480
1484
  }
1481
1485
  if (type === "reasoning" && hasOpaqueProviderArtifact(item)) {
1482
1486
  const projected = projectRejectedReasoningArtifact(item);
1487
+ if (Object.keys(projected).length === 1) {
1488
+ changed = true;
1489
+ continue;
1490
+ }
1483
1491
  changed ||= projected !== item;
1484
1492
  out.push(projected);
1485
1493
  continue;
1486
1494
  }
1495
+ if (type === "reasoning" && Object.keys(item).length === 1) {
1496
+ changed = true;
1497
+ continue;
1498
+ }
1487
1499
  out.push(item);
1488
1500
  }
1489
1501
  return changed ? out : items;
@@ -1548,9 +1560,12 @@ function oldestLogicalUnitCuts(items) {
1548
1560
  cuts.push(items.length);
1549
1561
  return cuts;
1550
1562
  }
1551
- function buildCompactionReplacementHistory(items, summaryBody, retainedItemTokens = (item) => estimateTokens([item])) {
1563
+ function buildCompactionReplacementHistory(items, summaryBody, retainedItemTokens = (item) => estimateTokens([item]), retainedMessageBudgetTokens = COMPACT_USER_MESSAGE_MAX_TOKENS) {
1552
1564
  const retainedReversed = [];
1553
- let remaining = COMPACT_USER_MESSAGE_MAX_TOKENS;
1565
+ let remaining = Math.max(
1566
+ 0,
1567
+ Math.min(COMPACT_USER_MESSAGE_MAX_TOKENS, retainedMessageBudgetTokens)
1568
+ );
1554
1569
  for (let index = items.length - 1; index >= 0 && remaining > 0; index -= 1) {
1555
1570
  const item = items[index];
1556
1571
  if (!isUserMessage(item) || isCompactionSummary(item) || isAttachmentCatalog(item)) {
@@ -10389,7 +10404,7 @@ Skills are reusable instructions supplied dynamically for the current session. W
10389
10404
 
10390
10405
  # Integration setup
10391
10406
 
10392
- Use available integration tools directly. If the task needs an integration you cannot access, discover it with \`capability_catalog_search\` before declaring a setup blocker. For a suitable match with \`setup.nextAction\`, call \`capability_authorization_request\` with the returned capability ID and a brief task-specific rationale to show its Connect card in chat. Requesting the card does not need integration-management permission; the authenticated human must authorize setup. A card is for an integration required by the authorized design, including established or delegated choices. Resolve out-of-scope architecture choices before requesting setup. After setup, rediscover the tools and continue the task, verifying the access it needs. If access remains blocked, explain the specific blocker from the returned facts. If either setup tool is unavailable, report the missing setup path.
10407
+ Use available integration tools directly. If access is missing, search \`capability_catalog_search\` first. For a suitable match with \`setup.nextAction\`, call \`capability_authorization_request\` with its ID and a task-specific rationale. If no match exists and the task needs a remote MCP whose exact HTTPS URL the user supplied or reliable documentation establishes, call \`custom_mcp_setup_request\` with its name, URL, and rationale. Never invent URLs or request credentials in chat. Showing either card does not need integration-management permission and grants no access; the authenticated human must authorize setup. A card is for an integration required by the authorized design, including established or delegated choices. Resolve out-of-scope architecture choices before requesting setup. After setup, rediscover tools and verify access. If blocked or a setup tool is unavailable, explain the specific gap.
10393
10408
 
10394
10409
  # Session coordination
10395
10410
 
@@ -12348,7 +12363,7 @@ import { existsSync, readdirSync } from "fs";
12348
12363
  // ../sdk/package.json
12349
12364
  var package_default = {
12350
12365
  name: "@opengeni/sdk",
12351
- version: "7.1.0",
12366
+ version: "7.1.1-canary.36079201993001",
12352
12367
  description: "Framework-agnostic TypeScript SDK for the OpenGeni API: typed client, session lifecycle, SSE event streaming with reconnect + replay-by-sequence, and proxy re-streaming helpers.",
12353
12368
  license: "Apache-2.0",
12354
12369
  repository: {
@@ -12500,7 +12515,7 @@ var package_default = {
12500
12515
  // ../react/package.json
12501
12516
  var package_default2 = {
12502
12517
  name: "@opengeni/react",
12503
- version: "7.1.0",
12518
+ version: "7.1.2-canary.36079201993001",
12504
12519
  description: "React hooks and styled components for OpenGeni: live session streaming, chat composer, message timeline, session status, and fleet views \u2014 token-themed (CSS variables), dark-first, built on Tailwind v4 + Radix + Motion.",
12505
12520
  license: "Apache-2.0",
12506
12521
  repository: {
@@ -12753,7 +12768,7 @@ var package_default2 = {
12753
12768
  // ../codemode/package.json
12754
12769
  var package_default3 = {
12755
12770
  name: "@opengeni/codemode",
12756
- version: "0.6.1",
12771
+ version: "0.6.2-canary.36079201993001",
12757
12772
  description: "Attempt-frozen programmatic tool catalog and execution authority for OpenGeni.",
12758
12773
  license: "Apache-2.0",
12759
12774
  repository: {
@@ -12803,7 +12818,7 @@ var package_default3 = {
12803
12818
  // ../ogtool/package.json
12804
12819
  var package_default4 = {
12805
12820
  name: "@opengeni/ogtool",
12806
- version: "0.3.43",
12821
+ version: "0.3.44-canary.36079201993001",
12807
12822
  description: "Codemode CLI and typed client entrypoint for an OpenGeni execution attempt.",
12808
12823
  license: "Apache-2.0",
12809
12824
  repository: {
@@ -15021,6 +15036,10 @@ import {
15021
15036
  BrowserActionReceipt,
15022
15037
  BrowserClipboard,
15023
15038
  BrowserDiagnosticBatch,
15039
+ BrowserDomReadResponse,
15040
+ BrowserDomReadLocator,
15041
+ BrowserDomReadSelector,
15042
+ BrowserDomSafeAttribute,
15024
15043
  BrowserIdentity,
15025
15044
  BrowserIdentityListResponse,
15026
15045
  BrowserIdentityMutationResponse,
@@ -15061,6 +15080,16 @@ import {
15061
15080
  resolveFirstPartyDelegationSecret
15062
15081
  } from "@opengeni/config";
15063
15082
  import { OpenGeniApiError, OpenGeniClient } from "@opengeni/sdk";
15083
+
15084
+ // src/browser-action-json-schema.ts
15085
+ function browserActionInputJsonSchema(schema) {
15086
+ return external_exports.toJSONSchema(schema, {
15087
+ target: "draft-2020-12",
15088
+ reused: "ref"
15089
+ });
15090
+ }
15091
+
15092
+ // src/interaction-tools.ts
15064
15093
  var INTERACTION_ATTEMPT_TOOL_NAMES = FIRST_PARTY_IN_PROCESS_TOOL_NAMES;
15065
15094
  var InteractionExecutionResult = class {
15066
15095
  constructor(output, additionalContent) {
@@ -15068,11 +15097,161 @@ var InteractionExecutionResult = class {
15068
15097
  this.additionalContent = additionalContent;
15069
15098
  }
15070
15099
  };
15100
+ var BROWSER_AGENT_MAX_NODES = 60;
15101
+ var BROWSER_AGENT_MAX_NODE_BYTES = 12e3;
15102
+ var BROWSER_AGENT_MAX_FIELD_LENGTH = 180;
15103
+ var BROWSER_READ_MAX_NODES = 80;
15104
+ var BROWSER_TOOL_IMAGE_MAX_BYTES = 8 * 1024 * 1024;
15105
+ var BrowserAgentNode = external_exports.object({
15106
+ ref: external_exports.string().max(512),
15107
+ role: external_exports.string().max(256),
15108
+ depth: external_exports.number().int().nonnegative(),
15109
+ name: external_exports.string().max(BROWSER_AGENT_MAX_FIELD_LENGTH).optional(),
15110
+ description: external_exports.string().max(BROWSER_AGENT_MAX_FIELD_LENGTH).optional(),
15111
+ value: external_exports.union([
15112
+ external_exports.string().max(BROWSER_AGENT_MAX_FIELD_LENGTH),
15113
+ external_exports.object({ redacted: external_exports.literal(true), reason: external_exports.string().max(32) }).strict()
15114
+ ]).optional(),
15115
+ states: external_exports.array(external_exports.string().max(BROWSER_AGENT_MAX_FIELD_LENGTH)).max(6),
15116
+ actions: external_exports.array(external_exports.string().max(BROWSER_AGENT_MAX_FIELD_LENGTH)).max(6)
15117
+ }).strict();
15118
+ var BrowserAgentView = external_exports.object({
15119
+ kind: external_exports.literal("compact"),
15120
+ sourceKind: external_exports.enum(["snapshot", "diff", "none"]),
15121
+ nodes: external_exports.array(BrowserAgentNode).max(BROWSER_AGENT_MAX_NODES),
15122
+ sourceNodeCount: external_exports.number().int().nonnegative(),
15123
+ omittedNodeCount: external_exports.number().int().nonnegative(),
15124
+ removedRefCount: external_exports.number().int().nonnegative(),
15125
+ clippedFieldCount: external_exports.number().int().nonnegative(),
15126
+ maxNodes: external_exports.number().int().positive(),
15127
+ maxNodeBytes: external_exports.number().int().positive()
15128
+ }).strict();
15129
+ var CompactBrowserObservation = BrowserObservation.safeExtend({
15130
+ semantic: external_exports.null(),
15131
+ agentView: BrowserAgentView
15132
+ });
15133
+ var BrowserAgentObservation = external_exports.union([BrowserObservation, CompactBrowserObservation]);
15134
+ var BrowserAgentActionReceipt = BrowserActionReceipt.safeExtend({
15135
+ observation: BrowserAgentObservation.nullable()
15136
+ });
15137
+ var BrowserScreenshotInput = external_exports.object({
15138
+ browserSessionId: external_exports.string().uuid(),
15139
+ targetId: external_exports.string().min(1).max(512),
15140
+ fullPage: external_exports.boolean().optional(),
15141
+ quality: external_exports.number().int().min(1).max(100).optional()
15142
+ }).strict();
15143
+ var BrowserScreenshotOutput = external_exports.object({
15144
+ kind: external_exports.literal("browser_screenshot"),
15145
+ browserSessionId: external_exports.string().uuid(),
15146
+ targetId: external_exports.string(),
15147
+ frameId: external_exports.string(),
15148
+ targetGeneration: external_exports.string(),
15149
+ documentGeneration: external_exports.string(),
15150
+ mediaType: external_exports.enum(["image/jpeg", "image/png"]),
15151
+ width: external_exports.number().int().positive(),
15152
+ height: external_exports.number().int().positive(),
15153
+ deviceScaleFactor: external_exports.number().positive(),
15154
+ scrollX: external_exports.number(),
15155
+ scrollY: external_exports.number(),
15156
+ capturedAt: external_exports.string(),
15157
+ fullPage: external_exports.boolean()
15158
+ }).strict();
15159
+ var BrowserReadInput = external_exports.object({
15160
+ browserSessionId: external_exports.string().uuid(),
15161
+ targetId: external_exports.string().min(1).max(512),
15162
+ mode: external_exports.enum(["matches", "count", "subtree", "dom"]).optional(),
15163
+ dom: external_exports.discriminatedUnion("kind", [
15164
+ external_exports.object({
15165
+ kind: external_exports.literal("element"),
15166
+ locator: BrowserDomReadLocator,
15167
+ attributes: external_exports.array(BrowserDomSafeAttribute).max(6).optional(),
15168
+ maxChars: external_exports.number().int().min(1).max(4096).optional()
15169
+ }).strict(),
15170
+ external_exports.object({
15171
+ kind: external_exports.literal("count"),
15172
+ selector: BrowserDomReadSelector
15173
+ }).strict()
15174
+ ]).optional(),
15175
+ expectedTargetGeneration: external_exports.string().min(1).max(256).optional(),
15176
+ expectedDocumentGeneration: external_exports.string().min(1).max(256).nullable().optional(),
15177
+ expectedFrameId: external_exports.string().min(1).max(256).nullable().optional(),
15178
+ ref: external_exports.string().min(1).max(512).optional(),
15179
+ scopeRef: external_exports.string().min(1).max(512).optional(),
15180
+ role: external_exports.string().min(1).max(256).optional(),
15181
+ nameContains: external_exports.string().min(1).max(512).optional(),
15182
+ textContains: external_exports.string().min(1).max(512).optional(),
15183
+ state: external_exports.string().min(1).max(128).optional(),
15184
+ action: external_exports.string().min(1).max(128).optional(),
15185
+ limit: external_exports.number().int().min(1).max(BROWSER_READ_MAX_NODES).optional()
15186
+ }).strict().superRefine((value, context) => {
15187
+ if (value.mode === "subtree" && !value.ref) {
15188
+ context.addIssue({ code: "custom", path: ["ref"], message: "subtree requires a ref" });
15189
+ }
15190
+ if (value.mode === "dom" !== (value.dom !== void 0)) {
15191
+ context.addIssue({
15192
+ code: "custom",
15193
+ path: ["dom"],
15194
+ message: "dom query is required only with mode=dom"
15195
+ });
15196
+ }
15197
+ if (value.mode === "dom" && [
15198
+ value.ref,
15199
+ value.scopeRef,
15200
+ value.role,
15201
+ value.nameContains,
15202
+ value.textContains,
15203
+ value.state,
15204
+ value.action,
15205
+ value.limit
15206
+ ].some((field) => field !== void 0)) {
15207
+ context.addIssue({
15208
+ code: "custom",
15209
+ path: ["mode"],
15210
+ message: "accessibility filters cannot be combined with a DOM query"
15211
+ });
15212
+ }
15213
+ if (value.mode !== "dom" && [
15214
+ value.expectedTargetGeneration,
15215
+ value.expectedDocumentGeneration,
15216
+ value.expectedFrameId
15217
+ ].some((field) => field !== void 0)) {
15218
+ context.addIssue({
15219
+ code: "custom",
15220
+ path: ["mode"],
15221
+ message: "DOM generation fences require mode=dom"
15222
+ });
15223
+ }
15224
+ });
15225
+ var BrowserReadOutput = external_exports.object({
15226
+ browserSessionId: external_exports.string().uuid(),
15227
+ targetId: external_exports.string(),
15228
+ observationId: external_exports.string(),
15229
+ targetGeneration: external_exports.string(),
15230
+ documentGeneration: external_exports.string().nullable(),
15231
+ frameId: external_exports.string().nullable(),
15232
+ source: external_exports.literal("accessibility"),
15233
+ mode: external_exports.enum(["matches", "count", "subtree"]),
15234
+ scopeFound: external_exports.boolean(),
15235
+ nodes: external_exports.array(BrowserAgentNode).max(BROWSER_READ_MAX_NODES),
15236
+ totalMatches: external_exports.number().int().nonnegative(),
15237
+ omittedMatches: external_exports.number().int().nonnegative(),
15238
+ clippedFieldCount: external_exports.number().int().nonnegative(),
15239
+ maxNodeBytes: external_exports.number().int().positive()
15240
+ }).strict();
15241
+ var BrowserDomAgentReadOutput = BrowserDomReadResponse.safeExtend({
15242
+ source: external_exports.literal("dom")
15243
+ });
15244
+ var BrowserReadToolOutput = external_exports.discriminatedUnion("source", [
15245
+ BrowserReadOutput,
15246
+ BrowserDomAgentReadOutput
15247
+ ]);
15071
15248
  var TOOL_PERMISSION = {
15072
15249
  interaction_discover: "sessions:read",
15073
15250
  browser_open: "sessions:control",
15074
15251
  browser_tabs: "sessions:control",
15075
15252
  browser_observe: "sessions:read",
15253
+ browser_read: "sessions:read",
15254
+ browser_screenshot: "sessions:read",
15076
15255
  browser_act: "sessions:control",
15077
15256
  browser_clipboard: "sessions:read",
15078
15257
  browser_debug: "sessions:read",
@@ -15153,7 +15332,9 @@ var BrowserTabsInput = external_exports.discriminatedUnion("operation", [
15153
15332
  ]);
15154
15333
  var BrowserObserveInput = external_exports.object({
15155
15334
  browserSessionId: external_exports.string().uuid(),
15156
- targetId: external_exports.string().min(1).max(512)
15335
+ targetId: external_exports.string().min(1).max(512),
15336
+ view: external_exports.enum(["compact", "full"]).optional(),
15337
+ includeScreenshot: external_exports.boolean().optional()
15157
15338
  }).strict();
15158
15339
  var BrowserActInput = external_exports.object({
15159
15340
  browserSessionId: external_exports.string().uuid(),
@@ -15161,6 +15342,7 @@ var BrowserActInput = external_exports.object({
15161
15342
  expectedTargetGeneration: external_exports.string().min(1).max(256).optional(),
15162
15343
  expectedDocumentGeneration: external_exports.string().min(1).max(256).nullable().optional(),
15163
15344
  expectedFrameId: external_exports.string().min(1).max(256).nullable().optional(),
15345
+ view: external_exports.enum(["compact", "full", "none"]).optional(),
15164
15346
  action: external_exports.union([BrowserAction, BrowserActionBatch])
15165
15347
  }).strict();
15166
15348
  var BrowserClipboardInput = external_exports.object({ browserSessionId: external_exports.string().uuid() }).strict();
@@ -15288,12 +15470,15 @@ var ComputerObserveInput = external_exports.object({
15288
15470
  computerSessionId: external_exports.string().uuid(),
15289
15471
  targetId: external_exports.string().min(1).max(512)
15290
15472
  }).strict();
15473
+ var ComputerObserveOutput = ComputerObservation.extend({
15474
+ capturedFrame: external_exports.object({ width: external_exports.number().int().positive(), height: external_exports.number().int().positive() }).strict()
15475
+ }).strict();
15291
15476
  var ComputerClipboardInput = external_exports.object({ computerSessionId: external_exports.string().uuid() }).strict();
15292
15477
  var ComputerActInput = external_exports.object({
15293
15478
  computerSessionId: external_exports.string().uuid(),
15294
15479
  targetId: external_exports.string().min(1).max(512),
15295
15480
  expectedTargetGeneration: external_exports.string().min(1).max(256).optional(),
15296
- expectedObservationId: external_exports.string().uuid().nullable().optional(),
15481
+ expectedObservationId: ComputerObservation.shape.observationId.nullable().optional(),
15297
15482
  expectedFrameId: external_exports.string().min(1).max(256).nullable().optional(),
15298
15483
  action: ComputerAction
15299
15484
  }).strict();
@@ -15316,7 +15501,7 @@ function createInteractionAttemptToolDefinitions(input) {
15316
15501
  codemodePath: options.codemodePath,
15317
15502
  title: options.title,
15318
15503
  description: options.description,
15319
- inputSchema: jsonSchema(options.input),
15504
+ inputSchema: options.name === "browser_act" ? browserActionInputJsonSchema(options.input) : jsonSchema(options.input),
15320
15505
  outputSchema: jsonSchema(options.output),
15321
15506
  annotations: {
15322
15507
  title: options.title,
@@ -15384,7 +15569,7 @@ function createInteractionAttemptToolDefinitions(input) {
15384
15569
  name: "browser_open",
15385
15570
  codemodePath: ["interaction", "browser", "open"],
15386
15571
  title: "Open or reuse browser",
15387
- description: "Open a managed BrowserSession on the current agent placement, reuse a relevant compatible live session by default, attach to an explicit workspace BrowserSession, or open an attached Chrome profile by passing placement={kind:'attached_device',deviceId}. This does not infer or attach the user's existing Chrome: for requests about 'my browser', 'my tabs', or current Chrome, call interaction_discover first and select an actual attachedBrowsers device; if none exists, explain that the Chrome extension must be connected instead of silently creating a blank managed browser. Managed Chromium defaults to headed so OAuth and later human interaction use a supported browser; request headless=true only for agent-only work that will not require sign-in or human control. Returns exact session and tab state.",
15572
+ description: "Open a managed BrowserSession on the current agent placement, reuse a relevant compatible live session by default, attach to an explicit workspace BrowserSession, or open an attached Chrome profile by passing placement={kind:'attached_device',deviceId}. This does not infer or attach the user's existing Chrome: for requests about 'my browser', 'my tabs', or current Chrome, call interaction_discover first and select an actual attachedBrowsers device; if none exists, explain that the Chrome extension must be connected instead of silently creating a blank managed browser. BrowserSessions persist across tool calls; shell-launched browser daemons do not survive remote-command cleanup. Never switch to the user's attached Chrome as a fallback for a failed managed browser unless the user requested that profile. A new attached session opens a dedicated tab. Managed Chromium defaults to headed so OAuth and later human interaction use a supported browser; request headless=true only for agent-only work that will not require sign-in or human control. Returns exact session and tab state.",
15388
15573
  input: BrowserOpenInput,
15389
15574
  output: BrowserOpenOutput,
15390
15575
  readOnly: false,
@@ -15395,7 +15580,7 @@ function createInteractionAttemptToolDefinitions(input) {
15395
15580
  name: "browser_tabs",
15396
15581
  codemodePath: ["interaction", "browser", "tabs"],
15397
15582
  title: "Manage browser tabs",
15398
- description: "List, open, select, or close tabs in one exact BrowserSession. Returns the authoritative complete tab list after the operation.",
15583
+ description: "List, open, logically select, or close tabs in one exact BrowserSession. Selection changes the BrowserSession's default target, not the visible desktop tab. New attached-Chrome tabs open in the background. Use browser_act activate only when foregrounding the owned tab is explicitly intended. Returns the authoritative complete tab list after the operation.",
15399
15584
  input: BrowserTabsInput,
15400
15585
  output: BrowserTargetListResponse,
15401
15586
  readOnly: false,
@@ -15425,40 +15610,169 @@ function createInteractionAttemptToolDefinitions(input) {
15425
15610
  name: "browser_observe",
15426
15611
  codemodePath: ["interaction", "browser", "observe"],
15427
15612
  title: "Observe browser tab",
15428
- description: "Read one tab's current URL/title, causal generations, compact semantic accessibility tree, dialog, and diagnostic counts without taking control.",
15613
+ description: "Read one tab's URL, title, viewport, causal generations, and a bounded accessibility view. Compact view is the default: agentView lists selected refs and reports omitted nodes and clipped fields; it is not a complete page tree. Set view=full for the complete accessibility snapshot. Set includeScreenshot=true to add a current still image as tool image content; browser_screenshot is faster when only pixels are needed.",
15429
15614
  input: BrowserObserveInput,
15430
- output: BrowserObservation,
15615
+ output: BrowserAgentObservation,
15431
15616
  readOnly: true,
15432
15617
  idempotent: true,
15433
- execute: async (value) => await input.transport.observeBrowserTarget(
15434
- input.workspaceId,
15435
- value.browserSessionId,
15436
- value.targetId
15437
- )
15618
+ execute: async (value) => {
15619
+ let observation = await input.transport.observeBrowserTarget(
15620
+ input.workspaceId,
15621
+ value.browserSessionId,
15622
+ value.targetId
15623
+ );
15624
+ if (!value.includeScreenshot)
15625
+ return projectBrowserObservation(observation, value.view ?? "compact");
15626
+ const frame = await input.transport.captureBrowserTarget(
15627
+ input.workspaceId,
15628
+ value.browserSessionId,
15629
+ value.targetId
15630
+ );
15631
+ if (observation.target.targetGeneration !== frame.targetGeneration || observation.target.documentGeneration !== frame.documentGeneration) {
15632
+ observation = await input.transport.observeBrowserTarget(
15633
+ input.workspaceId,
15634
+ value.browserSessionId,
15635
+ value.targetId
15636
+ );
15637
+ }
15638
+ if (observation.target.targetGeneration !== frame.targetGeneration || observation.target.documentGeneration !== frame.documentGeneration) {
15639
+ throw new Error("browser target changed while its visual observation was captured");
15640
+ }
15641
+ return new InteractionExecutionResult(
15642
+ projectBrowserObservation(observation, value.view ?? "compact"),
15643
+ [browserToolImageContent(frame.data, frame.mediaType)]
15644
+ );
15645
+ }
15646
+ });
15647
+ add({
15648
+ name: "browser_read",
15649
+ codemodePath: ["interaction", "browser", "read"],
15650
+ title: "Read focused browser content",
15651
+ description: "Search, count, or read a subtree from one tab's accessibility snapshot; filter by ref, role, name, accessibility text, state, or action, and scopeRef. AX mode refreshes the full tree internally and cannot return DOM attributes or editable input values. Use mode=dom with a ref, CSS, test-id, or placeholder locator for bounded element text, editable value, or allowlisted attributes, or a CSS selector for count. Content-matching role/label/text locators and CSS attribute/pseudo selectors are rejected for DOM reads to prevent secret-value probing. DOM reads use exact causal fences and only fixed, read-only browser-side projection; callers cannot supply JavaScript. Ref DOM locators refresh accessibility; CSS/test-id/placeholder locators avoid that scan.",
15652
+ input: BrowserReadInput,
15653
+ output: BrowserReadToolOutput,
15654
+ readOnly: true,
15655
+ idempotent: true,
15656
+ execute: async (value) => {
15657
+ if (value.mode === "dom") {
15658
+ const state = value.expectedTargetGeneration !== void 0 && value.expectedDocumentGeneration !== void 0 && value.expectedFrameId !== void 0 ? null : await input.transport.getBrowserTargetState(
15659
+ input.workspaceId,
15660
+ value.browserSessionId,
15661
+ value.targetId
15662
+ );
15663
+ const fences = {
15664
+ expectedTargetGeneration: value.expectedTargetGeneration ?? state.targetGeneration,
15665
+ expectedDocumentGeneration: value.expectedDocumentGeneration === void 0 ? state.documentGeneration : value.expectedDocumentGeneration,
15666
+ expectedFrameId: value.expectedFrameId === void 0 ? state.frameId : value.expectedFrameId
15667
+ };
15668
+ const documentGeneration = fences.expectedDocumentGeneration;
15669
+ const frameId = fences.expectedFrameId;
15670
+ if (documentGeneration === null || frameId === null) {
15671
+ throw new OpenGeniApiError(409, "browser target has no inspectable document", {
15672
+ code: "document_unavailable",
15673
+ retryable: true
15674
+ });
15675
+ }
15676
+ const inspectedFences = {
15677
+ expectedTargetGeneration: fences.expectedTargetGeneration,
15678
+ expectedDocumentGeneration: documentGeneration,
15679
+ expectedFrameId: frameId
15680
+ };
15681
+ const dom = value.dom;
15682
+ const request = dom.kind === "element" ? {
15683
+ ...inspectedFences,
15684
+ kind: "element",
15685
+ locator: dom.locator,
15686
+ ...dom.attributes ? { attributes: dom.attributes } : {},
15687
+ maxChars: dom.maxChars ?? 4096
15688
+ } : { ...inspectedFences, kind: "count", selector: dom.selector };
15689
+ return {
15690
+ ...await input.transport.readBrowserDom(
15691
+ input.workspaceId,
15692
+ value.browserSessionId,
15693
+ value.targetId,
15694
+ request
15695
+ ),
15696
+ source: "dom"
15697
+ };
15698
+ }
15699
+ return readBrowserObservation(
15700
+ await input.transport.observeBrowserTarget(
15701
+ input.workspaceId,
15702
+ value.browserSessionId,
15703
+ value.targetId
15704
+ ),
15705
+ value
15706
+ );
15707
+ }
15708
+ });
15709
+ add({
15710
+ name: "browser_screenshot",
15711
+ codemodePath: ["interaction", "browser", "screenshot"],
15712
+ title: "Capture browser screenshot",
15713
+ description: "Capture a current browser tab screenshot without reading its accessibility tree. The image is returned as tool image content, with small structured frame metadata. Set fullPage=true to capture the whole scrollable page when supported; large pages may take longer or exceed capture bounds. Set quality lower to reduce JPEG bytes if a large capture exceeds the Code Mode image limit.",
15714
+ input: BrowserScreenshotInput,
15715
+ output: BrowserScreenshotOutput,
15716
+ readOnly: true,
15717
+ idempotent: true,
15718
+ execute: async (value) => {
15719
+ const frame = await input.transport.captureBrowserTarget(
15720
+ input.workspaceId,
15721
+ value.browserSessionId,
15722
+ value.targetId,
15723
+ {},
15724
+ { fullPage: value.fullPage ?? false, ...value.quality ? { quality: value.quality } : {} }
15725
+ );
15726
+ return new InteractionExecutionResult(
15727
+ {
15728
+ kind: "browser_screenshot",
15729
+ browserSessionId: frame.browserSessionId,
15730
+ targetId: frame.targetId,
15731
+ frameId: frame.frameId,
15732
+ targetGeneration: frame.targetGeneration,
15733
+ documentGeneration: frame.documentGeneration,
15734
+ mediaType: frame.mediaType,
15735
+ width: frame.width,
15736
+ height: frame.height,
15737
+ deviceScaleFactor: frame.deviceScaleFactor,
15738
+ scrollX: frame.scrollX,
15739
+ scrollY: frame.scrollY,
15740
+ capturedAt: frame.capturedAt,
15741
+ fullPage: value.fullPage ?? false
15742
+ },
15743
+ [browserToolImageContent(frame.data, frame.mediaType)]
15744
+ );
15745
+ }
15438
15746
  });
15439
15747
  add({
15440
15748
  name: "browser_act",
15441
15749
  codemodePath: ["interaction", "browser", "act"],
15442
15750
  title: "Act in browser tab",
15443
- description: "Perform one semantic-first browser action or bounded batch, including setting a managed browser's web permission for this tab's exact current top-level origin. Omit generation fences to use a fresh observation automatically; provide them to require exact previously observed state. Returns the durable receipt and changed observation.",
15751
+ description: "Perform one semantic-first browser action or bounded batch. Use viewport to set page width, height, desktop/mobile layout and touch emulation, then check the measured viewport in the returned observation; emulation does not prove physical mobile-browser behavior. Use history back/forward for tab navigation; keypress shortcuts are page input and may not navigate browser history. The explicit activate action foregrounds the target in the user's desktop browser; use only when that is intended. Permission actions set a managed browser's web permission for this tab's exact current top-level origin. Omit generation fences to fetch fresh generation metadata without scanning accessibility; supplying all three fences skips that state read while preserving controller validation. The default receipt includes a compact accessibility view with explicit omissions; set view=full for the complete observation, or view=none when no post-action tree is needed.",
15444
15752
  input: BrowserActInput,
15445
- output: BrowserActionReceipt,
15753
+ output: BrowserAgentActionReceipt,
15446
15754
  readOnly: false,
15447
15755
  idempotent: true,
15448
15756
  execute: async (value, context) => {
15449
- const current = await input.transport.observeBrowserTarget(
15757
+ const current = value.expectedTargetGeneration !== void 0 && value.expectedDocumentGeneration !== void 0 && value.expectedFrameId !== void 0 ? null : await input.transport.getBrowserTargetState(
15450
15758
  input.workspaceId,
15451
15759
  value.browserSessionId,
15452
15760
  value.targetId
15453
15761
  );
15454
- return await input.transport.actInBrowser(input.workspaceId, value.browserSessionId, {
15455
- operationId: context.operationId,
15456
- targetId: value.targetId,
15457
- expectedTargetGeneration: value.expectedTargetGeneration ?? current.target.targetGeneration,
15458
- expectedDocumentGeneration: value.expectedDocumentGeneration === void 0 ? current.target.documentGeneration : value.expectedDocumentGeneration,
15459
- expectedFrameId: value.expectedFrameId === void 0 ? current.frameId : value.expectedFrameId,
15460
- action: value.action
15461
- });
15762
+ const receipt = await input.transport.actInBrowser(
15763
+ input.workspaceId,
15764
+ value.browserSessionId,
15765
+ {
15766
+ operationId: context.operationId,
15767
+ targetId: value.targetId,
15768
+ expectedTargetGeneration: value.expectedTargetGeneration ?? current.targetGeneration,
15769
+ expectedDocumentGeneration: value.expectedDocumentGeneration === void 0 ? current.documentGeneration : value.expectedDocumentGeneration,
15770
+ expectedFrameId: value.expectedFrameId === void 0 ? current.frameId : value.expectedFrameId,
15771
+ ...value.view === "none" ? { observationMode: "none" } : {},
15772
+ action: value.action
15773
+ }
15774
+ );
15775
+ return receipt.observation && (value.view ?? "compact") === "compact" ? { ...receipt, observation: projectBrowserObservation(receipt.observation, "compact") } : receipt;
15462
15776
  }
15463
15777
  });
15464
15778
  add({
@@ -15758,9 +16072,9 @@ function createInteractionAttemptToolDefinitions(input) {
15758
16072
  name: "computer_observe",
15759
16073
  codemodePath: ["interaction", "computer", "observe"],
15760
16074
  title: "Observe app or window",
15761
- description: "Read one ComputerSession app/window/screen target, causal generation, semantic accessibility tree, focus, frame identity, and a bounded current screenshot without taking control.",
16075
+ description: "Read one ComputerSession app/window/screen target, causal generation, semantic accessibility tree, focus, frame identity, and a bounded current screenshot without taking control. capturedFrame gives the screenshot's exact pixel dimensions; use those pixels for pointer coordinates, not the target's native bounds or an image-preview size.",
15762
16076
  input: ComputerObserveInput,
15763
- output: ComputerObservation,
16077
+ output: ComputerObserveOutput,
15764
16078
  readOnly: true,
15765
16079
  idempotent: true,
15766
16080
  execute: async (value) => {
@@ -15784,13 +16098,20 @@ function createInteractionAttemptToolDefinitions(input) {
15784
16098
  if (observation.target.targetGeneration !== frame.targetGeneration) {
15785
16099
  throw new Error("computer target changed while its visual observation was captured");
15786
16100
  }
15787
- return new InteractionExecutionResult({ ...observation, frameId: frame.frameId }, [
16101
+ return new InteractionExecutionResult(
15788
16102
  {
15789
- type: "image",
15790
- data: Buffer.from(frame.data).toString("base64"),
15791
- mimeType: frame.mediaType
15792
- }
15793
- ]);
16103
+ ...observation,
16104
+ frameId: frame.frameId,
16105
+ capturedFrame: { width: frame.width, height: frame.height }
16106
+ },
16107
+ [
16108
+ {
16109
+ type: "image",
16110
+ data: Buffer.from(frame.data).toString("base64"),
16111
+ mimeType: frame.mediaType
16112
+ }
16113
+ ]
16114
+ );
15794
16115
  }
15795
16116
  });
15796
16117
  add({
@@ -15808,13 +16129,13 @@ function createInteractionAttemptToolDefinitions(input) {
15808
16129
  name: "computer_act",
15809
16130
  codemodePath: ["interaction", "computer", "act"],
15810
16131
  title: "Act in app or window",
15811
- description: "Perform one action in an exact ComputerSession target. Prefer semantic actions from computer_observe: on macOS they can invoke controls and set values without foregrounding the app. Pointer, keyboard, target focus, screen actions, and clipboard paste use the physical graphical seat and may change the user's foreground app; use them only when foreground control is explicitly intended. Omit fences to use a fresh observation automatically. Returns the durable causal receipt.",
16132
+ description: "Perform one action in an exact ComputerSession target. Prefer semantic actions from computer_observe: on macOS they can invoke controls and set values without foregrounding the app. Pointer, keyboard, target focus, screen actions, and clipboard paste use the physical graphical seat and may change the user's foreground app; use them only when foreground control is explicitly intended. For pointer actions, set action.frameId from the observed frame and use coordinates in the returned screenshot's pixels; do not scale them to target.bounds. A pixel frame fence applies only to pointer actions; semantic actions use the observation fence even if a frame ID is supplied. Supplying the target generation and relevant action fence preserves the exact observation without refreshing it. Omit fences to use a fresh observation automatically. Returns the durable causal receipt.",
15812
16133
  input: ComputerActInput,
15813
16134
  output: ComputerActionReceipt,
15814
16135
  readOnly: false,
15815
16136
  idempotent: true,
15816
16137
  execute: async (value, context) => {
15817
- const current = await input.transport.observeComputerTarget(
16138
+ const current = value.expectedTargetGeneration !== void 0 && (value.action.type === "pointer" ? (value.expectedFrameId ?? value.action.frameId) != null : value.expectedObservationId != null) ? null : await input.transport.observeComputerTarget(
15818
16139
  input.workspaceId,
15819
16140
  value.computerSessionId,
15820
16141
  value.targetId
@@ -15823,8 +16144,8 @@ function createInteractionAttemptToolDefinitions(input) {
15823
16144
  operationId: context.operationId,
15824
16145
  targetId: value.targetId,
15825
16146
  expectedTargetGeneration: value.expectedTargetGeneration ?? current.target.targetGeneration,
15826
- expectedObservationId: value.expectedObservationId === void 0 ? current.observationId : value.expectedObservationId,
15827
- expectedFrameId: value.expectedFrameId === void 0 ? value.action.type === "pointer" ? value.action.frameId : null : value.expectedFrameId,
16147
+ expectedObservationId: value.expectedObservationId === void 0 ? current?.observationId ?? null : value.expectedObservationId,
16148
+ expectedFrameId: value.action.type === "pointer" ? value.expectedFrameId === void 0 ? value.action.frameId : value.expectedFrameId : null,
15828
16149
  action: value.action
15829
16150
  });
15830
16151
  }
@@ -15901,10 +16222,12 @@ async function openBrowser(transport, workspaceId, sourceSessionId, value, conte
15901
16222
  if (value.browserSessionId) {
15902
16223
  session = await transport.getBrowserSession(workspaceId, value.browserSessionId);
15903
16224
  } else {
15904
- const listed = await transport.listBrowserSessions(workspaceId);
16225
+ const listed = value.mode === "new" ? { sessions: [] } : await transport.listBrowserSessions(workspaceId);
15905
16226
  const requestedHeadless = value.headless ?? false;
15906
16227
  const reusable = value.mode === "new" ? null : newestRelevant(
15907
- listed.sessions.filter((candidate) => candidate.headless === requestedHeadless),
16228
+ listed.sessions.filter(
16229
+ (candidate) => candidate.headless === requestedHeadless && compatibleInteractionPlacement(candidate.placement, value.placement) && (value.identityId === void 0 || candidate.identityId === value.identityId) && (value.baseRevisionId === void 0 || candidate.baseRevisionId === value.baseRevisionId) && (value.networkRouteId === void 0 || candidate.networkRouteId === value.networkRouteId) && (value.linkedComputerSessionId === void 0 || candidate.linkedComputerSessionId === value.linkedComputerSessionId)
16230
+ ),
15908
16231
  sourceSessionId
15909
16232
  );
15910
16233
  if (reusable) {
@@ -15950,8 +16273,13 @@ async function openComputer(transport, workspaceId, sourceSessionId, value, cont
15950
16273
  if (value.computerSessionId) {
15951
16274
  session = await transport.getComputerSession(workspaceId, value.computerSessionId);
15952
16275
  } else {
15953
- const listed = await transport.listComputerSessions(workspaceId);
15954
- const reusable = value.mode === "new" ? null : newestRelevant(listed.sessions, sourceSessionId);
16276
+ const listed = value.mode === "new" ? { sessions: [] } : await transport.listComputerSessions(workspaceId);
16277
+ const reusable = newestRelevant(
16278
+ listed.sessions.filter(
16279
+ (candidate) => compatibleInteractionPlacement(candidate.placement, value.placement)
16280
+ ),
16281
+ sourceSessionId
16282
+ );
15955
16283
  session = reusable ? reusable : (await transport.createComputerSession(workspaceId, {
15956
16284
  operationId: context.operationId,
15957
16285
  sessionId: sourceSessionId,
@@ -15964,6 +16292,12 @@ async function openComputer(transport, workspaceId, sourceSessionId, value, cont
15964
16292
  targets: session.lifecycle === "active" ? (await transport.listComputerTargets(workspaceId, session.id)).targets : []
15965
16293
  };
15966
16294
  }
16295
+ function compatibleInteractionPlacement(candidate, requested) {
16296
+ if (!requested) return candidate.kind !== "attached_device";
16297
+ return Object.entries(requested).every(
16298
+ ([key, value]) => candidate[key] === value
16299
+ );
16300
+ }
15967
16301
  function newestRelevant(sessions, sourceSessionId) {
15968
16302
  return sessions.filter(
15969
16303
  (session) => !["ending", "ended", "failed", "lost", "repair_required"].includes(session.lifecycle) && session.associations.some((association) => association.sessionId === sourceSessionId)
@@ -15980,6 +16314,147 @@ function assertInterventionResumeMatches(request, intervention) {
15980
16314
  throw new Error("Interaction response does not match the resumed tool request");
15981
16315
  }
15982
16316
  }
16317
+ function flattenBrowserNodes(roots, scopeRef) {
16318
+ const flattened = [];
16319
+ const stack = [...roots].reverse().map((node) => ({ node, depth: 0, withinScope: !scopeRef }));
16320
+ while (stack.length > 0) {
16321
+ const next = stack.pop();
16322
+ const withinScope = next.withinScope || next.node.ref === scopeRef;
16323
+ flattened.push({
16324
+ node: next.node,
16325
+ depth: next.depth,
16326
+ index: flattened.length,
16327
+ withinScope
16328
+ });
16329
+ for (const child of [...next.node.children ?? []].reverse()) {
16330
+ stack.push({ node: child, depth: next.depth + 1, withinScope });
16331
+ }
16332
+ }
16333
+ return flattened;
16334
+ }
16335
+ function boundedAgentField(value, onClip) {
16336
+ if (value.length <= BROWSER_AGENT_MAX_FIELD_LENGTH) return value;
16337
+ onClip();
16338
+ return `${value.slice(0, BROWSER_AGENT_MAX_FIELD_LENGTH - 1)}\u2026`;
16339
+ }
16340
+ function projectAgentNode(flat) {
16341
+ let clippedFieldCount = 0;
16342
+ const clip = () => {
16343
+ clippedFieldCount += 1;
16344
+ };
16345
+ const source = flat.node;
16346
+ const nodes = {
16347
+ ref: source.ref,
16348
+ role: source.role,
16349
+ depth: flat.depth,
16350
+ ...source.name !== void 0 ? { name: boundedAgentField(source.name, clip) } : {},
16351
+ ...source.description !== void 0 ? { description: boundedAgentField(source.description, clip) } : {},
16352
+ ...source.value !== void 0 ? {
16353
+ value: typeof source.value === "string" ? boundedAgentField(source.value, clip) : source.value
16354
+ } : {},
16355
+ states: source.states.slice(0, 6).map((state) => boundedAgentField(state, clip)),
16356
+ actions: source.actions.slice(0, 6).map((action) => boundedAgentField(action, clip))
16357
+ };
16358
+ if (source.states.length > 6) clippedFieldCount += source.states.length - 6;
16359
+ if (source.actions.length > 6) clippedFieldCount += source.actions.length - 6;
16360
+ return { node: nodes, clippedFieldCount };
16361
+ }
16362
+ function selectAgentNodes(flattened, maxNodes, maxBytes, prioritize = true) {
16363
+ const priority = (flat) => {
16364
+ const { node } = flat;
16365
+ if (node.actions.length > 0) return 0;
16366
+ if (["heading", "dialog", "alert", "status", "navigation", "main"].includes(node.role))
16367
+ return 1;
16368
+ if (["text", "paragraph", "listitem"].includes(node.role) && node.name) return 2;
16369
+ if (node.name || node.value || node.description) return 3;
16370
+ return 4;
16371
+ };
16372
+ const candidates = prioritize ? [...flattened].sort((a, b) => priority(a) - priority(b) || a.index - b.index) : flattened;
16373
+ const selected = [];
16374
+ let usedBytes = 0;
16375
+ let clippedFieldCount = 0;
16376
+ for (const flat of candidates) {
16377
+ if (selected.length >= maxNodes) break;
16378
+ const projected = projectAgentNode(flat);
16379
+ const bytes = Buffer.byteLength(JSON.stringify(projected.node), "utf8");
16380
+ if (usedBytes + bytes > maxBytes) continue;
16381
+ selected.push({ index: flat.index, node: projected.node });
16382
+ usedBytes += bytes;
16383
+ clippedFieldCount += projected.clippedFieldCount;
16384
+ }
16385
+ return {
16386
+ nodes: selected.sort((a, b) => a.index - b.index).map((entry) => entry.node),
16387
+ clippedFieldCount
16388
+ };
16389
+ }
16390
+ function projectBrowserObservation(observation, view) {
16391
+ if (view === "full") return observation;
16392
+ const semantic = observation.semantic;
16393
+ const roots = semantic?.kind === "snapshot" ? semantic.roots : semantic?.kind === "diff" ? semantic.changed : [];
16394
+ const flattened = flattenBrowserNodes(roots);
16395
+ const projected = selectAgentNodes(
16396
+ flattened,
16397
+ BROWSER_AGENT_MAX_NODES,
16398
+ BROWSER_AGENT_MAX_NODE_BYTES
16399
+ );
16400
+ return {
16401
+ ...observation,
16402
+ semantic: null,
16403
+ agentView: {
16404
+ kind: "compact",
16405
+ sourceKind: semantic?.kind ?? "none",
16406
+ nodes: projected.nodes,
16407
+ sourceNodeCount: flattened.length,
16408
+ omittedNodeCount: flattened.length - projected.nodes.length,
16409
+ removedRefCount: semantic?.kind === "diff" ? semantic.removedRefs.length : 0,
16410
+ clippedFieldCount: projected.clippedFieldCount,
16411
+ maxNodes: BROWSER_AGENT_MAX_NODES,
16412
+ maxNodeBytes: BROWSER_AGENT_MAX_NODE_BYTES
16413
+ }
16414
+ };
16415
+ }
16416
+ function readBrowserObservation(observation, input) {
16417
+ if (observation.semantic?.kind !== "snapshot") {
16418
+ throw new Error("browser focused read requires a complete accessibility snapshot");
16419
+ }
16420
+ const mode = input.mode && input.mode !== "dom" ? input.mode : "matches";
16421
+ const scopeRef = mode === "subtree" ? input.ref : input.scopeRef;
16422
+ const flattened = flattenBrowserNodes(observation.semantic.roots, scopeRef);
16423
+ const scopeFound = !scopeRef || flattened.some((entry) => entry.node.ref === scopeRef);
16424
+ const includes = (source, needle) => needle === void 0 || (source ?? "").toLowerCase().includes(needle.toLowerCase());
16425
+ const matches = flattened.filter(({ node, withinScope }) => {
16426
+ if (!withinScope) return false;
16427
+ if (mode !== "subtree" && input.ref && node.ref !== input.ref) return false;
16428
+ if (input.role && node.role.toLowerCase() !== input.role.toLowerCase()) return false;
16429
+ if (!includes(node.name, input.nameContains)) return false;
16430
+ if (input.textContains && ![node.name, node.description, typeof node.value === "string" ? node.value : void 0].some(
16431
+ (candidate) => includes(candidate, input.textContains)
16432
+ ))
16433
+ return false;
16434
+ if (input.state && !node.states.some((state) => state.toLowerCase() === input.state.toLowerCase()))
16435
+ return false;
16436
+ if (input.action && !node.actions.some((action) => action.toLowerCase() === input.action.toLowerCase()))
16437
+ return false;
16438
+ return true;
16439
+ });
16440
+ const projected = mode === "count" ? { nodes: [], clippedFieldCount: 0 } : selectAgentNodes(matches, input.limit ?? 40, BROWSER_AGENT_MAX_NODE_BYTES, false);
16441
+ return {
16442
+ browserSessionId: observation.browserSessionId,
16443
+ targetId: observation.target.id,
16444
+ observationId: observation.observationId,
16445
+ targetGeneration: observation.target.targetGeneration,
16446
+ documentGeneration: observation.target.documentGeneration,
16447
+ frameId: observation.frameId,
16448
+ source: "accessibility",
16449
+ mode,
16450
+ scopeFound,
16451
+ nodes: projected.nodes,
16452
+ totalMatches: matches.length,
16453
+ omittedMatches: matches.length - projected.nodes.length,
16454
+ clippedFieldCount: projected.clippedFieldCount,
16455
+ maxNodeBytes: BROWSER_AGENT_MAX_NODE_BYTES
16456
+ };
16457
+ }
15983
16458
  async function safeInteractionExecution(inputSchema, outputSchema, raw, context, execute) {
15984
16459
  try {
15985
16460
  const value = inputSchema.parse(raw);
@@ -16009,6 +16484,16 @@ async function safeInteractionExecution(inputSchema, outputSchema, raw, context,
16009
16484
  throw error;
16010
16485
  }
16011
16486
  }
16487
+ function browserToolImageContent(data, mimeType) {
16488
+ if (data.byteLength > BROWSER_TOOL_IMAGE_MAX_BYTES) {
16489
+ throw new OpenGeniApiError(
16490
+ 413,
16491
+ "Browser screenshot exceeds the Code Mode image limit; capture the viewport or lower JPEG quality.",
16492
+ { code: "browser_screenshot_too_large", retryable: false }
16493
+ );
16494
+ }
16495
+ return { type: "image", data: Buffer.from(data).toString("base64"), mimeType };
16496
+ }
16012
16497
  function interactionErrorResult(code, message, retryable = false) {
16013
16498
  const error = { code, message, retryable };
16014
16499
  return {
@@ -16801,17 +17286,24 @@ async function summarizeForCompaction(settings, input, options = {}) {
16801
17286
  const model = options.model ?? settings.openaiModel;
16802
17287
  const provider = options.provider ?? configuredProviders2(settings)[0];
16803
17288
  if (!provider) throw new Error("Built-in model provider is unavailable");
16804
- const maxTokens = options.maxOutputTokens ?? SUMMARY_BUFFER_TOKENS;
17289
+ const azureResponses = provider.wireProfile === "azure-openai";
17290
+ const maxTokens = options.maxOutputTokens ?? compactionSummaryOutputTokens(settings.contextWindowTokens);
16805
17291
  if (api === "chat") {
16806
17292
  const transcript = renderCompactionPromptInputForChat(input);
16807
17293
  let completion;
16808
17294
  try {
16809
- completion = await client.chat.completions.create({
16810
- model,
16811
- max_tokens: maxTokens,
16812
- messages: [{ role: "user", content: transcript }],
16813
- ...options.promptCacheKey ? { prompt_cache_key: options.promptCacheKey } : {}
16814
- });
17295
+ completion = await client.chat.completions.create(
17296
+ {
17297
+ model,
17298
+ max_tokens: maxTokens,
17299
+ messages: [
17300
+ ...options.systemInstructions ? [{ role: "system", content: options.systemInstructions }] : [],
17301
+ { role: "user", content: transcript }
17302
+ ],
17303
+ ...options.promptCacheKey ? { prompt_cache_key: options.promptCacheKey } : {}
17304
+ },
17305
+ options.signal ? { signal: options.signal } : void 0
17306
+ );
16815
17307
  } catch (error) {
16816
17308
  throw new CompactionProviderResponseError(compactionProviderFailureDiagnostics(error), error);
16817
17309
  }
@@ -16819,31 +17311,62 @@ async function summarizeForCompaction(settings, input, options = {}) {
16819
17311
  if (usage2) {
16820
17312
  await options.onUsage?.(usage2);
16821
17313
  }
16822
- const text = completion.choices?.[0]?.message?.content;
17314
+ const choice = completion.choices?.[0];
17315
+ if (choice?.finish_reason !== "stop") {
17316
+ throw new EmptyCompactionSummaryError({
17317
+ stage: "chat_completion",
17318
+ reason: "non_stop_finish",
17319
+ finishReason: ["length", "content_filter", "tool_calls", "function_call"].includes(
17320
+ String(choice?.finish_reason)
17321
+ ) ? choice?.finish_reason : "unknown"
17322
+ });
17323
+ }
17324
+ const text = choice.message?.content;
16823
17325
  const summary2 = typeof text === "string" ? text.trim() : "";
16824
17326
  if (!summary2) {
16825
17327
  throw new EmptyCompactionSummaryError(compactionResponseDiagnostics(completion, summary2));
16826
17328
  }
16827
17329
  return summary2;
16828
17330
  }
16829
- const request = {
17331
+ const preparedPrefix = options.preparedRequest ? (({ signal: _priorSignal, ...prefix }) => prefix)(options.preparedRequest) : null;
17332
+ const { store: _priorStore, ...preparedModelSettings } = preparedPrefix?.modelSettings ?? {};
17333
+ const request = preparedPrefix ? {
17334
+ ...preparedPrefix,
17335
+ // The history copy is still portable: dependent stored response ids are
17336
+ // removed, and the final checkpoint instruction is appended by the caller.
17337
+ input: input.map(detachCompactionResponseItemIdentity),
17338
+ modelSettings: {
17339
+ ...preparedModelSettings,
17340
+ maxTokens,
17341
+ // Retain schemas for the warm prefix without letting the checkpoint
17342
+ // model select or execute a tool (including a historical Azure tool).
17343
+ toolChoice: "none",
17344
+ // The selected provider, not the deployment default, owns this wire
17345
+ // policy. Override any inherited value on a prepared Azure request.
17346
+ ...azureResponses ? {} : { store: false }
17347
+ },
17348
+ outputType: "text",
17349
+ tracing: false,
17350
+ ...options.signal ? { signal: options.signal } : {}
17351
+ } : {
16830
17352
  systemInstructions: options.systemInstructions ?? "",
16831
17353
  input: input.map(detachCompactionResponseItemIdentity),
16832
17354
  modelSettings: {
16833
17355
  maxTokens,
16834
17356
  // Azure can select a historical tool despite empty schemas. Keep this
16835
17357
  // verified policy off subscription/gateway transports with other contracts.
16836
- ...provider.wireProfile === "azure-openai" ? { toolChoice: "none" } : {},
17358
+ ...azureResponses ? { toolChoice: "none" } : {},
16837
17359
  // Azure rejects store:false; the Codex subscription transport enforces
16838
- // it independently. The OpenAI platform path remains explicitly storeless.
16839
- ...settings.openaiProvider === "azure" ? {} : { store: false },
17360
+ // it independently. Other Responses routes remain explicitly storeless.
17361
+ ...azureResponses ? {} : { store: false },
16840
17362
  ...options.promptCacheKey ? { providerData: { prompt_cache_key: options.promptCacheKey } } : {}
16841
17363
  },
16842
17364
  tools: [],
16843
17365
  toolsExplicitlyProvided: true,
16844
17366
  outputType: "text",
16845
17367
  handoffs: [],
16846
- tracing: false
17368
+ tracing: false,
17369
+ ...options.signal ? { signal: options.signal } : {}
16847
17370
  };
16848
17371
  let response;
16849
17372
  try {
@@ -18291,6 +18814,14 @@ function buildAgentCapabilitiesFromComposition(settings, skillComposition, optio
18291
18814
  const caps = [
18292
18815
  filesystemCapability,
18293
18816
  shell({
18817
+ // The SDK normally renders every shell error into model-facing text.
18818
+ // Preserve that behavior except for client-side, pre-dispatch Modal
18819
+ // readiness proof, which reaches bounded same-turn recovery.
18820
+ execCommandErrorFunction: (_context, error) => {
18821
+ if (isModalTaskExecStartPreDispatchUnavailableError(error)) throw error;
18822
+ const details = error instanceof Error ? error.toString() : String(error);
18823
+ return `An error occurred while running the tool. Please try again. Error: ${details}`;
18824
+ },
18294
18825
  ...toolCancellation ? {} : { configureTools: withExecOpCorrelation }
18295
18826
  })
18296
18827
  ];
@@ -21622,7 +22153,7 @@ async function runOwnedSandboxSetup(agent, session, setupSession, opts) {
21622
22153
  if (opts.recordLazyManifest) {
21623
22154
  const manifest = agent.defaultManifest;
21624
22155
  if (manifest) {
21625
- const { recordLazyMaterializedDirectories } = await import("./lazy-manifest-OEYEHNVY.js");
22156
+ const { recordLazyMaterializedDirectories } = await import("./lazy-manifest-GCGUFIWP.js");
21626
22157
  await recordLazyMaterializedDirectories(session, manifest);
21627
22158
  }
21628
22159
  }
@@ -23687,6 +24218,7 @@ export {
23687
24218
  serializedRunStateHasOpaqueProviderArtifact,
23688
24219
  COMPACTION_SUMMARY_MARKER,
23689
24220
  SUMMARY_BUFFER_TOKENS,
24221
+ compactionSummaryOutputTokens,
23690
24222
  COMPACT_USER_MESSAGE_MAX_TOKENS,
23691
24223
  REMOTE_V2_RETAINED_MESSAGE_TOKEN_BUDGET,
23692
24224
  REMOTE_COMPACTION_V2_IMPLEMENTATION,
@@ -23941,4 +24473,4 @@ export {
23941
24473
  runAzureCliLoginHook,
23942
24474
  renderSessionGoalContext2 as renderSessionGoalContext
23943
24475
  };
23944
- //# sourceMappingURL=chunk-J6J3VYFW.js.map
24476
+ //# sourceMappingURL=chunk-OGG5NQLA.js.map