@opengeni/runtime 0.6.1 → 0.7.1

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 (45) hide show
  1. package/dist/{chunk-DYBF7ZEB.js → chunk-RYDCVTMW.js} +1958 -207
  2. package/dist/chunk-RYDCVTMW.js.map +1 -0
  3. package/dist/{index-BTo_bZvN.d.ts → index-DIiiwQY2.d.ts} +689 -52
  4. package/dist/index.d.ts +296 -123
  5. package/dist/index.js +1907 -809
  6. package/dist/index.js.map +1 -1
  7. package/dist/sandbox/index.d.ts +1 -1
  8. package/dist/sandbox/index.js +79 -3
  9. package/package.json +21 -20
  10. package/src/codex-tool-search.ts +185 -31
  11. package/src/context-compaction.ts +78 -243
  12. package/src/history-sanitizer.ts +172 -20
  13. package/src/index.ts +2687 -920
  14. package/src/metrics.ts +28 -2
  15. package/src/sandbox/capabilities.ts +12 -3
  16. package/src/sandbox/channel-a.ts +420 -72
  17. package/src/sandbox/display-stack.ts +18 -4
  18. package/src/sandbox/errors.ts +13 -0
  19. package/src/sandbox/index.ts +398 -112
  20. package/src/sandbox/op-correlation.ts +70 -0
  21. package/src/sandbox/providers/index.ts +9 -3
  22. package/src/sandbox/providers/modal.ts +84 -14
  23. package/src/sandbox/providers/selfhosted.ts +1 -4
  24. package/src/sandbox/recording.ts +146 -90
  25. package/src/sandbox/routing/backend-resolver.ts +144 -10
  26. package/src/sandbox/routing/routing-session.ts +129 -25
  27. package/src/sandbox/select.ts +60 -8
  28. package/src/sandbox/selfhosted/capabilities.ts +59 -25
  29. package/src/sandbox/selfhosted/control-rpc.ts +160 -28
  30. package/src/sandbox/selfhosted/fault-rendering.ts +226 -0
  31. package/src/sandbox/selfhosted/op-observer.ts +54 -0
  32. package/src/sandbox/selfhosted/op-stream.ts +801 -0
  33. package/src/sandbox/selfhosted/op-testing.ts +468 -0
  34. package/src/sandbox/selfhosted/op-transport.ts +151 -0
  35. package/src/sandbox/selfhosted/retry-policy.ts +177 -0
  36. package/src/sandbox/selfhosted/session.ts +498 -55
  37. package/src/sandbox/selfhosted/testing.ts +60 -19
  38. package/src/sandbox/stream-port.ts +17 -5
  39. package/src/sandbox/stream-token.ts +8 -2
  40. package/src/sandbox/terminal-server.ts +18 -4
  41. package/src/sandbox-computer.ts +332 -70
  42. package/src/usage-telemetry.ts +73 -0
  43. package/dist/chunk-DYBF7ZEB.js.map +0 -1
  44. package/src/image-history.ts +0 -149
  45. package/src/screenshot-omitted-card.ts +0 -15
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import * as _openai_agents from '@openai/agents';
2
2
  import { Tool, Computer, AgentInputItem, Model, MCPServer, ModelProvider, Agent, RunState, CallModelInputFilter, RunStreamEvent } from '@openai/agents';
3
3
  export { MaxTurnsExceededError, OpenAIChatCompletionsModel, OpenAIResponsesModel } from '@openai/agents';
4
- import { ContextCompactionMode, Settings, ResolvedModelProvider, ConfiguredModel, ModelProviderApi } from '@opengeni/config';
4
+ import { Settings, ResolvedModelProvider, ConfiguredModel, ModelProviderApi } from '@opengeni/config';
5
5
  export { collectSandboxEnvironment, parseExposedPorts } from '@opengeni/config';
6
- import { ReasoningEffort, SessionEventType, ResourceRef, ToolRef, Permission, McpServerConnectionRef, ToolAuthNeededPayload } from '@opengeni/contracts';
6
+ import { ReasoningEffort, GitCredentialProvider, SessionEventType, ResourceRef, ToolRef, Permission, McpServerConnectionRef, ToolAuthNeededPayload } from '@opengeni/contracts';
7
7
  export { CAPABILITY_DESCRIPTORS, CapabilityDescriptor, DESKTOP_STREAM_PORT, StreamTokenPayload, StreamTokenPayload as StreamTokenPayloadType, TERMINAL_STREAM_PORT } from '@opengeni/contracts';
8
- import { Capability, SandboxSessionLike, SandboxSessionState, Manifest, Capabilities, LocalDirLazySkillSource, SandboxClient } from '@openai/agents/sandbox';
8
+ import { SandboxSessionLike, Capability, SandboxSessionState, Manifest, Capabilities, LocalDirLazySkillSource, SandboxClient } from '@openai/agents/sandbox';
9
9
  import OpenAI from 'openai';
