@giselles-ai/sandbox-agent 0.1.12 → 0.1.14
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/index.d.ts +4 -0
- package/dist/index.js +26 -9
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ declare class Agent {
|
|
|
17
17
|
path: string;
|
|
18
18
|
content: Buffer;
|
|
19
19
|
}>): this;
|
|
20
|
+
setAgentMd(content: string | Buffer): this;
|
|
20
21
|
runCommands(commands: Array<{
|
|
21
22
|
cmd: string;
|
|
22
23
|
args?: string[];
|
|
@@ -28,6 +29,7 @@ type BaseChatRequest = {
|
|
|
28
29
|
message: string;
|
|
29
30
|
session_id?: string;
|
|
30
31
|
sandbox_id?: string;
|
|
32
|
+
snapshot_id?: string;
|
|
31
33
|
};
|
|
32
34
|
type ChatCommand = {
|
|
33
35
|
cmd: string;
|
|
@@ -61,6 +63,7 @@ declare const codexRequestSchema: z.ZodObject<{
|
|
|
61
63
|
message: z.ZodString;
|
|
62
64
|
session_id: z.ZodOptional<z.ZodString>;
|
|
63
65
|
sandbox_id: z.ZodOptional<z.ZodString>;
|
|
66
|
+
snapshot_id: z.ZodOptional<z.ZodString>;
|
|
64
67
|
relay_session_id: z.ZodOptional<z.ZodString>;
|
|
65
68
|
relay_token: z.ZodOptional<z.ZodString>;
|
|
66
69
|
}, z.core.$strip>;
|
|
@@ -86,6 +89,7 @@ declare const geminiRequestSchema: z.ZodObject<{
|
|
|
86
89
|
message: z.ZodString;
|
|
87
90
|
session_id: z.ZodOptional<z.ZodString>;
|
|
88
91
|
sandbox_id: z.ZodOptional<z.ZodString>;
|
|
92
|
+
snapshot_id: z.ZodOptional<z.ZodString>;
|
|
89
93
|
relay_session_id: z.ZodOptional<z.ZodString>;
|
|
90
94
|
relay_token: z.ZodOptional<z.ZodString>;
|
|
91
95
|
}, z.core.$strip>;
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,13 @@ var Agent = class _Agent {
|
|
|
34
34
|
});
|
|
35
35
|
return this;
|
|
36
36
|
}
|
|
37
|
+
setAgentMd(content) {
|
|
38
|
+
const buffer = typeof content === "string" ? Buffer.from(content) : content;
|
|
39
|
+
console.log(`[agent] setAgentMd called, content length=${buffer.length}`);
|
|
40
|
+
return this.addFiles([
|
|
41
|
+
{ path: "/home/vercel-sandbox/AGENTS.md", content: buffer }
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
37
44
|
runCommands(commands) {
|
|
38
45
|
for (const command of commands) {
|
|
39
46
|
this._pendingOps.push({
|
|
@@ -45,6 +52,9 @@ var Agent = class _Agent {
|
|
|
45
52
|
return this;
|
|
46
53
|
}
|
|
47
54
|
async prepare() {
|
|
55
|
+
console.log(
|
|
56
|
+
`[agent] prepare called, dirty=${this.dirty}, pendingOps=${this._pendingOps.length}`
|
|
57
|
+
);
|
|
48
58
|
if (!this.dirty) {
|
|
49
59
|
return;
|
|
50
60
|
}
|
|
@@ -66,6 +76,7 @@ var Agent = class _Agent {
|
|
|
66
76
|
}
|
|
67
77
|
}
|
|
68
78
|
const snapshot = await sandbox.snapshot();
|
|
79
|
+
console.log(`[agent] prepare done, new snapshotId=${snapshot.snapshotId}`);
|
|
69
80
|
this._snapshotId = snapshot.snapshotId;
|
|
70
81
|
this._pendingOps = [];
|
|
71
82
|
}
|
|
@@ -180,6 +191,7 @@ var codexRequestSchema = z.object({
|
|
|
180
191
|
message: z.string().min(1),
|
|
181
192
|
session_id: z.string().min(1).optional(),
|
|
182
193
|
sandbox_id: z.string().min(1).optional(),
|
|
194
|
+
snapshot_id: z.string().min(1).optional(),
|
|
183
195
|
relay_session_id: z.string().min(1).optional(),
|
|
184
196
|
relay_token: z.string().min(1).optional()
|
|
185
197
|
});
|
|
@@ -248,8 +260,6 @@ function createCodexAgent(options = {}) {
|
|
|
248
260
|
const browserToolRelayUrl = options.tools?.browser?.relayUrl?.trim();
|
|
249
261
|
if (browserToolEnabled) {
|
|
250
262
|
requiredEnv(env, "BROWSER_TOOL_RELAY_URL");
|
|
251
|
-
requiredEnv(env, "BROWSER_TOOL_RELAY_SESSION_ID");
|
|
252
|
-
requiredEnv(env, "BROWSER_TOOL_RELAY_TOKEN");
|
|
253
263
|
}
|
|
254
264
|
if (browserToolEnabled && !browserToolRelayUrl) {
|
|
255
265
|
throw new Error("tools.browser.relayUrl is empty.");
|
|
@@ -261,9 +271,13 @@ function createCodexAgent(options = {}) {
|
|
|
261
271
|
if (!browserToolEnabled) {
|
|
262
272
|
return;
|
|
263
273
|
}
|
|
264
|
-
requiredEnv(env, "VERCEL_OIDC_TOKEN");
|
|
265
274
|
assertBrowserToolRelayCredentials(_input.input);
|
|
266
|
-
|
|
275
|
+
const patchEnv = {
|
|
276
|
+
...env,
|
|
277
|
+
BROWSER_TOOL_RELAY_SESSION_ID: _input.input.relay_session_id,
|
|
278
|
+
BROWSER_TOOL_RELAY_TOKEN: _input.input.relay_token
|
|
279
|
+
};
|
|
280
|
+
await patchCodexConfigTransportEnv(_input.sandbox, patchEnv);
|
|
267
281
|
},
|
|
268
282
|
createCommand({ input }) {
|
|
269
283
|
const args = ["exec"];
|
|
@@ -290,6 +304,7 @@ var geminiRequestSchema = z2.object({
|
|
|
290
304
|
message: z2.string().min(1),
|
|
291
305
|
session_id: z2.string().min(1).optional(),
|
|
292
306
|
sandbox_id: z2.string().min(1).optional(),
|
|
307
|
+
snapshot_id: z2.string().min(1).optional(),
|
|
293
308
|
relay_session_id: z2.string().min(1).optional(),
|
|
294
309
|
relay_token: z2.string().min(1).optional()
|
|
295
310
|
});
|
|
@@ -361,8 +376,6 @@ function createGeminiAgent(options = {}) {
|
|
|
361
376
|
const browserToolRelayUrl = options.tools?.browser?.relayUrl?.trim();
|
|
362
377
|
if (browserToolEnabled) {
|
|
363
378
|
requiredEnv2(env, "BROWSER_TOOL_RELAY_URL");
|
|
364
|
-
requiredEnv2(env, "BROWSER_TOOL_RELAY_SESSION_ID");
|
|
365
|
-
requiredEnv2(env, "BROWSER_TOOL_RELAY_TOKEN");
|
|
366
379
|
}
|
|
367
380
|
if (browserToolEnabled && !browserToolRelayUrl) {
|
|
368
381
|
throw new Error("tools.browser.relayUrl is empty.");
|
|
@@ -374,9 +387,13 @@ function createGeminiAgent(options = {}) {
|
|
|
374
387
|
if (!browserToolEnabled) {
|
|
375
388
|
return;
|
|
376
389
|
}
|
|
377
|
-
requiredEnv2(env, "VERCEL_OIDC_TOKEN");
|
|
378
390
|
assertBrowserToolRelayCredentials2(input);
|
|
379
|
-
|
|
391
|
+
const patchEnv = {
|
|
392
|
+
...env,
|
|
393
|
+
BROWSER_TOOL_RELAY_SESSION_ID: input.relay_session_id,
|
|
394
|
+
BROWSER_TOOL_RELAY_TOKEN: input.relay_token
|
|
395
|
+
};
|
|
396
|
+
await patchGeminiSettingsTransportEnv(sandbox, patchEnv);
|
|
380
397
|
},
|
|
381
398
|
createCommand({ input }) {
|
|
382
399
|
const args = [
|
|
@@ -458,7 +475,7 @@ function runChat(input) {
|
|
|
458
475
|
void (async () => {
|
|
459
476
|
try {
|
|
460
477
|
const sandbox = parsed.sandbox_id ? await Sandbox2.get({ sandboxId: parsed.sandbox_id }) : await (async () => {
|
|
461
|
-
const snapshotId = input.agent.snapshotId?.trim();
|
|
478
|
+
const snapshotId = parsed.snapshot_id?.trim() || input.agent.snapshotId?.trim();
|
|
462
479
|
if (!snapshotId) {
|
|
463
480
|
throw new Error(
|
|
464
481
|
"Agent must provide snapshotId when sandbox_id is not provided."
|