@opengeni/runtime 6.5.2-canary.41607687019001 → 6.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/agent-instructions/modules/subagents.d.ts +4 -1
  2. package/dist/agent-instructions/tool-availability.d.ts +12 -0
  3. package/dist/agent-instructions/types.d.ts +16 -2
  4. package/dist/assets/codemode-client.json +1 -1
  5. package/dist/{chunk-HYSMFK7K.js → chunk-3MNZZ2B4.js} +34 -12
  6. package/dist/chunk-3MNZZ2B4.js.map +1 -0
  7. package/dist/{chunk-PZPM6Z62.js → chunk-77NQGL66.js} +4 -2
  8. package/dist/chunk-77NQGL66.js.map +1 -0
  9. package/dist/{chunk-AE7DWNDQ.js → chunk-FNAYH3SN.js} +572 -278
  10. package/dist/chunk-FNAYH3SN.js.map +1 -0
  11. package/dist/{chunk-RYNEQOTX.js → chunk-GFAFQMZV.js} +3 -3
  12. package/dist/{chunk-ZNFEE7S5.js → chunk-JF5UTPEU.js} +2 -2
  13. package/dist/{chunk-GRNURW7Y.js → chunk-JY5NSZ37.js} +294 -36
  14. package/dist/chunk-JY5NSZ37.js.map +1 -0
  15. package/dist/{chunk-XXCIHKHP.js → chunk-OAW6MMSY.js} +3 -3
  16. package/dist/{chunk-F62XZWUW.js → chunk-RZJXTSVA.js} +2 -2
  17. package/dist/command-completion-delivery.d.ts +130 -0
  18. package/dist/gmail-rest-mcp.js +3 -3
  19. package/dist/google-calendar-rest-mcp.js +2 -2
  20. package/dist/index.d.ts +8 -0
  21. package/dist/index.js +20 -8
  22. package/dist/interaction-tools.d.ts +9 -0
  23. package/dist/lazy-tool-transport.d.ts +2 -0
  24. package/dist/metrics.d.ts +9 -0
  25. package/dist/model-call.js +1 -1
  26. package/dist/provider-history-adapter.d.ts +6 -0
  27. package/dist/provider-invalid-request.d.ts +16 -0
  28. package/dist/provider-tool-names.d.ts +54 -0
  29. package/dist/sandbox/index.js +2 -2
  30. package/dist/sandbox/providers/modal-command-router-wire.d.ts +2 -0
  31. package/dist/slack-rest-mcp.js +3 -3
  32. package/dist/workspace-tool-gateway.js +8 -8
  33. package/package.json +16 -17
  34. package/src/agent-instructions/PROMPT_CHANGELOG.md +75 -3
  35. package/src/agent-instructions/modules/subagents.ts +43 -30
  36. package/src/agent-instructions/runtime-mechanics.ts +20 -2
  37. package/src/agent-instructions/tool-availability.ts +23 -2
  38. package/src/agent-instructions/types.ts +16 -2
  39. package/src/anthropic-messages.ts +4 -1
  40. package/src/command-completion-delivery.ts +388 -0
  41. package/src/index.ts +47 -7
  42. package/src/interaction-tools.ts +19 -2
  43. package/src/lazy-tool-transport.ts +48 -2
  44. package/src/metrics.ts +5 -0
  45. package/src/model-provider-client.ts +20 -0
  46. package/src/model-provider-routing.ts +2 -0
  47. package/src/provider-history-adapter.ts +23 -2
  48. package/src/provider-invalid-request.ts +77 -0
  49. package/src/provider-tool-names.ts +340 -0
  50. package/src/sandbox/providers/modal-command-control.ts +2 -1
  51. package/src/sandbox/providers/modal-command-router-wire.ts +3 -1
  52. package/src/sandbox/providers/modal-command-session.ts +54 -11
  53. package/dist/chunk-AE7DWNDQ.js.map +0 -1
  54. package/dist/chunk-GRNURW7Y.js.map +0 -1
  55. package/dist/chunk-HYSMFK7K.js.map +0 -1
  56. package/dist/chunk-PZPM6Z62.js.map +0 -1
  57. /package/dist/{chunk-RYNEQOTX.js.map → chunk-GFAFQMZV.js.map} +0 -0
  58. /package/dist/{chunk-ZNFEE7S5.js.map → chunk-JF5UTPEU.js.map} +0 -0
  59. /package/dist/{chunk-XXCIHKHP.js.map → chunk-OAW6MMSY.js.map} +0 -0
  60. /package/dist/{chunk-F62XZWUW.js.map → chunk-RZJXTSVA.js.map} +0 -0
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  connectorAttachmentFileName
3
- } from "./chunk-ZNFEE7S5.js";
3
+ } from "./chunk-JF5UTPEU.js";
4
4
  import {
5
5
  isRoutingMutationOutcomeUnknownError
6
- } from "./chunk-PZPM6Z62.js";
6
+ } from "./chunk-77NQGL66.js";
7
7
 
8
8
  // src/slack-rest-mcp.ts
9
9
  import {
@@ -597,4 +597,4 @@ export {
597
597
  SLACK_REST_API_BASE2 as SLACK_REST_API_BASE,
598
598
  SLACK_REST_MCP_TOOLS
599
599
  };
600
- //# sourceMappingURL=chunk-RYNEQOTX.js.map
600
+ //# sourceMappingURL=chunk-GFAFQMZV.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  isRoutingMutationOutcomeUnknownError,
6
6
  isRoutingMutationOutputRejectedError
7
- } from "./chunk-PZPM6Z62.js";
7
+ } from "./chunk-77NQGL66.js";
8
8
 
9
9
  // src/connector-attachments.ts
10
10
  import { createHash } from "crypto";
@@ -162,4 +162,4 @@ export {
162
162
  connectorAttachmentSandboxPath,
163
163
  projectConnectorAttachmentTransfers
164
164
  };