10
- import { R as RuntimeMetricsHooks } from './index-BTo_bZvN.js';
11
- export { A as ActiveBackendResolverDeps, a as ActiveBackendUnresolvableError, b as ActivePointer, C as ChannelAConflictError, c as ChannelAEmitter, d as ChannelAExecArgs, e as ChannelAExecResult, f as ChannelANotFoundError, g as ChannelASession, h as ChannelAUnsupportedError, i as ChannelAValidationError, j as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, k as DISPLAY_STACK_TIMEOUT_MS, l as DesktopGeometry, m as DisplayStackError, n as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, o as EnsureDisplayStackResult, p as EnsureTerminalServerOptions, q as EnsureTerminalServerResult, r as EstablishedSandboxSession, s as ExposeStreamPortInput, t as ExposeStreamPortResult, u as ExposedPortEndpoint, F as FinalizeRecordingResult, L as LiveModalSandboxLeaseAttribution, M as MintStreamTokenInput, v as MockAgentResponder, w as MockAgentResponderOptions, x as MockExecHandler, y as ModalModuleLoader, z as ModalOrphanSweepResult, B as ModalSandboxAttribution, N as NatsControlRpc, G as NatsRequestConnection, H as NegotiationContext, I as NumstatEntry, P as PROVIDER_REGISTRY, J as ProviderConstructionContext, K as ProviderRegistration, O as RecordingCodec, Q as RecordingContentType, S as RecordingError, T as RecordingProcess, U as RecordingUnavailableError, V as ResolvedActiveBackend, W as RoutableBackendSession, X as RoutableSandbox, Y as RoutingSandboxSession, Z as RoutingSandboxSessionDeps, _ as RoutingTransitionEvent, $ as RoutingUnsupportedError, a0 as SELFHOSTED_DEFAULT_TIMEOUT_MS, a1 as SELFHOSTED_RECONNECT_WINDOW_MS, a2 as SELFHOSTED_RELAY_STREAM_PATH, a3 as STREAM_PORT, a4 as STREAM_TOKEN_DEFAULT_TTL_SECONDS, a5 as SandboxChannelAService, a6 as SandboxChannelAServiceOptions, a7 as SandboxConfigError, a8 as SandboxCreatedCallback, a9 as SandboxProviderUnavailableError, aa as SelfhostedApplyDiff, ab as SelfhostedControlError, ac as SelfhostedEditor, ad as SelfhostedEnrollment, ae as SelfhostedExecArgs, af as SelfhostedExecResult, ag as SelfhostedImageOutput, ah as SelfhostedLivenessState, ai as SelfhostedNegotiationInput, aj as SelfhostedRelayConfig, ak as SelfhostedSandboxClient, al as SelfhostedSession, am as SelfhostedSessionBuild, an as SelfhostedSessionDeps, ao as SelfhostedSessionState, ap as SelfhostedUnavailableReason, aq as StartRecordingInput, ar as StreamPortUnavailableError, as as TERMINAL_SERVER_TIMEOUT_MS, at as TerminalServerError, au as TerminalServerUnsupportedError, av as agentErrorToControlError, aw as assertDescriptorRegistryInvariants, ax as assertProviderRegistryInvariants, ay as assertSafeRelPath, az as backendSupportsOs, aA as buildDisplayStackScript, aB as buildSelfhostedBackendSession, aC as buildStreamUrl, aD as buildTerminalServerScript, aE as contentTypeForCodec, aF as createSandboxClient, aG as createSandboxClientForBackend, aH as decodeModalSnapshotId, aI as deletePriorPersistedSnapshot, aJ as deleteRecordingArtifacts, aK as deserializeSandboxSessionStateEnvelope, aL as desktopCapableBackend, aM as ensureDisplayStack, aN as ensureModalRegistryImage, aO as ensureTerminalServer, aP as establishSandboxSessionFromEnvelope, aQ as exposeStreamPort, aR as extForCodec, aS as isExecSessionLostBanner, aT as isProviderSandboxNotFoundError, aU as isSelfhostedProviderNotFoundError, aV as isWorkspaceEscapeError, aW as makeActiveBackendResolver, aX as mintStreamToken, aY as modalSandboxAttributionEnvironment, aZ as modalSandboxAttributionTags, a_ as negotiateCapabilities, a$ as negotiateSelfhostedCapabilities, b0 as offlineAgentError, b1 as offlineControlResponse, b2 as parseExecBannerSessionId, b3 as parseNumstatZ, b4 as parsePorcelainV2, b5 as parseUnifiedPatch, b6 as readRecordingBytes, b7 as readWorkspaceArchiveFromEnvelopeSessionState, b8 as recordingStorageKey, b9 as restoredSandboxSessionStateFromEntry, ba as sandboxStateEntryFromRunState, bb as selectBackend, bc as selfhostedLiveness, bd as serializeEstablishedSandboxEnvelope, be as setSelfhostedApplyDiff, bf as startRecording, bg as stopRecording, bh as stripExecBanner, bi as subjectFor, bj as sweepModalOrphanSandboxes, bk as tagModalSandbox, bl as tearDownDisplayStack, bm as tearDownTerminalServer, bn as terminateModalSandboxById, bo as timeoutAgentError, bp as timeoutControlResponse, bq as verifyStreamToken } from './index-BTo_bZvN.js';
10
+ import { R as RuntimeMetricsHooks } from './index-DIiiwQY2.js';
11
+ export { A as ActiveBackendResolverDeps, a as ActiveBackendUnresolvableError, b as ActivePointer, B as BackendUnresolvableCode, C as ChannelAConflictError, c as ChannelAEmitter, d as ChannelAExecArgs, e as ChannelAExecResult, f as ChannelANotFoundError, g as ChannelASession, h as ChannelAUnsupportedError, i as ChannelAValidationError, j as ControlRpc, D as DEFAULT_DESKTOP_GEOMETRY, k as DISPLAY_STACK_TIMEOUT_MS, l as DesktopGeometry, m as DisplayStackError, n as DisplayStackUnsupportedError, E as EnsureDisplayStackOptions, o as EnsureDisplayStackResult, p as EnsureTerminalServerOptions, q as EnsureTerminalServerResult, r as EstablishedSandboxSession, s as ExposeStreamPortInput, t as ExposeStreamPortResult, u as ExposedPortEndpoint, F as FAULT_FIELD_WHAT_HAPPENED, v as FAULT_FIELD_WHAT_PRESERVED, w as FAULT_FIELD_WHAT_TO_TRY, x as FAULT_FIELD_WHICH_LAYER, L as LiveModalSandboxLeaseAttribution, M as MintStreamTokenInput, y as MockAgentResponder, z as MockAgentResponderOptions, G as MockExecHandler, H as ModalModuleLoader, I as ModalOrphanSweepResult, J as ModalSandboxAttribution, N as NEVER_SENT_DETAIL_KEY, K as NatsControlRpc, O as NatsOpStreamConnection, P as NatsOpStreamTransport, Q as NatsRequestConnection, S as NegotiationContext, T as NumstatEntry, U as OP_STREAM_ACK_INTERVAL_MS, V as OP_STREAM_DEFAULT_WINDOW_BYTES, W as OP_STREAM_RECONNECT_HOLD_MS, X as OP_STREAM_SILENCE_TIMEOUT_MS, Y as OpStreamExecOutcome, Z as OpStreamJournal, _ as OpStreamSubscription, $ as OpStreamTransport, a0 as OpStreamUnavailableError, a1 as PROVIDER_REGISTRY, a2 as ProviderConstructionContext, a3 as ProviderRegistration, a4 as REPOSITORY_DISCOVERY_LIMIT, a5 as RecordingArtifactMetadata, a6 as RecordingCodec, a7 as RecordingContentType, a8 as RecordingError, a9 as RecordingProcess, aa as RecordingUnavailableError, ab as RepositoryDiscoveryDegradedReason, ac as RepositoryDiscoveryResult, ad as ResolvedActiveBackend, ae as RoutableBackendSession, af as RoutableSandbox, ag as RoutingSandboxSession, ah as RoutingSandboxSessionDeps, ai as RoutingTransitionEvent, aj as RoutingUnsupportedError, ak as SELFHOSTED_DEFAULT_TIMEOUT_MS, al as SELFHOSTED_DRAINING_MAX_RETRIES, am as SELFHOSTED_EXEC_DRAINING_MAX_RETRIES, an as SELFHOSTED_IDEMPOTENT_READONLY_OPS, ao as SELFHOSTED_INFRASTRUCTURE_FAULT_CLASSES, ap as SELFHOSTED_NEVER_SENT_MAX_RETRIES, aq as SELFHOSTED_RECONNECT_WINDOW_MS, ar as SELFHOSTED_RELAY_STREAM_PATH, as as SELFHOSTED_RETRY_BACKOFF_BASE_MS, at as SELFHOSTED_RETRY_BACKOFF_CAP_MS, au as SELFHOSTED_RETRY_BACKOFF_FACTOR, av as SELFHOSTED_TIMEOUT_MAX_RETRIES, aw as STREAM_PORT, ax as STREAM_TOKEN_DEFAULT_TTL_SECONDS, ay as SandboxChannelAService, az as SandboxChannelAServiceOptions, aA as SandboxConfigError, aB as SandboxCreatedCallback, aC as SandboxProviderUnavailableError, aD as SandboxResumeStateUnavailableError, aE as SelfhostedApplyDiff, aF as SelfhostedControlError, aG as SelfhostedEditor, aH as SelfhostedEnrollment, aI as SelfhostedExecArgs, aJ as SelfhostedExecResult, aK as SelfhostedImageOutput, aL as SelfhostedLivenessState, aM as SelfhostedNegotiationInput, aN as SelfhostedOpObservation, aO as SelfhostedOpObserver, aP as SelfhostedOpStreamDeps, aQ as SelfhostedRelayConfig, aR as SelfhostedRetryClock, aS as SelfhostedRetryDecision, aT as SelfhostedSandboxClient, aU as SelfhostedSession, aV as SelfhostedSessionBuild, aW as SelfhostedSessionDeps, aX as SelfhostedSessionState, aY as SelfhostedUnavailableReason, aZ as StartRecordingInput, a_ as StreamPortUnavailableError, a$ as SwapTargetEstablishability, b0 as TERMINAL_SERVER_TIMEOUT_MS, b1 as TerminalServerError, b2 as TerminalServerUnsupportedError, b3 as agentErrorToControlError, b4 as assertDescriptorRegistryInvariants, b5 as assertProviderRegistryInvariants, b6 as assertSafeRelPath, b7 as backendSupportsOs, b8 as buildDisplayStackScript, b9 as buildSelfhostedBackendSession, ba as buildStreamUrl, bb as buildTerminalServerScript, bc as contentTypeForCodec, bd as createSandboxClient, be as createSandboxClientForBackend, bf as decideSelfhostedRetry, bg as decodeModalSnapshotId, bh as defaultSelfhostedRetryClock, bi as deletePriorPersistedSnapshot, bj as deleteRecordingArtifacts, bk as deserializeSandboxSessionStateEnvelope, bl as desktopCapableBackend, bm as drainingExhaustedError, bn as drainingMessage, bo as ensureDisplayStack, bp as ensureModalRegistryImage, bq as ensureTerminalServer, br as establishSandboxSessionFromEnvelope, bs as execDeadlineHint, bt as exposeStreamPort, bu as extForCodec, bv as inspectRecordingArtifact, bw as isExecSessionLostBanner, bx as isProviderSandboxNotFoundError, by as isSelfhostedProviderNotFoundError, bz as isWorkspaceEscapeError, bA as makeActiveBackendResolver, bB as mintStreamToken, bC as modalSandboxAttributionEnvironment, bD as modalSandboxAttributionTags, bE as negotiateCapabilities, bF as negotiateSelfhostedCapabilities, bG as nextDurableOpId, bH as offlineAgentError, bI as offlineControlResponse, bJ as opAckSubject, bK as opFrameSubject, bL as parseExecBannerSessionId, bM as parseNumstatZ, bN as parsePorcelainV2, bO as parseUnifiedPatch, bP as payloadTooLargeMessage, bQ as readWorkspaceArchiveFromEnvelopeSessionState, bR as recordingStorageKey, bS as renderSelfhostedFault, bT as restoredSandboxSessionStateFromEntry, bU as runWithToolCallCorrelation, bV as sandboxStateEntryFromRunState, bW as sanitizeOpIdToken, bX as selectBackend, bY as selfhostedFaultClass, bZ as selfhostedLiveness, b_ as selfhostedRetryBackoffMs, b$ as serializeEstablishedSandboxEnvelope, c0 as setSelfhostedApplyDiff, c1 as startRecording, c2 as stopRecording, c3 as stripExecBanner, c4 as subjectFor, c5 as swapTargetEstablishability, c6 as sweepModalOrphanSandboxes, c7 as tagModalSandbox, c8 as tearDownDisplayStack, c9 as tearDownTerminalServer, ca as terminateModalSandboxById, cb as timeoutAgentError, cc as timeoutControlResponse, cd as uploadRecordingArtifact, ce as verifyStreamToken } from './index-DIiiwQY2.js';
12
12
  import 'modal';
13
13
  import '@opengeni/agent-proto';
14
14
 
@@ -22,6 +22,14 @@ type SandboxComputerOptions = {
22
22
  screenshotTmpDir?: string;
23
23
  screenshotWarmupBudgetMs?: number;
24
24
  screenshotRetryDelayMs?: number;
25
+ /**
26
+ * One turn-scoped preparation hook, invoked by the first real computer action.
27
+ * The agent may advertise computer-use on every turn, but merely advertising the
28
+ * tool must not boot Xvfb/XFCE or start a recording. The runtime capability owns
29
+ * this hook and uses it to bring up :0 (and optionally notify the worker) only
30
+ * after the model actually chooses a computer tool.
31
+ */
32
+ prepare?: (session: SandboxSessionLike) => Promise<void>;
25
33
  };
26
34
  /** No exec/execCommand on the session, or the display is not up. */
