@finalai/daytona-agent-provider 0.9.0 → 0.11.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/HOSTING.md +334 -245
- package/README.md +86 -26
- package/dist/modules/sandboxes/daytona.d.mts +18 -20
- package/dist/modules/sandboxes/daytona.mjs +234 -539
- package/dist/modules/sandboxes/daytona.mjs.map +3 -3
- package/dist/modules/sandboxes/environment.d.mts +5 -36
- package/dist/modules/sandboxes/environment.mjs +11 -59
- package/dist/modules/sandboxes/environment.mjs.map +3 -3
- package/dist/modules/sandboxes/index.d.mts +9 -60
- package/dist/modules/sandboxes/index.mjs +14 -41
- package/dist/modules/sandboxes/index.mjs.map +3 -3
- package/dist/modules/sandboxes/session.d.mts +2 -3
- package/dist/modules/sandboxes/session.mjs +8 -51
- package/dist/modules/sandboxes/session.mjs.map +2 -2
- package/package.json +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/sandboxes/environment.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { sandboxCredentialRefSchema } from '@finalai/agent-provider';\nimport * as z from 'zod';\n\n// The `daytona` provider environment: Daytona's own options for the sandboxes\n// created from it (image or snapshot, resources, region, idle and park policy,\n// the API key by reference). What should be on the machine (repositories,\n// variables, steps, services, network policy) is a sandbox setup, which the\n// platform applies on any provider. Pure (no I/O) so callers can import it.\n\nexport const DAYTONA_SANDBOX_SPECIFIER = '@finalai/daytona-agent-provider/sandboxes/daytona';\nexport const DAYTONA_SANDBOX_NAME = 'daytona';\n\n// What parking a sandbox does with it. Both keep its disk.\nexport enum DaytonaParkPolicy {\n // Stop it; it starts again quickly.\n Stop = 'stop',\n // Archive it to Daytona's object storage; cheaper, slower to start again.\n Archive = 'archive',\n}\n\n// Resources of a snapshot built from `image` (cores and GiB).\nexport const daytonaResourcesSchema = z.strictObject({\n cpu: z.number().int().min(1).max(64).optional(),\n memory: z.number().int().min(1).max(256).optional(),\n disk: z.number().int().min(1).max(1024).optional(),\n});\n\nexport const daytonaEnvironmentSchema = z\n .strictObject({\n // The Daytona API key by reference: `secretRef` is the name of the secret\n // holding it, never the key. Without it no sandbox can be created.\n credential: sandboxCredentialRefSchema.optional(),\n // An OCI image; prepare builds a snapshot from it once.\n image: z.string().min(1).optional(),\n // An existing Daytona snapshot by name. Neither: Daytona's default snapshot.\n snapshot: z.string().min(1).optional(),\n resources: daytonaResourcesSchema.optional(),\n // Daytona region (`us`, `eu`, ...); the organization default otherwise.\n region: z.string().min(1).optional(),\n // The sandbox OS user; the snapshot's otherwise.\n user: z.string().min(1).optional(),\n // Absolute; the sandbox user's working directory otherwise.\n workingDirectory: z.string().startsWith('/').optional(),\n // Daytona stops an idle sandbox after this long; 0 disables.\n autoStopMinutes: z\n .number()\n .int()\n .min(0)\n .max(7 * 24 * 60)\n .default(15),\n // Daytona archives a sandbox stopped this long; Daytona's default otherwise.\n autoArchiveMinutes: z.number().int().min(1).optional(),\n park: z.nativeEnum(DaytonaParkPolicy).default(DaytonaParkPolicy.Stop),\n labels: z.record(z.string().min(1).max(63), z.string().max(63)).default({}),\n })\n .superRefine((value, ctx) => {\n if (value.image != null && value.snapshot != null) {\n ctx.addIssue({ code: 'custom', message: 'give image or snapshot, not both' });\n }\n if (value.resources != null && value.image == null) {\n ctx.addIssue({\n code: 'custom',\n message: 'resources apply to a snapshot built from image; a named snapshot has its own',\n });\n }\n });\n\nexport type DaytonaEnvironmentOptions = z.infer<typeof daytonaEnvironmentSchema>;\nexport type DaytonaEnvironmentInput = z.input<typeof daytonaEnvironmentSchema>;\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,kCAAkC;AAC3C,YAAY,OAAO;AAQZ,MAAM,4BAA4B;AAClC,MAAM,uBAAuB;AAG7B,IAAK,oBAAL,kBAAKA,uBAAL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AQ,CAAC,CAAC;AAC5E,CAAC,EACA,YAAY,CAAC,OAAO,QAAQ;AAC3B,MAAI,MAAM,SAAS,QAAQ,MAAM,YAAY,MAAM;AACjD,QAAI,SAAS,EAAE,MAAM,UAAU,SAAS,mCAAmC,CAAC;AAAA,EAC9E;AACA,MAAI,MAAM,aAAa,QAAQ,MAAM,SAAS,MAAM;AAClD,QAAI,SAAS;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACF,CAAC;",
|
|
6
|
+
"names": ["DaytonaParkPolicy"]
|
|
7
7
|
}
|
|
@@ -1,60 +1,9 @@
|
|
|
1
|
-
import { type JsonObject
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
type
|
|
6
|
-
export interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
export interface DaytonaInputIface {
|
|
12
|
-
credential?: {
|
|
13
|
-
secretRef: string;
|
|
14
|
-
};
|
|
15
|
-
image?: string;
|
|
16
|
-
snapshot?: string;
|
|
17
|
-
resources?: {
|
|
18
|
-
cpu?: number;
|
|
19
|
-
memory?: number;
|
|
20
|
-
disk?: number;
|
|
21
|
-
};
|
|
22
|
-
target?: string;
|
|
23
|
-
user?: string;
|
|
24
|
-
workingDirectory?: string;
|
|
25
|
-
env?: Record<string, string>;
|
|
26
|
-
variables?: string[];
|
|
27
|
-
repositories?: DaytonaRepositoryInputIface[];
|
|
28
|
-
networkPolicy?: EnumInput<NetworkPolicy> | {
|
|
29
|
-
mode: EnumInput<NetworkPolicy>;
|
|
30
|
-
allow?: string[];
|
|
31
|
-
};
|
|
32
|
-
ports?: number[];
|
|
33
|
-
autoStopMinutes?: number;
|
|
34
|
-
autoArchiveMinutes?: number;
|
|
35
|
-
workspace?: EnumInput<SandboxWorkspace>;
|
|
36
|
-
onSessionEnd?: EnumInput<DaytonaSessionEndPolicy>;
|
|
37
|
-
labels?: Record<string, string>;
|
|
38
|
-
}
|
|
39
|
-
export interface DaytonaOpenInputIface {
|
|
40
|
-
access?: EnumInput<SandboxAccess>;
|
|
41
|
-
attach?: EnumInput<SandboxAttach>;
|
|
42
|
-
}
|
|
43
|
-
export interface DaytonaOpenRequestIface {
|
|
44
|
-
readonly providerName: string;
|
|
45
|
-
readonly providerRef: PackageProviderRefIface;
|
|
46
|
-
readonly environmentOptions: JsonObject;
|
|
47
|
-
readonly openOptions: JsonObject;
|
|
48
|
-
}
|
|
49
|
-
export interface DaytonaSandboxEnvironmentIface {
|
|
50
|
-
readonly providerName: string;
|
|
51
|
-
readonly providerRef: PackageProviderRefIface;
|
|
52
|
-
readonly options: JsonObject;
|
|
53
|
-
open(options?: DaytonaOpenInputIface): DaytonaOpenRequestIface & PromiseLike<NetworkSandboxSessionIface>;
|
|
54
|
-
}
|
|
55
|
-
export declare const daytona: ((input?: DaytonaInputIface) => DaytonaSandboxEnvironmentIface) & {
|
|
56
|
-
providerRef: {
|
|
57
|
-
kind: import("@finalai/agent-provider").ProviderRefKind.Package;
|
|
58
|
-
specifier: string;
|
|
59
|
-
};
|
|
60
|
-
};
|
|
1
|
+
import { type JsonObject } from '@finalai/agent-provider';
|
|
2
|
+
import type { SandboxEnvironmentValueIface } from '@finalai/agent-provider/sandbox';
|
|
3
|
+
import { type DaytonaEnvironmentInput, type DaytonaParkPolicy } from "./environment.mjs";
|
|
4
|
+
export { DAYTONA_SANDBOX_NAME, DAYTONA_SANDBOX_SPECIFIER, daytonaEnvironmentSchema, DaytonaParkPolicy, } from "./environment.mjs";
|
|
5
|
+
export type { DaytonaEnvironmentInput, DaytonaEnvironmentOptions } from "./environment.mjs";
|
|
6
|
+
export interface DaytonaInputIface extends Omit<DaytonaEnvironmentInput, 'park'> {
|
|
7
|
+
park?: DaytonaParkPolicy | `${DaytonaParkPolicy}`;
|
|
8
|
+
}
|
|
9
|
+
export declare const daytona: (input?: DaytonaInputIface) => SandboxEnvironmentValueIface<JsonObject>;
|
|
@@ -1,51 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
awaitableOpenRequest,
|
|
3
|
-
jsonObjectSchema,
|
|
4
|
-
packageRef
|
|
5
|
-
} from "@finalai/agent-provider";
|
|
1
|
+
import { jsonObjectSchema } from "@finalai/agent-provider";
|
|
6
2
|
import {
|
|
7
3
|
DAYTONA_SANDBOX_NAME,
|
|
8
|
-
|
|
9
|
-
daytonaEnvironmentSchema,
|
|
10
|
-
daytonaOpenOptionsSchema
|
|
4
|
+
daytonaEnvironmentSchema
|
|
11
5
|
} from "./environment.mjs";
|
|
12
6
|
import {
|
|
13
|
-
|
|
7
|
+
DAYTONA_SANDBOX_NAME as DAYTONA_SANDBOX_NAME2,
|
|
8
|
+
DAYTONA_SANDBOX_SPECIFIER,
|
|
14
9
|
daytonaEnvironmentSchema as daytonaEnvironmentSchema2,
|
|
15
|
-
|
|
10
|
+
DaytonaParkPolicy
|
|
16
11
|
} from "./environment.mjs";
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!parsed.success) throw new Error(`invalid daytona environment: ${parsed.error.message}`);
|
|
24
|
-
return {
|
|
25
|
-
providerName: DAYTONA_SANDBOX_NAME,
|
|
26
|
-
providerRef,
|
|
27
|
-
options,
|
|
28
|
-
open: (openOptions) => {
|
|
29
|
-
const open = recorded(openOptions ?? {});
|
|
30
|
-
const checked = daytonaOpenOptionsSchema.safeParse(open);
|
|
31
|
-
if (!checked.success) {
|
|
32
|
-
throw new Error(`invalid daytona open options: ${checked.error.message}`);
|
|
33
|
-
}
|
|
34
|
-
return awaitableOpenRequest({
|
|
35
|
-
providerName: DAYTONA_SANDBOX_NAME,
|
|
36
|
-
providerRef,
|
|
37
|
-
environmentOptions: options,
|
|
38
|
-
openOptions: open
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
// `defineDynamic({ provider: daytona, ... })` names the provider this way.
|
|
44
|
-
{ providerRef }
|
|
45
|
-
);
|
|
12
|
+
const daytona = (input = {}) => {
|
|
13
|
+
const environment = jsonObjectSchema.parse(JSON.parse(JSON.stringify(input)));
|
|
14
|
+
const parsed = daytonaEnvironmentSchema.safeParse(environment);
|
|
15
|
+
if (!parsed.success) throw new Error(`invalid daytona environment: ${parsed.error.message}`);
|
|
16
|
+
return { provider: DAYTONA_SANDBOX_NAME, environment };
|
|
17
|
+
};
|
|
46
18
|
export {
|
|
47
|
-
|
|
48
|
-
|
|
19
|
+
DAYTONA_SANDBOX_NAME2 as DAYTONA_SANDBOX_NAME,
|
|
20
|
+
DAYTONA_SANDBOX_SPECIFIER,
|
|
21
|
+
DaytonaParkPolicy,
|
|
49
22
|
daytona,
|
|
50
23
|
daytonaEnvironmentSchema2 as daytonaEnvironmentSchema
|
|
51
24
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/sandboxes/index.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import { jsonObjectSchema, type JsonObject } from '@finalai/agent-provider';\nimport type { SandboxEnvironmentValueIface } from '@finalai/agent-provider/sandbox';\nimport {\n DAYTONA_SANDBOX_NAME,\n daytonaEnvironmentSchema,\n type DaytonaEnvironmentInput,\n type DaytonaParkPolicy,\n} from \"./environment.mjs\";\n\n// The `daytona` provider environment, as the plain value a caller creates\n// sandboxes from:\n//\n// import { daytona } from '@finalai/daytona-agent-provider/sandboxes';\n// const box = await project.sandboxes.create(\n// daytona({ credential: { secretRef: 'DAYTONA_API_KEY' }, image: 'node:26' }),\n// { setup },\n// );\n//\n// Pure: it validates the options and returns them as authored. The runtime\n// provider lives in `./sandboxes/daytona`.\n\nexport {\n DAYTONA_SANDBOX_NAME,\n DAYTONA_SANDBOX_SPECIFIER,\n daytonaEnvironmentSchema,\n DaytonaParkPolicy,\n} from \"./environment.mjs\";\nexport type { DaytonaEnvironmentInput, DaytonaEnvironmentOptions } from \"./environment.mjs\";\n\nexport interface DaytonaInputIface extends Omit<DaytonaEnvironmentInput, 'park'> {\n park?: DaytonaParkPolicy | `${DaytonaParkPolicy}`;\n}\n\n// A Daytona sandbox in your own Daytona account.\nexport const daytona = (\n input: DaytonaInputIface = {},\n): SandboxEnvironmentValueIface<JsonObject> => {\n // JSON round trip drops undefined members, so the value is stable plain data.\n const environment = jsonObjectSchema.parse(JSON.parse(JSON.stringify(input)));\n const parsed = daytonaEnvironmentSchema.safeParse(environment);\n if (!parsed.success) throw new Error(`invalid daytona environment: ${parsed.error.message}`);\n return { provider: DAYTONA_SANDBOX_NAME, environment };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,wBAAyC;AAElD;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAcP;AAAA,EACE,wBAAAA;AAAA,EACA;AAAA,EACA,4BAAAC;AAAA,EACA;AAAA,OACK;AAQA,MAAM,UAAU,CACrB,QAA2B,CAAC,MACiB;AAE7C,QAAM,cAAc,iBAAiB,MAAM,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAAC;AAC5E,QAAM,SAAS,yBAAyB,UAAU,WAAW;AAC7D,MAAI,CAAC,OAAO,QAAS,OAAM,IAAI,MAAM,gCAAgC,OAAO,MAAM,OAAO,EAAE;AAC3F,SAAO,EAAE,UAAU,sBAAsB,YAAY;AACvD;",
|
|
6
|
+
"names": ["DAYTONA_SANDBOX_NAME", "daytonaEnvironmentSchema"]
|
|
7
7
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SandboxAccess } from '@finalai/agent-provider';
|
|
2
1
|
import { SandboxCapability, type NetworkPolicyIface, type NetworkSandboxSessionIface } from '@finalai/agent-provider/sandbox';
|
|
3
2
|
import { type DaytonaClientIface, type DaytonaNetworkSettingsIface, type DaytonaResultIface, type DaytonaToolboxIface } from "../client/index.mjs";
|
|
4
3
|
export interface DaytonaSandboxSessionIface extends NetworkSandboxSessionIface {
|
|
@@ -33,6 +32,6 @@ export interface CreateDaytonaSessionArgsIface {
|
|
|
33
32
|
destroy: () => Promise<void>;
|
|
34
33
|
beforeUse?: () => Promise<void>;
|
|
35
34
|
}
|
|
36
|
-
export declare const
|
|
35
|
+
export declare const DAYTONA_FEATURES: readonly SandboxCapability[];
|
|
37
36
|
export declare const createDaytonaSession: (args: CreateDaytonaSessionArgsIface) => DaytonaSandboxSessionIface;
|
|
38
|
-
export declare const
|
|
37
|
+
export declare const withNetworkPolicyValidation: (session: DaytonaSandboxSessionIface) => DaytonaSandboxSessionIface;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { SandboxAccess } from "@finalai/agent-provider";
|
|
2
1
|
import {
|
|
3
2
|
createConfinedFileReader,
|
|
4
3
|
NetworkPolicy,
|
|
@@ -120,7 +119,7 @@ const toStat = (path, info) => ({
|
|
|
120
119
|
modifiedAt: info.modifiedAt,
|
|
121
120
|
mode: info.mode
|
|
122
121
|
});
|
|
123
|
-
const
|
|
122
|
+
const DAYTONA_FEATURES = [
|
|
124
123
|
SandboxCapability.Files,
|
|
125
124
|
SandboxCapability.Process,
|
|
126
125
|
SandboxCapability.DurableProcesses,
|
|
@@ -238,7 +237,7 @@ const createDaytonaSession = (args) => {
|
|
|
238
237
|
description: args.description,
|
|
239
238
|
defaultWorkingDirectory: args.workingDirectory,
|
|
240
239
|
ports: args.ports,
|
|
241
|
-
capabilities:
|
|
240
|
+
capabilities: DAYTONA_FEATURES,
|
|
242
241
|
resolvePath,
|
|
243
242
|
readFile: ({ path, abortSignal }) => readStream(path, abortSignal),
|
|
244
243
|
readBinaryFile: async ({ path, abortSignal }) => {
|
|
@@ -317,68 +316,26 @@ const createDaytonaSession = (args) => {
|
|
|
317
316
|
};
|
|
318
317
|
return { ...session, confinedFileReader: createConfinedFileReader(session) };
|
|
319
318
|
};
|
|
320
|
-
const
|
|
321
|
-
throw new Error("this sandbox binding is read-only");
|
|
322
|
-
};
|
|
323
|
-
const fileWriteRefusal = async () => {
|
|
324
|
-
throw new Error("this sandbox binding runs processes but does not write files");
|
|
325
|
-
};
|
|
326
|
-
const sessionForAccess = (session, access) => {
|
|
319
|
+
const withNetworkPolicyValidation = (session) => {
|
|
327
320
|
const apply = session.setNetworkPolicy;
|
|
328
|
-
|
|
321
|
+
if (apply == null) return session;
|
|
322
|
+
return {
|
|
329
323
|
...session,
|
|
330
324
|
setNetworkPolicy: async (policy) => {
|
|
331
325
|
networkSettingsFor(policy);
|
|
332
326
|
await apply(policy);
|
|
333
327
|
}
|
|
334
328
|
};
|
|
335
|
-
if (access === SandboxAccess.Read) {
|
|
336
|
-
const restricted = {
|
|
337
|
-
...validated,
|
|
338
|
-
capabilities: session.capabilities.filter(
|
|
339
|
-
(capability) => capability !== SandboxCapability.Egress && capability !== SandboxCapability.DurableProcesses
|
|
340
|
-
),
|
|
341
|
-
writeFile: readOnlyRefusal,
|
|
342
|
-
writeBinaryFile: readOnlyRefusal,
|
|
343
|
-
writeTextFile: readOnlyRefusal,
|
|
344
|
-
spawn: readOnlyRefusal,
|
|
345
|
-
run: readOnlyRefusal,
|
|
346
|
-
removePath: readOnlyRefusal,
|
|
347
|
-
setNetworkPolicy: readOnlyRefusal,
|
|
348
|
-
stop: readOnlyRefusal,
|
|
349
|
-
destroy: readOnlyRefusal
|
|
350
|
-
};
|
|
351
|
-
delete restricted.egress;
|
|
352
|
-
delete restricted.attachProcess;
|
|
353
|
-
return restricted;
|
|
354
|
-
}
|
|
355
|
-
if (access === SandboxAccess.Execute) {
|
|
356
|
-
const restricted = {
|
|
357
|
-
...validated,
|
|
358
|
-
capabilities: session.capabilities.filter(
|
|
359
|
-
(capability) => capability !== SandboxCapability.Egress
|
|
360
|
-
),
|
|
361
|
-
writeFile: fileWriteRefusal,
|
|
362
|
-
writeBinaryFile: fileWriteRefusal,
|
|
363
|
-
writeTextFile: fileWriteRefusal,
|
|
364
|
-
removePath: fileWriteRefusal,
|
|
365
|
-
stop: fileWriteRefusal,
|
|
366
|
-
destroy: fileWriteRefusal
|
|
367
|
-
};
|
|
368
|
-
delete restricted.egress;
|
|
369
|
-
return restricted;
|
|
370
|
-
}
|
|
371
|
-
return validated;
|
|
372
329
|
};
|
|
373
330
|
export {
|
|
374
|
-
|
|
331
|
+
DAYTONA_FEATURES,
|
|
375
332
|
createDaytonaSession,
|
|
376
333
|
daytonaApiError,
|
|
377
334
|
isCidr,
|
|
378
335
|
networkSettingsFor,
|
|
379
336
|
normalizePosixPath,
|
|
380
337
|
resolvePosixPath,
|
|
381
|
-
|
|
382
|
-
|
|
338
|
+
unwrap,
|
|
339
|
+
withNetworkPolicyValidation
|
|
383
340
|
};
|
|
384
341
|
//# sourceMappingURL=session.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/sandboxes/session.ts"],
|
|
4
|
-
"sourcesContent": ["import { SandboxAccess } from '@finalai/agent-provider';\nimport {\n createConfinedFileReader,\n NetworkPolicy,\n PortProtocol,\n SandboxCapability,\n SandboxEntryType,\n type DirEntryIface,\n type NetworkPolicyIface,\n type NetworkSandboxSessionIface,\n type SandboxAttachedProcessIface,\n type SandboxAttachProcessOptionsIface,\n type SandboxProcessIface,\n type SandboxProcessOptionsIface,\n type SandboxRunResultIface,\n type StatIface,\n} from '@finalai/agent-provider/sandbox';\nimport {\n type DaytonaClientIface,\n type DaytonaFileInfoIface,\n type DaytonaNetworkSettingsIface,\n type DaytonaProcessIface,\n type DaytonaResultIface,\n type DaytonaToolboxIface,\n} from \"../client/index.mjs\";\n\n// NetworkSandboxSessionIface over one Daytona sandbox: files through the\n// toolbox's file endpoints, processes through its process sessions, ports\n// through Daytona preview URLs and the egress policy through the sandbox's\n// network settings.\n\nexport interface DaytonaSandboxSessionIface extends NetworkSandboxSessionIface {\n readonly capabilities: readonly SandboxCapability[];\n}\n\nexport interface DaytonaApiErrorIface extends Error {\n code: string;\n status: number | null;\n}\n\nexport const daytonaApiError = (result: {\n error: string;\n statusCode?: number;\n details?: Array<{ message?: string }>;\n}): DaytonaApiErrorIface =>\n Object.assign(new Error(result.details?.[0]?.message ?? result.error), {\n name: 'DaytonaApiError',\n code: `daytona_${result.error}`,\n status: result.statusCode ?? null,\n });\n\nexport const unwrap = <T>(result: DaytonaResultIface<T>): T => {\n if (!result.ok) throw daytonaApiError(result);\n return result.data;\n};\n\nconst fsError = (code: string, message: string): Error =>\n Object.assign(new Error(`${code}: ${message}`), { code });\n\n// Exit status of a process stopped by its timeout, as `timeout(1)` reports it.\nconst TIMED_OUT_EXIT_CODE = 124;\nconst SIGNED_PORT_URL_SECONDS = 60 * 60;\n\nconst CIDR = /^\\d{1,3}(?:\\.\\d{1,3}){3}(?:\\/\\d{1,2})?$/;\nexport const isCidr = (entry: string): boolean => CIDR.test(entry);\nconst canonicalCidr = (entry: string): string => {\n const [ip = '', suffix] = entry.split('/');\n const octets = ip.split('.').map(Number);\n const prefix = suffix == null ? 32 : Number(suffix);\n if (octets.some((value) => value > 255) || prefix > 32)\n throw fsError('unsupported_network_policy', 'Invalid IPv4 CIDR in Daytona allowlist');\n const address = octets.reduce((value, octet) => value * 256 + octet, 0);\n const blockSize = 2 ** (32 - prefix);\n const network = address - (address % blockSize);\n return (\n [24, 16, 8, 0].map((shift) => Math.floor(network / 2 ** shift) % 256).join('.') + '/' + prefix\n );\n};\n\n// The contract's egress policy as Daytona network settings: CIDR blocks go to\n// the network allow list, everything else to the domain allow list.\nexport const networkSettingsFor = (policy: NetworkPolicyIface): DaytonaNetworkSettingsIface => {\n if (policy.mode === NetworkPolicy.AllowAll)\n return { networkBlockAll: false, domainAllowList: '', networkAllowList: '' };\n const allow = policy.mode === NetworkPolicy.Allowlist ? (policy.allow ?? []) : [];\n if (allow.length === 0)\n return { networkBlockAll: true, domainAllowList: '', networkAllowList: '' };\n const cidrs = allow.filter((entry) => CIDR.test(entry));\n const domains = allow.filter((entry) => !CIDR.test(entry));\n if (cidrs.length > 0 && domains.length > 0)\n throw fsError(\n 'unsupported_network_policy',\n 'Daytona allowlists must use domains or IPv4 CIDRs; mixed allowlists are unsupported',\n );\n const settings: DaytonaNetworkSettingsIface = {};\n if (cidrs.length > 0) {\n settings.networkBlockAll = false;\n settings.networkAllowList = [...new Set(cidrs.map(canonicalCidr))].join(',');\n // Daytona requires an explicit empty string to clear the other stored allowlist.\n settings.domainAllowList = '';\n }\n if (domains.length > 0) {\n settings.networkBlockAll = false;\n settings.domainAllowList = [...new Set(domains)].join(',');\n settings.networkAllowList = '';\n }\n return settings;\n};\n\nexport const normalizePosixPath = (path: string): string => {\n const parts: string[] = [];\n for (const part of path.split('/')) {\n if (part === '' || part === '.') continue;\n if (part === '..') parts.pop();\n else parts.push(part);\n }\n return `/${parts.join('/')}`;\n};\n\nexport const resolvePosixPath = (cwd: string, path: string): string =>\n normalizePosixPath(path.startsWith('/') ? path : `${cwd}/${path}`);\n\nconst encoder = new TextEncoder();\n\nconst collect = async (stream: ReadableStream<Uint8Array>): Promise<Uint8Array> => {\n const chunks: Uint8Array[] = [];\n let total = 0;\n for await (const chunk of stream) {\n chunks.push(chunk);\n total += chunk.byteLength;\n }\n const out = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out;\n};\n\n// Lines keep their terminators, so a range reads back exactly as stored.\nconst readLineRange = async (\n stream: ReadableStream<Uint8Array>,\n startLine: number,\n endLine: number | null,\n): Promise<string> => {\n const decoder = new TextDecoder();\n const reader = stream.getReader();\n const lines: string[] = [];\n let partial = '';\n let lineNumber = 1;\n const take = (line: string): boolean => {\n if (lineNumber >= startLine && (endLine == null || lineNumber <= endLine)) lines.push(line);\n lineNumber += 1;\n return endLine != null && lineNumber > endLine;\n };\n for (;;) {\n const next = await reader.read();\n partial += next.done ? decoder.decode() : decoder.decode(next.value, { stream: true });\n let newline = partial.indexOf('\\n');\n while (newline >= 0) {\n if (take(partial.slice(0, newline + 1))) {\n await reader.cancel();\n return lines.join('');\n }\n partial = partial.slice(newline + 1);\n newline = partial.indexOf('\\n');\n }\n if (next.done) break;\n }\n if (partial !== '') take(partial);\n return lines.join('');\n};\n\nconst toStat = (path: string, info: DaytonaFileInfoIface): StatIface => ({\n path,\n type: info.isDir ? SandboxEntryType.Directory : SandboxEntryType.File,\n size: info.size,\n modifiedAt: info.modifiedAt,\n mode: info.mode,\n});\n\nexport interface CreateDaytonaSessionArgsIface {\n client: DaytonaClientIface;\n toolbox: DaytonaToolboxIface;\n // Daytona's id for the sandbox (previews, network settings).\n sandboxId: string;\n description: string;\n workingDirectory: string;\n ports: readonly number[];\n // Every process's environment (injected variables), under per-call env;\n // read again for every process.\n baseEnv: () => Promise<Record<string, string>>;\n // Adds the platform's egress hosts to a policy set on this sandbox.\n platformEgress?: (policy: NetworkPolicyIface) => Promise<NetworkPolicyIface>;\n stop: () => Promise<void>;\n destroy: () => Promise<void>;\n beforeUse?: () => Promise<void>;\n}\n\nexport const DAYTONA_CAPABILITIES: readonly SandboxCapability[] = [\n SandboxCapability.Files,\n SandboxCapability.Process,\n SandboxCapability.DurableProcesses,\n SandboxCapability.Ports,\n SandboxCapability.NetworkPolicy,\n];\n\nexport const createDaytonaSession = (\n args: CreateDaytonaSessionArgsIface,\n): DaytonaSandboxSessionIface => {\n const { client, toolbox } = args;\n const resolvePath = (path: string): string => resolvePosixPath(args.workingDirectory, path);\n\n const readStream = async (\n path: string,\n signal: AbortSignal | undefined,\n ): Promise<ReadableStream<Uint8Array> | null> =>\n unwrap(await toolbox.download({ path: resolvePath(path), signal }));\n\n const writeContent = async (\n path: string,\n content: ReadableStream<Uint8Array> | Uint8Array,\n signal: AbortSignal | undefined,\n ): Promise<void> => {\n await args.beforeUse?.();\n const resolved = resolvePath(path);\n const parent = resolved.slice(0, resolved.lastIndexOf('/')) || '/';\n unwrap(await toolbox.createFolder({ path: parent, signal }));\n unwrap(await toolbox.upload({ path: resolved, content, signal }));\n };\n\n const spawnProcess = async (\n options: SandboxProcessOptionsIface,\n closeStdin: boolean,\n ): Promise<SandboxProcessIface> => {\n await args.beforeUse?.();\n const input = options.stdin;\n const stdin = input != null || !closeStdin;\n const durable = options.durable === true;\n const process: DaytonaProcessIface = unwrap(\n await toolbox.spawn({\n command: options.command,\n args: options.args ?? [],\n shell: options.shell === true,\n cwd: resolvePath(options.cwd ?? args.workingDirectory),\n env: { ...(await args.baseEnv()), ...options.env },\n stdin,\n signal: options.abortSignal,\n // A durable process's timeout runs in the sandbox, not in this handle.\n ...(durable ? { durable, timeoutMs: options.timeoutMs ?? null } : {}),\n }),\n );\n let timedOut = false;\n const timer =\n options.timeoutMs == null || durable\n ? null\n : setTimeout(() => {\n timedOut = true;\n void process.kill();\n }, options.timeoutMs);\n const exit = process.wait().then((result) => {\n if (timer != null) clearTimeout(timer);\n const { exitCode } = unwrap(result);\n return { exitCode: timedOut ? TIMED_OUT_EXIT_CODE : exitCode };\n });\n // Avoid an unhandled rejection when the caller only reads the streams.\n exit.catch(() => undefined);\n\n const write = async (\n data: Uint8Array | string,\n writeOptions?: { end?: boolean },\n ): Promise<void> => {\n // A detached durable handle neither writes to nor closes the process's stdin.\n if (durable) options.abortSignal?.throwIfAborted();\n await args.beforeUse?.();\n const bytes = data instanceof Uint8Array ? data : encoder.encode(data);\n if (bytes.byteLength > 0) unwrap(await process.write(bytes));\n if (writeOptions?.end === true) unwrap(await process.closeStdin());\n };\n if (input instanceof ReadableStream) {\n void (async () => {\n for await (const chunk of input) await write(chunk);\n await write(new Uint8Array(), { end: true });\n })().catch(async () => {\n // A durable process outlives a stdin that failed with its handle.\n if (!durable) await process.kill();\n });\n } else if (input != null) {\n try {\n await write(input, { end: true });\n } catch (error) {\n // An abort detaches a durable process rather than killing it.\n if (!durable || options.abortSignal?.aborted !== true) await process.kill();\n throw error;\n }\n }\n return {\n pid: process.id,\n ref: process.ref,\n stdout: process.stdout,\n stderr: process.stderr,\n write,\n wait: () => exit,\n // Daytona ends a process by ending its session, whatever the signal.\n kill: async () => {\n unwrap(await process.kill());\n },\n };\n };\n\n const attachProcess = async (\n options: SandboxAttachProcessOptionsIface,\n ): Promise<SandboxAttachedProcessIface | null> => {\n await args.beforeUse?.();\n const process = unwrap(\n await toolbox.attach({\n ref: options.ref,\n stdoutOffset: options.stdoutOffset,\n stderrOffset: options.stderrOffset,\n signal: options.abortSignal,\n }),\n );\n if (process == null) return null;\n const exit = process.wait().then((result) => unwrap(result));\n exit.catch(() => undefined);\n return {\n ref: options.ref,\n // The session keeps the whole log, so output resumes where asked.\n stdoutOffset: options.stdoutOffset,\n stderrOffset: options.stderrOffset,\n stdout: process.stdout,\n stderr: process.stderr,\n wait: () => exit,\n kill: async () => {\n unwrap(await process.kill());\n },\n };\n };\n\n const portEndpoint = async (options: {\n port: number;\n protocol?: PortProtocol;\n }): Promise<{ url: string; headers?: Record<string, string> }> => {\n const preview = unwrap(await client.previewUrl(args.sandboxId, options.port));\n const url =\n options.protocol === PortProtocol.Ws ? preview.url.replace(/^http/, 'ws') : preview.url;\n return { url, headers: { 'X-Daytona-Preview-Token': preview.token } };\n };\n\n const session: DaytonaSandboxSessionIface = {\n id: args.sandboxId,\n description: args.description,\n defaultWorkingDirectory: args.workingDirectory,\n ports: args.ports,\n capabilities: DAYTONA_CAPABILITIES,\n resolvePath,\n readFile: ({ path, abortSignal }) => readStream(path, abortSignal),\n readBinaryFile: async ({ path, abortSignal }) => {\n const stream = await readStream(path, abortSignal);\n return stream == null ? null : collect(stream);\n },\n readTextFile: async ({ path, startLine, endLine, abortSignal }) => {\n const stream = await readStream(path, abortSignal);\n if (stream == null) return null;\n if (startLine == null && endLine == null) {\n return new TextDecoder().decode(await collect(stream));\n }\n return readLineRange(stream, Math.max(1, startLine ?? 1), endLine ?? null);\n },\n writeFile: ({ path, content, abortSignal }) => writeContent(path, content, abortSignal),\n writeBinaryFile: ({ path, content, abortSignal }) => writeContent(path, content, abortSignal),\n writeTextFile: ({ path, content, abortSignal }) =>\n writeContent(path, encoder.encode(content), abortSignal),\n spawn: (options) => spawnProcess(options, false),\n attachProcess,\n run: async (options): Promise<SandboxRunResultIface> => {\n const process = await spawnProcess({ ...options, durable: false }, true);\n const [stdout, stderr, exit] = await Promise.all([\n collect(process.stdout),\n collect(process.stderr),\n process.wait(),\n ]);\n return {\n exitCode: exit.exitCode,\n stdout: new TextDecoder().decode(stdout),\n stderr: new TextDecoder().decode(stderr),\n };\n },\n stat: async ({ path, abortSignal }) => {\n const resolved = resolvePath(path);\n const info = unwrap(await toolbox.info({ path: resolved, signal: abortSignal }));\n return info == null ? null : toStat(resolved, info);\n },\n readDir: async ({ path, abortSignal }): Promise<DirEntryIface[]> => {\n const resolved = resolvePath(path);\n const entries = unwrap(await toolbox.list({ path: resolved, signal: abortSignal }));\n if (entries == null) throw fsError('ENOENT', `${resolved} does not exist`);\n return entries.map((entry) => ({\n name: entry.name,\n path: entry.path ?? resolvePosixPath(resolved, entry.name),\n type: entry.isDir ? SandboxEntryType.Directory : SandboxEntryType.File,\n size: entry.isDir ? null : entry.size,\n }));\n },\n removePath: async ({ path, recursive, force, abortSignal }) => {\n await args.beforeUse?.();\n const resolved = resolvePath(path);\n const removed = unwrap(\n await toolbox.remove({\n path: resolved,\n recursive: recursive === true,\n signal: abortSignal,\n }),\n );\n if (!removed && force !== true) throw fsError('ENOENT', `${resolved} does not exist`);\n },\n getPortEndpoint: portEndpoint,\n // A signed URL, usable without headers (a browser, a webhook) until it expires.\n getPortUrl: async (options) => {\n const url = unwrap(\n await client.signedPreviewUrl(args.sandboxId, options.port, SIGNED_PORT_URL_SECONDS),\n );\n return options.protocol === PortProtocol.Ws ? url.replace(/^http/, 'ws') : url;\n },\n setNetworkPolicy: async (policy) => {\n await args.beforeUse?.();\n const settings = networkSettingsFor((await args.platformEgress?.(policy)) ?? policy);\n unwrap(await client.updateNetworkSettings(args.sandboxId, settings));\n },\n stop: args.stop,\n destroy: args.destroy,\n };\n return { ...session, confinedFileReader: createConfinedFileReader(session) };\n};\n\nconst readOnlyRefusal = async (): Promise<never> => {\n throw new Error('this sandbox binding is read-only');\n};\n\nconst fileWriteRefusal = async (): Promise<never> => {\n throw new Error('this sandbox binding runs processes but does not write files');\n};\n\n// The view of a handle that a binding's access allows.\nexport const sessionForAccess = (\n session: DaytonaSandboxSessionIface,\n access: SandboxAccess,\n): DaytonaSandboxSessionIface => {\n const apply = session.setNetworkPolicy;\n const validated =\n apply == null\n ? session\n : {\n ...session,\n setNetworkPolicy: async (policy: NetworkPolicyIface) => {\n networkSettingsFor(policy);\n await apply(policy);\n },\n };\n\n if (access === SandboxAccess.Read) {\n const restricted: DaytonaSandboxSessionIface = {\n ...validated,\n capabilities: session.capabilities.filter(\n (capability) =>\n capability !== SandboxCapability.Egress &&\n capability !== SandboxCapability.DurableProcesses,\n ),\n writeFile: readOnlyRefusal,\n writeBinaryFile: readOnlyRefusal,\n writeTextFile: readOnlyRefusal,\n spawn: readOnlyRefusal,\n run: readOnlyRefusal,\n removePath: readOnlyRefusal,\n setNetworkPolicy: readOnlyRefusal,\n stop: readOnlyRefusal,\n destroy: readOnlyRefusal,\n };\n delete restricted.egress;\n delete restricted.attachProcess;\n return restricted;\n }\n if (access === SandboxAccess.Execute) {\n const restricted: DaytonaSandboxSessionIface = {\n ...validated,\n capabilities: session.capabilities.filter(\n (capability) => capability !== SandboxCapability.Egress,\n ),\n writeFile: fileWriteRefusal,\n writeBinaryFile: fileWriteRefusal,\n writeTextFile: fileWriteRefusal,\n removePath: fileWriteRefusal,\n stop: fileWriteRefusal,\n destroy: fileWriteRefusal,\n };\n delete restricted.egress;\n return restricted;\n }\n return validated;\n};\n"],
|
|
5
|
-
"mappings": "AAAA
|
|
4
|
+
"sourcesContent": ["import {\n createConfinedFileReader,\n NetworkPolicy,\n PortProtocol,\n SandboxCapability,\n SandboxEntryType,\n type DirEntryIface,\n type NetworkPolicyIface,\n type NetworkSandboxSessionIface,\n type SandboxAttachedProcessIface,\n type SandboxAttachProcessOptionsIface,\n type SandboxProcessIface,\n type SandboxProcessOptionsIface,\n type SandboxRunResultIface,\n type StatIface,\n} from '@finalai/agent-provider/sandbox';\nimport {\n type DaytonaClientIface,\n type DaytonaFileInfoIface,\n type DaytonaNetworkSettingsIface,\n type DaytonaProcessIface,\n type DaytonaResultIface,\n type DaytonaToolboxIface,\n} from \"../client/index.mjs\";\n\n// NetworkSandboxSessionIface over one Daytona sandbox: files through the\n// toolbox's file endpoints, processes through its process sessions, ports\n// through Daytona preview URLs and the egress policy through the sandbox's\n// network settings.\n\nexport interface DaytonaSandboxSessionIface extends NetworkSandboxSessionIface {\n readonly capabilities: readonly SandboxCapability[];\n}\n\nexport interface DaytonaApiErrorIface extends Error {\n code: string;\n status: number | null;\n}\n\nexport const daytonaApiError = (result: {\n error: string;\n statusCode?: number;\n details?: Array<{ message?: string }>;\n}): DaytonaApiErrorIface =>\n Object.assign(new Error(result.details?.[0]?.message ?? result.error), {\n name: 'DaytonaApiError',\n code: `daytona_${result.error}`,\n status: result.statusCode ?? null,\n });\n\nexport const unwrap = <T>(result: DaytonaResultIface<T>): T => {\n if (!result.ok) throw daytonaApiError(result);\n return result.data;\n};\n\nconst fsError = (code: string, message: string): Error =>\n Object.assign(new Error(`${code}: ${message}`), { code });\n\n// Exit status of a process stopped by its timeout, as `timeout(1)` reports it.\nconst TIMED_OUT_EXIT_CODE = 124;\nconst SIGNED_PORT_URL_SECONDS = 60 * 60;\n\nconst CIDR = /^\\d{1,3}(?:\\.\\d{1,3}){3}(?:\\/\\d{1,2})?$/;\nexport const isCidr = (entry: string): boolean => CIDR.test(entry);\nconst canonicalCidr = (entry: string): string => {\n const [ip = '', suffix] = entry.split('/');\n const octets = ip.split('.').map(Number);\n const prefix = suffix == null ? 32 : Number(suffix);\n if (octets.some((value) => value > 255) || prefix > 32)\n throw fsError('unsupported_network_policy', 'Invalid IPv4 CIDR in Daytona allowlist');\n const address = octets.reduce((value, octet) => value * 256 + octet, 0);\n const blockSize = 2 ** (32 - prefix);\n const network = address - (address % blockSize);\n return (\n [24, 16, 8, 0].map((shift) => Math.floor(network / 2 ** shift) % 256).join('.') + '/' + prefix\n );\n};\n\n// The contract's egress policy as Daytona network settings: CIDR blocks go to\n// the network allow list, everything else to the domain allow list.\nexport const networkSettingsFor = (policy: NetworkPolicyIface): DaytonaNetworkSettingsIface => {\n if (policy.mode === NetworkPolicy.AllowAll)\n return { networkBlockAll: false, domainAllowList: '', networkAllowList: '' };\n const allow = policy.mode === NetworkPolicy.Allowlist ? (policy.allow ?? []) : [];\n if (allow.length === 0)\n return { networkBlockAll: true, domainAllowList: '', networkAllowList: '' };\n const cidrs = allow.filter((entry) => CIDR.test(entry));\n const domains = allow.filter((entry) => !CIDR.test(entry));\n if (cidrs.length > 0 && domains.length > 0)\n throw fsError(\n 'unsupported_network_policy',\n 'Daytona allowlists must use domains or IPv4 CIDRs; mixed allowlists are unsupported',\n );\n const settings: DaytonaNetworkSettingsIface = {};\n if (cidrs.length > 0) {\n settings.networkBlockAll = false;\n settings.networkAllowList = [...new Set(cidrs.map(canonicalCidr))].join(',');\n // Daytona requires an explicit empty string to clear the other stored allowlist.\n settings.domainAllowList = '';\n }\n if (domains.length > 0) {\n settings.networkBlockAll = false;\n settings.domainAllowList = [...new Set(domains)].join(',');\n settings.networkAllowList = '';\n }\n return settings;\n};\n\nexport const normalizePosixPath = (path: string): string => {\n const parts: string[] = [];\n for (const part of path.split('/')) {\n if (part === '' || part === '.') continue;\n if (part === '..') parts.pop();\n else parts.push(part);\n }\n return `/${parts.join('/')}`;\n};\n\nexport const resolvePosixPath = (cwd: string, path: string): string =>\n normalizePosixPath(path.startsWith('/') ? path : `${cwd}/${path}`);\n\nconst encoder = new TextEncoder();\n\nconst collect = async (stream: ReadableStream<Uint8Array>): Promise<Uint8Array> => {\n const chunks: Uint8Array[] = [];\n let total = 0;\n for await (const chunk of stream) {\n chunks.push(chunk);\n total += chunk.byteLength;\n }\n const out = new Uint8Array(total);\n let offset = 0;\n for (const chunk of chunks) {\n out.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out;\n};\n\n// Lines keep their terminators, so a range reads back exactly as stored.\nconst readLineRange = async (\n stream: ReadableStream<Uint8Array>,\n startLine: number,\n endLine: number | null,\n): Promise<string> => {\n const decoder = new TextDecoder();\n const reader = stream.getReader();\n const lines: string[] = [];\n let partial = '';\n let lineNumber = 1;\n const take = (line: string): boolean => {\n if (lineNumber >= startLine && (endLine == null || lineNumber <= endLine)) lines.push(line);\n lineNumber += 1;\n return endLine != null && lineNumber > endLine;\n };\n for (;;) {\n const next = await reader.read();\n partial += next.done ? decoder.decode() : decoder.decode(next.value, { stream: true });\n let newline = partial.indexOf('\\n');\n while (newline >= 0) {\n if (take(partial.slice(0, newline + 1))) {\n await reader.cancel();\n return lines.join('');\n }\n partial = partial.slice(newline + 1);\n newline = partial.indexOf('\\n');\n }\n if (next.done) break;\n }\n if (partial !== '') take(partial);\n return lines.join('');\n};\n\nconst toStat = (path: string, info: DaytonaFileInfoIface): StatIface => ({\n path,\n type: info.isDir ? SandboxEntryType.Directory : SandboxEntryType.File,\n size: info.size,\n modifiedAt: info.modifiedAt,\n mode: info.mode,\n});\n\nexport interface CreateDaytonaSessionArgsIface {\n client: DaytonaClientIface;\n toolbox: DaytonaToolboxIface;\n // Daytona's id for the sandbox (previews, network settings).\n sandboxId: string;\n description: string;\n workingDirectory: string;\n ports: readonly number[];\n // Every process's environment (injected variables), under per-call env;\n // read again for every process.\n baseEnv: () => Promise<Record<string, string>>;\n // Adds the platform's egress hosts to a policy set on this sandbox.\n platformEgress?: (policy: NetworkPolicyIface) => Promise<NetworkPolicyIface>;\n stop: () => Promise<void>;\n destroy: () => Promise<void>;\n beforeUse?: () => Promise<void>;\n}\n\nexport const DAYTONA_FEATURES: readonly SandboxCapability[] = [\n SandboxCapability.Files,\n SandboxCapability.Process,\n SandboxCapability.DurableProcesses,\n SandboxCapability.Ports,\n SandboxCapability.NetworkPolicy,\n];\n\nexport const createDaytonaSession = (\n args: CreateDaytonaSessionArgsIface,\n): DaytonaSandboxSessionIface => {\n const { client, toolbox } = args;\n const resolvePath = (path: string): string => resolvePosixPath(args.workingDirectory, path);\n\n const readStream = async (\n path: string,\n signal: AbortSignal | undefined,\n ): Promise<ReadableStream<Uint8Array> | null> =>\n unwrap(await toolbox.download({ path: resolvePath(path), signal }));\n\n const writeContent = async (\n path: string,\n content: ReadableStream<Uint8Array> | Uint8Array,\n signal: AbortSignal | undefined,\n ): Promise<void> => {\n await args.beforeUse?.();\n const resolved = resolvePath(path);\n const parent = resolved.slice(0, resolved.lastIndexOf('/')) || '/';\n unwrap(await toolbox.createFolder({ path: parent, signal }));\n unwrap(await toolbox.upload({ path: resolved, content, signal }));\n };\n\n const spawnProcess = async (\n options: SandboxProcessOptionsIface,\n closeStdin: boolean,\n ): Promise<SandboxProcessIface> => {\n await args.beforeUse?.();\n const input = options.stdin;\n const stdin = input != null || !closeStdin;\n const durable = options.durable === true;\n const process: DaytonaProcessIface = unwrap(\n await toolbox.spawn({\n command: options.command,\n args: options.args ?? [],\n shell: options.shell === true,\n cwd: resolvePath(options.cwd ?? args.workingDirectory),\n env: { ...(await args.baseEnv()), ...options.env },\n stdin,\n signal: options.abortSignal,\n // A durable process's timeout runs in the sandbox, not in this handle.\n ...(durable ? { durable, timeoutMs: options.timeoutMs ?? null } : {}),\n }),\n );\n let timedOut = false;\n const timer =\n options.timeoutMs == null || durable\n ? null\n : setTimeout(() => {\n timedOut = true;\n void process.kill();\n }, options.timeoutMs);\n const exit = process.wait().then((result) => {\n if (timer != null) clearTimeout(timer);\n const { exitCode } = unwrap(result);\n return { exitCode: timedOut ? TIMED_OUT_EXIT_CODE : exitCode };\n });\n // Avoid an unhandled rejection when the caller only reads the streams.\n exit.catch(() => undefined);\n\n const write = async (\n data: Uint8Array | string,\n writeOptions?: { end?: boolean },\n ): Promise<void> => {\n // A detached durable handle neither writes to nor closes the process's stdin.\n if (durable) options.abortSignal?.throwIfAborted();\n await args.beforeUse?.();\n const bytes = data instanceof Uint8Array ? data : encoder.encode(data);\n if (bytes.byteLength > 0) unwrap(await process.write(bytes));\n if (writeOptions?.end === true) unwrap(await process.closeStdin());\n };\n if (input instanceof ReadableStream) {\n void (async () => {\n for await (const chunk of input) await write(chunk);\n await write(new Uint8Array(), { end: true });\n })().catch(async () => {\n // A durable process outlives a stdin that failed with its handle.\n if (!durable) await process.kill();\n });\n } else if (input != null) {\n try {\n await write(input, { end: true });\n } catch (error) {\n // An abort detaches a durable process rather than killing it.\n if (!durable || options.abortSignal?.aborted !== true) await process.kill();\n throw error;\n }\n }\n return {\n pid: process.id,\n ref: process.ref,\n stdout: process.stdout,\n stderr: process.stderr,\n write,\n wait: () => exit,\n // Daytona ends a process by ending its session, whatever the signal.\n kill: async () => {\n unwrap(await process.kill());\n },\n };\n };\n\n const attachProcess = async (\n options: SandboxAttachProcessOptionsIface,\n ): Promise<SandboxAttachedProcessIface | null> => {\n await args.beforeUse?.();\n const process = unwrap(\n await toolbox.attach({\n ref: options.ref,\n stdoutOffset: options.stdoutOffset,\n stderrOffset: options.stderrOffset,\n signal: options.abortSignal,\n }),\n );\n if (process == null) return null;\n const exit = process.wait().then((result) => unwrap(result));\n exit.catch(() => undefined);\n return {\n ref: options.ref,\n // The session keeps the whole log, so output resumes where asked.\n stdoutOffset: options.stdoutOffset,\n stderrOffset: options.stderrOffset,\n stdout: process.stdout,\n stderr: process.stderr,\n wait: () => exit,\n kill: async () => {\n unwrap(await process.kill());\n },\n };\n };\n\n const portEndpoint = async (options: {\n port: number;\n protocol?: PortProtocol;\n }): Promise<{ url: string; headers?: Record<string, string> }> => {\n const preview = unwrap(await client.previewUrl(args.sandboxId, options.port));\n const url =\n options.protocol === PortProtocol.Ws ? preview.url.replace(/^http/, 'ws') : preview.url;\n return { url, headers: { 'X-Daytona-Preview-Token': preview.token } };\n };\n\n const session: DaytonaSandboxSessionIface = {\n id: args.sandboxId,\n description: args.description,\n defaultWorkingDirectory: args.workingDirectory,\n ports: args.ports,\n capabilities: DAYTONA_FEATURES,\n resolvePath,\n readFile: ({ path, abortSignal }) => readStream(path, abortSignal),\n readBinaryFile: async ({ path, abortSignal }) => {\n const stream = await readStream(path, abortSignal);\n return stream == null ? null : collect(stream);\n },\n readTextFile: async ({ path, startLine, endLine, abortSignal }) => {\n const stream = await readStream(path, abortSignal);\n if (stream == null) return null;\n if (startLine == null && endLine == null) {\n return new TextDecoder().decode(await collect(stream));\n }\n return readLineRange(stream, Math.max(1, startLine ?? 1), endLine ?? null);\n },\n writeFile: ({ path, content, abortSignal }) => writeContent(path, content, abortSignal),\n writeBinaryFile: ({ path, content, abortSignal }) => writeContent(path, content, abortSignal),\n writeTextFile: ({ path, content, abortSignal }) =>\n writeContent(path, encoder.encode(content), abortSignal),\n spawn: (options) => spawnProcess(options, false),\n attachProcess,\n run: async (options): Promise<SandboxRunResultIface> => {\n const process = await spawnProcess({ ...options, durable: false }, true);\n const [stdout, stderr, exit] = await Promise.all([\n collect(process.stdout),\n collect(process.stderr),\n process.wait(),\n ]);\n return {\n exitCode: exit.exitCode,\n stdout: new TextDecoder().decode(stdout),\n stderr: new TextDecoder().decode(stderr),\n };\n },\n stat: async ({ path, abortSignal }) => {\n const resolved = resolvePath(path);\n const info = unwrap(await toolbox.info({ path: resolved, signal: abortSignal }));\n return info == null ? null : toStat(resolved, info);\n },\n readDir: async ({ path, abortSignal }): Promise<DirEntryIface[]> => {\n const resolved = resolvePath(path);\n const entries = unwrap(await toolbox.list({ path: resolved, signal: abortSignal }));\n if (entries == null) throw fsError('ENOENT', `${resolved} does not exist`);\n return entries.map((entry) => ({\n name: entry.name,\n path: entry.path ?? resolvePosixPath(resolved, entry.name),\n type: entry.isDir ? SandboxEntryType.Directory : SandboxEntryType.File,\n size: entry.isDir ? null : entry.size,\n }));\n },\n removePath: async ({ path, recursive, force, abortSignal }) => {\n await args.beforeUse?.();\n const resolved = resolvePath(path);\n const removed = unwrap(\n await toolbox.remove({\n path: resolved,\n recursive: recursive === true,\n signal: abortSignal,\n }),\n );\n if (!removed && force !== true) throw fsError('ENOENT', `${resolved} does not exist`);\n },\n getPortEndpoint: portEndpoint,\n // A signed URL, usable without headers (a browser, a webhook) until it expires.\n getPortUrl: async (options) => {\n const url = unwrap(\n await client.signedPreviewUrl(args.sandboxId, options.port, SIGNED_PORT_URL_SECONDS),\n );\n return options.protocol === PortProtocol.Ws ? url.replace(/^http/, 'ws') : url;\n },\n setNetworkPolicy: async (policy) => {\n await args.beforeUse?.();\n const settings = networkSettingsFor((await args.platformEgress?.(policy)) ?? policy);\n unwrap(await client.updateNetworkSettings(args.sandboxId, settings));\n },\n stop: args.stop,\n destroy: args.destroy,\n };\n return { ...session, confinedFileReader: createConfinedFileReader(session) };\n};\n\n// Validates a policy against what Daytona can express before anything wrapping\n// the session (a networking extension) records it.\nexport const withNetworkPolicyValidation = (\n session: DaytonaSandboxSessionIface,\n): DaytonaSandboxSessionIface => {\n const apply = session.setNetworkPolicy;\n if (apply == null) return session;\n return {\n ...session,\n setNetworkPolicy: async (policy: NetworkPolicyIface) => {\n networkSettingsFor(policy);\n await apply(policy);\n },\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAUK;AACP;AAAA,OAOO;AAgBA,MAAM,kBAAkB,CAAC,WAK9B,OAAO,OAAO,IAAI,MAAM,OAAO,UAAU,CAAC,GAAG,WAAW,OAAO,KAAK,GAAG;AAAA,EACrE,MAAM;AAAA,EACN,MAAM,WAAW,OAAO,KAAK;AAAA,EAC7B,QAAQ,OAAO,cAAc;AAC/B,CAAC;AAEI,MAAM,SAAS,CAAI,WAAqC;AAC7D,MAAI,CAAC,OAAO,GAAI,OAAM,gBAAgB,MAAM;AAC5C,SAAO,OAAO;AAChB;AAEA,MAAM,UAAU,CAAC,MAAc,YA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C;AAAA,IACrE;AAAA,IACA,MAAM,KAAK;AAAA,IACX,SAAS,KAAK;AAAA,EAChB;AACA,SAAO,EAAE,GAAG,SAAS,oBAAoB,yBAAyB,OAAO,EAAE;AAC7E;AAIO,MAAM,8BAA8B,CACzC,YAC+B;AAC/B,QAAM,QAAQ,QAAQ;AACtB,MAAI,SAAS,KAAM,QAAO;AAC1B,SAAO;AAAA,IACL,GAAG;AAAA,IACH,kBAAkB,OAAO,WAA+B;AACtD,yBAAmB,MAAM;AACzB,YAAM,MAAM,MAAM;AAAA,IACpB;AAAA,EACF;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finalai/daytona-agent-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "Daytona's provider package: the daytona sandbox over Daytona's public API, implementing only the public sandbox provider contract.",
|
|
5
|
+
"description": "Daytona's provider package: the daytona sandbox provider over Daytona's public API, implementing only the public sandbox provider contract.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
9
|
"README.md",
|
|
10
10
|
"LICENSE",
|
|
11
11
|
"NOTICE",
|
|
12
|
-
"HOSTING.md"
|
|
13
|
-
"THIRD_PARTY_NOTICES.md"
|
|
12
|
+
"HOSTING.md"
|
|
14
13
|
],
|
|
15
14
|
"type": "module",
|
|
16
15
|
"sideEffects": false,
|
|
@@ -37,7 +36,8 @@
|
|
|
37
36
|
"registry": "https://registry.npmjs.org/"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@finalai/agent-
|
|
39
|
+
"@finalai/agent-protocol": "0.10.0",
|
|
40
|
+
"@finalai/agent-provider": "0.11.0",
|
|
41
41
|
"zod": "4.6.6"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|