@openai/agents-extensions 0.8.4 → 0.9.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/ai-sdk-ui/uiMessageStream.d.ts +5 -0
- package/dist/ai-sdk-ui/uiMessageStream.js +10 -3
- package/dist/ai-sdk-ui/uiMessageStream.js.map +1 -1
- package/dist/ai-sdk-ui/uiMessageStream.mjs +9 -3
- package/dist/ai-sdk-ui/uiMessageStream.mjs.map +1 -1
- package/dist/metadata.js +2 -2
- package/dist/metadata.mjs +2 -2
- package/dist/sandbox/blaxel/index.d.ts +2 -0
- package/dist/sandbox/blaxel/index.js +19 -0
- package/dist/sandbox/blaxel/index.js.map +1 -0
- package/dist/sandbox/blaxel/index.mjs +3 -0
- package/dist/sandbox/blaxel/index.mjs.map +1 -0
- package/dist/sandbox/blaxel/mounts.d.ts +101 -0
- package/dist/sandbox/blaxel/mounts.js +542 -0
- package/dist/sandbox/blaxel/mounts.js.map +1 -0
- package/dist/sandbox/blaxel/mounts.mjs +529 -0
- package/dist/sandbox/blaxel/mounts.mjs.map +1 -0
- package/dist/sandbox/blaxel/sandbox.d.ts +155 -0
- package/dist/sandbox/blaxel/sandbox.js +1110 -0
- package/dist/sandbox/blaxel/sandbox.js.map +1 -0
- package/dist/sandbox/blaxel/sandbox.mjs +1072 -0
- package/dist/sandbox/blaxel/sandbox.mjs.map +1 -0
- package/dist/sandbox/cloudflare/index.d.ts +2 -0
- package/dist/sandbox/cloudflare/index.js +19 -0
- package/dist/sandbox/cloudflare/index.js.map +1 -0
- package/dist/sandbox/cloudflare/index.mjs +3 -0
- package/dist/sandbox/cloudflare/index.mjs.map +1 -0
- package/dist/sandbox/cloudflare/mounts.d.ts +28 -0
- package/dist/sandbox/cloudflare/mounts.js +150 -0
- package/dist/sandbox/cloudflare/mounts.js.map +1 -0
- package/dist/sandbox/cloudflare/mounts.mjs +143 -0
- package/dist/sandbox/cloudflare/mounts.mjs.map +1 -0
- package/dist/sandbox/cloudflare/sandbox.d.ts +91 -0
- package/dist/sandbox/cloudflare/sandbox.js +1163 -0
- package/dist/sandbox/cloudflare/sandbox.js.map +1 -0
- package/dist/sandbox/cloudflare/sandbox.mjs +1125 -0
- package/dist/sandbox/cloudflare/sandbox.mjs.map +1 -0
- package/dist/sandbox/daytona/index.d.ts +2 -0
- package/dist/sandbox/daytona/index.js +19 -0
- package/dist/sandbox/daytona/index.js.map +1 -0
- package/dist/sandbox/daytona/index.mjs +3 -0
- package/dist/sandbox/daytona/index.mjs.map +1 -0
- package/dist/sandbox/daytona/mounts.d.ts +11 -0
- package/dist/sandbox/daytona/mounts.js +17 -0
- package/dist/sandbox/daytona/mounts.js.map +1 -0
- package/dist/sandbox/daytona/mounts.mjs +12 -0
- package/dist/sandbox/daytona/mounts.mjs.map +1 -0
- package/dist/sandbox/daytona/sandbox.d.ts +160 -0
- package/dist/sandbox/daytona/sandbox.js +938 -0
- package/dist/sandbox/daytona/sandbox.js.map +1 -0
- package/dist/sandbox/daytona/sandbox.mjs +900 -0
- package/dist/sandbox/daytona/sandbox.mjs.map +1 -0
- package/dist/sandbox/e2b/index.d.ts +2 -0
- package/dist/sandbox/e2b/index.js +19 -0
- package/dist/sandbox/e2b/index.js.map +1 -0
- package/dist/sandbox/e2b/index.mjs +3 -0
- package/dist/sandbox/e2b/index.mjs.map +1 -0
- package/dist/sandbox/e2b/mounts.d.ts +11 -0
- package/dist/sandbox/e2b/mounts.js +17 -0
- package/dist/sandbox/e2b/mounts.js.map +1 -0
- package/dist/sandbox/e2b/mounts.mjs +12 -0
- package/dist/sandbox/e2b/mounts.mjs.map +1 -0
- package/dist/sandbox/e2b/sandbox.d.ts +169 -0
- package/dist/sandbox/e2b/sandbox.js +829 -0
- package/dist/sandbox/e2b/sandbox.js.map +1 -0
- package/dist/sandbox/e2b/sandbox.mjs +791 -0
- package/dist/sandbox/e2b/sandbox.mjs.map +1 -0
- package/dist/sandbox/modal/index.d.ts +2 -0
- package/dist/sandbox/modal/index.js +19 -0
- package/dist/sandbox/modal/index.js.map +1 -0
- package/dist/sandbox/modal/index.mjs +3 -0
- package/dist/sandbox/modal/index.mjs.map +1 -0
- package/dist/sandbox/modal/mounts.d.ts +24 -0
- package/dist/sandbox/modal/mounts.js +194 -0
- package/dist/sandbox/modal/mounts.js.map +1 -0
- package/dist/sandbox/modal/mounts.mjs +188 -0
- package/dist/sandbox/modal/mounts.mjs.map +1 -0
- package/dist/sandbox/modal/sandbox.d.ts +220 -0
- package/dist/sandbox/modal/sandbox.js +1621 -0
- package/dist/sandbox/modal/sandbox.js.map +1 -0
- package/dist/sandbox/modal/sandbox.mjs +1581 -0
- package/dist/sandbox/modal/sandbox.mjs.map +1 -0
- package/dist/sandbox/runloop/index.d.ts +2 -0
- package/dist/sandbox/runloop/index.js +19 -0
- package/dist/sandbox/runloop/index.js.map +1 -0
- package/dist/sandbox/runloop/index.mjs +3 -0
- package/dist/sandbox/runloop/index.mjs.map +1 -0
- package/dist/sandbox/runloop/mounts.d.ts +11 -0
- package/dist/sandbox/runloop/mounts.js +17 -0
- package/dist/sandbox/runloop/mounts.js.map +1 -0
- package/dist/sandbox/runloop/mounts.mjs +12 -0
- package/dist/sandbox/runloop/mounts.mjs.map +1 -0
- package/dist/sandbox/runloop/sandbox.d.ts +266 -0
- package/dist/sandbox/runloop/sandbox.js +1390 -0
- package/dist/sandbox/runloop/sandbox.js.map +1 -0
- package/dist/sandbox/runloop/sandbox.mjs +1346 -0
- package/dist/sandbox/runloop/sandbox.mjs.map +1 -0
- package/dist/sandbox/shared/archive.d.ts +34 -0
- package/dist/sandbox/shared/archive.js +397 -0
- package/dist/sandbox/shared/archive.js.map +1 -0
- package/dist/sandbox/shared/archive.mjs +389 -0
- package/dist/sandbox/shared/archive.mjs.map +1 -0
- package/dist/sandbox/shared/editor.d.ts +17 -0
- package/dist/sandbox/shared/editor.js +65 -0
- package/dist/sandbox/shared/editor.js.map +1 -0
- package/dist/sandbox/shared/editor.mjs +61 -0
- package/dist/sandbox/shared/editor.mjs.map +1 -0
- package/dist/sandbox/shared/environment.d.ts +1 -0
- package/dist/sandbox/shared/environment.js +13 -0
- package/dist/sandbox/shared/environment.js.map +1 -0
- package/dist/sandbox/shared/environment.mjs +2 -0
- package/dist/sandbox/shared/environment.mjs.map +1 -0
- package/dist/sandbox/shared/git.d.ts +4 -0
- package/dist/sandbox/shared/git.js +20 -0
- package/dist/sandbox/shared/git.js.map +1 -0
- package/dist/sandbox/shared/git.mjs +17 -0
- package/dist/sandbox/shared/git.mjs.map +1 -0
- package/dist/sandbox/shared/inContainerMounts.d.ts +40 -0
- package/dist/sandbox/shared/inContainerMounts.js +670 -0
- package/dist/sandbox/shared/inContainerMounts.js.map +1 -0
- package/dist/sandbox/shared/inContainerMounts.mjs +662 -0
- package/dist/sandbox/shared/inContainerMounts.mjs.map +1 -0
- package/dist/sandbox/shared/index.d.ts +23 -0
- package/dist/sandbox/shared/index.js +112 -0
- package/dist/sandbox/shared/index.js.map +1 -0
- package/dist/sandbox/shared/index.mjs +18 -0
- package/dist/sandbox/shared/index.mjs.map +1 -0
- package/dist/sandbox/shared/localSources.d.ts +8 -0
- package/dist/sandbox/shared/localSources.js +378 -0
- package/dist/sandbox/shared/localSources.js.map +1 -0
- package/dist/sandbox/shared/localSources.mjs +372 -0
- package/dist/sandbox/shared/localSources.mjs.map +1 -0
- package/dist/sandbox/shared/manifest.d.ts +38 -0
- package/dist/sandbox/shared/manifest.js +254 -0
- package/dist/sandbox/shared/manifest.js.map +1 -0
- package/dist/sandbox/shared/manifest.mjs +233 -0
- package/dist/sandbox/shared/manifest.mjs.map +1 -0
- package/dist/sandbox/shared/media.d.ts +1 -0
- package/dist/sandbox/shared/media.js +10 -0
- package/dist/sandbox/shared/media.js.map +1 -0
- package/dist/sandbox/shared/media.mjs +2 -0
- package/dist/sandbox/shared/media.mjs.map +1 -0
- package/dist/sandbox/shared/metadata.d.ts +7 -0
- package/dist/sandbox/shared/metadata.js +87 -0
- package/dist/sandbox/shared/metadata.js.map +1 -0
- package/dist/sandbox/shared/metadata.mjs +81 -0
- package/dist/sandbox/shared/metadata.mjs.map +1 -0
- package/dist/sandbox/shared/output.d.ts +1 -0
- package/dist/sandbox/shared/output.js +8 -0
- package/dist/sandbox/shared/output.js.map +1 -0
- package/dist/sandbox/shared/output.mjs +2 -0
- package/dist/sandbox/shared/output.mjs.map +1 -0
- package/dist/sandbox/shared/paths.d.ts +27 -0
- package/dist/sandbox/shared/paths.js +245 -0
- package/dist/sandbox/shared/paths.js.map +1 -0
- package/dist/sandbox/shared/paths.mjs +236 -0
- package/dist/sandbox/shared/paths.mjs.map +1 -0
- package/dist/sandbox/shared/ports.d.ts +14 -0
- package/dist/sandbox/shared/ports.js +75 -0
- package/dist/sandbox/shared/ports.js.map +1 -0
- package/dist/sandbox/shared/ports.mjs +69 -0
- package/dist/sandbox/shared/ports.mjs.map +1 -0
- package/dist/sandbox/shared/process.d.ts +16 -0
- package/dist/sandbox/shared/process.js +90 -0
- package/dist/sandbox/shared/process.js.map +1 -0
- package/dist/sandbox/shared/process.mjs +86 -0
- package/dist/sandbox/shared/process.mjs.map +1 -0
- package/dist/sandbox/shared/pty.d.ts +81 -0
- package/dist/sandbox/shared/pty.js +382 -0
- package/dist/sandbox/shared/pty.js.map +1 -0
- package/dist/sandbox/shared/pty.mjs +335 -0
- package/dist/sandbox/shared/pty.mjs.map +1 -0
- package/dist/sandbox/shared/runAs.d.ts +46 -0
- package/dist/sandbox/shared/runAs.js +149 -0
- package/dist/sandbox/shared/runAs.js.map +1 -0
- package/dist/sandbox/shared/runAs.mjs +141 -0
- package/dist/sandbox/shared/runAs.mjs.map +1 -0
- package/dist/sandbox/shared/session.d.ts +16 -0
- package/dist/sandbox/shared/session.js +138 -0
- package/dist/sandbox/shared/session.js.map +1 -0
- package/dist/sandbox/shared/session.mjs +128 -0
- package/dist/sandbox/shared/session.mjs.map +1 -0
- package/dist/sandbox/shared/sessionBase.d.ts +90 -0
- package/dist/sandbox/shared/sessionBase.js +446 -0
- package/dist/sandbox/shared/sessionBase.js.map +1 -0
- package/dist/sandbox/shared/sessionBase.mjs +442 -0
- package/dist/sandbox/shared/sessionBase.mjs.map +1 -0
- package/dist/sandbox/shared/sessionState.d.ts +7 -0
- package/dist/sandbox/shared/sessionState.js +35 -0
- package/dist/sandbox/shared/sessionState.js.map +1 -0
- package/dist/sandbox/shared/sessionState.mjs +31 -0
- package/dist/sandbox/shared/sessionState.mjs.map +1 -0
- package/dist/sandbox/shared/snapshots.d.ts +9 -0
- package/dist/sandbox/shared/snapshots.js +62 -0
- package/dist/sandbox/shared/snapshots.js.map +1 -0
- package/dist/sandbox/shared/snapshots.mjs +57 -0
- package/dist/sandbox/shared/snapshots.mjs.map +1 -0
- package/dist/sandbox/shared/typeGuards.d.ts +10 -0
- package/dist/sandbox/shared/typeGuards.js +50 -0
- package/dist/sandbox/shared/typeGuards.js.map +1 -0
- package/dist/sandbox/shared/typeGuards.mjs +38 -0
- package/dist/sandbox/shared/typeGuards.mjs.map +1 -0
- package/dist/sandbox/shared/types.d.ts +24 -0
- package/dist/sandbox/shared/types.js +3 -0
- package/dist/sandbox/shared/types.js.map +1 -0
- package/dist/sandbox/shared/types.mjs +2 -0
- package/dist/sandbox/shared/types.mjs.map +1 -0
- package/dist/sandbox/vercel/index.d.ts +1 -0
- package/dist/sandbox/vercel/index.js +18 -0
- package/dist/sandbox/vercel/index.js.map +1 -0
- package/dist/sandbox/vercel/index.mjs +2 -0
- package/dist/sandbox/vercel/index.mjs.map +1 -0
- package/dist/sandbox/vercel/sandbox.d.ts +135 -0
- package/dist/sandbox/vercel/sandbox.js +1001 -0
- package/dist/sandbox/vercel/sandbox.js.map +1 -0
- package/dist/sandbox/vercel/sandbox.mjs +963 -0
- package/dist/sandbox/vercel/sandbox.mjs.map +1 -0
- package/package.json +108 -4
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { SandboxProviderError } from '@openai/agents-core/sandbox';
|
|
2
|
+
import { RemoteSandboxEditor } from "./editor.mjs";
|
|
3
|
+
import { sandboxEntryPermissionsMode } from "./metadata.mjs";
|
|
4
|
+
import { shellQuote } from "./paths.mjs";
|
|
5
|
+
export function sandboxUserShellCommand(command, user) {
|
|
6
|
+
if (!user) {
|
|
7
|
+
return command;
|
|
8
|
+
}
|
|
9
|
+
return [
|
|
10
|
+
`target_user=${shellQuote(user)}`,
|
|
11
|
+
'current_uid="$(id -u)"',
|
|
12
|
+
'current_user="$(id -un 2>/dev/null || id -u)"',
|
|
13
|
+
'if [ "$current_uid" = "$target_user" ] || [ "$current_user" = "$target_user" ]; then',
|
|
14
|
+
` sh -lc ${shellQuote(command)}`,
|
|
15
|
+
'elif [ "$current_uid" -eq 0 ]; then',
|
|
16
|
+
` su -s /bin/sh "$target_user" -c ${shellQuote(command)}`,
|
|
17
|
+
'else',
|
|
18
|
+
` sudo -n -u "$target_user" -- sh -lc ${shellQuote(command)}`,
|
|
19
|
+
'fi',
|
|
20
|
+
].join('\n');
|
|
21
|
+
}
|
|
22
|
+
export function createRunAsRemoteEditor(args) {
|
|
23
|
+
return new RemoteSandboxEditor({
|
|
24
|
+
resolvePath: args.resolvePath,
|
|
25
|
+
mkdir: async (path) => {
|
|
26
|
+
await args.beforeFilesystemMutation?.();
|
|
27
|
+
await runCheckedRunAsRemoteCommand(args.providerName, args.providerId, args.runCommand, `mkdir -p -- ${shellQuote(path)}`, `create directory ${path}`, args.runAs);
|
|
28
|
+
},
|
|
29
|
+
readText: async (path) => new TextDecoder().decode(await readRunAsRemoteFile({
|
|
30
|
+
providerName: args.providerName,
|
|
31
|
+
providerId: args.providerId,
|
|
32
|
+
path,
|
|
33
|
+
runAs: args.runAs,
|
|
34
|
+
runCommand: args.runCommand,
|
|
35
|
+
})),
|
|
36
|
+
pathExists: async (path) => await runAsRemotePathExists(path, args.runAs, args.runCommand),
|
|
37
|
+
writeText: async (path, content) => {
|
|
38
|
+
await args.beforeFilesystemMutation?.();
|
|
39
|
+
await writeRunAsRemoteText({
|
|
40
|
+
providerName: args.providerName,
|
|
41
|
+
providerId: args.providerId,
|
|
42
|
+
path,
|
|
43
|
+
content,
|
|
44
|
+
runAs: args.runAs,
|
|
45
|
+
runCommand: args.runCommand,
|
|
46
|
+
writer: args.writer,
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
deletePath: async (path) => {
|
|
50
|
+
await args.beforeFilesystemMutation?.();
|
|
51
|
+
await runCheckedRunAsRemoteCommand(args.providerName, args.providerId, args.runCommand, `rm -f -- ${shellQuote(path)}`, `delete path ${path}`, args.runAs);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export async function readRunAsRemoteFile(args) {
|
|
56
|
+
const output = await runCheckedRunAsRemoteCommand(args.providerName, args.providerId, args.runCommand, `base64 -- ${shellQuote(args.path)}`, `read file ${args.path}`, args.runAs);
|
|
57
|
+
return decodeBase64(output);
|
|
58
|
+
}
|
|
59
|
+
export async function runAsRemotePathExists(path, runAs, runCommand) {
|
|
60
|
+
const result = await runCommand(`test -e ${shellQuote(path)}`, { runAs });
|
|
61
|
+
return result.status === 0;
|
|
62
|
+
}
|
|
63
|
+
export async function writeRunAsRemoteText(args) {
|
|
64
|
+
const tempPath = `/tmp/openai-agents-${randomId()}`;
|
|
65
|
+
try {
|
|
66
|
+
await args.writer.writeFile(tempPath, args.content);
|
|
67
|
+
await runCheckedRunAsRemoteCommand(args.providerName, args.providerId, args.runCommand, [
|
|
68
|
+
`chmod 0644 -- ${shellQuote(tempPath)}`,
|
|
69
|
+
`chown ${shellQuote(args.runAs)}:${shellQuote(args.runAs)} -- ${shellQuote(tempPath)}`,
|
|
70
|
+
].join(' && '), `prepare temporary file ${tempPath}`, 'root');
|
|
71
|
+
await runCheckedRunAsRemoteCommand(args.providerName, args.providerId, args.runCommand, `cat -- ${shellQuote(tempPath)} > ${shellQuote(args.path)}`, `write file ${args.path}`, args.runAs);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
await args
|
|
75
|
+
.runCommand(`rm -f -- ${shellQuote(tempPath)}`, { runAs: 'root' })
|
|
76
|
+
.catch(() => { });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export function manifestMaterializationOptionsWithRunAs(args) {
|
|
80
|
+
const options = args.options ?? {};
|
|
81
|
+
if (!args.runAs &&
|
|
82
|
+
!args.support?.entryGroups &&
|
|
83
|
+
!args.support?.entryPermissions) {
|
|
84
|
+
return options;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
...options,
|
|
88
|
+
applyMetadata: async (absolutePath, entry) => {
|
|
89
|
+
await options.applyMetadata?.(absolutePath, entry);
|
|
90
|
+
await applyRunAsManifestEntryMetadata({
|
|
91
|
+
providerName: args.providerName,
|
|
92
|
+
providerId: args.providerId,
|
|
93
|
+
absolutePath,
|
|
94
|
+
entry,
|
|
95
|
+
runAs: args.runAs,
|
|
96
|
+
runCommand: args.runCommand,
|
|
97
|
+
support: args.support,
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async function applyRunAsManifestEntryMetadata(args) {
|
|
103
|
+
const commands = [];
|
|
104
|
+
if (args.runAs) {
|
|
105
|
+
commands.push(`chown ${shellQuote(args.runAs)}:${shellQuote(args.runAs)} -- ${shellQuote(args.absolutePath)}`);
|
|
106
|
+
}
|
|
107
|
+
if (args.support?.entryGroups && args.entry.group) {
|
|
108
|
+
commands.push(`chgrp ${shellQuote(args.entry.group.name)} -- ${shellQuote(args.absolutePath)}`);
|
|
109
|
+
}
|
|
110
|
+
if (args.support?.entryPermissions) {
|
|
111
|
+
commands.push(`chmod ${sandboxEntryPermissionsMode(args.entry)} -- ${shellQuote(args.absolutePath)}`);
|
|
112
|
+
}
|
|
113
|
+
if (commands.length === 0) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
await runCheckedRunAsRemoteCommand(args.providerName, args.providerId, args.runCommand, commands.join(' && '), `apply metadata to ${args.absolutePath}`, 'root');
|
|
117
|
+
}
|
|
118
|
+
async function runCheckedRunAsRemoteCommand(providerName, providerId, runCommand, command, action, runAs) {
|
|
119
|
+
const result = await runCommand(command, { runAs });
|
|
120
|
+
if (result.status !== 0) {
|
|
121
|
+
const output = [result.stdout ?? '', result.stderr ?? '']
|
|
122
|
+
.filter((value) => value.trim().length > 0)
|
|
123
|
+
.join('\n');
|
|
124
|
+
throw new SandboxProviderError(`${providerName} failed to ${action}${output ? `: ${output}` : ''}`, {
|
|
125
|
+
provider: providerId,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return result.stdout ?? '';
|
|
129
|
+
}
|
|
130
|
+
function decodeBase64(value) {
|
|
131
|
+
const binary = atob(value.replace(/\s+/gu, ''));
|
|
132
|
+
const bytes = new Uint8Array(binary.length);
|
|
133
|
+
for (let index = 0; index < binary.length; index += 1) {
|
|
134
|
+
bytes[index] = binary.charCodeAt(index);
|
|
135
|
+
}
|
|
136
|
+
return bytes;
|
|
137
|
+
}
|
|
138
|
+
function randomId() {
|
|
139
|
+
return (globalThis.crypto?.randomUUID?.() ?? Math.random().toString(16).slice(2)).replace(/-/gu, '');
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=runAs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runAs.mjs","sourceRoot":"","sources":["../../../src/sandbox/shared/runAs.ts"],"names":[],"mappings":"OAAO,EAAE,oBAAoB,EAAc,MAAM,6BAA6B;OACvE,EAAE,mBAAmB,EAAE;OAEvB,EAAE,2BAA2B,EAAE;OAC/B,EAAE,UAAU,EAAE;AAkBrB,MAAM,UAAU,uBAAuB,CACrC,OAAe,EACf,IAAa;IAEb,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO;QACL,eAAe,UAAU,CAAC,IAAI,CAAC,EAAE;QACjC,wBAAwB;QACxB,+CAA+C;QAC/C,sFAAsF;QACtF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EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACtD,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,QAAQ;IACf,OAAO,CACL,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CACzE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACvB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { withSandboxSpan, type SandboxConcurrencyLimits, type SnapshotSpec } from '@openai/agents-core/sandbox';
|
|
2
|
+
export { withSandboxSpan };
|
|
3
|
+
export declare function closeRemoteSessionOnManifestError(providerName: string, session: {
|
|
4
|
+
close(): Promise<void>;
|
|
5
|
+
}, manifestError: unknown): Promise<never>;
|
|
6
|
+
export declare function assertRunAsUnsupported(providerName: string, runAs?: string): void;
|
|
7
|
+
export declare function assertCoreSnapshotUnsupported(providerName: string, snapshot?: SnapshotSpec): void;
|
|
8
|
+
export declare function assertCoreConcurrencyLimitsUnsupported(providerName: string, limits?: SandboxConcurrencyLimits): void;
|
|
9
|
+
export declare function withProviderError<T>(providerName: string, provider: string, operation: string, fn: () => Promise<T>, context?: Record<string, unknown>): Promise<T>;
|
|
10
|
+
export declare function isProviderSandboxNotFoundError(error: unknown): boolean;
|
|
11
|
+
export type ResumeRecreateErrorContext = {
|
|
12
|
+
providerName: string;
|
|
13
|
+
provider: string;
|
|
14
|
+
details?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
export declare function assertResumeRecreateAllowed(error: unknown, context: ResumeRecreateErrorContext): void;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withSandboxSpan = void 0;
|
|
4
|
+
exports.closeRemoteSessionOnManifestError = closeRemoteSessionOnManifestError;
|
|
5
|
+
exports.assertRunAsUnsupported = assertRunAsUnsupported;
|
|
6
|
+
exports.assertCoreSnapshotUnsupported = assertCoreSnapshotUnsupported;
|
|
7
|
+
exports.assertCoreConcurrencyLimitsUnsupported = assertCoreConcurrencyLimitsUnsupported;
|
|
8
|
+
exports.withProviderError = withProviderError;
|
|
9
|
+
exports.isProviderSandboxNotFoundError = isProviderSandboxNotFoundError;
|
|
10
|
+
exports.assertResumeRecreateAllowed = assertResumeRecreateAllowed;
|
|
11
|
+
const agents_core_1 = require("@openai/agents-core");
|
|
12
|
+
const sandbox_1 = require("@openai/agents-core/sandbox");
|
|
13
|
+
Object.defineProperty(exports, "withSandboxSpan", { enumerable: true, get: function () { return sandbox_1.withSandboxSpan; } });
|
|
14
|
+
const typeGuards_1 = require("./typeGuards.js");
|
|
15
|
+
async function closeRemoteSessionOnManifestError(providerName, session, manifestError) {
|
|
16
|
+
try {
|
|
17
|
+
await session.close();
|
|
18
|
+
}
|
|
19
|
+
catch (closeError) {
|
|
20
|
+
throw new agents_core_1.UserError(`Failed to apply a ${providerName} sandbox manifest and close the sandbox. Manifest error: ${errorMessage(manifestError)} Close error: ${errorMessage(closeError)}`);
|
|
21
|
+
}
|
|
22
|
+
throw manifestError;
|
|
23
|
+
}
|
|
24
|
+
function assertRunAsUnsupported(providerName, runAs) {
|
|
25
|
+
if (runAs) {
|
|
26
|
+
throw new sandbox_1.SandboxUnsupportedFeatureError(`${providerName} does not support runAs yet.`, {
|
|
27
|
+
provider: providerName,
|
|
28
|
+
feature: 'runAs',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function assertCoreSnapshotUnsupported(providerName, snapshot) {
|
|
33
|
+
if (snapshot && snapshot.type !== 'noop') {
|
|
34
|
+
throw new sandbox_1.SandboxUnsupportedFeatureError(`${providerName} does not support core sandbox snapshots yet. Use the provider-specific workspacePersistence option when available.`, {
|
|
35
|
+
provider: providerName,
|
|
36
|
+
feature: 'snapshot',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function assertCoreConcurrencyLimitsUnsupported(providerName, limits) {
|
|
41
|
+
if (limits?.manifestEntries !== undefined ||
|
|
42
|
+
limits?.localDirFiles !== undefined) {
|
|
43
|
+
throw new sandbox_1.SandboxUnsupportedFeatureError(`${providerName} does not support core sandbox concurrencyLimits yet.`, {
|
|
44
|
+
provider: providerName,
|
|
45
|
+
feature: 'concurrencyLimits',
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async function withProviderError(providerName, provider, operation, fn, context = {}) {
|
|
50
|
+
try {
|
|
51
|
+
return await fn();
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (error instanceof agents_core_1.UserError) {
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
throw new sandbox_1.SandboxProviderError(`${providerName} failed to ${operation}.`, {
|
|
58
|
+
provider,
|
|
59
|
+
operation,
|
|
60
|
+
...context,
|
|
61
|
+
cause: errorMessage(error),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function isProviderSandboxNotFoundError(error) {
|
|
66
|
+
if (isNotFoundErrorRecord(error, new Set())) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
const text = errorMessage(error).trim();
|
|
70
|
+
return isNotFoundErrorMessage(text);
|
|
71
|
+
}
|
|
72
|
+
function assertResumeRecreateAllowed(error, context) {
|
|
73
|
+
if (error instanceof agents_core_1.UserError) {
|
|
74
|
+
throw error;
|
|
75
|
+
}
|
|
76
|
+
if (isProviderSandboxNotFoundError(error)) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
throw new sandbox_1.SandboxProviderError(`${context.providerName} failed to reconnect sandbox during resume.`, {
|
|
80
|
+
provider: context.provider,
|
|
81
|
+
operation: 'resume',
|
|
82
|
+
...context.details,
|
|
83
|
+
cause: errorMessage(error),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function errorMessage(error) {
|
|
87
|
+
return error instanceof Error ? error.message : String(error);
|
|
88
|
+
}
|
|
89
|
+
function isNotFoundErrorRecord(error, seen) {
|
|
90
|
+
if (!(0, typeGuards_1.isRecord)(error)) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (seen.has(error)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
seen.add(error);
|
|
97
|
+
for (const key of ['status', 'statusCode', 'httpStatus', 'httpStatusCode']) {
|
|
98
|
+
if (is404(error[key])) {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const response = error.response;
|
|
103
|
+
if ((0, typeGuards_1.isRecord)(response) && is404(response.status)) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
if (isNotFoundErrorCode(error.code)) {
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
if (typeof error.message === 'string' &&
|
|
110
|
+
isNotFoundErrorMessage(error.message)) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
return isNotFoundErrorRecord(error.cause, seen);
|
|
114
|
+
}
|
|
115
|
+
function is404(value) {
|
|
116
|
+
return value === 404 || value === '404';
|
|
117
|
+
}
|
|
118
|
+
function isNotFoundErrorCode(value) {
|
|
119
|
+
if (typeof value === 'number') {
|
|
120
|
+
return value === 404;
|
|
121
|
+
}
|
|
122
|
+
if (typeof value !== 'string') {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
return /^(404|not_found|not-found|notfound|resource_not_found|resource-not-found|not found)$/iu.test(value.trim());
|
|
126
|
+
}
|
|
127
|
+
function isNotFoundErrorMessage(message) {
|
|
128
|
+
const text = message.trim();
|
|
129
|
+
if (!text) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
if (/^(404|not[_ -]?found)$/iu.test(text)) {
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
return (/\b(sandbox|sandbox instance|instance|devbox)\b.*\b(not found|missing|does not exist|no such)\b/iu.test(text) ||
|
|
136
|
+
/\b(not found|missing|does not exist|no such)\b.*\b(sandbox|sandbox instance|instance|devbox)\b/iu.test(text));
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/sandbox/shared/session.ts"],"names":[],"mappings":";;;AAYA,8EAaC;AAED,wDAaC;AAED,sEAaC;AAED,wFAgBC;AAED,8CAoBC;AAED,wEAOC;AAQD,kEAqBC;AArID,qDAAgD;AAChD,yDAMqC;AAG5B,gGANP,yBAAe,OAMO;AAFxB,gDAAwC;AAIjC,KAAK,UAAU,iCAAiC,CACrD,YAAoB,EACpB,OAAmC,EACnC,aAAsB;IAEtB,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAAC,OAAO,UAAU,EAAE,CAAC;QACpB,MAAM,IAAI,uBAAS,CACjB,qBAAqB,YAAY,4DAA4D,YAAY,CAAC,aAAa,CAAC,iBAAiB,YAAY,CAAC,UAAU,CAAC,EAAE,CACpK,CAAC;IACJ,CAAC;IACD,MAAM,aAAa,CAAC;AACtB,CAAC;AAED,SAAgB,sBAAsB,CACpC,YAAoB,EACpB,KAAc;IAEd,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,wCAA8B,CACtC,GAAG,YAAY,8BAA8B,EAC7C;YACE,QAAQ,EAAE,YAAY;YACtB,OAAO,EAAE,OAAO;SACjB,CACF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAgB,6BAA6B,CAC3C,YAAoB,EACpB,QAAuB;IAEvB,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzC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AAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IACE,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QACjC,sBAAsB,CAAC,KAAK,CAAC,OAAO,CAAC,EACrC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,qBAAqB,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,KAAK,CAAC,KAAc;IAC3B,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,KAAK,CAAC;AAC1C,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,KAAK,GAAG,CAAC;IACvB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,wFAAwF,CAAC,IAAI,CAClG,KAAK,CAAC,IAAI,EAAE,CACb,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAe;IAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,kGAAkG,CAAC,IAAI,CACrG,IAAI,CACL;QACD,kGAAkG,CAAC,IAAI,CACrG,IAAI,CACL,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { UserError } from '@openai/agents-core';
|
|
2
|
+
import { SandboxProviderError, SandboxUnsupportedFeatureError, withSandboxSpan, } from '@openai/agents-core/sandbox';
|
|
3
|
+
import { isRecord } from "./typeGuards.mjs";
|
|
4
|
+
export { withSandboxSpan };
|
|
5
|
+
export async function closeRemoteSessionOnManifestError(providerName, session, manifestError) {
|
|
6
|
+
try {
|
|
7
|
+
await session.close();
|
|
8
|
+
}
|
|
9
|
+
catch (closeError) {
|
|
10
|
+
throw new UserError(`Failed to apply a ${providerName} sandbox manifest and close the sandbox. Manifest error: ${errorMessage(manifestError)} Close error: ${errorMessage(closeError)}`);
|
|
11
|
+
}
|
|
12
|
+
throw manifestError;
|
|
13
|
+
}
|
|
14
|
+
export function assertRunAsUnsupported(providerName, runAs) {
|
|
15
|
+
if (runAs) {
|
|
16
|
+
throw new SandboxUnsupportedFeatureError(`${providerName} does not support runAs yet.`, {
|
|
17
|
+
provider: providerName,
|
|
18
|
+
feature: 'runAs',
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function assertCoreSnapshotUnsupported(providerName, snapshot) {
|
|
23
|
+
if (snapshot && snapshot.type !== 'noop') {
|
|
24
|
+
throw new SandboxUnsupportedFeatureError(`${providerName} does not support core sandbox snapshots yet. Use the provider-specific workspacePersistence option when available.`, {
|
|
25
|
+
provider: providerName,
|
|
26
|
+
feature: 'snapshot',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function assertCoreConcurrencyLimitsUnsupported(providerName, limits) {
|
|
31
|
+
if (limits?.manifestEntries !== undefined ||
|
|
32
|
+
limits?.localDirFiles !== undefined) {
|
|
33
|
+
throw new SandboxUnsupportedFeatureError(`${providerName} does not support core sandbox concurrencyLimits yet.`, {
|
|
34
|
+
provider: providerName,
|
|
35
|
+
feature: 'concurrencyLimits',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export async function withProviderError(providerName, provider, operation, fn, context = {}) {
|
|
40
|
+
try {
|
|
41
|
+
return await fn();
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
if (error instanceof UserError) {
|
|
45
|
+
throw error;
|
|
46
|
+
}
|
|
47
|
+
throw new SandboxProviderError(`${providerName} failed to ${operation}.`, {
|
|
48
|
+
provider,
|
|
49
|
+
operation,
|
|
50
|
+
...context,
|
|
51
|
+
cause: errorMessage(error),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function isProviderSandboxNotFoundError(error) {
|
|
56
|
+
if (isNotFoundErrorRecord(error, new Set())) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
const text = errorMessage(error).trim();
|
|
60
|
+
return isNotFoundErrorMessage(text);
|
|
61
|
+
}
|
|
62
|
+
export function assertResumeRecreateAllowed(error, context) {
|
|
63
|
+
if (error instanceof UserError) {
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
if (isProviderSandboxNotFoundError(error)) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
throw new SandboxProviderError(`${context.providerName} failed to reconnect sandbox during resume.`, {
|
|
70
|
+
provider: context.provider,
|
|
71
|
+
operation: 'resume',
|
|
72
|
+
...context.details,
|
|
73
|
+
cause: errorMessage(error),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function errorMessage(error) {
|
|
77
|
+
return error instanceof Error ? error.message : String(error);
|
|
78
|
+
}
|
|
79
|
+
function isNotFoundErrorRecord(error, seen) {
|
|
80
|
+
if (!isRecord(error)) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (seen.has(error)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
seen.add(error);
|
|
87
|
+
for (const key of ['status', 'statusCode', 'httpStatus', 'httpStatusCode']) {
|
|
88
|
+
if (is404(error[key])) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
const response = error.response;
|
|
93
|
+
if (isRecord(response) && is404(response.status)) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if (isNotFoundErrorCode(error.code)) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (typeof error.message === 'string' &&
|
|
100
|
+
isNotFoundErrorMessage(error.message)) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
return isNotFoundErrorRecord(error.cause, seen);
|
|
104
|
+
}
|
|
105
|
+
function is404(value) {
|
|
106
|
+
return value === 404 || value === '404';
|
|
107
|
+
}
|
|
108
|
+
function isNotFoundErrorCode(value) {
|
|
109
|
+
if (typeof value === 'number') {
|
|
110
|
+
return value === 404;
|
|
111
|
+
}
|
|
112
|
+
if (typeof value !== 'string') {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return /^(404|not_found|not-found|notfound|resource_not_found|resource-not-found|not found)$/iu.test(value.trim());
|
|
116
|
+
}
|
|
117
|
+
function isNotFoundErrorMessage(message) {
|
|
118
|
+
const text = message.trim();
|
|
119
|
+
if (!text) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
if (/^(404|not[_ -]?found)$/iu.test(text)) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
return (/\b(sandbox|sandbox instance|instance|devbox)\b.*\b(not found|missing|does not exist|no such)\b/iu.test(text) ||
|
|
126
|
+
/\b(not found|missing|does not exist|no such)\b.*\b(sandbox|sandbox instance|instance|devbox)\b/iu.test(text));
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=session.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.mjs","sourceRoot":"","sources":["../../../src/sandbox/shared/session.ts"],"names":[],"mappings":"OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB;OACxC,EACL,oBAAoB,EACpB,8BAA8B,EAC9B,eAAe,GAGhB,MAAM,6BAA6B;OAC7B,EAAE,QAAQ,EAAE;AAEnB,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,YAAoB,EACpB,OAAmC,EACnC,aAAsB;IAE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f,CAAC;IACD,OAAO,wFAAwF,CAAC,IAAI,CAClG,KAAK,CAAC,IAAI,EAAE,CACb,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB,CAAC,OAAe;IAC7C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,kGAAkG,CAAC,IAAI,CACrG,IAAI,CACL;QACD,kGAAkG,CAAC,IAAI,CACrG,IAAI,CACL,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { type ToolOutputImage } from '@openai/agents-core';
|
|
2
|
+
import { type ExecCommandArgs, type ExposedPortEndpoint, type Manifest, type MaterializeEntryArgs, type ReadFileArgs, type SandboxConcurrencyLimits, type SandboxSession, type SandboxSessionState, type ViewImageArgs, type WorkspaceArchiveData } from '@openai/agents-core/sandbox';
|
|
3
|
+
import { type RemoteWorkspaceTarIo } from './archive';
|
|
4
|
+
import { RemoteSandboxEditor } from './editor';
|
|
5
|
+
import type { ManifestMaterializationOptions } from './manifest';
|
|
6
|
+
import type { RemoteManifestWriter, RemoteSandboxPathOptions, RemoteSandboxPathResolver, SandboxManifestMetadataSupport } from './types';
|
|
7
|
+
export type RemoteSandboxCommandKind = 'archive' | 'exec' | 'manifest' | 'path' | 'running';
|
|
8
|
+
export type RemoteSandboxCommandOptions = {
|
|
9
|
+
kind: RemoteSandboxCommandKind;
|
|
10
|
+
workdir: string;
|
|
11
|
+
runAs?: string;
|
|
12
|
+
execArgs?: ExecCommandArgs;
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
};
|
|
15
|
+
export type RemoteSandboxCommandResult = {
|
|
16
|
+
status: number;
|
|
17
|
+
stdout?: string;
|
|
18
|
+
stderr?: string;
|
|
19
|
+
};
|
|
20
|
+
export type RemoteSandboxSessionBaseOptions = {
|
|
21
|
+
providerName: string;
|
|
22
|
+
providerId: string;
|
|
23
|
+
concurrencyLimits?: SandboxConcurrencyLimits;
|
|
24
|
+
};
|
|
25
|
+
export declare abstract class RemoteSandboxSessionBase<TState extends SandboxSessionState & {
|
|
26
|
+
environment: Record<string, string>;
|
|
27
|
+
}> implements SandboxSession<TState> {
|
|
28
|
+
readonly state: TState;
|
|
29
|
+
protected readonly providerName: string;
|
|
30
|
+
protected readonly providerId: string;
|
|
31
|
+
private readonly concurrencyLimits?;
|
|
32
|
+
protected readonly remotePathResolver: RemoteSandboxPathResolver;
|
|
33
|
+
protected constructor(args: {
|
|
34
|
+
state: TState;
|
|
35
|
+
options: RemoteSandboxSessionBaseOptions;
|
|
36
|
+
});
|
|
37
|
+
createEditor(runAs?: string): RemoteSandboxEditor;
|
|
38
|
+
supportsPty(): boolean;
|
|
39
|
+
execCommand(args: ExecCommandArgs): Promise<string>;
|
|
40
|
+
viewImage(args: ViewImageArgs): Promise<ToolOutputImage>;
|
|
41
|
+
pathExists(path: string, runAs?: string): Promise<boolean>;
|
|
42
|
+
readFile(args: ReadFileArgs): Promise<Uint8Array>;
|
|
43
|
+
running(): Promise<boolean>;
|
|
44
|
+
resolveExposedPort(port: number): Promise<ExposedPortEndpoint>;
|
|
45
|
+
materializeEntry(args: MaterializeEntryArgs): Promise<void>;
|
|
46
|
+
applyManifest(manifest: Manifest, runAs?: string): Promise<void>;
|
|
47
|
+
persistWorkspace(): Promise<Uint8Array>;
|
|
48
|
+
hydrateWorkspace(data: WorkspaceArchiveData): Promise<void>;
|
|
49
|
+
protected abstract runRemoteCommand(command: string, options: RemoteSandboxCommandOptions): Promise<RemoteSandboxCommandResult>;
|
|
50
|
+
protected abstract mkdirRemote(path: string): Promise<void>;
|
|
51
|
+
protected abstract readRemoteText(path: string): Promise<string>;
|
|
52
|
+
protected abstract readRemoteFile(path: string): Promise<Uint8Array>;
|
|
53
|
+
protected abstract writeRemoteFile(path: string, content: string | Uint8Array): Promise<void>;
|
|
54
|
+
protected abstract deleteRemotePath(path: string): Promise<void>;
|
|
55
|
+
protected execPtyCommand(_args: ExecCommandArgs): Promise<string>;
|
|
56
|
+
protected assertExecRunAs(runAs?: string): void;
|
|
57
|
+
protected assertFilesystemRunAs(runAs?: string): void;
|
|
58
|
+
protected assertManifestRunAs(runAs?: string): void;
|
|
59
|
+
protected beforeExecCommand(_args: ExecCommandArgs): Promise<void>;
|
|
60
|
+
protected beforeFilesystemMutation(): Promise<void>;
|
|
61
|
+
protected beforeMaterializeEntry(_args: MaterializeEntryArgs): Promise<void>;
|
|
62
|
+
protected beforeApplyManifest(_manifest: Manifest): Promise<void>;
|
|
63
|
+
protected resolveManifestForApply(manifest: Manifest): Manifest | Promise<Manifest>;
|
|
64
|
+
protected manifestMetadataSupport(): SandboxManifestMetadataSupport | undefined;
|
|
65
|
+
protected manifestMaterializationOptions(): ManifestMaterializationOptions;
|
|
66
|
+
protected workspacePersistence(): unknown;
|
|
67
|
+
protected configuredExposedPorts(): number[] | undefined;
|
|
68
|
+
protected allowOnDemandExposedPorts(): boolean;
|
|
69
|
+
protected useCachedExposedPortEndpoint(_port: number): boolean;
|
|
70
|
+
protected exposedPortSource(): string;
|
|
71
|
+
protected resolveRemoteExposedPort(port: number): Promise<string | ExposedPortEndpoint>;
|
|
72
|
+
protected runningWorkdir(): string;
|
|
73
|
+
protected resolveWorkdir(path?: string): string;
|
|
74
|
+
protected resolveAbsolutePath(path?: string): string;
|
|
75
|
+
protected resolveRemotePath(path?: string, options?: RemoteSandboxPathOptions): Promise<string>;
|
|
76
|
+
protected ensureParentDir(path: string): Promise<void>;
|
|
77
|
+
protected persistWorkspaceTar(): Promise<Uint8Array>;
|
|
78
|
+
protected hydrateWorkspaceTar(data: WorkspaceArchiveData): Promise<void>;
|
|
79
|
+
protected manifestWriter(): RemoteManifestWriter;
|
|
80
|
+
protected materializeManifestEntries(manifest: Manifest): Promise<void>;
|
|
81
|
+
protected archiveIo(): RemoteWorkspaceTarIo;
|
|
82
|
+
private parentDir;
|
|
83
|
+
private createRunAsEditor;
|
|
84
|
+
private readRemoteFileAs;
|
|
85
|
+
private writeRemoteTextAs;
|
|
86
|
+
private manifestMaterializationOptionsWithMetadata;
|
|
87
|
+
private provisionManifestAccounts;
|
|
88
|
+
private applyManifestEntryMetadata;
|
|
89
|
+
private runCheckedRemoteCommand;
|
|
90
|
+
}
|