@lunora/container 1.0.0-alpha.9 → 1.0.0-alpha.90
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/README.md +24 -5
- package/dist/bridge.d.mts +43 -33
- package/dist/bridge.d.ts +43 -33
- package/dist/bridge.mjs +1 -79
- package/dist/do/index.d.mts +354 -78
- package/dist/do/index.d.ts +354 -78
- package/dist/do/index.mjs +1 -321
- package/dist/index.d.mts +585 -148
- package/dist/index.d.ts +585 -148
- package/dist/index.mjs +1 -2
- package/dist/otel.d.mts +217 -0
- package/dist/otel.d.ts +217 -0
- package/dist/otel.mjs +1 -0
- package/dist/packem_shared/CONTAINER_EXEC_PATH-7Hcd6-zs.mjs +1 -0
- package/dist/packem_shared/CUSTOM_INSTANCE_MIN_MEMORY_MIB_PER_VCPU-D8Hy9Rxv.mjs +1 -0
- package/dist/packem_shared/ContainerProxy-CfXjS6ZI.mjs +27 -0
- package/dist/packem_shared/DURABLE_OBJECT_POLICY_FORBIDDEN_KEYS-gYi8RBUO.mjs +1 -0
- package/dist/packem_shared/LunoraSandboxContainer-DPnhJUu1.mjs +1 -0
- package/dist/packem_shared/abort-deadline-jwbW9Ala.mjs +1 -0
- package/dist/packem_shared/createContainerContext-p6QxWjsm.mjs +1 -0
- package/dist/packem_shared/exec-BYLW70sR.mjs +1 -0
- package/dist/packem_shared/jurisdiction-DtE9s70w.mjs +1 -0
- package/dist/packem_shared/jurisdiction.d-BwpauCoI.d.mts +471 -0
- package/dist/packem_shared/jurisdiction.d-BwpauCoI.d.ts +471 -0
- package/dist/packem_shared/sampling-D21rpu_s.mjs +1 -0
- package/dist/packem_shared/sandbox-types.d-DXlHnsEg.d.mts +110 -0
- package/dist/packem_shared/sandbox-types.d-DXlHnsEg.d.ts +110 -0
- package/dist/sandbox/index.d.mts +66 -0
- package/dist/sandbox/index.d.ts +66 -0
- package/dist/sandbox/index.mjs +1 -0
- package/package.json +12 -2
- package/dist/packem_shared/ContainerProxy-DWqUX_re.mjs +0 -1474
- package/dist/packem_shared/containerBindingName-BiTrAF1J.mjs +0 -224
- package/dist/packem_shared/createContainerContext-CIVzsY5m.mjs +0 -220
- package/dist/packem_shared/jurisdiction-CuPNcLDt.mjs +0 -13
- package/dist/packem_shared/jurisdiction.d-TwTGkgTg.d.mts +0 -266
- package/dist/packem_shared/jurisdiction.d-TwTGkgTg.d.ts +0 -266
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { SandboxDirectoryEntry, SandboxFileStat, DirectoryBackupRecord, S3MountInspection } from '@cloudflare/sandbox';
|
|
2
|
+
/** Options every file operation accepts. */
|
|
3
|
+
interface ContainerFileOptions {
|
|
4
|
+
/** Absolute directory a relative path is joined onto. */
|
|
5
|
+
cwd?: string;
|
|
6
|
+
/** Numeric `uid:gid` that opens the file. */
|
|
7
|
+
user?: string;
|
|
8
|
+
}
|
|
9
|
+
/** What `handle.files.writeFile` accepts. A stream is written as it arrives. */
|
|
10
|
+
type ContainerFileContent = ArrayBuffer | ArrayBufferView | ReadableStream<Uint8Array> | string;
|
|
11
|
+
/**
|
|
12
|
+
* Structured file operations on the instance's own disk (`handle.files`),
|
|
13
|
+
* through `@cloudflare/sandbox`'s `Files`. A filesystem failure rejects with a
|
|
14
|
+
* `LunoraError` whose `data.errno` is the Linux code (`ENOENT`, `EACCES`, …).
|
|
15
|
+
*/
|
|
16
|
+
interface ContainerFiles {
|
|
17
|
+
/** Create a directory; `recursive` creates parents and accepts an existing one. */
|
|
18
|
+
mkdir: (path: string, options?: ContainerFileOptions & {
|
|
19
|
+
recursive?: boolean;
|
|
20
|
+
}) => Promise<void>;
|
|
21
|
+
/** List a directory's immediate entries, without following symlinked entries. */
|
|
22
|
+
readDirectory: (path: string, options?: ContainerFileOptions) => Promise<SandboxDirectoryEntry[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Stream a file out of the container. The body applies backpressure to the
|
|
25
|
+
* read. Read the body to the end or cancel it: the container is counted in
|
|
26
|
+
* flight until then, so an abandoned body keeps it from sleeping.
|
|
27
|
+
*/
|
|
28
|
+
readFile: (path: string, options?: ContainerFileOptions) => Promise<Response>;
|
|
29
|
+
/** Remove a file or symlink; `recursive` removes a directory tree, `force` ignores a missing target. */
|
|
30
|
+
remove: (path: string, options?: ContainerFileOptions & {
|
|
31
|
+
force?: boolean;
|
|
32
|
+
recursive?: boolean;
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
/** Rename within one filesystem (`EXDEV` across filesystems; there is no copy fallback). */
|
|
35
|
+
rename: (source: string, destination: string, options?: ContainerFileOptions) => Promise<void>;
|
|
36
|
+
/** Metadata for a path, following a final symlink. */
|
|
37
|
+
stat: (path: string, options?: ContainerFileOptions) => Promise<SandboxFileStat>;
|
|
38
|
+
/** Create or truncate a file and write `content` into it. */
|
|
39
|
+
writeFile: (path: string, content: ContainerFileContent, options?: ContainerFileOptions) => Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/** Options for `handle.backup()`. */
|
|
42
|
+
interface ContainerBackupOptions {
|
|
43
|
+
/** gitignore-syntax patterns, relative to the directory, to leave out. */
|
|
44
|
+
exclude?: ReadonlyArray<string>;
|
|
45
|
+
/** Also apply `.gitignore` files inside the directory and `.git/info/exclude`. */
|
|
46
|
+
gitignore?: boolean;
|
|
47
|
+
/** A label stored with the backup. */
|
|
48
|
+
name?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Credentials for an S3-compatible bucket mount, by **name**: each value is the
|
|
52
|
+
* name of a Worker secret (`wrangler secret put`) the container Durable Object
|
|
53
|
+
* reads at mount time. The keys themselves never appear in source, and the
|
|
54
|
+
* Worker signs every storage request, so they never enter the container either.
|
|
55
|
+
*/
|
|
56
|
+
interface ContainerMountCredentials {
|
|
57
|
+
/** Worker secret holding the access key id. */
|
|
58
|
+
accessKeyIdSecret: string;
|
|
59
|
+
/** Worker secret holding the secret access key. */
|
|
60
|
+
secretAccessKeySecret: string;
|
|
61
|
+
/** Worker secret holding a session token, for temporary credentials. */
|
|
62
|
+
sessionTokenSecret?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* An S3-compatible bucket (R2, S3, GCS) to mount at `path` with
|
|
66
|
+
* `handle.mount()`. For R2 the endpoint is
|
|
67
|
+
* `https://<account-id>.r2.cloudflarestorage.com` with region `"auto"`, and the
|
|
68
|
+
* credentials are an R2 API token's S3 keys — an R2 bucket binding is not used.
|
|
69
|
+
*/
|
|
70
|
+
interface ContainerMountRequest {
|
|
71
|
+
access: "read-only" | "read-write";
|
|
72
|
+
bucket: string;
|
|
73
|
+
credentials: ContainerMountCredentials;
|
|
74
|
+
endpoint: string;
|
|
75
|
+
/** Mount only this key prefix. A non-empty prefix ends in `/`. */
|
|
76
|
+
keyPrefix?: string;
|
|
77
|
+
/** Absolute path inside the container to mount at. */
|
|
78
|
+
path: string;
|
|
79
|
+
region: string;
|
|
80
|
+
/** Extra s3fs options, passed through as-is. */
|
|
81
|
+
s3fsOptions?: Readonly<Record<string, boolean | number | string>>;
|
|
82
|
+
}
|
|
83
|
+
/** The sandbox operations on a named instance of a `defineContainer({ sandbox: true })` container. */
|
|
84
|
+
interface ContainerSandboxControls {
|
|
85
|
+
/**
|
|
86
|
+
* Save `directory` to the R2 bucket in the definition's `backups` and return its
|
|
87
|
+
* record — plain data to store and pass to `restore` later, here or on
|
|
88
|
+
* another instance, even one on a newer image. Pause writers in it first.
|
|
89
|
+
*/
|
|
90
|
+
backup: (directory: string, options?: ContainerBackupOptions) => Promise<DirectoryBackupRecord>;
|
|
91
|
+
/** Delete a backup's object. Deleting one that is already gone succeeds. */
|
|
92
|
+
deleteBackup: (backup: DirectoryBackupRecord) => Promise<void>;
|
|
93
|
+
/** Structured file operations on the instance's disk. */
|
|
94
|
+
files: ContainerFiles;
|
|
95
|
+
/** Report a mount path's state without changing it. */
|
|
96
|
+
inspectMount: (path: string) => Promise<S3MountInspection>;
|
|
97
|
+
/** Mount an S3-compatible bucket at `request.path`. Mounting the same settings again reuses the mount. */
|
|
98
|
+
mount: (request: ContainerMountRequest) => Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Replace `options.directory` (default: the directory it was taken from) with the
|
|
101
|
+
* backup's contents. The target is swapped in only after the download is
|
|
102
|
+
* verified; a rejection means it was not replaced.
|
|
103
|
+
*/
|
|
104
|
+
restore: (backup: DirectoryBackupRecord, options?: {
|
|
105
|
+
directory?: string;
|
|
106
|
+
}) => Promise<void>;
|
|
107
|
+
/** Stop access to a mount and unmount it. Never force-unmounts a busy path. */
|
|
108
|
+
unmount: (path: string) => Promise<void>;
|
|
109
|
+
}
|
|
110
|
+
export { ContainerFileOptions as C, ContainerFileContent as a, ContainerBackupOptions as b, ContainerMountRequest as c, ContainerSandboxControls as d, ContainerFiles as e, ContainerMountCredentials as f };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { SandboxFileStat, SandboxDirectoryEntry, DirectoryBackupRecord, S3MountInspection } from '@cloudflare/sandbox';
|
|
2
|
+
export { DirectoryBackupGateway, S3Gateway } from '@cloudflare/sandbox';
|
|
3
|
+
import { LunoraContainer } from "../do/index.mjs";
|
|
4
|
+
import { C as ContainerFileOptions, a as ContainerFileContent, b as ContainerBackupOptions, c as ContainerMountRequest } from "../packem_shared/sandbox-types.d-DXlHnsEg.mjs";
|
|
5
|
+
import { C as ContainerDefinition } from "../packem_shared/jurisdiction.d-BwpauCoI.mjs";
|
|
6
|
+
import 'cloudflare:workers';
|
|
7
|
+
type DurableObjectContext = ConstructorParameters<typeof LunoraContainer>[0];
|
|
8
|
+
declare class LunoraSandboxContainer<Env = unknown> extends LunoraContainer<Env> {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(context: DurableObjectContext, env: Env, definition: ContainerDefinition, exportName?: string, jurisdiction?: ConstructorParameters<typeof LunoraContainer>[4]);
|
|
11
|
+
lunoraReadFile(path: string, options?: ContainerFileOptions): Promise<Response>;
|
|
12
|
+
lunoraWriteFile(path: string, content: ContainerFileContent, options?: ContainerFileOptions): Promise<void>;
|
|
13
|
+
lunoraStat(path: string, options?: ContainerFileOptions): Promise<SandboxFileStat>;
|
|
14
|
+
lunoraReadDirectory(path: string, options?: ContainerFileOptions): Promise<SandboxDirectoryEntry[]>;
|
|
15
|
+
lunoraMkdir(path: string, options?: ContainerFileOptions & {
|
|
16
|
+
recursive?: boolean;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
lunoraRename(source: string, destination: string, options?: ContainerFileOptions): Promise<void>;
|
|
19
|
+
lunoraRemove(path: string, options?: ContainerFileOptions & {
|
|
20
|
+
force?: boolean;
|
|
21
|
+
recursive?: boolean;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
lunoraBackup(directory: string, options?: ContainerBackupOptions): Promise<DirectoryBackupRecord>;
|
|
24
|
+
lunoraRestore(backup: DirectoryBackupRecord, options?: {
|
|
25
|
+
directory?: string;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
/** Needs no running container — it only deletes the object. */
|
|
28
|
+
lunoraDeleteBackup(backup: DirectoryBackupRecord): Promise<void>;
|
|
29
|
+
lunoraMount(request: ContainerMountRequest): Promise<void>;
|
|
30
|
+
lunoraInspectMount(path: string): Promise<S3MountInspection>;
|
|
31
|
+
lunoraUnmount(path: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Route backup traffic to its gateway before the base installs the egress
|
|
34
|
+
* policy's catch-all, which takes every hostname registered after it.
|
|
35
|
+
* Without an egress policy there is no catch-all, and each backup or
|
|
36
|
+
* restore registers its own route when it runs.
|
|
37
|
+
*/
|
|
38
|
+
protected override beforeContainerStart(): Promise<void>;
|
|
39
|
+
/** Run one helper operation on the running container, translating sandbox errors. */
|
|
40
|
+
private withContainer;
|
|
41
|
+
private files;
|
|
42
|
+
/** One `DirectoryBackup` per instance: it runs one operation at a time per container, which only holds if every call shares it. */
|
|
43
|
+
private backups;
|
|
44
|
+
private mounts;
|
|
45
|
+
/** A Worker entrypoint from `ctx.exports`, with the fix when the worker does not export it. */
|
|
46
|
+
private workerExport;
|
|
47
|
+
/** Resolve a mount's credentials from the Worker secrets they name. */
|
|
48
|
+
private mountCredentials;
|
|
49
|
+
private label;
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
/**
|
|
53
|
+
* `@lunora/container/sandbox` — the workerd-only half of the Sandbox SDK
|
|
54
|
+
* helpers (`@cloudflare/sandbox`) a `defineContainer({ sandbox: true })`
|
|
55
|
+
* container uses. A separate subpath from `/do`, so an app that never opts in
|
|
56
|
+
* never loads `@cloudflare/sandbox` (or the `zod` it depends on).
|
|
57
|
+
*
|
|
58
|
+
* `LunoraSandboxContainer` is the base class codegen extends for a `sandbox:
|
|
59
|
+
* true` container: `LunoraContainer` plus the file, backup and bucket-mount
|
|
60
|
+
* RPCs the named-instance handle calls. `DirectoryBackupGateway` and
|
|
61
|
+
* `S3Gateway` are the `WorkerEntrypoint`s the backup and mount helpers route
|
|
62
|
+
* the container's storage traffic through (reached as `ctx.exports.<Name>`),
|
|
63
|
+
* so the deployed worker must export both; the generated
|
|
64
|
+
* `_generated/containers.ts` re-exports them from here.
|
|
65
|
+
*/
|
|
66
|
+
LunoraSandboxContainer };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { SandboxFileStat, SandboxDirectoryEntry, DirectoryBackupRecord, S3MountInspection } from '@cloudflare/sandbox';
|
|
2
|
+
export { DirectoryBackupGateway, S3Gateway } from '@cloudflare/sandbox';
|
|
3
|
+
import { LunoraContainer } from "../do/index.js";
|
|
4
|
+
import { C as ContainerFileOptions, a as ContainerFileContent, b as ContainerBackupOptions, c as ContainerMountRequest } from "../packem_shared/sandbox-types.d-DXlHnsEg.js";
|
|
5
|
+
import { C as ContainerDefinition } from "../packem_shared/jurisdiction.d-BwpauCoI.js";
|
|
6
|
+
import 'cloudflare:workers';
|
|
7
|
+
type DurableObjectContext = ConstructorParameters<typeof LunoraContainer>[0];
|
|
8
|
+
declare class LunoraSandboxContainer<Env = unknown> extends LunoraContainer<Env> {
|
|
9
|
+
#private;
|
|
10
|
+
constructor(context: DurableObjectContext, env: Env, definition: ContainerDefinition, exportName?: string, jurisdiction?: ConstructorParameters<typeof LunoraContainer>[4]);
|
|
11
|
+
lunoraReadFile(path: string, options?: ContainerFileOptions): Promise<Response>;
|
|
12
|
+
lunoraWriteFile(path: string, content: ContainerFileContent, options?: ContainerFileOptions): Promise<void>;
|
|
13
|
+
lunoraStat(path: string, options?: ContainerFileOptions): Promise<SandboxFileStat>;
|
|
14
|
+
lunoraReadDirectory(path: string, options?: ContainerFileOptions): Promise<SandboxDirectoryEntry[]>;
|
|
15
|
+
lunoraMkdir(path: string, options?: ContainerFileOptions & {
|
|
16
|
+
recursive?: boolean;
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
lunoraRename(source: string, destination: string, options?: ContainerFileOptions): Promise<void>;
|
|
19
|
+
lunoraRemove(path: string, options?: ContainerFileOptions & {
|
|
20
|
+
force?: boolean;
|
|
21
|
+
recursive?: boolean;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
lunoraBackup(directory: string, options?: ContainerBackupOptions): Promise<DirectoryBackupRecord>;
|
|
24
|
+
lunoraRestore(backup: DirectoryBackupRecord, options?: {
|
|
25
|
+
directory?: string;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
/** Needs no running container — it only deletes the object. */
|
|
28
|
+
lunoraDeleteBackup(backup: DirectoryBackupRecord): Promise<void>;
|
|
29
|
+
lunoraMount(request: ContainerMountRequest): Promise<void>;
|
|
30
|
+
lunoraInspectMount(path: string): Promise<S3MountInspection>;
|
|
31
|
+
lunoraUnmount(path: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Route backup traffic to its gateway before the base installs the egress
|
|
34
|
+
* policy's catch-all, which takes every hostname registered after it.
|
|
35
|
+
* Without an egress policy there is no catch-all, and each backup or
|
|
36
|
+
* restore registers its own route when it runs.
|
|
37
|
+
*/
|
|
38
|
+
protected override beforeContainerStart(): Promise<void>;
|
|
39
|
+
/** Run one helper operation on the running container, translating sandbox errors. */
|
|
40
|
+
private withContainer;
|
|
41
|
+
private files;
|
|
42
|
+
/** One `DirectoryBackup` per instance: it runs one operation at a time per container, which only holds if every call shares it. */
|
|
43
|
+
private backups;
|
|
44
|
+
private mounts;
|
|
45
|
+
/** A Worker entrypoint from `ctx.exports`, with the fix when the worker does not export it. */
|
|
46
|
+
private workerExport;
|
|
47
|
+
/** Resolve a mount's credentials from the Worker secrets they name. */
|
|
48
|
+
private mountCredentials;
|
|
49
|
+
private label;
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
/**
|
|
53
|
+
* `@lunora/container/sandbox` — the workerd-only half of the Sandbox SDK
|
|
54
|
+
* helpers (`@cloudflare/sandbox`) a `defineContainer({ sandbox: true })`
|
|
55
|
+
* container uses. A separate subpath from `/do`, so an app that never opts in
|
|
56
|
+
* never loads `@cloudflare/sandbox` (or the `zod` it depends on).
|
|
57
|
+
*
|
|
58
|
+
* `LunoraSandboxContainer` is the base class codegen extends for a `sandbox:
|
|
59
|
+
* true` container: `LunoraContainer` plus the file, backup and bucket-mount
|
|
60
|
+
* RPCs the named-instance handle calls. `DirectoryBackupGateway` and
|
|
61
|
+
* `S3Gateway` are the `WorkerEntrypoint`s the backup and mount helpers route
|
|
62
|
+
* the container's storage traffic through (reached as `ctx.exports.<Name>`),
|
|
63
|
+
* so the deployed worker must export both; the generated
|
|
64
|
+
* `_generated/containers.ts` re-exports them from here.
|
|
65
|
+
*/
|
|
66
|
+
LunoraSandboxContainer };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as r}from"../packem_shared/LunoraSandboxContainer-DPnhJUu1.mjs";import{DirectoryBackupGateway as t,S3Gateway as n}from"@cloudflare/sandbox";export{t as DirectoryBackupGateway,r as LunoraSandboxContainer,n as S3Gateway};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/container",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.90",
|
|
4
4
|
"description": "Cloudflare Containers for Lunora: defineContainer, generated Container DO classes, and the ctx.containers action surface",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,13 +46,23 @@
|
|
|
46
46
|
"types": "./dist/bridge.d.ts",
|
|
47
47
|
"import": "./dist/bridge.mjs"
|
|
48
48
|
},
|
|
49
|
+
"./otel": {
|
|
50
|
+
"types": "./dist/otel.d.ts",
|
|
51
|
+
"import": "./dist/otel.mjs"
|
|
52
|
+
},
|
|
53
|
+
"./sandbox": {
|
|
54
|
+
"types": "./dist/sandbox/index.d.ts",
|
|
55
|
+
"import": "./dist/sandbox/index.mjs"
|
|
56
|
+
},
|
|
49
57
|
"./package.json": "./package.json"
|
|
50
58
|
},
|
|
51
59
|
"publishConfig": {
|
|
52
60
|
"access": "public"
|
|
53
61
|
},
|
|
54
62
|
"dependencies": {
|
|
55
|
-
"@
|
|
63
|
+
"@cloudflare/sandbox": "1.0.0",
|
|
64
|
+
"@lunora/errors": ">=1.0.0-alpha.51 <2.0.0-0",
|
|
65
|
+
"@lunora/wire": "1.0.0-alpha.2"
|
|
56
66
|
},
|
|
57
67
|
"engines": {
|
|
58
68
|
"node": "^22.15.0 || >=24.11.0"
|