165
- //# sourceMappingURL=chunk-ZNFEE7S5.js.map
165
+ //# sourceMappingURL=chunk-JF5UTPEU.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SLACK_REST_MCP_BRIDGE_ADAPTER
3
- } from "./chunk-RYNEQOTX.js";
3
+ } from "./chunk-GFAFQMZV.js";
4
4
  import {
5
5
  ModalCloudBucketMountStrategy,
6
6
  codemodeTokenFileFromEnvironment,
@@ -21,7 +21,7 @@ import {
21
21
  withCommandNotStartedCallProof,
22
22
  withRunCredentialsClient,
23
23
  withRunCredentialsSession
24
- } from "./chunk-HYSMFK7K.js";
24
+ } from "./chunk-3MNZZ2B4.js";
25
25
  import {
26
26
  sandboxHookOperationPurpose,
27
27
  withSandboxOperationPurpose
@@ -129,7 +129,7 @@ import {
129
129
  withPreparedCompactionRequest,
130
130
  withPromptCacheFingerprintObserver,
131
131
  withSearchRecordForm
132
- } from "./chunk-AE7DWNDQ.js";
132
+ } from "./chunk-FNAYH3SN.js";
133
133
  import {
134
134
  normalizeProtocolJsonValue
135
135
  } from "./chunk-V6YVIEUE.js";
@@ -140,11 +140,11 @@ import {
140
140
  modelToolTextBudgetBytes,
141
141
  wrapAttemptToolDefinitions,
142
142
  wrapAttemptToolExecute
143
- } from "./chunk-XXCIHKHP.js";
143
+ } from "./chunk-OAW6MMSY.js";
144
144
  import {
145
145
  ConnectorAttachmentTransferError,
146
146
  projectConnectorAttachmentTransfers
147
- } from "./chunk-ZNFEE7S5.js";
147
+ } from "./chunk-JF5UTPEU.js";
148
148
  import {
149
149
  MCP_MAX_CONCURRENT_SERVER_OPERATIONS,
150
150
  MCP_MAX_RESPONSE_BYTES,
@@ -165,7 +165,7 @@ import {
165
165
  GOOGLE_CALENDAR_REST_MCP_BRIDGE_ADAPTER,
166
166
  googleCalendarRestResultOutcome,
167
167
  isOfficialGoogleCalendarMcpConfig
168
- } from "./chunk-F62XZWUW.js";
168
+ } from "./chunk-RZJXTSVA.js";
169
169
  import {
170
170
  OpStreamUnavailableError,
171
171
  ProviderCommandObservationUnavailableError,
@@ -183,7 +183,7 @@ import {
183
183
  setSelfhostedApplyDiff,
184
184
  withRoutingMutationOutputRejectionFence,
185
185
  wrapCapabilityToolsForTurnCancellation
186
- } from "./chunk-PZPM6Z62.js";
186
+ } from "./chunk-77NQGL66.js";
187
187
  import {
188
188
  SandboxAgent,
189
189
  filesystem,
@@ -657,6 +657,224 @@ function secretValueModelInputFilter(memory) {
657
657
  };
658
658
  }
659
659
 
