@opengeni/runtime 0.14.1 → 0.14.15
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-4YJ5Z52Z.js → chunk-7E2ZSCZK.js} +6 -6
- package/dist/{chunk-4YJ5Z52Z.js.map → chunk-7E2ZSCZK.js.map} +1 -1
- package/dist/{chunk-HHWIZHQM.js → chunk-GNEGANUF.js} +942 -300
- package/dist/chunk-GNEGANUF.js.map +1 -0
- package/dist/codex-tool-search.d.ts +100 -0
- package/dist/context-compaction.d.ts +236 -0
- package/dist/history-sanitizer.d.ts +320 -0
- package/dist/index.d.ts +186 -718
- package/dist/index.js +612 -126
- package/dist/index.js.map +1 -1
- package/dist/{localSources-T3HZ6KY4.js → localSources-BXHBKGF4.js} +2 -2
- package/dist/mcp-network.d.ts +32 -35
- package/dist/metrics.d.ts +33 -0
- package/dist/sandbox/capabilities.d.ts +11 -0
- package/dist/sandbox/channel-a.d.ts +226 -0
- package/dist/sandbox/display-stack.d.ts +99 -0
- package/dist/sandbox/errors.d.ts +16 -0
- package/dist/sandbox/exec-banner.d.ts +19 -0
- package/dist/sandbox/index.d.ts +190 -6
- package/dist/sandbox/index.js +20 -4
- package/dist/sandbox/op-correlation.d.ts +24 -0
- package/dist/sandbox/provider-errors.d.ts +32 -0
- package/dist/sandbox/provider-operation-gate.d.ts +12 -0
- package/dist/sandbox/providers/blaxel.d.ts +2 -0
- package/dist/sandbox/providers/cloudflare.d.ts +2 -0
- package/dist/sandbox/providers/daytona.d.ts +2 -0
- package/dist/sandbox/providers/docker.d.ts +2 -0
- package/dist/sandbox/providers/e2b.d.ts +2 -0
- package/dist/sandbox/providers/index.d.ts +11 -0
- package/dist/sandbox/providers/local.d.ts +2 -0
- package/dist/sandbox/providers/modal.d.ts +132 -0
- package/dist/sandbox/providers/none.d.ts +2 -0
- package/dist/sandbox/providers/runloop.d.ts +2 -0
- package/dist/sandbox/providers/selfhosted.d.ts +2 -0
- package/dist/sandbox/providers/types.d.ts +30 -0
- package/dist/sandbox/providers/vercel.d.ts +2 -0
- package/dist/sandbox/recording.d.ts +80 -0
- package/dist/sandbox/routing/backend-resolver.d.ts +173 -0
- package/dist/sandbox/routing/routing-session.d.ts +401 -0
- package/dist/sandbox/run-credentials.d.ts +65 -0
- package/dist/sandbox/select.d.ts +120 -0
- package/dist/sandbox/selfhosted/capabilities.d.ts +91 -0
- package/dist/sandbox/selfhosted/control-rpc.d.ts +175 -0
- package/dist/sandbox/selfhosted/fault-rendering.d.ts +40 -0
- package/dist/sandbox/selfhosted/op-observer.d.ts +40 -0
- package/dist/sandbox/selfhosted/op-stream.d.ts +104 -0
- package/dist/sandbox/selfhosted/op-testing.d.ts +108 -0
- package/dist/sandbox/selfhosted/op-transport.d.ts +60 -0
- package/dist/sandbox/selfhosted/retry-policy.d.ts +106 -0
- package/dist/sandbox/selfhosted/session.d.ts +552 -0
- package/dist/sandbox/selfhosted/testing.d.ts +48 -0
- package/dist/sandbox/stream-port.d.ts +80 -0
- package/dist/sandbox/stream-token.d.ts +44 -0
- package/dist/sandbox/terminal-server.d.ts +67 -0
- package/dist/sandbox/toolspace-token.d.ts +23 -0
- package/dist/sandbox/turn-tool-cancellation.d.ts +72 -0
- package/dist/sandbox/workspace-archive.d.ts +39 -0
- package/dist/sandbox-computer.d.ts +227 -0
- package/dist/screenshot-error-card.d.ts +1 -0
- package/dist/skill-library.d.ts +10 -12
- package/dist/usage-telemetry.d.ts +45 -0
- package/dist/workspace-skills.d.ts +31 -0
- package/package.json +7 -7
- package/src/context-compaction.ts +600 -6
- package/src/history-sanitizer.ts +10 -92
- package/src/index.ts +301 -62
- package/src/sandbox/channel-a.ts +267 -81
- package/src/sandbox/index.ts +56 -94
- package/src/sandbox/provider-operation-gate.ts +110 -0
- package/src/sandbox/providers/docker.ts +13 -1
- package/src/sandbox/providers/modal.ts +433 -3
- package/src/sandbox/routing/routing-session.ts +84 -8
- package/src/sandbox/selfhosted/session.ts +7 -6
- package/src/sandbox/turn-tool-cancellation.ts +47 -7
- package/src/sandbox/workspace-archive.ts +176 -73
- package/src/sandbox-computer.ts +25 -75
- package/dist/chunk-HHWIZHQM.js.map +0 -1
- package/dist/index-BraazrAO.d.ts +0 -2931
- /package/dist/{localSources-T3HZ6KY4.js.map → localSources-BXHBKGF4.js.map} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,596 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
type
|
|
26
|
-
/**
|
|
27
|
-
* Marker stored on the synthetic summary item so the UI can render it and the
|
|
28
|
-
* next rebuild can exclude old summaries from the retained user-message set.
|
|
29
|
-
*/
|
|
30
|
-
declare const COMPACTION_SUMMARY_MARKER = "opengeni_context_summary";
|
|
31
|
-
declare const SUMMARY_BUFFER_TOKENS = 20000;
|
|
32
|
-
declare const COMPACT_USER_MESSAGE_MAX_TOKENS = 20000;
|
|
33
|
-
declare const DEFAULT_COMPACTION_THRESHOLD_RATIO = 0.9;
|
|
34
|
-
declare const MIN_COMPACTION_THRESHOLD_RATIO = 0.3;
|
|
35
|
-
declare const MAX_COMPACTION_THRESHOLD_RATIO = 0.9;
|
|
36
|
-
declare const COMPACTION_PROMPT: string;
|
|
37
|
-
declare const SUMMARY_PREFIX = "Another language model started to solve this problem and produced a summary of its thinking process. You also have access to the state of the tools that were used by that language model. Use this to build on the work that has already been done and avoid duplicating work. Here is the summary produced by the other language model, use the information in this summary to assist with your own analysis:";
|
|
38
|
-
declare const USER_MESSAGE_TRUNCATION_MARKER = "\n[... middle truncated for context compaction ...]\n";
|
|
39
|
-
/** A user-authored `message` item is the only legal turn boundary. */
|
|
40
|
-
declare function isUserMessage(item: unknown): boolean;
|
|
41
|
-
/** True for our synthetic compaction summary item. */
|
|
42
|
-
declare function isCompactionSummary(item: unknown): boolean;
|
|
43
|
-
/** Serialized-item estimate for pre-call accounting and retained user budgets. */
|
|
44
|
-
declare function estimateItemTokens(item: CompactionItem): number;
|
|
45
|
-
declare function estimateTokens(items: readonly CompactionItem[]): number;
|
|
46
|
-
declare function estimateSerializedValueTokens(value: unknown): number;
|
|
47
|
-
type CompleteModelInputFootprint = {
|
|
48
|
-
input: readonly CompactionItem[];
|
|
49
|
-
instructionsTokens: number;
|
|
50
|
-
toolSchemaTokens: number;
|
|
51
|
-
};
|
|
52
|
-
type ProviderContextTokenSignal = {
|
|
53
|
-
/** Monotonic within one sampled run; advances after every model response. */
|
|
54
|
-
revision: number;
|
|
55
|
-
/** Provider total tokens after that response (input + generated output). */
|
|
56
|
-
totalTokens: number;
|
|
57
|
-
};
|
|
58
|
-
type CompleteModelInputEstimate = {
|
|
59
|
-
tokens: number;
|
|
60
|
-
source: "complete_estimate" | "provider_plus_local";
|
|
61
|
-
inputTokens: number;
|
|
62
|
-
instructionsTokens: number;
|
|
63
|
-
toolSchemaTokens: number;
|
|
64
|
-
appendedAfterModelTokens: number;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Match Codex history accounting: after one provider response, start from its
|
|
68
|
-
* authoritative TOTAL token count and add only local items placed after the
|
|
69
|
-
* newest model-generated item. System instructions and tool schemas are
|
|
70
|
-
* compared with the exact request footprint that produced the provider count;
|
|
71
|
-
* positive growth is added. Without a bound anchor, estimate the entire
|
|
72
|
-
* outgoing request rather than trusting stale usage from an earlier turn.
|
|
73
|
-
*/
|
|
74
|
-
declare function estimateCompleteModelInput(input: {
|
|
75
|
-
current: CompleteModelInputFootprint;
|
|
76
|
-
provider?: ProviderContextTokenSignal | null;
|
|
77
|
-
providerRequestFootprint?: CompleteModelInputFootprint | null;
|
|
78
|
-
}): CompleteModelInputEstimate;
|
|
79
|
-
declare function hasModelGeneratedItem(items: readonly CompactionItem[]): boolean;
|
|
80
|
-
declare function clampCompactionThresholdRatio(value: number | undefined | null): number;
|
|
81
|
-
declare function compactionThresholdTokens(input: {
|
|
82
|
-
contextWindowTokens: number;
|
|
83
|
-
contextReservedOutputTokens: number;
|
|
84
|
-
contextAutoCompactThresholdTokens?: number | null | undefined;
|
|
85
|
-
contextCompactionThresholdRatio?: number | null | undefined;
|
|
86
|
-
}): number;
|
|
87
|
-
type CompactionDecision = {
|
|
88
|
-
shouldCompact: boolean;
|
|
89
|
-
reason: "force" | "above_threshold" | "below_threshold" | "no_history";
|
|
90
|
-
signalTokens: number;
|
|
91
|
-
thresholdTokens: number;
|
|
92
|
-
};
|
|
93
|
-
declare function decideCompaction(input: {
|
|
94
|
-
items: readonly CompactionItem[];
|
|
95
|
-
lastInputTokens?: number | null;
|
|
96
|
-
contextWindowTokens: number;
|
|
97
|
-
contextReservedOutputTokens: number;
|
|
98
|
-
contextAutoCompactThresholdTokens?: number | null | undefined;
|
|
99
|
-
contextCompactionThresholdRatio?: number | null | undefined;
|
|
100
|
-
force?: boolean;
|
|
101
|
-
}): CompactionDecision;
|
|
102
|
-
declare class CompactionNeededError extends Error {
|
|
103
|
-
readonly signalTokens: number;
|
|
104
|
-
readonly thresholdTokens: number;
|
|
105
|
-
readonly signalSource: "provider" | "estimate";
|
|
106
|
-
readonly trigger: "threshold" | "operator";
|
|
107
|
-
constructor(input: {
|
|
108
|
-
signalTokens: number;
|
|
109
|
-
thresholdTokens: number;
|
|
110
|
-
signalSource: "provider" | "estimate";
|
|
111
|
-
trigger?: "threshold" | "operator";
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
declare class EmptyCompactionSummaryError extends Error {
|
|
115
|
-
readonly diagnostics: Record<string, unknown>;
|
|
116
|
-
constructor(diagnostics?: Record<string, unknown>);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* The checkpoint model request ended in a provider/transport failure rather
|
|
120
|
-
* than a successful response with an empty assistant message. Diagnostics are
|
|
121
|
-
* deliberately bounded and content-free so this error can be persisted on a
|
|
122
|
-
* turn without copying provider messages or conversation input into events.
|
|
123
|
-
*/
|
|
124
|
-
declare class CompactionProviderResponseError extends Error {
|
|
125
|
-
readonly diagnostics: Record<string, unknown>;
|
|
126
|
-
readonly status?: number;
|
|
127
|
-
readonly code?: string;
|
|
128
|
-
readonly type?: string;
|
|
129
|
-
readonly cause?: unknown;
|
|
130
|
-
constructor(diagnostics?: Record<string, unknown>, cause?: unknown);
|
|
131
|
-
}
|
|
132
|
-
declare function findCompactionNeededError(error: unknown, seen?: WeakSet<object>): CompactionNeededError | null;
|
|
133
|
-
/**
|
|
134
|
-
* The exact checkpoint input shape: current active history followed by Codex's
|
|
135
|
-
* checkpoint prompt as a synthesized user message.
|
|
136
|
-
*/
|
|
137
|
-
declare function buildCompactionPromptInput(items: readonly CompactionItem[]): CompactionItem[];
|
|
138
|
-
type PreparedCompactionPromptInput = {
|
|
139
|
-
input: CompactionItem[];
|
|
140
|
-
estimatedInputTokens: number;
|
|
141
|
-
rewrittenToolOutputs: number;
|
|
142
|
-
droppedHistoryItems: number;
|
|
143
|
-
};
|
|
144
|
-
/**
|
|
145
|
-
* Fit the explicit checkpoint request without mutating canonical history.
|
|
146
|
-
*
|
|
147
|
-
* Codex first replaces oversized tool outputs in its temporary remote-
|
|
148
|
-
* compaction input. OpenGeni does the same oldest-first, preserving the most
|
|
149
|
-
* recent tool detail for the plaintext summary. If that is still insufficient,
|
|
150
|
-
* whole oldest user-delimited work units are removed and the remaining suffix
|
|
151
|
-
* is protocol-sanitized so no call/result/reasoning fragment is orphaned.
|
|
152
|
-
* The raw active history is still the source for the eventual replacement and
|
|
153
|
-
* remains unchanged if the provider call fails.
|
|
154
|
-
*/
|
|
155
|
-
declare function prepareCompactionPromptInput(items: readonly CompactionItem[], maxInputTokens: number): PreparedCompactionPromptInput;
|
|
156
|
-
/**
|
|
157
|
-
* Build the active history after compaction:
|
|
158
|
-
* the newest real user messages that fit one cumulative 20k-token budget
|
|
159
|
-
* (prior summaries excluded, images removed) plus one marked summary item.
|
|
160
|
-
*/
|
|
161
|
-
declare function buildCompactionReplacementHistory(items: readonly CompactionItem[], summaryBody: string): CompactionItem[];
|
|
162
|
-
declare function compactionReplacementFingerprint(items: readonly CompactionItem[]): string;
|
|
163
|
-
/** Fingerprint the latest durable replacement prefix in active history. */
|
|
164
|
-
declare function latestCompactionReplacementFingerprint(items: readonly CompactionItem[]): string | null;
|
|
165
|
-
/**
|
|
166
|
-
* Build the synthetic summary item (a plain user message) appended to the
|
|
167
|
-
* rebuilt active history.
|
|
168
|
-
*/
|
|
169
|
-
declare function buildSummaryItem(summaryBody: string): CompactionItem;
|
|
170
|
-
declare function renderCompactionPromptInputForChat(input: readonly CompactionItem[]): string;
|
|
171
|
-
|
|
172
|
-
type CommandCancellationSession = {
|
|
173
|
-
cancelExecCommand?(opId: string): Promise<boolean>;
|
|
174
|
-
supportsPty?(): boolean;
|
|
175
|
-
hasRetainedProcess?(providerSessionId: number): boolean;
|
|
176
|
-
writeStdinForProcessMutation?(args: {
|
|
177
|
-
sessionId: number;
|
|
178
|
-
chars?: string;
|
|
179
|
-
yieldTimeMs?: number;
|
|
180
|
-
maxOutputTokens?: number;
|
|
181
|
-
}): Promise<string>;
|
|
182
|
-
writeStdinForProcessControl?(args: {
|
|
183
|
-
sessionId: number;
|
|
184
|
-
chars?: string;
|
|
185
|
-
yieldTimeMs?: number;
|
|
186
|
-
maxOutputTokens?: number;
|
|
187
|
-
}): Promise<string>;
|
|
188
|
-
execCommandForProcessControl?(providerSessionId: number, args: TurnSandboxCommandArgs): Promise<string>;
|
|
189
|
-
};
|
|
190
|
-
type TurnSandboxCommandArgs = {
|
|
191
|
-
cmd: string;
|
|
192
|
-
workdir?: string;
|
|
193
|
-
shell?: string;
|
|
194
|
-
login?: boolean;
|
|
195
|
-
tty?: boolean;
|
|
196
|
-
yieldTimeMs?: number;
|
|
197
|
-
maxOutputTokens?: number;
|
|
198
|
-
runAs?: string;
|
|
199
|
-
};
|
|
200
|
-
type TurnSandboxCommandResult = {
|
|
201
|
-
stdout: string;
|
|
202
|
-
stderr: string;
|
|
203
|
-
exitCode: number;
|
|
204
|
-
wallTimeSeconds: number;
|
|
205
|
-
};
|
|
206
|
-
type TurnSandboxCommandSession = CommandCancellationSession & {
|
|
207
|
-
exec?(args: TurnSandboxCommandArgs): Promise<unknown>;
|
|
208
|
-
execCommand?(args: TurnSandboxCommandArgs): Promise<string>;
|
|
209
|
-
writeStdin?(args: {
|
|
210
|
-
sessionId: number;
|
|
211
|
-
chars?: string;
|
|
212
|
-
yieldTimeMs?: number;
|
|
213
|
-
maxOutputTokens?: number;
|
|
214
|
-
}): Promise<string>;
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* The worker may publish an attempt-quiesced receipt only after this fence
|
|
218
|
-
* resolves. `cancel()` prevents new turn-owned sandbox calls, actively stops
|
|
219
|
-
* shell processes, and `waitForQuiescence()` drains every capability call that
|
|
220
|
-
* was already in flight. Cleanup/telemetry outside the sandbox capability set
|
|
221
|
-
* remains independently attempt-fenced.
|
|
222
|
-
*/
|
|
223
|
-
type TurnToolCancellationFence = {
|
|
224
|
-
cancel(reason?: unknown): void;
|
|
225
|
-
waitForQuiescence(): Promise<void>;
|
|
226
|
-
runSandboxCommand(session: TurnSandboxCommandSession, args: TurnSandboxCommandArgs): Promise<unknown>;
|
|
227
|
-
runSandboxCommandStructured(session: TurnSandboxCommandSession, args: TurnSandboxCommandArgs): Promise<TurnSandboxCommandResult>;
|
|
228
|
-
};
|
|
229
|
-
type TurnToolCancellationController = TurnToolCancellationFence & {
|
|
230
|
-
wrapTools<T>(tools: T[], session?: CommandCancellationSession): T[];
|
|
231
|
-
};
|
|
232
|
-
declare class TurnSandboxCommandCancelledError extends Error {
|
|
233
|
-
readonly name = "TurnSandboxCommandCancelledError";
|
|
234
|
-
constructor(reason: unknown);
|
|
235
|
-
}
|
|
236
|
-
declare function createTurnToolCancellationController(signal?: AbortSignal): TurnToolCancellationController;
|
|
237
|
-
|
|
238
|
-
type ComputerButton = "left" | "right" | "wheel" | "back" | "forward";
|
|
239
|
-
type SandboxComputerOptions = {
|
|
240
|
-
display?: string;
|
|
241
|
-
dimensions?: [number, number];
|
|
242
|
-
runAs?: string;
|
|
243
|
-
typeDelayMs?: number;
|
|
244
|
-
readOnly?: boolean;
|
|
245
|
-
screenshotTmpDir?: string;
|
|
246
|
-
screenshotWarmupBudgetMs?: number;
|
|
247
|
-
screenshotRetryDelayMs?: number;
|
|
248
|
-
/**
|
|
249
|
-
* One turn-scoped preparation hook, invoked by the first real computer action.
|
|
250
|
-
* The agent may advertise computer-use on every turn, but merely advertising the
|
|
251
|
-
* tool must not boot Xvfb/XFCE or start a recording. The runtime capability owns
|
|
252
|
-
* this hook and uses it to bring up :0 (and optionally notify the worker) only
|
|
253
|
-
* after the model actually chooses a computer tool.
|
|
254
|
-
*/
|
|
255
|
-
prepare?: (session: SandboxSessionLike) => Promise<void>;
|
|
256
|
-
};
|
|
257
|
-
/** No exec/execCommand on the session, or the display is not up. */
|
|
258
|
-
declare class ComputerUnavailableError extends Error {
|
|
259
|
-
constructor(message: string);
|
|
260
|
-
}
|
|
261
|
-
/** A write action attempted while readOnly. */
|
|
262
|
-
declare class ComputerReadOnlyError extends Error {
|
|
263
|
-
constructor();
|
|
264
|
-
}
|
|
265
|
-
/** A nonzero xdotool/scrot exit, OR a command that did not finish before the
|
|
266
|
-
* yield window (F3 — "still running" is a failure, not a silent success). */
|
|
267
|
-
declare class ComputerActionError extends Error {
|
|
268
|
-
cmd: string;
|
|
269
|
-
exitCode: number;
|
|
270
|
-
stderr: string;
|
|
271
|
-
constructor(cmd: string, exitCode: number, stderr: string);
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* The Computer the agent drives. Every action issues ONE shell line through the
|
|
275
|
-
* externally-owned session (exec ?? execCommand, F1), prefixed with the display.
|
|
276
|
-
* screenshot() scrots to a /tmp file and reads the RAW bytes by running
|
|
277
|
-
* `base64 <path>` over the SAME command primitive and stripping the banner — NOT
|
|
278
|
-
* `session.readFile` (Modal's readFile path-validates against /workspace and rejects
|
|
279
|
-
* /tmp with "escapes the workspace root", which would yield an empty frame and 400
|
|
280
|
-
* the model). The base64-over-exec path is /tmp-readable and binary-safe.
|
|
281
|
-
*/
|
|
282
|
-
declare class SandboxComputer implements Computer {
|
|
283
|
-
readonly environment: "ubuntu";
|
|
284
|
-
readonly dimensions: [number, number];
|
|
285
|
-
private session;
|
|
286
|
-
private readonly display;
|
|
287
|
-
private readonly runAs?;
|
|
288
|
-
private readonly typeDelayMs;
|
|
289
|
-
private readonly readOnly;
|
|
290
|
-
private readonly tmp;
|
|
291
|
-
private readonly screenshotWarmupBudgetMs;
|
|
292
|
-
private readonly screenshotRetryDelayMs;
|
|
293
|
-
private readonly prepare;
|
|
294
|
-
private prepared;
|
|
295
|
-
private preparation;
|
|
296
|
-
constructor(session: SandboxSessionLike, opts?: SandboxComputerOptions);
|
|
297
|
-
/** Rebind to a freshly resumed-by-id session after a box rollover / re-establish. */
|
|
298
|
-
rebind(session: SandboxSessionLike): void;
|
|
299
|
-
private prepareOnce;
|
|
300
|
-
private x;
|
|
301
|
-
private guardWrite;
|
|
302
|
-
private shq;
|
|
303
|
-
screenshot(): Promise<string>;
|
|
304
|
-
private readCmdRaw;
|
|
305
|
-
private readScreenshotBytes;
|
|
306
|
-
click(xp: number, yp: number, button: ComputerButton): Promise<void>;
|
|
307
|
-
doubleClick(xp: number, yp: number): Promise<void>;
|
|
308
|
-
move(xp: number, yp: number): Promise<void>;
|
|
309
|
-
scroll(xp: number, yp: number, sx: number, sy: number): Promise<void>;
|
|
310
|
-
type(text: string): Promise<void>;
|
|
311
|
-
keypress(keys: string[]): Promise<void>;
|
|
312
|
-
drag(path: [number, number][]): Promise<void>;
|
|
313
|
-
wait(): Promise<void>;
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* EXPLICIT tool-transport selection, decided by the caller that knows the
|
|
317
|
-
* provider's true wire identity (the worker's model resolution — see agent-turn.ts),
|
|
318
|
-
* NOT inferred from the bound model instance's constructor name. This is the
|
|
319
|
-
* HARDENING seam: `supportsStructuredToolOutputTransport` string-sniffs the
|
|
320
|
-
* constructor for "ChatCompletions", which a wrapped / proxied / minified model
|
|
321
|
-
* instance would defeat — silently handing a chat-completions provider the HOSTED
|
|
322
|
-
* `computer_use_preview` tool it 400s on every turn. When `toolMode` is set, tools()
|
|
323
|
-
* OBEYS it and never consults the sniff:
|
|
324
|
-
* • "hosted" → the single hosted `computer_use_preview` tool (Responses backends).
|
|
325
|
-
* • "function-image" → the FUNCTION `computer_*` tools with screenshots delivered as a
|
|
326
|
-
* structured `{type:'image'}` output (the codex/ChatGPT backend,
|
|
327
|
-
* which rejects hosted tool types but SEES structured image results).
|
|
328
|
-
* • "function-text" → the FUNCTION tools with screenshots rendered as a text
|
|
329
|
-
* `data:…;base64` URL (chat-completions providers, which can't read
|
|
330
|
-
* structured image tool results).
|
|
331
|
-
*/
|
|
332
|
-
type ComputerToolMode = "hosted" | "function-image" | "function-text";
|
|
333
|
-
type ComputerUseArgs = {
|
|
334
|
-
dimensions?: [number, number];
|
|
335
|
-
readOnly?: boolean;
|
|
336
|
-
display?: string;
|
|
337
|
-
needsApproval?: boolean | ((ctx: unknown, action: unknown) => boolean | Promise<boolean>);
|
|
338
|
-
imageFunctionResults?: boolean;
|
|
339
|
-
toolMode?: ComputerToolMode;
|
|
340
|
-
/** Called after the display is ready on the first actual computer action. */
|
|
341
|
-
onReady?: (session: SandboxSessionLike) => Promise<void>;
|
|
342
|
-
};
|
|
343
|
-
declare function computerUse(args?: ComputerUseArgs): ComputerUseCapability;
|
|
344
|
-
/**
|
|
345
|
-
* A `Capability` subclass merged into the agent's tool set by SandboxAgent
|
|
346
|
-
* (`tools = [...agent.tools, ...capability.tools()]`). `bind(session)` hands it
|
|
347
|
-
* the LIVE externally-owned session, so the agent's actions and the viewers'
|
|
348
|
-
* pixels are one display.
|
|
349
|
-
*
|
|
350
|
-
* `tools()` is TRANSPORT-AWARE, mirroring the SDK's `filesystem()` capability
|
|
351
|
-
* (which branches its `view_image` / `apply_patch` on
|
|
352
|
-
* `supportsStructuredToolOutputTransport(this._modelInstance)`):
|
|
353
|
-
* • structured transport (the Responses/OpenAI backend) → the single HOSTED
|
|
354
|
-
* `computer_use_preview` tool over a Computer bound to the session (unchanged).
|
|
355
|
-
* • text transport (codex / ChatGPT backend — or an unbound model) → a set of
|
|
356
|
-
* FUNCTION tools ({@link computerFunctionTools}) that route to the SAME Computer,
|
|
357
|
-
* because the codex backend rejects the hosted computer tool type.
|
|
358
|
-
* The bound model instance is captured by the SDK's `bind().bindRunAs().bindModel()`
|
|
359
|
-
* chain (base `Capability._modelInstance`); the codex path in index.ts neutralizes
|
|
360
|
-
* `bindModel` so `_modelInstance` stays undefined here → the function tools win.
|
|
361
|
-
*/
|
|
362
|
-
declare class ComputerUseCapability extends Capability {
|
|
363
|
-
private args;
|
|
364
|
-
readonly type = "computer-use";
|
|
365
|
-
constructor(args?: ComputerUseArgs);
|
|
366
|
-
tools(): Tool<unknown>[];
|
|
367
|
-
/** The single HOSTED `computer_use_preview` tool bound to `computer` — identical
|
|
368
|
-
* construction for the explicit "hosted" mode and the legacy structured-sniff path. */
|
|
369
|
-
private hostedComputerTool;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
type WorkspaceSkillSearchPath = Readonly<{
|
|
373
|
-
path: string;
|
|
374
|
-
source: string;
|
|
375
|
-
}>;
|
|
376
|
-
|
|
377
|
-
/**
|
|
378
|
-
* Read-path sanitizer for replayed conversation history (issue: orphaned
|
|
379
|
-
* tool outputs brick a session).
|
|
380
|
-
*
|
|
381
|
-
* Conversation truth is persisted as a flat list of SDK history items in
|
|
382
|
-
* `session_history_items` and replayed verbatim into the model on every turn.
|
|
383
|
-
* The OpenAI Responses API rejects the whole request (HTTP 400) when that list
|
|
384
|
-
* violates its tool-call pairing rules — most destructively:
|
|
385
|
-
*
|
|
386
|
-
* `400 No tool call found for function call output with call_id <X>`
|
|
387
|
-
*
|
|
388
|
-
* when a `function_call_result` (a.k.a. function_call_output) has no matching
|
|
389
|
-
* `function_call` earlier in the list. Because the corrupt item is replayed on
|
|
390
|
-
* every subsequent turn, one orphaned output permanently bricks the session
|
|
391
|
-
* across revival — it stays dead until the row is hand-deleted.
|
|
392
|
-
*
|
|
393
|
-
* This module is the reliability net: before history items are sent to the
|
|
394
|
-
* model they pass through `sanitizeHistoryItemsForModel`, which removes any
|
|
395
|
-
* item that would make the request invalid. It mirrors the SDK's own
|
|
396
|
-
* `dropOrphanToolCalls` continuation logic (which only runs over the SDK's
|
|
397
|
-
* in-memory `state.history`, not over rows we reload from the database) so a
|
|
398
|
-
* reloaded history is shaped exactly like a freshly-generated one.
|
|
399
|
-
*
|
|
400
|
-
* It is a pure function over plain JSON item shapes (no SDK import, no I/O) so
|
|
401
|
-
* it is cheap to unit-test exhaustively. It NEVER mutates its input items and
|
|
402
|
-
* NEVER touches the stored rows — only the in-memory copy sent to the model is
|
|
403
|
-
* filtered, keeping the persisted audit trail intact.
|
|
404
|
-
*/
|
|
405
|
-
/** A history item is any JSON object; we only inspect a few discriminator fields. */
|
|
406
|
-
type HistoryItem = Record<string, unknown>;
|
|
407
|
-
/**
|
|
408
|
-
* Remove superseded `view_image` call/result pairs for the SAME local path,
|
|
409
|
-
* retaining the newest fully-paired observation. A `view_image` result can be
|
|
410
|
-
* hundreds of kilobytes of base64. When a model re-opens the same attachment,
|
|
411
|
-
* replaying every older copy on each subsequent model call grows input
|
|
412
|
-
* quadratically and can trap a turn in context-compaction/requeue recovery.
|
|
413
|
-
*
|
|
414
|
-
* This is state-based rather than count-based: every distinct path is kept,
|
|
415
|
-
* and an older observation is removed only after a newer successful pair for
|
|
416
|
-
* that exact path exists. The reasoning items immediately attached to a
|
|
417
|
-
* removed call are removed with it, preserving Responses API item validity.
|
|
418
|
-
*/
|
|
419
|
-
declare function elideSupersededViewImagePairs<T extends HistoryItem>(items: readonly T[]): T[];
|
|
420
|
-
/**
|
|
421
|
-
* Sanitize a replayed history item list into a sequence the Responses API
|
|
422
|
-
* accepts. Pure: returns a new array of the same item references in order,
|
|
423
|
-
* with invalid items omitted. Valid histories come back byte-identical
|
|
424
|
-
* (same references, same order).
|
|
425
|
-
*
|
|
426
|
-
* Rules, each motivated by a concrete 400 the API raises:
|
|
427
|
-
*
|
|
428
|
-
* 1. Drop every tool-call RESULT whose matching tool CALL does not appear
|
|
429
|
-
* earlier in the list. This is the session-bricking orphan: a
|
|
430
|
-
* `function_call_result` with no preceding `function_call` of the same
|
|
431
|
-
* `call_id`. ("No tool call found for function call output…")
|
|
432
|
-
*
|
|
433
|
-
* 2. Drop every tool CALL that has no matching RESULT anywhere after it.
|
|
434
|
-
* The Responses API requires each tool call to be settled by its output
|
|
435
|
-
* before the conversation can continue; a dangling call left in replayed
|
|
436
|
-
* history 400s with "No tool output found for function call…". Dropping
|
|
437
|
-
* the dangling call (rather than synthesizing a fake output) is what the
|
|
438
|
-
* SDK itself does for in-memory continuation, so a reloaded history is
|
|
439
|
-
* shaped identically. The matching result, if it later exists, is kept;
|
|
440
|
-
* only genuinely unpaired calls are removed.
|
|
441
|
-
*
|
|
442
|
-
* 3. Drop any `reasoning` item that immediately precedes (across a run of
|
|
443
|
-
* reasoning items) a dropped tool call. The Responses API ties an
|
|
444
|
-
* encrypted reasoning item to the tool call it produced; a reasoning item
|
|
445
|
-
* orphaned by rule 2 trips "Item 'rs_…' of type 'reasoning' was provided
|
|
446
|
-
* without its required following item". Mirrors the SDK's
|
|
447
|
-
* `dropReasoningItemsPrecedingDroppedCalls`.
|
|
448
|
-
*
|
|
449
|
-
* A `call_id` is paired only when BOTH a call and a result of the matching
|
|
450
|
-
* types exist with that id, the call appearing before the result. Calls and
|
|
451
|
-
* results that satisfy that survive untouched.
|
|
452
|
-
*/
|
|
453
|
-
declare function sanitizeHistoryItemsForModel<T extends HistoryItem>(items: readonly T[], toolOutputTruncationTokens?: number): T[];
|
|
454
|
-
/**
|
|
455
|
-
* Drop the account/org-bound `reasoning.encrypted_content` blob from a single
|
|
456
|
-
* history item, preserving everything else (the visible chain-of-thought text in
|
|
457
|
-
* `summary`/`content`, and every non-reasoning field). Pure + non-mutating: when
|
|
458
|
-
* there is nothing to strip the SAME reference is returned (so the common,
|
|
459
|
-
* same-account path stays byte-identical); otherwise a shallow clone is returned.
|
|
460
|
-
*
|
|
461
|
-
* WHY. A codex-subscription turn round-trips `reasoning.encrypted_content` — an
|
|
462
|
-
* opaque blob minted by the ChatGPT/Codex backend that is bound to the account
|
|
463
|
-
* (org) that produced it. After a manual switch from codex account A to B, the
|
|
464
|
-
* carried history items still hold A-minted blobs; replaying them into a turn
|
|
465
|
-
* running on B is rejected (400). The blob is purely a chain-of-thought
|
|
466
|
-
* continuity optimization — dropping it costs at most one turn of lost CoT
|
|
467
|
-
* continuity and never any message content.
|
|
468
|
-
*
|
|
469
|
-
* USED FOR `compaction` items only on the history-items read path: a foreign
|
|
470
|
-
* `compaction` summary carries account-bound `encrypted_content` but its summary
|
|
471
|
-
* is real conversation content that must be preserved, so we strip only the blob
|
|
472
|
-
* (we do NOT drop the whole item). Foreign `reasoning` items are instead dropped
|
|
473
|
-
* WHOLESALE by the caller (id + blob), because the Responses backend validates
|
|
474
|
-
* the foreign `rs_…` id and rejects a reasoning item that has a foreign id and no
|
|
475
|
-
* encrypted_content (so blanking the blob alone is not enough — see
|
|
476
|
-
* {@link applyCodexHistoryStrip}).
|
|
477
|
-
*
|
|
478
|
-
* The SDK's Responses converter reads the blob via `providerData.encryptedContent`
|
|
479
|
-
* (camel) or `providerData.encrypted_content` (snake); persisted rows use the
|
|
480
|
-
* snake form, but we delete both casings defensively. We also clear a top-level
|
|
481
|
-
* `encrypted_content` (the `compaction`-item shape) belt-and-braces — that blob
|
|
482
|
-
* is likewise source-bound. Only `reasoning` and `compaction` items are touched;
|
|
483
|
-
* messages, tool calls, and tool outputs pass through untouched by reference.
|
|
484
|
-
*/
|
|
485
|
-
declare function stripReasoningEncryptedContent<T extends HistoryItem>(item: T): T;
|
|
486
|
-
/**
|
|
487
|
-
* Neutralize the account/org-bound identity of EVERY `reasoning` item embedded
|
|
488
|
-
* in a serialized RunState JSON string, returning the re-serialized string. Pure:
|
|
489
|
-
* a parse failure or a no-op returns the SAME string reference (so an unchanged
|
|
490
|
-
* or non-codex run-state replays byte-for-byte).
|
|
491
|
-
*
|
|
492
|
-
* WHY (HOLE C — approval replay). An approval decision resumes the serialized
|
|
493
|
-
* RunState blob. That blob round-trips `reasoning.encrypted_content` minted by the ChatGPT/Codex
|
|
494
|
-
* backend (bound to the freezing account/org — a foreign account 400s it) AND the
|
|
495
|
-
* foreign `rs_…` reasoning ids the Responses backend validates (rejected once the
|
|
496
|
-
* blob is gone). Unlike `session_history_items`, the blob carries NO per-item
|
|
497
|
-
* producer tag, so foreign-ness cannot be decided per item; the worker instead
|
|
498
|
-
* records the FREEZING codex account on the run-state row and calls this only when
|
|
499
|
-
* the resuming turn's codex account DIFFERS from it. When the accounts differ we
|
|
500
|
-
* conservatively neutralize every reasoning item: delete its provider id and its
|
|
501
|
-
* `encrypted_content` (both casings, in `providerData`). The visible reasoning
|
|
502
|
-
* `content`/`summary` and every message / tool-call / tool-output item are left
|
|
503
|
-
* intact (message and tool content are never account-bound).
|
|
504
|
-
*
|
|
505
|
-
* A reasoning item with no id and no encrypted_content is exactly the shape the
|
|
506
|
-
* production Azure path already sends (see `stripProviderItemIdsFilter`), so it
|
|
507
|
-
* deserializes and replays cleanly. Reasoning items live in several places in the
|
|
508
|
-
* blob — `originalInput` (when an array), each `modelResponses[].output`,
|
|
509
|
-
* `lastModelResponse.output`, and the `generatedItems` wrappers (`reasoning_item`
|
|
510
|
-
* → `rawItem`) — and we scrub all of them. `compaction` items are deliberately
|
|
511
|
-
* left untouched: their `encrypted_content` is a protocol-REQUIRED field whose
|
|
512
|
-
* removal would fail the SDK's run-state schema validation on deserialize.
|
|
513
|
-
*/
|
|
514
|
-
declare function stripReasoningIdentityFromSerializedRunState(serialized: string): string;
|
|
515
|
-
/**
|
|
516
|
-
* Neutralize tool_search items IN PLACE in a serialized RunState blob for a
|
|
517
|
-
* cross-account codex resume — the run-state sibling of
|
|
518
|
-
* `applyCodexHistoryStrip`'s tool_search rule, but COUNT-PRESERVING (HOLE E: the
|
|
519
|
-
* blob path's reconcile watermark counts the blob's history length, so items
|
|
520
|
-
* must never be removed — only mutated, exactly like the reasoning
|
|
521
|
-
* neutralization above).
|
|
522
|
-
*
|
|
523
|
-
* The hazard: on deserialize, the SDK re-runs the registered CLIENT tool_search
|
|
524
|
-
* execute callback per frozen pair (`rehydrateToolSearchRuntimeTools`) and
|
|
525
|
-
* THROWS a UserError when the re-run's runtime-tool keys mismatch the serialized
|
|
526
|
-
* expectation — which is exactly what happens when the RESUMING account's
|
|
527
|
-
* connector pool differs from the FREEZING account's. The SDK skips that
|
|
528
|
-
* rehydration entirely for `execution === 'server'` calls, so flipping the
|
|
529
|
-
* frozen pairs' `execution` to `"server"` in place defuses the throw without
|
|
530
|
-
* touching counts, ids, pairing, or content. The flipped shape is wire-safe:
|
|
531
|
-
* LIVE-VERIFIED against /codex/responses — a replayed server-execution pair is
|
|
532
|
-
* accepted (200) and its disclosure still holds. The account-bound `tsc_…` id is
|
|
533
|
-
* separately stripped by the codex transport normalizer (all input item ids).
|
|
534
|
-
*
|
|
535
|
-
* Walks the same blob locations as {@link stripReasoningIdentityFromSerializedRunState}:
|
|
536
|
-
* `originalInput` (array form), `generatedItems` (SDK run-item wrappers — the
|
|
537
|
-
* raw shape under `rawItem`), every `modelResponses[].output`, and
|
|
538
|
-
* `lastModelResponse.output`. Returns the input string unchanged when nothing
|
|
539
|
-
* matched.
|
|
540
|
-
*/
|
|
541
|
-
declare function neutralizeToolSearchItemsInSerializedRunState(serialized: string): string;
|
|
542
|
-
|
|
543
|
-
type UsageDetails = Record<string, unknown> | Array<Record<string, unknown>>;
|
|
544
|
-
type RequestUsageEntry = {
|
|
545
|
-
inputTokens?: unknown;
|
|
546
|
-
input_tokens?: unknown;
|
|
547
|
-
outputTokens?: unknown;
|
|
548
|
-
output_tokens?: unknown;
|
|
549
|
-
totalTokens?: unknown;
|
|
550
|
-
total_tokens?: unknown;
|
|
551
|
-
inputTokensDetails?: UsageDetails | undefined;
|
|
552
|
-
input_tokens_details?: UsageDetails | undefined;
|
|
553
|
-
outputTokensDetails?: UsageDetails | undefined;
|
|
554
|
-
output_tokens_details?: UsageDetails | undefined;
|
|
555
|
-
};
|
|
556
|
-
type ModelCallUsageInput = {
|
|
557
|
-
inputTokens?: unknown;
|
|
558
|
-
outputTokens?: unknown;
|
|
559
|
-
totalTokens?: unknown;
|
|
560
|
-
inputTokensDetails?: UsageDetails | undefined;
|
|
561
|
-
outputTokensDetails?: UsageDetails | undefined;
|
|
562
|
-
requestUsageEntries?: RequestUsageEntry[] | undefined;
|
|
563
|
-
};
|
|
564
|
-
/**
|
|
565
|
-
* A single provider usage frame above one billion tokens is outside every
|
|
566
|
-
* supported OpenGeni model contract. Keeping the ceiling explicit also prevents
|
|
567
|
-
* malformed-but-finite provider values from corrupting durable accounting or a
|
|
568
|
-
* process-lifetime Prometheus counter.
|
|
569
|
-
*/
|
|
570
|
-
declare const MAX_MODEL_USAGE_TOKEN_COUNT = 1000000000;
|
|
571
|
-
type ModelCallUsageTelemetry = {
|
|
572
|
-
inputTokens: number | null;
|
|
573
|
-
outputTokens: number | null;
|
|
574
|
-
cachedTokens: number | null;
|
|
575
|
-
cacheWriteTokens: number | null;
|
|
576
|
-
reasoningTokens: number | null;
|
|
577
|
-
};
|
|
578
|
-
type ModelCallUsageNormalization = {
|
|
579
|
-
telemetry: ModelCallUsageTelemetry;
|
|
580
|
-
totalTokens: number | null;
|
|
581
|
-
/** Bounded field paths only; raw provider values are never retained. */
|
|
582
|
-
rejectedFields: string[];
|
|
583
|
-
};
|
|
584
|
-
declare function modelUsageTokenCountOrNull(value: unknown): number | null;
|
|
585
|
-
declare function normalizeModelCallUsage(usage: ModelCallUsageInput | null | undefined): ModelCallUsageNormalization;
|
|
586
|
-
declare function modelCallUsageTelemetry(usage: ModelCallUsageInput | null | undefined): ModelCallUsageTelemetry;
|
|
587
|
-
|
|
588
|
-
type NormalizedRuntimeEvent = {
|
|
1
|
+
import type { ConfiguredModel, ModelProviderApi, ResolvedModelProvider, Settings } from "@opengeni/config";
|
|
2
|
+
import { RequestHumanInputToolInput, type GitCredentialProvider, type GitCredentialTransport, type HumanInputResponse, type McpServerConnectionRef, type Permission, type FirstPartyMcpToolName, type LatencyMode, type ReasoningEffort, type ResourceRef, type SessionEventType, type ToolAuthNeededPayload, type ToolRef } from "@opengeni/contracts";
|
|
3
|
+
import { Agent, RunState, type AgentInputItem, type CallModelInputFilter, type MCPServer, type Model, type ModelProvider, type RunStreamEvent, type Tool } from "@openai/agents";
|
|
4
|
+
import { Capabilities, Manifest, type LocalDirLazySkillSource, type SandboxClient, type SandboxSessionLike, type SandboxSessionState } from "@openai/agents/sandbox";
|
|
5
|
+
import OpenAI from "openai";
|
|
6
|
+
import { type ProviderContextTokenSignal } from "./context-compaction";
|
|
7
|
+
import { type RunCredentialSessionReady } from "./sandbox";
|
|
8
|
+
import { type TurnSandboxCommandArgs, type TurnSandboxCommandSession, type TurnToolCancellationFence } from "./sandbox/turn-tool-cancellation";
|
|
9
|
+
import { type ComputerToolMode } from "./sandbox-computer";
|
|
10
|
+
import type { RuntimeMetricsHooks } from "./metrics";
|
|
11
|
+
import { type WorkspaceSkillSearchPath } from "./workspace-skills";
|
|
12
|
+
export { getSkillLibraryEntry, isSkillLibraryEntryId, listSkillLibraryEntries, loadSkillLibrarySkill, type SkillLibraryEntry, type SkillLibraryFile, type SkillLibrarySkill, } from "./skill-library";
|
|
13
|
+
export type { RuntimeMetricsHooks } from "./metrics";
|
|
14
|
+
export { createTurnToolCancellationController, TurnSandboxCommandCancelledError, } from "./sandbox/turn-tool-cancellation";
|
|
15
|
+
export type { TurnSandboxCommandArgs, TurnSandboxCommandSession, TurnToolCancellationController, TurnToolCancellationFence, } from "./sandbox/turn-tool-cancellation";
|
|
16
|
+
export { SandboxComputer, ComputerUseCapability, computerUse, ComputerUnavailableError, ComputerReadOnlyError, ComputerActionError, type SandboxComputerOptions, type ComputerUseArgs, type ComputerToolMode, } from "./sandbox-computer";
|
|
17
|
+
export * from "./sandbox";
|
|
18
|
+
export { elideSupersededViewImagePairs, sanitizeHistoryItemsForModel, stripReasoningEncryptedContent, stripReasoningIdentityFromSerializedRunState, neutralizeToolSearchItemsInSerializedRunState, } from "./history-sanitizer";
|
|
19
|
+
export type { HistoryItem } from "./history-sanitizer";
|
|
20
|
+
export { OpenAIChatCompletionsModel, OpenAIResponsesModel } from "@openai/agents";
|
|
21
|
+
export { CompactionNeededError, CompactionProviderResponseError, EmptyCompactionSummaryError, buildCompactionPromptInput, buildCompactionReplacementHistory, compactionReplacementFingerprint, compactionThresholdTokens, clampCompactionThresholdRatio, decideCompaction, buildSummaryItem, buildRemoteCompactionV2PromptInput, buildRemoteV2ReplacementHistory, extractRemoteCompactionV2OutputItem, findCompactionNeededError, isCompactionSummary, isRemoteCompactionItem, isRetainedRemoteV2Message, latestCompactionReplacementFingerprint, prepareCompactionPromptInput, isUserMessage, estimateTokens, estimateTokensBreakdown, estimateItemTokens, estimateItemTokenBreakdown, estimateOpaqueEncryptedModelVisibleBytes, estimateOpaqueEncryptedTokens, opaqueEncryptedContentLength, estimateNativeImageTokens, estimateCompleteModelInput, estimateSerializedValueTokens, hasModelGeneratedItem, renderCompactionPromptInputForChat, COMPACTION_SUMMARY_MARKER, COMPACTION_PROMPT, COMPACT_USER_MESSAGE_MAX_TOKENS, REMOTE_V2_RETAINED_MESSAGE_TOKEN_BUDGET, REMOTE_COMPACTION_V2_IMPLEMENTATION, REMOTE_COMPACTION_V2_BETA_FEATURE, DEFAULT_COMPACTION_THRESHOLD_RATIO, MIN_COMPACTION_THRESHOLD_RATIO, MAX_COMPACTION_THRESHOLD_RATIO, SUMMARY_BUFFER_TOKENS, SUMMARY_PREFIX, USER_MESSAGE_TRUNCATION_MARKER, UNKNOWN_IMAGE_TOKENS, MAX_NATIVE_IMAGE_TOKENS, } from "./context-compaction";
|
|
22
|
+
export type { CompactionDecision, ModelInputTokenBreakdown, NativeImageEstimateReason, NativeImageTokenEstimate, CompactionItem, PreparedCompactionPromptInput, } from "./context-compaction";
|
|
23
|
+
export { MAX_MODEL_USAGE_TOKEN_COUNT, modelCallUsageTelemetry, modelUsageTokenCountOrNull, normalizeModelCallUsage, } from "./usage-telemetry";
|
|
24
|
+
export type { ModelCallUsageInput, ModelCallUsageNormalization, ModelCallUsageTelemetry, } from "./usage-telemetry";
|
|
25
|
+
export type NormalizedRuntimeEvent = {
|
|
589
26
|
type: SessionEventType;
|
|
590
27
|
payload: unknown;
|
|
591
28
|
};
|
|
592
|
-
type ModelResponseUsage = {
|
|
29
|
+
export type ModelResponseUsage = {
|
|
593
30
|
responseId?: string;
|
|
31
|
+
serviceTier?: string;
|
|
594
32
|
usage: {
|
|
595
33
|
inputTokens?: number;
|
|
596
34
|
outputTokens?: number;
|
|
@@ -612,7 +50,7 @@ type ModelResponseUsage = {
|
|
|
612
50
|
};
|
|
613
51
|
};
|
|
614
52
|
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
615
|
-
type ResolveConnectionCredentialInput = {
|
|
53
|
+
export type ResolveConnectionCredentialInput = {
|
|
616
54
|
workspaceId: string;
|
|
617
55
|
subjectId?: string;
|
|
618
56
|
serverId: string;
|
|
@@ -622,7 +60,7 @@ type ResolveConnectionCredentialInput = {
|
|
|
622
60
|
destinationUrl: string;
|
|
623
61
|
forceRefresh?: boolean;
|
|
624
62
|
};
|
|
625
|
-
type ResolveConnectionCredentialResult = {
|
|
63
|
+
export type ResolveConnectionCredentialResult = {
|
|
626
64
|
status: "ok";
|
|
627
65
|
headers: Record<string, string>;
|
|
628
66
|
connectionId: string;
|
|
@@ -638,8 +76,8 @@ type ResolveConnectionCredentialResult = {
|
|
|
638
76
|
selectedResources?: McpServerConnectionRef["selectedResources"];
|
|
639
77
|
authorizationUrl?: string;
|
|
640
78
|
};
|
|
641
|
-
declare function ensureReadableStreamFrom(): void;
|
|
642
|
-
type AgentSegmentInput = {
|
|
79
|
+
export declare function ensureReadableStreamFrom(): void;
|
|
80
|
+
export type AgentSegmentInput = {
|
|
643
81
|
kind: "message";
|
|
644
82
|
/** A real human/API prompt. Omitted when resuming the same inference. */
|
|
645
83
|
text?: string;
|
|
@@ -658,16 +96,16 @@ type AgentSegmentInput = {
|
|
|
658
96
|
serializedRunState: string;
|
|
659
97
|
toolCallId: string;
|
|
660
98
|
};
|
|
661
|
-
type PreparedAgentInput = {
|
|
99
|
+
export type PreparedAgentInput = {
|
|
662
100
|
input: string | AgentInputItem[] | RunState<any, any>;
|
|
663
101
|
sandboxSessionState?: SandboxSessionState;
|
|
664
102
|
};
|
|
665
|
-
declare const HUMAN_INPUT_TOOL_NAME = "request_human_input";
|
|
666
|
-
type SerializedHumanInputInterruption = {
|
|
103
|
+
export declare const HUMAN_INPUT_TOOL_NAME = "request_human_input";
|
|
104
|
+
export type SerializedHumanInputInterruption = {
|
|
667
105
|
toolCallId: string;
|
|
668
106
|
input: ReturnType<typeof RequestHumanInputToolInput.parse>;
|
|
669
107
|
};
|
|
670
|
-
type SandboxFileDownload = {
|
|
108
|
+
export type SandboxFileDownload = {
|
|
671
109
|
fileId: string;
|
|
672
110
|
mountPath: string;
|
|
673
111
|
filename: string;
|
|
@@ -676,7 +114,7 @@ type SandboxFileDownload = {
|
|
|
676
114
|
expiresAt?: Date | string;
|
|
677
115
|
sizeBytes?: number;
|
|
678
116
|
};
|
|
679
|
-
type SandboxFileDownloadFailure = {
|
|
117
|
+
export type SandboxFileDownloadFailure = {
|
|
680
118
|
fileId: string;
|
|
681
119
|
filename: string;
|
|
682
120
|
path: string;
|
|
@@ -684,11 +122,11 @@ type SandboxFileDownloadFailure = {
|
|
|
684
122
|
exitCode?: number;
|
|
685
123
|
output?: string;
|
|
686
124
|
};
|
|
687
|
-
type SandboxFileDownloadMaterializationResult = {
|
|
125
|
+
export type SandboxFileDownloadMaterializationResult = {
|
|
688
126
|
failures: SandboxFileDownloadFailure[];
|
|
689
127
|
};
|
|
690
|
-
declare function configureRuntimeMetricsHooks(hooks: RuntimeMetricsHooks | null | undefined): void;
|
|
691
|
-
type OpenGeniRuntime = {
|
|
128
|
+
export declare function configureRuntimeMetricsHooks(hooks: RuntimeMetricsHooks | null | undefined): void;
|
|
129
|
+
export type OpenGeniRuntime = {
|
|
692
130
|
configure: (settings: Settings) => void;
|
|
693
131
|
resolveTurnModel: (settings: Settings, modelId: string) => ReturnType<typeof resolveTurnModel>;
|
|
694
132
|
buildAgent: (settings: Settings, resources: ResourceRef[], options?: BuildAgentOptions) => Agent<any, any>;
|
|
@@ -698,12 +136,12 @@ type OpenGeniRuntime = {
|
|
|
698
136
|
serializeApprovals: (interruptions: unknown[]) => unknown[];
|
|
699
137
|
serializeHumanInputRequests?: (interruptions: unknown[]) => SerializedHumanInputInterruption[];
|
|
700
138
|
};
|
|
701
|
-
type ProductionRuntimeOverrides = {
|
|
139
|
+
export type ProductionRuntimeOverrides = {
|
|
702
140
|
model?: Model;
|
|
703
141
|
sandboxClient?: unknown;
|
|
704
142
|
metrics?: RuntimeMetricsHooks;
|
|
705
143
|
};
|
|
706
|
-
declare function createProductionAgentRuntime(overrides?: ProductionRuntimeOverrides): OpenGeniRuntime;
|
|
144
|
+
export declare function createProductionAgentRuntime(overrides?: ProductionRuntimeOverrides): OpenGeniRuntime;
|
|
707
145
|
/**
|
|
708
146
|
* Build an OpenAI client from settings for the configured provider. Mirrors the
|
|
709
147
|
* client construction in configureOpenAI so a direct API call (the compaction
|
|
@@ -711,8 +149,8 @@ declare function createProductionAgentRuntime(overrides?: ProductionRuntimeOverr
|
|
|
711
149
|
* the OpenAI-platform path has only a key (the SDK default client is used via
|
|
712
150
|
* setDefaultOpenAIKey there); the caller then constructs a key-only client.
|
|
713
151
|
*/
|
|
714
|
-
declare function buildOpenAIClientFromSettings(settings: Settings, providerId?: string): OpenAI;
|
|
715
|
-
declare function buildProviderClient(provider: ResolvedModelProvider, settings: Settings): OpenAI;
|
|
152
|
+
export declare function buildOpenAIClientFromSettings(settings: Settings, providerId?: string): OpenAI;
|
|
153
|
+
export declare function buildProviderClient(provider: ResolvedModelProvider, settings: Settings): OpenAI;
|
|
716
154
|
/**
|
|
717
155
|
* Bind a model id to a provider's OpenAI client as an @openai/agents `Model`
|
|
718
156
|
* instance, choosing the wire API by the provider's declared `api`: the "chat"
|
|
@@ -722,7 +160,7 @@ declare function buildProviderClient(provider: ResolvedModelProvider, settings:
|
|
|
722
160
|
* the agent is what routes a turn to its provider without mutating the global
|
|
723
161
|
* default client.
|
|
724
162
|
*/
|
|
725
|
-
declare function buildModelInstance(provider: ResolvedModelProvider, client: OpenAI, modelId: string): Model;
|
|
163
|
+
export declare function buildModelInstance(provider: ResolvedModelProvider, client: OpenAI, modelId: string): Model;
|
|
726
164
|
/**
|
|
727
165
|
* Resolved per-turn model routing: the provider that serves `modelId`, its
|
|
728
166
|
* (cached) OpenAI client, the provider-bound `Model` instance, and the
|
|
@@ -731,7 +169,7 @@ declare function buildModelInstance(provider: ResolvedModelProvider, client: Ope
|
|
|
731
169
|
* back to the legacy global-client path (settings.openaiModel + the default
|
|
732
170
|
* client configured by configureOpenAI), preserved byte-for-byte.
|
|
733
171
|
*/
|
|
734
|
-
declare function resolveTurnModel(settings: Settings, modelId: string): {
|
|
172
|
+
export declare function resolveTurnModel(settings: Settings, modelId: string): {
|
|
735
173
|
provider: ResolvedModelProvider;
|
|
736
174
|
client: OpenAI;
|
|
737
175
|
model: Model;
|
|
@@ -757,7 +195,7 @@ declare function resolveTurnModel(settings: Settings, modelId: string): {
|
|
|
757
195
|
* The process default remains only as a boot-time fallback. Falls back to the
|
|
758
196
|
* SDK default provider for a model that is in no provider's allow-list.
|
|
759
197
|
*/
|
|
760
|
-
declare class MultiProviderModelProvider implements ModelProvider {
|
|
198
|
+
export declare class MultiProviderModelProvider implements ModelProvider {
|
|
761
199
|
private readonly settings;
|
|
762
200
|
private fallback;
|
|
763
201
|
constructor(settings: Settings);
|
|
@@ -772,7 +210,7 @@ declare class MultiProviderModelProvider implements ModelProvider {
|
|
|
772
210
|
* and carries no status/code, so agentRunFailurePayload surfaces it verbatim as
|
|
773
211
|
* a non-retryable turn.failed the session UI shows.
|
|
774
212
|
*/
|
|
775
|
-
declare class CodexSubscriptionUnavailableError extends Error {
|
|
213
|
+
export declare class CodexSubscriptionUnavailableError extends Error {
|
|
776
214
|
constructor(modelName: string);
|
|
777
215
|
}
|
|
778
216
|
/**
|
|
@@ -783,10 +221,10 @@ declare class CodexSubscriptionUnavailableError extends Error {
|
|
|
783
221
|
* the paid built-in client. Like CodexSubscriptionUnavailableError the message
|
|
784
222
|
* is user-actionable and surfaces verbatim as a non-retryable turn.failed.
|
|
785
223
|
*/
|
|
786
|
-
declare class WorkspaceModelPolicyBlockedError extends Error {
|
|
224
|
+
export declare class WorkspaceModelPolicyBlockedError extends Error {
|
|
787
225
|
constructor(modelName: string, providerId: string, reason: "provider" | "model");
|
|
788
226
|
}
|
|
789
|
-
declare function configureOpenAI(settings: Settings): void;
|
|
227
|
+
export declare function configureOpenAI(settings: Settings): void;
|
|
790
228
|
/**
|
|
791
229
|
* Run the compaction summarizer as one plain, tool-less, non-streaming model
|
|
792
230
|
* call against the resolved provider. `input` is the active history plus
|
|
@@ -804,7 +242,7 @@ declare function configureOpenAI(settings: Settings): void;
|
|
|
804
242
|
* supplied it uses the built-in OpenAI/Azure Responses path. store:false is set
|
|
805
243
|
* only on the OpenAI-platform Responses path (Azure rejects it; chat ignores it).
|
|
806
244
|
*/
|
|
807
|
-
declare function summarizeForCompaction(settings: Settings, input: Array<Record<string, unknown>>, options?: {
|
|
245
|
+
export declare function summarizeForCompaction(settings: Settings, input: Array<Record<string, unknown>>, options?: {
|
|
808
246
|
client?: OpenAI;
|
|
809
247
|
api?: ModelProviderApi;
|
|
810
248
|
maxOutputTokens?: number;
|
|
@@ -813,10 +251,21 @@ declare function summarizeForCompaction(settings: Settings, input: Array<Record<
|
|
|
813
251
|
systemInstructions?: string;
|
|
814
252
|
onUsage?: (usage: ModelResponseUsage) => void | Promise<void>;
|
|
815
253
|
}): Promise<string>;
|
|
254
|
+
/**
|
|
255
|
+
* Codex remote compaction v2: send active history + `compaction_trigger`, collect
|
|
256
|
+
* exactly one `{ type: "compaction", encrypted_content }` output item.
|
|
257
|
+
* Must run inside Codex ALS with `remote_compaction_v2` beta + turn metadata.
|
|
258
|
+
*/
|
|
259
|
+
export declare function requestRemoteCompactionV2(settings: Settings, input: Array<Record<string, unknown>>, options: {
|
|
260
|
+
client: OpenAI;
|
|
261
|
+
model: string;
|
|
262
|
+
promptCacheKey?: string;
|
|
263
|
+
onUsage?: (usage: ModelResponseUsage) => void | Promise<void>;
|
|
264
|
+
}): Promise<Record<string, unknown>>;
|
|
816
265
|
/** Bounded provider diagnostics: identifiers and classifications, never messages or model data. */
|
|
817
|
-
declare function compactionProviderFailureDiagnostics(error: unknown): Record<string, unknown>;
|
|
266
|
+
export declare function compactionProviderFailureDiagnostics(error: unknown): Record<string, unknown>;
|
|
818
267
|
/** Bounded, content-free diagnostics for a semantically empty checkpoint. */
|
|
819
|
-
declare function compactionResponseDiagnostics(response: unknown, extractedText?: string): Record<string, unknown>;
|
|
268
|
+
export declare function compactionResponseDiagnostics(response: unknown, extractedText?: string): Record<string, unknown>;
|
|
820
269
|
/**
|
|
821
270
|
* Pull the assistant text out of a Responses API result, shape-tolerant. Only
|
|
822
271
|
* `role === "assistant"` message items contribute: a provider whose Responses
|
|
@@ -825,9 +274,9 @@ declare function compactionResponseDiagnostics(response: unknown, extractedText?
|
|
|
825
274
|
* otherwise corrupt the summary with the prompt it was given. The OpenAI/Azure
|
|
826
275
|
* Responses API only emits assistant messages, so this guard is a no-op there.
|
|
827
276
|
*/
|
|
828
|
-
declare function extractResponseOutputText(response: unknown): string;
|
|
829
|
-
type GitTokenSeeds = Partial<Record<GitCredentialProvider, string>>;
|
|
830
|
-
type GitCredentialBindingSeed = {
|
|
277
|
+
export declare function extractResponseOutputText(response: unknown): string;
|
|
278
|
+
export type GitTokenSeeds = Partial<Record<GitCredentialProvider, string>>;
|
|
279
|
+
export type GitCredentialBindingSeed = {
|
|
831
280
|
credentialBindingId: string;
|
|
832
281
|
provider: GitCredentialProvider;
|
|
833
282
|
token: string;
|
|
@@ -836,9 +285,9 @@ type GitCredentialBindingSeed = {
|
|
|
836
285
|
/** Total active bindings for this provider, used to suppress unsafe aliases. */
|
|
837
286
|
providerBindingCount?: number;
|
|
838
287
|
};
|
|
839
|
-
type GitCredentialTokenWriterSession = SandboxSessionLike;
|
|
840
|
-
type ToolspaceTokenWriterSession = SandboxSessionLike;
|
|
841
|
-
type EffectiveSkillSelection = Readonly<{
|
|
288
|
+
export type GitCredentialTokenWriterSession = SandboxSessionLike;
|
|
289
|
+
export type ToolspaceTokenWriterSession = SandboxSessionLike;
|
|
290
|
+
export type EffectiveSkillSelection = Readonly<{
|
|
842
291
|
id: string;
|
|
843
292
|
name: string;
|
|
844
293
|
source: "bundled" | "library" | "pack" | "session";
|
|
@@ -852,8 +301,8 @@ type EffectiveSkillSelection = Readonly<{
|
|
|
852
301
|
* effective configuration inspection cannot accidentally expose credentials or
|
|
853
302
|
* turn skill activation into an authorization change.
|
|
854
303
|
*/
|
|
855
|
-
declare function effectiveSkillSelectionsForAgent(agent: object): readonly EffectiveSkillSelection[];
|
|
856
|
-
type BuildAgentOptions = {
|
|
304
|
+
export declare function effectiveSkillSelectionsForAgent(agent: object): readonly EffectiveSkillSelection[];
|
|
305
|
+
export type BuildAgentOptions = {
|
|
857
306
|
model?: Model;
|
|
858
307
|
/** Settled response for the one internal human-input interruption resumed by this run. */
|
|
859
308
|
humanInputResponse?: {
|
|
@@ -862,6 +311,10 @@ type BuildAgentOptions = {
|
|
|
862
311
|
response: HumanInputResponse;
|
|
863
312
|
};
|
|
864
313
|
reasoningEffort?: ReasoningEffort;
|
|
314
|
+
/** Product latency selection frozen onto this turn. */
|
|
315
|
+
latencyMode?: LatencyMode;
|
|
316
|
+
/** Provider-specific wire value resolved by the worker (`fast` or `priority`). */
|
|
317
|
+
serviceTier?: "fast" | "priority";
|
|
865
318
|
hostedWebSearch?: boolean;
|
|
866
319
|
encryptedReasoning?: boolean;
|
|
867
320
|
structuredToolTransport?: boolean;
|
|
@@ -911,11 +364,11 @@ type BuildAgentOptions = {
|
|
|
911
364
|
*/
|
|
912
365
|
onToolCancellationFence?: (fence: TurnToolCancellationFence) => void;
|
|
913
366
|
};
|
|
914
|
-
type PackSkillFile = {
|
|
367
|
+
export type PackSkillFile = {
|
|
915
368
|
path: string;
|
|
916
369
|
content: string;
|
|
917
370
|
};
|
|
918
|
-
type PackSkill = {
|
|
371
|
+
export type PackSkill = {
|
|
919
372
|
name: string;
|
|
920
373
|
description?: string | null | undefined;
|
|
921
374
|
files: PackSkillFile[];
|
|
@@ -928,12 +381,12 @@ type PackSkill = {
|
|
|
928
381
|
* agent must not have to rediscover that by enumerating `env` and guessing.
|
|
929
382
|
* Only metadata belongs here — never variable values.
|
|
930
383
|
*/
|
|
931
|
-
type WorkspaceEnvironmentContext = {
|
|
384
|
+
export type WorkspaceEnvironmentContext = {
|
|
932
385
|
name: string;
|
|
933
386
|
description?: string | null;
|
|
934
387
|
variableNames?: string[];
|
|
935
388
|
};
|
|
936
|
-
type PersistentSessionSettings = {
|
|
389
|
+
export type PersistentSessionSettings = {
|
|
937
390
|
titleIsSet: boolean;
|
|
938
391
|
};
|
|
939
392
|
/**
|
|
@@ -943,12 +396,12 @@ type PersistentSessionSettings = {
|
|
|
943
396
|
* machine definition and how to promote a durable change. Absent for rig-less
|
|
944
397
|
* sessions (the block never renders).
|
|
945
398
|
*/
|
|
946
|
-
type RigInstructionsContext = {
|
|
399
|
+
export type RigInstructionsContext = {
|
|
947
400
|
name: string;
|
|
948
401
|
version: number;
|
|
949
402
|
};
|
|
950
|
-
declare function rigInstructions(rig: RigInstructionsContext): string[];
|
|
951
|
-
declare function workspaceEnvironmentInstructions(environment: WorkspaceEnvironmentContext): string[];
|
|
403
|
+
export declare function rigInstructions(rig: RigInstructionsContext): string[];
|
|
404
|
+
export declare function workspaceEnvironmentInstructions(environment: WorkspaceEnvironmentContext): string[];
|
|
952
405
|
/**
|
|
953
406
|
* The non-bypassable CORE of the agent instructions: the goal-loop ownership
|
|
954
407
|
* line (which names the opengeni__goal_* tools and is what keeps a long-running
|
|
@@ -960,7 +413,7 @@ declare function workspaceEnvironmentInstructions(environment: WorkspaceEnvironm
|
|
|
960
413
|
* drop: composeAgentInstructions() substitutes it at the persona template's
|
|
961
414
|
* {{core}} marker, and appends it when the marker is absent.
|
|
962
415
|
*/
|
|
963
|
-
declare function coreInstructions(workspaceEnvironment?: WorkspaceEnvironmentContext, rig?: RigInstructionsContext): string[];
|
|
416
|
+
export declare function coreInstructions(workspaceEnvironment?: WorkspaceEnvironmentContext, rig?: RigInstructionsContext): string[];
|
|
964
417
|
/**
|
|
965
418
|
* Composes the final agent instructions from a (possibly white-labelled)
|
|
966
419
|
* persona template and the non-bypassable CORE. The CORE is substituted at the
|
|
@@ -969,7 +422,7 @@ declare function coreInstructions(workspaceEnvironment?: WorkspaceEnvironmentCon
|
|
|
969
422
|
* and the append both join by " ", so the DEFAULT_AGENT_INSTRUCTIONS template
|
|
970
423
|
* with an empty environment reproduces the historical preamble byte-for-byte.
|
|
971
424
|
*/
|
|
972
|
-
declare function composeAgentInstructions(template: string, workspaceEnvironment?: WorkspaceEnvironmentContext, rig?: RigInstructionsContext): string;
|
|
425
|
+
export declare function composeAgentInstructions(template: string, workspaceEnvironment?: WorkspaceEnvironmentContext, rig?: RigInstructionsContext): string;
|
|
973
426
|
/**
|
|
974
427
|
* Appends the per-session persona instructions to the already-composed
|
|
975
428
|
* (workspace + CORE) instructions, joined by " " — exactly the join used
|
|
@@ -977,9 +430,9 @@ declare function composeAgentInstructions(template: string, workspaceEnvironment
|
|
|
977
430
|
* (session-specific refinement of the workspace persona). An absent/blank value
|
|
978
431
|
* is a no-op that returns the composed string byte-for-byte.
|
|
979
432
|
*/
|
|
980
|
-
declare function appendSessionInstructions(composed: string, sessionInstructions?: string): string;
|
|
433
|
+
export declare function appendSessionInstructions(composed: string, sessionInstructions?: string): string;
|
|
981
434
|
/** Append system instructions that apply to this exact turn only. */
|
|
982
|
-
declare function appendTurnInstructions(composed: string, turnInstructions?: string): string;
|
|
435
|
+
export declare function appendTurnInstructions(composed: string, turnInstructions?: string): string;
|
|
983
436
|
/**
|
|
984
437
|
* Append the durable session metadata the model otherwise cannot observe.
|
|
985
438
|
* This is deliberately declarative and excludes the title text: the title is
|
|
@@ -987,7 +440,7 @@ declare function appendTurnInstructions(composed: string, turnInstructions?: str
|
|
|
987
440
|
* initialization has already happened. The block is present on every turn when
|
|
988
441
|
* supplied so compaction cannot erase knowledge that these settings persist.
|
|
989
442
|
*/
|
|
990
|
-
declare function appendPersistentSessionSettings(composed: string, settings?: PersistentSessionSettings): string;
|
|
443
|
+
export declare function appendPersistentSessionSettings(composed: string, settings?: PersistentSessionSettings): string;
|
|
991
444
|
/**
|
|
992
445
|
* Appends the workspace memory working-set block to the already-composed
|
|
993
446
|
* (workspace + CORE + generic substrate) instructions, joined by " ". The
|
|
@@ -995,7 +448,7 @@ declare function appendPersistentSessionSettings(composed: string, settings?: Pe
|
|
|
995
448
|
* per-session instructions. An absent/blank value is a no-op that returns the
|
|
996
449
|
* composed string byte-for-byte.
|
|
997
450
|
*/
|
|
998
|
-
declare function appendWorkspaceMemory(composed: string, workspaceMemory?: string): string;
|
|
451
|
+
export declare function appendWorkspaceMemory(composed: string, workspaceMemory?: string): string;
|
|
999
452
|
/**
|
|
1000
453
|
* Appends the generic programmatic-tool-calling (toolspace) directive to the
|
|
1001
454
|
* composed workspace + CORE instructions, joined by " ". This is GENERIC
|
|
@@ -1011,7 +464,7 @@ declare function appendWorkspaceMemory(composed: string, workspaceMemory?: strin
|
|
|
1011
464
|
* per-session instructions so host/session specificity still wins over this
|
|
1012
465
|
* substrate note.
|
|
1013
466
|
*/
|
|
1014
|
-
declare function appendToolspaceInstructions(composed: string, toolspaceAvailable: boolean): string;
|
|
467
|
+
export declare function appendToolspaceInstructions(composed: string, toolspaceAvailable: boolean): string;
|
|
1015
468
|
/**
|
|
1016
469
|
* Make multi-account provider-CLI selection discoverable to the model.
|
|
1017
470
|
*
|
|
@@ -1019,13 +472,13 @@ declare function appendToolspaceInstructions(composed: string, toolspaceAvailabl
|
|
|
1019
472
|
* secret-free repository mapping is materialized in the sandbox by the Git
|
|
1020
473
|
* setup hook so prompts stay compact.
|
|
1021
474
|
*/
|
|
1022
|
-
declare function appendGitCredentialBindingInstructions(composed: string, bindings: GitCredentialBindingSeed[] | undefined, activeSandboxBackend?: Settings["sandboxBackend"]): string;
|
|
475
|
+
export declare function appendGitCredentialBindingInstructions(composed: string, bindings: GitCredentialBindingSeed[] | undefined, activeSandboxBackend?: Settings["sandboxBackend"]): string;
|
|
1023
476
|
/**
|
|
1024
477
|
* Appends the one-shot genesis title directive (genesis turn only), joined by
|
|
1025
478
|
* " " and always LAST so a white-label persona template or a per-session
|
|
1026
479
|
* instruction can't drop it. A no-op when the hint is absent.
|
|
1027
480
|
*/
|
|
1028
|
-
declare function appendGenesisTitleDirective(instructions: string, genesisTitleHint?: boolean): string;
|
|
481
|
+
export declare function appendGenesisTitleDirective(instructions: string, genesisTitleHint?: boolean): string;
|
|
1029
482
|
/**
|
|
1030
483
|
* The tool output emitted for an MCP tool call that FAILED with a THROWN error
|
|
1031
484
|
* — a JSON-RPC protocol error (e.g. -32602 invalid params), an auth 401/403, a
|
|
@@ -1050,14 +503,14 @@ declare function appendGenesisTitleDirective(instructions: string, genesisTitleH
|
|
|
1050
503
|
* requires an SDK-level change (preserve `isError`) or reading the raw
|
|
1051
504
|
* CallToolResult — tracked separately.
|
|
1052
505
|
*/
|
|
1053
|
-
declare function mcpToolErrorOutput(error: unknown): {
|
|
506
|
+
export declare function mcpToolErrorOutput(error: unknown): {
|
|
1054
507
|
isError: true;
|
|
1055
508
|
content: [{
|
|
1056
509
|
type: "text";
|
|
1057
510
|
text: string;
|
|
1058
511
|
}];
|
|
1059
512
|
};
|
|
1060
|
-
declare function buildOpenGeniAgent(settings: Settings, resources: ResourceRef[], options?: BuildAgentOptions): Agent<any, any>;
|
|
513
|
+
export declare function buildOpenGeniAgent(settings: Settings, resources: ResourceRef[], options?: BuildAgentOptions): Agent<any, any>;
|
|
1061
514
|
/**
|
|
1062
515
|
* Codex accepts ordinary FUNCTION tools but also accepts `input_image` content
|
|
1063
516
|
* inside a function_call_output (the same transport used by codex-rs
|
|
@@ -1067,8 +520,8 @@ declare function buildOpenGeniAgent(settings: Settings, resources: ResourceRef[]
|
|
|
1067
520
|
* base64 characters. Re-wrap only successful data-URL results as a structured
|
|
1068
521
|
* image. Text errors remain text, and the tool itself remains a normal function.
|
|
1069
522
|
*/
|
|
1070
|
-
declare function withStructuredViewImageFunctionResults(tools: Tool<unknown>[]): Tool<unknown>[];
|
|
1071
|
-
declare function buildAgentCapabilities(settings: Settings, packSkills: PackSkill[], options?: {
|
|
523
|
+
export declare function withStructuredViewImageFunctionResults(tools: Tool<unknown>[]): Tool<unknown>[];
|
|
524
|
+
export declare function buildAgentCapabilities(settings: Settings, packSkills: PackSkill[], options?: {
|
|
1072
525
|
skillLibrarySkills?: PackSkill[];
|
|
1073
526
|
sessionSkills?: PackSkill[];
|
|
1074
527
|
workspaceSkillPaths?: readonly WorkspaceSkillSearchPath[];
|
|
@@ -1078,13 +531,13 @@ declare function buildAgentCapabilities(settings: Settings, packSkills: PackSkil
|
|
|
1078
531
|
turnCancellationSignal?: AbortSignal;
|
|
1079
532
|
onToolCancellationFence?: (fence: TurnToolCancellationFence) => void;
|
|
1080
533
|
}): ReturnType<typeof Capabilities.default>;
|
|
1081
|
-
declare function sandboxRunAs(_settings: Settings): string | undefined;
|
|
1082
|
-
type PreparedAgentTools = {
|
|
534
|
+
export declare function sandboxRunAs(_settings: Settings): string | undefined;
|
|
535
|
+
export type PreparedAgentTools = {
|
|
1083
536
|
mcpServers: MCPServer[];
|
|
1084
537
|
close: () => Promise<void>;
|
|
1085
538
|
codexConnectorNamespaces: Set<string>;
|
|
1086
539
|
};
|
|
1087
|
-
type PrepareToolsOptions = {
|
|
540
|
+
export type PrepareToolsOptions = {
|
|
1088
541
|
accountId?: string;
|
|
1089
542
|
workspaceId?: string;
|
|
1090
543
|
sessionId?: string;
|
|
@@ -1101,7 +554,7 @@ type PrepareToolsOptions = {
|
|
|
1101
554
|
/** Injectable final MCP transport for tests and embedded hosts. */
|
|
1102
555
|
mcpFetchImpl?: FetchLike;
|
|
1103
556
|
};
|
|
1104
|
-
type ConnectedMcpServerBatches = {
|
|
557
|
+
export type ConnectedMcpServerBatches = {
|
|
1105
558
|
active: MCPServer[];
|
|
1106
559
|
failed: MCPServer[];
|
|
1107
560
|
errors: ReadonlyMap<MCPServer, Error>;
|
|
@@ -1112,17 +565,30 @@ type ConnectedMcpServerBatches = {
|
|
|
1112
565
|
* failing strict batch; this wrapper additionally closes every earlier batch
|
|
1113
566
|
* before rethrowing, so a later-batch failure cannot leak live connections.
|
|
1114
567
|
*/
|
|
1115
|
-
declare function connectMcpServersInBatches(servers: MCPServer[], options: {
|
|
568
|
+
export declare function connectMcpServersInBatches(servers: MCPServer[], options: {
|
|
1116
569
|
strict: boolean;
|
|
1117
570
|
connectTimeoutMs?: number;
|
|
1118
571
|
}): Promise<ConnectedMcpServerBatches>;
|
|
1119
|
-
declare function prepareAgentTools(settings: Settings, tools: ToolRef[], options?: PrepareToolsOptions): Promise<PreparedAgentTools>;
|
|
1120
|
-
|
|
1121
|
-
|
|
572
|
+
export declare function prepareAgentTools(settings: Settings, tools: ToolRef[], options?: PrepareToolsOptions): Promise<PreparedAgentTools>;
|
|
573
|
+
type SafeMcpTransportError = Error & {
|
|
574
|
+
status?: number;
|
|
575
|
+
code?: number;
|
|
576
|
+
mcpTransportFailureKind?: "request_timeout";
|
|
577
|
+
};
|
|
578
|
+
/**
|
|
579
|
+
* Preserve the MCP SDK's exact request-timeout meaning without retaining or
|
|
580
|
+
* exposing a raw HTTP response body. The numeric code is not sufficient:
|
|
581
|
+
* Streamable HTTP also uses -32001 for "Session not found" and arbitrary
|
|
582
|
+
* AbortSignal reasons, so only the SDK's two owned timeout messages qualify.
|
|
583
|
+
*/
|
|
584
|
+
export declare function isMcpRequestTimeoutError(error: unknown, seen?: WeakSet<object>): boolean;
|
|
585
|
+
export declare function safeMcpTransportError(error: unknown): SafeMcpTransportError;
|
|
586
|
+
export declare function prefixedMcpToolName(registryId: string, toolName: string): string;
|
|
587
|
+
export type PrepareInputOptions = {
|
|
1122
588
|
sandboxClient?: unknown;
|
|
1123
589
|
};
|
|
1124
|
-
declare function prepareRunInput(agent: Agent<any, any>, input: AgentSegmentInput, options?: PrepareInputOptions): Promise<PreparedAgentInput>;
|
|
1125
|
-
type RunAgentStreamOptions = {
|
|
590
|
+
export declare function prepareRunInput(agent: Agent<any, any>, input: AgentSegmentInput, options?: PrepareInputOptions): Promise<PreparedAgentInput>;
|
|
591
|
+
export type RunAgentStreamOptions = {
|
|
1126
592
|
/** Abort the provider/tool loop when the owning activity is cancelled. */
|
|
1127
593
|
signal?: AbortSignal;
|
|
1128
594
|
sandboxClient?: unknown;
|
|
@@ -1151,12 +617,12 @@ type RunAgentStreamOptions = {
|
|
|
1151
617
|
turnToolCancellationFence?: TurnToolCancellationFence;
|
|
1152
618
|
callModelInputFilter?: CallModelInputFilter;
|
|
1153
619
|
};
|
|
1154
|
-
type ContextRobustnessFilterOptions = {
|
|
620
|
+
export type ContextRobustnessFilterOptions = {
|
|
1155
621
|
contextCompactionSignal?: () => ProviderContextTokenSignal | null | undefined;
|
|
1156
622
|
contextCompactionRequested?: () => boolean | Promise<boolean>;
|
|
1157
623
|
throwOnCompactionNeeded?: boolean;
|
|
1158
624
|
};
|
|
1159
|
-
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.";
|
|
625
|
+
export 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.";
|
|
1160
626
|
/**
|
|
1161
627
|
* Inject the genesis-title directive into exactly one model request. Agent
|
|
1162
628
|
* instructions are reused for every model call in a tool loop, so placing this
|
|
@@ -1164,8 +630,8 @@ declare const GENESIS_TITLE_DIRECTIVE = "This is the first turn of a new session
|
|
|
1164
630
|
* calls. The closure is intentionally consumed even when the first request
|
|
1165
631
|
* fails: a retry/recovery must continue the task, not restart setup.
|
|
1166
632
|
*/
|
|
1167
|
-
declare function oneShotGenesisTitleInputFilter(): CallModelInputFilter;
|
|
1168
|
-
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. If `ogtool` is installed, run `ogtool list` to see the available tools and their input schemas (from tools/list), then `ogtool call <tool-name> '<json-args>'`. If it is absent and both npm and $OPENGENI_OGTOOL_PACKAGE_SPEC are available, run the exact deployment-pinned package with `npm exec --yes --package=\"$OPENGENI_OGTOOL_PACKAGE_SPEC\" -- ogtool ...`; never guess a version or install `latest`. Otherwise POST MCP JSON-RPC directly 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.";
|
|
633
|
+
export declare function oneShotGenesisTitleInputFilter(): CallModelInputFilter;
|
|
634
|
+
export 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. If `ogtool` is installed, run `ogtool list` to see the available tools and their input schemas (from tools/list), then `ogtool call <tool-name> '<json-args>'`. If it is absent and both npm and $OPENGENI_OGTOOL_PACKAGE_SPEC are available, run the exact deployment-pinned package with `npm exec --yes --package=\"$OPENGENI_OGTOOL_PACKAGE_SPEC\" -- ogtool ...`; never guess a version or install `latest`. Otherwise POST MCP JSON-RPC directly 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.";
|
|
1169
635
|
/**
|
|
1170
636
|
* callModelInputFilter that removes provider-assigned item ids (rs_/msg_/fc_…)
|
|
1171
637
|
* from every input item immediately before each model call. Responses-API
|
|
@@ -1179,7 +645,7 @@ declare const TOOLSPACE_PROGRAMMATIC_DIRECTIVE = "Every tool on your MCP surface
|
|
|
1179
645
|
* fragility without adding information. Pairing fields (`call_id`/`callId`)
|
|
1180
646
|
* are separate properties and stay untouched; items are cloned, never mutated.
|
|
1181
647
|
*/
|
|
1182
|
-
declare const stripProviderItemIdsFilter: CallModelInputFilter;
|
|
648
|
+
export declare const stripProviderItemIdsFilter: CallModelInputFilter;
|
|
1183
649
|
/**
|
|
1184
650
|
* callModelInputFilter that normalizes every `computer_call` carrying BOTH
|
|
1185
651
|
* `action` and `actions` down to EXACTLY ONE (keeps `actions`, drops `action`).
|
|
@@ -1194,20 +660,14 @@ declare const stripProviderItemIdsFilter: CallModelInputFilter;
|
|
|
1194
660
|
* which the turn-start `prepareRunInput` sanitizer never sees. Items are cloned,
|
|
1195
661
|
* never mutated.
|
|
1196
662
|
*/
|
|
1197
|
-
declare const normalizeComputerCallsFilter: CallModelInputFilter;
|
|
1198
|
-
/**
|
|
1199
|
-
* Per-call state compaction for local image inspection. Re-opening the same
|
|
1200
|
-
* path supersedes its prior base64 result; carrying both provides no newer
|
|
1201
|
-
* information and can otherwise balloon every following model request.
|
|
1202
|
-
*/
|
|
1203
|
-
declare const elideSupersededViewImagesFilter: CallModelInputFilter;
|
|
663
|
+
export declare const normalizeComputerCallsFilter: CallModelInputFilter;
|
|
1204
664
|
/**
|
|
1205
665
|
* Canonical Codex-style tool-result bound at the final model-input seam. The
|
|
1206
666
|
* identical pure normalizer also runs before conversation rows are persisted,
|
|
1207
667
|
* so this is a live-turn defense rather than a request-only alternate history.
|
|
1208
668
|
*/
|
|
1209
|
-
declare function boundModelToolOutputsFilterForSettings(settings: Settings): CallModelInputFilter;
|
|
1210
|
-
declare function contextRobustnessFilterForSettings(settings: Settings, options?: ContextRobustnessFilterOptions): CallModelInputFilter;
|
|
669
|
+
export declare function boundModelToolOutputsFilterForSettings(settings: Settings): CallModelInputFilter;
|
|
670
|
+
export declare function contextRobustnessFilterForSettings(settings: Settings, options?: ContextRobustnessFilterOptions): CallModelInputFilter;
|
|
1211
671
|
/**
|
|
1212
672
|
* The model-input filter applied before every model call. The computer_call
|
|
1213
673
|
* action/actions normalizer is ALWAYS on (the Azure endpoint 400s without it);
|
|
@@ -1216,9 +676,9 @@ declare function contextRobustnessFilterForSettings(settings: Settings, options?
|
|
|
1216
676
|
* compaction signal on the client-compaction path. It never trims history from
|
|
1217
677
|
* an individual request.
|
|
1218
678
|
*/
|
|
1219
|
-
declare function callModelInputFilterForSettings(settings: Settings, options?: ContextRobustnessFilterOptions): CallModelInputFilter | undefined;
|
|
1220
|
-
declare function runAgentStream(agent: Agent<any, any>, input: PreparedAgentInput | string | RunState<any, any>, settings: Settings, overrides?: RunAgentStreamOptions): Promise<
|
|
1221
|
-
|
|
679
|
+
export declare function callModelInputFilterForSettings(settings: Settings, options?: ContextRobustnessFilterOptions): CallModelInputFilter | undefined;
|
|
680
|
+
export declare function runAgentStream(agent: Agent<any, any>, input: PreparedAgentInput | string | RunState<any, any>, settings: Settings, overrides?: RunAgentStreamOptions): Promise<import("@openai/agents").StreamedRunResult<any, Agent<any, any>>>;
|
|
681
|
+
export { MaxTurnsExceededError } from "@openai/agents";
|
|
1222
682
|
/**
|
|
1223
683
|
* Detects the agents SDK per-segment turn cap. The cap is a pacing valve, not
|
|
1224
684
|
* a session failure: callers should end the segment gracefully (idle) so an
|
|
@@ -1226,7 +686,7 @@ declare function runAgentStream(agent: Agent<any, any>, input: PreparedAgentInpu
|
|
|
1226
686
|
* the work. When the SDK attached the run state at the moment the cap hit,
|
|
1227
687
|
* the serialized form is returned so the resumed turn keeps full context.
|
|
1228
688
|
*/
|
|
1229
|
-
declare function maxTurnsExceededRunState(error: unknown): {
|
|
689
|
+
export declare function maxTurnsExceededRunState(error: unknown): {
|
|
1230
690
|
serializedRunState: string | null;
|
|
1231
691
|
} | null;
|
|
1232
692
|
/**
|
|
@@ -1235,15 +695,15 @@ declare function maxTurnsExceededRunState(error: unknown): {
|
|
|
1235
695
|
* must treat a null here as "resume from the previous snapshot" rather than
|
|
1236
696
|
* an error.
|
|
1237
697
|
*/
|
|
1238
|
-
declare function agentsErrorRunState(error: unknown): string | null;
|
|
1239
|
-
declare function withManifestRefreshOnResume(client: SandboxClient, targetManifest: Manifest | undefined, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): SandboxClient;
|
|
1240
|
-
declare function applyMissingManifestEntries(session: SandboxSessionLike, targetManifest: Manifest, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): Promise<void>;
|
|
698
|
+
export declare function agentsErrorRunState(error: unknown): string | null;
|
|
699
|
+
export declare function withManifestRefreshOnResume(client: SandboxClient, targetManifest: Manifest | undefined, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): SandboxClient;
|
|
700
|
+
export declare function applyMissingManifestEntries(session: SandboxSessionLike, targetManifest: Manifest, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): Promise<void>;
|
|
1241
701
|
/**
|
|
1242
702
|
* Key-level diff of the live box's baked manifest env vs the freshly recomputed
|
|
1243
703
|
* target env. Returns null when identical. Key NAMES only — values are secrets
|
|
1244
704
|
* and must never leave this function's comparison.
|
|
1245
705
|
*/
|
|
1246
|
-
declare function manifestEnvironmentDrift(current: Manifest, target: Manifest): {
|
|
706
|
+
export declare function manifestEnvironmentDrift(current: Manifest, target: Manifest): {
|
|
1247
707
|
added: string[];
|
|
1248
708
|
removed: string[];
|
|
1249
709
|
changed: string[];
|
|
@@ -1259,7 +719,7 @@ declare function manifestEnvironmentDrift(current: Manifest, target: Manifest):
|
|
|
1259
719
|
* names only) instead of letting it kill the session. Fresh env lands at the
|
|
1260
720
|
* next cold-create; rotating values ride OFF-manifest (TOKEN-BROKER B1/B2).
|
|
1261
721
|
*/
|
|
1262
|
-
declare function pinProvidedSessionManifestEnvironment(agent: Agent<any, any>, session: SandboxSessionLike, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): Promise<void>;
|
|
722
|
+
export declare function pinProvidedSessionManifestEnvironment(agent: Agent<any, any>, session: SandboxSessionLike, context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent">): Promise<void>;
|
|
1263
723
|
/**
|
|
1264
724
|
* The one-truth owned-path platform setup: the manifest-env pin (align the turn's
|
|
1265
725
|
* manifest to the live box's baked env + report drift, NEVER die on it) plus the
|
|
@@ -1281,7 +741,7 @@ declare function pinProvidedSessionManifestEnvironment(agent: Agent<any, any>, s
|
|
|
1281
741
|
* run-scoped provider tokens (minted at establish time, not turn start);
|
|
1282
742
|
* unset ⇒ read the seeds off the agent exactly as the eager path does.
|
|
1283
743
|
*/
|
|
1284
|
-
declare function runOwnedSandboxSetup(agent: Agent<any, any>, session: SandboxSessionLike, setupSession: SandboxSessionLike, opts: {
|
|
744
|
+
export declare function runOwnedSandboxSetup(agent: Agent<any, any>, session: SandboxSessionLike, setupSession: SandboxSessionLike, opts: {
|
|
1285
745
|
settings: Settings;
|
|
1286
746
|
environment: Record<string, string>;
|
|
1287
747
|
preparedInput?: PreparedAgentInput;
|
|
@@ -1293,30 +753,40 @@ declare function runOwnedSandboxSetup(agent: Agent<any, any>, session: SandboxSe
|
|
|
1293
753
|
toolspaceTokenSeedOverride?: string;
|
|
1294
754
|
commandRunner?: SandboxLifecycleCommandRunner;
|
|
1295
755
|
}): Promise<void>;
|
|
1296
|
-
declare function withSandboxFileDownloads(client: SandboxClient, downloads: SandboxFileDownload[], context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent" | "runAs" | "commandRunner">): SandboxClient;
|
|
1297
|
-
declare function materializeSandboxFileDownloads(session: SandboxSessionLike, downloads: SandboxFileDownload[], context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent" | "runAs" | "commandRunner">): Promise<SandboxFileDownloadMaterializationResult>;
|
|
1298
|
-
declare function sandboxFileDownloadFailureNote(failures: SandboxFileDownloadFailure[]): string;
|
|
1299
|
-
declare function sandboxFileDownloadsForAgent(agent: unknown): SandboxFileDownload[];
|
|
756
|
+
export declare function withSandboxFileDownloads(client: SandboxClient, downloads: SandboxFileDownload[], context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent" | "runAs" | "commandRunner">): SandboxClient;
|
|
757
|
+
export declare function materializeSandboxFileDownloads(session: SandboxSessionLike, downloads: SandboxFileDownload[], context?: Pick<SandboxLifecycleHookContext, "onRuntimeEvent" | "runAs" | "commandRunner">): Promise<SandboxFileDownloadMaterializationResult>;
|
|
758
|
+
export declare function sandboxFileDownloadFailureNote(failures: SandboxFileDownloadFailure[]): string;
|
|
759
|
+
export declare function sandboxFileDownloadsForAgent(agent: unknown): SandboxFileDownload[];
|
|
1300
760
|
/**
|
|
1301
761
|
* Normalize a tool-call output for the lossy `agent.toolCall.output` audit event.
|
|
1302
762
|
* Inline image bytes/data URLs become a compact `media_preview` with exact byte
|
|
1303
763
|
* length where knowable and `fullOutputAvailable:false`. The model-facing output
|
|
1304
764
|
* is not changed here, and mixed arrays retain their non-image text/error facts.
|
|
1305
765
|
*/
|
|
1306
|
-
declare function normalizeToolOutputForEvent(output: unknown): unknown;
|
|
1307
|
-
declare function normalizeSdkEvent(event: RunStreamEvent): NormalizedRuntimeEvent[];
|
|
1308
|
-
declare function modelResponseUsageFromSdkEvent(event: RunStreamEvent): ModelResponseUsage | null;
|
|
766
|
+
export declare function normalizeToolOutputForEvent(output: unknown): unknown;
|
|
767
|
+
export declare function normalizeSdkEvent(event: RunStreamEvent): NormalizedRuntimeEvent[];
|
|
768
|
+
export declare function modelResponseUsageFromSdkEvent(event: RunStreamEvent): ModelResponseUsage | null;
|
|
1309
769
|
/** Normalize usage from either a Responses or Chat Completions result. */
|
|
1310
|
-
declare function modelResponseUsageFromResponse(response: unknown): ModelResponseUsage | null;
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
770
|
+
export declare function modelResponseUsageFromResponse(response: unknown): ModelResponseUsage | null;
|
|
771
|
+
export type ModelResponseServiceTierEvent = {
|
|
772
|
+
source: "normalized" | "provider";
|
|
773
|
+
serviceTier: string | null;
|
|
774
|
+
};
|
|
775
|
+
/**
|
|
776
|
+
* Read the provider's terminal service tier without depending on usage being
|
|
777
|
+
* present. The normalized terminal can omit provider-only fields, so callers
|
|
778
|
+
* should treat the raw provider response as the fail-closed authority.
|
|
779
|
+
*/
|
|
780
|
+
export declare function modelResponseServiceTierFromSdkEvent(event: RunStreamEvent): ModelResponseServiceTierEvent | null;
|
|
781
|
+
export declare function serializeApprovals(interruptions: unknown[]): unknown[];
|
|
782
|
+
export declare function serializeHumanInputRequests(interruptions: unknown[]): SerializedHumanInputInterruption[];
|
|
783
|
+
export declare function buildManifest(settings: Settings, resources: ResourceRef[], environment?: Record<string, string>, fileResourceDownloads?: SandboxFileDownload[]): Manifest;
|
|
784
|
+
export declare function repositoryWorkspaceSkillPathsOption(resources: readonly ResourceRef[]): {
|
|
1315
785
|
workspaceSkillPaths?: readonly WorkspaceSkillSearchPath[];
|
|
1316
786
|
};
|
|
1317
|
-
type SandboxLifecycleHookPhase = "beforeAgentStart";
|
|
1318
|
-
type SandboxLifecycleCommandRunner = (session: TurnSandboxCommandSession, args: TurnSandboxCommandArgs) => Promise<unknown>;
|
|
1319
|
-
type SandboxLifecycleHookContext = {
|
|
787
|
+
export type SandboxLifecycleHookPhase = "beforeAgentStart";
|
|
788
|
+
export type SandboxLifecycleCommandRunner = (session: TurnSandboxCommandSession, args: TurnSandboxCommandArgs) => Promise<unknown>;
|
|
789
|
+
export type SandboxLifecycleHookContext = {
|
|
1320
790
|
environment: Record<string, string>;
|
|
1321
791
|
onRuntimeEvent?: (event: NormalizedRuntimeEvent) => Promise<void> | void;
|
|
1322
792
|
runAs?: string;
|
|
@@ -1328,20 +798,20 @@ type SandboxLifecycleHookContext = {
|
|
|
1328
798
|
rigSetup?: RigSetupDescriptor;
|
|
1329
799
|
commandRunner?: SandboxLifecycleCommandRunner;
|
|
1330
800
|
};
|
|
1331
|
-
type RigSetupDescriptor = {
|
|
801
|
+
export type RigSetupDescriptor = {
|
|
1332
802
|
rigId: string;
|
|
1333
803
|
versionId: string;
|
|
1334
804
|
rigName: string;
|
|
1335
805
|
script: string;
|
|
1336
806
|
timeoutMs: number;
|
|
1337
807
|
};
|
|
1338
|
-
type SandboxLifecycleHook = {
|
|
808
|
+
export type SandboxLifecycleHook = {
|
|
1339
809
|
id: string;
|
|
1340
810
|
phase: SandboxLifecycleHookPhase;
|
|
1341
811
|
shouldRun?: (context: SandboxLifecycleHookContext) => boolean;
|
|
1342
812
|
run: (session: SandboxSessionLike, context: SandboxLifecycleHookContext) => Promise<void>;
|
|
1343
813
|
};
|
|
1344
|
-
declare function sandboxLifecycleHooksForIds(ids: string[]): SandboxLifecycleHook[];
|
|
814
|
+
export declare function sandboxLifecycleHooksForIds(ids: string[]): SandboxLifecycleHook[];
|
|
1345
815
|
/**
|
|
1346
816
|
* Run the beforeAgentStart lifecycle hooks directly against an already-live box.
|
|
1347
817
|
*
|
|
@@ -1353,8 +823,8 @@ declare function sandboxLifecycleHooksForIds(ids: string[]): SandboxLifecycleHoo
|
|
|
1353
823
|
* before starting the run so the box still gets its beforeAgentStart preparation
|
|
1354
824
|
* (repository clone + B1 askpass/token-file seed, azure-cli-login).
|
|
1355
825
|
*/
|
|
1356
|
-
declare function runBeforeAgentStartHooks(session: SandboxSessionLike, hooks: SandboxLifecycleHook[], context: SandboxLifecycleHookContext): Promise<void>;
|
|
1357
|
-
declare function withSandboxLifecycleHooks(client: SandboxClient, hooks: SandboxLifecycleHook[], context: SandboxLifecycleHookContext): SandboxClient;
|
|
826
|
+
export declare function runBeforeAgentStartHooks(session: SandboxSessionLike, hooks: SandboxLifecycleHook[], context: SandboxLifecycleHookContext): Promise<void>;
|
|
827
|
+
export declare function withSandboxLifecycleHooks(client: SandboxClient, hooks: SandboxLifecycleHook[], context: SandboxLifecycleHookContext): SandboxClient;
|
|
1358
828
|
/**
|
|
1359
829
|
* Whether the platform should seed a repository resource by `git clone` inside
|
|
1360
830
|
* the sandbox before the agent starts.
|
|
@@ -1373,10 +843,10 @@ declare function withSandboxLifecycleHooks(client: SandboxClient, hooks: Sandbox
|
|
|
1373
843
|
* is gated with no caller change, and every cloud path is byte-for-byte
|
|
1374
844
|
* unchanged.
|
|
1375
845
|
*/
|
|
1376
|
-
declare function repositoryUsesSandboxClone(settings: Settings, resource: Extract<ResourceRef, {
|
|
846
|
+
export declare function repositoryUsesSandboxClone(settings: Settings, resource: Extract<ResourceRef, {
|
|
1377
847
|
kind: "repository";
|
|
1378
848
|
}>, activeSandboxBackend?: Settings["sandboxBackend"]): boolean;
|
|
1379
|
-
declare function gitCredentialBindingHash(credentialBindingId: string): string;
|
|
849
|
+
export declare function gitCredentialBindingHash(credentialBindingId: string): string;
|
|
1380
850
|
/**
|
|
1381
851
|
* Build the off-manifest command used to atomically replace provider token files.
|
|
1382
852
|
*
|
|
@@ -1385,25 +855,25 @@ declare function gitCredentialBindingHash(credentialBindingId: string): string;
|
|
|
1385
855
|
* in-flight multi-day turn observes the replacement without changing its
|
|
1386
856
|
* manifest environment or rebuilding the sandbox.
|
|
1387
857
|
*/
|
|
1388
|
-
declare function gitProviderTokenRefreshCommand(seeds: GitTokenSeeds): string;
|
|
1389
|
-
declare function gitCredentialBindingTokenRefreshCommand(bindings: GitCredentialBindingSeed[]): string;
|
|
1390
|
-
declare function refreshGitProviderTokenFiles(session: GitCredentialTokenWriterSession, seeds: GitTokenSeeds, options?: {
|
|
858
|
+
export declare function gitProviderTokenRefreshCommand(seeds: GitTokenSeeds): string;
|
|
859
|
+
export declare function gitCredentialBindingTokenRefreshCommand(bindings: GitCredentialBindingSeed[]): string;
|
|
860
|
+
export declare function refreshGitProviderTokenFiles(session: GitCredentialTokenWriterSession, seeds: GitTokenSeeds, options?: {
|
|
1391
861
|
runAs?: string;
|
|
1392
862
|
commandRunner?: SandboxLifecycleCommandRunner;
|
|
1393
863
|
}): Promise<void>;
|
|
1394
|
-
declare function refreshGitCredentialBindingTokenFiles(session: GitCredentialTokenWriterSession, bindings: GitCredentialBindingSeed[], options?: {
|
|
864
|
+
export declare function refreshGitCredentialBindingTokenFiles(session: GitCredentialTokenWriterSession, bindings: GitCredentialBindingSeed[], options?: {
|
|
1395
865
|
runAs?: string;
|
|
1396
866
|
commandRunner?: SandboxLifecycleCommandRunner;
|
|
1397
867
|
}): Promise<void>;
|
|
1398
|
-
declare function repositoryCloneCommand(resources: Extract<ResourceRef, {
|
|
868
|
+
export declare function repositoryCloneCommand(resources: Extract<ResourceRef, {
|
|
1399
869
|
kind: "repository";
|
|
1400
870
|
}>[], bindings?: GitCredentialBindingSeed[]): string;
|
|
1401
|
-
declare function toolspaceTokenSeedCommand(options?: {
|
|
871
|
+
export declare function toolspaceTokenSeedCommand(options?: {
|
|
1402
872
|
tokenFile?: string;
|
|
1403
873
|
legacyTokenFile?: string;
|
|
1404
874
|
}): string;
|
|
1405
|
-
declare function runToolspaceTokenSeedHook(session: SandboxSessionLike, context: SandboxLifecycleHookContext): Promise<void>;
|
|
1406
|
-
declare function refreshToolspaceTokenFile(session: ToolspaceTokenWriterSession, token: string, options?: {
|
|
875
|
+
export declare function runToolspaceTokenSeedHook(session: SandboxSessionLike, context: SandboxLifecycleHookContext): Promise<void>;
|
|
876
|
+
export declare function refreshToolspaceTokenFile(session: ToolspaceTokenWriterSession, token: string, options?: {
|
|
1407
877
|
runAs?: string;
|
|
1408
878
|
commandRunner?: SandboxLifecycleCommandRunner;
|
|
1409
879
|
tokenFile?: string;
|
|
@@ -1423,7 +893,7 @@ declare function refreshToolspaceTokenFile(session: ToolspaceTokenWriterSession,
|
|
|
1423
893
|
* The heredoc delimiter is quoted, so the script content is executed verbatim
|
|
1424
894
|
* with no host-side expansion.
|
|
1425
895
|
*/
|
|
1426
|
-
declare function rigSetupScriptCommand(script: string, versionId: string, timeoutMs?: number, markerRoot?: string): string;
|
|
896
|
+
export declare function rigSetupScriptCommand(script: string, versionId: string, timeoutMs?: number, markerRoot?: string): string;
|
|
1427
897
|
/**
|
|
1428
898
|
* The rig-setup beforeAgentStart hook (M3). Runs the frozen rig version's setup
|
|
1429
899
|
* script exactly once per box (marker-guarded), under the RIG's own timeout
|
|
@@ -1435,16 +905,16 @@ declare function rigSetupScriptCommand(script: string, versionId: string, timeou
|
|
|
1435
905
|
* and on failure THROWS (fail the turn closed) with a message naming the
|
|
1436
906
|
* rig/version and a bounded tail of the setup output.
|
|
1437
907
|
*/
|
|
1438
|
-
declare function runRigSetupHook(session: SandboxSessionLike, context?: SandboxLifecycleHookContext): Promise<void>;
|
|
1439
|
-
declare function runRepositoryCloneHook(session: SandboxSessionLike, resources: Extract<ResourceRef, {
|
|
908
|
+
export declare function runRigSetupHook(session: SandboxSessionLike, context?: SandboxLifecycleHookContext): Promise<void>;
|
|
909
|
+
export declare function runRepositoryCloneHook(session: SandboxSessionLike, resources: Extract<ResourceRef, {
|
|
1440
910
|
kind: "repository";
|
|
1441
911
|
}>[], context?: SandboxLifecycleHookContext): Promise<void>;
|
|
1442
|
-
declare function azureCliLoginCommand(): string;
|
|
1443
|
-
declare function sandboxCommandExitCode(result: unknown): number | null;
|
|
1444
|
-
declare function sandboxCommandOutput(result: unknown): string;
|
|
1445
|
-
declare function sandboxCommandStillRunning(result: unknown): boolean;
|
|
1446
|
-
declare function runAzureCliLoginHook(session: SandboxSessionLike, context?: SandboxLifecycleHookContext): Promise<void>;
|
|
1447
|
-
declare function azureOpenAIDefaultQuery(settings: Pick<Settings, "azureOpenaiApiVersion">, baseURL: string): Record<string, string> | undefined;
|
|
912
|
+
export declare function azureCliLoginCommand(): string;
|
|
913
|
+
export declare function sandboxCommandExitCode(result: unknown): number | null;
|
|
914
|
+
export declare function sandboxCommandOutput(result: unknown): string;
|
|
915
|
+
export declare function sandboxCommandStillRunning(result: unknown): boolean;
|
|
916
|
+
export declare function runAzureCliLoginHook(session: SandboxSessionLike, context?: SandboxLifecycleHookContext): Promise<void>;
|
|
917
|
+
export declare function azureOpenAIDefaultQuery(settings: Pick<Settings, "azureOpenaiApiVersion">, baseURL: string): Record<string, string> | undefined;
|
|
1448
918
|
/**
|
|
1449
919
|
* The skill source fed to the SDK Skills capability. Without pack or curated
|
|
1450
920
|
* skills this is the plain bundled local-dir source, byte-for-byte the
|
|
@@ -1455,6 +925,4 @@ declare function azureOpenAIDefaultQuery(settings: Pick<Settings, "azureOpenaiAp
|
|
|
1455
925
|
* `load_skill` for all of them. A pack skill shadows a bundled or curated
|
|
1456
926
|
* skill with the same directory name, case-insensitively.
|
|
1457
927
|
*/
|
|
1458
|
-
declare function lazySkillSourceWithPackSkills(packSkills: PackSkill[], skillLibrarySkills?: PackSkill[]): LocalDirLazySkillSource;
|
|
1459
|
-
|
|
1460
|
-
export { type AgentSegmentInput, type BuildAgentOptions, COMPACTION_PROMPT, COMPACTION_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, CodexSubscriptionUnavailableError, type CompactionDecision, type CompactionItem, CompactionNeededError, CompactionProviderResponseError, ComputerActionError, ComputerReadOnlyError, type ComputerToolMode, ComputerUnavailableError, type ComputerUseArgs, ComputerUseCapability, type ConnectedMcpServerBatches, type ContextRobustnessFilterOptions, DEFAULT_COMPACTION_THRESHOLD_RATIO, type EffectiveSkillSelection, EmptyCompactionSummaryError, GENESIS_TITLE_DIRECTIVE, type GitCredentialBindingSeed, type GitCredentialTokenWriterSession, type GitTokenSeeds, HUMAN_INPUT_TOOL_NAME, type HistoryItem, MAX_COMPACTION_THRESHOLD_RATIO, MAX_MODEL_USAGE_TOKEN_COUNT, MIN_COMPACTION_THRESHOLD_RATIO, type ModelCallUsageInput, type ModelCallUsageNormalization, type ModelCallUsageTelemetry, type ModelResponseUsage, MultiProviderModelProvider, type NormalizedRuntimeEvent, type OpenGeniRuntime, type PackSkill, type PackSkillFile, type PersistentSessionSettings, type PrepareInputOptions, type PrepareToolsOptions, type PreparedAgentInput, type PreparedAgentTools, type PreparedCompactionPromptInput, type ProductionRuntimeOverrides, type ResolveConnectionCredentialInput, type ResolveConnectionCredentialResult, type RigInstructionsContext, type RigSetupDescriptor, type RunAgentStreamOptions, RunCredentialSessionReady, RuntimeMetricsHooks, SUMMARY_BUFFER_TOKENS, SUMMARY_PREFIX, SandboxComputer, type SandboxComputerOptions, type SandboxFileDownload, type SandboxFileDownloadFailure, type SandboxFileDownloadMaterializationResult, type SandboxLifecycleCommandRunner, type SandboxLifecycleHook, type SandboxLifecycleHookContext, type SandboxLifecycleHookPhase, type SerializedHumanInputInterruption, TOOLSPACE_PROGRAMMATIC_DIRECTIVE, type ToolspaceTokenWriterSession, type TurnSandboxCommandArgs, TurnSandboxCommandCancelledError, type TurnSandboxCommandSession, type TurnToolCancellationController, type TurnToolCancellationFence, USER_MESSAGE_TRUNCATION_MARKER, type WorkspaceEnvironmentContext, WorkspaceModelPolicyBlockedError, agentsErrorRunState, appendGenesisTitleDirective, appendGitCredentialBindingInstructions, appendPersistentSessionSettings, appendSessionInstructions, appendToolspaceInstructions, appendTurnInstructions, appendWorkspaceMemory, applyMissingManifestEntries, azureCliLoginCommand, azureOpenAIDefaultQuery, boundModelToolOutputsFilterForSettings, buildAgentCapabilities, buildCompactionPromptInput, buildCompactionReplacementHistory, buildManifest, buildModelInstance, buildOpenAIClientFromSettings, buildOpenGeniAgent, buildProviderClient, buildSummaryItem, callModelInputFilterForSettings, clampCompactionThresholdRatio, compactionProviderFailureDiagnostics, compactionReplacementFingerprint, compactionResponseDiagnostics, compactionThresholdTokens, composeAgentInstructions, computerUse, configureOpenAI, configureRuntimeMetricsHooks, connectMcpServersInBatches, contextRobustnessFilterForSettings, coreInstructions, createProductionAgentRuntime, createTurnToolCancellationController, decideCompaction, effectiveSkillSelectionsForAgent, elideSupersededViewImagePairs, elideSupersededViewImagesFilter, ensureReadableStreamFrom, estimateCompleteModelInput, estimateItemTokens, estimateSerializedValueTokens, estimateTokens, extractResponseOutputText, findCompactionNeededError, gitCredentialBindingHash, gitCredentialBindingTokenRefreshCommand, gitProviderTokenRefreshCommand, hasModelGeneratedItem, isCompactionSummary, isUserMessage, latestCompactionReplacementFingerprint, lazySkillSourceWithPackSkills, manifestEnvironmentDrift, materializeSandboxFileDownloads, maxTurnsExceededRunState, mcpToolErrorOutput, modelCallUsageTelemetry, modelResponseUsageFromResponse, modelResponseUsageFromSdkEvent, modelUsageTokenCountOrNull, neutralizeToolSearchItemsInSerializedRunState, normalizeComputerCallsFilter, normalizeModelCallUsage, normalizeSdkEvent, normalizeToolOutputForEvent, oneShotGenesisTitleInputFilter, pinProvidedSessionManifestEnvironment, prefixedMcpToolName, prepareAgentTools, prepareCompactionPromptInput, prepareRunInput, refreshGitCredentialBindingTokenFiles, refreshGitProviderTokenFiles, refreshToolspaceTokenFile, renderCompactionPromptInputForChat, repositoryCloneCommand, repositoryUsesSandboxClone, repositoryWorkspaceSkillPathsOption, resolveTurnModel, rigInstructions, rigSetupScriptCommand, runAgentStream, runAzureCliLoginHook, runBeforeAgentStartHooks, runOwnedSandboxSetup, runRepositoryCloneHook, runRigSetupHook, runToolspaceTokenSeedHook, sandboxCommandExitCode, sandboxCommandOutput, sandboxCommandStillRunning, sandboxFileDownloadFailureNote, sandboxFileDownloadsForAgent, sandboxLifecycleHooksForIds, sandboxRunAs, sanitizeHistoryItemsForModel, serializeApprovals, serializeHumanInputRequests, stripProviderItemIdsFilter, stripReasoningEncryptedContent, stripReasoningIdentityFromSerializedRunState, summarizeForCompaction, toolspaceTokenSeedCommand, withManifestRefreshOnResume, withSandboxFileDownloads, withSandboxLifecycleHooks, withStructuredViewImageFunctionResults, workspaceEnvironmentInstructions };
|
|
928
|
+
export declare function lazySkillSourceWithPackSkills(packSkills: PackSkill[], skillLibrarySkills?: PackSkill[]): LocalDirLazySkillSource;
|