27
35
  declare class ComputerUnavailableError extends Error {
@@ -59,9 +67,13 @@ declare class SandboxComputer implements Computer {
59
67
  private readonly tmp;
60
68
  private readonly screenshotWarmupBudgetMs;
61
69
  private readonly screenshotRetryDelayMs;
70
+ private readonly prepare;
71
+ private prepared;
72
+ private preparation;
62
73
  constructor(session: SandboxSessionLike, opts?: SandboxComputerOptions);
63
74
  /** Rebind to a freshly resumed-by-id session after a box rollover / re-establish. */
64
75
  rebind(session: SandboxSessionLike): void;
76
+ private prepareOnce;
65
77
  private x;
66
78
  private guardWrite;
67
79
  private shq;
@@ -102,6 +114,8 @@ type ComputerUseArgs = {
102
114
  needsApproval?: boolean | ((ctx: unknown, action: unknown) => boolean | Promise<boolean>);
103
115
  imageFunctionResults?: boolean;
104
116
  toolMode?: ComputerToolMode;
117
+ /** Called after the display is ready on the first actual computer action. */
118
+ onReady?: (session: SandboxSessionLike) => Promise<void>;
105
119
  };
106
120
  declare function computerUse(args?: ComputerUseArgs): ComputerUseCapability;
107
121
  /**
@@ -162,6 +176,19 @@ declare class ComputerUseCapability extends Capability {
162
176
  */
163
177
  /** A history item is any JSON object; we only inspect a few discriminator fields. */
164
178
  type HistoryItem = Record<string, unknown>;
179
+ /**
180
+ * Remove superseded `view_image` call/result pairs for the SAME local path,
181
+ * retaining the newest fully-paired observation. A `view_image` result can be
182
+ * hundreds of kilobytes of base64. When a model re-opens the same attachment,
183
+ * replaying every older copy on each subsequent model call grows input
184
+ * quadratically and can trap a turn in context-compaction/requeue recovery.
185
+ *
186
+ * This is state-based rather than count-based: every distinct path is kept,
187
+ * and an older observation is removed only after a newer successful pair for
188
+ * that exact path exists. The reasoning items immediately attached to a
189
+ * removed call are removed with it, preserving Responses API item validity.
190
+ */
191
+ declare function elideSupersededViewImagePairs<T extends HistoryItem>(items: readonly T[]): T[];
165
192
  /**
166
193
  * Sanitize a replayed history item list into a sequence the Responses API
167
194
  * accepts. Pure: returns a new array of the same item references in order,
@@ -234,9 +261,8 @@ declare function stripReasoningEncryptedContent<T extends HistoryItem>(item: T):
234
261
  * a parse failure or a no-op returns the SAME string reference (so an unchanged
235
262
  * or non-codex run-state replays byte-for-byte).
236
263
  *
237
- * WHY (HOLE C — the run-state REPLAY paths). The approval-decision resume and the
238
- * items-mode run-state fallback replay the serialized RunState blob verbatim. That
239
- * blob round-trips `reasoning.encrypted_content` minted by the ChatGPT/Codex
264
+ * WHY (HOLE C — approval replay). An approval decision resumes the serialized
265
+ * RunState blob. That blob round-trips `reasoning.encrypted_content` minted by the ChatGPT/Codex
240
266
  * backend (bound to the freezing account/org — a foreign account 400s it) AND the
241
267
  * foreign `rs_…` reasoning ids the Responses backend validates (rejected once the
242
268
  * blob is gone). Unlike `session_history_items`, the blob carries NO per-item
@@ -287,11 +313,11 @@ declare function stripReasoningIdentityFromSerializedRunState(serialized: string
287
313
  declare function neutralizeToolSearchItemsInSerializedRunState(serialized: string): string;
288
314
 
289
315
  /**
290
- * Client-side conversation context compaction (the Azure/client path).
316
+ * Portable conversation context compaction, following Codex CLI's local path.
291
317
  *
292
- * This mirrors Codex CLI's compaction model: the checkpoint model sees the
293
- * current active history plus one fixed checkpoint prompt, then the active
294
- * history is rebuilt as all real user messages plus one summary message.
318
+ * The checkpoint model sees the current active history plus one fixed
319
+ * checkpoint prompt, then the active history is rebuilt from the newest real
320
+ * user messages within one cumulative 20k-token budget plus one summary.
295
321
  * Assistant messages, tool calls/results, reasoning, and images are removed
296
322
  * from the active model-facing history; the database audit rows remain.
297
323
  */
@@ -303,7 +329,7 @@ type CompactionItem = Record<string, unknown>;
303
329
  declare const COMPACTION_SUMMARY_MARKER = "opengeni_context_summary";
304
330
  declare const SUMMARY_BUFFER_TOKENS = 20000;
305
331
  declare const COMPACT_USER_MESSAGE_MAX_TOKENS = 20000;
306
- declare const DEFAULT_COMPACTION_THRESHOLD_RATIO = 0.6;
332
+ declare const DEFAULT_COMPACTION_THRESHOLD_RATIO = 0.9;
307
333
  declare const MIN_COMPACTION_THRESHOLD_RATIO = 0.3;
308
334
  declare const MAX_COMPACTION_THRESHOLD_RATIO = 0.9;
309
335
  declare const COMPACTION_PROMPT: string;
@@ -313,63 +339,49 @@ declare const USER_MESSAGE_TRUNCATION_MARKER = "\n[... middle truncated for cont
313
339
  declare function isUserMessage(item: unknown): boolean;
314
340
  /** True for our synthetic compaction summary item. */
315
341
  declare function isCompactionSummary(item: unknown): boolean;
342
+ /** Platform-authored system context exists for one inference and is never persisted. */
343
+ declare function isEphemeralInternalContext(item: unknown): boolean;
316
344
  /**
317
345
  * Rough token estimate for an item: char/4 over its serialized text. Used for
318
- * the pre-first-call fallback, per-user-message cap, and read-path airbag.
346
+ * the pre-first-call signal and the retained user-message budget.
319
347
  */
320
348
  declare function estimateItemTokens(item: CompactionItem): number;
321
349
  declare function estimateTokens(items: readonly CompactionItem[]): number;
322
350
  declare function clampCompactionThresholdRatio(value: number | undefined | null): number;
323
- declare function clientCompactionThresholdTokens(input: {
351
+ declare function compactionThresholdTokens(input: {
324
352
  contextWindowTokens: number;
325
353
  contextReservedOutputTokens: number;
326
- contextCompactionThresholdRatio?: number | null;
354
+ contextAutoCompactThresholdTokens?: number | null | undefined;
355
+ contextCompactionThresholdRatio?: number | null | undefined;
327
356
  }): number;
328
- type ClientCompactionDecision = {
357
+ type CompactionDecision = {
329
358
  shouldCompact: boolean;
330
359
  reason: "force" | "above_threshold" | "below_threshold" | "no_history";
331
360
  signalTokens: number;
332
361
  thresholdTokens: number;
333
362
  };
334
- declare function decideClientCompaction(input: {
363
+ declare function decideCompaction(input: {
335
364
  items: readonly CompactionItem[];
336
365
  lastInputTokens?: number | null;
337
366
  contextWindowTokens: number;
338
367
  contextReservedOutputTokens: number;
339
- contextCompactionThresholdRatio?: number | null;
368
+ contextAutoCompactThresholdTokens?: number | null | undefined;
369
+ contextCompactionThresholdRatio?: number | null | undefined;
340
370
  force?: boolean;
341
- }): ClientCompactionDecision;
371
+ }): CompactionDecision;
342
372
  declare class CompactionNeededError extends Error {
343
373
  readonly signalTokens: number;
344
374
  readonly thresholdTokens: number;
345
375
  readonly signalSource: "provider" | "estimate";
376
+ readonly trigger: "threshold" | "operator";
346
377
  constructor(input: {
347
378
  signalTokens: number;
348
379
  thresholdTokens: number;
349
380
  signalSource: "provider" | "estimate";
381
+ trigger?: "threshold" | "operator";
350
382
  });
351
383
  }
352
384
  declare function findCompactionNeededError(error: unknown, seen?: WeakSet<object>): CompactionNeededError | null;
353
- /**
354
- * Walk backwards from the end of `items` keeping whole turns until the kept
355
- * tail would exceed `keepRecentTokens`, and return the index of the first kept
356
- * item. Retained for the read-path budget guard only; the client compaction
357
- * rebuild no longer uses a keep-recent tail.
358
- */
359
- declare function findKeepBoundary(items: readonly CompactionItem[], keepRecentTokens: number): number;
360
- /**
361
- * READ-PATH BUDGET GUARD (last-resort backstop).
362
- *
363
- * Drops the oldest history at a clean user-message boundary until an assembled
364
- * input fits the request budget. This remains a request-local safety rail; it
365
- * is not the compaction strategy.
366
- */
367
- declare function enforceInputBudget<T extends CompactionItem>(items: readonly T[], maxTokens: number, trailingTokens?: number): {
368
- items: T[];
369
- trimmed: boolean;
370
- droppedCount: number;
371
- estimatedTokens: number;
372
- };
373
385
  /**
374
386
  * The exact checkpoint input shape: current active history followed by Codex's
375
387
  * checkpoint prompt as a synthesized user message.
@@ -377,44 +389,30 @@ declare function enforceInputBudget<T extends CompactionItem>(items: readonly T[
377
389
  declare function buildCompactionPromptInput(items: readonly CompactionItem[]): CompactionItem[];
378
390
  /**
379
391
  * Build the active history after compaction:
380
- * all real user messages (prior summaries excluded, images removed, each
381
- * message capped) plus one marked summary item.
392
+ * the newest real user messages that fit one cumulative 20k-token budget
393
+ * (prior summaries excluded, images removed) plus one marked summary item.
382
394
  */
383
395
  declare function buildCompactionReplacementHistory(items: readonly CompactionItem[], summaryBody: string): CompactionItem[];
384
- type DeterministicFallbackCompactionInput = {
385
- items: readonly CompactionItem[];
386
- cause?: string;
387
- targetTokens?: number;
388
- };
389
- declare function buildDeterministicFallbackCompactionHistory(input: DeterministicFallbackCompactionInput): CompactionItem[];
390
396
  /**
391
397
  * Build the synthetic summary item (a plain user message) appended to the
392
398
  * rebuilt active history.
393
399
  */
394
400
  declare function buildSummaryItem(summaryBody: string): CompactionItem;
395
- type RenderCompactionTranscriptOptions = {
396
- /**
397
- * Hard cap for a rendered transcript. When set, oldest rendered items are
398
- * dropped first while preserving the final checkpoint prompt; if the retained
399
- * item itself is too large, it is middle-truncated instead of looping.
400
- */
401
- maxEstimatedTokens?: number;
402
- };
403
- declare function renderCompactionPromptInputForChat(input: readonly CompactionItem[], options?: RenderCompactionTranscriptOptions): string;
401
+ declare function renderCompactionPromptInputForChat(input: readonly CompactionItem[]): string;
404
402
 
405
- declare const SCREENSHOT_OMITTED_PLACEHOLDER = "[screenshot omitted: an older desktop frame \u2014 the full image remains in the session event log]";
406
- type ElideStaleScreenshotsResult<T> = {
407
- items: T[];
408
- imageCount: number;
409
- elidedCount: number;
410
- };
411
- type ElideStaleScreenshotsOptions = {
412
- keepLast?: number;
413
- placeholder?: string;
403
+ type UsageDetails = Record<string, unknown> | Array<Record<string, unknown>>;
404
+ type ModelCallUsageTelemetry = {
405
+ inputTokens: number | null;
406
+ outputTokens: number | null;
407
+ cachedTokens: number | null;
408
+ reasoningTokens: number | null;
414
409
  };
415
- declare function elideStaleScreenshotImages<T extends AgentInputItem>(items: readonly T[], options?: ElideStaleScreenshotsOptions): ElideStaleScreenshotsResult<T>;
416
-
417
- declare const SCREENSHOT_OMITTED_IMAGE_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgwAAAC0CAYAAAD4gHQ+AAAG2klEQVR42u3dMXLbMBCGUR/ChQuPT5KD+c5q1Ki2b+CMRlji38UrXpWYoUkA/AoM8vb17/sHAOAvbx4CACAYAADBAAAIBgBAMAAAggEAEAwAgGAAABAMAIBgAAAEAwAgGAAAwQAACAYAQDAAAIIBAEAwAACCAQAQDACAYAAABAMAIBgAAMEAAAiGco/77SVXXz/9fqvv/9nrvzoedr/ftPvfPX7S14fV7+fZn582f0+7vggQDIJBMAgGwSAYXF8wCAbBIBgEg2AQDK4vGASDYBAMgkEwCAbXFwznBUP1C0q/fvUHK+35rF7QT3+/u38+fX149YOyejxb/9yfYBAMgkEwCAbBYP1zf4JBMAgGwSAYBINgEAyiQDAIBsEgGASDYBAMgkEwCIbc51P954JBMCSPP+ufYBAMJoxgEAyCQTBY/9yfYBAMgkEwCAbBIBgEA4JBMAgGwSAYBINgEAyzDm5K39SXdtDU7utXL8jdD86yIAqGk4Oh28FcCAbBIBgEg2AQDIJBMAgGwSAYBINgEAyCQTAIBsEgGASDYBAMgkEwzA+GaZsGLShrP9DT3p9gsOlUMNj0KBgEgwVFMAgGwWB+uz/BIBgEg2DwwRIM5rdgQDAIBsHggyUYBINgEAyCIeWDaEHpfbCUD5ZgEAyCAcEgGCwoPliCQTAIBsEgGASDCSsYBINgEAyCQTAIBhNWMAgGwWB+C4a5//nU6oM7qv+9qxe06vs/7fmkLTjV47/7gtjt/VbPr9MPbtq9PiAYBINgEAyCQTAIBhEgGASDYBAMgkEwCAbBIBgEg2AQDIJBMAgGwWDTIwAgGAAAwQAACAYAQDAAAAgGAEAwAACCAQAQDACAYAAABAMAIBgAAMEAACAYAADBAAAIBgBAMAAAggEAEAwAgGAAAASDhwAACAYAQDAAAIIBAEgIho/3z59Kj/ttqdX/XvX9P3v9bs8//frV47v786/+farH/+7xOW38GP/Wt78IBsEgGASDYBAMgkEwCAbBIBgEg2AQDIJBMAgGwSAYBINgEAyCQTBMDIa061dPqN0Tdvfzm35/xn/tB331398dkNPGT/f5nRZU6e9PMAgGwWD8CwbBIBgEg2AQDIJBMAgGwSAYBINgEAyCQTAIBsEgGASDYBAMgkEwnDz+q/9cMAgGwSAYBINgEAyCQTAIBsEgGASDYBAMgkEwCAbBIBgsmIJBMBj/gkEwCIazg8HBGrMnbLeDs04f/+kHB63+c+NHMCSNH8EgGASDYBAMgkEwCAbBIBhMWMEgGASDYBAMgkEwmLCCQTAIBsEgGASDTY9pm6pseuy9aXT687Gp2KZHwWDTo2AQDIJBMAgGwSAYBINgEAyCwYIvGASD9UcwCAbBIBgEg2AQDIJBMAiGvgPGpqO995e+aa3b8xEMxo9gEAyCQTAIBsEgGASDYBAMgkEwCAbBIBgEg/VHMAgGwSAYBINgEAyCQTA4uGndwS/dFrS0g6fSru8/n/JBT5pf09bP064//WBAwWBBEwyCQTAIBuuDYBAMgsGCIBgEg2CwPggGwSAYTFjBIBgEg2AQDIIBAJhIMAAAggEAEAwAgGAAAAQDACAYAADBAAAIBgAAwQAACAYAQDAAAIIBABAMAIBgAAAEAwAgGAAABAMAIBgAAMEAAAgGAEAwAACCAQAQDACAYFjvcb8ttfrfS3sh3Z7Pq8/zfz9/9fjxfme936uvb/wjGASDD4pg8H4Fg/GPYBAMgkEweL+CQTCAYBAMPiiCQTAIBh89em96rJ5w1T+/+/dPW/DTrt99fKd/0E+f36evXwgGweCDIhi8X8Fg/QLBIBgEg/crGKxfIBgEg2AQDIJBMIBgEAyCQTCkPP/d4yNtfl89ngUDgkEwCAbBIBgEg2BAMAgGwSAYBINgEAwIBsHggyIYBINgEAwIBsGQdLDP7oOz0g+uEQyCYef4SX//IBgEg2AQDIJBMIBgEAyCQTAIBsEgGBAMgkEwCAbBIBgEA4JBMHTaZGXTo2BYGag2Pdr0iGAQDIJBMAgGwSAYEAyCQTAIBsEgGAQDgkEwCAbBIBgEg2AAwSAYrno+1R8gwTArCP3nU1m/X/omYgSDYBAMgkEwCAbBgGAQDIJBMAgGwSAYEAwmnGAQDIJBMAgGBEO3BbX7wT7VBzd1XxCnHeS0+6Au4yf74DLBgGAQDIJBMAgGwSAYEAyCQTAIBsEgGAQDgkEwCAbBIBiMH8GAYAAAEAwAgGAAAAQDACAYAADBAAAIBgBAMAAAggEAQDAAAIIBABAMAIBgAAAEAwAgGAAAwQAACAYAAMEAAAgGAEAwAACCAQAQDACAYAAABAMAcLxffBoP915amCIAAAAASUVORK5CYII=";
410
+ declare function modelCallUsageTelemetry(usage: {
411
+ inputTokens?: unknown;
412
+ outputTokens?: unknown;
413
+ inputTokensDetails?: UsageDetails | undefined;
414
+ outputTokensDetails?: UsageDetails | undefined;
415
+ } | null | undefined): ModelCallUsageTelemetry;
418
416
 
419
417
  type NormalizedRuntimeEvent = {
420
418
  type: SessionEventType;
@@ -427,6 +425,7 @@ type ModelResponseUsage = {
427
425
  outputTokens?: number;
428
426
  totalTokens?: number;
429
427
  inputTokensDetails?: Record<string, number> | Array<Record<string, number>>;
428
+ outputTokensDetails?: Record<string, number> | Array<Record<string, number>>;
430
429
  };
431
430
  };
432
431
  type ResolveConnectionCredentialInput = {
@@ -454,8 +453,10 @@ type ResolveConnectionCredentialResult = {
454
453
  declare function ensureReadableStreamFrom(): void;
455
454
  type AgentSegmentInput = {
456
455
  kind: "message";
457
- text: string;
458
- serializedRunState?: string | null;
456
+ /** A real human/API prompt. Omitted when resuming the same inference. */
457
+ text?: string;
458
+ /** Ephemeral platform context: system role, never conversation history. */
459
+ internalContext?: string;
459
460
  historyItems?: AgentInputItem[] | null;
460
461
  sandboxEnvelope?: Record<string, unknown> | null;
461
462
  } | {
@@ -468,7 +469,6 @@ type AgentSegmentInput = {
468
469
  type PreparedAgentInput = {
469
470
  input: string | AgentInputItem[] | RunState<any, any>;
470
471
  sandboxSessionState?: SandboxSessionState;
471
- serializedRunStateForSandbox?: string;
472
472
  };
473
473
  type SandboxFileDownload = {
474
474
  fileId: string;
@@ -479,6 +479,17 @@ type SandboxFileDownload = {
479
479
  expiresAt?: Date | string;
480
480
  sizeBytes?: number;
481
481
  };
482
+ type SandboxFileDownloadFailure = {
483
+ fileId: string;
484
+ filename: string;
485
+ path: string;
486
+ reason: string;
487
+ exitCode?: number;
488
+ output?: string;
489
+ };
490
+ type SandboxFileDownloadMaterializationResult = {
491
+ failures: SandboxFileDownloadFailure[];
492
+ };
482
493
  declare function configureRuntimeMetricsHooks(hooks: RuntimeMetricsHooks | null | undefined): void;
483
494
  type OpenGeniRuntime = {
484
495
  configure: (settings: Settings) => void;
@@ -566,14 +577,25 @@ declare class MultiProviderModelProvider implements ModelProvider {
566
577
  declare class CodexSubscriptionUnavailableError extends Error {
567
578
  constructor(modelName: string);
568
579
  }
580
+ /**
581
+ * The workspace's model policy blocks the provider/model this turn resolved
582
+ * to. Thrown at the worker's post-resolution gate INSTEAD of running the turn
583
+ * on the blocked provider — a policy-restricted workspace (e.g. fail-closed to
584
+ * the Codex subscription) must never silently remap to, or fall through to,
585
+ * the paid built-in client. Like CodexSubscriptionUnavailableError the message
586
+ * is user-actionable and surfaces verbatim as a non-retryable turn.failed.
587
+ */
588
+ declare class WorkspaceModelPolicyBlockedError extends Error {
589
+ constructor(modelName: string, providerId: string, reason: "provider" | "model");
590
+ }
569
591
  declare function configureOpenAI(settings: Settings): void;
570
592
  /**
571
593
  * Run the compaction summarizer as one plain, tool-less, non-streaming model
572
594
  * call against the resolved provider. `input` is the active history plus
573
- * Codex's checkpoint prompt. Returns the trimmed summary text, or null on any
574
- * failure (the caller can retry with a harder-trimmed transcript, then fall
575
- * back to deterministic non-LLM compaction). The call deliberately does NOT
576
- * request reasoning encryption, tools, or server-side compaction; it is a
595
+ * Codex's checkpoint prompt. Provider failures propagate to the compaction
596
+ * lifecycle; there is no non-model fallback that silently discards history.
597
+ * The call deliberately does NOT
598
+ * request reasoning encryption, tools, or inline provider compaction; it is a
577
599
  * self-contained summarize.
578
600
  *
579
601
  * Provider-aware: the summary always runs on the SAME provider that serves the
@@ -581,8 +603,7 @@ declare function configureOpenAI(settings: Settings): void;
581
603
  * versa). `api: "chat"` providers (Fireworks) speak /v1/chat/completions, where
582
604
  * the summary is choices[0].message.content; `api: "responses"` (the default,
583
605
  * built-in OpenAI/Azure) speaks /v1/responses as before. When no client/api is
584
- * supplied it falls back to the built-in OpenAI/Azure Responses path so the
585
- * legacy global-client callers are byte-for-byte unchanged. store:false is set
606
+ * supplied it uses the built-in OpenAI/Azure Responses path. store:false is set
586
607
  * only on the OpenAI-platform Responses path (Azure rejects it; chat ignores it).
587
608
  */
588
609
  declare function summarizeForCompaction(settings: Settings, input: Array<Record<string, unknown>>, options?: {
@@ -590,8 +611,10 @@ declare function summarizeForCompaction(settings: Settings, input: Array<Record<
590
611
  api?: ModelProviderApi;
591
612
  maxOutputTokens?: number;
592
613
  model?: string;
593
- maxTranscriptTokens?: number;
594
- }): Promise<string | null>;
614
+ promptCacheKey?: string;
615
+ systemInstructions?: string;
616
+ onUsage?: (usage: ModelResponseUsage) => void | Promise<void>;
617
+ }): Promise<string>;
595
618
  /**
596
619
  * Pull the assistant text out of a Responses API result, shape-tolerant. Only
597
620
  * `role === "assistant"` message items contribute: a provider whose Responses
@@ -601,24 +624,38 @@ declare function summarizeForCompaction(settings: Settings, input: Array<Record<
601
624
  * Responses API only emits assistant messages, so this guard is a no-op there.
602
625
  */
603
626
  declare function extractResponseOutputText(response: unknown): string;
627
+ type GitTokenSeeds = Partial<Record<GitCredentialProvider, string>>;
628
+ type GitCredentialTokenWriterSession = SandboxSessionLike;
604
629
  type BuildAgentOptions = {
605
630
  model?: Model;
606
631
  reasoningEffort?: ReasoningEffort;
607
- compactionMode?: ContextCompactionMode;
608
632
  hostedWebSearch?: boolean;
609
633
  encryptedReasoning?: boolean;
610
- contextWindowTokens?: number;
611
634
  structuredToolTransport?: boolean;
612
635
  computerToolMode?: ComputerToolMode;
636
+ /**
637
+ * Invoked once, immediately before the first real computer action and after
638
+ * the display is ready. Merely advertising computer-use does not call it.
639
+ * The worker uses this seam for computer-use-only recording; ordinary
640
+ * shell/filesystem turns never pay that cost.
641
+ */
642
+ onComputerUseReady?: (session: SandboxSessionLike) => Promise<void>;
613
643
  codexConnectorNamespaces?: ReadonlySet<string>;
644
+ promptCacheKey?: string;
614
645
  sandboxEnvironment?: Record<string, string>;
615
646
  activeSandboxBackend?: Settings["sandboxBackend"];
616
647
  fileResourceDownloads?: SandboxFileDownload[];
617
648
  mcpServers?: MCPServer[];
649
+ workspaceMemory?: string;
618
650
  workspaceEnvironment?: WorkspaceEnvironmentContext;
651
+ rig?: RigInstructionsContext;
652
+ rigSetup?: RigSetupDescriptor;
653
+ rigCredentialHookIds?: string[];
619
654
  gitTokenSeed?: string;
655
+ gitTokenSeeds?: GitTokenSeeds;
620
656
  toolspaceTokenSeed?: string;
621
657
  genesisTitleHint?: boolean;
658
+ persistentSessionSettings?: PersistentSessionSettings;
622
659
  instructionsTemplate?: string;
623
660
  sessionInstructions?: string;
624
661
  packSkills?: PackSkill[];
@@ -645,6 +682,21 @@ type WorkspaceEnvironmentContext = {
645
682
  description?: string | null;
646
683
  variableNames?: string[];
647
684
  };
685
+ type PersistentSessionSettings = {
686
+ titleIsSet: boolean;
687
+ };
688
+ /**
689
+ * The rig a session rides (M3): its name + the active version pinned onto the
690
+ * session. Surfaced verbatim in the non-bypassable CORE instructions so the
691
+ * agent understands its sandbox is a disposable fork of a shared, versioned
692
+ * machine definition and how to promote a durable change. Absent for rig-less
693
+ * sessions (the block never renders).
694
+ */
695
+ type RigInstructionsContext = {
696
+ name: string;
697
+ version: number;
698
+ };
699
+ declare function rigInstructions(rig: RigInstructionsContext): string[];
648
700
  declare function workspaceEnvironmentInstructions(environment: WorkspaceEnvironmentContext): string[];
649
701
  /**
650
702
  * The non-bypassable CORE of the agent instructions: the goal-loop ownership
@@ -657,7 +709,7 @@ declare function workspaceEnvironmentInstructions(environment: WorkspaceEnvironm
657
709
  * drop: composeAgentInstructions() substitutes it at the persona template's
658
710
  * {{core}} marker, and appends it when the marker is absent.
659
711
  */
660
- declare function coreInstructions(workspaceEnvironment?: WorkspaceEnvironmentContext): string[];
712
+ declare function coreInstructions(workspaceEnvironment?: WorkspaceEnvironmentContext, rig?: RigInstructionsContext): string[];
661
713
  /**
662
714
  * Composes the final agent instructions from a (possibly white-labelled)
663
715
  * persona template and the non-bypassable CORE. The CORE is substituted at the
@@ -666,7 +718,7 @@ declare function coreInstructions(workspaceEnvironment?: WorkspaceEnvironmentCon
666
718
  * and the append both join by " ", so the DEFAULT_AGENT_INSTRUCTIONS template
667
719
  * with an empty environment reproduces the historical preamble byte-for-byte.
668
720
  */
669
- declare function composeAgentInstructions(template: string, workspaceEnvironment?: WorkspaceEnvironmentContext): string;
721
+ declare function composeAgentInstructions(template: string, workspaceEnvironment?: WorkspaceEnvironmentContext, rig?: RigInstructionsContext): string;
670
722
  /**
671
723
  * Appends the per-session persona instructions to the already-composed
672
724
  * (workspace + CORE) instructions, joined by " " — exactly the join used
@@ -675,6 +727,22 @@ declare function composeAgentInstructions(template: string, workspaceEnvironment
675
727
  * is a no-op that returns the composed string byte-for-byte.
676
728
  */
677
729
  declare function appendSessionInstructions(composed: string, sessionInstructions?: string): string;
730
+ /**
731
+ * Append the durable session metadata the model otherwise cannot observe.
732
+ * This is deliberately declarative and excludes the title text: the title is
733
+ * user-controlled display metadata, while the agent only needs to know whether
734
+ * initialization has already happened. The block is present on every turn when
735
+ * supplied so compaction cannot erase knowledge that these settings persist.
736
+ */
737
+ declare function appendPersistentSessionSettings(composed: string, settings?: PersistentSessionSettings): string;
738
+ /**
739
+ * Appends the workspace memory working-set block to the already-composed
740
+ * (workspace + CORE + generic substrate) instructions, joined by " ". The
741
+ * memory slice is workspace-ground and intentionally lands before
742
+ * per-session instructions. An absent/blank value is a no-op that returns the
743
+ * composed string byte-for-byte.
744
+ */
745
+ declare function appendWorkspaceMemory(composed: string, workspaceMemory?: string): string;
678
746
  /**
679
747
  * Appends the generic programmatic-tool-calling (toolspace) directive to the
680
748
  * composed workspace + CORE instructions, joined by " ". This is GENERIC
@@ -730,34 +798,19 @@ declare function mcpToolErrorOutput(error: unknown): {
730
798
  };
731
799
  declare function buildOpenGeniAgent(settings: Settings, resources: ResourceRef[], options?: BuildAgentOptions): Agent<any, any>;
732
800
  /**
733
- * Build the SandboxAgent capability set provider-aware.
734
- *
735
- * The SDK's `Capabilities.default()` force-includes `compaction()`, whose
736
- * sampling params emit `context_management:[{type:'compaction', …}]` to the
737
- * Responses transport. The OpenAI platform honors that (server-side compaction);
738
- * AZURE rejects it with `400 unsupported_parameter` — which is exactly the live
739
- * production failure on Azure today. So we MUST NOT attach the compaction
740
- * capability on the Azure / client / off paths.
741
- *
742
- * We rebuild the base set explicitly (`filesystem()`, `shell()`, the same
743
- * factories the SDK default uses) and add `compaction()` ONLY on the server
744
- * path, with an explicit `StaticCompactionPolicy(threshold)` so gpt-5.5 — which
745
- * is absent from the SDK's hardcoded context-window map and would otherwise hit
746
- * the wrong 240k fallback — gets the correct threshold. The SDK has no
747
- * window-registration API, so an explicit threshold is the only way to fix it.
748
- *
749
- * The resolved compaction mode and the effective context window are now passed
750
- * IN (the multi-provider caller resolves them per provider/model) rather than
751
- * re-derived from settings here. Both default to the settings-derived value so
752
- * callers that don't route per-model (and the existing tests) keep today's exact
753
- * behaviour; the effective window only changes the server-path threshold when a
754
- * resolved model declares its own contextWindowTokens.
801
+ * Codex accepts ordinary FUNCTION tools but also accepts `input_image` content
802
+ * inside a function_call_output (the same transport used by codex-rs
803
+ * view_image). The SDK filesystem capability unnecessarily couples this choice
804
+ * to hosted apply_patch support; when hosted tools are disabled it degrades
805
+ * view_image to a giant text data URL, charging roughly one token per four
806
+ * base64 characters. Re-wrap only successful data-URL results as a structured
807
+ * image. Text errors remain text, and the tool itself remains a normal function.
755
808
  */
809
+ declare function withStructuredViewImageFunctionResults(tools: Tool<unknown>[]): Tool<unknown>[];
756
810
  declare function buildAgentCapabilities(settings: Settings, packSkills: PackSkill[], options?: {
757
- compactionMode?: ContextCompactionMode;
758
- contextWindowTokens?: number;
759
811
  structuredToolTransport?: boolean;
760
812
  computerToolMode?: ComputerToolMode;
813
+ onComputerUseReady?: (session: SandboxSessionLike) => Promise<void>;
761
814
  }): ReturnType<typeof Capabilities.default>;
762
815
  declare function sandboxRunAs(_settings: Settings): string | undefined;
763
816
  type PreparedAgentTools = {
@@ -769,6 +822,9 @@ type PrepareToolsOptions = {
769
822
  accountId?: string;
770
823
  workspaceId?: string;
771
824
  sessionId?: string;
825
+ turnId?: string;
826
+ attemptId?: string;
827
+ executionGeneration?: number;
772
828
  subjectId?: string;
773
829
  subjectLabel?: string;
774
830
  firstPartyPermissions?: Permission[];
@@ -779,34 +835,41 @@ declare function prepareAgentTools(settings: Settings, tools: ToolRef[], options
779
835
  declare function prefixedMcpToolName(registryId: string, toolName: string): string;
780
836
  type PrepareInputOptions = {
781
837
  sandboxClient?: unknown;
782
- /**
783
- * Usable input-token budget B (window - reserved output). When set, the
784
- * assembled history is passed through `enforceInputBudget` so a single
785
- * over-budget input can never be sent — the last-resort backstop behind the
786
- * best-effort pre-turn compaction. Omitted (undefined) disables the guard
787
- * (no behaviour change for callers that don't opt in).
788
- */
789
- inputBudgetTokens?: number;
790
838
  };
791
839
  declare function prepareRunInput(agent: Agent<any, any>, input: AgentSegmentInput, options?: PrepareInputOptions): Promise<PreparedAgentInput>;
792
840
  type RunAgentStreamOptions = {
841
+ /** Abort the provider/tool loop when the owning activity is cancelled. */
842
+ signal?: AbortSignal;
793
843
  sandboxClient?: unknown;
794
844
  sandboxEnvironment?: Record<string, string>;
795
845
  onRuntimeEvent?: (event: NormalizedRuntimeEvent) => Promise<void> | void;
796
846
  contextCompactionSignalTokens?: () => number | null | undefined;
847
+ contextCompactionRequested?: () => boolean | Promise<boolean>;
848
+ onGitCredentialSessionReady?: (session: GitCredentialTokenWriterSession) => Promise<void> | void;
797
849
  ownedSandbox?: {
798
850
  client: unknown;
799
851
  session: unknown;
800
852
  sessionState?: unknown;
801
853
  setupSession?: unknown;
854
+ fileDownloadsMaterialized?: boolean;
855
+ deferredSetup?: boolean;
802
856
  };
803
857
  callModelInputFilter?: CallModelInputFilter;
804
858
  };
805
859
  type ContextRobustnessFilterOptions = {
806
860
  contextCompactionSignalTokens?: () => number | null | undefined;
861
+ contextCompactionRequested?: () => boolean | Promise<boolean>;
807
862
  throwOnCompactionNeeded?: boolean;
808
863
  };
809
864
  declare const GENESIS_TITLE_DIRECTIVE = "This is the first turn of a new session. Before responding to the user, call the opengeni__set_session_title tool with a concise 3-7 word title that summarizes what this session is about, then address the user's request normally.";
865
+ /**
866
+ * Inject the genesis-title directive into exactly one model request. Agent
867
+ * instructions are reused for every model call in a tool loop, so placing this
868
+ * directive there turned a nominally one-shot setup action into repeated title
869
+ * calls. The closure is intentionally consumed even when the first request
870
+ * fails: a retry/recovery must continue the task, not restart setup.
871
+ */
872
+ declare function oneShotGenesisTitleInputFilter(): CallModelInputFilter;
810
873
  declare const TOOLSPACE_PROGRAMMATIC_DIRECTIVE = "Every tool on your MCP surface is also callable programmatically from the sandbox shell, so scripts can invoke tools without a model round trip per call. Run `ogtool list` to see the available tools and their input schemas (from tools/list), then `ogtool call <tool-name> '<json-args>'`; equivalently, POST MCP JSON-RPC to $OPENGENI_TOOLSPACE_URL with the bearer token read from $OPENGENI_TOOLSPACE_TOKEN_FILE. Prefer programmatic calls for loops, polling, and bulk filtering: their results stay in the sandbox and do not consume your context window. Tools that require human approval must still be invoked normally \u2014 called programmatically they return a typed error.";
811
874
  /**
812
875
  * callModelInputFilter that removes provider-assigned item ids (rs_/msg_/fc_…)
@@ -827,7 +890,7 @@ declare const stripProviderItemIdsFilter: CallModelInputFilter;
827
890
  * `action` and `actions` down to EXACTLY ONE (keeps `actions`, drops `action`).
828
891
  * The Azure computer-use endpoint rejects a request whose computer_call has
829
892
  * both with `400 Computer call input must include exactly one of `action` or
830
- * `actions``; and (live-proven against gpt-5.5's GA computer tool) it also
893
+ * `actions``; and (live-proven against gpt-5.6-sol's GA computer tool) it also
831
894
  * rejects the `action`-only form, accepting ONLY the batched plural `actions`.
832
895
  * The SDK 0.11.6 schema allows both, so a freshly-emitted
833
896
  * screenshot call carries the redundant pair. This filter runs before EVERY
@@ -837,13 +900,20 @@ declare const stripProviderItemIdsFilter: CallModelInputFilter;
837
900
  * never mutated.
838
901
  */
839
902
  declare const normalizeComputerCallsFilter: CallModelInputFilter;
903
+ /**
904
+ * Per-call state compaction for local image inspection. Re-opening the same
905
+ * path supersedes its prior base64 result; carrying both provides no newer
906
+ * information and can otherwise balloon every following model request.
907
+ */
908
+ declare const elideSupersededViewImagesFilter: CallModelInputFilter;
840
909
  declare function contextRobustnessFilterForSettings(settings: Settings, options?: ContextRobustnessFilterOptions): CallModelInputFilter;
841
910
  /**
842
911
  * The model-input filter applied before every model call. The computer_call
843
912
  * action/actions normalizer is ALWAYS on (the Azure endpoint 400s without it);
844
913
  * the provider-item-id strip is layered on top when the configured policy
845
- * selects it; the context-robustness guard then elides stale screenshots on
846
- * every mode and applies hard budget trimming only on the client-compaction path.
914
+ * selects it; the context-robustness guard then raises the proactive durable
915
+ * compaction signal on the client-compaction path. It never trims history from
916
+ * an individual request.
847
917
  */
848
918
  declare function callModelInputFilterForSettings(settings: Settings, options?: ContextRobustnessFilterOptions): CallModelInputFilter | undefined;
849
919
  declare function runAgentStream(agent: Agent<any, any>, input: PreparedAgentInput | string | RunState<any, any>, settings: Settings, overrides?: RunAgentStreamOptions): Promise<_openai_agents.StreamedRunResult<any, Agent<any, any>>>;
@@ -865,10 +935,63 @@ declare function maxTurnsExceededRunState(error: unknown): {
865
935
  * an error.
866
936
  */
867
937
  declare function agentsErrorRunState(error: unknown): string | null;
868
- declare function withManifestRefreshOnResume(client: SandboxClient, targetManifest: Manifest | undefined): SandboxClient;
869
- declare function applyMissingManifestEntries(session: SandboxSessionLike, targetManifest: Manifest): Promise<void>;
938
+ declare function withManifestRefreshOnResume(client: SandboxClient, targetManifest: Manifest | undefined, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): SandboxClient;
939
+ declare function applyMissingManifestEntries(session: SandboxSessionLike, targetManifest: Manifest, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): Promise<void>;
940
+ /**
941
+ * Key-level diff of the live box's baked manifest env vs the freshly recomputed
942
+ * target env. Returns null when identical. Key NAMES only — values are secrets
943
+ * and must never leave this function's comparison.
944
+ */
945
+ declare function manifestEnvironmentDrift(current: Manifest, target: Manifest): {
946
+ added: string[];
947
+ removed: string[];
948
+ changed: string[];
949
+ } | null;
950
+ /**
951
+ * ENV PIN for provided sessions (the ownership-inversion turn path). The SDK
952
+ * validates the FULL target manifest environment against a live provided
953
+ * session's baked env BEFORE reducing to its entry-only delta
954
+ * (validateNoEnvironmentDelta -> session-fatal UserError on ANY difference).
955
+ * So a turn resuming an existing box must declare the box's OWN env,
956
+ * byte-identical — never the fresh recompute. This replaces the agent's
957
+ * defaultManifest environment with the baked one and reports the drift (key
958
+ * names only) instead of letting it kill the session. Fresh env lands at the
959
+ * next cold-create; rotating values ride OFF-manifest (TOKEN-BROKER B1/B2).
960
+ */
961
+ declare function pinProvidedSessionManifestEnvironment(agent: Agent<any, any>, session: SandboxSessionLike, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): Promise<void>;
962
+ /**
963
+ * The one-truth owned-path platform setup: the manifest-env pin (align the turn's
964
+ * manifest to the live box's baked env + report drift, NEVER die on it) plus the
965
+ * beforeAgentStart hooks (repository clone with B1 token/askpass seed, toolspace
966
+ * token seed, azure-cli-login) and signed-URL file materialization — all executed
967
+ * DIRECTLY against the pinned, UN-proxied established box (the SDK never calls
968
+ * client.create/resume for a provided session, so these decorations would never
969
+ * fire on their own).
970
+ *
971
+ * Extracted verbatim from `runStream`'s owned branch so both the EAGER path
972
+ * (runStream, before the run starts) and the LAZY path (the worker's first-op
973
+ * provisioner, after the box is established) run the IDENTICAL setup. A pure
974
+ * refactor for the eager path: same order, same gates, same idempotency
975
+ * (clone skips a materialized tree, token seed overwrites — the desired per-turn
976
+ * refresh, az login is idempotent). The connected-machine (selfhosted) branch
977
+ * keeps platform setup OFF the user's real box and seeds ONLY the toolspace token.
978
+ *
979
+ * `gitTokenSeedsOverride` lets the lazy provisioner pass its own freshly-minted
980
+ * run-scoped provider tokens (minted at establish time, not turn start);
981
+ * unset ⇒ read the seeds off the agent exactly as the eager path does.
982
+ */
983
+ declare function runOwnedSandboxSetup(agent: Agent<any, any>, session: SandboxSessionLike, setupSession: SandboxSessionLike, opts: {
984
+ settings: Settings;
985
+ environment: Record<string, string>;
986
+ preparedInput?: PreparedAgentInput;
987
+ fileDownloadsMaterialized?: boolean;
988
+ onRuntimeEvent?: SandboxLifecycleHookContext["onRuntimeEvent"];
989
+ gitTokenSeedsOverride?: GitTokenSeeds;
990
+ gitTokenSeedOverride?: string;
991
+ }): Promise<void>;
870
992
  declare function withSandboxFileDownloads(client: SandboxClient, downloads: SandboxFileDownload[], context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent" | "runAs">): SandboxClient;
871
- declare function materializeSandboxFileDownloads(session: SandboxSessionLike, downloads: SandboxFileDownload[], context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent" | "runAs">): Promise<void>;
993
+ declare function materializeSandboxFileDownloads(session: SandboxSessionLike, downloads: SandboxFileDownload[], context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent" | "runAs">): Promise<SandboxFileDownloadMaterializationResult>;
994
+ declare function sandboxFileDownloadFailureNote(failures: SandboxFileDownloadFailure[]): string;
872
995
  declare function sandboxFileDownloadsForAgent(agent: unknown): SandboxFileDownload[];
873
996
  /**
874
997
  * Compact a tool-call output for the `agent.toolCall.output` SESSION EVENT so it
@@ -888,6 +1011,8 @@ declare function sandboxFileDownloadsForAgent(agent: unknown): SandboxFileDownlo
888
1011
  declare function normalizeToolOutputForEvent(output: unknown): unknown;
889
1012
  declare function normalizeSdkEvent(event: RunStreamEvent): NormalizedRuntimeEvent[];
890
1013
  declare function modelResponseUsageFromSdkEvent(event: RunStreamEvent): ModelResponseUsage | null;
1014
+ /** Normalize usage from either a Responses or Chat Completions result. */
1015
+ declare function modelResponseUsageFromResponse(response: unknown): ModelResponseUsage | null;
891
1016
  declare function serializeApprovals(interruptions: unknown[]): unknown[];
892
1017
  declare function buildManifest(settings: Settings, resources: ResourceRef[], environment?: Record<string, string>, fileResourceDownloads?: SandboxFileDownload[]): Manifest;
893
1018
  type SandboxLifecycleHookPhase = "beforeAgentStart";
@@ -896,7 +1021,16 @@ type SandboxLifecycleHookContext = {
896
1021
  onRuntimeEvent?: (event: NormalizedRuntimeEvent) => Promise<void> | void;
897
1022
  runAs?: string;
898
1023
  gitTokenSeed?: string;
1024
+ gitTokenSeeds?: GitTokenSeeds;
899
1025
  toolspaceTokenSeed?: string;
1026
+ rigSetup?: RigSetupDescriptor;
1027
+ };
1028
+ type RigSetupDescriptor = {
1029
+ rigId: string;
1030
+ versionId: string;
1031
+ rigName: string;
1032
+ script: string;
1033
+ timeoutMs: number;
900
1034
  };
901
1035
  type SandboxLifecycleHook = {
902
1036
  id: string;
@@ -939,11 +1073,50 @@ declare function withSandboxLifecycleHooks(client: SandboxClient, hooks: Sandbox
939
1073
  declare function repositoryUsesSandboxClone(settings: Settings, resource: Extract<ResourceRef, {
940
1074
  kind: "repository";
941
1075
  }>, activeSandboxBackend?: Settings["sandboxBackend"]): boolean;
1076
+ /**
1077
+ * Build the off-manifest command used to atomically replace provider token files.
1078
+ *
1079
+ * Token values exist only in this one sandbox exec command. The stable askpass
1080
+ * and provider-CLI wrappers always read the files at invocation time, so an
1081
+ * in-flight multi-day turn observes the replacement without changing its
1082
+ * manifest environment or rebuilding the sandbox.
1083
+ */
1084
+ declare function gitProviderTokenRefreshCommand(seeds: GitTokenSeeds): string;
1085
+ declare function refreshGitProviderTokenFiles(session: GitCredentialTokenWriterSession, seeds: GitTokenSeeds, options?: {
1086
+ runAs?: string;
1087
+ }): Promise<void>;
942
1088
  declare function repositoryCloneCommand(resources: Extract<ResourceRef, {
943
1089
  kind: "repository";
944
1090
  }>[]): string;
945
1091
  declare function toolspaceTokenSeedCommand(): string;
946
1092
  declare function runToolspaceTokenSeedHook(session: SandboxSessionLike, context: SandboxLifecycleHookContext): Promise<void>;
1093
+ /**
1094
+ * The rig-setup command (M3). One idempotent bash program:
1095
+ * 1. `mkdir -p /var/opengeni` and, if the per-version marker already exists,
1096
+ * print the SKIP sentinel and exit 0 (a warm box re-running the hook).
1097
+ * 2. otherwise atomically claim a per-version lock directory. A loser waits
1098
+ * for the winner's marker, then skips; if the winner fails and releases the
1099
+ * lock, the loser retries the claim.
1100
+ * 3. the winner writes the rig's setup script to a temp file and runs it under
1101
+ * coreutils `timeout` (NOT `bash -e` — the script opts into `set -e`
1102
+ * itself if it wants), then captures the exit code and `touch`es the marker
1103
+ * ONLY on success (exit 0) so a failed/timed-out setup re-runs next turn.
1104
+ * The heredoc delimiter is quoted, so the script content is executed verbatim
1105
+ * with no host-side expansion.
1106
+ */
1107
+ declare function rigSetupScriptCommand(script: string, versionId: string, timeoutMs?: number, markerRoot?: string): string;
1108
+ /**
1109
+ * The rig-setup beforeAgentStart hook (M3). Runs the frozen rig version's setup
1110
+ * script exactly once per box (marker-guarded), under the RIG's own timeout
1111
+ * (context.rigSetup.timeoutMs, NOT the 120s lifecycle default). Emits
1112
+ * rig.setup.started, then one terminal event:
1113
+ * - rig.setup.skipped — marker already present,
1114
+ * - rig.setup.completed — script ran and exited 0,
1115
+ * - rig.setup.failed — nonzero exit / timeout,
1116
+ * and on failure THROWS (fail the turn closed) with a message naming the
1117
+ * rig/version and a bounded tail of the setup output.
1118
+ */
1119
+ declare function runRigSetupHook(session: SandboxSessionLike, context?: SandboxLifecycleHookContext): Promise<void>;
947
1120
  declare function runRepositoryCloneHook(session: SandboxSessionLike, resources: Extract<ResourceRef, {
948
1121
  kind: "repository";
949
1122
  }>[], context?: SandboxLifecycleHookContext): Promise<void>;
@@ -964,4 +1137,4 @@ declare function azureOpenAIDefaultQuery(settings: Pick<Settings, "azureOpenaiAp
964
1137
  */
965
1138
  declare function lazySkillSourceWithPackSkills(packSkills: PackSkill[]): LocalDirLazySkillSource;
966
1139
 
967
- export { type AgentSegmentInput, type BuildAgentOptions, 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, DEFAULT_COMPACTION_THRESHOLD_RATIO, type ElideStaleScreenshotsOptions, type ElideStaleScreenshotsResult, GENESIS_TITLE_DIRECTIVE, type HistoryItem, MAX_COMPACTION_THRESHOLD_RATIO, MIN_COMPACTION_THRESHOLD_RATIO, type ModelResponseUsage, MultiProviderModelProvider, type NormalizedRuntimeEvent, type OpenGeniRuntime, type PackSkill, type PackSkillFile, type PrepareInputOptions, type PrepareToolsOptions, type PreparedAgentInput, type PreparedAgentTools, type ProductionRuntimeOverrides, type ResolveConnectionCredentialInput, type ResolveConnectionCredentialResult, type RunAgentStreamOptions, RuntimeMetricsHooks, SCREENSHOT_OMITTED_IMAGE_DATA_URL, SCREENSHOT_OMITTED_PLACEHOLDER, SUMMARY_BUFFER_TOKENS, SUMMARY_PREFIX, SandboxComputer, type SandboxComputerOptions, type SandboxFileDownload, type SandboxLifecycleHook, type SandboxLifecycleHookContext, type SandboxLifecycleHookPhase, TOOLSPACE_PROGRAMMATIC_DIRECTIVE, USER_MESSAGE_TRUNCATION_MARKER, type WorkspaceEnvironmentContext, agentsErrorRunState, appendGenesisTitleDirective, appendSessionInstructions, appendToolspaceInstructions, applyMissingManifestEntries, azureCliLoginCommand, azureOpenAIDefaultQuery, buildAgentCapabilities, buildCompactionPromptInput, buildCompactionReplacementHistory, buildDeterministicFallbackCompactionHistory, buildManifest, buildModelInstance, buildOpenAIClientFromSettings, buildOpenGeniAgent, buildProviderClient, buildSummaryItem, callModelInputFilterForSettings, clampCompactionThresholdRatio, clientCompactionThresholdTokens, composeAgentInstructions, computerUse, configureOpenAI, configureRuntimeMetricsHooks, contextRobustnessFilterForSettings, coreInstructions, createProductionAgentRuntime, decideClientCompaction, elideStaleScreenshotImages, enforceInputBudget, ensureReadableStreamFrom, estimateItemTokens, estimateTokens, extractResponseOutputText, findCompactionNeededError, findKeepBoundary, isCompactionSummary, isUserMessage, lazySkillSourceWithPackSkills, materializeSandboxFileDownloads, maxTurnsExceededRunState, mcpToolErrorOutput, modelResponseUsageFromSdkEvent, neutralizeToolSearchItemsInSerializedRunState, normalizeComputerCallsFilter, normalizeSdkEvent, normalizeToolOutputForEvent, prefixedMcpToolName, prepareAgentTools, prepareRunInput, renderCompactionPromptInputForChat, repositoryCloneCommand, repositoryUsesSandboxClone, resolveTurnModel, runAgentStream, runAzureCliLoginHook, runBeforeAgentStartHooks, runRepositoryCloneHook, runToolspaceTokenSeedHook, sandboxCommandExitCode, sandboxCommandOutput, sandboxCommandStillRunning, sandboxFileDownloadsForAgent, sandboxLifecycleHooksForIds, sandboxRunAs, sanitizeHistoryItemsForModel, serializeApprovals, stripProviderItemIdsFilter, stripReasoningEncryptedContent, stripReasoningIdentityFromSerializedRunState, summarizeForCompaction, toolspaceTokenSeedCommand, withManifestRefreshOnResume, withSandboxFileDownloads, withSandboxLifecycleHooks, workspaceEnvironmentInstructions };
1140
+ export { type AgentSegmentInput, type BuildAgentOptions, COMPACTION_PROMPT, COMPACTION_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, CodexSubscriptionUnavailableError, type CompactionDecision, type CompactionItem, CompactionNeededError, ComputerActionError, ComputerReadOnlyError, type ComputerToolMode, ComputerUnavailableError, type ComputerUseArgs, ComputerUseCapability, type ContextRobustnessFilterOptions, DEFAULT_COMPACTION_THRESHOLD_RATIO, GENESIS_TITLE_DIRECTIVE, type GitCredentialTokenWriterSession, type GitTokenSeeds, type HistoryItem, MAX_COMPACTION_THRESHOLD_RATIO, MIN_COMPACTION_THRESHOLD_RATIO, type ModelCallUsageTelemetry, type ModelResponseUsage, MultiProviderModelProvider, type NormalizedRuntimeEvent, type OpenGeniRuntime, type PackSkill, type PackSkillFile, type PersistentSessionSettings, type PrepareInputOptions, type PrepareToolsOptions, type PreparedAgentInput, type PreparedAgentTools, type ProductionRuntimeOverrides, type ResolveConnectionCredentialInput, type ResolveConnectionCredentialResult, type RigInstructionsContext, type RigSetupDescriptor, type RunAgentStreamOptions, RuntimeMetricsHooks, SUMMARY_BUFFER_TOKENS, SUMMARY_PREFIX, SandboxComputer, type SandboxComputerOptions, type SandboxFileDownload, type SandboxFileDownloadFailure, type SandboxFileDownloadMaterializationResult, type SandboxLifecycleHook, type SandboxLifecycleHookContext, type SandboxLifecycleHookPhase, TOOLSPACE_PROGRAMMATIC_DIRECTIVE, USER_MESSAGE_TRUNCATION_MARKER, type WorkspaceEnvironmentContext, WorkspaceModelPolicyBlockedError, agentsErrorRunState, appendGenesisTitleDirective, appendPersistentSessionSettings, appendSessionInstructions, appendToolspaceInstructions, appendWorkspaceMemory, applyMissingManifestEntries, azureCliLoginCommand, azureOpenAIDefaultQuery, buildAgentCapabilities, buildCompactionPromptInput, buildCompactionReplacementHistory, buildManifest, buildModelInstance, buildOpenAIClientFromSettings, buildOpenGeniAgent, buildProviderClient, buildSummaryItem, callModelInputFilterForSettings, clampCompactionThresholdRatio, compactionThresholdTokens, composeAgentInstructions, computerUse, configureOpenAI, configureRuntimeMetricsHooks, contextRobustnessFilterForSettings, coreInstructions, createProductionAgentRuntime, decideCompaction, elideSupersededViewImagePairs, elideSupersededViewImagesFilter, ensureReadableStreamFrom, estimateItemTokens, estimateTokens, extractResponseOutputText, findCompactionNeededError, gitProviderTokenRefreshCommand, isCompactionSummary, isEphemeralInternalContext, isUserMessage, lazySkillSourceWithPackSkills, manifestEnvironmentDrift, materializeSandboxFileDownloads, maxTurnsExceededRunState, mcpToolErrorOutput, modelCallUsageTelemetry, modelResponseUsageFromResponse, modelResponseUsageFromSdkEvent, neutralizeToolSearchItemsInSerializedRunState, normalizeComputerCallsFilter, normalizeSdkEvent, normalizeToolOutputForEvent, oneShotGenesisTitleInputFilter, pinProvidedSessionManifestEnvironment, prefixedMcpToolName, prepareAgentTools, prepareRunInput, refreshGitProviderTokenFiles, renderCompactionPromptInputForChat, repositoryCloneCommand, repositoryUsesSandboxClone, resolveTurnModel, rigInstructions, rigSetupScriptCommand, runAgentStream, runAzureCliLoginHook, runBeforeAgentStartHooks, runOwnedSandboxSetup, runRepositoryCloneHook, runRigSetupHook, runToolspaceTokenSeedHook, sandboxCommandExitCode, sandboxCommandOutput, sandboxCommandStillRunning, sandboxFileDownloadFailureNote, sandboxFileDownloadsForAgent, sandboxLifecycleHooksForIds, sandboxRunAs, sanitizeHistoryItemsForModel, serializeApprovals, stripProviderItemIdsFilter, stripReasoningEncryptedContent, stripReasoningIdentityFromSerializedRunState, summarizeForCompaction, toolspaceTokenSeedCommand, withManifestRefreshOnResume, withSandboxFileDownloads, withSandboxLifecycleHooks, withStructuredViewImageFunctionResults, workspaceEnvironmentInstructions };