unfazed 0.9.0 → 0.10.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/CHANGELOG.md +28 -0
- package/README.md +57 -0
- package/dist/cli/eve-sandbox.d.ts +3 -0
- package/dist/cli/eve-sandbox.js +268 -0
- package/dist/cli/eve-sandbox.js.map +1 -0
- package/dist/cli/login.d.ts +1 -1
- package/dist/cli.js +11 -0
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/client.js.map +1 -1
- package/dist/eve-sandbox/daemon.d.ts +59 -0
- package/dist/eve-sandbox/daemon.js +664 -0
- package/dist/eve-sandbox/daemon.js.map +1 -0
- package/dist/eve-sandbox/index.d.ts +77 -0
- package/dist/eve-sandbox/index.js +352 -0
- package/dist/eve-sandbox/index.js.map +1 -0
- package/dist/eve-sandbox/protocol.d.ts +68 -0
- package/dist/eve-sandbox/protocol.js +22 -0
- package/dist/eve-sandbox/protocol.js.map +1 -0
- package/package.json +14 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eve-sandbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GAMxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,GAInB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAgClE,uFAAuF;AACvF,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC3C,kEAAkE;AAClE,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AACzC,MAAM,kBAAkB,GAAG,MAAM,C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AM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;YAC7C,CAAC;YACD,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,KAA2C,EAAE,EAAE,MAAM,EAAE;gBAC7E,MAAM,SAAS,GAAG,OAAO,KAAK,EAAE,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC1F,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YACzC,CAAC;YACD,oEAAoE;YACpE,0DAA0D;YAC1D,YAAY,EAAE,IAAa;SAC5B,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,yDAAyD;AACzD,MAAM,CAAC,MAAM,cAAc,GACzB,qBAAqB,CAAC,wBAAwB,CAAC,CAAC","sourcesContent":["/**\n * `unfazed/eve-sandbox` — eve sandboxes backed by an unfazed box.\n *\n * ```ts title=\"agent/sandbox.ts\"\n * import { defineSandbox } from \"eve/sandbox\";\n * import { UnfazedSandbox } from \"unfazed/eve-sandbox\";\n *\n * export const environment = UnfazedSandbox.environment({ box: \"my-sandbox-box\" });\n * export default defineSandbox(() => environment.open());\n * ```\n *\n * The box runs the sandbox daemon (`unfazed eve-sandbox setup` inside it).\n * Each eve session gets its own Unix user, home and workspace on the box; the\n * box keeps them across restarts and redeploys until the session ends. The\n * app authenticates with its workload identity token (audience: the box's\n * URL), so it needs no stored secret; the box's allow list names the apps it\n * serves.\n *\n * Requires the optional peer `eve` (0.90 or newer).\n */\n\nimport type { SandboxSession } from \"eve/sandbox\";\nimport {\n defineSandboxProvider,\n SandboxSessionGoneError,\n type SandboxConnection,\n type SandboxPrepareContext,\n type SandboxProvider,\n type SandboxProviderDefinition,\n type WithPrepareOption,\n} from \"eve/sandbox/provider\";\nimport { oidcToken } from \"../oidc.js\";\nimport {\n API_PREFIX,\n TEMPLATE_HOME,\n TEMPLATE_WORKSPACE,\n type ProcessEvent,\n type SessionInfo,\n type WireFile,\n} from \"./protocol.js\";\n\nexport { TEMPLATE_HOME, TEMPLATE_WORKSPACE } from \"./protocol.js\";\n\n/** Options of `UnfazedSandbox.environment()`. */\nexport interface UnfazedSandboxOptions {\n /** The box's alias; its URL is `https://<box>.unfz.to`. */\n readonly box?: string;\n /** The box's URL, instead of `box`. */\n readonly url?: string;\n /** Token audience; the box's URL by default. */\n readonly audience?: string;\n /** Supplies the bearer token; the app's workload identity token by default. */\n readonly token?: (audience: string) => Promise<string>;\n /** `fetch` used for every call (tests). */\n readonly fetch?: FetchLike;\n}\n\n/** The subset of `fetch` the client uses. */\nexport type FetchLike = (input: string, init: RequestInit) => Promise<Response>;\n\n/** The artifact `prepare()` ships with the deployment: the template files. */\nexport type UnfazedSandboxArtifact = {\n readonly v: 1;\n readonly files: readonly WireFile[];\n};\n\n/** What eve checkpoints for a session. */\nexport type UnfazedSandboxState = {\n readonly v: 1;\n readonly sessionId: string;\n readonly workspace: string;\n};\n\n/** Template files larger than this in total belong on the box, not in the artifact. */\nconst MAX_TEMPLATE_BYTES = 8 * 1024 * 1024;\n/** One `writeFiles` request carries at most this much content. */\nconst MAX_WRITE_BATCH = 16 * 1024 * 1024;\nconst CONTROL_TIMEOUT_MS = 60_000;\n\nexport class UnfazedSandboxError extends Error {\n constructor(\n readonly status: number,\n readonly code: string,\n message: string,\n ) {\n super(message);\n this.name = \"UnfazedSandboxError\";\n }\n}\n\nfunction boxUrl(options: UnfazedSandboxOptions): string {\n if (options.url) return options.url.replace(/\\/+$/, \"\");\n if (options.box) {\n if (!/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/.test(options.box)) throw new Error(`unfazed eve sandbox: invalid box alias \"${options.box}\"`);\n return `https://${options.box}.unfz.to`;\n }\n throw new Error(\"unfazed eve sandbox: pass { box } or { url }\");\n}\n\nconst toB64 = (bytes: Uint8Array) => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString(\"base64\");\n\n/** The daemon's HTTP API, one per environment. */\nexport class SandboxClient {\n private readonly doFetch: FetchLike;\n\n constructor(\n readonly base: string,\n private readonly bearer: () => Promise<string>,\n doFetch?: FetchLike,\n ) {\n this.doFetch = doFetch ?? ((input, init) => fetch(input, init));\n }\n\n async request(method: string, path: string, init: { body?: BodyInit; json?: unknown; signal?: AbortSignal; timeoutMs?: number } = {}): Promise<Response> {\n const headers: Record<string, string> = { authorization: `Bearer ${await this.bearer()}` };\n let body = init.body;\n if (init.json !== undefined) {\n headers[\"content-type\"] = \"application/json\";\n body = JSON.stringify(init.json);\n }\n const signals = [AbortSignal.timeout(init.timeoutMs ?? CONTROL_TIMEOUT_MS), ...(init.signal ? [init.signal] : [])];\n return await this.doFetch(`${this.base}${API_PREFIX}${path}`, { method, headers, body, signal: AbortSignal.any(signals) });\n }\n\n async ok(response: Response, what: string): Promise<Response> {\n if (response.ok) return response;\n let code = \"http_\" + response.status;\n let message = \"\";\n try {\n const body = (await response.json()) as { error?: string; message?: string };\n code = body.error ?? code;\n message = body.message ?? \"\";\n } catch {\n // not JSON\n }\n throw new UnfazedSandboxError(response.status, code, `unfazed eve sandbox: ${what}: ${response.status} ${code}${message ? `: ${message}` : \"\"}`);\n }\n\n async ensure(sessionId: string, template: readonly WireFile[]): Promise<SessionInfo> {\n const res = await this.request(\"PUT\", `/sessions/${encodeURIComponent(sessionId)}`, { json: { template } });\n return (await (await this.ok(res, \"start the sandbox\")).json()) as SessionInfo;\n }\n\n /** The session, or `null` when the box no longer has it. */\n async get(sessionId: string): Promise<SessionInfo | null> {\n const res = await this.request(\"GET\", `/sessions/${encodeURIComponent(sessionId)}`);\n if (res.status === 410) return null;\n return (await (await this.ok(res, \"resume the sandbox\")).json()) as SessionInfo;\n }\n\n async delete(sessionId: string, signal?: AbortSignal): Promise<void> {\n const res = await this.request(\"DELETE\", `/sessions/${encodeURIComponent(sessionId)}`, { signal });\n await this.ok(res, \"delete the sandbox\");\n }\n}\n\n/** A sandbox session that is gone answers 410: eve then starts a fresh one. */\nfunction gone(error: unknown, sessionId: string): never {\n if (error instanceof UnfazedSandboxError && error.status === 410) {\n throw new SandboxSessionGoneError(`unfazed sandbox for session ${sessionId} is gone`);\n }\n throw error;\n}\n\n/** Reads a process's event stream, reconnecting after a dropped connection. */\nasync function followProcess(\n client: SandboxClient,\n id: string,\n onEvent: (event: ProcessEvent) => void,\n signal: AbortSignal,\n): Promise<number> {\n let after = 0;\n let failures = 0;\n for (;;) {\n try {\n const res = await client.ok(\n await client.request(\"GET\", `/processes/${id}/events?after=${after}`, { signal, timeoutMs: 24 * 60 * 60 * 1000 }),\n \"read process output\",\n );\n const reader = res.body!.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n for (;;) {\n const { value, done } = await reader.read();\n if (done) break;\n buffer += decoder.decode(value, { stream: true });\n let cut: number;\n while ((cut = buffer.indexOf(\"\\n\\n\")) >= 0) {\n const frame = buffer.slice(0, cut);\n buffer = buffer.slice(cut + 2);\n for (const line of frame.split(\"\\n\")) {\n if (!line.startsWith(\"data: \")) continue;\n const event = JSON.parse(line.slice(6)) as ProcessEvent;\n after = event.s;\n failures = 0;\n onEvent(event);\n if (\"x\" in event) return event.x;\n }\n }\n }\n } catch (error) {\n if (signal.aborted) throw error;\n if (error instanceof UnfazedSandboxError && error.status < 500) throw error;\n if (++failures > 8) throw error;\n }\n await new Promise((resolve) => setTimeout(resolve, Math.min(250 * 2 ** failures, 5000)));\n }\n}\n\nfunction connect(client: SandboxClient, sessionId: string, session: SessionInfo): SandboxConnection {\n const sid = encodeURIComponent(sessionId);\n return {\n workspaceRoot: session.workspace,\n\n async spawn({ command, env, workingDirectory, stdin, signal }) {\n const res = await client\n .request(\"POST\", `/sessions/${sid}/processes`, { json: { command, cwd: workingDirectory, env, stdin: stdin === true }, signal })\n .then((r) => client.ok(r, \"start a command\"))\n .catch((error) => gone(error, sessionId));\n const { id, pid } = (await res.json()) as { id: string; pid?: number };\n const kill = async () => {\n await client.request(\"POST\", `/processes/${id}/kill`).catch(() => undefined);\n };\n const follow = new AbortController();\n let out!: ReadableStreamDefaultController<Uint8Array>;\n let err!: ReadableStreamDefaultController<Uint8Array>;\n const stdout = new ReadableStream<Uint8Array>({ start: (c) => void (out = c) });\n const stderr = new ReadableStream<Uint8Array>({ start: (c) => void (err = c) });\n const closeStreams = (error?: unknown) => {\n for (const c of [out, err]) {\n try {\n error === undefined ? c.close() : c.error(error);\n } catch {\n // already closed\n }\n }\n };\n const exited = followProcess(\n client,\n id,\n (event) => {\n if (\"d\" in event) (event.f === 1 ? out : err).enqueue(new Uint8Array(Buffer.from(event.d, \"base64\")));\n },\n follow.signal,\n ).then(\n (exitCode) => {\n closeStreams();\n return { exitCode };\n },\n (error) => {\n closeStreams(error);\n throw error;\n },\n );\n if (signal) {\n const onAbort = () => void kill();\n if (signal.aborted) onAbort();\n else signal.addEventListener(\"abort\", onAbort, { once: true });\n void exited.finally(() => signal.removeEventListener(\"abort\", onAbort)).catch(() => undefined);\n }\n let pending = Promise.resolve();\n const input = stdin\n ? new WritableStream<Uint8Array>({\n write: (chunk) =>\n (pending = pending.then(async () => {\n await client.ok(await client.request(\"POST\", `/processes/${id}/stdin`, { body: new Uint8Array(chunk) }), \"write stdin\");\n })),\n close: () =>\n (pending = pending.then(async () => {\n await client.ok(await client.request(\"POST\", `/processes/${id}/stdin?eof=1`, { body: new Uint8Array() }), \"close stdin\");\n })),\n })\n : undefined;\n return {\n pid,\n stdin: input,\n stdout,\n stderr,\n wait: () => exited,\n kill,\n };\n },\n\n async readFile({ path, signal }) {\n const res = await client.request(\"GET\", `/sessions/${sid}/file?path=${encodeURIComponent(path)}`, { signal }).catch((e) => gone(e, sessionId));\n if (res.status === 404) return null;\n await client.ok(res, `read ${path}`).catch((e) => gone(e, sessionId));\n return new Uint8Array(await res.arrayBuffer());\n },\n\n async writeFiles({ files, signal }) {\n let batch: WireFile[] = [];\n let size = 0;\n const send = async () => {\n if (batch.length === 0) return;\n await client\n .ok(await client.request(\"POST\", `/sessions/${sid}/files`, { json: { files: batch }, signal }), \"write files\")\n .catch((e) => gone(e, sessionId));\n batch = [];\n size = 0;\n };\n for (const file of files) {\n if (size + file.content.byteLength > MAX_WRITE_BATCH) await send();\n batch.push({ path: file.path, b64: toB64(file.content) });\n size += file.content.byteLength;\n }\n await send();\n },\n\n async removePath({ path, force, recursive, signal }) {\n await client\n .ok(await client.request(\"POST\", `/sessions/${sid}/remove`, { json: { path, force: force === true, recursive: recursive === true }, signal }), `remove ${path}`)\n .catch((e) => gone(e, sessionId));\n },\n\n async stop() {\n const res = await client.request(\"POST\", `/sessions/${sid}/stop`);\n if (res.status === 410) return;\n await client.ok(res, \"stop the sandbox\");\n },\n\n // The box keeps the session's processes (an open browser) between steps;\n // its daemon stops a session's processes after it has been idle.\n async close() {},\n };\n}\n\n/**\n * Captures the workspace and skill files `ctx.populate()` writes at build\n * time, so every new session starts from them. A build-time command other\n * than eve's `$HOME` probe is refused: install tools on the box instead.\n */\nasync function captureTemplate(ctx: SandboxPrepareContext): Promise<WireFile[]> {\n const files = new Map<string, Uint8Array>();\n const empty = () => new ReadableStream<Uint8Array>({ start: (c) => c.close() });\n const capture: SandboxConnection = {\n workspaceRoot: TEMPLATE_WORKSPACE,\n async spawn({ command }) {\n if (command.trim() !== `printf '%s\\\\n' \"$HOME\"`) {\n throw new Error(\n \"unfazed eve sandbox: commands in prepare() do not run at build time; install tools on the box itself (see `unfazed eve-sandbox setup`)\",\n );\n }\n return {\n stdout: new ReadableStream<Uint8Array>({\n start(c) {\n c.enqueue(new TextEncoder().encode(`${TEMPLATE_HOME}\\n`));\n c.close();\n },\n }),\n stderr: empty(),\n wait: async () => ({ exitCode: 0 }),\n kill: async () => {},\n };\n },\n async readFile({ path }) {\n return files.get(path) ?? null;\n },\n async writeFiles({ files: written }) {\n for (const file of written) files.set(file.path, file.content);\n },\n async removePath({ path, recursive }) {\n files.delete(path);\n if (recursive) for (const key of [...files.keys()]) if (key.startsWith(`${path}/`)) files.delete(key);\n },\n async stop() {},\n };\n await ctx.populate(capture);\n let total = 0;\n const out: WireFile[] = [];\n for (const [path, content] of files) {\n total += content.byteLength;\n out.push({ path, b64: toB64(content) });\n }\n if (total > MAX_TEMPLATE_BYTES) {\n throw new Error(`unfazed eve sandbox: the workspace and skill files are ${total} bytes; at most ${MAX_TEMPLATE_BYTES} fit in a template`);\n }\n return out.sort((a, b) => a.path.localeCompare(b.path));\n}\n\n/** The provider's implementation (for tests); eve apps use {@link UnfazedSandbox}. */\nexport const unfazedSandboxDefinition: SandboxProviderDefinition<\n UnfazedSandboxOptions,\n undefined,\n UnfazedSandboxArtifact,\n UnfazedSandboxState,\n {}\n> = {\n name: \"unfazed\",\n stateProtocolVersion: 1,\n environment(options: UnfazedSandboxOptions) {\n const base = boxUrl(options);\n const audience = options.audience ?? base;\n const token = options.token ?? ((aud: string) => oidcToken(aud));\n const client = new SandboxClient(base, () => token(audience), options.fetch);\n return {\n async prepare(ctx): Promise<UnfazedSandboxArtifact> {\n return { v: 1, files: ctx.isEmpty ? [] : await captureTemplate(ctx) };\n },\n async start(ctx, _open: undefined, artifact: Readonly<UnfazedSandboxArtifact>) {\n const session = await client.ensure(ctx.session.id, artifact?.files ?? []);\n const state: UnfazedSandboxState = { v: 1, sessionId: ctx.session.id, workspace: session.workspace };\n return { connection: connect(client, ctx.session.id, session), state };\n },\n async resume(ctx, _artifact: Readonly<UnfazedSandboxArtifact>, state: Readonly<UnfazedSandboxState>) {\n const sessionId = typeof state?.sessionId === \"string\" ? state.sessionId : ctx.session.id;\n const session = await client.get(sessionId);\n if (session === null) throw new SandboxSessionGoneError(`unfazed sandbox for session ${sessionId} is gone`);\n return connect(client, sessionId, session);\n },\n async onSessionEnd(ctx, state: Readonly<UnfazedSandboxState> | null, { signal }) {\n const sessionId = typeof state?.sessionId === \"string\" ? state.sessionId : ctx.session.id;\n await client.delete(sessionId, signal);\n },\n // Keyed MCP tool sessions keep their sandbox between calls; the box\n // deletes a sandbox nobody used for its retention period.\n toolSessions: true as const,\n };\n },\n};\n\n/** The eve sandbox provider backed by an unfazed box. */\nexport const UnfazedSandbox: SandboxProvider<WithPrepareOption<UnfazedSandboxOptions, SandboxSession>, undefined, SandboxSession> =\n defineSandboxProvider(unfazedSandboxDefinition);\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contract between the eve sandbox provider (`unfazed/eve-sandbox`) and
|
|
3
|
+
* the sandbox daemon that runs inside an unfazed box (`daemon.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Every route but `GET /v1/health` takes `Authorization: Bearer <OIDC JWT>`:
|
|
6
|
+
* a workload identity token of the calling app (issuer
|
|
7
|
+
* `https://unfazed.dev/oidc`) whose audience is the box's URL. The daemon
|
|
8
|
+
* namespaces every sandbox by the token's `app_id`, so two apps sharing a box
|
|
9
|
+
* never see each other's sessions.
|
|
10
|
+
*/
|
|
11
|
+
/** Version segment of every route. */
|
|
12
|
+
export declare const API_PREFIX = "/v1";
|
|
13
|
+
/** The daemon's own version, reported by `GET /v1/health`. */
|
|
14
|
+
export declare const DAEMON_VERSION = "1";
|
|
15
|
+
/**
|
|
16
|
+
* Template files captured at build time name these placeholder roots; the
|
|
17
|
+
* daemon maps them onto the session's workspace and home when it creates the
|
|
18
|
+
* session.
|
|
19
|
+
*/
|
|
20
|
+
export declare const TEMPLATE_WORKSPACE = "/__unfazed_eve_workspace__";
|
|
21
|
+
export declare const TEMPLATE_HOME = "/__unfazed_eve_home__";
|
|
22
|
+
/** A file as it travels in JSON: an absolute path and base64 content. */
|
|
23
|
+
export type WireFile = {
|
|
24
|
+
readonly path: string;
|
|
25
|
+
readonly b64: string;
|
|
26
|
+
};
|
|
27
|
+
/** `PUT /v1/sessions/:id` body. */
|
|
28
|
+
export interface EnsureSessionRequest {
|
|
29
|
+
readonly template?: readonly WireFile[];
|
|
30
|
+
}
|
|
31
|
+
/** A session as the daemon reports it. */
|
|
32
|
+
export interface SessionInfo {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly home: string;
|
|
35
|
+
readonly workspace: string;
|
|
36
|
+
readonly created?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/** `POST /v1/sessions/:id/processes` body. */
|
|
39
|
+
export interface SpawnRequest {
|
|
40
|
+
readonly command: string;
|
|
41
|
+
readonly cwd: string;
|
|
42
|
+
readonly env: Readonly<Record<string, string>>;
|
|
43
|
+
readonly stdin: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One server-sent event of `GET /v1/processes/:id/events`: output of stream
|
|
47
|
+
* `f` (1 stdout, 2 stderr) as base64 `d`, or the exit code `x`, numbered `s`
|
|
48
|
+
* from 1 so a client can resume with `?after=<s>`.
|
|
49
|
+
*/
|
|
50
|
+
export type ProcessEvent = {
|
|
51
|
+
readonly s: number;
|
|
52
|
+
readonly f: 1 | 2;
|
|
53
|
+
readonly d: string;
|
|
54
|
+
} | {
|
|
55
|
+
readonly s: number;
|
|
56
|
+
readonly x: number;
|
|
57
|
+
};
|
|
58
|
+
/** `POST /v1/sessions/:id/remove` body. */
|
|
59
|
+
export interface RemoveRequest {
|
|
60
|
+
readonly path: string;
|
|
61
|
+
readonly force?: boolean;
|
|
62
|
+
readonly recursive?: boolean;
|
|
63
|
+
}
|
|
64
|
+
/** Error body of every non-2xx answer. */
|
|
65
|
+
export interface ErrorBody {
|
|
66
|
+
readonly error: string;
|
|
67
|
+
readonly message?: string;
|
|
68
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire contract between the eve sandbox provider (`unfazed/eve-sandbox`) and
|
|
3
|
+
* the sandbox daemon that runs inside an unfazed box (`daemon.ts`).
|
|
4
|
+
*
|
|
5
|
+
* Every route but `GET /v1/health` takes `Authorization: Bearer <OIDC JWT>`:
|
|
6
|
+
* a workload identity token of the calling app (issuer
|
|
7
|
+
* `https://unfazed.dev/oidc`) whose audience is the box's URL. The daemon
|
|
8
|
+
* namespaces every sandbox by the token's `app_id`, so two apps sharing a box
|
|
9
|
+
* never see each other's sessions.
|
|
10
|
+
*/
|
|
11
|
+
/** Version segment of every route. */
|
|
12
|
+
export const API_PREFIX = "/v1";
|
|
13
|
+
/** The daemon's own version, reported by `GET /v1/health`. */
|
|
14
|
+
export const DAEMON_VERSION = "1";
|
|
15
|
+
/**
|
|
16
|
+
* Template files captured at build time name these placeholder roots; the
|
|
17
|
+
* daemon maps them onto the session's workspace and home when it creates the
|
|
18
|
+
* session.
|
|
19
|
+
*/
|
|
20
|
+
export const TEMPLATE_WORKSPACE = "/__unfazed_eve_workspace__";
|
|
21
|
+
export const TEMPLATE_HOME = "/__unfazed_eve_home__";
|
|
22
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/eve-sandbox/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,sCAAsC;AACtC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAEhC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAElC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,4BAA4B,CAAC;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,uBAAuB,CAAC","sourcesContent":["/**\n * Wire contract between the eve sandbox provider (`unfazed/eve-sandbox`) and\n * the sandbox daemon that runs inside an unfazed box (`daemon.ts`).\n *\n * Every route but `GET /v1/health` takes `Authorization: Bearer <OIDC JWT>`:\n * a workload identity token of the calling app (issuer\n * `https://unfazed.dev/oidc`) whose audience is the box's URL. The daemon\n * namespaces every sandbox by the token's `app_id`, so two apps sharing a box\n * never see each other's sessions.\n */\n\n/** Version segment of every route. */\nexport const API_PREFIX = \"/v1\";\n\n/** The daemon's own version, reported by `GET /v1/health`. */\nexport const DAEMON_VERSION = \"1\";\n\n/**\n * Template files captured at build time name these placeholder roots; the\n * daemon maps them onto the session's workspace and home when it creates the\n * session.\n */\nexport const TEMPLATE_WORKSPACE = \"/__unfazed_eve_workspace__\";\nexport const TEMPLATE_HOME = \"/__unfazed_eve_home__\";\n\n/** A file as it travels in JSON: an absolute path and base64 content. */\nexport type WireFile = {\n readonly path: string;\n readonly b64: string;\n};\n\n/** `PUT /v1/sessions/:id` body. */\nexport interface EnsureSessionRequest {\n readonly template?: readonly WireFile[];\n}\n\n/** A session as the daemon reports it. */\nexport interface SessionInfo {\n readonly name: string;\n readonly home: string;\n readonly workspace: string;\n readonly created?: boolean;\n}\n\n/** `POST /v1/sessions/:id/processes` body. */\nexport interface SpawnRequest {\n readonly command: string;\n readonly cwd: string;\n readonly env: Readonly<Record<string, string>>;\n readonly stdin: boolean;\n}\n\n/**\n * One server-sent event of `GET /v1/processes/:id/events`: output of stream\n * `f` (1 stdout, 2 stderr) as base64 `d`, or the exit code `x`, numbered `s`\n * from 1 so a client can resume with `?after=<s>`.\n */\nexport type ProcessEvent =\n | { readonly s: number; readonly f: 1 | 2; readonly d: string }\n | { readonly s: number; readonly x: number };\n\n/** `POST /v1/sessions/:id/remove` body. */\nexport interface RemoveRequest {\n readonly path: string;\n readonly force?: boolean;\n readonly recursive?: boolean;\n}\n\n/** Error body of every non-2xx answer. */\nexport interface ErrorBody {\n readonly error: string;\n readonly message?: string;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unfazed",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Official TypeScript SDK for unfazed. The code-mode companion to the unfazed MCP server: deploy, wait, tail logs and roll back from one script. `npx unfazed login` signs you in. Also ships the unfazed World for Workflow SDK (unfazed/workflow).",
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"description": "Official TypeScript SDK for unfazed. The code-mode companion to the unfazed MCP server: deploy, wait, tail logs and roll back from one script. `npx unfazed login` signs you in. Also ships the unfazed World for Workflow SDK (unfazed/workflow) and eve sandboxes on unfazed boxes (unfazed/eve-sandbox).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -31,6 +31,11 @@
|
|
|
31
31
|
"import": "./dist/workflow/nitro.js",
|
|
32
32
|
"default": "./dist/workflow/nitro.js"
|
|
33
33
|
},
|
|
34
|
+
"./eve-sandbox": {
|
|
35
|
+
"types": "./dist/eve-sandbox/index.d.ts",
|
|
36
|
+
"import": "./dist/eve-sandbox/index.js",
|
|
37
|
+
"default": "./dist/eve-sandbox/index.js"
|
|
38
|
+
},
|
|
34
39
|
"./package.json": "./package.json"
|
|
35
40
|
},
|
|
36
41
|
"files": [
|
|
@@ -99,7 +104,8 @@
|
|
|
99
104
|
"drizzle-orm": ">=0.45.2",
|
|
100
105
|
"nitro": ">=3.0.260610-beta",
|
|
101
106
|
"pg": "^8.20.0",
|
|
102
|
-
"workflow": "^5.2.0"
|
|
107
|
+
"workflow": "^5.2.0",
|
|
108
|
+
"eve": ">=0.90.0"
|
|
103
109
|
},
|
|
104
110
|
"peerDependenciesMeta": {
|
|
105
111
|
"@workflow/core": {
|
|
@@ -122,6 +128,9 @@
|
|
|
122
128
|
},
|
|
123
129
|
"workflow": {
|
|
124
130
|
"optional": true
|
|
131
|
+
},
|
|
132
|
+
"eve": {
|
|
133
|
+
"optional": true
|
|
125
134
|
}
|
|
126
135
|
},
|
|
127
136
|
"devDependencies": {
|
|
@@ -141,6 +150,7 @@
|
|
|
141
150
|
"pg": "8.20.0",
|
|
142
151
|
"typescript": "^6.0.3",
|
|
143
152
|
"vitest": "4.1.10",
|
|
144
|
-
"workflow": "5.2.2"
|
|
153
|
+
"workflow": "5.2.2",
|
|
154
|
+
"eve": "0.90.0"
|
|
145
155
|
}
|
|
146
156
|
}
|