@opengeni/runtime 0.2.3 → 0.3.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.
package/dist/index.d.ts CHANGED
@@ -7,7 +7,8 @@ import { ReasoningEffort, SessionEventType, ResourceRef, ToolRef, Permission } f
7
7
  export { CAPABILITY_DESCRIPTORS, CapabilityDescriptor, DESKTOP_STREAM_PORT, StreamTokenPayload, StreamTokenPayload as StreamTokenPayloadType, TERMINAL_STREAM_PORT } from '@opengeni/contracts';
8
8
  import { Capability, SandboxSessionLike, SandboxSessionState, Manifest, Capabilities, LocalDirLazySkillSource, SandboxClient } from '@openai/agents/sandbox';
9
9
  import OpenAI from 'openai';
10
- export { ActiveBackendResolverDeps, ActiveBackendUnresolvableError, ActivePointer, ChannelAConflictError, ChannelAEmitter, ChannelAExecArgs, ChannelAExecResult, ChannelANotFoundError, ChannelASession, ChannelAUnsupportedError, ChannelAValidationError, ControlRpc, DEFAULT_DESKTOP_GEOMETRY, DISPLAY_STACK_TIMEOUT_MS, DesktopGeometry, DisplayStackError, DisplayStackUnsupportedError, EnsureDisplayStackOptions, EnsureDisplayStackResult, EnsureTerminalServerOptions, EnsureTerminalServerResult, EstablishedSandboxSession, ExposeStreamPortInput, ExposeStreamPortResult, ExposedPortEndpoint, FinalizeRecordingResult, MintStreamTokenInput, MockAgentResponder, MockAgentResponderOptions, MockExecHandler, NatsControlRpc, NatsRequestConnection, NegotiationContext, NumstatEntry, PROVIDER_REGISTRY, ProviderConstructionContext, ProviderRegistration, RecordingCodec, RecordingContentType, RecordingError, RecordingProcess, RecordingUnavailableError, ResolvedActiveBackend, RoutableBackendSession, RoutableSandbox, RoutingSandboxSession, RoutingSandboxSessionDeps, RoutingTransitionEvent, RoutingUnsupportedError, SELFHOSTED_DEFAULT_TIMEOUT_MS, SELFHOSTED_RECONNECT_WINDOW_MS, SELFHOSTED_RELAY_STREAM_PATH, STREAM_PORT, STREAM_TOKEN_DEFAULT_TTL_SECONDS, SandboxChannelAService, SandboxChannelAServiceOptions, SandboxConfigError, SandboxProviderUnavailableError, SelfhostedApplyDiff, SelfhostedControlError, SelfhostedEditor, SelfhostedEnrollment, SelfhostedExecArgs, SelfhostedExecResult, SelfhostedImageOutput, SelfhostedLivenessState, SelfhostedNegotiationInput, SelfhostedRelayConfig, SelfhostedSandboxClient, SelfhostedSession, SelfhostedSessionBuild, SelfhostedSessionDeps, SelfhostedSessionState, SelfhostedUnavailableReason, StartRecordingInput, StreamPortUnavailableError, TERMINAL_SERVER_TIMEOUT_MS, TerminalServerError, TerminalServerUnsupportedError, agentErrorToControlError, assertDescriptorRegistryInvariants, assertProviderRegistryInvariants, assertSafeRelPath, backendSupportsOs, buildDisplayStackScript, buildSelfhostedBackendSession, buildStreamUrl, buildTerminalServerScript, contentTypeForCodec, createSandboxClient, createSandboxClientForBackend, decodeModalSnapshotId, deletePriorPersistedSnapshot, deleteRecordingArtifacts, deserializeSandboxSessionStateEnvelope, desktopCapableBackend, ensureDisplayStack, ensureTerminalServer, establishSandboxSessionFromEnvelope, exposeStreamPort, extForCodec, isExecSessionLostBanner, isProviderSandboxNotFoundError, isSelfhostedProviderNotFoundError, isWorkspaceEscapeError, makeActiveBackendResolver, mintStreamToken, negotiateCapabilities, negotiateSelfhostedCapabilities, offlineAgentError, offlineControlResponse, parseExecBannerSessionId, parseNumstatZ, parsePorcelainV2, parseUnifiedPatch, readRecordingBytes, readWorkspaceArchiveFromEnvelopeSessionState, recordingStorageKey, restoredSandboxSessionStateFromEntry, sandboxStateEntryFromRunState, selectBackend, selfhostedLiveness, serializeEstablishedSandboxEnvelope, setSelfhostedApplyDiff, startRecording, stopRecording, stripExecBanner, subjectFor, tearDownDisplayStack, tearDownTerminalServer, timeoutAgentError, timeoutControlResponse, verifyStreamToken } from './sandbox/index.js';
10
+ export { ActiveBackendResolverDeps, ActiveBackendUnresolvableError, ActivePointer, ChannelAConflictError, ChannelAEmitter, ChannelAExecArgs, ChannelAExecResult, ChannelANotFoundError, ChannelASession, ChannelAUnsupportedError, ChannelAValidationError, ControlRpc, DEFAULT_DESKTOP_GEOMETRY, DISPLAY_STACK_TIMEOUT_MS, DesktopGeometry, DisplayStackError, DisplayStackUnsupportedError, EnsureDisplayStackOptions, EnsureDisplayStackResult, EnsureTerminalServerOptions, EnsureTerminalServerResult, EstablishedSandboxSession, ExposeStreamPortInput, ExposeStreamPortResult, ExposedPortEndpoint, FinalizeRecordingResult, LiveModalSandboxLeaseAttribution, MintStreamTokenInput, MockAgentResponder, MockAgentResponderOptions, MockExecHandler, ModalOrphanSweepResult, ModalSandboxAttribution, NatsControlRpc, NatsRequestConnection, NegotiationContext, NumstatEntry, PROVIDER_REGISTRY, ProviderConstructionContext, ProviderRegistration, RecordingCodec, RecordingContentType, RecordingError, RecordingProcess, RecordingUnavailableError, ResolvedActiveBackend, RoutableBackendSession, RoutableSandbox, RoutingSandboxSession, RoutingSandboxSessionDeps, RoutingTransitionEvent, RoutingUnsupportedError, SELFHOSTED_DEFAULT_TIMEOUT_MS, SELFHOSTED_RECONNECT_WINDOW_MS, SELFHOSTED_RELAY_STREAM_PATH, STREAM_PORT, STREAM_TOKEN_DEFAULT_TTL_SECONDS, SandboxChannelAService, SandboxChannelAServiceOptions, SandboxConfigError, SandboxCreatedCallback, SandboxProviderUnavailableError, SelfhostedApplyDiff, SelfhostedControlError, SelfhostedEditor, SelfhostedEnrollment, SelfhostedExecArgs, SelfhostedExecResult, SelfhostedImageOutput, SelfhostedLivenessState, SelfhostedNegotiationInput, SelfhostedRelayConfig, SelfhostedSandboxClient, SelfhostedSession, SelfhostedSessionBuild, SelfhostedSessionDeps, SelfhostedSessionState, SelfhostedUnavailableReason, StartRecordingInput, StreamPortUnavailableError, TERMINAL_SERVER_TIMEOUT_MS, TerminalServerError, TerminalServerUnsupportedError, agentErrorToControlError, assertDescriptorRegistryInvariants, assertProviderRegistryInvariants, assertSafeRelPath, backendSupportsOs, buildDisplayStackScript, buildSelfhostedBackendSession, buildStreamUrl, buildTerminalServerScript, contentTypeForCodec, createSandboxClient, createSandboxClientForBackend, decodeModalSnapshotId, deletePriorPersistedSnapshot, deleteRecordingArtifacts, deserializeSandboxSessionStateEnvelope, desktopCapableBackend, ensureDisplayStack, ensureTerminalServer, establishSandboxSessionFromEnvelope, exposeStreamPort, extForCodec, isExecSessionLostBanner, isProviderSandboxNotFoundError, isSelfhostedProviderNotFoundError, isWorkspaceEscapeError, makeActiveBackendResolver, mintStreamToken, modalSandboxAttributionEnvironment, modalSandboxAttributionTags, negotiateCapabilities, negotiateSelfhostedCapabilities, offlineAgentError, offlineControlResponse, parseExecBannerSessionId, parseNumstatZ, parsePorcelainV2, parseUnifiedPatch, readRecordingBytes, readWorkspaceArchiveFromEnvelopeSessionState, recordingStorageKey, restoredSandboxSessionStateFromEntry, sandboxStateEntryFromRunState, selectBackend, selfhostedLiveness, serializeEstablishedSandboxEnvelope, setSelfhostedApplyDiff, startRecording, stopRecording, stripExecBanner, subjectFor, sweepModalOrphanSandboxes, tagModalSandbox, tearDownDisplayStack, tearDownTerminalServer, terminateModalSandboxById, timeoutAgentError, timeoutControlResponse, verifyStreamToken } from './sandbox/index.js';
11
+ import 'modal';
11
12
  import '@opengeni/agent-proto';
