@finalai/agent-provider 0.1.4 → 0.1.6
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 +49 -9
- package/dist/modules/conformance/agent.mjs +8 -4
- package/dist/modules/conformance/agent.mjs.map +2 -2
- package/dist/modules/conformance/sandbox-kit.d.mts +8 -0
- package/dist/modules/conformance/sandbox-kit.mjs +160 -3
- package/dist/modules/conformance/sandbox-kit.mjs.map +2 -2
- package/dist/modules/harness.mjs +2 -1
- package/dist/modules/harness.mjs.map +2 -2
- package/dist/modules/sandbox/memory-sandbox.d.mts +1 -0
- package/dist/modules/sandbox/memory-sandbox.mjs +25 -10
- package/dist/modules/sandbox/memory-sandbox.mjs.map +2 -2
- package/dist/modules/sandbox/memory-shell.d.mts +1 -0
- package/dist/modules/sandbox/memory-shell.mjs +14 -0
- package/dist/modules/sandbox/memory-shell.mjs.map +2 -2
- package/dist/modules/sandbox/types.d.mts +8 -1
- package/dist/modules/sandbox/types.mjs +32 -1
- package/dist/modules/sandbox/types.mjs.map +2 -2
- package/dist/modules/schemas.mjs +1 -1
- package/dist/modules/schemas.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/sandbox/memory-shell.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod';\nimport { utf8Encode } from \"./bytes.mjs\";\nimport { posixBasename, resolvePosixPath } from \"./paths.mjs\";\n\n// A tiny command interpreter for the in-memory reference sandbox: enough of a\n// shell for tests and the conformance kit. Supports `;`, `&&`, `||`, newlines,\n// single and double quotes, `> file`, `>> file`, `>&2`, and the commands echo,\n// cat, ls, pwd, cd, true, false, sleep, exit, mkdir and `sh -c` / `bash -c`.\n\nexport interface MemoryShellFsIface {\n readFile(path: string): Uint8Array | null;\n writeFile(path: string, data: Uint8Array, options: { append: boolean }): void;\n kind(path: string): 'file' | 'directory' | null;\n list(path: string): string[] | null;\n mkdir(path: string, options: { parents: boolean }): void;\n}\n\nexport interface MemoryShellIoIface {\n // Next stdin chunk, or null at end of input.\n readStdin: () => Promise<Uint8Array | null>;\n stdout: (bytes: Uint8Array) => void;\n stderr: (bytes: Uint8Array) => void;\n signal: AbortSignal;\n}\n\nexport interface MemoryShellContextIface {\n fs: MemoryShellFsIface;\n io: MemoryShellIoIface;\n cwd: string;\n sleep: (ms: number, signal: AbortSignal) => Promise<void>;\n}\n\ntype Token = { kind: 'word'; value: string } | { kind: 'op'; value: string };\n\ninterface CommandIface {\n argv: string[];\n stdoutTo: { path: string; append: boolean } | 'stderr' | null;\n}\n\ninterface StepIface {\n connector: ';' | '&&' | '||';\n command: CommandIface;\n}\n\n// `exit N` unwinds the script as an error carrying the status.\ninterface ExitRequestIface extends Error {\n code: number;\n}\n\nconst EXIT_REQUEST = 'MemoryShellExit';\nconst exitFieldsSchema = z.object({ code: z.number() });\n\nconst exitRequest = (code: number): ExitRequestIface =>\n Object.assign(new Error(`exit ${code}`), { name: EXIT_REQUEST, code });\n\nconst isExitRequest = (cause: unknown): cause is ExitRequestIface =>\n cause instanceof Error &&\n cause.name === EXIT_REQUEST &&\n exitFieldsSchema.safeParse(cause).success;\n\nconst tokenize = (script: string): Token[] => {\n const tokens: Token[] = [];\n let word: string | null = null;\n const flush = () => {\n if (word != null) tokens.push({ kind: 'word', value: word });\n word = null;\n };\n for (let i = 0; i < script.length; i += 1) {\n const char = script[i] ?? '';\n if (char === \"'\") {\n const end = script.indexOf(\"'\", i + 1);\n const stop = end < 0 ? script.length : end;\n word = (word ?? '') + script.slice(i + 1, stop);\n i = stop;\n continue;\n }\n if (char === '\"') {\n let value = '';\n let j = i + 1;\n for (; j < script.length && script[j] !== '\"'; j += 1) {\n if (script[j] === '\\\\' && j + 1 < script.length) {\n j += 1;\n }\n value += script[j] ?? '';\n }\n word = (word ?? '') + value;\n i = j;\n continue;\n }\n if (char === '\\\\' && i + 1 < script.length) {\n word = (word ?? '') + (script[i + 1] ?? '');\n i += 1;\n continue;\n }\n if (char === ' ' || char === '\\t') {\n flush();\n continue;\n }\n if (char === '\\n' || char === ';') {\n flush();\n tokens.push({ kind: 'op', value: ';' });\n continue;\n }\n if (char === '&' && script[i + 1] === '&') {\n flush();\n tokens.push({ kind: 'op', value: '&&' });\n i += 1;\n continue;\n }\n if (char === '|' && script[i + 1] === '|') {\n flush();\n tokens.push({ kind: 'op', value: '||' });\n i += 1;\n continue;\n }\n if (char === '>') {\n flush();\n if (script.startsWith('>&2', i)) {\n tokens.push({ kind: 'op', value: '>&2' });\n i += 2;\n } else if (script[i + 1] === '>') {\n tokens.push({ kind: 'op', value: '>>' });\n i += 1;\n } else {\n tokens.push({ kind: 'op', value: '>' });\n }\n continue;\n }\n if (char === '#' && word == null) {\n const end = script.indexOf('\\n', i);\n i = end < 0 ? script.length : end - 1;\n continue;\n }\n word = (word ?? '') + char;\n }\n flush();\n return tokens;\n};\n\nconst parse = (script: string): StepIface[] => {\n const steps: StepIface[] = [];\n let connector: StepIface['connector'] = ';';\n let command: CommandIface = { argv: [], stdoutTo: null };\n const push = () => {\n if (command.argv.length > 0) steps.push({ connector, command });\n command = { argv: [], stdoutTo: null };\n };\n const tokens = tokenize(script);\n for (let i = 0; i < tokens.length; i += 1) {\n const token = tokens[i];\n if (token == null) continue;\n if (token.kind === 'word') {\n command.argv.push(token.value);\n continue;\n }\n if (token.value === '>&2') {\n command.stdoutTo = 'stderr';\n continue;\n }\n if (token.value === '>' || token.value === '>>') {\n const target = tokens[i + 1];\n if (target?.kind === 'word') {\n command.stdoutTo = { path: target.value, append: token.value === '>>' };\n i += 1;\n }\n continue;\n }\n push();\n connector = token.value === '&&' ? '&&' : token.value === '||' ? '||' : ';';\n }\n push();\n return steps;\n};\n\nconst line = (text: string) => utf8Encode(`${text}\\n`);\n\nconst runCommand = async (\n context: MemoryShellContextIface,\n command: CommandIface,\n): Promise<number> => {\n const [name, ...args] = command.argv;\n const captured: Uint8Array[] = [];\n const out = (bytes: Uint8Array) => {\n if (command.stdoutTo == null) context.io.stdout(bytes);\n else if (command.stdoutTo === 'stderr') context.io.stderr(bytes);\n else captured.push(bytes);\n };\n const err = (text: string) => context.io.stderr(line(text));\n const status = await (async (): Promise<number> => {\n switch (name) {\n case 'echo': {\n const noNewline = args[0] === '-n';\n const text = (noNewline ? args.slice(1) : args).join(' ');\n out(utf8Encode(noNewline ? text : `${text}\\n`));\n return 0;\n }\n case 'cat': {\n if (args.length === 0) {\n for (;;) {\n const chunk = await context.io.readStdin();\n if (chunk == null) return 0;\n out(chunk);\n }\n }\n let status = 0;\n for (const arg of args) {\n const path = resolvePosixPath(context.cwd, arg);\n const data = context.fs.readFile(path);\n if (data == null) {\n err(\n `cat: ${arg}: ${context.fs.kind(path) === 'directory' ? 'Is a directory' : 'No such file or directory'}`,\n );\n status = 1;\n } else {\n out(data);\n }\n }\n return status;\n }\n case 'ls': {\n const targets = args.filter((arg) => !arg.startsWith('-'));\n let status = 0;\n for (const arg of targets.length === 0 ? ['.'] : targets) {\n const path = resolvePosixPath(context.cwd, arg);\n const kind = context.fs.kind(path);\n if (kind == null) {\n err(`ls: cannot access '${arg}': No such file or directory`);\n status = 2;\n } else if (kind === 'file') {\n out(line(posixBasename(path)));\n } else {\n for (const entry of context.fs.list(path) ?? []) out(line(entry));\n }\n }\n return status;\n }\n case 'pwd':\n out(line(context.cwd));\n return 0;\n case 'cd': {\n const path = resolvePosixPath(context.cwd, args[0] ?? '/');\n if (context.fs.kind(path) !== 'directory') {\n err(`cd: ${args[0] ?? '/'}: No such file or directory`);\n return 1;\n }\n context.cwd = path;\n return 0;\n }\n case 'true':\n return 0;\n case 'false':\n return 1;\n case 'sleep': {\n const seconds = Number(args[0] ?? '0');\n if (!Number.isFinite(seconds) || seconds < 0) {\n err(`sleep: invalid time interval '${args[0] ?? ''}'`);\n return 1;\n }\n await context.sleep(seconds * 1000, context.io.signal);\n return 0;\n }\n case 'exit': {\n const code = Number(args[0] ?? '0');\n throw exitRequest(Number.isInteger(code) ? code & 0xff : 2);\n }\n case 'mkdir': {\n const parents = args.includes('-p');\n for (const arg of args.filter((value) => !value.startsWith('-'))) {\n try {\n context.fs.mkdir(resolvePosixPath(context.cwd, arg), { parents });\n } catch (error) {\n err(\n `mkdir: cannot create directory '${arg}': ${error instanceof Error ? error.message : 'error'}`,\n );\n return 1;\n }\n }\n return 0;\n }\n case 'sh':\n case 'bash': {\n const flag = args.indexOf('-c');\n const script = flag >= 0 ? args[flag + 1] : undefined;\n if (script == null) {\n err(`${name}: interactive shells are not supported by the memory sandbox`);\n return 127;\n }\n return runMemoryScript({ ...context, script });\n }\n default:\n err(`${name ?? ''}: command not found`);\n return 127;\n }\n })();\n if (command.stdoutTo != null && command.stdoutTo !== 'stderr') {\n const path = resolvePosixPath(context.cwd, command.stdoutTo.path);\n const total = captured.reduce((sum, chunk) => sum + chunk.byteLength, 0);\n const data = new Uint8Array(total);\n let offset = 0;\n for (const chunk of captured) {\n data.set(chunk, offset);\n offset += chunk.byteLength;\n }\n context.fs.writeFile(path, data, { append: command.stdoutTo.append });\n }\n return status;\n};\n\n// Runs a script; resolves with its exit status. Aborting the signal stops it\n// between commands and inside `sleep` and stdin reads (the caller maps the\n// abort to a signal exit status).\nexport const runMemoryScript = async (\n args: MemoryShellContextIface & { script: string },\n): Promise<number> => {\n let status = 0;\n try {\n for (const step of parse(args.script)) {\n args.io.signal.throwIfAborted();\n if (step.connector === '&&' && status !== 0) continue;\n if (step.connector === '||' && status === 0) continue;\n status = await runCommand(args, step.command);\n }\n } catch (error) {\n if (isExitRequest(error)) return error.code;\n throw error;\n }\n return status;\n};\n\nexport const runMemoryArgv = async (\n args: MemoryShellContextIface & { argv: string[] },\n): Promise<number> => {\n try {\n return await runCommand(args, { argv: args.argv, stdoutTo: null });\n } catch (error) {\n if (isExitRequest(error)) return error.code;\n throw error;\n }\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,kBAAkB;AAC3B,SAAS,eAAe,wBAAwB;
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport { utf8Encode } from \"./bytes.mjs\";\nimport { posixBasename, resolvePosixPath } from \"./paths.mjs\";\n\n// A tiny command interpreter for the in-memory reference sandbox: enough of a\n// shell for tests and the conformance kit. Supports `;`, `&&`, `||`, newlines,\n// single and double quotes, `> file`, `>> file`, `>&2`, and the commands echo,\n// cat, ls, pwd, cd, true, false, sleep, exit, mkdir, printenv and `sh -c` / `bash -c`.\n\nexport interface MemoryShellFsIface {\n readFile(path: string): Uint8Array | null;\n writeFile(path: string, data: Uint8Array, options: { append: boolean }): void;\n kind(path: string): 'file' | 'directory' | null;\n list(path: string): string[] | null;\n mkdir(path: string, options: { parents: boolean }): void;\n}\n\nexport interface MemoryShellIoIface {\n // Next stdin chunk, or null at end of input.\n readStdin: () => Promise<Uint8Array | null>;\n stdout: (bytes: Uint8Array) => void;\n stderr: (bytes: Uint8Array) => void;\n signal: AbortSignal;\n}\n\nexport interface MemoryShellContextIface {\n fs: MemoryShellFsIface;\n io: MemoryShellIoIface;\n cwd: string;\n // The process's environment, which only printenv reads (no `$` expansion).\n env?: Record<string, string>;\n sleep: (ms: number, signal: AbortSignal) => Promise<void>;\n}\n\ntype Token = { kind: 'word'; value: string } | { kind: 'op'; value: string };\n\ninterface CommandIface {\n argv: string[];\n stdoutTo: { path: string; append: boolean } | 'stderr' | null;\n}\n\ninterface StepIface {\n connector: ';' | '&&' | '||';\n command: CommandIface;\n}\n\n// `exit N` unwinds the script as an error carrying the status.\ninterface ExitRequestIface extends Error {\n code: number;\n}\n\nconst EXIT_REQUEST = 'MemoryShellExit';\nconst exitFieldsSchema = z.object({ code: z.number() });\n\nconst exitRequest = (code: number): ExitRequestIface =>\n Object.assign(new Error(`exit ${code}`), { name: EXIT_REQUEST, code });\n\nconst isExitRequest = (cause: unknown): cause is ExitRequestIface =>\n cause instanceof Error &&\n cause.name === EXIT_REQUEST &&\n exitFieldsSchema.safeParse(cause).success;\n\nconst tokenize = (script: string): Token[] => {\n const tokens: Token[] = [];\n let word: string | null = null;\n const flush = () => {\n if (word != null) tokens.push({ kind: 'word', value: word });\n word = null;\n };\n for (let i = 0; i < script.length; i += 1) {\n const char = script[i] ?? '';\n if (char === \"'\") {\n const end = script.indexOf(\"'\", i + 1);\n const stop = end < 0 ? script.length : end;\n word = (word ?? '') + script.slice(i + 1, stop);\n i = stop;\n continue;\n }\n if (char === '\"') {\n let value = '';\n let j = i + 1;\n for (; j < script.length && script[j] !== '\"'; j += 1) {\n if (script[j] === '\\\\' && j + 1 < script.length) {\n j += 1;\n }\n value += script[j] ?? '';\n }\n word = (word ?? '') + value;\n i = j;\n continue;\n }\n if (char === '\\\\' && i + 1 < script.length) {\n word = (word ?? '') + (script[i + 1] ?? '');\n i += 1;\n continue;\n }\n if (char === ' ' || char === '\\t') {\n flush();\n continue;\n }\n if (char === '\\n' || char === ';') {\n flush();\n tokens.push({ kind: 'op', value: ';' });\n continue;\n }\n if (char === '&' && script[i + 1] === '&') {\n flush();\n tokens.push({ kind: 'op', value: '&&' });\n i += 1;\n continue;\n }\n if (char === '|' && script[i + 1] === '|') {\n flush();\n tokens.push({ kind: 'op', value: '||' });\n i += 1;\n continue;\n }\n if (char === '>') {\n flush();\n if (script.startsWith('>&2', i)) {\n tokens.push({ kind: 'op', value: '>&2' });\n i += 2;\n } else if (script[i + 1] === '>') {\n tokens.push({ kind: 'op', value: '>>' });\n i += 1;\n } else {\n tokens.push({ kind: 'op', value: '>' });\n }\n continue;\n }\n if (char === '#' && word == null) {\n const end = script.indexOf('\\n', i);\n i = end < 0 ? script.length : end - 1;\n continue;\n }\n word = (word ?? '') + char;\n }\n flush();\n return tokens;\n};\n\nconst parse = (script: string): StepIface[] => {\n const steps: StepIface[] = [];\n let connector: StepIface['connector'] = ';';\n let command: CommandIface = { argv: [], stdoutTo: null };\n const push = () => {\n if (command.argv.length > 0) steps.push({ connector, command });\n command = { argv: [], stdoutTo: null };\n };\n const tokens = tokenize(script);\n for (let i = 0; i < tokens.length; i += 1) {\n const token = tokens[i];\n if (token == null) continue;\n if (token.kind === 'word') {\n command.argv.push(token.value);\n continue;\n }\n if (token.value === '>&2') {\n command.stdoutTo = 'stderr';\n continue;\n }\n if (token.value === '>' || token.value === '>>') {\n const target = tokens[i + 1];\n if (target?.kind === 'word') {\n command.stdoutTo = { path: target.value, append: token.value === '>>' };\n i += 1;\n }\n continue;\n }\n push();\n connector = token.value === '&&' ? '&&' : token.value === '||' ? '||' : ';';\n }\n push();\n return steps;\n};\n\nconst line = (text: string) => utf8Encode(`${text}\\n`);\n\nconst runCommand = async (\n context: MemoryShellContextIface,\n command: CommandIface,\n): Promise<number> => {\n const [name, ...args] = command.argv;\n const captured: Uint8Array[] = [];\n const out = (bytes: Uint8Array) => {\n if (command.stdoutTo == null) context.io.stdout(bytes);\n else if (command.stdoutTo === 'stderr') context.io.stderr(bytes);\n else captured.push(bytes);\n };\n const err = (text: string) => context.io.stderr(line(text));\n const status = await (async (): Promise<number> => {\n switch (name) {\n case 'echo': {\n const noNewline = args[0] === '-n';\n const text = (noNewline ? args.slice(1) : args).join(' ');\n out(utf8Encode(noNewline ? text : `${text}\\n`));\n return 0;\n }\n case 'cat': {\n if (args.length === 0) {\n for (;;) {\n const chunk = await context.io.readStdin();\n if (chunk == null) return 0;\n out(chunk);\n }\n }\n let status = 0;\n for (const arg of args) {\n const path = resolvePosixPath(context.cwd, arg);\n const data = context.fs.readFile(path);\n if (data == null) {\n err(\n `cat: ${arg}: ${context.fs.kind(path) === 'directory' ? 'Is a directory' : 'No such file or directory'}`,\n );\n status = 1;\n } else {\n out(data);\n }\n }\n return status;\n }\n case 'ls': {\n const targets = args.filter((arg) => !arg.startsWith('-'));\n let status = 0;\n for (const arg of targets.length === 0 ? ['.'] : targets) {\n const path = resolvePosixPath(context.cwd, arg);\n const kind = context.fs.kind(path);\n if (kind == null) {\n err(`ls: cannot access '${arg}': No such file or directory`);\n status = 2;\n } else if (kind === 'file') {\n out(line(posixBasename(path)));\n } else {\n for (const entry of context.fs.list(path) ?? []) out(line(entry));\n }\n }\n return status;\n }\n case 'pwd':\n out(line(context.cwd));\n return 0;\n case 'cd': {\n const path = resolvePosixPath(context.cwd, args[0] ?? '/');\n if (context.fs.kind(path) !== 'directory') {\n err(`cd: ${args[0] ?? '/'}: No such file or directory`);\n return 1;\n }\n context.cwd = path;\n return 0;\n }\n case 'printenv': {\n const env = context.env ?? {};\n if (args.length === 0) {\n for (const [key, value] of Object.entries(env)) out(line(`${key}=${value}`));\n return 0;\n }\n let status = 0;\n for (const arg of args) {\n const value = Object.hasOwn(env, arg) ? env[arg] : undefined;\n if (value == null) status = 1;\n else out(line(value));\n }\n return status;\n }\n case 'true':\n return 0;\n case 'false':\n return 1;\n case 'sleep': {\n const seconds = Number(args[0] ?? '0');\n if (!Number.isFinite(seconds) || seconds < 0) {\n err(`sleep: invalid time interval '${args[0] ?? ''}'`);\n return 1;\n }\n await context.sleep(seconds * 1000, context.io.signal);\n return 0;\n }\n case 'exit': {\n const code = Number(args[0] ?? '0');\n throw exitRequest(Number.isInteger(code) ? code & 0xff : 2);\n }\n case 'mkdir': {\n const parents = args.includes('-p');\n for (const arg of args.filter((value) => !value.startsWith('-'))) {\n try {\n context.fs.mkdir(resolvePosixPath(context.cwd, arg), { parents });\n } catch (error) {\n err(\n `mkdir: cannot create directory '${arg}': ${error instanceof Error ? error.message : 'error'}`,\n );\n return 1;\n }\n }\n return 0;\n }\n case 'sh':\n case 'bash': {\n const flag = args.indexOf('-c');\n const script = flag >= 0 ? args[flag + 1] : undefined;\n if (script == null) {\n err(`${name}: interactive shells are not supported by the memory sandbox`);\n return 127;\n }\n return runMemoryScript({ ...context, script });\n }\n default:\n err(`${name ?? ''}: command not found`);\n return 127;\n }\n })();\n if (command.stdoutTo != null && command.stdoutTo !== 'stderr') {\n const path = resolvePosixPath(context.cwd, command.stdoutTo.path);\n const total = captured.reduce((sum, chunk) => sum + chunk.byteLength, 0);\n const data = new Uint8Array(total);\n let offset = 0;\n for (const chunk of captured) {\n data.set(chunk, offset);\n offset += chunk.byteLength;\n }\n context.fs.writeFile(path, data, { append: command.stdoutTo.append });\n }\n return status;\n};\n\n// Runs a script; resolves with its exit status. Aborting the signal stops it\n// between commands and inside `sleep` and stdin reads (the caller maps the\n// abort to a signal exit status).\nexport const runMemoryScript = async (\n args: MemoryShellContextIface & { script: string },\n): Promise<number> => {\n let status = 0;\n try {\n for (const step of parse(args.script)) {\n args.io.signal.throwIfAborted();\n if (step.connector === '&&' && status !== 0) continue;\n if (step.connector === '||' && status === 0) continue;\n status = await runCommand(args, step.command);\n }\n } catch (error) {\n if (isExitRequest(error)) return error.code;\n throw error;\n }\n return status;\n};\n\nexport const runMemoryArgv = async (\n args: MemoryShellContextIface & { argv: string[] },\n): Promise<number> => {\n try {\n return await runCommand(args, { argv: args.argv, stdoutTo: null });\n } catch (error) {\n if (isExitRequest(error)) return error.code;\n throw error;\n }\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,kBAAkB;AAC3B,SAAS,eAAe,wBAAwB;AAiDhD,MAAM,eAAe;AACrB,MAAM,mBAAmB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAEtD,MAAM,cAAc,CAAC,SACnB,OAAO,OAAO,IAAI,MAAM,QAAQ,IAAI,EAAE,GAAG,EAAE,MAAM,cAAc,KAAK,CAAC;AAEvE,MAAM,gBAAgB,CAAC,UACrB,iBAAiB,SACjB,MAAM,SAAS,gBACf,iBAAiB,UAAU,KAAK,EAAE;AAEpC,MAAM,WAAW,CAAC,WAA4B;AAC5C,QAAM,SAAkB,CAAC;AACzB,MAAI,OAAsB;AAC1B,QAAM,QAAQ,MAAM;AAClB,QAAI,QAAQ,KAAM,QAAO,KAAK,EAAE,MAAM,QAAQ,OAAO,KAAK,CAAC;AAC3D,WAAO;AAAA,EACT;AACA,WAAS,IAAI,GAAG,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K,CAAC;AAAA,EACnE,SAAS,OAAO;AACd,QAAI,cAAc,KAAK,EAAG,QAAO,MAAM;AACvC,UAAM;AAAA,EACR;AACF;",
|
|
6
6
|
"names": ["status"]
|
|
7
7
|
}
|
|
@@ -291,7 +291,14 @@ export interface SandboxStartContextIface {
|
|
|
291
291
|
variables: SandboxVariablesIface;
|
|
292
292
|
repositories: SandboxRepositoriesIface;
|
|
293
293
|
actingUser: SandboxActingUserIface;
|
|
294
|
-
|
|
294
|
+
platformEnvironment?: () => Promise<Record<string, string>>;
|
|
295
|
+
platformEgressHosts?: string[];
|
|
296
|
+
platformFiles?: () => Promise<Record<string, string>>;
|
|
297
|
+
}
|
|
298
|
+
export declare const PLATFORM_ENVIRONMENT_NAMES: ReadonlySet<string>;
|
|
299
|
+
export declare const platformProcessEnvironment: (ctx: Pick<SandboxStartContextIface, "platformEnvironment">, specEnv: Record<string, string>) => (() => Promise<Record<string, string>>);
|
|
300
|
+
export declare const writePlatformFiles: (ctx: Pick<SandboxStartContextIface, "platformFiles">, sandbox: Pick<SandboxSessionIface, "writeTextFile">) => Promise<void>;
|
|
301
|
+
export declare const withPlatformEgressHosts: (ctx: Pick<SandboxStartContextIface, "platformEgressHosts">, policy: NetworkPolicyIface) => NetworkPolicyIface;
|
|
295
302
|
export declare enum SandboxSessionEndReason {
|
|
296
303
|
Completed = "completed",
|
|
297
304
|
Expired = "expired",
|
|
@@ -39,6 +39,33 @@ const noSandboxRepositories = {
|
|
|
39
39
|
};
|
|
40
40
|
const noSandboxVariables = { get: async () => null };
|
|
41
41
|
const noSandboxActingUser = { current: async () => null };
|
|
42
|
+
const PLATFORM_ENVIRONMENT_NAMES = /* @__PURE__ */ new Set([
|
|
43
|
+
"HTTPS_PROXY",
|
|
44
|
+
"HTTP_PROXY",
|
|
45
|
+
"NO_PROXY",
|
|
46
|
+
"NODE_USE_ENV_PROXY",
|
|
47
|
+
"SSL_CERT_FILE",
|
|
48
|
+
"CURL_CA_BUNDLE",
|
|
49
|
+
"REQUESTS_CA_BUNDLE",
|
|
50
|
+
"GIT_SSL_CAINFO",
|
|
51
|
+
"CARGO_HTTP_CAINFO",
|
|
52
|
+
"DENO_CERT",
|
|
53
|
+
"NODE_EXTRA_CA_CERTS",
|
|
54
|
+
"FINAL_EGRESS_URL",
|
|
55
|
+
"FINAL_EGRESS_TOKEN",
|
|
56
|
+
"GH_TOKEN",
|
|
57
|
+
"GITHUB_TOKEN"
|
|
58
|
+
]);
|
|
59
|
+
const platformProcessEnvironment = (ctx, specEnv) => async () => ({ ...specEnv, ...await ctx.platformEnvironment?.() });
|
|
60
|
+
const writePlatformFiles = async (ctx, sandbox) => {
|
|
61
|
+
for (const [path, content] of Object.entries(await ctx.platformFiles?.() ?? {}))
|
|
62
|
+
await sandbox.writeTextFile({ path, content });
|
|
63
|
+
};
|
|
64
|
+
const withPlatformEgressHosts = (ctx, policy) => {
|
|
65
|
+
const hosts = ctx.platformEgressHosts ?? [];
|
|
66
|
+
if (policy.mode !== "allowlist" /* Allowlist */ || hosts.length === 0) return policy;
|
|
67
|
+
return { ...policy, allow: [.../* @__PURE__ */ new Set([...policy.allow ?? [], ...hosts])] };
|
|
68
|
+
};
|
|
42
69
|
var SandboxSessionEndReason = /* @__PURE__ */ ((SandboxSessionEndReason2) => {
|
|
43
70
|
SandboxSessionEndReason2["Completed"] = "completed";
|
|
44
71
|
SandboxSessionEndReason2["Expired"] = "expired";
|
|
@@ -70,6 +97,7 @@ var SandboxEventKind = /* @__PURE__ */ ((SandboxEventKind2) => {
|
|
|
70
97
|
})(SandboxEventKind || {});
|
|
71
98
|
export {
|
|
72
99
|
NetworkPolicy,
|
|
100
|
+
PLATFORM_ENVIRONMENT_NAMES,
|
|
73
101
|
PortProtocol,
|
|
74
102
|
SandboxCapability,
|
|
75
103
|
SandboxEntryType,
|
|
@@ -81,6 +109,9 @@ export {
|
|
|
81
109
|
noSandboxActingUser,
|
|
82
110
|
noSandboxGuides,
|
|
83
111
|
noSandboxRepositories,
|
|
84
|
-
noSandboxVariables
|
|
112
|
+
noSandboxVariables,
|
|
113
|
+
platformProcessEnvironment,
|
|
114
|
+
withPlatformEgressHosts,
|
|
115
|
+
writePlatformFiles
|
|
85
116
|
};
|
|
86
117
|
//# sourceMappingURL=types.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/sandbox/types.ts"],
|
|
4
|
-
"sourcesContent": ["import type { HostedBindingsIface } from \"../hosted-bindings.mjs\";\nimport type {\n ProcessInspectionRequestIface,\n ProcessInspectionResultIface,\n} from '@finalai/agent-protocol/process-inspection';\nimport type { JsonValue } from \"../json.mjs\";\nimport type { ToolDescriptorIface } from \"../manifest.mjs\";\nimport type { SandboxEditorRequestIface, SandboxEditorResultIface } from \"./editor.mjs\";\nimport { awaitableOpenRequest, type AwaitableSandboxOpenRequestIface } from \"./open-scope.mjs\";\nimport type { SandboxSnapshotRequestIface, SandboxSnapshotResponseIface } from \"./snapshots.mjs\";\n\n// Sandbox providers and consumers share the streaming session contract.\n\nexport interface AbortableIface {\n abortSignal?: AbortSignal;\n}\n\nexport interface SandboxProcessOptionsIface extends AbortableIface {\n command: string;\n args?: string[];\n cwd?: string;\n env?: Record<string, string>;\n // Run through the sandbox's login shell (`bash -lc`) instead of exec'ing.\n shell?: boolean;\n stdin?: ReadableStream<Uint8Array> | string;\n timeoutMs?: number;\n}\n\nexport interface SandboxProcessIface {\n readonly pid: string | null;\n readonly stdout: ReadableStream<Uint8Array>;\n readonly stderr: ReadableStream<Uint8Array>;\n // Writes to the process's stdin; closes stdin when `end` is true.\n write(data: Uint8Array | string, options?: { end?: boolean }): Promise<void>;\n wait(): Promise<{ exitCode: number }>;\n kill(signal?: string): Promise<void>;\n}\n\nexport interface SandboxRunResultIface {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\nexport enum SandboxEntryType {\n File = 'file',\n Directory = 'directory',\n Symlink = 'symlink',\n Other = 'other',\n}\n\nexport interface StatIface {\n path: string;\n type: SandboxEntryType;\n size: number;\n modifiedAt: string | null;\n mode: number | null;\n}\n\nexport interface DirEntryIface {\n name: string;\n path: string;\n type: SandboxEntryType;\n size: number | null;\n}\n\nexport interface ConfinedSandboxFilesIface {\n readFile(\n options: { path: string; root: string } & AbortableIface,\n ): Promise<ReadableStream<Uint8Array> | null>;\n stat(options: { path: string; root: string } & AbortableIface): Promise<StatIface | null>;\n readDir(\n options: { path: string; root: string } & AbortableIface,\n ): Promise<DirEntryIface[] | null>;\n}\n\nexport interface SandboxSessionIface {\n readonly description: string;\n readonly confinedFileReader?: ConfinedSandboxFilesIface;\n // On the RPC surface, root confines viewer reads to this directory, rejects\n // symlink ancestors and requires Python 3 in the sandbox (confinedFiles feature).\n readFile(\n options: { path: string; root?: string } & AbortableIface,\n ): Promise<ReadableStream<Uint8Array> | null>;\n readBinaryFile(options: { path: string } & AbortableIface): Promise<Uint8Array | null>;\n readTextFile(\n options: {\n path: string;\n encoding?: string;\n startLine?: number;\n endLine?: number;\n } & AbortableIface,\n ): Promise<string | null>;\n writeFile(\n options: { path: string; content: ReadableStream<Uint8Array> } & AbortableIface,\n ): Promise<void>;\n writeBinaryFile(options: { path: string; content: Uint8Array } & AbortableIface): Promise<void>;\n writeTextFile(\n options: { path: string; content: string; encoding?: string } & AbortableIface,\n ): Promise<void>;\n spawn(options: SandboxProcessOptionsIface): Promise<SandboxProcessIface>;\n run(options: SandboxProcessOptionsIface): Promise<SandboxRunResultIface>;\n stat(options: { path: string; root?: string } & AbortableIface): Promise<StatIface | null>;\n readDir(options: { path: string; root?: string } & AbortableIface): Promise<DirEntryIface[]>;\n resolvePath(path: string): string;\n removePath(\n options: { path: string; recursive?: boolean; force?: boolean } & AbortableIface,\n ): Promise<void>;\n}\n\nexport enum NetworkPolicy {\n AllowAll = 'allow-all',\n DenyAll = 'deny-all',\n Allowlist = 'allowlist',\n}\n\nexport interface NetworkPolicyIface {\n mode: NetworkPolicy;\n allow?: string[];\n}\n\nexport enum PortProtocol {\n Http = 'http',\n Https = 'https',\n Ws = 'ws',\n}\n\n// An MCP transport the sandbox serves for an optional capability: an HTTP MCP\n// endpoint the harness (or the session service) can dial.\nexport interface McpEndpointIface {\n name: string;\n url: string;\n headers: Record<string, string>;\n}\n\n// A JSON-RPC message channel to an MCP server the sandbox hosts, for backends\n// whose API reaches it some other way than HTTP MCP (a byte pipe, a socket).\n// Messages are JSON-RPC objects, in order.\nexport interface McpChannelIface {\n send(message: JsonValue, options?: AbortableIface): Promise<void>;\n // The messages that arrived since the last call; [] when none did.\n receive(options?: AbortableIface): Promise<JsonValue[]>;\n close(): Promise<void>;\n}\n\n// An MCP server the sandbox hosts, opened in process by whoever runs the handle.\n// It cannot cross the handle RPC wire.\nexport interface McpChannelEndpointIface {\n name: string;\n connect(options?: AbortableIface): Promise<McpChannelIface>;\n}\n\nexport type SandboxMcpEndpoint = McpEndpointIface | McpChannelEndpointIface;\n\n// The tools of a sandbox's hosted MCP servers, as far as they are known without\n// starting it. Null: unknown until the sandbox is attached and asked.\nexport interface SandboxMcpCatalogIface {\n computerUse: ToolDescriptorIface[] | null;\n // Local MCP server name \u2192 its tools.\n localMcp: Record<string, ToolDescriptorIface[]> | null;\n}\n\nexport const isMcpChannelEndpoint = (\n endpoint: SandboxMcpEndpoint,\n): endpoint is McpChannelEndpointIface => 'connect' in endpoint;\n\nexport interface ScreenOptionsIface {\n // View-only by default; explicit input control requires execute access.\n viewOnly?: boolean;\n}\n\nexport interface ScreenSessionIface {\n // A short-lived viewer grant; providers enforce the requested input access.\n url: string;\n token: string;\n expiresAt: string;\n}\n\nexport interface NetworkSandboxSessionIface extends SandboxSessionIface {\n readonly id: string;\n readonly defaultWorkingDirectory: string;\n readonly ports: readonly number[];\n getPortEndpoint(options: {\n port: number;\n protocol?: PortProtocol;\n }): Promise<{ url: string; headers?: Record<string, string> }>;\n getPortUrl(options: { port: number; protocol?: PortProtocol }): Promise<string>;\n stop(): Promise<void>;\n destroy(): Promise<void>;\n setNetworkPolicy?(policy: NetworkPolicyIface): Promise<void>;\n computerUse?(): Promise<SandboxMcpEndpoint>;\n screen?(options?: ScreenOptionsIface): Promise<ScreenSessionIface>;\n localMcp?(): Promise<SandboxMcpEndpoint[]>;\n}\n\n// Capabilities a started sandbox advertises (and the handle RPC exposes).\nexport enum SandboxCapability {\n Files = 'files',\n Process = 'process',\n Ports = 'ports',\n NetworkPolicy = 'networkPolicy',\n ComputerUse = 'computerUse',\n Screen = 'screen',\n LocalMcp = 'localMcp',\n Browser = 'browser',\n}\n\nexport interface SandboxProviderHandleIface<S extends SandboxSessionIface> {\n readonly sandbox: S;\n onSandboxStop(): Promise<void>;\n onSandboxDelete(options?: { reason?: string }): Promise<void>;\n onRuntimeShutdown(): Promise<void>;\n}\n\n// A saved computer setup guide version: Build's versioned build-\n// and start-time inputs for a sandbox, as the session service serves them.\nexport interface SandboxGuideVersionIface {\n guideId: string;\n versionId: string;\n slug: string;\n title: string;\n number: number;\n image: string;\n // `.final/sandbox-template.yaml` v2 as JSON.\n templateConfig: JsonValue;\n // The start-time parameters this version defaults to.\n defaultParameters: JsonValue;\n instructionsMarkdown: string | null;\n // A ready build from the guide's provider, reusable independently of workspace seeds.\n preparedArtifact?: { providerRef: string; key: string; artifact: JsonValue };\n}\n\n// The organization's computer setup guides, read through the session service.\n// Every provider gets the same reader; a provider whose\n// environments name no guide never calls it.\nexport interface SandboxGuidesIface {\n get(args: { ref: string; version: number | 'latest' }): Promise<SandboxGuideVersionIface | null>;\n // The organization's default guide; null when it has none.\n default(): Promise<SandboxGuideVersionIface | null>;\n}\n\n// Where to clone a repository from, with a short-lived read credential that\n// must reach only the clone process (never a repository's git config).\nexport interface SandboxRepositoryCloneSourceIface {\n url: string;\n // Checked out after the clone; null keeps the default branch.\n ref: string | null;\n // An HTTP Authorization header value for the clone, or null.\n authorization: string | null;\n}\n\n// Repository credentials for the repositories an environment names (a Code\n// Storage id, a GitHub owner/name), resolved by the session service for the\n// session's organization only. Null: not a repository it can resolve.\nexport interface SandboxRepositoriesIface {\n cloneSource(args: {\n repository: string;\n ref: string | null;\n }): Promise<SandboxRepositoryCloneSourceIface | null>;\n}\n\n// Reads a named organization variable (managed in Build) for the session's\n// organization. Values are injected into the sandbox only, never stored in a\n// manifest, a state or the log.\nexport interface SandboxVariablesIface {\n get(name: string): Promise<string | null>;\n}\n\nexport const noSandboxGuides: SandboxGuidesIface = {\n get: async () => null,\n default: async () => null,\n};\n\nexport const noSandboxRepositories: SandboxRepositoriesIface = {\n cloneSource: async () => null,\n};\n\nexport const noSandboxVariables: SandboxVariablesIface = { get: async () => null };\n\n// The user a session acts for: the author of its running turn, else its owner,\n// else the user whose Home its conversation is. A call a person makes through\n// the platform's sandbox viewer acts for that person instead. Null when it acts\n// for no user (a turn nobody prompted in a shared conversation) and outside any\n// session (a guide build). Read on each call, because it changes between turns\n// and between callers.\nexport interface SandboxActingUserIface {\n current(): Promise<string | null>;\n}\n\nexport const noSandboxActingUser: SandboxActingUserIface = { current: async () => null };\n\n// What an environment's pre-start reads (capabilities, mcpCatalog) are given.\nexport interface SandboxOfferContextIface {\n bindings?: HostedBindingsIface;\n organizationId: string;\n actingUser: SandboxActingUserIface;\n}\n\n// What an environment's hooks are given before anything starts.\nexport interface SandboxEnvironmentContextIface {\n bindings?: HostedBindingsIface;\n organizationId: string;\n guides: SandboxGuidesIface;\n}\n\n// Scoped by the host to this organization and provider. Providers can retain\n// reusable intermediate artifacts independently of a revision's seed files.\nexport interface SandboxArtifactsIface {\n get(key: string): Promise<JsonValue | null>;\n put(key: string, artifact: JsonValue): Promise<void>;\n}\n\nexport interface SandboxPreparationSourceIface {\n sourceRevision: string;\n read(): Promise<{ files: Record<string, string>; resources: Record<string, JsonValue> }>;\n}\n\nexport interface SandboxPrepareContextIface {\n bindings?: HostedBindingsIface;\n // A host-persisted resource source; artifacts may retain its identity instead of seed contents.\n preparation?: SandboxPreparationSourceIface;\n artifacts?: SandboxArtifactsIface;\n // Agent revisions supply workspace-relative seeds; setup-guide builds supply\n // guide.json and optional instructions.md. Resources name workspace, skills or guide.\n // Model instructions remain harness config.\n files: Record<string, string>;\n resources: Record<string, JsonValue>;\n sourceRevision: string;\n storagePath: string;\n organizationId: string;\n // The guide inputs (build-time) an environment names, resolved by the platform.\n guides: SandboxGuidesIface;\n // Who the session the artifact is prepared for acts for, for environments that\n // name a backend resource relative to that user; the key must then name it.\n actingUser: SandboxActingUserIface;\n log?: (message: string) => void;\n}\n\nexport interface SandboxStartContextIface {\n bindings?: HostedBindingsIface;\n /** Passive recovery only: never wake, create, seed, or restart backend services. */\n passive?: boolean;\n preparation?: SandboxPreparationSourceIface;\n session: {\n id: string;\n organizationId: string;\n conversationId: string | null;\n definitionId: string;\n bindingId: string;\n target: string;\n };\n storagePath: string;\n // Start-time inputs: guides, the variables to inject, repository credentials.\n guides: SandboxGuidesIface;\n variables: SandboxVariablesIface;\n repositories: SandboxRepositoriesIface;\n actingUser: SandboxActingUserIface;\n}\n\nexport enum SandboxSessionEndReason {\n Completed = 'completed',\n Expired = 'expired',\n Failed = 'failed',\n}\n\n// How long an environment's sandbox outlives a session: `session`\n// keeps it for the session's life; `conversation` gives every session in the\n// conversation one shared sandbox per target, surviving session resets;\n// `ephemeral` discards it when released.\nexport enum SandboxWorkspace {\n Session = 'session',\n Conversation = 'conversation',\n Ephemeral = 'ephemeral',\n}\n\nexport interface SandboxProviderImplementationIface<\n OpenOptions,\n Artifact extends JsonValue,\n State extends JsonValue,\n S extends NetworkSandboxSessionIface,\n> {\n // The workspace this environment declares, read before anything starts so the\n // session service knows which sessions share a binding. Absent or null: session.\n workspace?(ctx: SandboxEnvironmentContextIface): Promise<SandboxWorkspace | null>;\n // The capabilities this environment's sandboxes offer, read before anything\n // starts through the backend's own API. Absent or null: unknown\n // until started; local MCP is then not projected.\n capabilities?(ctx: SandboxOfferContextIface): Promise<SandboxCapability[] | null>;\n // The hosted MCP servers' tool catalogs the backend can give without starting\n // a sandbox (from its own records), so the MCP projection lists them from the\n // first `tools/list`. The projection checks a server's catalog against the\n // live server when a call first opens that server (servers a session never\n // uses stay closed) and announces a change with\n // `notifications/tools/list_changed`.\n //\n // Trade-off: a catalog left unknown (absent hook, null, or a null field) can\n // only be learned from the live sandbox, so the first `tools/list` that finds\n // it unknown starts the sandbox in the background, at session start rather\n // than on the first tool call. Otherwise those tools would never be listed,\n // and nothing would ever call them. Providers that can give the catalog keep\n // attach lazy.\n mcpCatalog?(ctx: SandboxOfferContextIface): Promise<SandboxMcpCatalogIface | null>;\n // Reads committed files without starting/resuming a sandbox. Null means the backend\n // is live or offers no snapshot. An unavailable sleeping snapshot must throw,\n // never fall through to a read that wakes it. Pin subsequent ranges by snapshotId.\n readSnapshot?(\n ctx: SandboxOfferContextIface,\n state: State,\n request: SandboxSnapshotRequestIface,\n ): Promise<SandboxSnapshotResponseIface | null>;\n // Inspect retained backend processes without opening, resuming or extending a sandbox.\n // Stop requires execute access; the provider also enforces backend ownership.\n processes?(\n ctx: SandboxOfferContextIface & { bindingId: string },\n state: State,\n request: ProcessInspectionRequestIface,\n ): Promise<ProcessInspectionResultIface>;\n // Browser editor for this provider's existing workspace. The host checks write\n // authorization; this hook never creates or wakes a backend. Credentials stay\n // in the authentication form, never the editor URL or stored provider state.\n editor?(\n ctx: SandboxOfferContextIface,\n state: State,\n request: SandboxEditorRequestIface,\n ): Promise<SandboxEditorResultIface>;\n // Content-addressed by `artifactKey`; the session service caches artifacts in\n // agent.sandbox_artifacts and calls prepare only on a miss.\n artifactKey(ctx: SandboxPrepareContextIface): Promise<string>;\n prepare(ctx: SandboxPrepareContextIface): Promise<Artifact>;\n // `region`: where the backend placed the sandbox (its own region name), so the\n // session service can place the harness near it; null when unknown.\n start(\n ctx: SandboxStartContextIface,\n options: OpenOptions | undefined,\n artifact: Artifact,\n ): Promise<{ handle: SandboxProviderHandleIface<S>; state: State; region?: string | null }>;\n resume(\n ctx: SandboxStartContextIface,\n artifact: Artifact,\n state: State,\n ): Promise<SandboxProviderHandleIface<S>>;\n // Reconnect to an already running backend after host restart for a read-only viewer.\n // Absent: viewers can use a retained live handle but cannot trigger resume.\n resumePassive?(\n ctx: SandboxStartContextIface,\n artifact: Artifact,\n state: State,\n ): Promise<SandboxProviderHandleIface<S>>;\n // Park: pause or stop the sandbox, returning the state resume needs.\n park?(ctx: SandboxStartContextIface, artifact: Artifact, state: State): Promise<State>;\n onSessionEnd?(\n ctx: SandboxStartContextIface,\n artifact: Artifact,\n state: State,\n options: { reason: SandboxSessionEndReason },\n ): Promise<void>;\n}\n\nexport interface SandboxProviderDefinitionIface<\n EnvOptions,\n OpenOptions,\n Artifact extends JsonValue,\n State extends JsonValue,\n S extends NetworkSandboxSessionIface,\n> {\n name: string;\n // The version of `State`'s shape. The session service records it with each\n // binding and refuses to resume a state written under another version (the\n // next call starts the sandbox again instead).\n stateProtocolVersion?: number;\n environment(\n options?: EnvOptions,\n ): SandboxProviderImplementationIface<OpenOptions, Artifact, State, S>;\n}\n\n// A defined provider: the definition plus authoring sugar. `environment(opts)`\n// returns an environment whose `.open(openOptions)` records a sandbox binding\n// target when authored, and is what the session service drives at run time.\nexport interface SandboxProviderIface<\n EnvOptions,\n OpenOptions,\n Artifact extends JsonValue,\n State extends JsonValue,\n S extends NetworkSandboxSessionIface,\n> {\n readonly definition: SandboxProviderDefinitionIface<EnvOptions, OpenOptions, Artifact, State, S>;\n readonly name: string;\n environment(options?: EnvOptions): AwaitableSandboxEnvironmentIface<EnvOptions, OpenOptions>;\n}\n\nexport interface SandboxEnvironmentIface<EnvOptions, OpenOptions> {\n readonly providerName: string;\n readonly options: EnvOptions | undefined;\n // Provider-authored notices shown by the compiler and Build before publication.\n readonly authoringWarnings?: readonly string[];\n // Authoring: records the open options (access, ...) for this target.\n open(options?: OpenOptions): SandboxOpenRequestIface<EnvOptions, OpenOptions>;\n}\n\n// An environment whose open request a sandbox.ts selector can await to get\n// the live session (open-scope.ts); what defineSandboxProvider and the\n// installed helpers return.\nexport interface AwaitableSandboxEnvironmentIface<\n EnvOptions,\n OpenOptions,\n> extends SandboxEnvironmentIface<EnvOptions, OpenOptions> {\n open(options?: OpenOptions): AwaitableSandboxOpenRequestIface<EnvOptions, OpenOptions>;\n}\n\nexport interface SandboxOpenRequestIface<EnvOptions, OpenOptions> {\n readonly providerName: string;\n readonly environmentOptions: EnvOptions | undefined;\n readonly openOptions: OpenOptions | undefined;\n readonly authoringWarnings?: readonly string[];\n}\n\nexport const defineSandboxProvider = <\n EnvOptions,\n OpenOptions,\n Artifact extends JsonValue,\n State extends JsonValue,\n S extends NetworkSandboxSessionIface,\n>(\n definition: SandboxProviderDefinitionIface<EnvOptions, OpenOptions, Artifact, State, S>,\n): SandboxProviderIface<EnvOptions, OpenOptions, Artifact, State, S> => ({\n definition,\n name: definition.name,\n environment: (options) => ({\n providerName: definition.name,\n options,\n open: (openOptions) =>\n awaitableOpenRequest({\n providerName: definition.name,\n environmentOptions: options,\n openOptions,\n }),\n }),\n});\n\n// Erased form the session service stores in its provider registry.\nexport type AnySandboxProviderIface = SandboxProviderIface<\n JsonValue,\n JsonValue,\n JsonValue,\n JsonValue,\n NetworkSandboxSessionIface\n>;\n\n// Events emitted through a sandbox provider's process lifecycle.\nexport enum SandboxEventKind {\n ProcessExited = 'process_exited',\n}\n"],
|
|
5
|
-
"mappings": "AAQA,SAAS,4BAAmE;AAoCrE,IAAK,mBAAL,kBAAKA,sBAAL;AACL,EAAAA,kBAAA,UAAO;AACP,EAAAA,kBAAA,eAAY;AACZ,EAAAA,kBAAA,aAAU;AACV,EAAAA,kBAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;
|
|
4
|
+
"sourcesContent": ["import type { HostedBindingsIface } from \"../hosted-bindings.mjs\";\nimport type {\n ProcessInspectionRequestIface,\n ProcessInspectionResultIface,\n} from '@finalai/agent-protocol/process-inspection';\nimport type { JsonValue } from \"../json.mjs\";\nimport type { ToolDescriptorIface } from \"../manifest.mjs\";\nimport type { SandboxEditorRequestIface, SandboxEditorResultIface } from \"./editor.mjs\";\nimport { awaitableOpenRequest, type AwaitableSandboxOpenRequestIface } from \"./open-scope.mjs\";\nimport type { SandboxSnapshotRequestIface, SandboxSnapshotResponseIface } from \"./snapshots.mjs\";\n\n// Sandbox providers and consumers share the streaming session contract.\n\nexport interface AbortableIface {\n abortSignal?: AbortSignal;\n}\n\nexport interface SandboxProcessOptionsIface extends AbortableIface {\n command: string;\n args?: string[];\n cwd?: string;\n env?: Record<string, string>;\n // Run through the sandbox's login shell (`bash -lc`) instead of exec'ing.\n shell?: boolean;\n stdin?: ReadableStream<Uint8Array> | string;\n timeoutMs?: number;\n}\n\nexport interface SandboxProcessIface {\n readonly pid: string | null;\n readonly stdout: ReadableStream<Uint8Array>;\n readonly stderr: ReadableStream<Uint8Array>;\n // Writes to the process's stdin; closes stdin when `end` is true.\n write(data: Uint8Array | string, options?: { end?: boolean }): Promise<void>;\n wait(): Promise<{ exitCode: number }>;\n kill(signal?: string): Promise<void>;\n}\n\nexport interface SandboxRunResultIface {\n exitCode: number;\n stdout: string;\n stderr: string;\n}\n\nexport enum SandboxEntryType {\n File = 'file',\n Directory = 'directory',\n Symlink = 'symlink',\n Other = 'other',\n}\n\nexport interface StatIface {\n path: string;\n type: SandboxEntryType;\n size: number;\n modifiedAt: string | null;\n mode: number | null;\n}\n\nexport interface DirEntryIface {\n name: string;\n path: string;\n type: SandboxEntryType;\n size: number | null;\n}\n\nexport interface ConfinedSandboxFilesIface {\n readFile(\n options: { path: string; root: string } & AbortableIface,\n ): Promise<ReadableStream<Uint8Array> | null>;\n stat(options: { path: string; root: string } & AbortableIface): Promise<StatIface | null>;\n readDir(\n options: { path: string; root: string } & AbortableIface,\n ): Promise<DirEntryIface[] | null>;\n}\n\nexport interface SandboxSessionIface {\n readonly description: string;\n readonly confinedFileReader?: ConfinedSandboxFilesIface;\n // On the RPC surface, root confines viewer reads to this directory, rejects\n // symlink ancestors and requires Python 3 in the sandbox (confinedFiles feature).\n readFile(\n options: { path: string; root?: string } & AbortableIface,\n ): Promise<ReadableStream<Uint8Array> | null>;\n readBinaryFile(options: { path: string } & AbortableIface): Promise<Uint8Array | null>;\n readTextFile(\n options: {\n path: string;\n encoding?: string;\n startLine?: number;\n endLine?: number;\n } & AbortableIface,\n ): Promise<string | null>;\n writeFile(\n options: { path: string; content: ReadableStream<Uint8Array> } & AbortableIface,\n ): Promise<void>;\n writeBinaryFile(options: { path: string; content: Uint8Array } & AbortableIface): Promise<void>;\n // Writes create missing parent directories.\n writeTextFile(\n options: { path: string; content: string; encoding?: string } & AbortableIface,\n ): Promise<void>;\n spawn(options: SandboxProcessOptionsIface): Promise<SandboxProcessIface>;\n run(options: SandboxProcessOptionsIface): Promise<SandboxRunResultIface>;\n stat(options: { path: string; root?: string } & AbortableIface): Promise<StatIface | null>;\n readDir(options: { path: string; root?: string } & AbortableIface): Promise<DirEntryIface[]>;\n resolvePath(path: string): string;\n removePath(\n options: { path: string; recursive?: boolean; force?: boolean } & AbortableIface,\n ): Promise<void>;\n}\n\nexport enum NetworkPolicy {\n AllowAll = 'allow-all',\n DenyAll = 'deny-all',\n Allowlist = 'allowlist',\n}\n\nexport interface NetworkPolicyIface {\n mode: NetworkPolicy;\n allow?: string[];\n}\n\nexport enum PortProtocol {\n Http = 'http',\n Https = 'https',\n Ws = 'ws',\n}\n\n// An MCP transport the sandbox serves for an optional capability: an HTTP MCP\n// endpoint the harness (or the session service) can dial.\nexport interface McpEndpointIface {\n name: string;\n url: string;\n headers: Record<string, string>;\n}\n\n// A JSON-RPC message channel to an MCP server the sandbox hosts, for backends\n// whose API reaches it some other way than HTTP MCP (a byte pipe, a socket).\n// Messages are JSON-RPC objects, in order.\nexport interface McpChannelIface {\n send(message: JsonValue, options?: AbortableIface): Promise<void>;\n // The messages that arrived since the last call; [] when none did.\n receive(options?: AbortableIface): Promise<JsonValue[]>;\n close(): Promise<void>;\n}\n\n// An MCP server the sandbox hosts, opened in process by whoever runs the handle.\n// It cannot cross the handle RPC wire.\nexport interface McpChannelEndpointIface {\n name: string;\n connect(options?: AbortableIface): Promise<McpChannelIface>;\n}\n\nexport type SandboxMcpEndpoint = McpEndpointIface | McpChannelEndpointIface;\n\n// The tools of a sandbox's hosted MCP servers, as far as they are known without\n// starting it. Null: unknown until the sandbox is attached and asked.\nexport interface SandboxMcpCatalogIface {\n computerUse: ToolDescriptorIface[] | null;\n // Local MCP server name \u2192 its tools.\n localMcp: Record<string, ToolDescriptorIface[]> | null;\n}\n\nexport const isMcpChannelEndpoint = (\n endpoint: SandboxMcpEndpoint,\n): endpoint is McpChannelEndpointIface => 'connect' in endpoint;\n\nexport interface ScreenOptionsIface {\n // View-only by default; explicit input control requires execute access.\n viewOnly?: boolean;\n}\n\nexport interface ScreenSessionIface {\n // A short-lived viewer grant; providers enforce the requested input access.\n url: string;\n token: string;\n expiresAt: string;\n}\n\nexport interface NetworkSandboxSessionIface extends SandboxSessionIface {\n readonly id: string;\n readonly defaultWorkingDirectory: string;\n readonly ports: readonly number[];\n getPortEndpoint(options: {\n port: number;\n protocol?: PortProtocol;\n }): Promise<{ url: string; headers?: Record<string, string> }>;\n getPortUrl(options: { port: number; protocol?: PortProtocol }): Promise<string>;\n stop(): Promise<void>;\n destroy(): Promise<void>;\n setNetworkPolicy?(policy: NetworkPolicyIface): Promise<void>;\n computerUse?(): Promise<SandboxMcpEndpoint>;\n screen?(options?: ScreenOptionsIface): Promise<ScreenSessionIface>;\n localMcp?(): Promise<SandboxMcpEndpoint[]>;\n}\n\n// Capabilities a started sandbox advertises (and the handle RPC exposes).\nexport enum SandboxCapability {\n Files = 'files',\n Process = 'process',\n Ports = 'ports',\n NetworkPolicy = 'networkPolicy',\n ComputerUse = 'computerUse',\n Screen = 'screen',\n LocalMcp = 'localMcp',\n Browser = 'browser',\n}\n\nexport interface SandboxProviderHandleIface<S extends SandboxSessionIface> {\n readonly sandbox: S;\n onSandboxStop(): Promise<void>;\n onSandboxDelete(options?: { reason?: string }): Promise<void>;\n onRuntimeShutdown(): Promise<void>;\n}\n\n// A saved computer setup guide version: Build's versioned build-\n// and start-time inputs for a sandbox, as the session service serves them.\nexport interface SandboxGuideVersionIface {\n guideId: string;\n versionId: string;\n slug: string;\n title: string;\n number: number;\n image: string;\n // `.final/sandbox-template.yaml` v2 as JSON.\n templateConfig: JsonValue;\n // The start-time parameters this version defaults to.\n defaultParameters: JsonValue;\n instructionsMarkdown: string | null;\n // A ready build from the guide's provider, reusable independently of workspace seeds.\n preparedArtifact?: { providerRef: string; key: string; artifact: JsonValue };\n}\n\n// The organization's computer setup guides, read through the session service.\n// Every provider gets the same reader; a provider whose\n// environments name no guide never calls it.\nexport interface SandboxGuidesIface {\n get(args: { ref: string; version: number | 'latest' }): Promise<SandboxGuideVersionIface | null>;\n // The organization's default guide; null when it has none.\n default(): Promise<SandboxGuideVersionIface | null>;\n}\n\n// Where to clone a repository from, with a short-lived read credential that\n// must reach only the clone process (never a repository's git config).\nexport interface SandboxRepositoryCloneSourceIface {\n url: string;\n // Checked out after the clone; null keeps the default branch.\n ref: string | null;\n // An HTTP Authorization header value for the clone, or null.\n authorization: string | null;\n}\n\n// Repository credentials for the repositories an environment names (a Code\n// Storage id, a GitHub owner/name), resolved by the session service for the\n// session's organization only. Null: not a repository it can resolve.\nexport interface SandboxRepositoriesIface {\n cloneSource(args: {\n repository: string;\n ref: string | null;\n }): Promise<SandboxRepositoryCloneSourceIface | null>;\n}\n\n// Reads a named organization variable (managed in Build) for the session's\n// organization. Values are injected into the sandbox only, never stored in a\n// manifest, a state or the log.\nexport interface SandboxVariablesIface {\n get(name: string): Promise<string | null>;\n}\n\nexport const noSandboxGuides: SandboxGuidesIface = {\n get: async () => null,\n default: async () => null,\n};\n\nexport const noSandboxRepositories: SandboxRepositoriesIface = {\n cloneSource: async () => null,\n};\n\nexport const noSandboxVariables: SandboxVariablesIface = { get: async () => null };\n\n// The user a session acts for: the author of its running turn, else its owner,\n// else the user whose Home its conversation is. A call a person makes through\n// the platform's sandbox viewer acts for that person instead. Null when it acts\n// for no user (a turn nobody prompted in a shared conversation) and outside any\n// session (a guide build). Read on each call, because it changes between turns\n// and between callers.\nexport interface SandboxActingUserIface {\n current(): Promise<string | null>;\n}\n\nexport const noSandboxActingUser: SandboxActingUserIface = { current: async () => null };\n\n// What an environment's pre-start reads (capabilities, mcpCatalog) are given.\nexport interface SandboxOfferContextIface {\n bindings?: HostedBindingsIface;\n organizationId: string;\n actingUser: SandboxActingUserIface;\n}\n\n// What an environment's hooks are given before anything starts.\nexport interface SandboxEnvironmentContextIface {\n bindings?: HostedBindingsIface;\n organizationId: string;\n guides: SandboxGuidesIface;\n}\n\n// Scoped by the host to this organization and provider. Providers can retain\n// reusable intermediate artifacts independently of a revision's seed files.\nexport interface SandboxArtifactsIface {\n get(key: string): Promise<JsonValue | null>;\n put(key: string, artifact: JsonValue): Promise<void>;\n}\n\nexport interface SandboxPreparationSourceIface {\n sourceRevision: string;\n read(): Promise<{ files: Record<string, string>; resources: Record<string, JsonValue> }>;\n}\n\nexport interface SandboxPrepareContextIface {\n bindings?: HostedBindingsIface;\n // A host-persisted resource source; artifacts may retain its identity instead of seed contents.\n preparation?: SandboxPreparationSourceIface;\n artifacts?: SandboxArtifactsIface;\n // Agent revisions supply workspace-relative seeds; setup-guide builds supply\n // guide.json and optional instructions.md. Resources name workspace, skills or guide.\n // Model instructions remain harness config.\n files: Record<string, string>;\n resources: Record<string, JsonValue>;\n sourceRevision: string;\n storagePath: string;\n organizationId: string;\n // The guide inputs (build-time) an environment names, resolved by the platform.\n guides: SandboxGuidesIface;\n // Who the session the artifact is prepared for acts for, for environments that\n // name a backend resource relative to that user; the key must then name it.\n actingUser: SandboxActingUserIface;\n log?: (message: string) => void;\n}\n\nexport interface SandboxStartContextIface {\n bindings?: HostedBindingsIface;\n /** Passive recovery only: never wake, create, seed, or restart backend services. */\n passive?: boolean;\n preparation?: SandboxPreparationSourceIface;\n session: {\n id: string;\n organizationId: string;\n conversationId: string | null;\n definitionId: string;\n bindingId: string;\n target: string;\n };\n storagePath: string;\n // Start-time inputs: guides, the variables to inject, repository credentials.\n guides: SandboxGuidesIface;\n variables: SandboxVariablesIface;\n repositories: SandboxRepositoriesIface;\n actingUser: SandboxActingUserIface;\n // Variables the platform sets in every process of this sandbox: the egress\n // proxy, trust for its CA, and one placeholder per bound secret. Evaluated\n // again for every spawn/run, never once per session: a secret bound\n // mid-session must reach the next command. May resolve to {} (no proxy\n // configured, or not ready yet). Platform values override the spec's env.\n platformEnvironment?: () => Promise<Record<string, string>>;\n // Hosts the sandbox must be able to reach for the proxy to work, to append\n // to any allowlist-mode network policy the spec declares.\n platformEgressHosts?: string[];\n // Files the platform needs in the sandbox before any clone, setup step or\n // service runs: written right after the sandbox exists, on start and resume.\n // Paths are absolute; missing parent directories are created.\n platformFiles?: () => Promise<Record<string, string>>;\n}\n\n// The variables `platformEnvironment` owns. A spec that sets one (as a plain\n// value or an organization variable) is refused at start.\nexport const PLATFORM_ENVIRONMENT_NAMES: ReadonlySet<string> = new Set([\n 'HTTPS_PROXY',\n 'HTTP_PROXY',\n 'NO_PROXY',\n 'NODE_USE_ENV_PROXY',\n 'SSL_CERT_FILE',\n 'CURL_CA_BUNDLE',\n 'REQUESTS_CA_BUNDLE',\n 'GIT_SSL_CAINFO',\n 'CARGO_HTTP_CAINFO',\n 'DENO_CERT',\n 'NODE_EXTRA_CA_CERTS',\n 'FINAL_EGRESS_URL',\n 'FINAL_EGRESS_TOKEN',\n 'GH_TOKEN',\n 'GITHUB_TOKEN',\n]);\n\n// A process's base environment: the spec's variables under the platform's,\n// read again on every call.\nexport const platformProcessEnvironment =\n (\n ctx: Pick<SandboxStartContextIface, 'platformEnvironment'>,\n specEnv: Record<string, string>,\n ): (() => Promise<Record<string, string>>) =>\n async () => ({ ...specEnv, ...(await ctx.platformEnvironment?.()) });\n\n// Writes `platformFiles` into a sandbox that now exists, before it runs anything.\n// Relies on writeTextFile creating missing parent directories.\nexport const writePlatformFiles = async (\n ctx: Pick<SandboxStartContextIface, 'platformFiles'>,\n sandbox: Pick<SandboxSessionIface, 'writeTextFile'>,\n): Promise<void> => {\n for (const [path, content] of Object.entries((await ctx.platformFiles?.()) ?? {}))\n await sandbox.writeTextFile({ path, content });\n};\n\n// An allowlist policy with the platform's egress hosts appended; any other\n// policy unchanged.\nexport const withPlatformEgressHosts = (\n ctx: Pick<SandboxStartContextIface, 'platformEgressHosts'>,\n policy: NetworkPolicyIface,\n): NetworkPolicyIface => {\n const hosts = ctx.platformEgressHosts ?? [];\n if (policy.mode !== NetworkPolicy.Allowlist || hosts.length === 0) return policy;\n return { ...policy, allow: [...new Set([...(policy.allow ?? []), ...hosts])] };\n};\n\nexport enum SandboxSessionEndReason {\n Completed = 'completed',\n Expired = 'expired',\n Failed = 'failed',\n}\n\n// How long an environment's sandbox outlives a session: `session`\n// keeps it for the session's life; `conversation` gives every session in the\n// conversation one shared sandbox per target, surviving session resets;\n// `ephemeral` discards it when released.\nexport enum SandboxWorkspace {\n Session = 'session',\n Conversation = 'conversation',\n Ephemeral = 'ephemeral',\n}\n\nexport interface SandboxProviderImplementationIface<\n OpenOptions,\n Artifact extends JsonValue,\n State extends JsonValue,\n S extends NetworkSandboxSessionIface,\n> {\n // The workspace this environment declares, read before anything starts so the\n // session service knows which sessions share a binding. Absent or null: session.\n workspace?(ctx: SandboxEnvironmentContextIface): Promise<SandboxWorkspace | null>;\n // The capabilities this environment's sandboxes offer, read before anything\n // starts through the backend's own API. Absent or null: unknown\n // until started; local MCP is then not projected.\n capabilities?(ctx: SandboxOfferContextIface): Promise<SandboxCapability[] | null>;\n // The hosted MCP servers' tool catalogs the backend can give without starting\n // a sandbox (from its own records), so the MCP projection lists them from the\n // first `tools/list`. The projection checks a server's catalog against the\n // live server when a call first opens that server (servers a session never\n // uses stay closed) and announces a change with\n // `notifications/tools/list_changed`.\n //\n // Trade-off: a catalog left unknown (absent hook, null, or a null field) can\n // only be learned from the live sandbox, so the first `tools/list` that finds\n // it unknown starts the sandbox in the background, at session start rather\n // than on the first tool call. Otherwise those tools would never be listed,\n // and nothing would ever call them. Providers that can give the catalog keep\n // attach lazy.\n mcpCatalog?(ctx: SandboxOfferContextIface): Promise<SandboxMcpCatalogIface | null>;\n // Reads committed files without starting/resuming a sandbox. Null means the backend\n // is live or offers no snapshot. An unavailable sleeping snapshot must throw,\n // never fall through to a read that wakes it. Pin subsequent ranges by snapshotId.\n readSnapshot?(\n ctx: SandboxOfferContextIface,\n state: State,\n request: SandboxSnapshotRequestIface,\n ): Promise<SandboxSnapshotResponseIface | null>;\n // Inspect retained backend processes without opening, resuming or extending a sandbox.\n // Stop requires execute access; the provider also enforces backend ownership.\n processes?(\n ctx: SandboxOfferContextIface & { bindingId: string },\n state: State,\n request: ProcessInspectionRequestIface,\n ): Promise<ProcessInspectionResultIface>;\n // Browser editor for this provider's existing workspace. The host checks write\n // authorization; this hook never creates or wakes a backend. Credentials stay\n // in the authentication form, never the editor URL or stored provider state.\n editor?(\n ctx: SandboxOfferContextIface,\n state: State,\n request: SandboxEditorRequestIface,\n ): Promise<SandboxEditorResultIface>;\n // Content-addressed by `artifactKey`; the session service caches artifacts in\n // agent.sandbox_artifacts and calls prepare only on a miss.\n artifactKey(ctx: SandboxPrepareContextIface): Promise<string>;\n prepare(ctx: SandboxPrepareContextIface): Promise<Artifact>;\n // `region`: where the backend placed the sandbox (its own region name), so the\n // session service can place the harness near it; null when unknown.\n start(\n ctx: SandboxStartContextIface,\n options: OpenOptions | undefined,\n artifact: Artifact,\n ): Promise<{ handle: SandboxProviderHandleIface<S>; state: State; region?: string | null }>;\n resume(\n ctx: SandboxStartContextIface,\n artifact: Artifact,\n state: State,\n ): Promise<SandboxProviderHandleIface<S>>;\n // Reconnect to an already running backend after host restart for a read-only viewer.\n // Absent: viewers can use a retained live handle but cannot trigger resume.\n resumePassive?(\n ctx: SandboxStartContextIface,\n artifact: Artifact,\n state: State,\n ): Promise<SandboxProviderHandleIface<S>>;\n // Park: pause or stop the sandbox, returning the state resume needs.\n park?(ctx: SandboxStartContextIface, artifact: Artifact, state: State): Promise<State>;\n onSessionEnd?(\n ctx: SandboxStartContextIface,\n artifact: Artifact,\n state: State,\n options: { reason: SandboxSessionEndReason },\n ): Promise<void>;\n}\n\nexport interface SandboxProviderDefinitionIface<\n EnvOptions,\n OpenOptions,\n Artifact extends JsonValue,\n State extends JsonValue,\n S extends NetworkSandboxSessionIface,\n> {\n name: string;\n // The version of `State`'s shape. The session service records it with each\n // binding and refuses to resume a state written under another version (the\n // next call starts the sandbox again instead).\n stateProtocolVersion?: number;\n environment(\n options?: EnvOptions,\n ): SandboxProviderImplementationIface<OpenOptions, Artifact, State, S>;\n}\n\n// A defined provider: the definition plus authoring sugar. `environment(opts)`\n// returns an environment whose `.open(openOptions)` records a sandbox binding\n// target when authored, and is what the session service drives at run time.\nexport interface SandboxProviderIface<\n EnvOptions,\n OpenOptions,\n Artifact extends JsonValue,\n State extends JsonValue,\n S extends NetworkSandboxSessionIface,\n> {\n readonly definition: SandboxProviderDefinitionIface<EnvOptions, OpenOptions, Artifact, State, S>;\n readonly name: string;\n environment(options?: EnvOptions): AwaitableSandboxEnvironmentIface<EnvOptions, OpenOptions>;\n}\n\nexport interface SandboxEnvironmentIface<EnvOptions, OpenOptions> {\n readonly providerName: string;\n readonly options: EnvOptions | undefined;\n // Provider-authored notices shown by the compiler and Build before publication.\n readonly authoringWarnings?: readonly string[];\n // Authoring: records the open options (access, ...) for this target.\n open(options?: OpenOptions): SandboxOpenRequestIface<EnvOptions, OpenOptions>;\n}\n\n// An environment whose open request a sandbox.ts selector can await to get\n// the live session (open-scope.ts); what defineSandboxProvider and the\n// installed helpers return.\nexport interface AwaitableSandboxEnvironmentIface<\n EnvOptions,\n OpenOptions,\n> extends SandboxEnvironmentIface<EnvOptions, OpenOptions> {\n open(options?: OpenOptions): AwaitableSandboxOpenRequestIface<EnvOptions, OpenOptions>;\n}\n\nexport interface SandboxOpenRequestIface<EnvOptions, OpenOptions> {\n readonly providerName: string;\n readonly environmentOptions: EnvOptions | undefined;\n readonly openOptions: OpenOptions | undefined;\n readonly authoringWarnings?: readonly string[];\n}\n\nexport const defineSandboxProvider = <\n EnvOptions,\n OpenOptions,\n Artifact extends JsonValue,\n State extends JsonValue,\n S extends NetworkSandboxSessionIface,\n>(\n definition: SandboxProviderDefinitionIface<EnvOptions, OpenOptions, Artifact, State, S>,\n): SandboxProviderIface<EnvOptions, OpenOptions, Artifact, State, S> => ({\n definition,\n name: definition.name,\n environment: (options) => ({\n providerName: definition.name,\n options,\n open: (openOptions) =>\n awaitableOpenRequest({\n providerName: definition.name,\n environmentOptions: options,\n openOptions,\n }),\n }),\n});\n\n// Erased form the session service stores in its provider registry.\nexport type AnySandboxProviderIface = SandboxProviderIface<\n JsonValue,\n JsonValue,\n JsonValue,\n JsonValue,\n NetworkSandboxSessionIface\n>;\n\n// Events emitted through a sandbox provider's process lifecycle.\nexport enum SandboxEventKind {\n ProcessExited = 'process_exited',\n}\n"],
|
|
5
|
+
"mappings": "AAQA,SAAS,4BAAmE;AAoCrE,IAAK,mBAAL,kBAAKA,sBAAL;AACL,EAAAA,kBAAA,UAAO;AACP,EAAAA,kBAAA,eAAY;AACZ,EAAAA,kBAAA,aAAU;AACV,EAAAA,kBAAA,WAAQ;AAJE,SAAAA;AAAA,GAAA;AAmEL,IAAK,gBAAL,kBAAKC,mBAAL;AACL,EAAAA,eAAA,cAAW;AACX,EAAAA,eAAA,aAAU;AACV,EAAAA,eAAA,eAAY;AAHF,SAAAA;AAAA,GAAA;AAWL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,UAAO;AACP,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,QAAK;AAHK,SAAAA;AAAA,GAAA;AAyCL,MAAM,uBAAuB,CAClC,aACwC,aAAa;AAgChD,IAAK,oBAAL,kBAAKC,uBAAL;AACL,EAAAA,mBAAA,WAAQ;AACR,EAAAA,mBAAA,aAAU;AACV,EAAAA,mBAAA,WAAQ;AACR,EAAAA,m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C,SAAAA;AAAA,GAAA;AAUL,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,aAAU;AACV,EAAAA,kBAAA,kBAAe;AACf,EAAAA,kBAAA,eAAY;AAHF,SAAAA;AAAA,GAAA;AAmJL,MAAM,wBAAwB,CAOnC,gBACuE;AAAA,EACvE;AAAA,EACA,MAAM,WAAW;AAAA,EACjB,aAAa,CAAC,aAAa;AAAA,IACzB,cAAc,WAAW;AAAA,IACzB;AAAA,IACA,MAAM,CAAC,gBACL,qBAAqB;AAAA,MACnB,cAAc,WAAW;AAAA,MACzB,oBAAoB;AAAA,MACpB;AAAA,IACF,CAAC;AAAA,EACL;AACF;AAYO,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,mBAAgB;AADN,SAAAA;AAAA,GAAA;",
|
|
6
6
|
"names": ["SandboxEntryType", "NetworkPolicy", "PortProtocol", "SandboxCapability", "SandboxSessionEndReason", "SandboxWorkspace", "SandboxEventKind"]
|
|
7
7
|
}
|
package/dist/modules/schemas.mjs
CHANGED
|
@@ -42,7 +42,7 @@ const SHARED_SCHEMAS = {
|
|
|
42
42
|
[SCHEMA_IDS.modelPicker]: {
|
|
43
43
|
$id: SCHEMA_IDS.modelPicker,
|
|
44
44
|
title: "Model",
|
|
45
|
-
// The harness
|
|
45
|
+
// The harness or hosting platform supplies reference constraints and picker choices.
|
|
46
46
|
type: "string",
|
|
47
47
|
"x-final-widget": "model-picker"
|
|
48
48
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/schemas.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod';\nimport type { JsonSchema } from \"./json.mjs\";\n\n// Shared JSON Schema fragments harness config schemas may $ref so Build renders\n// the familiar pickers. A harness with none of these\n// fields leaves them out.\n\nexport const SCHEMA_IDS = {\n modelPicker: 'final://schemas/model-picker',\n credentialPolicy: 'final://schemas/credential-policy',\n permissionMode: 'final://schemas/permission-mode',\n instructions: 'final://schemas/instructions',\n skills: 'final://schemas/skills',\n reasoning: 'final://schemas/reasoning',\n secretRef: 'final://schemas/secret-ref',\n} as const;\n\nconst dynamicSlotJsonSchema: JsonSchema = {\n type: 'object',\n required: ['$dynamic'],\n properties: {\n $dynamic: {\n type: 'object',\n required: ['resolver', 'events'],\n properties: {\n resolver: { type: 'string' },\n events: { type: 'array', items: { enum: ['session.started', 'turn.started'] } },\n description: { type: 'string' },\n preview: { type: 'string' },\n },\n },\n },\n};\n\nconst credentialNodeJsonSchema: JsonSchema = {\n type: 'object',\n required: ['kind'],\n properties: {\n kind: { enum: ['subscription', 'api-key', 'platform', 'harness-owned', 'custom'] },\n owner: { enum: ['payer', 'organization'] },\n vendor: { type: 'string' },\n pin: { type: 'string' },\n secret: { type: 'string' },\n baseUrl: { type: 'string', format: 'uri' },\n budget: { type: 'string' },\n resolver: { type: 'string' },\n },\n};\n\nexport const SHARED_SCHEMAS = {\n [SCHEMA_IDS.modelPicker]: {\n $id: SCHEMA_IDS.modelPicker,\n title: 'Model',\n // The harness
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport type { JsonSchema } from \"./json.mjs\";\n\n// Shared JSON Schema fragments harness config schemas may $ref so Build renders\n// the familiar pickers. A harness with none of these\n// fields leaves them out.\n\nexport const SCHEMA_IDS = {\n modelPicker: 'final://schemas/model-picker',\n credentialPolicy: 'final://schemas/credential-policy',\n permissionMode: 'final://schemas/permission-mode',\n instructions: 'final://schemas/instructions',\n skills: 'final://schemas/skills',\n reasoning: 'final://schemas/reasoning',\n secretRef: 'final://schemas/secret-ref',\n} as const;\n\nconst dynamicSlotJsonSchema: JsonSchema = {\n type: 'object',\n required: ['$dynamic'],\n properties: {\n $dynamic: {\n type: 'object',\n required: ['resolver', 'events'],\n properties: {\n resolver: { type: 'string' },\n events: { type: 'array', items: { enum: ['session.started', 'turn.started'] } },\n description: { type: 'string' },\n preview: { type: 'string' },\n },\n },\n },\n};\n\nconst credentialNodeJsonSchema: JsonSchema = {\n type: 'object',\n required: ['kind'],\n properties: {\n kind: { enum: ['subscription', 'api-key', 'platform', 'harness-owned', 'custom'] },\n owner: { enum: ['payer', 'organization'] },\n vendor: { type: 'string' },\n pin: { type: 'string' },\n secret: { type: 'string' },\n baseUrl: { type: 'string', format: 'uri' },\n budget: { type: 'string' },\n resolver: { type: 'string' },\n },\n};\n\nexport const SHARED_SCHEMAS = {\n [SCHEMA_IDS.modelPicker]: {\n $id: SCHEMA_IDS.modelPicker,\n title: 'Model',\n // The harness or hosting platform supplies reference constraints and picker choices.\n type: 'string',\n 'x-final-widget': 'model-picker',\n },\n [SCHEMA_IDS.reasoning]: {\n $id: SCHEMA_IDS.reasoning,\n title: 'Reasoning',\n enum: ['none', 'minimal', 'low', 'medium', 'high', 'max'],\n 'x-final-widget': 'reasoning-picker',\n },\n [SCHEMA_IDS.credentialPolicy]: {\n $id: SCHEMA_IDS.credentialPolicy,\n title: 'Credentials',\n type: 'object',\n required: ['payer', 'tryInOrder'],\n properties: {\n payer: { enum: ['agent-owner', 'organization', 'prompting-user', 'conversation-owner'] },\n tryInOrder: { type: 'array', minItems: 1, items: credentialNodeJsonSchema },\n },\n 'x-final-widget': 'credential-policy',\n },\n [SCHEMA_IDS.permissionMode]: {\n $id: SCHEMA_IDS.permissionMode,\n title: 'Permission mode',\n // The harness supplies the enum of its own modes.\n type: 'string',\n 'x-final-widget': 'permission-mode',\n },\n [SCHEMA_IDS.instructions]: {\n $id: SCHEMA_IDS.instructions,\n title: 'Instructions',\n type: 'array',\n items: {\n anyOf: [\n {\n type: 'object',\n required: ['role', 'content'],\n properties: {\n role: { enum: ['system', 'user'] },\n content: { type: 'string' },\n source: { type: 'string' },\n },\n },\n dynamicSlotJsonSchema,\n ],\n },\n 'x-final-widget': 'instructions',\n },\n [SCHEMA_IDS.skills]: {\n $id: SCHEMA_IDS.skills,\n title: 'Skills',\n type: 'array',\n items: {\n anyOf: [\n {\n type: 'object',\n required: ['key', 'files'],\n properties: {\n key: { type: 'string' },\n description: { type: 'string' },\n files: {\n type: 'array',\n items: {\n type: 'object',\n required: ['path', 'content'],\n properties: { path: { type: 'string' }, content: { type: 'string' } },\n },\n },\n },\n },\n dynamicSlotJsonSchema,\n ],\n },\n 'x-final-widget': 'skills',\n },\n [SCHEMA_IDS.secretRef]: {\n $id: SCHEMA_IDS.secretRef,\n title: 'Secret',\n type: 'object',\n required: ['secretKey'],\n properties: { secretKey: { type: 'string' } },\n 'x-final-widget': 'secret-picker',\n },\n} satisfies Record<string, JsonSchema>;\n\n// Which shared fragments a config schema references at its top level, e.g.\n// to decide whether the directory's instructions/skills apply to a harness.\nconst fieldRefSchema = z.object({ $ref: z.string().startsWith('final://schemas/') });\nconst propertiesSchema = z.object({ properties: z.record(z.string(), z.json()) });\n\nexport interface SharedSchemaReferencesIface {\n [field: string]: string;\n}\n\nexport const referencedSharedSchemas = (configSchema: JsonSchema): SharedSchemaReferencesIface => {\n const parsed = propertiesSchema.safeParse(configSchema);\n const out: SharedSchemaReferencesIface = {};\n if (!parsed.success) return out;\n for (const [field, fieldSchema] of Object.entries(parsed.data.properties)) {\n const ref = fieldRefSchema.safeParse(fieldSchema);\n if (ref.success) out[field] = ref.data.$ref;\n }\n return out;\n};\n"],
|
|
5
5
|
"mappings": "AAAA,YAAY,OAAO;AAOZ,MAAM,aAAa;AAAA,EACxB,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AACb;AAEA,MAAM,wBAAoC;AAAA,EACxC,MAAM;AAAA,EACN,UAAU,CAAC,UAAU;AAAA,EACrB,YAAY;AAAA,IACV,UAAU;AAAA,MACR,MAAM;AAAA,MACN,UAAU,CAAC,YAAY,QAAQ;AAAA,MAC/B,YAAY;AAAA,QACV,UAAU,EAAE,MAAM,SAAS;AAAA,QAC3B,QAAQ,EAAE,MA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SAAS,GAAG;AAAA,IACtB,KAAK,WAAW;AAAA,IAChB,OAAO;AAAA,IACP,MAAM;AAAA,IACN,UAAU,CAAC,WAAW;AAAA,IACtB,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,EAAE;AAAA,IAC5C,kBAAkB;AAAA,EACpB;AACF;AAIA,MAAM,iBAAiB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,kBAAkB,EAAE,CAAC;AACnF,MAAM,mBAAmB,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC;AAMzE,MAAM,0BAA0B,CAAC,iBAA0D;AAChG,QAAM,SAAS,iBAAiB,UAAU,YAAY;AACtD,QAAM,MAAmC,CAAC;AAC1C,MAAI,CAAC,OAAO,QAAS,QAAO;AAC5B,aAAW,CAAC,OAAO,WAAW,KAAK,OAAO,QAAQ,OAAO,KAAK,UAAU,GAAG;AACzE,UAAM,MAAM,eAAe,UAAU,WAAW;AAChD,QAAI,IAAI,QAAS,KAAI,KAAK,IAAI,IAAI,KAAK;AAAA,EACzC;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finalai/agent-provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provider contracts for the agent stack: harnesses, sandboxes (handle, wire, MCP projection), channels, credential policies, and the conformance kit.",
|
|
6
6
|
"license": "Apache-2.0",
|