@opengeni/runtime 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-DYBF7ZEB.js → chunk-RYDCVTMW.js} +1958 -207
- package/dist/chunk-RYDCVTMW.js.map +1 -0
- package/dist/{index-BTo_bZvN.d.ts → index-DIiiwQY2.d.ts} +689 -52
- package/dist/index.d.ts +293 -123
- package/dist/index.js +1819 -790
- package/dist/index.js.map +1 -1
- package/dist/sandbox/index.d.ts +1 -1
- package/dist/sandbox/index.js +79 -3
- package/package.json +21 -20
- package/src/codex-tool-search.ts +185 -31
- package/src/context-compaction.ts +78 -243
- package/src/history-sanitizer.ts +172 -20
- package/src/index.ts +2573 -898
- package/src/metrics.ts +28 -2
- package/src/sandbox/capabilities.ts +12 -3
- package/src/sandbox/channel-a.ts +420 -72
- package/src/sandbox/display-stack.ts +18 -4
- package/src/sandbox/errors.ts +13 -0
- package/src/sandbox/index.ts +398 -112
- package/src/sandbox/op-correlation.ts +70 -0
- package/src/sandbox/providers/index.ts +9 -3
- package/src/sandbox/providers/modal.ts +84 -14
- package/src/sandbox/providers/selfhosted.ts +1 -4
- package/src/sandbox/recording.ts +146 -90
- package/src/sandbox/routing/backend-resolver.ts +144 -10
- package/src/sandbox/routing/routing-session.ts +129 -25
- package/src/sandbox/select.ts +60 -8
- package/src/sandbox/selfhosted/capabilities.ts +59 -25
- package/src/sandbox/selfhosted/control-rpc.ts +160 -28
- package/src/sandbox/selfhosted/fault-rendering.ts +226 -0
- package/src/sandbox/selfhosted/op-observer.ts +54 -0
- package/src/sandbox/selfhosted/op-stream.ts +801 -0
- package/src/sandbox/selfhosted/op-testing.ts +468 -0
- package/src/sandbox/selfhosted/op-transport.ts +151 -0
- package/src/sandbox/selfhosted/retry-policy.ts +177 -0
- package/src/sandbox/selfhosted/session.ts +498 -55
- package/src/sandbox/selfhosted/testing.ts +60 -19
- package/src/sandbox/stream-port.ts +17 -5
- package/src/sandbox/stream-token.ts +8 -2
- package/src/sandbox/terminal-server.ts +18 -4
- package/src/sandbox-computer.ts +332 -70
- package/src/usage-telemetry.ts +73 -0
- package/dist/chunk-DYBF7ZEB.js.map +0 -1
- package/src/image-history.ts +0 -149
- package/src/screenshot-omitted-card.ts +0 -15
package/src/image-history.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import type { AgentInputItem } from "@openai/agents";
|
|
2
|
-
import { SCREENSHOT_OMITTED_IMAGE_DATA_URL } from "./screenshot-omitted-card";
|
|
3
|
-
|
|
4
|
-
export const SCREENSHOT_OMITTED_PLACEHOLDER =
|
|
5
|
-
"[screenshot omitted: an older desktop frame — the full image remains in the session event log]";
|
|
6
|
-
|
|
7
|
-
const DATA_IMAGE_BASE64_PATTERN = /data:image\/[a-z0-9.+-]+;base64,[a-z0-9+/=_-]+/i;
|
|
8
|
-
|
|
9
|
-
type PathSegment = string | number;
|
|
10
|
-
|
|
11
|
-
type ImageOccurrence = {
|
|
12
|
-
path: PathSegment[];
|
|
13
|
-
replacement: unknown;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type ElideStaleScreenshotsResult<T> = {
|
|
17
|
-
items: T[];
|
|
18
|
-
imageCount: number;
|
|
19
|
-
elidedCount: number;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type ElideStaleScreenshotsOptions = {
|
|
23
|
-
keepLast?: number;
|
|
24
|
-
placeholder?: string;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export function elideStaleScreenshotImages<T extends AgentInputItem>(
|
|
28
|
-
items: readonly T[],
|
|
29
|
-
options: ElideStaleScreenshotsOptions = {},
|
|
30
|
-
): ElideStaleScreenshotsResult<T> {
|
|
31
|
-
const keepLast = Math.max(0, Math.floor(options.keepLast ?? 3));
|
|
32
|
-
const placeholder = options.placeholder ?? SCREENSHOT_OMITTED_PLACEHOLDER;
|
|
33
|
-
const occurrences: ImageOccurrence[] = [];
|
|
34
|
-
for (let i = 0; i < items.length; i += 1) {
|
|
35
|
-
collectItemImageOccurrences(items[i], [i], placeholder, occurrences);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const elidedCount = Math.max(0, occurrences.length - keepLast);
|
|
39
|
-
if (elidedCount === 0) {
|
|
40
|
-
return { items: items.slice(), imageCount: occurrences.length, elidedCount: 0 };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const cloned = structuredClone(items) as T[];
|
|
44
|
-
for (const occurrence of occurrences.slice(0, elidedCount)) {
|
|
45
|
-
setPath(cloned, occurrence.path, occurrence.replacement);
|
|
46
|
-
}
|
|
47
|
-
return { items: cloned, imageCount: occurrences.length, elidedCount };
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function collectItemImageOccurrences(
|
|
51
|
-
item: unknown,
|
|
52
|
-
path: PathSegment[],
|
|
53
|
-
placeholder: string,
|
|
54
|
-
out: ImageOccurrence[],
|
|
55
|
-
): void {
|
|
56
|
-
if (!isRecord(item)) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
if (item.type === "message" && (item.role === "user" || item.role === "system")) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (item.type === "computer_call_result" || item.type === "computer_call_output") {
|
|
63
|
-
collectComputerOutputImages(item, path, out);
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
if (item.type === "function_call_result" || item.type === "function_call_output") {
|
|
67
|
-
collectToolResultImages(item.output, [...path, "output"], placeholder, out);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function collectComputerOutputImages(
|
|
72
|
-
item: Record<string, unknown>,
|
|
73
|
-
path: PathSegment[],
|
|
74
|
-
out: ImageOccurrence[],
|
|
75
|
-
): void {
|
|
76
|
-
const output = item.output;
|
|
77
|
-
if (!isRecord(output) || output.type !== "computer_screenshot") {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
for (const key of ["data", "image_url", "imageUrl"]) {
|
|
81
|
-
if (isImageDataUrl(output[key])) {
|
|
82
|
-
out.push({ path: [...path, "output", key], replacement: SCREENSHOT_OMITTED_IMAGE_DATA_URL });
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function collectToolResultImages(
|
|
89
|
-
value: unknown,
|
|
90
|
-
path: PathSegment[],
|
|
91
|
-
placeholder: string,
|
|
92
|
-
out: ImageOccurrence[],
|
|
93
|
-
): void {
|
|
94
|
-
if (typeof value === "string") {
|
|
95
|
-
if (isImageDataUrl(value)) {
|
|
96
|
-
out.push({ path, replacement: placeholder });
|
|
97
|
-
}
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (Array.isArray(value)) {
|
|
101
|
-
for (let i = 0; i < value.length; i += 1) {
|
|
102
|
-
collectToolResultImages(value[i], [...path, i], placeholder, out);
|
|
103
|
-
}
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
if (!isRecord(value)) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (value.type === "input_image") {
|
|
110
|
-
for (const key of ["image", "imageUrl", "image_url"]) {
|
|
111
|
-
if (isImageDataUrl(value[key])) {
|
|
112
|
-
out.push({ path, replacement: { type: "input_text", text: placeholder } });
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
for (const key of ["content", "text", "output"]) {
|
|
118
|
-
if (key in value) {
|
|
119
|
-
collectToolResultImages(value[key], [...path, key], placeholder, out);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function isImageDataUrl(value: unknown): value is string {
|
|
125
|
-
return typeof value === "string" && DATA_IMAGE_BASE64_PATTERN.test(value);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
129
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function setPath(root: unknown, path: PathSegment[], value: unknown): void {
|
|
133
|
-
if (path.length === 0) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
let cursor = root;
|
|
137
|
-
for (let i = 0; i < path.length - 1; i += 1) {
|
|
138
|
-
const segment = path[i]!;
|
|
139
|
-
cursor = Array.isArray(cursor)
|
|
140
|
-
? cursor[segment as number]
|
|
141
|
-
: (cursor as Record<string, unknown>)[segment as string];
|
|
142
|
-
}
|
|
143
|
-
const last = path[path.length - 1]!;
|
|
144
|
-
if (Array.isArray(cursor)) {
|
|
145
|
-
cursor[last as number] = value;
|
|
146
|
-
} else {
|
|
147
|
-
(cursor as Record<string, unknown>)[last as string] = value;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// The legible "screenshot omitted" card that image-history substitutes for an
|
|
2
|
-
// ELIDED `computer_call_output` screenshot. The hosted computer tool requires
|
|
3
|
-
// `computer_call_output.output.image_url` to remain a syntactically valid URL;
|
|
4
|
-
// the text placeholder is valid for tool-result text paths but 400s this image
|
|
5
|
-
// channel once older screenshots are elided.
|
|
6
|
-
//
|
|
7
|
-
// This is a valid 8-bit RGBA PNG (signature + chunk CRCs emitted by the
|
|
8
|
-
// dependency-free generator) rendered from a fixed message:
|
|
9
|
-
// SCREENSHOT OMITTED
|
|
10
|
-
// EARLIER FRAME ELIDED
|
|
11
|
-
// TO SAVE CONTEXT.
|
|
12
|
-
//
|
|
13
|
-
// Regenerate with: `bun run scripts/gen-screenshot-omitted-card.mjs`
|
|
14
|
-
export const SCREENSHOT_OMITTED_IMAGE_DATA_URL =
|
|
15
|
-
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAgwAAAC0CAYAAAD4gHQ+AAAG2klEQVR42u3dMXLbMBCGUR/ChQuPT5KD+c5q1Ki2b+CMRlji38UrXpWYoUkA/AoM8vb17/sHAOAvbx4CACA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