12
13
 
13
14
  type ComputerButton = "left" | "right" | "wheel" | "back" | "forward";
@@ -569,6 +570,7 @@ type BuildAgentOptions = {
569
570
  gitTokenSeed?: string;
570
571
  genesisTitleHint?: boolean;
571
572
  instructionsTemplate?: string;
573
+ sessionInstructions?: string;
572
574
  packSkills?: PackSkill[];
573
575
  };
574
576
  type PackSkillFile = {
@@ -615,6 +617,20 @@ declare function coreInstructions(workspaceEnvironment?: WorkspaceEnvironmentCon
615
617
  * with an empty environment reproduces the historical preamble byte-for-byte.
616
618
  */
617
619
  declare function composeAgentInstructions(template: string, workspaceEnvironment?: WorkspaceEnvironmentContext): string;
620
+ /**
621
+ * Appends the per-session persona instructions to the already-composed
622
+ * (workspace + CORE) instructions, joined by " " — exactly the join used
623
+ * throughout the persona composition. The session slice is intentionally LAST
624
+ * (session-specific refinement of the workspace persona). An absent/blank value
625
+ * is a no-op that returns the composed string byte-for-byte.
626
+ */
627
+ declare function appendSessionInstructions(composed: string, sessionInstructions?: string): string;
628
+ /**
629
+ * Appends the one-shot genesis title directive (genesis turn only), joined by
630
+ * " " and always LAST so a white-label persona template or a per-session
631
+ * instruction can't drop it. A no-op when the hint is absent.
632
+ */
633
+ declare function appendGenesisTitleDirective(instructions: string, genesisTitleHint?: boolean): string;
618
634
  declare function buildOpenGeniAgent(settings: Settings, resources: ResourceRef[], options?: BuildAgentOptions): Agent<any, any>;
619
635
  /**
620
636
  * Build the SandboxAgent capability set provider-aware.
@@ -845,4 +861,4 @@ declare function azureOpenAIDefaultQuery(settings: Pick<Settings, "azureOpenaiAp
845
861
  */
846
862
  declare function lazySkillSourceWithPackSkills(packSkills: PackSkill[]): LocalDirLazySkillSource;
847
863
 
848
- export { type AgentSegmentInput, type BuildAgentOptions, CLIENT_COMPACTION_TRIGGER_FRACTION, COMPACTION_PROMPT, COMPACTION_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, type ClientCompactionDecision, CodexSubscriptionUnavailableError, type CompactionItem, CompactionNeededError, ComputerActionError, ComputerReadOnlyError, type ComputerToolMode, ComputerUnavailableError, type ComputerUseArgs, ComputerUseCapability, type ContextRobustnessFilterOptions, type ElideStaleScreenshotsOptions, type ElideStaleScreenshotsResult, GENESIS_TITLE_DIRECTIVE, type HistoryItem, type ModelResponseUsage, MultiProviderModelProvider, type NormalizedRuntimeEvent, type OpenGeniRuntime, type PackSkill, type PackSkillFile, type PrepareInputOptions, type PrepareToolsOptions, type PreparedAgentInput, type PreparedAgentTools, type ProductionRuntimeOverrides, type RunAgentStreamOptions, SCREENSHOT_OMITTED_PLACEHOLDER, SUMMARY_BUFFER_TOKENS, SUMMARY_PREFIX, SandboxComputer, type SandboxComputerOptions, type SandboxFileDownload, type SandboxLifecycleHook, type SandboxLifecycleHookContext, type SandboxLifecycleHookPhase, USER_MESSAGE_TRUNCATION_MARKER, type WorkspaceEnvironmentContext, agentsErrorRunState, applyMissingManifestEntries, azureCliLoginCommand, azureOpenAIDefaultQuery, buildAgentCapabilities, buildCompactionPromptInput, buildCompactionReplacementHistory, buildManifest, buildModelInstance, buildOpenAIClientFromSettings, buildOpenGeniAgent, buildProviderClient, buildSummaryItem, callModelInputFilterForSettings, clientCompactionThresholdTokens, composeAgentInstructions, computerUse, configureOpenAI, contextRobustnessFilterForSettings, coreInstructions, createProductionAgentRuntime, decideClientCompaction, elideStaleScreenshotImages, enforceInputBudget, ensureReadableStreamFrom, estimateItemTokens, estimateTokens, extractResponseOutputText, findCompactionNeededError, findKeepBoundary, isCompactionSummary, isUserMessage, lazySkillSourceWithPackSkills, materializeSandboxFileDownloads, maxTurnsExceededRunState, modelResponseUsageFromSdkEvent, neutralizeToolSearchItemsInSerializedRunState, normalizeComputerCallsFilter, normalizeSdkEvent, normalizeToolOutputForEvent, prefixedMcpToolName, prepareAgentTools, prepareRunInput, renderCompactionPromptInputForChat, repositoryCloneCommand, repositoryUsesSandboxClone, resolveTurnModel, runAgentStream, runAzureCliLoginHook, runBeforeAgentStartHooks, runRepositoryCloneHook, sandboxCommandExitCode, sandboxCommandOutput, sandboxCommandStillRunning, sandboxFileDownloadsForAgent, sandboxLifecycleHooksForIds, sandboxRunAs, sanitizeHistoryItemsForModel, serializeApprovals, stripProviderItemIdsFilter, stripReasoningEncryptedContent, stripReasoningIdentityFromSerializedRunState, summarizeForCompaction, withManifestRefreshOnResume, withSandboxFileDownloads, withSandboxLifecycleHooks, workspaceEnvironmentInstructions };
864
+ export { type AgentSegmentInput, type BuildAgentOptions, CLIENT_COMPACTION_TRIGGER_FRACTION, COMPACTION_PROMPT, COMPACTION_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, type ClientCompactionDecision, CodexSubscriptionUnavailableError, type CompactionItem, CompactionNeededError, ComputerActionError, ComputerReadOnlyError, type ComputerToolMode, ComputerUnavailableError, type ComputerUseArgs, ComputerUseCapability, type ContextRobustnessFilterOptions, type ElideStaleScreenshotsOptions, type ElideStaleScreenshotsResult, GENESIS_TITLE_DIRECTIVE, type HistoryItem, type ModelResponseUsage, MultiProviderModelProvider, type NormalizedRuntimeEvent, type OpenGeniRuntime, type PackSkill, type PackSkillFile, type PrepareInputOptions, type PrepareToolsOptions, type PreparedAgentInput, type PreparedAgentTools, type ProductionRuntimeOverrides, type RunAgentStreamOptions, SCREENSHOT_OMITTED_PLACEHOLDER, SUMMARY_BUFFER_TOKENS, SUMMARY_PREFIX, SandboxComputer, type SandboxComputerOptions, type SandboxFileDownload, type SandboxLifecycleHook, type SandboxLifecycleHookContext, type SandboxLifecycleHookPhase, USER_MESSAGE_TRUNCATION_MARKER, type WorkspaceEnvironmentContext, agentsErrorRunState, appendGenesisTitleDirective, appendSessionInstructions, applyMissingManifestEntries, azureCliLoginCommand, azureOpenAIDefaultQuery, buildAgentCapabilities, buildCompactionPromptInput, buildCompactionReplacementHistory, buildManifest, buildModelInstance, buildOpenAIClientFromSettings, buildOpenGeniAgent, buildProviderClient, buildSummaryItem, callModelInputFilterForSettings, clientCompactionThresholdTokens, composeAgentInstructions, computerUse, configureOpenAI, contextRobustnessFilterForSettings, coreInstructions, createProductionAgentRuntime, decideClientCompaction, elideStaleScreenshotImages, enforceInputBudget, ensureReadableStreamFrom, estimateItemTokens, estimateTokens, extractResponseOutputText, findCompactionNeededError, findKeepBoundary, isCompactionSummary, isUserMessage, lazySkillSourceWithPackSkills, materializeSandboxFileDownloads, maxTurnsExceededRunState, modelResponseUsageFromSdkEvent, neutralizeToolSearchItemsInSerializedRunState, normalizeComputerCallsFilter, normalizeSdkEvent, normalizeToolOutputForEvent, prefixedMcpToolName, prepareAgentTools, prepareRunInput, renderCompactionPromptInputForChat, repositoryCloneCommand, repositoryUsesSandboxClone, resolveTurnModel, runAgentStream, runAzureCliLoginHook, runBeforeAgentStartHooks, runRepositoryCloneHook, sandboxCommandExitCode, sandboxCommandOutput, sandboxCommandStillRunning, sandboxFileDownloadsForAgent, sandboxLifecycleHooksForIds, sandboxRunAs, sanitizeHistoryItemsForModel, serializeApprovals, stripProviderItemIdsFilter, stripReasoningEncryptedContent, stripReasoningIdentityFromSerializedRunState, summarizeForCompaction, withManifestRefreshOnResume, withSandboxFileDownloads, withSandboxLifecycleHooks, workspaceEnvironmentInstructions };
package/dist/index.js CHANGED
@@ -63,6 +63,8 @@ import {
63
63
  isWorkspaceEscapeError,
64
64
  makeActiveBackendResolver,
65
65
  mintStreamToken,
66
+ modalSandboxAttributionEnvironment,
67
+ modalSandboxAttributionTags,
66
68
  negotiateCapabilities,
67
69
  negotiateSelfhostedCapabilities,
68
70
  offlineAgentError,
@@ -85,12 +87,15 @@ import {
85
87
  stopRecording,
86
88
  stripExecBanner,
87
89
  subjectFor,
90
+ sweepModalOrphanSandboxes,
91
+ tagModalSandbox,
88
92
  tearDownDisplayStack,
89
93
  tearDownTerminalServer,
94
+ terminateModalSandboxById,
90
95
  timeoutAgentError,
91
96
  timeoutControlResponse,
92
97
  verifyStreamToken
93
- } from "./chunk-KNW7AMQB.js";
98
+ } from "./chunk-D5KU3QUC.js";
94
99
 
95
100
  // src/index.ts
96
101
  import { AGENT_INSTRUCTIONS_CORE_PLACEHOLDER, collectSandboxEnvironment as collectSandboxEnvironment2, contextInputBudgetTokens, contextServerCompactThreshold, firstPartyMcpBaseUrl, resolveContextCompactionMode, resolveModelProvider, sandboxLifecycleHookIds } from "@opengeni/config";
@@ -1328,6 +1333,15 @@ var NativeDesktopComputer = class {
1328
1333
  dimensions;
1329
1334
  session;
1330
1335
  readOnly;
1336
+ // The ENCODED vs NATIVE geometry of the MOST RECENT screenshot the model saw. The
1337
+ // model computes click coordinates in the encoded-pixel space of that screenshot;
1338
+ // when the agent downscaled the PNG to fit the transport budget, encoded < native,
1339
+ // so we scale coordinates back up to native pixels before injecting (the agent's
1340
+ // native inject — macOS CGEvent / Linux XTEST — expects native-pixel coordinates,
1341
+ // exactly as it received them pre-downscale). Null until the first screenshot;
1342
+ // equal encoded==native (or absent) ⇒ scale factor 1.0 ⇒ byte-identical behavior.
1343
+ lastEncoded = null;
1344
+ lastNative = null;
1331
1345
  constructor(session, opts = {}) {
1332
1346
  this.session = session;
1333
1347
  this.dimensions = opts.dimensions ?? DEFAULT_DIMENSIONS;
@@ -1341,14 +1355,33 @@ var NativeDesktopComputer = class {
1341
1355
  guardWrite() {
1342
1356
  if (this.readOnly) throw new ComputerReadOnlyError();
1343
1357
  }
1358
+ /** Scale a coordinate the model expressed in the MOST RECENT screenshot's
1359
+ * ENCODED pixel space back to NATIVE pixels. When the last frame was not
1360
+ * downscaled (encoded == native), or no screenshot has been taken yet, this is a
1361
+ * 1:1 identity — the byte-identical current behavior. The agent then applies its
1362
+ * own platform mapping (macOS divides native pixels by the backing scale to reach
1363
+ * CGEvent points; Linux XTEST is 1:1) exactly as it did pre-downscale. */
1364
+ toNative(x, y) {
1365
+ const enc = this.lastEncoded;
1366
+ const nat = this.lastNative;
1367
+ if (!enc || !nat || enc[0] <= 0 || enc[1] <= 0) return { x, y };
1368
+ if (enc[0] === nat[0] && enc[1] === nat[1]) return { x, y };
1369
+ return {
1370
+ x: Math.round(x * nat[0] / enc[0]),
1371
+ y: Math.round(y * nat[1] / enc[1])
1372
+ };
1373
+ }
1344
1374
  async pointer(x, y, action, button) {
1345
- await this.session.desktopInput({ $case: "pointer", pointer: { x, y, action, button } });
1375
+ const n = this.toNative(x, y);
1376
+ await this.session.desktopInput({ $case: "pointer", pointer: { x: n.x, y: n.y, action, button } });
1346
1377
  }
1347
1378
  async screenshot() {
1348
- const { png } = await this.session.screenshot();
1379
+ const { png, width, height, nativeWidth, nativeHeight } = await this.session.screenshot();
1349
1380
  if (png.length === 0) {
1350
1381
  throw new ComputerUnavailableError("native desktop screenshot returned an empty frame (display not up?)");
1351
1382
  }
1383
+ this.lastEncoded = [width, height];
1384
+ this.lastNative = [nativeWidth || width, nativeHeight || height];
1352
1385
  return Buffer.from(png).toString("base64");
1353
1386
  }
1354
1387
  async click(x, y, button) {
@@ -1365,7 +1398,8 @@ var NativeDesktopComputer = class {
1365
1398
  }
1366
1399
  async scroll(x, y, sx, sy) {
1367
1400
  this.guardWrite();
1368
- await this.session.desktopInput({ $case: "scroll", scroll: { x, y, deltaX: sx, deltaY: sy } });
1401
+ const n = this.toNative(x, y);
1402
+ await this.session.desktopInput({ $case: "scroll", scroll: { x: n.x, y: n.y, deltaX: sx, deltaY: sy } });
1369
1403
  }
1370
1404
  async type(text) {
1371
1405
  this.guardWrite();
@@ -1724,7 +1758,7 @@ var MultiProviderModelProvider = class {
1724
1758
  fallback;
1725
1759
  async getModel(modelName) {
1726
1760
  if (modelName) {
1727
- const resolved = resolveTurnModel(this.settings, modelName);
1761
+ const resolved = resolveTurnModel(settingsForRunScopedModelResolution(this.settings, modelName), modelName);
1728
1762
  if (resolved) {
1729
1763
  if (modelName.startsWith(CODEX_MODEL_ID_PREFIX) && resolved.provider.kind !== "codex-subscription") {
1730
1764
  throw new CodexSubscriptionUnavailableError(modelName);
@@ -1739,6 +1773,20 @@ var MultiProviderModelProvider = class {
1739
1773
  return this.fallback.getModel(modelName);
1740
1774
  }
1741
1775
  };
1776
+ function settingsForRunScopedModelResolution(settings, modelName) {
1777
+ if (modelName !== settings.openaiModel) {
1778
+ return settings;
1779
+ }
1780
+ const builtinAllowed = splitOpenaiAllowedModels(settings.openaiAllowedModels);
1781
+ const fallbackBuiltin = builtinAllowed.find((id) => id !== modelName);
1782
+ if (!fallbackBuiltin) {
1783
+ return settings;
1784
+ }
1785
+ return builtinAllowed.includes(modelName) ? settings : { ...settings, openaiModel: fallbackBuiltin };
1786
+ }
1787
+ function splitOpenaiAllowedModels(value) {
1788
+ return value.split(",").map((item) => item.trim()).filter(Boolean);
1789
+ }
1742
1790
  var CodexSubscriptionUnavailableError = class extends Error {
1743
1791
  constructor(modelName) {
1744
1792
  super(
@@ -1858,6 +1906,13 @@ function composeAgentInstructions(template, workspaceEnvironment) {
1858
1906
  }
1859
1907
  return core ? `${template} ${core}` : template;
1860
1908
  }
1909
+ function appendSessionInstructions(composed, sessionInstructions) {
1910
+ const trimmed = sessionInstructions?.trim();
1911
+ return trimmed ? `${composed} ${trimmed}` : composed;
1912
+ }
1913
+ function appendGenesisTitleDirective(instructions, genesisTitleHint) {
1914
+ return genesisTitleHint ? `${instructions} ${GENESIS_TITLE_DIRECTIVE}` : instructions;
1915
+ }
1861
1916
  var agentFileDownloads = /* @__PURE__ */ new WeakMap();
1862
1917
  var agentRepositoryCloneHooks = /* @__PURE__ */ new WeakMap();
1863
1918
  var agentGitTokenSeed = /* @__PURE__ */ new WeakMap();
@@ -1879,7 +1934,21 @@ function buildOpenGeniAgent(settings, resources, options = {}) {
1879
1934
  // ownership + workspace-environment block) at the {{core}} marker, or
1880
1935
  // appends it when the template omits the marker. With the default template
1881
1936
  // and no environment this is byte-identical to the historical preamble.
1882
- instructions: options.genesisTitleHint ? `${composeAgentInstructions(options.instructionsTemplate ?? settings.agentInstructionsTemplate, options.workspaceEnvironment)} ${GENESIS_TITLE_DIRECTIVE}` : composeAgentInstructions(options.instructionsTemplate ?? settings.agentInstructionsTemplate, options.workspaceEnvironment),
1937
+ // Persona composition order (all one system-level instructions string):
1938
+ // 1. workspace instructionsTemplate (or deployment default) with the
1939
+ // non-bypassable CORE substituted at {{core}} — composeAgentInstructions,
1940
+ // 2. + the per-session persona instructions (session-specific, LAST so it
1941
+ // refines the workspace persona),
1942
+ // 3. + the one-shot genesis title directive (genesis turn only).
1943
+ // With no session instructions and no genesis hint this is byte-identical to
1944
+ // the historical composed instructions.
1945
+ instructions: appendGenesisTitleDirective(
1946
+ appendSessionInstructions(
1947
+ composeAgentInstructions(options.instructionsTemplate ?? settings.agentInstructionsTemplate, options.workspaceEnvironment),
1948
+ options.sessionInstructions
1949
+ ),
1950
+ options.genesisTitleHint
1951
+ ),
1883
1952
  modelSettings: {
1884
1953
  reasoning: { effort: options.reasoningEffort ?? settings.openaiReasoningEffort, summary: "detailed" },
1885
1954
  // Server-side compaction (OpenAI platform) requires store=false: the
@@ -3738,6 +3807,8 @@ export {
3738
3807
  USER_MESSAGE_TRUNCATION_MARKER,
3739
3808
  agentErrorToControlError,
3740
3809
  agentsErrorRunState,
3810
+ appendGenesisTitleDirective,
3811
+ appendSessionInstructions,
3741
3812
  applyMissingManifestEntries,
3742
3813
  assertDescriptorRegistryInvariants,
3743
3814
  assertProviderRegistryInvariants,
@@ -3800,6 +3871,8 @@ export {
3800
3871
  materializeSandboxFileDownloads,
3801
3872
  maxTurnsExceededRunState,
3802
3873
  mintStreamToken,
3874
+ modalSandboxAttributionEnvironment,
3875
+ modalSandboxAttributionTags,
3803
3876
  modelResponseUsageFromSdkEvent,
3804
3877
  negotiateCapabilities,
3805
3878
  negotiateSelfhostedCapabilities,
@@ -3850,8 +3923,11 @@ export {
3850
3923
  stripReasoningIdentityFromSerializedRunState,
3851
3924
  subjectFor,
3852
3925
  summarizeForCompaction,
3926
+ sweepModalOrphanSandboxes,
3927
+ tagModalSandbox,
3853
3928
  tearDownDisplayStack,
3854
3929
  tearDownTerminalServer,
3930
+ terminateModalSandboxById,
3855
3931
  timeoutAgentError,
3856
3932
  timeoutControlResponse,
3857
3933
  verifyStreamToken,