660
+ // src/command-completion-delivery.ts
661
+ var WAIT_AFTER_UNREAD_COMMAND_RESULTS = "Not waiting, and your reply was not shown: a background command finished during this step and its result is in another tool result of this step. Read it first, then wait again with your full reply if you still need to.";
662
+ var CommandCompletionDelivery = class {
663
+ constructor(source) {
664
+ this.source = source;
665
+ }
666
+ turnEndingCallStarted = false;
667
+ deliveredInStep = false;
668
+ takes = /* @__PURE__ */ new Set();
669
+ /** The next model call receives every result attached so far. */
670
+ modelCallStarting() {
671
+ this.turnEndingCallStarted = false;
672
+ this.deliveredInStep = false;
673
+ }
674
+ /** Before a turn-ending call runs: its refusal text, or null to run it. */
675
+ async beforeTurnEndingCall() {
676
+ this.turnEndingCallStarted = true;
677
+ while (this.takes.size > 0) await Promise.allSettled([...this.takes]);
678
+ return this.deliveredInStep ? WAIT_AFTER_UNREAD_COMMAND_RESULTS : null;
679
+ }
680
+ /** The tool output followed by any finished commands, in its own shape. */
681
+ async deliverWith(output) {
682
+ const own = plainTextToolOutputText(output);
683
+ if (this.turnEndingCallStarted || this.source.signal?.aborted || own === null) {
684
+ return output;
685
+ }
686
+ const maxBytes = commandCompletionRoomBytes(
687
+ Buffer.byteLength(own, "utf8"),
688
+ this.source.maxTextBytes?.() ?? modelToolTextBudgetBytes()
689
+ );
690
+ if (maxBytes < COMMAND_COMPLETION_NOTICE_MIN_ROOM_BYTES) return output;
691
+ const take = (async () => {
692
+ const completions = await this.source.take({ maxBytes });
693
+ if (completions.length === 0) return null;
694
+ const notice2 = renderCommandCompletionNotice(completions);
695
+ return this.source.mask ? await this.source.mask(notice2) : notice2;
696
+ })();
697
+ this.takes.add(take);
698
+ let notice;
699
+ try {
700
+ notice = await take;
701
+ } catch (error) {
702
+ this.source.onError?.(error);
703
+ return output;
704
+ } finally {
705
+ this.takes.delete(take);
706
+ }
707
+ if (notice === null) return output;
708
+ const next = appendToPlainTextToolOutput(output, notice);
709
+ if (next === null) return output;
710
+ this.deliveredInStep = true;
711
+ this.source.onDelivered?.(notice);
712
+ return next;
713
+ }
714
+ };
715
+ var COMMAND_COMPLETION_NOTICE_MAX_BYTES = 16384;
716
+ var COMMAND_COMPLETION_NOTICE_MIN_ROOM_BYTES = 1024;
717
+ var COMMAND_COMPLETION_NOTICE_MARGIN_BYTES = 512;
718
+ function commandCompletionRoomBytes(ownBytes, budgetBytes) {
719
+ return Math.max(
720
+ 0,
721
+ Math.min(
722
+ COMMAND_COMPLETION_NOTICE_MAX_BYTES,
723
+ budgetBytes - ownBytes - COMMAND_COMPLETION_NOTICE_MARGIN_BYTES
724
+ )
725
+ );
726
+ }
727
+ var TURN_ENDING_TOOL_SUFFIXES = ["wait_for_input"];
728
+ function endsTurn(name) {
729
+ return TURN_ENDING_TOOL_SUFFIXES.some(
730
+ (suffix) => name === suffix || name.endsWith(`__${suffix}`)
731
+ );
732
+ }
733
+ function renderCommandCompletionNotice(completions) {
734
+ return completions.map((completion) => {
735
+ const lines = [
736
+ `[Background command finished] ${completion.summary}`,
737
+ `Command ID: ${completion.commandId}`
738
+ ];
739
+ if (completion.notice) lines.push(completion.notice);
740
+ if (completion.output === null) {
741
+ lines.push(`Output: read it with command_read.`);
742
+ } else if (completion.output === "") {
743
+ lines.push("Output: (none)");
744
+ } else {
745
+ lines.push("Output:", completion.output);
746
+ }
747
+ return lines.join("\n");
748
+ }).join("\n\n");
749
+ }
750
+ function parsesAsJson(text) {
751
+ const start = text.trimStart()[0];
752
+ if (start !== "{" && start !== "[" && start !== '"') return false;
753
+ try {
754
+ JSON.parse(text);
755
+ return true;
756
+ } catch {
757
+ return false;
758
+ }
759
+ }
760
+ function plainTextToolOutputText(output) {
761
+ if (appendToPlainTextToolOutput(output, "") === null) return null;
762
+ return typeof output === "string" ? output : output.text;
763
+ }
764
+ function appendToPlainTextToolOutput(output, text) {
765
+ if (typeof output === "string") {
766
+ return parsesAsJson(output) ? null : `${output}${output === "" ? "" : "\n\n"}${text}`;
767
+ }
768
+ if (output !== null && typeof output === "object" && !Array.isArray(output) && output.type === "text" && typeof output.text === "string" && Object.keys(output).every((key) => key === "type" || key === "text")) {
769
+ const current = output.text;
770
+ return parsesAsJson(current) ? null : { type: "text", text: `${current}${current === "" ? "" : "\n\n"}${text}` };
771
+ }
772
+ return null;
773
+ }
774
+ function withoutAppendedCommandCompletions(output, appended) {
775
+ for (const text of appended) {
776
+ const own = withoutAppendedText(output, text);
777
+ if (own !== output) {
778
+ appended.delete(text);
779
+ return own;
780
+ }
781
+ }
782
+ return output;
783
+ }
784
+ function withoutAppendedText(output, appended) {
785
+ const strip = (text) => {
786
+ if (!text.endsWith(appended)) return null;
787
+ const rest = text.slice(0, text.length - appended.length);
788
+ return rest.endsWith("\n\n") ? rest.slice(0, -2) : rest;
789
+ };
790
+ if (typeof output === "string") return strip(output) ?? output;
791
+ if (output !== null && typeof output === "object" && !Array.isArray(output) && typeof output.text === "string") {
792
+ const text = strip(output.text);
793
+ return text === null ? output : { ...output, text };
794
+ }
795
+ return output;
796
+ }
797
+ var deliveringTools = /* @__PURE__ */ new WeakMap();
798
+ function deliveringApplyPatchEditor(editor, delivery) {
799
+ const deliver = (method) => async (operation, context) => {
800
+ const result = await editor[method](operation, context);
801
+ const output = result?.output ?? "";
802
+ const next = await delivery.deliverWith(output);
803
+ return next === output ? result : { ...result, output: next };
804
+ };
805
+ return {
806
+ createFile: deliver("createFile"),
807
+ updateFile: deliver("updateFile"),
808
+ deleteFile: deliver("deleteFile")
809
+ };
810
+ }
811
+ function commandCompletionDeliveringTool(tool2, delivery) {
812
+ if (tool2.type !== "function" && tool2.type !== "apply_patch") return tool2;
813
+ let cache = deliveringTools.get(delivery);
814
+ if (!cache) {
815
+ cache = /* @__PURE__ */ new WeakMap();
816
+ deliveringTools.set(delivery, cache);
817
+ }
818
+ const existing = cache.get(tool2);
819
+ if (existing) return existing;
820
+ if (tool2.type === "apply_patch") {
821
+ const editor = tool2.editor;
822
+ if (!editor) return tool2;
823
+ const next2 = { ...tool2, editor: deliveringApplyPatchEditor(editor, delivery) };
824
+ cache.set(tool2, next2);
825
+ cache.set(next2, next2);
826
+ return next2;
827
+ }
828
+ const invoke = tool2.invoke.bind(tool2);
829
+ const turnEnding = endsTurn(tool2.name);
830
+ const next = {
831
+ ...tool2,
832
+ invoke: async (...args) => {
833
+ if (turnEnding) {
834
+ const refusal = await delivery.beforeTurnEndingCall();
835
+ return refusal ?? await invoke(...args);
836
+ }
837
+ const output = await invoke(...args);
838
+ return await delivery.deliverWith(output);
839
+ }
840
+ };
841
+ cache.set(tool2, next);
842
+ cache.set(next, next);
843
+ return next;
844
+ }
845
+ var agentDeliveries = /* @__PURE__ */ new WeakMap();
846
+ function installCommandCompletionDelivery(agent, delivery) {
847
+ if (agentDeliveries.has(agent)) return;
848
+ agentDeliveries.set(agent, delivery);
849
+ const getAllTools = agent.getAllTools.bind(agent);
850
+ agent.getAllTools = async (runContext) => (await getAllTools(runContext)).map((tool2) => commandCompletionDeliveringTool(tool2, delivery));
851
+ const clone = agent.clone?.bind(agent);
852
+ if (clone) {
853
+ agent.clone = (config) => {
854
+ const cloned = clone(config);
855
+ installCommandCompletionDelivery(cloned, delivery);
856
+ return cloned;
857
+ };
858
+ }
859
+ }
860
+ function commandCompletionToolResolver(agent, resolve) {
861
+ const delivery = agentDeliveries.get(agent);
862
+ if (!delivery || !resolve) return resolve;
863
+ const wrapped = async (input) => {
864
+ const tool2 = await resolve(input);
865
+ return tool2 ? commandCompletionDeliveringTool(tool2, delivery) : tool2;
866
+ };
867
+ return wrapped;
868
+ }
869
+ function commandCompletionModelCallFilter(agent) {
870
+ const delivery = agentDeliveries.get(agent);
871
+ if (!delivery) return void 0;
872
+ return ({ modelData }) => {
873
+ delivery.modelCallStarting();
874
+ return modelData;
875
+ };
876
+ }
877
+
660
878
  // src/agent-instructions/types.ts
