@opengeni/runtime 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-DYBF7ZEB.js → chunk-RYDCVTMW.js} +1958 -207
- package/dist/chunk-RYDCVTMW.js.map +1 -0
- package/dist/{index-BTo_bZvN.d.ts → index-DIiiwQY2.d.ts} +689 -52
- package/dist/index.d.ts +293 -123
- package/dist/index.js +1819 -790
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +79 -3
- package/package.json +21 -20
- package/src/codex-tool-search.ts +185 -31
- package/src/context-compaction.ts +78 -243
- package/src/history-sanitizer.ts +172 -20
- package/src/index.ts +2573 -898
- package/src/metrics.ts +28 -2
- package/src/sandbox/capabilities.ts +12 -3
- package/src/sandbox/channel-a.ts +420 -72
- package/src/sandbox/display-stack.ts +18 -4
- package/src/sandbox/errors.ts +13 -0
- package/src/sandbox/index.ts +398 -112
- package/src/sandbox/op-correlation.ts +70 -0
- package/src/sandbox/providers/index.ts +9 -3
- package/src/sandbox/providers/modal.ts +84 -14
- package/src/sandbox/providers/selfhosted.ts +1 -4
- package/src/sandbox/recording.ts +146 -90
- package/src/sandbox/routing/backend-resolver.ts +144 -10
- package/src/sandbox/routing/routing-session.ts +129 -25
- package/src/sandbox/select.ts +60 -8
- package/src/sandbox/selfhosted/capabilities.ts +59 -25
- package/src/sandbox/selfhosted/control-rpc.ts +160 -28
- package/src/sandbox/selfhosted/fault-rendering.ts +226 -0
- package/src/sandbox/selfhosted/op-observer.ts +54 -0
- package/src/sandbox/selfhosted/op-stream.ts +801 -0
- package/src/sandbox/selfhosted/op-testing.ts +468 -0
- package/src/sandbox/selfhosted/op-transport.ts +151 -0
- package/src/sandbox/selfhosted/retry-policy.ts +177 -0
- package/src/sandbox/selfhosted/session.ts +498 -55
- package/src/sandbox/selfhosted/testing.ts +60 -19
- package/src/sandbox/stream-port.ts +17 -5
- package/src/sandbox/stream-token.ts +8 -2
- package/src/sandbox/terminal-server.ts +18 -4
- package/src/sandbox-computer.ts +332 -70
- package/src/usage-telemetry.ts +73 -0
- package/dist/chunk-DYBF7ZEB.js.map +0 -1
- package/src/image-history.ts +0 -149
- 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 {
|
|
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 {
|
|
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-
|
|
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
|
|
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 —
|
|
238
|
-
*
|
|
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
|
-
*
|
|
316
|
+
* Portable conversation context compaction, following Codex CLI's local path.
|
|
291
317
|
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
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.
|
|
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
|
|
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
|
|
351
|
+
declare function compactionThresholdTokens(input: {
|
|
324
352
|
contextWindowTokens: number;
|
|
325
353
|
contextReservedOutputTokens: number;
|
|
326
|
-
|
|
354
|
+
contextAutoCompactThresholdTokens?: number | null | undefined;
|
|
355
|
+
contextCompactionThresholdRatio?: number | null | undefined;
|
|
327
356
|
}): number;
|
|
328
|
-
type
|
|
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
|
|
363
|
+
declare function decideCompaction(input: {
|
|
335
364
|
items: readonly CompactionItem[];
|
|
336
365
|
lastInputTokens?: number | null;
|
|
337
366
|
contextWindowTokens: number;
|
|
338
367
|
contextReservedOutputTokens: number;
|
|
339
|
-
|
|
368
|
+
contextAutoCompactThresholdTokens?: number | null | undefined;
|
|
369
|
+
contextCompactionThresholdRatio?: number | null | undefined;
|
|
340
370
|
force?: boolean;
|
|
341
|
-
}):
|
|
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
|
-
*
|
|
381
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
406
|
-
type
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
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
|
|
416
|
-
|
|
417
|
-
|
|
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
|
-
|
|
458
|
-
|
|
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.
|
|
574
|
-
*
|
|
575
|
-
*
|
|
576
|
-
* request reasoning encryption, tools, or
|
|
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
|
|
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
|
-
|
|
594
|
-
|
|
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,22 @@ type WorkspaceEnvironmentContext = {
|
|
|
645
682
|
description?: string | null;
|
|
646
683
|
variableNames?: string[];
|
|
647
684
|
};
|
|
685
|
+
type PersistentSessionSettings = {
|
|
686
|
+
titleIsSet: boolean;
|
|
687
|
+
childNotificationsMode?: "digest" | "passive";
|
|
688
|
+
};
|
|
689
|
+
/**
|
|
690
|
+
* The rig a session rides (M3): its name + the active version pinned onto the
|
|
691
|
+
* session. Surfaced verbatim in the non-bypassable CORE instructions so the
|
|
692
|
+
* agent understands its sandbox is a disposable fork of a shared, versioned
|
|
693
|
+
* machine definition and how to promote a durable change. Absent for rig-less
|
|
694
|
+
* sessions (the block never renders).
|
|
695
|
+
*/
|
|
696
|
+
type RigInstructionsContext = {
|
|
697
|
+
name: string;
|
|
698
|
+
version: number;
|
|
699
|
+
};
|
|
700
|
+
declare function rigInstructions(rig: RigInstructionsContext): string[];
|
|
648
701
|
declare function workspaceEnvironmentInstructions(environment: WorkspaceEnvironmentContext): string[];
|
|
649
702
|
/**
|
|
650
703
|
* The non-bypassable CORE of the agent instructions: the goal-loop ownership
|
|
@@ -657,7 +710,7 @@ declare function workspaceEnvironmentInstructions(environment: WorkspaceEnvironm
|
|
|
657
710
|
* drop: composeAgentInstructions() substitutes it at the persona template's
|
|
658
711
|
* {{core}} marker, and appends it when the marker is absent.
|
|
659
712
|
*/
|
|
660
|
-
declare function coreInstructions(workspaceEnvironment?: WorkspaceEnvironmentContext): string[];
|
|
713
|
+
declare function coreInstructions(workspaceEnvironment?: WorkspaceEnvironmentContext, rig?: RigInstructionsContext): string[];
|
|
661
714
|
/**
|
|
662
715
|
* Composes the final agent instructions from a (possibly white-labelled)
|
|
663
716
|
* persona template and the non-bypassable CORE. The CORE is substituted at the
|
|
@@ -666,7 +719,7 @@ declare function coreInstructions(workspaceEnvironment?: WorkspaceEnvironmentCon
|
|
|
666
719
|
* and the append both join by " ", so the DEFAULT_AGENT_INSTRUCTIONS template
|
|
667
720
|
* with an empty environment reproduces the historical preamble byte-for-byte.
|
|
668
721
|
*/
|
|
669
|
-
declare function composeAgentInstructions(template: string, workspaceEnvironment?: WorkspaceEnvironmentContext): string;
|
|
722
|
+
declare function composeAgentInstructions(template: string, workspaceEnvironment?: WorkspaceEnvironmentContext, rig?: RigInstructionsContext): string;
|
|
670
723
|
/**
|
|
671
724
|
* Appends the per-session persona instructions to the already-composed
|
|
672
725
|
* (workspace + CORE) instructions, joined by " " — exactly the join used
|
|
@@ -675,6 +728,22 @@ declare function composeAgentInstructions(template: string, workspaceEnvironment
|
|
|
675
728
|
* is a no-op that returns the composed string byte-for-byte.
|
|
676
729
|
*/
|
|
677
730
|
declare function appendSessionInstructions(composed: string, sessionInstructions?: string): string;
|
|
731
|
+
/**
|
|
732
|
+
* Append the durable session metadata the model otherwise cannot observe.
|
|
733
|
+
* This is deliberately declarative and excludes the title text: the title is
|
|
734
|
+
* user-controlled display metadata, while the agent only needs to know whether
|
|
735
|
+
* initialization has already happened. The block is present on every turn when
|
|
736
|
+
* supplied so compaction cannot erase knowledge that these settings persist.
|
|
737
|
+
*/
|
|
738
|
+
declare function appendPersistentSessionSettings(composed: string, settings?: PersistentSessionSettings): string;
|
|
739
|
+
/**
|
|
740
|
+
* Appends the workspace memory working-set block to the already-composed
|
|
741
|
+
* (workspace + CORE + generic substrate) instructions, joined by " ". The
|
|
742
|
+
* memory slice is workspace-ground and intentionally lands before
|
|
743
|
+
* per-session instructions. An absent/blank value is a no-op that returns the
|
|
744
|
+
* composed string byte-for-byte.
|
|
745
|
+
*/
|
|
746
|
+
declare function appendWorkspaceMemory(composed: string, workspaceMemory?: string): string;
|
|
678
747
|
/**
|
|
679
748
|
* Appends the generic programmatic-tool-calling (toolspace) directive to the
|
|
680
749
|
* composed workspace + CORE instructions, joined by " ". This is GENERIC
|
|
@@ -730,34 +799,19 @@ declare function mcpToolErrorOutput(error: unknown): {
|
|
|
730
799
|
};
|
|
731
800
|
declare function buildOpenGeniAgent(settings: Settings, resources: ResourceRef[], options?: BuildAgentOptions): Agent<any, any>;
|
|
732
801
|
/**
|
|
733
|
-
*
|
|
734
|
-
*
|
|
735
|
-
* The SDK
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*
|
|
739
|
-
*
|
|
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.
|
|
802
|
+
* Codex accepts ordinary FUNCTION tools but also accepts `input_image` content
|
|
803
|
+
* inside a function_call_output (the same transport used by codex-rs
|
|
804
|
+
* view_image). The SDK filesystem capability unnecessarily couples this choice
|
|
805
|
+
* to hosted apply_patch support; when hosted tools are disabled it degrades
|
|
806
|
+
* view_image to a giant text data URL, charging roughly one token per four
|
|
807
|
+
* base64 characters. Re-wrap only successful data-URL results as a structured
|
|
808
|
+
* image. Text errors remain text, and the tool itself remains a normal function.
|
|
755
809
|
*/
|
|
810
|
+
declare function withStructuredViewImageFunctionResults(tools: Tool<unknown>[]): Tool<unknown>[];
|
|
756
811
|
declare function buildAgentCapabilities(settings: Settings, packSkills: PackSkill[], options?: {
|
|
757
|
-
compactionMode?: ContextCompactionMode;
|
|
758
|
-
contextWindowTokens?: number;
|
|
759
812
|
structuredToolTransport?: boolean;
|
|
760
813
|
computerToolMode?: ComputerToolMode;
|
|
814
|
+
onComputerUseReady?: (session: SandboxSessionLike) => Promise<void>;
|
|
761
815
|
}): ReturnType<typeof Capabilities.default>;
|
|
762
816
|
declare function sandboxRunAs(_settings: Settings): string | undefined;
|
|
763
817
|
type PreparedAgentTools = {
|
|
@@ -769,6 +823,7 @@ type PrepareToolsOptions = {
|
|
|
769
823
|
accountId?: string;
|
|
770
824
|
workspaceId?: string;
|
|
771
825
|
sessionId?: string;
|
|
826
|
+
turnId?: string;
|
|
772
827
|
subjectId?: string;
|
|
773
828
|
subjectLabel?: string;
|
|
774
829
|
firstPartyPermissions?: Permission[];
|
|
@@ -779,14 +834,6 @@ declare function prepareAgentTools(settings: Settings, tools: ToolRef[], options
|
|
|
779
834
|
declare function prefixedMcpToolName(registryId: string, toolName: string): string;
|
|
780
835
|
type PrepareInputOptions = {
|
|
781
836
|
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
837
|
};
|
|
791
838
|
declare function prepareRunInput(agent: Agent<any, any>, input: AgentSegmentInput, options?: PrepareInputOptions): Promise<PreparedAgentInput>;
|
|
792
839
|
type RunAgentStreamOptions = {
|
|
@@ -794,19 +841,32 @@ type RunAgentStreamOptions = {
|
|
|
794
841
|
sandboxEnvironment?: Record<string, string>;
|
|
795
842
|
onRuntimeEvent?: (event: NormalizedRuntimeEvent) => Promise<void> | void;
|
|
796
843
|
contextCompactionSignalTokens?: () => number | null | undefined;
|
|
844
|
+
contextCompactionRequested?: () => boolean | Promise<boolean>;
|
|
845
|
+
onGitCredentialSessionReady?: (session: GitCredentialTokenWriterSession) => Promise<void> | void;
|
|
797
846
|
ownedSandbox?: {
|
|
798
847
|
client: unknown;
|
|
799
848
|
session: unknown;
|
|
800
849
|
sessionState?: unknown;
|
|
801
850
|
setupSession?: unknown;
|
|
851
|
+
fileDownloadsMaterialized?: boolean;
|
|
852
|
+
deferredSetup?: boolean;
|
|
802
853
|
};
|
|
803
854
|
callModelInputFilter?: CallModelInputFilter;
|
|
804
855
|
};
|
|
805
856
|
type ContextRobustnessFilterOptions = {
|
|
806
857
|
contextCompactionSignalTokens?: () => number | null | undefined;
|
|
858
|
+
contextCompactionRequested?: () => boolean | Promise<boolean>;
|
|
807
859
|
throwOnCompactionNeeded?: boolean;
|
|
808
860
|
};
|
|
809
861
|
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.";
|
|
862
|
+
/**
|
|
863
|
+
* Inject the genesis-title directive into exactly one model request. Agent
|
|
864
|
+
* instructions are reused for every model call in a tool loop, so placing this
|
|
865
|
+
* directive there turned a nominally one-shot setup action into repeated title
|
|
866
|
+
* calls. The closure is intentionally consumed even when the first request
|
|
867
|
+
* fails: a retry/recovery must continue the task, not restart setup.
|
|
868
|
+
*/
|
|
869
|
+
declare function oneShotGenesisTitleInputFilter(): CallModelInputFilter;
|
|
810
870
|
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
871
|
/**
|
|
812
872
|
* callModelInputFilter that removes provider-assigned item ids (rs_/msg_/fc_…)
|
|
@@ -827,7 +887,7 @@ declare const stripProviderItemIdsFilter: CallModelInputFilter;
|
|
|
827
887
|
* `action` and `actions` down to EXACTLY ONE (keeps `actions`, drops `action`).
|
|
828
888
|
* The Azure computer-use endpoint rejects a request whose computer_call has
|
|
829
889
|
* both with `400 Computer call input must include exactly one of `action` or
|
|
830
|
-
* `actions``; and (live-proven against gpt-5.
|
|
890
|
+
* `actions``; and (live-proven against gpt-5.6-sol's GA computer tool) it also
|
|
831
891
|
* rejects the `action`-only form, accepting ONLY the batched plural `actions`.
|
|
832
892
|
* The SDK 0.11.6 schema allows both, so a freshly-emitted
|
|
833
893
|
* screenshot call carries the redundant pair. This filter runs before EVERY
|
|
@@ -837,13 +897,20 @@ declare const stripProviderItemIdsFilter: CallModelInputFilter;
|
|
|
837
897
|
* never mutated.
|
|
838
898
|
*/
|
|
839
899
|
declare const normalizeComputerCallsFilter: CallModelInputFilter;
|
|
900
|
+
/**
|
|
901
|
+
* Per-call state compaction for local image inspection. Re-opening the same
|
|
902
|
+
* path supersedes its prior base64 result; carrying both provides no newer
|
|
903
|
+
* information and can otherwise balloon every following model request.
|
|
904
|
+
*/
|
|
905
|
+
declare const elideSupersededViewImagesFilter: CallModelInputFilter;
|
|
840
906
|
declare function contextRobustnessFilterForSettings(settings: Settings, options?: ContextRobustnessFilterOptions): CallModelInputFilter;
|
|
841
907
|
/**
|
|
842
908
|
* The model-input filter applied before every model call. The computer_call
|
|
843
909
|
* action/actions normalizer is ALWAYS on (the Azure endpoint 400s without it);
|
|
844
910
|
* the provider-item-id strip is layered on top when the configured policy
|
|
845
|
-
* selects it; the context-robustness guard then
|
|
846
|
-
*
|
|
911
|
+
* selects it; the context-robustness guard then raises the proactive durable
|
|
912
|
+
* compaction signal on the client-compaction path. It never trims history from
|
|
913
|
+
* an individual request.
|
|
847
914
|
*/
|
|
848
915
|
declare function callModelInputFilterForSettings(settings: Settings, options?: ContextRobustnessFilterOptions): CallModelInputFilter | undefined;
|
|
849
916
|
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 +932,63 @@ declare function maxTurnsExceededRunState(error: unknown): {
|
|
|
865
932
|
* an error.
|
|
866
933
|
*/
|
|
867
934
|
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>;
|
|
935
|
+
declare function withManifestRefreshOnResume(client: SandboxClient, targetManifest: Manifest | undefined, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): SandboxClient;
|
|
936
|
+
declare function applyMissingManifestEntries(session: SandboxSessionLike, targetManifest: Manifest, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): Promise<void>;
|
|
937
|
+
/**
|
|
938
|
+
* Key-level diff of the live box's baked manifest env vs the freshly recomputed
|
|
939
|
+
* target env. Returns null when identical. Key NAMES only — values are secrets
|
|
940
|
+
* and must never leave this function's comparison.
|
|
941
|
+
*/
|
|
942
|
+
declare function manifestEnvironmentDrift(current: Manifest, target: Manifest): {
|
|
943
|
+
added: string[];
|
|
944
|
+
removed: string[];
|
|
945
|
+
changed: string[];
|
|
946
|
+
} | null;
|
|
947
|
+
/**
|
|
948
|
+
* ENV PIN for provided sessions (the ownership-inversion turn path). The SDK
|
|
949
|
+
* validates the FULL target manifest environment against a live provided
|
|
950
|
+
* session's baked env BEFORE reducing to its entry-only delta
|
|
951
|
+
* (validateNoEnvironmentDelta -> session-fatal UserError on ANY difference).
|
|
952
|
+
* So a turn resuming an existing box must declare the box's OWN env,
|
|
953
|
+
* byte-identical — never the fresh recompute. This replaces the agent's
|
|
954
|
+
* defaultManifest environment with the baked one and reports the drift (key
|
|
955
|
+
* names only) instead of letting it kill the session. Fresh env lands at the
|
|
956
|
+
* next cold-create; rotating values ride OFF-manifest (TOKEN-BROKER B1/B2).
|
|
957
|
+
*/
|
|
958
|
+
declare function pinProvidedSessionManifestEnvironment(agent: Agent<any, any>, session: SandboxSessionLike, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): Promise<void>;
|
|
959
|
+
/**
|
|
960
|
+
* The one-truth owned-path platform setup: the manifest-env pin (align the turn's
|
|
961
|
+
* manifest to the live box's baked env + report drift, NEVER die on it) plus the
|
|
962
|
+
* beforeAgentStart hooks (repository clone with B1 token/askpass seed, toolspace
|
|
963
|
+
* token seed, azure-cli-login) and signed-URL file materialization — all executed
|
|
964
|
+
* DIRECTLY against the pinned, UN-proxied established box (the SDK never calls
|
|
965
|
+
* client.create/resume for a provided session, so these decorations would never
|
|
966
|
+
* fire on their own).
|
|
967
|
+
*
|
|
968
|
+
* Extracted verbatim from `runStream`'s owned branch so both the EAGER path
|
|
969
|
+
* (runStream, before the run starts) and the LAZY path (the worker's first-op
|
|
970
|
+
* provisioner, after the box is established) run the IDENTICAL setup. A pure
|
|
971
|
+
* refactor for the eager path: same order, same gates, same idempotency
|
|
972
|
+
* (clone skips a materialized tree, token seed overwrites — the desired per-turn
|
|
973
|
+
* refresh, az login is idempotent). The connected-machine (selfhosted) branch
|
|
974
|
+
* keeps platform setup OFF the user's real box and seeds ONLY the toolspace token.
|
|
975
|
+
*
|
|
976
|
+
* `gitTokenSeedsOverride` lets the lazy provisioner pass its own freshly-minted
|
|
977
|
+
* run-scoped provider tokens (minted at establish time, not turn start);
|
|
978
|
+
* unset ⇒ read the seeds off the agent exactly as the eager path does.
|
|
979
|
+
*/
|
|
980
|
+
declare function runOwnedSandboxSetup(agent: Agent<any, any>, session: SandboxSessionLike, setupSession: SandboxSessionLike, opts: {
|
|
981
|
+
settings: Settings;
|
|
982
|
+
environment: Record<string, string>;
|
|
983
|
+
preparedInput?: PreparedAgentInput;
|
|
984
|
+
fileDownloadsMaterialized?: boolean;
|
|
985
|
+
onRuntimeEvent?: SandboxLifecycleHookContext["onRuntimeEvent"];
|
|
986
|
+
gitTokenSeedsOverride?: GitTokenSeeds;
|
|
987
|
+
gitTokenSeedOverride?: string;
|
|
988
|
+
}): Promise<void>;
|
|
870
989
|
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<
|
|
990
|
+
declare function materializeSandboxFileDownloads(session: SandboxSessionLike, downloads: SandboxFileDownload[], context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent" | "runAs">): Promise<SandboxFileDownloadMaterializationResult>;
|
|
991
|
+
declare function sandboxFileDownloadFailureNote(failures: SandboxFileDownloadFailure[]): string;
|
|
872
992
|
declare function sandboxFileDownloadsForAgent(agent: unknown): SandboxFileDownload[];
|
|
873
993
|
/**
|
|
874
994
|
* Compact a tool-call output for the `agent.toolCall.output` SESSION EVENT so it
|
|
@@ -888,6 +1008,8 @@ declare function sandboxFileDownloadsForAgent(agent: unknown): SandboxFileDownlo
|
|
|
888
1008
|
declare function normalizeToolOutputForEvent(output: unknown): unknown;
|
|
889
1009
|
declare function normalizeSdkEvent(event: RunStreamEvent): NormalizedRuntimeEvent[];
|
|
890
1010
|
declare function modelResponseUsageFromSdkEvent(event: RunStreamEvent): ModelResponseUsage | null;
|
|
1011
|
+
/** Normalize usage from either a Responses or Chat Completions result. */
|
|
1012
|
+
declare function modelResponseUsageFromResponse(response: unknown): ModelResponseUsage | null;
|
|
891
1013
|
declare function serializeApprovals(interruptions: unknown[]): unknown[];
|
|
892
1014
|
declare function buildManifest(settings: Settings, resources: ResourceRef[], environment?: Record<string, string>, fileResourceDownloads?: SandboxFileDownload[]): Manifest;
|
|
893
1015
|
type SandboxLifecycleHookPhase = "beforeAgentStart";
|
|
@@ -896,7 +1018,16 @@ type SandboxLifecycleHookContext = {
|
|
|
896
1018
|
onRuntimeEvent?: (event: NormalizedRuntimeEvent) => Promise<void> | void;
|
|
897
1019
|
runAs?: string;
|
|
898
1020
|
gitTokenSeed?: string;
|
|
1021
|
+
gitTokenSeeds?: GitTokenSeeds;
|
|
899
1022
|
toolspaceTokenSeed?: string;
|
|
1023
|
+
rigSetup?: RigSetupDescriptor;
|
|
1024
|
+
};
|
|
1025
|
+
type RigSetupDescriptor = {
|
|
1026
|
+
rigId: string;
|
|
1027
|
+
versionId: string;
|
|
1028
|
+
rigName: string;
|
|
1029
|
+
script: string;
|
|
1030
|
+
timeoutMs: number;
|
|
900
1031
|
};
|
|
901
1032
|
type SandboxLifecycleHook = {
|
|
902
1033
|
id: string;
|
|
@@ -939,11 +1070,50 @@ declare function withSandboxLifecycleHooks(client: SandboxClient, hooks: Sandbox
|
|
|
939
1070
|
declare function repositoryUsesSandboxClone(settings: Settings, resource: Extract<ResourceRef, {
|
|
940
1071
|
kind: "repository";
|
|
941
1072
|
}>, activeSandboxBackend?: Settings["sandboxBackend"]): boolean;
|
|
1073
|
+
/**
|
|
1074
|
+
* Build the off-manifest command used to atomically replace provider token files.
|
|
1075
|
+
*
|
|
1076
|
+
* Token values exist only in this one sandbox exec command. The stable askpass
|
|
1077
|
+
* and provider-CLI wrappers always read the files at invocation time, so an
|
|
1078
|
+
* in-flight multi-day turn observes the replacement without changing its
|
|
1079
|
+
* manifest environment or rebuilding the sandbox.
|
|
1080
|
+
*/
|
|
1081
|
+
declare function gitProviderTokenRefreshCommand(seeds: GitTokenSeeds): string;
|
|
1082
|
+
declare function refreshGitProviderTokenFiles(session: GitCredentialTokenWriterSession, seeds: GitTokenSeeds, options?: {
|
|
1083
|
+
runAs?: string;
|
|
1084
|
+
}): Promise<void>;
|
|
942
1085
|
declare function repositoryCloneCommand(resources: Extract<ResourceRef, {
|
|
943
1086
|
kind: "repository";
|
|
944
1087
|
}>[]): string;
|
|
945
1088
|
declare function toolspaceTokenSeedCommand(): string;
|
|
946
1089
|
declare function runToolspaceTokenSeedHook(session: SandboxSessionLike, context: SandboxLifecycleHookContext): Promise<void>;
|
|
1090
|
+
/**
|
|
1091
|
+
* The rig-setup command (M3). One idempotent bash program:
|
|
1092
|
+
* 1. `mkdir -p /var/opengeni` and, if the per-version marker already exists,
|
|
1093
|
+
* print the SKIP sentinel and exit 0 (a warm box re-running the hook).
|
|
1094
|
+
* 2. otherwise atomically claim a per-version lock directory. A loser waits
|
|
1095
|
+
* for the winner's marker, then skips; if the winner fails and releases the
|
|
1096
|
+
* lock, the loser retries the claim.
|
|
1097
|
+
* 3. the winner writes the rig's setup script to a temp file and runs it under
|
|
1098
|
+
* coreutils `timeout` (NOT `bash -e` — the script opts into `set -e`
|
|
1099
|
+
* itself if it wants), then captures the exit code and `touch`es the marker
|
|
1100
|
+
* ONLY on success (exit 0) so a failed/timed-out setup re-runs next turn.
|
|
1101
|
+
* The heredoc delimiter is quoted, so the script content is executed verbatim
|
|
1102
|
+
* with no host-side expansion.
|
|
1103
|
+
*/
|
|
1104
|
+
declare function rigSetupScriptCommand(script: string, versionId: string, timeoutMs?: number, markerRoot?: string): string;
|
|
1105
|
+
/**
|
|
1106
|
+
* The rig-setup beforeAgentStart hook (M3). Runs the frozen rig version's setup
|
|
1107
|
+
* script exactly once per box (marker-guarded), under the RIG's own timeout
|
|
1108
|
+
* (context.rigSetup.timeoutMs, NOT the 120s lifecycle default). Emits
|
|
1109
|
+
* rig.setup.started, then one terminal event:
|
|
1110
|
+
* - rig.setup.skipped — marker already present,
|
|
1111
|
+
* - rig.setup.completed — script ran and exited 0,
|
|
1112
|
+
* - rig.setup.failed — nonzero exit / timeout,
|
|
1113
|
+
* and on failure THROWS (fail the turn closed) with a message naming the
|
|
1114
|
+
* rig/version and a bounded tail of the setup output.
|
|
1115
|
+
*/
|
|
1116
|
+
declare function runRigSetupHook(session: SandboxSessionLike, context?: SandboxLifecycleHookContext): Promise<void>;
|
|
947
1117
|
declare function runRepositoryCloneHook(session: SandboxSessionLike, resources: Extract<ResourceRef, {
|
|
948
1118
|
kind: "repository";
|
|
949
1119
|
}>[], context?: SandboxLifecycleHookContext): Promise<void>;
|
|
@@ -964,4 +1134,4 @@ declare function azureOpenAIDefaultQuery(settings: Pick<Settings, "azureOpenaiAp
|
|
|
964
1134
|
*/
|
|
965
1135
|
declare function lazySkillSourceWithPackSkills(packSkills: PackSkill[]): LocalDirLazySkillSource;
|
|
966
1136
|
|
|
967
|
-
export { type AgentSegmentInput, type BuildAgentOptions, COMPACTION_PROMPT, COMPACTION_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, type
|
|
1137
|
+
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 };
|