@opengeni/runtime 0.2.1 → 0.2.3
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-2PO56VAL.js → chunk-KNW7AMQB.js} +11 -4
- package/dist/chunk-KNW7AMQB.js.map +1 -0
- package/dist/index.d.ts +113 -177
- package/dist/index.js +371 -171
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +6 -4
- package/dist/sandbox/index.js +1 -1
- package/package.json +5 -5
- package/src/context-compaction.ts +217 -348
- package/src/image-history.ts +149 -0
- package/src/index.ts +184 -60
- package/src/sandbox/display-stack.ts +61 -12
- package/src/sandbox-computer.ts +90 -18
- package/dist/chunk-2PO56VAL.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ type SandboxComputerOptions = {
|
|
|
18
18
|
typeDelayMs?: number;
|
|
19
19
|
readOnly?: boolean;
|
|
20
20
|
screenshotTmpDir?: string;
|
|
21
|
+
screenshotWarmupBudgetMs?: number;
|
|
22
|
+
screenshotRetryDelayMs?: number;
|
|
21
23
|
};
|
|
22
24
|
/** No exec/execCommand on the session, or the display is not up. */
|
|
23
25
|
declare class ComputerUnavailableError extends Error {
|
|
@@ -53,6 +55,8 @@ declare class SandboxComputer implements Computer {
|
|
|
53
55
|
private readonly typeDelayMs;
|
|
54
56
|
private readonly readOnly;
|
|
55
57
|
private readonly tmp;
|
|
58
|
+
private readonly screenshotWarmupBudgetMs;
|
|
59
|
+
private readonly screenshotRetryDelayMs;
|
|
56
60
|
constructor(session: SandboxSessionLike, opts?: SandboxComputerOptions);
|
|
57
61
|
/** Rebind to a freshly resumed-by-id session after a box rollover / re-establish. */
|
|
58
62
|
rebind(session: SandboxSessionLike): void;
|
|
@@ -70,12 +74,31 @@ declare class SandboxComputer implements Computer {
|
|
|
70
74
|
drag(path: [number, number][]): Promise<void>;
|
|
71
75
|
wait(): Promise<void>;
|
|
72
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* EXPLICIT tool-transport selection, decided by the caller that knows the
|
|
79
|
+
* provider's true wire identity (the worker's model resolution — see agent-turn.ts),
|
|
80
|
+
* NOT inferred from the bound model instance's constructor name. This is the
|
|
81
|
+
* HARDENING seam: `supportsStructuredToolOutputTransport` string-sniffs the
|
|
82
|
+
* constructor for "ChatCompletions", which a wrapped / proxied / minified model
|
|
83
|
+
* instance would defeat — silently handing a chat-completions provider the HOSTED
|
|
84
|
+
* `computer_use_preview` tool it 400s on every turn. When `toolMode` is set, tools()
|
|
85
|
+
* OBEYS it and never consults the sniff:
|
|
86
|
+
* • "hosted" → the single hosted `computer_use_preview` tool (Responses backends).
|
|
87
|
+
* • "function-image" → the FUNCTION `computer_*` tools with screenshots delivered as a
|
|
88
|
+
* structured `{type:'image'}` output (the codex/ChatGPT backend,
|
|
89
|
+
* which rejects hosted tool types but SEES structured image results).
|
|
90
|
+
* • "function-text" → the FUNCTION tools with screenshots rendered as a text
|
|
91
|
+
* `data:…;base64` URL (chat-completions providers, which can't read
|
|
92
|
+
* structured image tool results).
|
|
93
|
+
*/
|
|
94
|
+
type ComputerToolMode = "hosted" | "function-image" | "function-text";
|
|
73
95
|
type ComputerUseArgs = {
|
|
74
96
|
dimensions?: [number, number];
|
|
75
97
|
readOnly?: boolean;
|
|
76
98
|
display?: string;
|
|
77
99
|
needsApproval?: boolean | ((ctx: unknown, action: unknown) => boolean | Promise<boolean>);
|
|
78
100
|
imageFunctionResults?: boolean;
|
|
101
|
+
toolMode?: ComputerToolMode;
|
|
79
102
|
};
|
|
80
103
|
declare function computerUse(args?: ComputerUseArgs): ComputerUseCapability;
|
|
81
104
|
/**
|
|
@@ -101,6 +124,9 @@ declare class ComputerUseCapability extends Capability {
|
|
|
101
124
|
readonly type = "computer-use";
|
|
102
125
|
constructor(args?: ComputerUseArgs);
|
|
103
126
|
tools(): Tool<unknown>[];
|
|
127
|
+
/** The single HOSTED `computer_use_preview` tool bound to `computer` — identical
|
|
128
|
+
* construction for the explicit "hosted" mode and the legacy structured-sniff path. */
|
|
129
|
+
private hostedComputerTool;
|
|
104
130
|
}
|
|
105
131
|
|
|
106
132
|
/**
|
|
@@ -258,97 +284,77 @@ declare function stripReasoningIdentityFromSerializedRunState(serialized: string
|
|
|
258
284
|
declare function neutralizeToolSearchItemsInSerializedRunState(serialized: string): string;
|
|
259
285
|
|
|
260
286
|
/**
|
|
261
|
-
* Client-side conversation context compaction (the Azure path).
|
|
262
|
-
*
|
|
263
|
-
* OpenGeni runs long-lived agent sessions whose conversation truth
|
|
264
|
-
* (`session_history_items`) grows unbounded. On the OpenAI platform the
|
|
265
|
-
* Responses API compacts server-side (the SDK's `compaction()` capability). On
|
|
266
|
-
* Azure that capability 400s (`unsupported_parameter`), so the session
|
|
267
|
-
* eventually overflows the model context window and hard-fails every turn.
|
|
268
|
-
*
|
|
269
|
-
* This module is the Azure-safe replacement. It is built from two pure pieces
|
|
270
|
-
* plus one impure step the caller wires in:
|
|
287
|
+
* Client-side conversation context compaction (the Azure/client path).
|
|
271
288
|
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* model call — see `buildCompactionMessages` / `SUMMARY_PREFIX`.
|
|
278
|
-
* 3. `applyCompaction` shape — the storage write the caller performs:
|
|
279
|
-
* supersede the prefix rows, insert the summary at the boundary position.
|
|
280
|
-
*
|
|
281
|
-
* Design constraints (non-negotiable):
|
|
282
|
-
* - The summary is a PLAIN user message, NOT the SDK `compaction` item type
|
|
283
|
-
* (that requires server-minted `encrypted_content`; a hand-rolled one risks
|
|
284
|
-
* an Azure 400).
|
|
285
|
-
* - ORPHAN SAFETY: the cut lands only at a clean turn boundary (start of a
|
|
286
|
-
* user message). No tool call_id may straddle the cut — for every
|
|
287
|
-
* `function_call` dropped, its `function_call_result` is also dropped, and
|
|
288
|
-
* vice versa. Reasoning items drop/keep with their whole turn.
|
|
289
|
-
* - SINGLE LIVE SUMMARY: each compaction folds the prior summary forward
|
|
290
|
-
* (summarize [prior summary] + [items since]); prior summaries are excluded
|
|
291
|
-
* from re-collection so drift stays bounded.
|
|
289
|
+
* This mirrors Codex CLI's compaction model: the checkpoint model sees the
|
|
290
|
+
* current active history plus one fixed checkpoint prompt, then the active
|
|
291
|
+
* history is rebuilt as all real user messages plus one summary message.
|
|
292
|
+
* Assistant messages, tool calls/results, reasoning, and images are removed
|
|
293
|
+
* from the active model-facing history; the database audit rows remain.
|
|
292
294
|
*/
|
|
293
295
|
type CompactionItem = Record<string, unknown>;
|
|
294
296
|
/**
|
|
295
|
-
* Marker stored on the synthetic summary item so
|
|
296
|
-
* next
|
|
297
|
-
* lives in the item JSON, not a DB column, so it survives verbatim replay.
|
|
297
|
+
* Marker stored on the synthetic summary item so the UI can render it and the
|
|
298
|
+
* next rebuild can exclude old summaries from the retained user-message set.
|
|
298
299
|
*/
|
|
299
300
|
declare const COMPACTION_SUMMARY_MARKER = "opengeni_context_summary";
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
declare const SUMMARY_PREFIX: string;
|
|
301
|
+
declare const SUMMARY_BUFFER_TOKENS = 20000;
|
|
302
|
+
declare const COMPACT_USER_MESSAGE_MAX_TOKENS = 20000;
|
|
303
|
+
declare const CLIENT_COMPACTION_TRIGGER_FRACTION = 0.9;
|
|
304
|
+
declare const COMPACTION_PROMPT: string;
|
|
305
|
+
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:";
|
|
306
|
+
declare const USER_MESSAGE_TRUNCATION_MARKER = "\n[... middle truncated for context compaction ...]\n";
|
|
307
307
|
/** A user-authored `message` item is the only legal turn boundary. */
|
|
308
308
|
declare function isUserMessage(item: unknown): boolean;
|
|
309
309
|
/** True for our synthetic compaction summary item. */
|
|
310
310
|
declare function isCompactionSummary(item: unknown): boolean;
|
|
311
311
|
/**
|
|
312
|
-
* Rough token estimate for an item: char/4 over its serialized text. Used
|
|
313
|
-
*
|
|
314
|
-
* token count, falling back to this when that is unavailable.
|
|
312
|
+
* Rough token estimate for an item: char/4 over its serialized text. Used for
|
|
313
|
+
* the pre-first-call fallback, per-user-message cap, and read-path airbag.
|
|
315
314
|
*/
|
|
316
315
|
declare function estimateItemTokens(item: CompactionItem): number;
|
|
317
316
|
declare function estimateTokens(items: readonly CompactionItem[]): number;
|
|
317
|
+
declare function clientCompactionThresholdTokens(input: {
|
|
318
|
+
contextWindowTokens: number;
|
|
319
|
+
contextReservedOutputTokens: number;
|
|
320
|
+
}): number;
|
|
321
|
+
type ClientCompactionDecision = {
|
|
322
|
+
shouldCompact: boolean;
|
|
323
|
+
reason: "force" | "above_threshold" | "below_threshold" | "no_history";
|
|
324
|
+
signalTokens: number;
|
|
325
|
+
thresholdTokens: number;
|
|
326
|
+
};
|
|
327
|
+
declare function decideClientCompaction(input: {
|
|
328
|
+
items: readonly CompactionItem[];
|
|
329
|
+
lastInputTokens?: number | null;
|
|
330
|
+
contextWindowTokens: number;
|
|
331
|
+
contextReservedOutputTokens: number;
|
|
332
|
+
force?: boolean;
|
|
333
|
+
}): ClientCompactionDecision;
|
|
334
|
+
declare class CompactionNeededError extends Error {
|
|
335
|
+
readonly signalTokens: number;
|
|
336
|
+
readonly thresholdTokens: number;
|
|
337
|
+
readonly signalSource: "provider" | "estimate";
|
|
338
|
+
constructor(input: {
|
|
339
|
+
signalTokens: number;
|
|
340
|
+
thresholdTokens: number;
|
|
341
|
+
signalSource: "provider" | "estimate";
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
declare function findCompactionNeededError(error: unknown, seen?: WeakSet<object>): CompactionNeededError | null;
|
|
318
345
|
/**
|
|
319
346
|
* Walk backwards from the end of `items` keeping whole turns until the kept
|
|
320
347
|
* tail would exceed `keepRecentTokens`, and return the index of the first kept
|
|
321
|
-
* item.
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
* Returns `items.length` when nothing fits within the budget yet a boundary is
|
|
325
|
-
* required (degenerate); callers treat an index of 0 or length as "no useful
|
|
326
|
-
* cut".
|
|
348
|
+
* item. Retained for the read-path budget guard only; the client compaction
|
|
349
|
+
* rebuild no longer uses a keep-recent tail.
|
|
327
350
|
*/
|
|
328
351
|
declare function findKeepBoundary(items: readonly CompactionItem[], keepRecentTokens: number): number;
|
|
329
352
|
/**
|
|
330
353
|
* READ-PATH BUDGET GUARD (last-resort backstop).
|
|
331
354
|
*
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
* model context window. The #61 orphan sanitizer is purely structural — it has
|
|
336
|
-
* NO size awareness — so without this guard an over-budget input is sent and
|
|
337
|
-
* 400s every turn, re-bricking the session.
|
|
338
|
-
*
|
|
339
|
-
* `enforceInputBudget` drops the OLDEST history at a clean turn boundary until
|
|
340
|
-
* the estimated input fits `maxTokens`, ALWAYS keeping the most recent turn(s).
|
|
341
|
-
* It is orphan-safe by construction: it only ever cuts at the start of a user
|
|
342
|
-
* message (via `findKeepBoundary`), so no tool-call pair is split. It is a
|
|
343
|
-
* crude data-loss fallback (no summary is generated) that exists solely so a
|
|
344
|
-
* single over-budget assembled input is never put on the wire — real context
|
|
345
|
-
* preservation is the summarizing pre-turn path; this is the airbag.
|
|
346
|
-
*
|
|
347
|
-
* Pure: returns a new array (same item references, in order) with an oldest
|
|
348
|
-
* prefix omitted, or the input unchanged when it already fits. The provided
|
|
349
|
-
* `trailingTokens` accounts for the un-stored part of the assembled input (the
|
|
350
|
-
* new user/continuation message + fixed system/tool overhead) so the cap is
|
|
351
|
-
* measured against the WHOLE request, not just the stored history.
|
|
355
|
+
* Drops the oldest history at a clean user-message boundary until an assembled
|
|
356
|
+
* input fits the request budget. This remains a request-local safety rail; it
|
|
357
|
+
* is not the compaction strategy.
|
|
352
358
|
*/
|
|
353
359
|
declare function enforceInputBudget<T extends CompactionItem>(items: readonly T[], maxTokens: number, trailingTokens?: number): {
|
|
354
360
|
items: T[];
|
|
@@ -356,111 +362,35 @@ declare function enforceInputBudget<T extends CompactionItem>(items: readonly T[
|
|
|
356
362
|
droppedCount: number;
|
|
357
363
|
estimatedTokens: number;
|
|
358
364
|
};
|
|
359
|
-
type CompactionPlan = {
|
|
360
|
-
/** Whether a compaction should run this turn. */
|
|
361
|
-
shouldCompact: boolean;
|
|
362
|
-
/** Why not, when shouldCompact is false (for logs/tests). */
|
|
363
|
-
reason: "below_threshold" | "no_boundary" | "nothing_to_summarize" | "compact";
|
|
364
|
-
/**
|
|
365
|
-
* The signal-token count the trigger decision was made on:
|
|
366
|
-
* max(actual last-turn input tokens, char/4 estimate of the active items).
|
|
367
|
-
* Recorded for logging / metrics and so a caller can reason about pressure.
|
|
368
|
-
*/
|
|
369
|
-
signalTokens: number;
|
|
370
|
-
/**
|
|
371
|
-
* True when the signal reached hardFraction*B — the session is at/over the
|
|
372
|
-
* hard ceiling and compaction was forced even if the recorded last-turn count
|
|
373
|
-
* was stale-low. The boundary walk is run with a SHRUNK keep-recent budget in
|
|
374
|
-
* this case so an over-budget history always yields a non-empty prefix to
|
|
375
|
-
* summarize (the everything-is-"recent" deadlock can't strand it un-compacted).
|
|
376
|
-
*/
|
|
377
|
-
hardForced: boolean;
|
|
378
|
-
/** Index (into the active items) where the kept tail begins. */
|
|
379
|
-
boundaryIndex: number;
|
|
380
|
-
/**
|
|
381
|
-
* The prefix items to summarize: active[0, boundaryIndex), EXCLUDING any
|
|
382
|
-
* prior compaction summary (which is folded forward via `priorSummaryItem`).
|
|
383
|
-
*/
|
|
384
|
-
prefixItems: CompactionItem[];
|
|
385
|
-
/** The prior live summary item folded into this compaction, if any. */
|
|
386
|
-
priorSummaryItem: CompactionItem | null;
|
|
387
|
-
/** Items kept verbatim: active[boundaryIndex, end). */
|
|
388
|
-
tailItems: CompactionItem[];
|
|
389
|
-
};
|
|
390
|
-
type PlanCompactionInput = {
|
|
391
|
-
/** Active history items in position order (already excludes superseded rows). */
|
|
392
|
-
items: readonly CompactionItem[];
|
|
393
|
-
/**
|
|
394
|
-
* Actual input tokens reported for the last model call of the previous turn.
|
|
395
|
-
* Null/undefined falls back to a char/4 estimate over `items`.
|
|
396
|
-
*/
|
|
397
|
-
lastInputTokens?: number | null;
|
|
398
|
-
/** Usable input budget B = window - reserved output. */
|
|
399
|
-
inputBudgetTokens: number;
|
|
400
|
-
softFraction: number;
|
|
401
|
-
hardFraction: number;
|
|
402
|
-
keepRecentTokens: number;
|
|
403
|
-
/**
|
|
404
|
-
* Operator-forced compaction (the /compact command): bypass the soft-limit
|
|
405
|
-
* token trigger and compact now if there is anything to summarize. The
|
|
406
|
-
* boundary / nothing-to-summarize guards still apply — force never invents a
|
|
407
|
-
* cut that would orphan a tool-call pair or summarize an empty prefix.
|
|
408
|
-
*/
|
|
409
|
-
force?: boolean;
|
|
410
|
-
};
|
|
411
365
|
/**
|
|
412
|
-
*
|
|
413
|
-
*
|
|
414
|
-
* Trigger: signal tokens >= softFraction*B (soft) or hardFraction*B (hard).
|
|
415
|
-
* Signal = MAX(actual last-turn input tokens, char/4 estimate of the active
|
|
416
|
-
* items). The max — not "trust the recorded count, estimate only when it's
|
|
417
|
-
* null" — is the self-heal fix: `sessions.last_input_tokens` is written ONLY
|
|
418
|
-
* when a model response reports usage, so a turn that OVERFLOWS on its first
|
|
419
|
-
* model call records NOTHING and the column keeps a STALE-POSITIVE value from
|
|
420
|
-
* the last good turn (e.g. ~600k). Trusting that stale-low number let an
|
|
421
|
-
* actually-over-budget history (>1.05M) slip under the soft limit and overflow
|
|
422
|
-
* again, re-bricking with no self-heal. Taking the max means a bloated history
|
|
423
|
-
* triggers compaction regardless of a stale recorded count.
|
|
424
|
-
*
|
|
425
|
-
* Hard force (hardFraction*B): at/over the hard ceiling we compact even if the
|
|
426
|
-
* recorded count was stale-low, AND we run the boundary walk with a shrunk
|
|
427
|
-
* keep-recent budget so an over-budget history always yields a non-empty prefix
|
|
428
|
-
* — otherwise a history where the whole thing reads as "recent" (tail within
|
|
429
|
-
* keepRecentTokens) would find no prefix and strand the session over budget.
|
|
430
|
-
*
|
|
431
|
-
* Boundary: the earliest user-message boundary whose kept tail fits the
|
|
432
|
-
* (possibly shrunk) keep-recent budget. The prefix before it (minus any prior
|
|
433
|
-
* summary, which is folded forward) is what gets summarized.
|
|
434
|
-
*/
|
|
435
|
-
declare function planCompaction(input: PlanCompactionInput): CompactionPlan;
|
|
436
|
-
/** Extract the plain-text body of the prior summary item, if any. */
|
|
437
|
-
declare function compactionSummaryText(item: CompactionItem | null): string;
|
|
438
|
-
/**
|
|
439
|
-
* Build the synthetic summary item (a plain user message) to insert at the
|
|
440
|
-
* boundary. `summaryBody` is the model-generated working-memory bridge.
|
|
441
|
-
*/
|
|
442
|
-
declare function buildSummaryItem(summaryBody: string): CompactionItem;
|
|
443
|
-
/**
|
|
444
|
-
* Instruction prompt for the summarizer model call. Leans on OpenGeni's durable
|
|
445
|
-
* structured memory (the notebook) so the summary stays a light working-memory
|
|
446
|
-
* bridge, never a place secret values get copied.
|
|
366
|
+
* The exact checkpoint input shape: current active history followed by Codex's
|
|
367
|
+
* checkpoint prompt as a synthesized user message.
|
|
447
368
|
*/
|
|
448
|
-
declare
|
|
369
|
+
declare function buildCompactionPromptInput(items: readonly CompactionItem[]): CompactionItem[];
|
|
449
370
|
/**
|
|
450
|
-
*
|
|
451
|
-
*
|
|
452
|
-
*
|
|
371
|
+
* Build the active history after compaction:
|
|
372
|
+
* all real user messages (prior summaries excluded, images removed, each
|
|
373
|
+
* message capped) plus one marked summary item.
|
|
453
374
|
*/
|
|
454
|
-
declare function
|
|
375
|
+
declare function buildCompactionReplacementHistory(items: readonly CompactionItem[], summaryBody: string): CompactionItem[];
|
|
455
376
|
/**
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* tools, no streaming) and feeds the text result into `buildSummaryItem`.
|
|
377
|
+
* Build the synthetic summary item (a plain user message) appended to the
|
|
378
|
+
* rebuilt active history.
|
|
459
379
|
*/
|
|
460
|
-
declare function
|
|
461
|
-
|
|
462
|
-
|
|
380
|
+
declare function buildSummaryItem(summaryBody: string): CompactionItem;
|
|
381
|
+
declare function renderCompactionPromptInputForChat(input: readonly CompactionItem[]): string;
|
|
382
|
+
|
|
383
|
+
declare const SCREENSHOT_OMITTED_PLACEHOLDER = "[screenshot omitted: an older desktop frame \u2014 the full image remains in the session event log]";
|
|
384
|
+
type ElideStaleScreenshotsResult<T> = {
|
|
385
|
+
items: T[];
|
|
386
|
+
imageCount: number;
|
|
387
|
+
elidedCount: number;
|
|
463
388
|
};
|
|
389
|
+
type ElideStaleScreenshotsOptions = {
|
|
390
|
+
keepLast?: number;
|
|
391
|
+
placeholder?: string;
|
|
392
|
+
};
|
|
393
|
+
declare function elideStaleScreenshotImages<T extends AgentInputItem>(items: readonly T[], options?: ElideStaleScreenshotsOptions): ElideStaleScreenshotsResult<T>;
|
|
464
394
|
|
|
465
395
|
type NormalizedRuntimeEvent = {
|
|
466
396
|
type: SessionEventType;
|
|
@@ -591,10 +521,10 @@ declare class CodexSubscriptionUnavailableError extends Error {
|
|
|
591
521
|
declare function configureOpenAI(settings: Settings): void;
|
|
592
522
|
/**
|
|
593
523
|
* Run the compaction summarizer as one plain, tool-less, non-streaming model
|
|
594
|
-
* call against the resolved provider. `
|
|
595
|
-
*
|
|
524
|
+
* call against the resolved provider. `input` is the active history plus
|
|
525
|
+
* Codex's checkpoint prompt. Returns the trimmed summary text, or null on any
|
|
596
526
|
* failure (the caller treats a failed summarize as "skip compaction this turn"
|
|
597
|
-
*
|
|
527
|
+
* - never fatal). The call deliberately does NOT request reasoning encryption,
|
|
598
528
|
* tools, or server-side compaction; it is a self-contained summarize.
|
|
599
529
|
*
|
|
600
530
|
* Provider-aware: the summary always runs on the SAME provider that serves the
|
|
@@ -606,10 +536,7 @@ declare function configureOpenAI(settings: Settings): void;
|
|
|
606
536
|
* legacy global-client callers are byte-for-byte unchanged. store:false is set
|
|
607
537
|
* only on the OpenAI-platform Responses path (Azure rejects it; chat ignores it).
|
|
608
538
|
*/
|
|
609
|
-
declare function summarizeForCompaction(settings: Settings,
|
|
610
|
-
system: string;
|
|
611
|
-
user: string;
|
|
612
|
-
}, options?: {
|
|
539
|
+
declare function summarizeForCompaction(settings: Settings, input: Array<Record<string, unknown>>, options?: {
|
|
613
540
|
client?: OpenAI;
|
|
614
541
|
api?: ModelProviderApi;
|
|
615
542
|
maxOutputTokens?: number;
|
|
@@ -632,6 +559,7 @@ type BuildAgentOptions = {
|
|
|
632
559
|
encryptedReasoning?: boolean;
|
|
633
560
|
contextWindowTokens?: number;
|
|
634
561
|
structuredToolTransport?: boolean;
|
|
562
|
+
computerToolMode?: ComputerToolMode;
|
|
635
563
|
codexConnectorNamespaces?: ReadonlySet<string>;
|
|
636
564
|
sandboxEnvironment?: Record<string, string>;
|
|
637
565
|
activeSandboxBackend?: Settings["sandboxBackend"];
|
|
@@ -716,6 +644,7 @@ declare function buildAgentCapabilities(settings: Settings, packSkills: PackSkil
|
|
|
716
644
|
compactionMode?: ContextCompactionMode;
|
|
717
645
|
contextWindowTokens?: number;
|
|
718
646
|
structuredToolTransport?: boolean;
|
|
647
|
+
computerToolMode?: ComputerToolMode;
|
|
719
648
|
}): ReturnType<typeof Capabilities.default>;
|
|
720
649
|
declare function sandboxRunAs(_settings: Settings): string | undefined;
|
|
721
650
|
type PreparedAgentTools = {
|
|
@@ -749,6 +678,7 @@ type RunAgentStreamOptions = {
|
|
|
749
678
|
sandboxClient?: unknown;
|
|
750
679
|
sandboxEnvironment?: Record<string, string>;
|
|
751
680
|
onRuntimeEvent?: (event: NormalizedRuntimeEvent) => Promise<void> | void;
|
|
681
|
+
contextCompactionSignalTokens?: () => number | null | undefined;
|
|
752
682
|
ownedSandbox?: {
|
|
753
683
|
client: unknown;
|
|
754
684
|
session: unknown;
|
|
@@ -757,6 +687,10 @@ type RunAgentStreamOptions = {
|
|
|
757
687
|
};
|
|
758
688
|
callModelInputFilter?: CallModelInputFilter;
|
|
759
689
|
};
|
|
690
|
+
type ContextRobustnessFilterOptions = {
|
|
691
|
+
contextCompactionSignalTokens?: () => number | null | undefined;
|
|
692
|
+
throwOnCompactionNeeded?: boolean;
|
|
693
|
+
};
|
|
760
694
|
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.";
|
|
761
695
|
/**
|
|
762
696
|
* callModelInputFilter that removes provider-assigned item ids (rs_/msg_/fc_…)
|
|
@@ -787,13 +721,15 @@ declare const stripProviderItemIdsFilter: CallModelInputFilter;
|
|
|
787
721
|
* never mutated.
|
|
788
722
|
*/
|
|
789
723
|
declare const normalizeComputerCallsFilter: CallModelInputFilter;
|
|
724
|
+
declare function contextRobustnessFilterForSettings(settings: Settings, options?: ContextRobustnessFilterOptions): CallModelInputFilter;
|
|
790
725
|
/**
|
|
791
726
|
* The model-input filter applied before every model call. The computer_call
|
|
792
727
|
* action/actions normalizer is ALWAYS on (the Azure endpoint 400s without it);
|
|
793
728
|
* the provider-item-id strip is layered on top when the configured policy
|
|
794
|
-
* selects it
|
|
729
|
+
* selects it; the context-robustness guard then elides stale screenshots on
|
|
730
|
+
* every mode and applies hard budget trimming only on the client-compaction path.
|
|
795
731
|
*/
|
|
796
|
-
declare function callModelInputFilterForSettings(settings: Settings): CallModelInputFilter | undefined;
|
|
732
|
+
declare function callModelInputFilterForSettings(settings: Settings, options?: ContextRobustnessFilterOptions): CallModelInputFilter | undefined;
|
|
797
733
|
declare function runAgentStream(agent: Agent<any, any>, input: PreparedAgentInput | string | RunState<any, any>, settings: Settings, overrides?: RunAgentStreamOptions): Promise<_openai_agents.StreamedRunResult<any, Agent<any, any>>>;
|
|
798
734
|
|
|
799
735
|
/**
|
|
@@ -909,4 +845,4 @@ declare function azureOpenAIDefaultQuery(settings: Pick<Settings, "azureOpenaiAp
|
|
|
909
845
|
*/
|
|
910
846
|
declare function lazySkillSourceWithPackSkills(packSkills: PackSkill[]): LocalDirLazySkillSource;
|
|
911
847
|
|
|
912
|
-
export { type AgentSegmentInput, type BuildAgentOptions, COMPACTION_SUMMARY_MARKER,
|
|
848
|
+
export { type AgentSegmentInput, type BuildAgentOptions, CLIENT_COMPACTION_TRIGGER_FRACTION, COMPACTION_PROMPT, COMPACTION_SUMMARY_MARKER, COMPACT_USER_MESSAGE_MAX_TOKENS, type ClientCompactionDecision, CodexSubscriptionUnavailableError, type CompactionItem, CompactionNeededError, ComputerActionError, ComputerReadOnlyError, type ComputerToolMode, ComputerUnavailableError, type ComputerUseArgs, ComputerUseCapability, type ContextRobustnessFilterOptions, type ElideStaleScreenshotsOptions, type ElideStaleScreenshotsResult, GENESIS_TITLE_DIRECTIVE, type HistoryItem, type ModelResponseUsage, MultiProviderModelProvider, type NormalizedRuntimeEvent, type OpenGeniRuntime, type PackSkill, type PackSkillFile, type PrepareInputOptions, type PrepareToolsOptions, type PreparedAgentInput, type PreparedAgentTools, type ProductionRuntimeOverrides, type RunAgentStreamOptions, SCREENSHOT_OMITTED_PLACEHOLDER, SUMMARY_BUFFER_TOKENS, SUMMARY_PREFIX, SandboxComputer, type SandboxComputerOptions, type SandboxFileDownload, type SandboxLifecycleHook, type SandboxLifecycleHookContext, type SandboxLifecycleHookPhase, USER_MESSAGE_TRUNCATION_MARKER, type WorkspaceEnvironmentContext, agentsErrorRunState, applyMissingManifestEntries, azureCliLoginCommand, azureOpenAIDefaultQuery, buildAgentCapabilities, buildCompactionPromptInput, buildCompactionReplacementHistory, buildManifest, buildModelInstance, buildOpenAIClientFromSettings, buildOpenGeniAgent, buildProviderClient, buildSummaryItem, callModelInputFilterForSettings, clientCompactionThresholdTokens, composeAgentInstructions, computerUse, configureOpenAI, contextRobustnessFilterForSettings, coreInstructions, createProductionAgentRuntime, decideClientCompaction, elideStaleScreenshotImages, enforceInputBudget, ensureReadableStreamFrom, estimateItemTokens, estimateTokens, extractResponseOutputText, findCompactionNeededError, findKeepBoundary, isCompactionSummary, isUserMessage, lazySkillSourceWithPackSkills, materializeSandboxFileDownloads, maxTurnsExceededRunState, modelResponseUsageFromSdkEvent, neutralizeToolSearchItemsInSerializedRunState, normalizeComputerCallsFilter, normalizeSdkEvent, normalizeToolOutputForEvent, prefixedMcpToolName, prepareAgentTools, prepareRunInput, renderCompactionPromptInputForChat, repositoryCloneCommand, repositoryUsesSandboxClone, resolveTurnModel, runAgentStream, runAzureCliLoginHook, runBeforeAgentStartHooks, runRepositoryCloneHook, sandboxCommandExitCode, sandboxCommandOutput, sandboxCommandStillRunning, sandboxFileDownloadsForAgent, sandboxLifecycleHooksForIds, sandboxRunAs, sanitizeHistoryItemsForModel, serializeApprovals, stripProviderItemIdsFilter, stripReasoningEncryptedContent, stripReasoningIdentityFromSerializedRunState, summarizeForCompaction, withManifestRefreshOnResume, withSandboxFileDownloads, withSandboxLifecycleHooks, workspaceEnvironmentInstructions };
|