661
879
  function toolAvailable(context, name) {
662
880
  return !context.toolAvailability?.unavailable.includes(name);
@@ -2132,6 +2350,7 @@ var InteractionExecutionResult = class {
2132
2350
  }
2133
2351
  };
2134
2352
  var BROWSER_AGENT_MAX_NODES = 60;
2353
+ var BROWSER_OPEN_RESULT_GUIDANCE = "Act on the outline's elements directly instead of observing again; browser_observe, browser_act, browser_screenshot and browser_tabs work on this session. A new attached session opens a dedicated tab.";
2135
2354
  var BROWSER_AGENT_MAX_NODE_BYTES = 12e3;
2136
2355
  var BROWSER_AGENT_MAX_FIELD_LENGTH = 180;
2137
2356
  var BROWSER_AGENT_MAX_OMITTED_REGIONS = 4;
@@ -2865,6 +3084,7 @@ function createInteractionAttemptToolDefinitions(input) {
2865
3084
  while (fullFrameSizes.size > 32) fullFrameSizes.delete(fullFrameSizes.keys().next().value);
2866
3085
  };
2867
3086
  const browserSeen = /* @__PURE__ */ new Map();
3087
+ let browserOpenGuidanceShown = false;
2868
3088
  const rememberBrowserReading = (context, observation) => {
2869
3089
  if (context.caller.kind !== "model" || !observation) return;
2870
3090
  browserSeen.delete(observation.target.id);
@@ -3329,14 +3549,18 @@ function createInteractionAttemptToolDefinitions(input) {
3329
3549
  name: "browser_open",
3330
3550
  codemodePath: ["interaction", "browser", "open"],
3331
3551
  title: "Open or reuse browser",
3332
- 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 the user's own Chrome with placement={kind:'attached_device'}. Use that directly for requests about 'my browser', 'my tabs', or current Chrome: it opens the only Chrome profile connected through the ${extension.name} extension, or else the most recently active one (reported as attachedProfile, the rest as otherAttachedProfiles). Add deviceId (from interaction_discover scope=attached_browsers or otherAttachedProfiles) only when the user wants a different profile. Omitting placement never uses the user's Chrome. If no profile is connected, do not fall back to 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. Operator-enabled disposable sandbox verification may explicitly request storageMode=ephemeral_context with headless=true: no saved identity, route, Computer, checkpoint or resume; process loss ends the session. Default private_profile storage is unchanged. Returns the session, its tabs and an outline of the opened (or selected) tab when one is available, in the browser_observe format. With initialUrl, only the opened tab is listed and the others are counted (browser_tabs list shows them). Act on the outline's elements directly instead of observing again. Set includeScreenshot=true to also get a still image of the opened tab in the same call when its visual state matters. Call it first for any browser task; browser_observe, browser_act, browser_screenshot and browser_tabs then work on the session it returns. For repetitive or bulk work, such as screenshots of many pages or widths, script these same browsers with Code Mode instead of installing another browser automation library: openGeni.browsers.open({initialUrl}), tab.navigate(url, {waitUntil:'network_idle'}), tab.act({type:'viewport',width,height}) and tab.screenshot({saveTo}), or from the shell client, call interaction.browser.screenshot with --save-image <path>. Solve CAPTCHAs and other verification challenges yourself, retrying and trying alternatives as needed; never hand them to the user.`,
3552
+ 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 the user's own Chrome with placement={kind:'attached_device'}. Use that directly for requests about 'my browser', 'my tabs', or current Chrome: it opens the only Chrome profile connected through the ${extension.name} extension, or else the most recently active one (reported as attachedProfile, the rest as otherAttachedProfiles). Add deviceId (from interaction_discover scope=attached_browsers or otherAttachedProfiles) only when the user wants a different profile. Omitting placement never uses the user's Chrome. If no profile is connected, do not fall back to a blank managed browser. Never switch to the user's attached Chrome as a fallback for a failed managed browser unless the user requested that profile. 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. Operator-enabled disposable sandbox verification may explicitly request storageMode=ephemeral_context with headless=true: no saved identity, route, Computer, checkpoint or resume; process loss ends the session. Set includeScreenshot=true to also get a still image of the opened tab in the same call when its visual state matters. Call it first for any browser task: BrowserSessions persist across tool calls, while shell-launched browser daemons do not survive remote-command cleanup. For repetitive or bulk work, such as screenshots of many pages or widths, script these same browsers with Code Mode instead of installing another browser automation library: openGeni.browsers.open({initialUrl}), tab.navigate(url, {waitUntil:'network_idle'}), tab.act({type:'viewport',width,height}) and tab.screenshot({saveTo}), or from the shell client, interaction.browser.screenshot with --save-image <path>. Solve CAPTCHAs and other verification challenges yourself, retrying and trying alternatives as needed; never hand them to the user.`,
3333
3553
  input: BrowserOpenInput,
3334
3554
  output: BrowserOpenOutput,
3335
3555
  readOnly: false,
3336
3556
  idempotent: true,
3337
3557
  modelText: (output, context) => {
3338
3558
  rememberBrowserReading(context, output.observation);
3339
- return browserOpenText(output);
3559
+ const text = browserOpenText(output);
3560
+ if (context.caller.kind !== "model" || browserOpenGuidanceShown) return text;
3561
+ browserOpenGuidanceShown = true;
3562
+ return `${text}
3563
+ ${BROWSER_OPEN_RESULT_GUIDANCE}`;
3340
3564
  },
3341
3565
  execute: async (value, context) => {
3342
3566
  const chatMove = { moved: false };
@@ -7661,10 +7885,14 @@ function ceilingCanAdmit(ceiling, policy) {
7661
7885
  function deriveAgentPromptToolAvailability(input) {
7662
7886
  const selected = new Set(input.selectedFirstPartyTools);
7663
7887
  const ceiling = input.firstPartyPermissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS2;
7888
+ const nestingExhausted = typeof input.nestedAgentDepth === "number" && typeof input.effectiveMaxNestedAgentDepth === "number" && input.nestedAgentDepth >= input.effectiveMaxNestedAgentDepth;
7664
7889
  const unavailable = FIRST_PARTY_MCP_TOOL_NAMES.filter(
7665
- (name) => !selected.has(name) || !ceilingCanAdmit(ceiling, FIRST_PARTY_TOOL_AUTHORIZATION[name])
7890
+ (name) => !selected.has(name) || !ceilingCanAdmit(ceiling, FIRST_PARTY_TOOL_AUTHORIZATION[name]) || nestingExhausted && name === "session_create"
7666
7891
  );
7667
- return { unavailable: [...new Set(unavailable)].sort() };
7892
+ return {
7893
+ unavailable: [...new Set(unavailable)].sort(),
7894
+ ...nestingExhausted ? { childSessionsImpossible: true } : {}
7895
+ };
7668
7896
  }
7669
7897
 
7670
7898
  // src/index.ts
@@ -8026,17 +8254,26 @@ var COMPACTION = `When earlier context is compacted, continue from the supplied
8026
8254
  var BACKGROUND_COMMANDS = `For a yielded command, use \`command_read\` to read available output and status, or \`command_wait\` to wait briefly using the same command interface. Keep the command ID and output cursor. A terminal read suppresses any still-pending completion notification; a running read does not. Earlier tool results and delivered messages never change. Use \`command_input\` only to send input where supported, not to poll output. An unsupported input capability does not imply output is unavailable. Give foreground commands a realistic requested wait; default to 10 seconds (yield_time_ms: 10000). An internal polling slice is not a reason to return a background handle.
8027
8255
 
8028
8256
  Command completion alone resumes you only while you have an explicit \`wait_for_input\` registered. For ordinary background commands, register that session-level wait before ending your turn. Exception: pending Codemode calls need the current live attempt; keep observing them with \`command_wait\`/\`command_read\` instead of ending the turn. If you finish normally, command results remain retained and can accompany later input, but do not start another turn by themselves. No per-command dismissal is required.`;
8257
+ var COMMAND_COMPLETION_DELIVERY = "A command that finishes while you work reports its exit status and output on its own, after a later tool result or as input, so do not poll only to learn that it finished.";
8258
+ var TERMINAL_READ_SENTENCE = "A terminal read suppresses any still-pending completion notification; a running read does not.";
8029
8259
  function backgroundCommands(context) {
8030
8260
  const read = toolAvailable(context, "command_read");
8031
8261
  const wait = toolAvailable(context, "command_wait");
8032
8262
  const waitForInput = toolAvailable(context, "wait_for_input");
8033
- if (read && wait && waitForInput) return BACKGROUND_COMMANDS;
8263
+ const delivery = context.resources.commandCompletionDelivery === true;
8264
+ if (read && wait && waitForInput) {
8265
+ return delivery ? BACKGROUND_COMMANDS.replace(
8266
+ TERMINAL_READ_SENTENCE,
8267
+ `${TERMINAL_READ_SENTENCE} ${COMMAND_COMPLETION_DELIVERY}`
8268
+ ) : BACKGROUND_COMMANDS;
8269
+ }
8034
8270
  const observe = read && wait ? "`command_wait`/`command_read`" : read ? "`command_read`" : "`command_wait`";
8035
8271
  return blocks(
8036
8272
  sentences(
8037
8273
  read && wait ? "For a yielded command, use `command_read` to read available output and status, or `command_wait` to wait briefly using the same command interface." : read ? "For a yielded command, use `command_read` to read available output and status." : wait ? "For a yielded command, use `command_wait` to wait briefly for available output and status." : void 0,
8038
8274
  (read || wait) && "Keep the command ID and output cursor.",
8039
8275
  (read || wait) && "A terminal read suppresses any still-pending completion notification; a running read does not.",
8276
+ delivery && COMMAND_COMPLETION_DELIVERY,
8040
8277
  "Earlier tool results and delivered messages never change.",
8041
8278
  "Use `command_input` only to send input where supported, not to poll output.",
8042
8279
  "An unsupported input capability does not imply output is unavailable.",
@@ -8422,6 +8659,8 @@ var subagentsModule = {
8422
8659
  applies: (context) => context.capabilities.subagents,
8423
8660
  render: (context) => {
8424
8661
  const { goals } = context.capabilities;
8662
+ const spawn = toolAvailable(context, "session_create");
8663
+ const children = context.toolAvailability?.childSessionsImpossible !== true;
8425
8664
  const sessionEvents = toolAvailable(context, "session_events");
8426
8665
  const waitForInput = toolAvailable(context, "wait_for_input");
8427
8666
  const pollingTools = toolsAvailable(context, ["session_wait", "session_get"]);
@@ -8434,17 +8673,17 @@ var subagentsModule = {
8434
8673
  sessionEvents && toolsAvailable(context, ["session_target_get", "session_target_set"]) && "For a conversation about another session, use session_target_get/set to remember or clear the selected target; selection is context, not permission to mutate. Discover with sessions_list and inspect with session_events; keep voice in this session. Send only when asked, and use Steer only for an explicit change of direction.",
8435
8674
  toolAvailable(context, "session_message_status") && "After Send or Steer, use session_message_status with the returned update ID to follow its exact consuming turn and read the indicated result before relaying it. Do not resend pending work or mistake acceptance for completion.",
8436
8675
  sentences(
8437
- "Create a child worker only for a concrete, bounded subtask that can run independently and whose result has a clear integration point in the current request.",
8438
- toolAvailable(context, "session_send_message") ? "Delegation has setup and coordination overhead: by default, answer directly when the work takes only a few steps, and send a related follow-up to a child you already spawned with `session_send_message` instead of spawning another." : "Delegation has setup and coordination overhead: by default, answer directly when the work takes only a few steps.",
8439
- "Explicit user requests and applicable Skill guidance for delegation, independent review, or fresh workers override that default within existing authority.",
8440
- "Before spawning, decide what output you need and keep the parent's concurrent work disjoint.",
8441
- "Do not duplicate a child's implementation; independent review or comparison may intentionally examine the same subject with a distinct deliverable.",
8442
- "If no useful independent work remains and no such delegation is requested, continue in this session.",
8676
+ spawn && "Create a child worker only for a concrete, bounded subtask that can run independently and whose result has a clear integration point in the current request.",
8677
+ spawn && (toolAvailable(context, "session_send_message") ? "Delegation has setup and coordination overhead: by default, answer directly when the work takes only a few steps, and send a related follow-up to a child you already spawned with `session_send_message` instead of spawning another." : "Delegation has setup and coordination overhead: by default, answer directly when the work takes only a few steps."),
8678
+ spawn && "Explicit user requests and applicable Skill guidance for delegation, independent review, or fresh workers override that default within existing authority.",
8679
+ spawn && "Before spawning, decide what output you need and keep the parent's concurrent work disjoint.",
8680
+ spawn && "Do not duplicate a child's implementation; independent review or comparison may intentionally examine the same subject with a distinct deliverable.",
8681
+ spawn && "If no useful independent work remains and no such delegation is requested, continue in this session.",
8443
8682
  "Do not repurpose or direct an unrelated existing session unless the user explicitly asks.",
8444
8683
  "If no matching session tool is available on this turn, handle what you can in this session and report any required delegation that is unavailable instead of inventing an API."
8445
8684
  ),
8446
8685
  "When supervising work, an accepted message, queued status, or changing timestamp is not proof of execution. Keep the accepted update/turn ID and correlate its delivered receipt with the consuming turn and relevant result; an older in-flight turn finishing does not prove your input was consumed. Use the receipt correlation described by the sending tool. Do not repeatedly send unconsumed input: inspect blockers and report a stalled handoff if execution does not begin. Preserve explicit human pauses and approvals.",
8447
- sentences(
8686
+ children && sentences(
8448
8687
  "After spawning, keep each child id and event cursor.",
8449
8688
  goals ? "Before committing, publishing, completing a goal, or giving a final answer that depends on a child, consume and integrate that child's completed result." : "Before committing, publishing, or giving a final answer that depends on a child, consume and integrate that child's completed result.",
8450
8689
  waitForInput && (pollingTools ? "When a child needs minutes and nothing else can advance meanwhile, call `wait_for_input` right after spawning instead of alternating `session_wait` and `session_get`: the child's terminal result wakes you and carries its final answer in `payload.finalAnswer`." : "When a child needs minutes and nothing else can advance meanwhile, call `wait_for_input` right after spawning: the child's terminal result wakes you and carries its final answer in `payload.finalAnswer`."),
@@ -8454,7 +8693,7 @@ var subagentsModule = {
8454
8693
  "Do not present delegated work as incorporated until you have consumed the completed result.",
8455
8694
  "If a child becomes unnecessary, pause it when authorized instead of letting unused work continue."
8456
8695
  ),
8457
- toolAvailable(context, "session_human_input_respond") && "A child's question to the person may also reach you as a `child_requires_action` update; the first answer wins. Answer it with `session_human_input_respond` as soon as you can from your task context, before the person has to. When it asks for agent work you can do, such as starting a reviewer or worker, do that work and answer. When the person lets you decide a child's question, answer it with your best judgement and say in one sentence what you chose. Leave questions only a person can answer (decisions, preferences, credentials, approvals) to the person, and never answer a question meant for the person on their behalf.",
8696
+ children && toolAvailable(context, "session_human_input_respond") && "A child's question to the person may also reach you as a `child_requires_action` update; the first answer wins. Answer it with `session_human_input_respond` as soon as you can from your task context, before the person has to. When it asks for agent work you can do, such as starting a reviewer or worker, do that work and answer. When the person lets you decide a child's question, answer it with your best judgement and say in one sentence what you chose. Leave questions only a person can answer (decisions, preferences, credentials, approvals) to the person, and never answer a question meant for the person on their behalf.",
8458
8697
  shortWaits(context)
8459
8698
  );
8460
8699
  }
@@ -9615,7 +9854,7 @@ import { existsSync, readdirSync } from "fs";
9615
9854
  // ../sdk/package.json
9616
9855
  var package_default = {
9617
9856
  name: "@opengeni/sdk",
9618
- version: "6.5.2-canary.41607687019001",
9857
+ version: "6.7.0",
9619
9858
  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.",
9620
9859
  license: "Apache-2.0",
9621
9860
  repository: {
@@ -9859,14 +10098,13 @@ var package_default = {
9859
10098
  },
9860
10099
  engines: {
9861
10100
  node: ">=18"
9862
- },
9863
- gitHead: "041e773bc7a4e5e1ecd9f3667659f29f4599e441"
10101
+ }
9864
10102
  };
9865
10103
 
9866
10104
  // ../react/package.json
9867
10105
  var package_default2 = {
9868
10106
  name: "@opengeni/react",
9869
- version: "6.5.2-canary.41607687019001",
10107
+ version: "6.7.0",
9870
10108
  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.",
9871
10109
  license: "Apache-2.0",
9872
10110
  repository: {
@@ -10283,14 +10521,13 @@ var package_default2 = {
10283
10521
  },
10284
10522
  engines: {
10285
10523
  node: ">=18"
10286
- },
10287
- gitHead: "041e773bc7a4e5e1ecd9f3667659f29f4599e441"
10524
+ }
10288
10525
  };
10289
10526
 
10290
10527
  // ../codemode/package.json
10291
10528
  var package_default3 = {
10292
10529
  name: "@opengeni/codemode",
10293
- version: "6.5.2-canary.41607687019001",
10530
+ version: "6.7.0",
10294
10531
  description: "Attempt-frozen programmatic tool catalog and execution authority for Opengeni.",
10295
10532
  license: "Apache-2.0",
10296
10533
  repository: {
@@ -10334,14 +10571,13 @@ var package_default3 = {
10334
10571
  },
10335
10572
  engines: {
10336
10573
  node: ">=18"
10337
- },
10338
- gitHead: "041e773bc7a4e5e1ecd9f3667659f29f4599e441"
10574
+ }
10339
10575
  };
10340
10576
 
10341
10577
  // ../ogtool/package.json
10342
10578
  var package_default4 = {
10343
10579
  name: "@opengeni/ogtool",
10344
- version: "6.5.2-canary.41607687019001",
10580
+ version: "6.7.0",
10345
10581
  description: "Codemode CLI and typed client entrypoint for an Opengeni execution attempt.",
10346
10582
  license: "Apache-2.0",
10347
10583
  repository: {
@@ -10387,8 +10623,7 @@ var package_default4 = {
10387
10623
  },
10388
10624
  engines: {
10389
10625
  node: ">=18"
10390
- },
10391
- gitHead: "041e773bc7a4e5e1ecd9f3667659f29f4599e441"
10626
+ }
10392
10627
  };
10393
10628
 
10394
10629
  // src/site-package-versions.ts
@@ -13095,6 +13330,9 @@ function agentPromptResourcesFor(settings, resources, options) {
13095
13330
  ...options.secrets?.referencesEnabled ? { secretReferences: true } : {},
13096
13331
  ...options.unattended ? { unattended: true } : {},
13097
13332
  ...settings.githubPersonalOauthEnabled ? { personalGitHub: true } : {},
13333
+ // The worker attaches finished commands to later tool results whenever a
13334
+ // sandbox is active and cut polling is on (see installCommandCompletionDelivery).
13335
+ ...backend !== "none" && settings.experimentCutPolling ? { commandCompletionDelivery: true } : {},
13098
13336
  ...repositoryIdentities.length > 0 ? { repositoryIdentities } : {}
13099
13337
  };
13100
13338
  }
@@ -13662,6 +13900,9 @@ function buildOpenGeniAgent(settings, resources, options = {}) {
13662
13900
  );
13663
13901
  }
13664
13902
  installToolPreflightContainment(agent2);
13903
+ if (options.commandCompletionDelivery && settings.experimentCutPolling) {
13904
+ installCommandCompletionDelivery(agent2, options.commandCompletionDelivery);
13905
+ }
13665
13906
  if (options.secretValueMemory) {
13666
13907
  installToolResultSecretMasking(agent2, options.secretValueMemory);
13667
13908
  }
@@ -13786,6 +14027,9 @@ function buildOpenGeniAgent(settings, resources, options = {}) {
13786
14027
  );
13787
14028
  }
13788
14029
  installToolPreflightContainment(agent);
14030
+ if (options.commandCompletionDelivery && settings.experimentCutPolling) {
14031
+ installCommandCompletionDelivery(agent, options.commandCompletionDelivery);
14032
+ }
13789
14033
  if (options.secretValueMemory) {
13790
14034
  installToolResultSecretMasking(agent, options.secretValueMemory);
13791
14035
  }
@@ -17865,7 +18109,10 @@ async function restoreInterruptedRunState(agent, serializedRunState) {
17865
18109
  }
17866
18110
  return await RunState.fromString(agent, serializedRunState, {
17867
18111
  clientToolSearchRehydration: "preserve_history",
17868
- resolveMissingFunctionTool: secretMaskedToolResolver(agent, mcpToolResolverForAgent(agent))
18112
+ resolveMissingFunctionTool: secretMaskedToolResolver(
18113
+ agent,
18114
+ commandCompletionToolResolver(agent, mcpToolResolverForAgent(agent))
18115
+ )
17869
18116
  });
17870
18117
  }
17871
18118
  async function prepareRunInput(agent, input, options = {}) {
@@ -17958,7 +18205,7 @@ function takeGenesisTitleInputFilter(agent) {
17958
18205
  return oneShotGenesisTitleInputFilter();
17959
18206
  }
17960
18207
  var CODE_SEARCH_DIRECTIVE = "To find where something is implemented, configured or decided in the code, start with one `code_search` call (a precise question plus 6-15 likely identifiers, file-name fragments, config keys or error strings) instead of a series of separate searches and file reads. When the question asks whether something is required, enforced or the default, add a subQuestion and keywords for what could skip, bypass or override it. Use the returned passages directly instead of re-reading them. Their evidence rating covers only what the search returned, so spend follow-up searches outside those passages: other entry points to the same outcome (API routes, automatic or self-service paths), defaults, flags, exceptions and its unfollowed leads.";
17961
- var CODEMODE_PROGRAMMATIC_DIRECTIVE = 'Default `ogtool list` enumerates every authorized tool with a compact summary, without schemas or an output-size cutoff. Codemode uses current-attempt credentials. Keep ordinary running commands alive with `command_wait`/`command_read`. When a call returns `codemode_approval_pending`, retain its operation ID and let the review pause work. The worker resumes that exact stored operation after human approval; JavaScript locals do not resume. A later authorized attempt of the same turn can use `ogtool read <operation-id>` or `environmentCodemodeClient().status(operationId)` / `.resume(operationId)` to observe its result. Never copy the payload into another call to request approval. Observation failure or outcome_unknown does not prove execution failed; inspect actual state before any separately authorized retry. Managed sandboxes select the worker-release client on PATH for every command, including warm boxes. When OPENGENI_CODEMODE_CLIENT_MODULE is set, persistent Bun programs must use `const { tools, openGeni } = await import(process.env.OPENGENI_CODEMODE_CLIENT_MODULE!)`; do not import the older image-baked package or invoke /usr/local/bin/ogtool directly. The stock-package import below is only for environments without that deployment-selected module. Every tool in the Codemode catalog (what `ogtool list` shows) is also callable programmatically from the sandbox through the same frozen catalog, authority, credentials, policy, and execution path. Built-in sandbox tools for the shell, file patching, image viewing and terminal input are not in that catalog; inside the sandbox, use the shell and filesystem directly. In stock sandboxes, write persistent Bun code with `import { tools, openGeni } from "@opengeni/codemode"`; run `ogtool declarations <file.d.ts>` when project-local catalog types are useful. For shell calls, discover tools with `ogtool list`, inspect an unfamiliar tool with `ogtool show <tool-path>`, then use `ogtool call <tool-path> \'<json-args>\'`. Listing is compact by default; `list --json` gives compact structured discovery and `list --full` explicitly includes all schemas. When $OPENGENI_CODEMODE_NATIVE_CLIENT is available, prefer the connection-bound native client even if an older `ogtool` is installed: use `"$OPENGENI_CODEMODE_NATIVE_CLIENT" codemode` with the same list, show, and call commands; this uses the same public Codemode operation journal, not another tool path. If no compatible installed client is available and Bun plus $OPENGENI_OGTOOL_PACKAGE_SPEC are available, run the exact deployment-pinned package with `bun x -p "$OPENGENI_OGTOOL_PACKAGE_SPEC" ogtool ...`; never guess a version or install `latest`. Prefer Codemode for loops, polling, bulk filtering, and intermediate data that should remain in the sandbox instead of consuming your context window. Tools needing review return a compact durable pending handle in Codemode. New calls use the current permission snapshot; an existing review keeps its original action.';
18208
+ var CODEMODE_PROGRAMMATIC_DIRECTIVE = 'Every tool in the Codemode catalog (what `ogtool list` shows) is also callable programmatically from the sandbox through the same frozen catalog, authority, credentials, policy, and execution path. Built-in sandbox tools for the shell, file patching, image viewing and terminal input are not in that catalog; inside the sandbox, use the shell and filesystem directly. Prefer Codemode for loops, polling, bulk filtering, and intermediate data that should remain in the sandbox instead of consuming your context window. When $OPENGENI_CODEMODE_NATIVE_CLIENT is available, prefer the connection-bound native client even if an older `ogtool` is installed: `"$OPENGENI_CODEMODE_NATIVE_CLIENT" codemode` takes the same list, show, call, and read commands and uses the same public Codemode operation journal. Otherwise use a compatible `ogtool` from PATH (managed sandboxes put the worker-release client there for every command); if none is compatible, with Bun and $OPENGENI_OGTOOL_PACKAGE_SPEC use the exact pinned `bun x -p "$OPENGENI_OGTOOL_PACKAGE_SPEC" ogtool ...`; never guess a version or install `latest`. Default `ogtool list` enumerates every authorized tool with a compact summary, without schemas or an output-size cutoff; `list --json` is structured and `list --full` includes all schemas. Inspect a tool with `ogtool show <tool-path>` and call it with `ogtool call <tool-path> \'<json-args>\'`. When OPENGENI_CODEMODE_CLIENT_MODULE is set, persistent Bun programs must use `const { tools, openGeni } = await import(process.env.OPENGENI_CODEMODE_CLIENT_MODULE!)` (do not import the older image-baked package or invoke /usr/local/bin/ogtool directly); otherwise import them from "@opengeni/codemode"; `ogtool declarations <file.d.ts>` writes catalog types. A call needing review returns `codemode_approval_pending` with an operation ID: keep it and let the review pause the work; never copy the payload into another call to request approval. After approval the worker resumes that exact stored operation with its original action (JavaScript locals do not resume), and `ogtool read <operation-id>` (or `resume` to wait) observes the result from any authorized attempt of the same turn; new calls use the current permission snapshot. Observation failure or outcome_unknown does not prove execution failed; inspect actual state before any separately authorized retry.';
17962
18209
  function modelModalityProjectionFilterForAgent(agent, initialInputAlreadyProjected) {
17963
18210
  return incrementalModelInputProjectionFilter(
17964
18211
  {
@@ -18171,6 +18418,7 @@ async function runAgentStreamInternal(agent, input, settings, overrides = {}, in
18171
18418
  const ownedFilter = composeCallModelInputFilters(
18172
18419
  [
18173
18420
  inputWaitYield?.modelInputFilter,
18421
+ commandCompletionModelCallFilter(agent),
18174
18422
  measuredModelInputFilter(
18175
18423
  "input_filter_base",
18176
18424
  baseModelInputFilterForSettings(settings, {
@@ -18321,6 +18569,7 @@ async function runAgentStreamInternal(agent, input, settings, overrides = {}, in
18321
18569
  const callModelInputFilter = composeCallModelInputFilters(
18322
18570
  [
18323
18571
  inputWaitYield?.modelInputFilter,
18572
+ commandCompletionModelCallFilter(agent),
18324
18573
  measuredModelInputFilter(
18325
18574
  "input_filter_base",
18326
18575
  baseModelInputFilterForSettings(settings, {
@@ -18423,7 +18672,10 @@ function lazyToolRunBindings(agent) {
18423
18672
  const runtime = lazyToolRuntimeForAgent(agent);
18424
18673
  return {
18425
18674
  ...runtime ? { toolNotFoundBehavior: "return_error_to_model" } : {},
18426
- resolveMissingFunctionTool: secretMaskedToolResolver(agent, mcpToolResolverForAgent(agent))
18675
+ resolveMissingFunctionTool: secretMaskedToolResolver(
18676
+ agent,
18677
+ commandCompletionToolResolver(agent, mcpToolResolverForAgent(agent))
18678
+ )
18427
18679
  };
18428
18680
  }
18429
18681
  var FIRST_PARTY_CATALOG_SOURCES = /* @__PURE__ */ new Set([
@@ -21658,7 +21910,13 @@ export {
21658
21910
  secretMaskedTool,
21659
21911
  installToolResultSecretMasking,
21660
21912
  secretValueModelInputFilter,
21913
+ CommandCompletionDelivery,
21914
+ COMMAND_COMPLETION_NOTICE_MAX_BYTES,
21915
+ renderCommandCompletionNotice,
21916
+ withoutAppendedCommandCompletions,
21917
+ withoutAppendedText,
21661
21918
  INTERACTION_ATTEMPT_TOOL_NAMES,
21919
+ BROWSER_OPEN_RESULT_GUIDANCE,
21662
21920
  createInteractionAttemptToolDefinitions,
21663
21921
  nativeCuaSchema,
21664
21922
  createFirstPartyInteractionAttemptToolDefinitions,
@@ -21864,4 +22122,4 @@ export {
21864
22122
  runAzureCliLoginHook,
21865
22123
  renderSessionGoalContext2 as renderSessionGoalContext
21866
22124
  };
21867
- //# sourceMappingURL=chunk-GRNURW7Y.js.map
22125
+ //# sourceMappingURL=chunk-JY5NSZ37.js.map