@finalai/agent-definition 0.5.0 → 0.6.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.
Files changed (93) hide show
  1. package/HOSTING.md +7 -7
  2. package/THIRD_PARTY_NOTICES.md +1 -1
  3. package/dist/compiler-assets/{chunk-FU5VHNO4.ts → chunk-3R7MNW5L.ts} +1 -1
  4. package/dist/compiler-assets/{chunk-7KPWSOMK.ts → chunk-3SDZJK7K.ts} +1 -1
  5. package/dist/compiler-assets/{chunk-KTXTYIF4.ts → chunk-4A4EQHYK.ts} +57 -20
  6. package/dist/compiler-assets/{chunk-S5ON7OBR.ts → chunk-4MJF3ALN.ts} +5 -5
  7. package/dist/compiler-assets/{chunk-QVHDGZAN.ts → chunk-4T2URCJZ.ts} +2 -2
  8. package/dist/compiler-assets/{chunk-7MDGEPFT.ts → chunk-6K3WO73F.ts} +1 -1
  9. package/dist/compiler-assets/{chunk-KMBQVNAJ.ts → chunk-AMYJRTAC.ts} +3 -3
  10. package/dist/compiler-assets/{chunk-OVAUXBQU.ts → chunk-BHNF7BEJ.ts} +86 -17
  11. package/dist/compiler-assets/{chunk-L7E6UQX3.ts → chunk-CORCFNEY.ts} +3 -3
  12. package/dist/compiler-assets/{chunk-4ERFBLH7.ts → chunk-DRHDNSCQ.ts} +4 -4
  13. package/dist/compiler-assets/{chunk-O3JKMLDP.ts → chunk-EKR4AEM5.ts} +3 -3
  14. package/dist/compiler-assets/{chunk-YOE37BRR.ts → chunk-FE7PIPSW.ts} +57 -10
  15. package/dist/compiler-assets/{chunk-V5E4RKG6.ts → chunk-FFI2K5IJ.ts} +4 -4
  16. package/dist/compiler-assets/{chunk-36MVFRMA.ts → chunk-IZJMGIAH.ts} +2 -2
  17. package/dist/compiler-assets/{chunk-KTBNDKGJ.ts → chunk-JZTF36V2.ts} +2 -1
  18. package/dist/compiler-assets/{chunk-XJNO7EHQ.ts → chunk-KNYB36DW.ts} +2 -2
  19. package/dist/compiler-assets/{chunk-TFPXCL5W.ts → chunk-L7YJCQVB.ts} +4 -4
  20. package/dist/compiler-assets/{chunk-WJPAUIVM.ts → chunk-LGGJ6S3U.ts} +1 -1
  21. package/dist/compiler-assets/{chunk-JW4Y5OAP.ts → chunk-LIRONA4O.ts} +6 -6
  22. package/dist/compiler-assets/{chunk-ZICJVGG7.ts → chunk-MM4JCZSK.ts} +7 -7
  23. package/dist/compiler-assets/{chunk-VI5WBWUX.ts → chunk-MPZMRU56.ts} +4 -4
  24. package/dist/compiler-assets/chunk-PLQKTBKO.ts +27 -0
  25. package/dist/compiler-assets/{chunk-GOIK7WNT.ts → chunk-Q26ZPNVB.ts} +31 -12
  26. package/dist/compiler-assets/{chunk-Z7HGOUC2.ts → chunk-RTC7AJBS.ts} +1 -1
  27. package/dist/compiler-assets/{chunk-OX46N5EP.ts → chunk-TCXQ4GLM.ts} +1 -1
  28. package/dist/compiler-assets/{chunk-R4IHPPTB.ts → chunk-UUQAHJRT.ts} +2 -2
  29. package/dist/compiler-assets/{chunk-KNFPKVUS.ts → chunk-XCX6VAK7.ts} +1 -1
  30. package/dist/compiler-assets/{chunk-OBFQTLWC.ts → chunk-Y73DOSSB.ts} +3 -3
  31. package/dist/compiler-assets/{chunk-2LYL3UFK.ts → chunk-YAO6DUQO.ts} +4 -4
  32. package/dist/compiler-assets/src/authoring/agent.ts +4 -4
  33. package/dist/compiler-assets/src/authoring/approval.ts +7 -7
  34. package/dist/compiler-assets/src/authoring/brand.ts +3 -3
  35. package/dist/compiler-assets/src/authoring/channels.ts +6 -8
  36. package/dist/compiler-assets/src/authoring/connections.ts +11 -11
  37. package/dist/compiler-assets/src/authoring/credentials.ts +7 -7
  38. package/dist/compiler-assets/src/authoring/dynamic.ts +8 -8
  39. package/dist/compiler-assets/src/authoring/harness.ts +9 -9
  40. package/dist/compiler-assets/src/authoring/hooks.ts +10 -10
  41. package/dist/compiler-assets/src/authoring/index.ts +27 -26
  42. package/dist/compiler-assets/src/authoring/instructions.ts +9 -9
  43. package/dist/compiler-assets/src/authoring/sandbox.ts +11 -11
  44. package/dist/compiler-assets/src/authoring/schedules.ts +4 -4
  45. package/dist/compiler-assets/src/authoring/skills.ts +4 -4
  46. package/dist/compiler-assets/src/authoring/tools.ts +9 -9
  47. package/dist/compiler-assets/src/compatibility.ts +6 -6
  48. package/dist/compiler-assets/src/hosted-bindings.ts +6 -6
  49. package/dist/compiler-assets/src/index.ts +30 -27
  50. package/dist/compiler-assets/src/manifest.ts +6 -4
  51. package/dist/compiler-assets/src/resolve.ts +5 -5
  52. package/dist/compiler-assets/src/runtime/bundle.ts +17 -18
  53. package/dist/compiler-assets/src/runtime/describe.ts +14 -14
  54. package/dist/compiler-assets/src/runtime/described.ts +28 -16
  55. package/dist/compiler-assets/src/runtime/isolate.ts +16 -17
  56. package/dist/compiler-assets/src/runtime/lower.ts +13 -13
  57. package/dist/compiler-assets/src/runtime/schema-validation.ts +4 -4
  58. package/dist/compiler-assets/src/runtime/values.ts +2 -2
  59. package/dist/modules/authoring/agent.d.mts +25 -1
  60. package/dist/modules/authoring/agent.mjs.map +2 -2
  61. package/dist/modules/authoring/brand.d.mts +1 -0
  62. package/dist/modules/authoring/brand.mjs +1 -0
  63. package/dist/modules/authoring/brand.mjs.map +2 -2
  64. package/dist/modules/authoring/channels.d.mts +13 -96
  65. package/dist/modules/authoring/channels.mjs +6 -52
  66. package/dist/modules/authoring/channels.mjs.map +3 -3
  67. package/dist/modules/authoring/index.d.mts +1 -1
  68. package/dist/modules/authoring/index.mjs +2 -0
  69. package/dist/modules/authoring/index.mjs.map +2 -2
  70. package/dist/modules/compiler/assemble.d.mts +0 -4
  71. package/dist/modules/compiler/assemble.mjs +55 -23
  72. package/dist/modules/compiler/assemble.mjs.map +2 -2
  73. package/dist/modules/compiler/bundle.mjs.map +1 -1
  74. package/dist/modules/compiler/index.d.mts +1 -4
  75. package/dist/modules/compiler/index.mjs +4 -3
  76. package/dist/modules/compiler/index.mjs.map +2 -2
  77. package/dist/modules/manifest.d.mts +2 -2
  78. package/dist/modules/manifest.mjs +2 -0
  79. package/dist/modules/manifest.mjs.map +2 -2
  80. package/dist/modules/runtime/describe.mjs +49 -2
  81. package/dist/modules/runtime/describe.mjs.map +2 -2
  82. package/dist/modules/runtime/described.d.mts +94 -3
  83. package/dist/modules/runtime/described.mjs +14 -2
  84. package/dist/modules/runtime/described.mjs.map +2 -2
  85. package/dist/modules/runtime/isolate.d.mts +3 -2
  86. package/dist/modules/runtime/isolate.mjs +2 -0
  87. package/dist/modules/runtime/isolate.mjs.map +2 -2
  88. package/fixtures/release-scout/agent/channels/github.ts +2 -38
  89. package/fixtures/release-scout/agent/hooks/audit.ts +1 -1
  90. package/fixtures/release-scout/agent/instructions/org-context.ts +1 -1
  91. package/package.json +4 -4
  92. package/dist/compiler-assets/chunk-ISYIPH2T.ts +0 -120
  93. package/dist/compiler-assets/chunk-JRKGCYWA.ts +0 -87
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/compiler/bundle.ts"],
4
- "sourcesContent": ["import { build, transform, type Loader, type Message, type Plugin } from 'esbuild';\nimport { createHash } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { readFile, realpath } from 'node:fs/promises';\nimport { isBuiltin } from 'node:module';\nimport { dirname, isAbsolute, posix, relative, resolve } from 'node:path';\nimport * as z from 'zod';\nimport type { LayoutModuleIface } from \"../runtime/layout.mjs\";\nimport { MAX_FILE_BYTES, preparationFiles } from \"./files.mjs\";\nimport {\n packageEntry,\n packageImportTarget,\n splitSpecifier,\n type VendoredPackageIface,\n} from \"./packages.mjs\";\n\n// Where this package's sources live. The compiler bundles authored code against\n// the authoring modules as source, so a host that runs the compiler from a\n// bundle (agent-session-service) passes the installed package's root.\nconst packedAssets = resolve(import.meta.dirname, '..', '..', 'compiler-assets');\nexport const DEFAULT_packageRoot = existsSync(packedAssets)\n ? packedAssets\n : resolve(import.meta.dirname, '..', '..');\n\ninterface CompilerAssetsIface {\n packageRoot: string;\n bundleRuntime: string;\n // Import specifiers authored code uses for the authoring API.\n aliases: Map<string, string>;\n}\n\nconst compilerAssets = (packageRoot: string): CompilerAssetsIface => {\n const src = resolve(packageRoot, 'src');\n const authoring = resolve(src, 'authoring');\n return {\n packageRoot,\n bundleRuntime: resolve(src, 'runtime', 'bundle.ts'),\n aliases: new Map<string, string>(\n Object.entries({\n '@finalai/agents': resolve(authoring, 'index.ts'),\n '@finalai/agents/instructions': resolve(authoring, 'instructions.ts'),\n '@finalai/agents/approval': resolve(authoring, 'approval.ts'),\n '@finalai/agents/hooks': resolve(authoring, 'hooks.ts'),\n '@finalai/agents/tools': resolve(authoring, 'tools.ts'),\n '@finalai/agents/channels': resolve(authoring, 'channels.ts'),\n // Final's sandbox helpers are pure, so authored code bundles the provider\n // package's own module (as it does a vendor package's), never a copy.\n '@finalai/agent-definition': resolve(src, 'index.ts'),\n '@finalai/agent-definition/authoring': resolve(authoring, 'index.ts'),\n '@finalai/agent-definition/instructions': resolve(authoring, 'instructions.ts'),\n '@finalai/agent-definition/approval': resolve(authoring, 'approval.ts'),\n '@finalai/agent-definition/hooks': resolve(authoring, 'hooks.ts'),\n '@finalai/agent-definition/tools': resolve(authoring, 'tools.ts'),\n '@finalai/agent-definition/channels': resolve(authoring, 'channels.ts'),\n '@finalai/agent-definition/manifest': resolve(src, 'manifest.ts'),\n }),\n ),\n };\n};\n\nconst SOURCE_NAMESPACE = 'agent-source';\nconst SOURCE_PREFIX = `${SOURCE_NAMESPACE}:`;\n// Vendored workspace packages: `<package name>:<package-relative path>`.\nconst PACKAGE_NAMESPACE = 'agent-package';\n\nconst packagePath = (name: string, file: string): string => `${name}:${file}`;\n\ninterface PackageFileIface {\n name: string;\n file: string;\n}\n\nconst splitPackagePath = (path: string): PackageFileIface => {\n const index = path.indexOf(':');\n return { name: path.slice(0, index), file: path.slice(index + 1) };\n};\n\nconst LOADERS = new Map<string, Loader>(\n Object.entries({\n '.ts': 'ts',\n '.mts': 'ts',\n '.cts': 'ts',\n '.tsx': 'tsx',\n '.js': 'js',\n '.mjs': 'js',\n '.cjs': 'js',\n '.jsx': 'jsx',\n '.json': 'json',\n '.md': 'text',\n '.txt': 'text',\n }),\n);\n\n// esbuild rejects a failed build with its messages attached.\nconst buildFailureSchema = z.object({\n errors: z.array(z.custom<Message>((value) => value instanceof Object)),\n});\n\nconst RESOLVE_EXTENSIONS = [\n '',\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n '.json',\n '/index.ts',\n '/index.tsx',\n '/index.mts',\n '/index.cts',\n '/index.js',\n '/index.jsx',\n '/index.mjs',\n '/index.cjs',\n];\n\nexport interface BundleInputIface {\n files: Record<string, string>;\n layout: LayoutModuleIface[];\n // Real directory of the sources, for resolving packages they import; null\n // for file maps (packages then resolve from this package's dependencies).\n root: string | null;\n // This package's installed root; defaults to the source checkout.\n packageRoot?: string;\n // Workspace packages the agent imports, by package name (packages.ts).\n packages?: Record<string, VendoredPackageIface>;\n // Authoring modules of provider packages the host installed, by import\n // specifier (CompileOptionsIface.providerModules).\n providerModules?: Readonly<Record<string, string>>;\n}\n\nexport interface BundleProblemIface {\n path: string | null;\n message: string;\n builtin: boolean;\n}\n\nexport interface BundleOutputIface {\n code: string | null;\n hash: string | null;\n problems: BundleProblemIface[];\n}\n\nconst resolveVirtual = (\n files: Record<string, string>,\n fromDir: string,\n specifier: string,\n): string | null => {\n const joined = posix.normalize(posix.join(fromDir, specifier));\n if (joined === '..' || joined.startsWith('../') || joined.startsWith('/')) return null;\n const candidates = [joined];\n // TypeScript's convention: `./x.js` names `x.ts` (`.mjs` \u2192 `.mts`, `.cjs` \u2192 `.cts`).\n if (/\\.jsx?$/.test(joined)) {\n const stem = joined.replace(/\\.jsx?$/, '');\n candidates.push(`${stem}.ts`, `${stem}.tsx`);\n } else if (joined.endsWith('.mjs')) candidates.push(joined.replace(/\\.mjs$/, '.mts'));\n else if (joined.endsWith('.cjs')) candidates.push(joined.replace(/\\.cjs$/, '.cts'));\n for (const candidate of candidates) {\n for (const extension of RESOLVE_EXTENSIONS) {\n const path = `${candidate}${extension}`;\n if (Object.hasOwn(files, path)) return path;\n }\n }\n return null;\n};\n\nconst escapes = (fromDir: string, specifier: string): boolean => {\n const joined = posix.normalize(posix.join(fromDir, specifier));\n return joined === '..' || joined.startsWith('../');\n};\n\nconst withinDependency = async (args: {\n specifier: string;\n path: string;\n resolveDir: string;\n packageRoot: string;\n}): Promise<boolean> => {\n const segments = args.specifier.split('/');\n const name = segments[0]?.startsWith('@') ? segments.slice(0, 2).join('/') : segments[0];\n if (name == null || name.length === 0) return false;\n const candidates = [resolve(args.packageRoot, 'node_modules', name)];\n let directory = args.resolveDir;\n for (;;) {\n candidates.push(resolve(directory, 'node_modules', name));\n // Node also resolves a package's own name from inside that package.\n const self = await readFile(resolve(directory, 'package.json'), 'utf8')\n .then((text) => z.object({ name: z.string() }).parse(JSON.parse(text)))\n .catch(() => null);\n if (self?.name === name) candidates.push(directory);\n const parent = dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n const path = await realpath(args.path).catch(() => null);\n if (path == null) return false;\n for (const candidate of candidates) {\n // pnpm workspace dependencies resolve to their source directory through a symlink.\n const root = await realpath(candidate).catch(() => null);\n if (root == null) continue;\n const distance = relative(root, path);\n if (!isAbsolute(distance) && distance !== '..' && !distance.startsWith('../')) return true;\n }\n return false;\n};\n\nconst entrySource = (layout: LayoutModuleIface[], bundleRuntime: string): string => {\n const imports = layout.map(\n (entry, index) =>\n `import * as m${index} from ${JSON.stringify(`${SOURCE_PREFIX}${entry.path}`)};`,\n );\n return [\n ...imports,\n `import { createAgentBundle } from ${JSON.stringify(bundleRuntime)};`,\n `const bundle = createAgentBundle({ layout: ${JSON.stringify(layout)}, namespaces: [${layout.map((_, index) => `m${index}`).join(', ')}] });`,\n 'export const modules = bundle.modules;',\n 'export const runtime = bundle.runtime;',\n 'export const __describe = bundle.describe;',\n ].join('\\n');\n};\n\nconst formatMessage = (message: Message): BundleProblemIface => {\n const location = message.location;\n const file = location?.file ?? null;\n const path =\n file == null ? null : file.startsWith(SOURCE_PREFIX) ? file.slice(SOURCE_PREFIX.length) : file;\n const text = message.text;\n return {\n path,\n message: location == null ? text : `${text} (${path ?? 'bundle'}:${location.line})`,\n builtin: false,\n };\n};\n\n// Bundles every authored module, the authoring API and the bundle runtime\n// into one ESM module for the Worker isolate. Node built-ins are rejected.\nexport const bundleAgent = async (input: BundleInputIface): Promise<BundleOutputIface> => {\n const assets = compilerAssets(input.packageRoot ?? DEFAULT_packageRoot);\n const packageRoot = assets.packageRoot;\n const builtinImports: { importer: string; path: string }[] = [];\n const outsideImports: string[] = [];\n const sourcePlugin: Plugin = {\n name: 'agent-sources',\n setup: (api) => {\n api.onResolve({ filter: /.*/ }, async (args) => {\n const specifier = args.path;\n if (args.pluginData === 'final-resolving') return null;\n if (specifier.startsWith(SOURCE_PREFIX)) {\n return { path: specifier.slice(SOURCE_PREFIX.length), namespace: SOURCE_NAMESPACE };\n }\n const fromSource = args.namespace === SOURCE_NAMESPACE;\n const importer =\n fromSource || args.namespace === PACKAGE_NAMESPACE\n ? args.importer\n : posix.relative(packageRoot, args.importer);\n if (isBuiltin(specifier)) {\n builtinImports.push({ importer, path: specifier });\n return { path: specifier, external: true };\n }\n const alias =\n (Object.hasOwn(input.providerModules ?? {}, specifier)\n ? input.providerModules?.[specifier]\n : undefined) ?? assets.aliases.get(specifier);\n // A re-exporting authoring module reaches the provider's canonical package.\n if (alias != null && alias !== args.importer) return { path: alias };\n const fromPackage = args.namespace === PACKAGE_NAMESPACE;\n if (!fromSource && !fromPackage) return null;\n const owner = fromPackage ? splitPackagePath(args.importer) : null;\n const fromDir = posix.dirname(owner?.file ?? args.importer);\n if (specifier.startsWith('#')) {\n const files = owner == null ? input.files : (input.packages?.[owner.name]?.files ?? {});\n const target = packageImportTarget({\n packageJson: files['package.json'],\n specifier: specifier,\n require: args.kind === 'require-call' || args.kind === 'require-resolve',\n });\n if (target == null || !target.startsWith('./') || escapes('', target))\n return {\n errors: [\n {\n text: `Could not resolve package import ${specifier} from ${args.importer}; imports must name source files inside the package`,\n },\n ],\n };\n const resolved = resolveVirtual(files, '', target);\n return resolved == null\n ? {\n errors: [\n { text: `Missing source for package import ${specifier} from ${args.importer}` },\n ],\n }\n : owner == null\n ? { path: resolved, namespace: SOURCE_NAMESPACE }\n : { path: packagePath(owner.name, resolved), namespace: PACKAGE_NAMESPACE };\n }\n if (specifier.startsWith('.') || specifier.startsWith('/')) {\n if (specifier.startsWith('/') || escapes(fromDir, specifier)) {\n outsideImports.push(`${args.importer} imports ${specifier}`);\n return { path: specifier, external: true };\n }\n const ownFiles =\n owner == null ? input.files : (input.packages?.[owner.name]?.files ?? {});\n const resolved = resolveVirtual(ownFiles, fromDir, specifier);\n if (resolved == null) {\n return {\n errors: [\n { text: `Could not resolve ${JSON.stringify(specifier)} from ${args.importer}` },\n ],\n };\n }\n return owner == null\n ? { path: resolved, namespace: SOURCE_NAMESPACE }\n : { path: packagePath(owner.name, resolved), namespace: PACKAGE_NAMESPACE };\n }\n const split = splitSpecifier(specifier);\n const vendored =\n split == null || !Object.hasOwn(input.packages ?? {}, split.name)\n ? undefined\n : input.packages?.[split.name];\n if (split != null && vendored != null && !specifier.split('/').includes('..')) {\n if (vendored.loadError != null) return { errors: [{ text: vendored.loadError }] };\n const entry = packageEntry({\n pkg: vendored,\n subpath: split.subpath,\n require: args.kind === 'require-call' || args.kind === 'require-resolve',\n resolve: (path) => resolveVirtual(vendored.files, '', `./${path}`),\n });\n if (entry.path == null) {\n return {\n errors: [\n {\n text: entry.exported\n ? `${JSON.stringify(specifier)} resolves to ${entry.wanted}, which is not in the repository; workspace packages are compiled from source, so point the package's exports at source files`\n : `${JSON.stringify(specifier)} is not exported by ${split.name} for Workers (its exports name no workerd, worker, browser, import, require or default target)`,\n },\n ],\n };\n }\n return { path: packagePath(split.name, entry.path), namespace: PACKAGE_NAMESPACE };\n }\n if (specifier.includes('\\\\') || specifier.split('/').includes('..')) {\n outsideImports.push(`${args.importer} imports ${specifier}`);\n return { path: specifier, external: true };\n }\n const resolveDir =\n input.root == null || fromPackage ? packageRoot : resolve(input.root, fromDir);\n let result = await api.resolve(specifier, {\n resolveDir,\n kind: args.kind,\n pluginData: 'final-resolving',\n });\n if (result.errors.length > 0 && input.root != null) {\n result = await api.resolve(specifier, {\n resolveDir: packageRoot,\n kind: args.kind,\n pluginData: 'final-resolving',\n });\n }\n if (\n result.errors.length === 0 &&\n !(await withinDependency({\n specifier: specifier,\n path: result.path,\n resolveDir,\n packageRoot,\n }))\n ) {\n outsideImports.push(`${args.importer} imports ${specifier}`);\n return { path: specifier, external: true };\n }\n return result;\n });\n api.onLoad({ filter: /.*/, namespace: PACKAGE_NAMESPACE }, (args) => {\n const { name, file } = splitPackagePath(args.path);\n const contents = input.packages?.[name]?.files[file];\n if (contents == null) return { errors: [{ text: `Missing source ${args.path}` }] };\n if (Buffer.byteLength(contents) > MAX_FILE_BYTES)\n return { errors: [{ text: `${name}/${file} is larger than ${MAX_FILE_BYTES} bytes` }] };\n return {\n contents,\n loader: LOADERS.get(posix.extname(file)) ?? 'text',\n resolveDir: packageRoot,\n };\n });\n api.onLoad({ filter: /.*/, namespace: SOURCE_NAMESPACE }, (args) => {\n const contents = input.files[args.path];\n if (contents == null) return { errors: [{ text: `Missing source ${args.path}` }] };\n if (Buffer.byteLength(contents) > MAX_FILE_BYTES)\n return { errors: [{ text: `${args.path} is larger than ${MAX_FILE_BYTES} bytes` }] };\n const extension = posix.extname(args.path);\n return {\n contents,\n loader: LOADERS.get(extension) ?? 'text',\n resolveDir:\n input.root == null ? packageRoot : resolve(input.root, posix.dirname(args.path)),\n };\n });\n },\n };\n let output;\n try {\n output = await build({\n stdin: {\n contents: entrySource(input.layout, assets.bundleRuntime),\n resolveDir: packageRoot,\n loader: 'ts',\n sourcefile: 'agent-bundle-entry.ts',\n },\n bundle: true,\n write: false,\n format: 'esm',\n platform: 'neutral',\n target: 'es2024',\n mainFields: ['module', 'main'],\n conditions: ['workerd', 'worker', 'browser', 'module'],\n nodePaths: [resolve(packageRoot, 'node_modules')],\n metafile: true,\n minifyWhitespace: true,\n minifySyntax: true,\n legalComments: 'none',\n charset: 'utf8',\n logLevel: 'silent',\n plugins: [sourcePlugin],\n });\n } catch (cause) {\n const failure = buildFailureSchema.safeParse(cause);\n const errors: Message[] = failure.success ? failure.data.errors : [];\n const problems =\n errors.length > 0\n ? errors.map(formatMessage)\n : [\n {\n path: null,\n message: cause instanceof Error ? cause.message : String(cause),\n builtin: false,\n },\n ];\n return { code: null, hash: null, problems };\n }\n const problems: BundleProblemIface[] = outsideImports.map((message) => ({\n path: message.split(' ')[0] ?? null,\n message: `${message}: authored imports must stay inside the agent directory (share code as a package)`,\n builtin: false,\n }));\n const surviving = new Set(\n Object.values(output.metafile.outputs)\n .flatMap((file) => file.imports)\n .filter((entry) => entry.external)\n .map((entry) => entry.path),\n );\n for (const item of builtinImports) {\n if (!surviving.has(item.path)) continue;\n problems.push({\n path: item.importer,\n message: `${item.importer} imports the Node built-in ${item.path}; authored code runs in a Worker isolate (use a sandbox tool for host work)`,\n builtin: true,\n });\n }\n const file = output.outputFiles[0];\n if (file == null)\n return {\n code: null,\n hash: null,\n problems: [\n ...problems,\n { path: null, message: 'esbuild produced no output', builtin: false },\n ],\n };\n // Assign identifiers after graph discovery so concurrent builds produce the same names.\n const minified = await transform(file.text, {\n format: 'esm',\n target: 'es2024',\n minify: true,\n legalComments: 'none',\n charset: 'utf8',\n });\n // Seed resources affect immutable identity even when no runtime code imports them.\n const resources = Object.entries(preparationFiles(input.files)).toSorted(([a], [b]) =>\n a < b ? -1 : a > b ? 1 : 0,\n );\n const sourceHash = createHash('sha256').update(JSON.stringify(resources)).digest('hex');\n const code =\n resources.length === 0\n ? minified.code\n : `${minified.code}\\n// final:sandbox-inputs:${sourceHash}\\n`;\n return {\n code,\n hash: `sha256:${createHash('sha256').update(code).digest('hex')}`,\n problems,\n };\n};\n"],
4
+ "sourcesContent": ["import { build, transform, type Loader, type Message, type Plugin } from 'esbuild';\nimport { createHash } from 'node:crypto';\nimport { existsSync } from 'node:fs';\nimport { readFile, realpath } from 'node:fs/promises';\nimport { isBuiltin } from 'node:module';\nimport { dirname, isAbsolute, posix, relative, resolve } from 'node:path';\nimport * as z from 'zod';\nimport type { LayoutModuleIface } from \"../runtime/layout.mjs\";\nimport { MAX_FILE_BYTES, preparationFiles } from \"./files.mjs\";\nimport {\n packageEntry,\n packageImportTarget,\n splitSpecifier,\n type VendoredPackageIface,\n} from \"./packages.mjs\";\n\n// Where this package's sources live. The compiler bundles authored code against\n// the authoring modules as source, so a host that runs the compiler from a\n// bundle passes the installed package's root.\nconst packedAssets = resolve(import.meta.dirname, '..', '..', 'compiler-assets');\nexport const DEFAULT_packageRoot = existsSync(packedAssets)\n ? packedAssets\n : resolve(import.meta.dirname, '..', '..');\n\ninterface CompilerAssetsIface {\n packageRoot: string;\n bundleRuntime: string;\n // Import specifiers authored code uses for the authoring API.\n aliases: Map<string, string>;\n}\n\nconst compilerAssets = (packageRoot: string): CompilerAssetsIface => {\n const src = resolve(packageRoot, 'src');\n const authoring = resolve(src, 'authoring');\n return {\n packageRoot,\n bundleRuntime: resolve(src, 'runtime', 'bundle.ts'),\n aliases: new Map<string, string>(\n Object.entries({\n '@finalai/agents': resolve(authoring, 'index.ts'),\n '@finalai/agents/instructions': resolve(authoring, 'instructions.ts'),\n '@finalai/agents/approval': resolve(authoring, 'approval.ts'),\n '@finalai/agents/hooks': resolve(authoring, 'hooks.ts'),\n '@finalai/agents/tools': resolve(authoring, 'tools.ts'),\n '@finalai/agents/channels': resolve(authoring, 'channels.ts'),\n // Final's sandbox helpers are pure, so authored code bundles the provider\n // package's own module (as it does a vendor package's), never a copy.\n '@finalai/agent-definition': resolve(src, 'index.ts'),\n '@finalai/agent-definition/authoring': resolve(authoring, 'index.ts'),\n '@finalai/agent-definition/instructions': resolve(authoring, 'instructions.ts'),\n '@finalai/agent-definition/approval': resolve(authoring, 'approval.ts'),\n '@finalai/agent-definition/hooks': resolve(authoring, 'hooks.ts'),\n '@finalai/agent-definition/tools': resolve(authoring, 'tools.ts'),\n '@finalai/agent-definition/channels': resolve(authoring, 'channels.ts'),\n '@finalai/agent-definition/manifest': resolve(src, 'manifest.ts'),\n }),\n ),\n };\n};\n\nconst SOURCE_NAMESPACE = 'agent-source';\nconst SOURCE_PREFIX = `${SOURCE_NAMESPACE}:`;\n// Vendored workspace packages: `<package name>:<package-relative path>`.\nconst PACKAGE_NAMESPACE = 'agent-package';\n\nconst packagePath = (name: string, file: string): string => `${name}:${file}`;\n\ninterface PackageFileIface {\n name: string;\n file: string;\n}\n\nconst splitPackagePath = (path: string): PackageFileIface => {\n const index = path.indexOf(':');\n return { name: path.slice(0, index), file: path.slice(index + 1) };\n};\n\nconst LOADERS = new Map<string, Loader>(\n Object.entries({\n '.ts': 'ts',\n '.mts': 'ts',\n '.cts': 'ts',\n '.tsx': 'tsx',\n '.js': 'js',\n '.mjs': 'js',\n '.cjs': 'js',\n '.jsx': 'jsx',\n '.json': 'json',\n '.md': 'text',\n '.txt': 'text',\n }),\n);\n\n// esbuild rejects a failed build with its messages attached.\nconst buildFailureSchema = z.object({\n errors: z.array(z.custom<Message>((value) => value instanceof Object)),\n});\n\nconst RESOLVE_EXTENSIONS = [\n '',\n '.ts',\n '.tsx',\n '.mts',\n '.cts',\n '.js',\n '.jsx',\n '.mjs',\n '.cjs',\n '.json',\n '/index.ts',\n '/index.tsx',\n '/index.mts',\n '/index.cts',\n '/index.js',\n '/index.jsx',\n '/index.mjs',\n '/index.cjs',\n];\n\nexport interface BundleInputIface {\n files: Record<string, string>;\n layout: LayoutModuleIface[];\n // Real directory of the sources, for resolving packages they import; null\n // for file maps (packages then resolve from this package's dependencies).\n root: string | null;\n // This package's installed root; defaults to the source checkout.\n packageRoot?: string;\n // Workspace packages the agent imports, by package name (packages.ts).\n packages?: Record<string, VendoredPackageIface>;\n // Authoring modules of provider packages the host installed, by import\n // specifier (CompileOptionsIface.providerModules).\n providerModules?: Readonly<Record<string, string>>;\n}\n\nexport interface BundleProblemIface {\n path: string | null;\n message: string;\n builtin: boolean;\n}\n\nexport interface BundleOutputIface {\n code: string | null;\n hash: string | null;\n problems: BundleProblemIface[];\n}\n\nconst resolveVirtual = (\n files: Record<string, string>,\n fromDir: string,\n specifier: string,\n): string | null => {\n const joined = posix.normalize(posix.join(fromDir, specifier));\n if (joined === '..' || joined.startsWith('../') || joined.startsWith('/')) return null;\n const candidates = [joined];\n // TypeScript's convention: `./x.js` names `x.ts` (`.mjs` \u2192 `.mts`, `.cjs` \u2192 `.cts`).\n if (/\\.jsx?$/.test(joined)) {\n const stem = joined.replace(/\\.jsx?$/, '');\n candidates.push(`${stem}.ts`, `${stem}.tsx`);\n } else if (joined.endsWith('.mjs')) candidates.push(joined.replace(/\\.mjs$/, '.mts'));\n else if (joined.endsWith('.cjs')) candidates.push(joined.replace(/\\.cjs$/, '.cts'));\n for (const candidate of candidates) {\n for (const extension of RESOLVE_EXTENSIONS) {\n const path = `${candidate}${extension}`;\n if (Object.hasOwn(files, path)) return path;\n }\n }\n return null;\n};\n\nconst escapes = (fromDir: string, specifier: string): boolean => {\n const joined = posix.normalize(posix.join(fromDir, specifier));\n return joined === '..' || joined.startsWith('../');\n};\n\nconst withinDependency = async (args: {\n specifier: string;\n path: string;\n resolveDir: string;\n packageRoot: string;\n}): Promise<boolean> => {\n const segments = args.specifier.split('/');\n const name = segments[0]?.startsWith('@') ? segments.slice(0, 2).join('/') : segments[0];\n if (name == null || name.length === 0) return false;\n const candidates = [resolve(args.packageRoot, 'node_modules', name)];\n let directory = args.resolveDir;\n for (;;) {\n candidates.push(resolve(directory, 'node_modules', name));\n // Node also resolves a package's own name from inside that package.\n const self = await readFile(resolve(directory, 'package.json'), 'utf8')\n .then((text) => z.object({ name: z.string() }).parse(JSON.parse(text)))\n .catch(() => null);\n if (self?.name === name) candidates.push(directory);\n const parent = dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n const path = await realpath(args.path).catch(() => null);\n if (path == null) return false;\n for (const candidate of candidates) {\n // pnpm workspace dependencies resolve to their source directory through a symlink.\n const root = await realpath(candidate).catch(() => null);\n if (root == null) continue;\n const distance = relative(root, path);\n if (!isAbsolute(distance) && distance !== '..' && !distance.startsWith('../')) return true;\n }\n return false;\n};\n\nconst entrySource = (layout: LayoutModuleIface[], bundleRuntime: string): string => {\n const imports = layout.map(\n (entry, index) =>\n `import * as m${index} from ${JSON.stringify(`${SOURCE_PREFIX}${entry.path}`)};`,\n );\n return [\n ...imports,\n `import { createAgentBundle } from ${JSON.stringify(bundleRuntime)};`,\n `const bundle = createAgentBundle({ layout: ${JSON.stringify(layout)}, namespaces: [${layout.map((_, index) => `m${index}`).join(', ')}] });`,\n 'export const modules = bundle.modules;',\n 'export const runtime = bundle.runtime;',\n 'export const __describe = bundle.describe;',\n ].join('\\n');\n};\n\nconst formatMessage = (message: Message): BundleProblemIface => {\n const location = message.location;\n const file = location?.file ?? null;\n const path =\n file == null ? null : file.startsWith(SOURCE_PREFIX) ? file.slice(SOURCE_PREFIX.length) : file;\n const text = message.text;\n return {\n path,\n message: location == null ? text : `${text} (${path ?? 'bundle'}:${location.line})`,\n builtin: false,\n };\n};\n\n// Bundles every authored module, the authoring API and the bundle runtime\n// into one ESM module for the Worker isolate. Node built-ins are rejected.\nexport const bundleAgent = async (input: BundleInputIface): Promise<BundleOutputIface> => {\n const assets = compilerAssets(input.packageRoot ?? DEFAULT_packageRoot);\n const packageRoot = assets.packageRoot;\n const builtinImports: { importer: string; path: string }[] = [];\n const outsideImports: string[] = [];\n const sourcePlugin: Plugin = {\n name: 'agent-sources',\n setup: (api) => {\n api.onResolve({ filter: /.*/ }, async (args) => {\n const specifier = args.path;\n if (args.pluginData === 'final-resolving') return null;\n if (specifier.startsWith(SOURCE_PREFIX)) {\n return { path: specifier.slice(SOURCE_PREFIX.length), namespace: SOURCE_NAMESPACE };\n }\n const fromSource = args.namespace === SOURCE_NAMESPACE;\n const importer =\n fromSource || args.namespace === PACKAGE_NAMESPACE\n ? args.importer\n : posix.relative(packageRoot, args.importer);\n if (isBuiltin(specifier)) {\n builtinImports.push({ importer, path: specifier });\n return { path: specifier, external: true };\n }\n const alias =\n (Object.hasOwn(input.providerModules ?? {}, specifier)\n ? input.providerModules?.[specifier]\n : undefined) ?? assets.aliases.get(specifier);\n // A re-exporting authoring module reaches the provider's canonical package.\n if (alias != null && alias !== args.importer) return { path: alias };\n const fromPackage = args.namespace === PACKAGE_NAMESPACE;\n if (!fromSource && !fromPackage) return null;\n const owner = fromPackage ? splitPackagePath(args.importer) : null;\n const fromDir = posix.dirname(owner?.file ?? args.importer);\n if (specifier.startsWith('#')) {\n const files = owner == null ? input.files : (input.packages?.[owner.name]?.files ?? {});\n const target = packageImportTarget({\n packageJson: files['package.json'],\n specifier: specifier,\n require: args.kind === 'require-call' || args.kind === 'require-resolve',\n });\n if (target == null || !target.startsWith('./') || escapes('', target))\n return {\n errors: [\n {\n text: `Could not resolve package import ${specifier} from ${args.importer}; imports must name source files inside the package`,\n },\n ],\n };\n const resolved = resolveVirtual(files, '', target);\n return resolved == null\n ? {\n errors: [\n { text: `Missing source for package import ${specifier} from ${args.importer}` },\n ],\n }\n : owner == null\n ? { path: resolved, namespace: SOURCE_NAMESPACE }\n : { path: packagePath(owner.name, resolved), namespace: PACKAGE_NAMESPACE };\n }\n if (specifier.startsWith('.') || specifier.startsWith('/')) {\n if (specifier.startsWith('/') || escapes(fromDir, specifier)) {\n outsideImports.push(`${args.importer} imports ${specifier}`);\n return { path: specifier, external: true };\n }\n const ownFiles =\n owner == null ? input.files : (input.packages?.[owner.name]?.files ?? {});\n const resolved = resolveVirtual(ownFiles, fromDir, specifier);\n if (resolved == null) {\n return {\n errors: [\n { text: `Could not resolve ${JSON.stringify(specifier)} from ${args.importer}` },\n ],\n };\n }\n return owner == null\n ? { path: resolved, namespace: SOURCE_NAMESPACE }\n : { path: packagePath(owner.name, resolved), namespace: PACKAGE_NAMESPACE };\n }\n const split = splitSpecifier(specifier);\n const vendored =\n split == null || !Object.hasOwn(input.packages ?? {}, split.name)\n ? undefined\n : input.packages?.[split.name];\n if (split != null && vendored != null && !specifier.split('/').includes('..')) {\n if (vendored.loadError != null) return { errors: [{ text: vendored.loadError }] };\n const entry = packageEntry({\n pkg: vendored,\n subpath: split.subpath,\n require: args.kind === 'require-call' || args.kind === 'require-resolve',\n resolve: (path) => resolveVirtual(vendored.files, '', `./${path}`),\n });\n if (entry.path == null) {\n return {\n errors: [\n {\n text: entry.exported\n ? `${JSON.stringify(specifier)} resolves to ${entry.wanted}, which is not in the repository; workspace packages are compiled from source, so point the package's exports at source files`\n : `${JSON.stringify(specifier)} is not exported by ${split.name} for Workers (its exports name no workerd, worker, browser, import, require or default target)`,\n },\n ],\n };\n }\n return { path: packagePath(split.name, entry.path), namespace: PACKAGE_NAMESPACE };\n }\n if (specifier.includes('\\\\') || specifier.split('/').includes('..')) {\n outsideImports.push(`${args.importer} imports ${specifier}`);\n return { path: specifier, external: true };\n }\n const resolveDir =\n input.root == null || fromPackage ? packageRoot : resolve(input.root, fromDir);\n let result = await api.resolve(specifier, {\n resolveDir,\n kind: args.kind,\n pluginData: 'final-resolving',\n });\n if (result.errors.length > 0 && input.root != null) {\n result = await api.resolve(specifier, {\n resolveDir: packageRoot,\n kind: args.kind,\n pluginData: 'final-resolving',\n });\n }\n if (\n result.errors.length === 0 &&\n !(await withinDependency({\n specifier: specifier,\n path: result.path,\n resolveDir,\n packageRoot,\n }))\n ) {\n outsideImports.push(`${args.importer} imports ${specifier}`);\n return { path: specifier, external: true };\n }\n return result;\n });\n api.onLoad({ filter: /.*/, namespace: PACKAGE_NAMESPACE }, (args) => {\n const { name, file } = splitPackagePath(args.path);\n const contents = input.packages?.[name]?.files[file];\n if (contents == null) return { errors: [{ text: `Missing source ${args.path}` }] };\n if (Buffer.byteLength(contents) > MAX_FILE_BYTES)\n return { errors: [{ text: `${name}/${file} is larger than ${MAX_FILE_BYTES} bytes` }] };\n return {\n contents,\n loader: LOADERS.get(posix.extname(file)) ?? 'text',\n resolveDir: packageRoot,\n };\n });\n api.onLoad({ filter: /.*/, namespace: SOURCE_NAMESPACE }, (args) => {\n const contents = input.files[args.path];\n if (contents == null) return { errors: [{ text: `Missing source ${args.path}` }] };\n if (Buffer.byteLength(contents) > MAX_FILE_BYTES)\n return { errors: [{ text: `${args.path} is larger than ${MAX_FILE_BYTES} bytes` }] };\n const extension = posix.extname(args.path);\n return {\n contents,\n loader: LOADERS.get(extension) ?? 'text',\n resolveDir:\n input.root == null ? packageRoot : resolve(input.root, posix.dirname(args.path)),\n };\n });\n },\n };\n let output;\n try {\n output = await build({\n stdin: {\n contents: entrySource(input.layout, assets.bundleRuntime),\n resolveDir: packageRoot,\n loader: 'ts',\n sourcefile: 'agent-bundle-entry.ts',\n },\n bundle: true,\n write: false,\n format: 'esm',\n platform: 'neutral',\n target: 'es2024',\n mainFields: ['module', 'main'],\n conditions: ['workerd', 'worker', 'browser', 'module'],\n nodePaths: [resolve(packageRoot, 'node_modules')],\n metafile: true,\n minifyWhitespace: true,\n minifySyntax: true,\n legalComments: 'none',\n charset: 'utf8',\n logLevel: 'silent',\n plugins: [sourcePlugin],\n });\n } catch (cause) {\n const failure = buildFailureSchema.safeParse(cause);\n const errors: Message[] = failure.success ? failure.data.errors : [];\n const problems =\n errors.length > 0\n ? errors.map(formatMessage)\n : [\n {\n path: null,\n message: cause instanceof Error ? cause.message : String(cause),\n builtin: false,\n },\n ];\n return { code: null, hash: null, problems };\n }\n const problems: BundleProblemIface[] = outsideImports.map((message) => ({\n path: message.split(' ')[0] ?? null,\n message: `${message}: authored imports must stay inside the agent directory (share code as a package)`,\n builtin: false,\n }));\n const surviving = new Set(\n Object.values(output.metafile.outputs)\n .flatMap((file) => file.imports)\n .filter((entry) => entry.external)\n .map((entry) => entry.path),\n );\n for (const item of builtinImports) {\n if (!surviving.has(item.path)) continue;\n problems.push({\n path: item.importer,\n message: `${item.importer} imports the Node built-in ${item.path}; authored code runs in a Worker isolate (use a sandbox tool for host work)`,\n builtin: true,\n });\n }\n const file = output.outputFiles[0];\n if (file == null)\n return {\n code: null,\n hash: null,\n problems: [\n ...problems,\n { path: null, message: 'esbuild produced no output', builtin: false },\n ],\n };\n // Assign identifiers after graph discovery so concurrent builds produce the same names.\n const minified = await transform(file.text, {\n format: 'esm',\n target: 'es2024',\n minify: true,\n legalComments: 'none',\n charset: 'utf8',\n });\n // Seed resources affect immutable identity even when no runtime code imports them.\n const resources = Object.entries(preparationFiles(input.files)).toSorted(([a], [b]) =>\n a < b ? -1 : a > b ? 1 : 0,\n );\n const sourceHash = createHash('sha256').update(JSON.stringify(resources)).digest('hex');\n const code =\n resources.length === 0\n ? minified.code\n : `${minified.code}\\n// final:sandbox-inputs:${sourceHash}\\n`;\n return {\n code,\n hash: `sha256:${createHash('sha256').update(code).digest('hex')}`,\n problems,\n };\n};\n"],
5
5
  "mappings": "AAAA,SAAS,OAAO,iBAAyD;AACzE,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,UAAU,gBAAgB;AACnC,SAAS,iBAAiB;AAC1B,SAAS,SAAS,YAAY,OAAO,UAAU,eAAe;AAC9D,YAAY,OAAO;AAEnB,SAAS,gBAAgB,wBAAwB;AACjD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAKP,MAAM,eAAe,QAAQ,YAAY,SAAS,MAAM,MAAM,iBAAiB;AACxE,MAAM,sBAAsB,WAAW,YAAY,IACtD,eACA,QAAQ,YAAY,SAAS,MAAM,IAAI;AAS3C,MAAM,iBAAiB,CAAC,gBAA6C;AACnE,QAAM,MAAM,QAAQ,aAAa,KAAK;AACtC,QAAM,YAAY,QAAQ,KAAK,WAAW;AAC1C,SAAO;AAAA,IACL;AAAA,IACA,eAAe,QAAQ,KAAK,WAAW,WAAW;AAAA,IAClD,SAAS,IAAI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G,KAAK,QAAQ,8BAA8B,KAAK,IAAI;AAAA,MAChE,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACA,QAAM,OAAO,OAAO,YAAY,CAAC;AACjC,MAAI,QAAQ;AACV,WAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,QACR,GAAG;AAAA,QACH,EAAE,MAAM,MAAM,SAAS,8BAA8B,SAAS,MAAM;AAAA,MACtE;AAAA,IACF;AAEF,QAAM,WAAW,MAAM,UAAU,KAAK,MAAM;AAAA,IAC1C,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,eAAe;AAAA,IACf,SAAS;AAAA,EACX,CAAC;AAED,QAAM,YAAY,OAAO,QAAQ,iBAAiB,MAAM,KAAK,CAAC,EAAE;AAAA,IAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAC/E,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI;AAAA,EAC3B;AACA,QAAM,aAAa,WAAW,QAAQ,EAAE,OAAO,KAAK,UAAU,SAAS,CAAC,EAAE,OAAO,KAAK;AACtF,QAAM,OACJ,UAAU,WAAW,IACjB,SAAS,OACT,GAAG,SAAS,IAAI;AAAA,0BAA6B,UAAU;AAAA;AAC7D,SAAO;AAAA,IACL;AAAA,IACA,MAAM,UAAU,WAAW,QAAQ,EAAE,OAAO,IAAI,EAAE,OAAO,KAAK,CAAC;AAAA,IAC/D;AAAA,EACF;AACF;",
6
6
  "names": ["file", "problems"]
7
7
  }
@@ -13,6 +13,7 @@ export type { LocalIsolateOptionsIface } from "./local-isolate.mjs";
13
13
  export { parsePackageJson, PLATFORM_PACKAGES, splitSpecifier, workspaceDependencies, WorkspaceDependencyKind, workspacePackageCandidates, workspacePackageGlobs, } from "./packages.mjs";
14
14
  export type { VendoredPackageIface, WorkspaceDependencyIface } from "./packages.mjs";
15
15
  export interface CompileOptionsIface {
16
+ previewBundle?: boolean;
16
17
  dir?: string;
17
18
  hostedBindings?: HostedBindingsIface;
18
19
  files?: Record<string, string>;
@@ -36,10 +37,6 @@ export interface CompiledBundleIface {
36
37
  code: string;
37
38
  modules: Record<string, string>;
38
39
  sandboxOpeners: Record<string, string>;
39
- channelRoutes: Record<string, {
40
- method: string;
41
- path: string;
42
- }[]>;
43
40
  }
44
41
  export interface CompileResultIface {
45
42
  manifest: AgentManifestIface | null;
@@ -185,6 +185,8 @@ const compile = async (options) => {
185
185
  for (const key of defaultModuleKeys) {
186
186
  const source = assembled.manifest.channelSources?.[key];
187
187
  if (source != null) source.source = "default";
188
+ if (key === "final" && assembled.manifest.roomSurface != null)
189
+ assembled.manifest.roomSurface.source = "default";
188
190
  for (const channel of assembled.manifest.channels)
189
191
  if (channel.key === key) channel.source = "default";
190
192
  }
@@ -208,12 +210,11 @@ const compile = async (options) => {
208
210
  return { manifest: null, bundle: null, diagnostics, report: null };
209
211
  }
210
212
  }
211
- const compiledBundle = manifest?.bundle == null || bundle == null ? null : {
213
+ const compiledBundle = manifest == null || bundle == null || manifest.bundle == null && options.previewBundle !== true ? null : {
212
214
  ...bundle,
213
215
  files: preparationFiles(files),
214
216
  modules: assembled.modules,
215
- sandboxOpeners: assembled.sandboxOpeners,
216
- channelRoutes: assembled.channelRoutes
217
+ sandboxOpeners: assembled.sandboxOpeners
217
218
  };
218
219
  let report = null;
219
220
  let finalManifest = manifest;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/compiler/index.ts"],
4
- "sourcesContent": ["import {\n jsonValueSchema,\n type AgentManifestIface,\n type HostedBindingsIface,\n type HarnessDescriptionIface,\n type JsonSchema,\n type ProviderRef,\n} from '@finalai/agent-provider';\nimport { sandboxPreparationInputs, sandboxSeedFiles } from '@finalai/agent-provider/sandbox';\nimport { basename, dirname } from 'node:path';\nimport * as z from 'zod';\nimport { compatibilityReport, type CompatibilityReportIface } from \"../compatibility.mjs\";\nimport { assemble } from \"./assemble.mjs\";\nimport { validateHostedBindings } from \"../hosted-bindings.mjs\";\nimport { bundleAgent } from \"./bundle.mjs\";\nimport {\n diagnostic,\n DiagnosticCode,\n DiagnosticSeverity,\n hasErrors,\n type DiagnosticIface,\n} from \"./diagnostics.mjs\";\nimport { discover } from \"./discovery.mjs\";\nimport { evaluateBundle } from \"./evaluate.mjs\";\nimport { normalizeFiles, preparationFiles, readAgentDirectory } from \"./files.mjs\";\nimport { declaredDependencyDiagnostics, type VendoredPackageIface } from \"./packages.mjs\";\n\nexport type { CompatibilityReportIface } from \"../compatibility.mjs\";\nexport { DiagnosticCode, DiagnosticSeverity, hasErrors } from \"./diagnostics.mjs\";\nexport type { DiagnosticIface } from \"./diagnostics.mjs\";\nexport { discover } from \"./discovery.mjs\";\nexport { loadBundle } from \"./load.mjs\";\nexport type { LoadedBundleIface } from \"./load.mjs\";\nexport { loadBundleInLocalIsolate } from \"./local-isolate.mjs\";\nexport type { LocalIsolateOptionsIface } from \"./local-isolate.mjs\";\nexport {\n parsePackageJson,\n PLATFORM_PACKAGES,\n splitSpecifier,\n workspaceDependencies,\n WorkspaceDependencyKind,\n workspacePackageCandidates,\n workspacePackageGlobs,\n} from \"./packages.mjs\";\nexport type { VendoredPackageIface, WorkspaceDependencyIface } from \"./packages.mjs\";\n\nexport interface CompileOptionsIface {\n // An agent directory on disk (the repository's `agent/` directory)...\n dir?: string;\n // When supplied by hosting, validate declared requirements before release.\n hostedBindings?: HostedBindingsIface;\n // ...or its files, directory-relative (what Build reads from git).\n files?: Record<string, string>;\n // Optional modules supplied by the host when the author did not provide them.\n defaultFiles?: Readonly<Record<string, string>>;\n // Identity name when agent.ts sets none; defaults to the directory name.\n name?: string;\n // Looks up the chosen harness's description for the compatibility report.\n // A bundle harness is described from the bundle being compiled.\n harnessDescriptions?: (\n ref: ProviderRef,\n context: HarnessDescriptionContextIface,\n ) => Promise<HarnessDescriptionIface | null>;\n // This package's installed root, when the compiler runs from a bundle.\n packageRoot?: string;\n // Workspace packages from the agent's repository it imports, by name\n // (packages.ts); the platform passes them since it compiles without installing.\n packages?: Record<string, VendoredPackageIface>;\n // Authoring modules of the provider packages the host installed, by import\n // specifier \u2192 source file (`@finalai/daytona-agent-provider/sandboxes`), which\n // authored code may import though this package does not depend on them. A\n // compile of files without a checkout resolves packages from this package's\n // dependencies only.\n providerModules?: Readonly<Record<string, string>>;\n // Explicit provider defaults used to infer a dynamic sandbox target by name.\n installedSandboxProviders?: Readonly<Record<string, string>>;\n}\n\nexport interface HarnessDescriptionContextIface {\n // The compiled bundle; null when the definition has no authored modules.\n bundle: { hash: string; code: string } | null;\n}\n\nexport interface CompiledBundleIface {\n // Pinned workspace and skill files used by sandbox provider preparation.\n files?: Record<string, string>;\n hash: string;\n // One ESM module for the Worker isolate; exports `modules` and `runtime`.\n code: string;\n // Bundle export \u2192 directory-relative source path, for everything the\n // runtime calls (tools, channels, hooks, resolvers, selectors, providers).\n modules: Record<string, string>;\n // Target \u2192 bundle export of the sandbox.ts selector that opens it.\n sandboxOpeners: Record<string, string>;\n // Bundle channel export ('channels/github') \u2192 its routes, so the platform\n // shows route URLs without running the bundle.\n channelRoutes: Record<string, { method: string; path: string }[]>;\n}\n\nexport interface CompileResultIface {\n // Null when there are errors.\n manifest: AgentManifestIface | null;\n bundle: CompiledBundleIface | null;\n diagnostics: DiagnosticIface[];\n report: CompatibilityReportIface | null;\n}\n\nconst directoryName = (dir: string): string => {\n const name = basename(dir);\n return name === 'agent' ? basename(dirname(dir)) : name;\n};\n\nconst configObjectSchema = z.record(z.string(), jsonValueSchema);\nconst schemaPropertiesSchema = z.object({ properties: z.record(z.string(), jsonValueSchema) });\n\nconst withoutUndeclaredDirectoryFields = (args: {\n manifest: AgentManifestIface;\n configSchema: JsonSchema;\n directoryFields: { instructions: string[]; skills: string[] };\n diagnostics: DiagnosticIface[];\n}): AgentManifestIface => {\n const config = configObjectSchema.safeParse(args.manifest.harness.config);\n if (!config.success) return args.manifest;\n const declared = schemaPropertiesSchema.safeParse(args.configSchema);\n const properties = declared.success ? declared.data.properties : {};\n const next = { ...config.data };\n const fields: ['instructions' | 'skills', string[]][] = [\n ['instructions', args.directoryFields.instructions],\n ['skills', args.directoryFields.skills],\n ];\n for (const [field, sources] of fields) {\n if (sources.length === 0 || field in properties || !(field in next)) continue;\n delete next[field];\n args.diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Warning,\n code: DiagnosticCode.Compatibility,\n message: `the harness has no ${field} field, so ${sources.join(', ')} ${sources.length === 1 ? 'is' : 'are'} unused`,\n }),\n );\n }\n return { ...args.manifest, harness: { ...args.manifest.harness, config: next } };\n};\n\nexport const compile = async (options: CompileOptionsIface): Promise<CompileResultIface> => {\n const diagnostics: DiagnosticIface[] = [];\n const fail = (message: string): CompileResultIface => ({\n manifest: null,\n bundle: null,\n diagnostics: [\n ...diagnostics,\n diagnostic({ severity: DiagnosticSeverity.Error, code: DiagnosticCode.Input, message }),\n ],\n report: null,\n });\n let root: string | null = null;\n let rawFiles: Record<string, string>;\n if (options.dir != null) {\n if (options.files != null) return fail('pass either dir or files, not both');\n try {\n const read = await readAgentDirectory(options.dir);\n root = read.root;\n rawFiles = read.files;\n } catch (cause) {\n return fail(cause instanceof Error ? cause.message : String(cause));\n }\n } else if (options.files != null) rawFiles = options.files;\n else return fail('pass dir or files');\n const normalized = normalizeFiles(rawFiles);\n for (const problem of normalized.problems) {\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Error,\n code: DiagnosticCode.Input,\n message: problem.message,\n path: problem.path,\n }),\n );\n }\n const { files } = normalized;\n const defaultModuleKeys = new Set<string>();\n for (const [path, source] of Object.entries(options.defaultFiles ?? {})) {\n const stem = path.replace(/\\.(ts|mts|js|mjs)$/, '');\n if (!Object.keys(files).some((file) => file.replace(/\\.(ts|mts|js|mjs)$/, '') === stem)) {\n files[path] = source;\n defaultModuleKeys.add(stem.replace(/^channels\\//, ''));\n }\n }\n try {\n sandboxSeedFiles(sandboxPreparationInputs(files));\n } catch (cause) {\n return fail(cause instanceof Error ? cause.message : String(cause));\n }\n const packages: Record<string, VendoredPackageIface> = {};\n for (const [name, pkg] of Object.entries(options.packages ?? {})) {\n const vendored = normalizeFiles(pkg.files, { enforceSizeLimits: false });\n for (const problem of vendored.problems) {\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Error,\n code: DiagnosticCode.Input,\n message: `${name}: ${problem.message}`,\n path: problem.path,\n }),\n );\n }\n Object.defineProperty(packages, name, {\n value: { ...pkg, files: vendored.files },\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n diagnostics.push(\n ...declaredDependencyDiagnostics({\n packageJson: files['package.json'],\n vendored: new Set(Object.keys(packages)),\n local: root != null,\n }),\n );\n const discovery = discover(Object.keys(files));\n\n let bundle: { hash: string; code: string } | null = null;\n let described = null;\n if (discovery.modules.length > 0) {\n const bundled = await bundleAgent({\n files,\n layout: discovery.modules,\n root,\n packageRoot: options.packageRoot,\n packages,\n providerModules: options.providerModules,\n });\n for (const problem of bundled.problems) {\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Error,\n code: problem.builtin ? DiagnosticCode.NodeBuiltin : DiagnosticCode.Bundle,\n message: problem.message,\n path: problem.path,\n }),\n );\n }\n if (bundled.code != null && bundled.hash != null) {\n bundle = { hash: bundled.hash, code: bundled.code };\n const evaluated = await evaluateBundle(bundled.code, { packageRoot: options.packageRoot });\n if (evaluated.ok) described = evaluated.described;\n else\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Error,\n code: DiagnosticCode.Evaluation,\n message: evaluated.message,\n }),\n );\n }\n }\n if (hasErrors(diagnostics)) return { manifest: null, bundle: null, diagnostics, report: null };\n\n const assembled = assemble({\n files,\n discovery,\n described,\n fallbackName:\n options.name ?? (options.dir == null ? 'agent' : directoryName(root ?? options.dir)),\n bundle,\n installedSandboxProviders: options.installedSandboxProviders,\n });\n if (assembled.manifest != null) {\n for (const key of defaultModuleKeys) {\n const source = assembled.manifest.channelSources?.[key];\n if (source != null) source.source = 'default';\n for (const channel of assembled.manifest.channels)\n if (channel.key === key) channel.source = 'default';\n }\n }\n diagnostics.push(...assembled.diagnostics);\n const manifest = assembled.manifest;\n if (manifest != null && options.hostedBindings != null) {\n try {\n await validateHostedBindings({\n manifest,\n bindings: options.hostedBindings,\n });\n } catch (error) {\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Error,\n code: DiagnosticCode.Connections,\n message: error instanceof Error ? error.message : String(error),\n }),\n );\n return { manifest: null, bundle: null, diagnostics, report: null };\n }\n }\n const compiledBundle: CompiledBundleIface | null =\n manifest?.bundle == null || bundle == null\n ? null\n : {\n ...bundle,\n files: preparationFiles(files),\n modules: assembled.modules,\n sandboxOpeners: assembled.sandboxOpeners,\n channelRoutes: assembled.channelRoutes,\n };\n\n let report: CompatibilityReportIface | null = null;\n let finalManifest = manifest;\n if (manifest != null && options.harnessDescriptions != null) {\n const description = await options.harnessDescriptions(manifest.harness.harness, { bundle });\n if (description == null) {\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Warning,\n code: DiagnosticCode.Compatibility,\n message: 'the harness description is unavailable, so there is no compatibility report',\n }),\n );\n } else {\n report = compatibilityReport({\n manifest,\n description,\n directoryFiles: assembled.directoryFields,\n });\n // Directory instructions and skills fill harness config fields\n // only when the harness declares them; otherwise they are reported unused.\n finalManifest = withoutUndeclaredDirectoryFields({\n manifest,\n configSchema: description.configSchema,\n directoryFields: assembled.directoryFields,\n diagnostics,\n });\n }\n }\n return { manifest: finalManifest, bundle: compiledBundle, diagnostics, report };\n};\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,OAMK;AACP,SAAS,0BAA0B,wBAAwB;AAC3D,SAAS,UAAU,eAAe;AAClC,YAAY,OAAO;AACnB,SAAS,2BAA0D;AACnE,SAAS,gBAAgB;AACzB,SAAS,8BAA8B;AACvC,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBA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AY;AAAA,QAC1B,iBAAiB,UAAU;AAAA,QAC3B;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO,EAAE,UAAU,eAAe,QAAQ,gBAAgB,aAAa,OAAO;AAChF;",
4
+ "sourcesContent": ["import {\n jsonValueSchema,\n type AgentManifestIface,\n type HostedBindingsIface,\n type HarnessDescriptionIface,\n type JsonSchema,\n type ProviderRef,\n} from '@finalai/agent-provider';\nimport { sandboxPreparationInputs, sandboxSeedFiles } from '@finalai/agent-provider/sandbox';\nimport { basename, dirname } from 'node:path';\nimport * as z from 'zod';\nimport { compatibilityReport, type CompatibilityReportIface } from \"../compatibility.mjs\";\nimport { assemble } from \"./assemble.mjs\";\nimport { validateHostedBindings } from \"../hosted-bindings.mjs\";\nimport { bundleAgent } from \"./bundle.mjs\";\nimport {\n diagnostic,\n DiagnosticCode,\n DiagnosticSeverity,\n hasErrors,\n type DiagnosticIface,\n} from \"./diagnostics.mjs\";\nimport { discover } from \"./discovery.mjs\";\nimport { evaluateBundle } from \"./evaluate.mjs\";\nimport { normalizeFiles, preparationFiles, readAgentDirectory } from \"./files.mjs\";\nimport { declaredDependencyDiagnostics, type VendoredPackageIface } from \"./packages.mjs\";\n\nexport type { CompatibilityReportIface } from \"../compatibility.mjs\";\nexport { DiagnosticCode, DiagnosticSeverity, hasErrors } from \"./diagnostics.mjs\";\nexport type { DiagnosticIface } from \"./diagnostics.mjs\";\nexport { discover } from \"./discovery.mjs\";\nexport { loadBundle } from \"./load.mjs\";\nexport type { LoadedBundleIface } from \"./load.mjs\";\nexport { loadBundleInLocalIsolate } from \"./local-isolate.mjs\";\nexport type { LocalIsolateOptionsIface } from \"./local-isolate.mjs\";\nexport {\n parsePackageJson,\n PLATFORM_PACKAGES,\n splitSpecifier,\n workspaceDependencies,\n WorkspaceDependencyKind,\n workspacePackageCandidates,\n workspacePackageGlobs,\n} from \"./packages.mjs\";\nexport type { VendoredPackageIface, WorkspaceDependencyIface } from \"./packages.mjs\";\n\nexport interface CompileOptionsIface {\n // Local route preview needs the evaluated module even when production uses an installed implementation.\n previewBundle?: boolean;\n // An agent directory on disk (the repository's `agent/` directory)...\n dir?: string;\n // When supplied by hosting, validate declared requirements before release.\n hostedBindings?: HostedBindingsIface;\n // ...or its files, directory-relative (what Build reads from git).\n files?: Record<string, string>;\n // Optional modules supplied by the host when the author did not provide them.\n defaultFiles?: Readonly<Record<string, string>>;\n // Identity name when agent.ts sets none; defaults to the directory name.\n name?: string;\n // Looks up the chosen harness's description for the compatibility report.\n // A bundle harness is described from the bundle being compiled.\n harnessDescriptions?: (\n ref: ProviderRef,\n context: HarnessDescriptionContextIface,\n ) => Promise<HarnessDescriptionIface | null>;\n // This package's installed root, when the compiler runs from a bundle.\n packageRoot?: string;\n // Workspace packages from the agent's repository it imports, by name\n // (packages.ts); the platform passes them since it compiles without installing.\n packages?: Record<string, VendoredPackageIface>;\n // Authoring modules of the provider packages the host installed, by import\n // specifier \u2192 source file (`@finalai/daytona-agent-provider/sandboxes`), which\n // authored code may import though this package does not depend on them. A\n // compile of files without a checkout resolves packages from this package's\n // dependencies only.\n providerModules?: Readonly<Record<string, string>>;\n // Explicit provider defaults used to infer a dynamic sandbox target by name.\n installedSandboxProviders?: Readonly<Record<string, string>>;\n}\n\nexport interface HarnessDescriptionContextIface {\n // The compiled bundle; null when the definition has no authored modules.\n bundle: { hash: string; code: string } | null;\n}\n\nexport interface CompiledBundleIface {\n // Pinned workspace and skill files used by sandbox provider preparation.\n files?: Record<string, string>;\n hash: string;\n // One ESM module for the Worker isolate; exports `modules` and `runtime`.\n code: string;\n // Bundle export \u2192 directory-relative source path, for everything the\n // runtime calls (tools, channels, hooks, resolvers, selectors, providers).\n modules: Record<string, string>;\n // Target \u2192 bundle export of the sandbox.ts selector that opens it.\n sandboxOpeners: Record<string, string>;\n}\n\nexport interface CompileResultIface {\n // Null when there are errors.\n manifest: AgentManifestIface | null;\n bundle: CompiledBundleIface | null;\n diagnostics: DiagnosticIface[];\n report: CompatibilityReportIface | null;\n}\n\nconst directoryName = (dir: string): string => {\n const name = basename(dir);\n return name === 'agent' ? basename(dirname(dir)) : name;\n};\n\nconst configObjectSchema = z.record(z.string(), jsonValueSchema);\nconst schemaPropertiesSchema = z.object({ properties: z.record(z.string(), jsonValueSchema) });\n\nconst withoutUndeclaredDirectoryFields = (args: {\n manifest: AgentManifestIface;\n configSchema: JsonSchema;\n directoryFields: { instructions: string[]; skills: string[] };\n diagnostics: DiagnosticIface[];\n}): AgentManifestIface => {\n const config = configObjectSchema.safeParse(args.manifest.harness.config);\n if (!config.success) return args.manifest;\n const declared = schemaPropertiesSchema.safeParse(args.configSchema);\n const properties = declared.success ? declared.data.properties : {};\n const next = { ...config.data };\n const fields: ['instructions' | 'skills', string[]][] = [\n ['instructions', args.directoryFields.instructions],\n ['skills', args.directoryFields.skills],\n ];\n for (const [field, sources] of fields) {\n if (sources.length === 0 || field in properties || !(field in next)) continue;\n delete next[field];\n args.diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Warning,\n code: DiagnosticCode.Compatibility,\n message: `the harness has no ${field} field, so ${sources.join(', ')} ${sources.length === 1 ? 'is' : 'are'} unused`,\n }),\n );\n }\n return { ...args.manifest, harness: { ...args.manifest.harness, config: next } };\n};\n\nexport const compile = async (options: CompileOptionsIface): Promise<CompileResultIface> => {\n const diagnostics: DiagnosticIface[] = [];\n const fail = (message: string): CompileResultIface => ({\n manifest: null,\n bundle: null,\n diagnostics: [\n ...diagnostics,\n diagnostic({ severity: DiagnosticSeverity.Error, code: DiagnosticCode.Input, message }),\n ],\n report: null,\n });\n let root: string | null = null;\n let rawFiles: Record<string, string>;\n if (options.dir != null) {\n if (options.files != null) return fail('pass either dir or files, not both');\n try {\n const read = await readAgentDirectory(options.dir);\n root = read.root;\n rawFiles = read.files;\n } catch (cause) {\n return fail(cause instanceof Error ? cause.message : String(cause));\n }\n } else if (options.files != null) rawFiles = options.files;\n else return fail('pass dir or files');\n const normalized = normalizeFiles(rawFiles);\n for (const problem of normalized.problems) {\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Error,\n code: DiagnosticCode.Input,\n message: problem.message,\n path: problem.path,\n }),\n );\n }\n const { files } = normalized;\n const defaultModuleKeys = new Set<string>();\n for (const [path, source] of Object.entries(options.defaultFiles ?? {})) {\n const stem = path.replace(/\\.(ts|mts|js|mjs)$/, '');\n if (!Object.keys(files).some((file) => file.replace(/\\.(ts|mts|js|mjs)$/, '') === stem)) {\n files[path] = source;\n defaultModuleKeys.add(stem.replace(/^channels\\//, ''));\n }\n }\n try {\n sandboxSeedFiles(sandboxPreparationInputs(files));\n } catch (cause) {\n return fail(cause instanceof Error ? cause.message : String(cause));\n }\n const packages: Record<string, VendoredPackageIface> = {};\n for (const [name, pkg] of Object.entries(options.packages ?? {})) {\n const vendored = normalizeFiles(pkg.files, { enforceSizeLimits: false });\n for (const problem of vendored.problems) {\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Error,\n code: DiagnosticCode.Input,\n message: `${name}: ${problem.message}`,\n path: problem.path,\n }),\n );\n }\n Object.defineProperty(packages, name, {\n value: { ...pkg, files: vendored.files },\n enumerable: true,\n configurable: true,\n writable: true,\n });\n }\n diagnostics.push(\n ...declaredDependencyDiagnostics({\n packageJson: files['package.json'],\n vendored: new Set(Object.keys(packages)),\n local: root != null,\n }),\n );\n const discovery = discover(Object.keys(files));\n\n let bundle: { hash: string; code: string } | null = null;\n let described = null;\n if (discovery.modules.length > 0) {\n const bundled = await bundleAgent({\n files,\n layout: discovery.modules,\n root,\n packageRoot: options.packageRoot,\n packages,\n providerModules: options.providerModules,\n });\n for (const problem of bundled.problems) {\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Error,\n code: problem.builtin ? DiagnosticCode.NodeBuiltin : DiagnosticCode.Bundle,\n message: problem.message,\n path: problem.path,\n }),\n );\n }\n if (bundled.code != null && bundled.hash != null) {\n bundle = { hash: bundled.hash, code: bundled.code };\n const evaluated = await evaluateBundle(bundled.code, { packageRoot: options.packageRoot });\n if (evaluated.ok) described = evaluated.described;\n else\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Error,\n code: DiagnosticCode.Evaluation,\n message: evaluated.message,\n }),\n );\n }\n }\n if (hasErrors(diagnostics)) return { manifest: null, bundle: null, diagnostics, report: null };\n\n const assembled = assemble({\n files,\n discovery,\n described,\n fallbackName:\n options.name ?? (options.dir == null ? 'agent' : directoryName(root ?? options.dir)),\n bundle,\n installedSandboxProviders: options.installedSandboxProviders,\n });\n if (assembled.manifest != null) {\n for (const key of defaultModuleKeys) {\n const source = assembled.manifest.channelSources?.[key];\n if (source != null) source.source = 'default';\n if (key === 'final' && assembled.manifest.roomSurface != null)\n assembled.manifest.roomSurface.source = 'default';\n for (const channel of assembled.manifest.channels)\n if (channel.key === key) channel.source = 'default';\n }\n }\n diagnostics.push(...assembled.diagnostics);\n const manifest = assembled.manifest;\n if (manifest != null && options.hostedBindings != null) {\n try {\n await validateHostedBindings({\n manifest,\n bindings: options.hostedBindings,\n });\n } catch (error) {\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Error,\n code: DiagnosticCode.Connections,\n message: error instanceof Error ? error.message : String(error),\n }),\n );\n return { manifest: null, bundle: null, diagnostics, report: null };\n }\n }\n const compiledBundle: CompiledBundleIface | null =\n manifest == null ||\n bundle == null ||\n (manifest.bundle == null && options.previewBundle !== true)\n ? null\n : {\n ...bundle,\n files: preparationFiles(files),\n modules: assembled.modules,\n sandboxOpeners: assembled.sandboxOpeners,\n };\n\n let report: CompatibilityReportIface | null = null;\n let finalManifest = manifest;\n if (manifest != null && options.harnessDescriptions != null) {\n const description = await options.harnessDescriptions(manifest.harness.harness, { bundle });\n if (description == null) {\n diagnostics.push(\n diagnostic({\n severity: DiagnosticSeverity.Warning,\n code: DiagnosticCode.Compatibility,\n message: 'the harness description is unavailable, so there is no compatibility report',\n }),\n );\n } else {\n report = compatibilityReport({\n manifest,\n description,\n directoryFiles: assembled.directoryFields,\n });\n // Directory instructions and skills fill harness config fields\n // only when the harness declares them; otherwise they are reported unused.\n finalManifest = withoutUndeclaredDirectoryFields({\n manifest,\n configSchema: description.configSchema,\n directoryFields: assembled.directoryFields,\n diagnostics,\n });\n }\n }\n return { manifest: finalManifest, bundle: compiledBundle, diagnostics, report };\n};\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,OAMK;AACP,SAAS,0BAA0B,wBAAwB;AAC3D,SAAS,UAAU,eAAe;AAClC,YAAY,OAAO;AACnB,SAAS,2BAA0D;AACnE,SAAS,gBAAgB;AACzB,SAAS,8BAA8B;AACvC,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,gBAAgB;AACzB,SAAS,sBAAsB;AAC/B,SAAS,gBAAgB,kBAAkB,0BAA0B;AACrE,SAAS,qCAAgE;AAGzE,SAAS,kBAAAA,iBAAgB,sBAAAC,qBAAoB,aAAAC,kBAAiB;AAE9D,SAAS,YAAAC,iBAAgB;AACzB,SAAS,kBAAkB;AAE3B,SAAS,gCAAgC;AAEzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA+DP,MAAM,gBAAgB,CAAC,QAAwB;AAC7C,QAAM,OAAO,SAAS,GAAG;AACzB,SAAO,SAAS,UAAU,SAAS,QAAQ,GAAG,CAAC,IAAI;AACrD;AAEA,MAAM,qBAAqB,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe;AAC/D,MAAM,yBAAyB,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,eAAe,EAAE,CAAC;AAE7F,MAAM,mCAAmC,CAAC,SAKhB;AACxB,QAAM,SAAS,mBAAmB,UAAU,KAAK,SAAS,QAAQ,MAAM;AACxE,MAAI,CAAC,OAAO,QAAS,QAAO,KAAK;AACjC,QAAM,WAAW,uBAAuB,UA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AAO,iBAAiB,KAAK;AAAA,IAC7B,SAAS,UAAU;AAAA,IACnB,gBAAgB,UAAU;AAAA,EAC5B;AAEN,MAAI,SAA0C;AAC9C,MAAI,gBAAgB;AACpB,MAAI,YAAY,QAAQ,QAAQ,uBAAuB,MAAM;AAC3D,UAAM,cAAc,MAAM,QAAQ,oBAAoB,SAAS,QAAQ,SAAS,EAAE,OAAO,CAAC;AAC1F,QAAI,eAAe,MAAM;AACvB,kBAAY;AAAA,QACV,WAAW;AAAA,UACT,UAAU,mBAAmB;AAAA,UAC7B,MAAM,eAAe;AAAA,UACrB,SAAS;AAAA,QACX,CAAC;AAAA,MACH;AAAA,IACF,OAAO;AACL,eAAS,oBAAoB;AAAA,QAC3B;AAAA,QACA;AAAA,QACA,gBAAgB,UAAU;AAAA,MAC5B,CAAC;AAGD,sBAAgB,iCAAiC;AAAA,QAC/C;AAAA,QACA,cAAc,YAAY;AAAA,QAC1B,iBAAiB,UAAU;AAAA,QAC3B;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO,EAAE,UAAU,eAAe,QAAQ,gBAAgB,aAAa,OAAO;AAChF;",
6
6
  "names": ["DiagnosticCode", "DiagnosticSeverity", "hasErrors", "discover"]
7
7
  }
@@ -1,2 +1,2 @@
1
- export { BaseCapability, DynamicEvent, InstructionRole, MANIFEST_VERSION, McpServerBindingKind, SandboxAccess, SandboxAttach, ScheduleTarget, ToolApproval, agentAvatarSchema, avatarMediaSchema, agentManifestSchema, baseToolsSchema, bundleSchema, channelBindingSchema, dynamicSlotSchema, emptyManifest, findDynamicSlots, harnessBindingSchema, hookBindingSchema, httpMcpServerBindingSchema, identitySchema, instructionFragmentSchema, isDynamicSlot, mcpAuthSchema, mcpServerBindingSchema, resolvedAgentManifestSchema, sandboxBindingSchema, scheduleDefinitionSchema, skillBundleSchema, skillFileSchema, toolDescriptorSchema, workerMcpServerBindingSchema, } from '@finalai/agent-provider';
2
- export type { AgentAvatarIface, AvatarMedia, AvatarState, AgentManifestIface, BaseToolsIface, BundleIface, ChannelBindingIface, DynamicSlotIface, DynamicSlotLocationIface, HarnessBindingIface, HookBindingIface, HttpMcpServerBindingIface, IdentityIface, InstructionFragmentIface, McpAuth, McpServerBinding, ResolvedAgentManifestIface, ResolvedSandboxBindingIface, SandboxBindingIface, ScheduleDefinitionIface, SkillBundleIface, ToolDescriptorIface, WorkerMcpServerBindingIface, } from '@finalai/agent-provider';
1
+ export { BaseCapability, DynamicEvent, InstructionRole, MANIFEST_VERSION, McpServerBindingKind, SandboxAccess, SandboxAttach, ScheduleTarget, ToolApproval, agentAvatarSchema, avatarMediaSchema, agentManifestSchema, baseToolsSchema, bundleSchema, channelBindingSchema, dynamicSlotSchema, emptyManifest, findDynamicSlots, harnessBindingSchema, hookBindingSchema, httpMcpServerBindingSchema, identitySchema, instructionFragmentSchema, isDynamicSlot, mcpAuthSchema, mcpServerBindingSchema, resolvedAgentManifestSchema, sandboxBindingSchema, sandboxCredentialRefSchema, scheduleDefinitionSchema, skillBundleSchema, skillFileSchema, toolDescriptorSchema, workerMcpServerBindingSchema, } from '@finalai/agent-provider';
2
+ export type { AgentAvatarIface, AvatarMedia, AvatarState, AgentManifestIface, BaseToolsIface, BundleIface, ChannelBindingIface, DynamicSlotIface, DynamicSlotLocationIface, HarnessBindingIface, HookBindingIface, HttpMcpServerBindingIface, IdentityIface, InstructionFragmentIface, McpAuth, McpServerBinding, ResolvedAgentManifestIface, ResolvedSandboxBindingIface, SandboxBindingIface, SandboxCredentialRefIface, ScheduleDefinitionIface, SkillBundleIface, ToolDescriptorIface, WorkerMcpServerBindingIface, } from '@finalai/agent-provider';
@@ -27,6 +27,7 @@ import {
27
27
  mcpServerBindingSchema,
28
28
  resolvedAgentManifestSchema,
29
29
  sandboxBindingSchema,
30
+ sandboxCredentialRefSchema,
30
31
  scheduleDefinitionSchema,
31
32
  skillBundleSchema,
32
33
  skillFileSchema,
@@ -62,6 +63,7 @@ export {
62
63
  mcpServerBindingSchema,
63
64
  resolvedAgentManifestSchema,
64
65
  sandboxBindingSchema,
66
+ sandboxCredentialRefSchema,
65
67
  scheduleDefinitionSchema,
66
68
  skillBundleSchema,
67
69
  skillFileSchema,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/manifest.ts"],
4
- "sourcesContent": ["// The Agent Manifest lives in the provider contract (harnesses, sandboxes and\n// channels receive it); this package compiles directories into it.\nexport {\n BaseCapability,\n DynamicEvent,\n InstructionRole,\n MANIFEST_VERSION,\n McpServerBindingKind,\n SandboxAccess,\n SandboxAttach,\n ScheduleTarget,\n ToolApproval,\n agentAvatarSchema,\n avatarMediaSchema,\n agentManifestSchema,\n baseToolsSchema,\n bundleSchema,\n channelBindingSchema,\n dynamicSlotSchema,\n emptyManifest,\n findDynamicSlots,\n harnessBindingSchema,\n hookBindingSchema,\n httpMcpServerBindingSchema,\n identitySchema,\n instructionFragmentSchema,\n isDynamicSlot,\n mcpAuthSchema,\n mcpServerBindingSchema,\n resolvedAgentManifestSchema,\n sandboxBindingSchema,\n scheduleDefinitionSchema,\n skillBundleSchema,\n skillFileSchema,\n toolDescriptorSchema,\n workerMcpServerBindingSchema,\n} from '@finalai/agent-provider';\nexport type {\n AgentAvatarIface,\n AvatarMedia,\n AvatarState,\n AgentManifestIface,\n BaseToolsIface,\n BundleIface,\n ChannelBindingIface,\n DynamicSlotIface,\n DynamicSlotLocationIface,\n HarnessBindingIface,\n HookBindingIface,\n HttpMcpServerBindingIface,\n IdentityIface,\n InstructionFragmentIface,\n McpAuth,\n McpServerBinding,\n ResolvedAgentManifestIface,\n ResolvedSandboxBindingIface,\n SandboxBindingIface,\n ScheduleDefinitionIface,\n SkillBundleIface,\n ToolDescriptorIface,\n WorkerMcpServerBindingIface,\n} from '@finalai/agent-provider';\n"],
5
- "mappings": "AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
4
+ "sourcesContent": ["// The Agent Manifest lives in the provider contract (harnesses, sandboxes and\n// channels receive it); this package compiles directories into it.\nexport {\n BaseCapability,\n DynamicEvent,\n InstructionRole,\n MANIFEST_VERSION,\n McpServerBindingKind,\n SandboxAccess,\n SandboxAttach,\n ScheduleTarget,\n ToolApproval,\n agentAvatarSchema,\n avatarMediaSchema,\n agentManifestSchema,\n baseToolsSchema,\n bundleSchema,\n channelBindingSchema,\n dynamicSlotSchema,\n emptyManifest,\n findDynamicSlots,\n harnessBindingSchema,\n hookBindingSchema,\n httpMcpServerBindingSchema,\n identitySchema,\n instructionFragmentSchema,\n isDynamicSlot,\n mcpAuthSchema,\n mcpServerBindingSchema,\n resolvedAgentManifestSchema,\n sandboxBindingSchema,\n sandboxCredentialRefSchema,\n scheduleDefinitionSchema,\n skillBundleSchema,\n skillFileSchema,\n toolDescriptorSchema,\n workerMcpServerBindingSchema,\n} from '@finalai/agent-provider';\nexport type {\n AgentAvatarIface,\n AvatarMedia,\n AvatarState,\n AgentManifestIface,\n BaseToolsIface,\n BundleIface,\n ChannelBindingIface,\n DynamicSlotIface,\n DynamicSlotLocationIface,\n HarnessBindingIface,\n HookBindingIface,\n HttpMcpServerBindingIface,\n IdentityIface,\n InstructionFragmentIface,\n McpAuth,\n McpServerBinding,\n ResolvedAgentManifestIface,\n ResolvedSandboxBindingIface,\n SandboxBindingIface,\n SandboxCredentialRefIface,\n ScheduleDefinitionIface,\n SkillBundleIface,\n ToolDescriptorIface,\n WorkerMcpServerBindingIface,\n} from '@finalai/agent-provider';\n"],
5
+ "mappings": "AAEA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,7 @@
1
1
  import {
2
2
  agentAvatarSchema,
3
+ channelCredentialsSchema,
4
+ channelSurfaceSchema,
3
5
  jsonValueSchema,
4
6
  hostedBindingRequirementSchema
5
7
  } from "@finalai/agent-provider";
@@ -212,6 +214,32 @@ const describeAvatar = (value, issues) => {
212
214
  }
213
215
  return null;
214
216
  };
217
+ const invalidChannelFields = (value) => {
218
+ const invalid = [];
219
+ if (!z.string().min(1).safeParse(fieldOf(value, "name")).success) invalid.push("name");
220
+ if (!channelCredentialsSchema.safeParse(fieldOf(value, "credentials")).success)
221
+ invalid.push("credentials");
222
+ const identity = fieldOf(value, "identity");
223
+ const kind = fieldOf(identity, "kind");
224
+ if (kind !== "none" && kind !== "redirect" && kind !== "challenge" || kind === "redirect" && !isCallable(fieldOf(identity, "start")) || kind === "challenge" && !isCallable(fieldOf(identity, "deliver")))
225
+ invalid.push("identity");
226
+ if (!z.array(z.string()).safeParse(fieldOf(fieldOf(value, "places"), "kinds")).success)
227
+ invalid.push("places");
228
+ if (!isCallable(fieldOf(value, "receive"))) invalid.push("receive");
229
+ return invalid;
230
+ };
231
+ const channelSurfaceOf = (value) => {
232
+ const routes = fieldOf(value, "routes");
233
+ const listeners = fieldOf(value, "listeners");
234
+ return {
235
+ routes: Array.isArray(routes) ? routes.map((route) => ({
236
+ method: String(fieldOf(route, "method")),
237
+ path: String(fieldOf(route, "path"))
238
+ })) : [],
239
+ listeners: Array.isArray(listeners) ? listeners.map((listener) => String(fieldOf(listener, "key"))) : [],
240
+ placeKinds: z.array(z.string()).safeParse(fieldOf(fieldOf(value, "places"), "kinds")).data ?? []
241
+ };
242
+ };
215
243
  const describeAgent = (value, ctx, issues) => {
216
244
  if (value == null) return null;
217
245
  if (!isPlainObject(value)) {
@@ -235,7 +263,12 @@ const describeAgent = (value, ctx, issues) => {
235
263
  if (Array.isArray(channelsRaw)) {
236
264
  channels = channelsRaw.map((binding, index) => ({
237
265
  key: stringOrNull(fieldOf(binding, "key")),
238
- channel: toJson(fieldOf(binding, "channel") ?? null, {
266
+ install: stringOrNull(fieldOf(binding, "install")),
267
+ credentials: channelCredentialsSchema.safeParse(fieldOf(binding, "credentials")).data ?? null,
268
+ surface: channelSurfaceSchema.safeParse(
269
+ fieldOf(binding, "surface") ?? (fieldOf(binding, "places") == null ? null : channelSurfaceOf(binding))
270
+ ).data ?? null,
271
+ channel: toJson(fieldOf(binding, "channel") ?? fieldOf(binding, "installed") ?? null, {
239
272
  path: `channels[${index}].channel`,
240
273
  issues
241
274
  }),
@@ -420,7 +453,21 @@ const describeModuleValue = (entry, ctx, sandbox, issues) => {
420
453
  method: String(fieldOf(route, "method")),
421
454
  path: String(fieldOf(route, "path"))
422
455
  })) : [],
423
- turnPolicy: stringOrNull(fieldOf(value, "turnPolicy")),
456
+ room: authoredKindOf(value) === AuthoredKind.RoomSurface,
457
+ invalidFields: authoredKindOf(value) === AuthoredKind.RoomSurface || fieldOf(value, "disabled") === true ? [] : invalidChannelFields(value),
458
+ credentials: channelCredentialsSchema.safeParse(fieldOf(value, "credentials")).data ?? {
459
+ app: null
460
+ },
461
+ surface: {
462
+ routes: Array.isArray(routes) ? routes.map((route) => ({
463
+ method: String(fieldOf(route, "method")),
464
+ path: String(fieldOf(route, "path"))
465
+ })) : [],
466
+ listeners: Array.isArray(fieldOf(value, "listeners")) ? entriesOf(fieldOf(value, "listeners")).map(
467
+ ([, listener]) => String(fieldOf(listener, "key"))
468
+ ) : [],
469
+ placeKinds: z.array(z.string()).safeParse(fieldOf(fieldOf(value, "places"), "kinds")).data ?? []
470
+ },
424
471
  config: toJson(fieldOf(value, "config") ?? {}, { path: `${layout.path} config`, issues })
425
472
  };
426
473
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/runtime/describe.ts"],
4
- "sourcesContent": ["import {\n agentAvatarSchema,\n jsonValueSchema,\n hostedBindingRequirementSchema,\n type JsonObject,\n type JsonValue,\n} from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport {\n AuthoredKind,\n authoredKindOf,\n pendingEntries,\n pendingExportName,\n} from \"../authoring/brand.mjs\";\nimport type {\n DescribedAgentIface,\n DescribedBundleIface,\n DescribedDynamicIface,\n DescribedModuleIface,\n DescribedSandboxIface,\n DescribedSandboxTargetIface,\n DescribedValue,\n} from \"./described.mjs\";\nimport {\n AGENT_DYNAMIC_PREFIX,\n COMBINED_MCP_SERVERS_EXPORT,\n namedExportName,\n SlotKind,\n type LayoutModuleIface,\n} from \"./layout.mjs\";\nimport {\n childPath,\n dynamicEventsOf,\n error,\n isDynamicSentinel,\n isEnvironmentLike,\n isOpenRequestLike,\n lowerConnection,\n lowerEnvironment,\n lowerInstructions,\n lowerSkill,\n lowerTool,\n note,\n sandboxProviderNameOf,\n toJson,\n type IssueIface,\n} from \"./lower.mjs\";\nimport {\n entriesOf,\n fieldOf,\n isCallable,\n isObjectLike,\n isPlainObject,\n isPromiseLike,\n isString,\n messageOf,\n stringOrNull,\n type AuthoredRecord,\n type AuthoredValue,\n} from \"./values.mjs\";\n\n// Static extraction, run inside the realm that evaluated the bundle. Reads\n// authored values; never calls tool bodies, resolvers or routes, and calls a\n// sandbox selector only to read the request a synchronous one returns.\n\nexport interface NamespaceEntryIface {\n layout: LayoutModuleIface;\n namespace: AuthoredRecord;\n}\n\nexport const describeDynamic = (value: AuthoredValue): DescribedDynamicIface => {\n const provider = fieldOf(value, 'provider');\n let hint: DescribedDynamicIface['provider'] = null;\n if (provider != null) {\n const kind = fieldOf(provider, 'kind');\n const ref = fieldOf(provider, 'providerRef');\n const issues: IssueIface[] = [];\n if ((kind === 'package' || kind === 'bundle') && provider != null) {\n hint = { ref: toJson(provider, { path: 'provider', issues }), name: null };\n } else if (ref != null) {\n hint = { ref: toJson(ref, { path: 'provider', issues }), name: null };\n } else {\n hint = {\n ref: null,\n name:\n stringOrNull(fieldOf(provider, 'name')) ??\n stringOrNull(fieldOf(fieldOf(provider, 'definition'), 'name')),\n };\n }\n }\n return {\n type: 'dynamic',\n events: dynamicEventsOf(value),\n description: stringOrNull(fieldOf(value, 'description')),\n preview: stringOrNull(fieldOf(value, 'preview')),\n provider: hint,\n requiredBindings: z\n .array(hostedBindingRequirementSchema)\n .parse(fieldOf(value, 'requiredBindings') ?? []),\n };\n};\n\n// Dynamic sentinels inside agent.ts's harness config, addressed by their authored path. The bundle exports each as\n// `agent:<path>`.\nexport const collectAgentDynamics = (\n agent: AuthoredValue,\n): { path: string; value: AuthoredValue }[] => {\n const found: { path: string; value: AuthoredValue }[] = [];\n const walk = (value: AuthoredValue, path: string, depth: number): void => {\n if (depth > 32) return;\n if (isDynamicSentinel(value)) {\n found.push({ path, value });\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((item, index) => walk(item, childPath(path, index), depth + 1));\n return;\n }\n if (isPlainObject(value) || authoredKindOf(value) != null) {\n for (const [key, item] of entriesOf(value)) walk(item, childPath(path, key), depth + 1);\n }\n };\n walk(fieldOf(fieldOf(agent, 'harness'), 'config'), 'harness.config', 0);\n return found;\n};\n\nconst dynamicSlot = (value: AuthoredValue, path: string): JsonValue => {\n const described = describeDynamic(value);\n const slot: JsonObject = { resolver: `${AGENT_DYNAMIC_PREFIX}${path}`, events: described.events };\n if (described.description != null) slot['description'] = described.description;\n if (described.preview != null) slot['preview'] = described.preview;\n if ((described.requiredBindings?.length ?? 0) > 0)\n slot['requiredBindings'] = jsonValueSchema.parse(described.requiredBindings);\n return { $dynamic: slot };\n};\n\nconst isDefinedHarnessLike = (value: AuthoredValue): boolean =>\n isCallable(value) && isCallable(fieldOf(value, 'describe')) && isCallable(fieldOf(value, 'open'));\n\nconst KNOWN_AGENT_FIELDS: ReadonlySet<string> = new Set([\n 'name',\n 'description',\n 'avatar',\n 'harness',\n 'tools',\n 'toolPolicy',\n 'secrets',\n 'channels',\n]);\n\n// Harness configuration belongs in the harness binding rather than top-level agent fields.\nconst HARNESS_CONFIG_FIELDS: ReadonlySet<string> = new Set([\n 'model',\n 'reasoning',\n 'credentials',\n 'permissions',\n 'permissionMode',\n 'instructions',\n 'skills',\n 'system',\n 'temperature',\n 'providerOptions',\n 'maxSteps',\n 'stopWhen',\n]);\n\nconst unknownAgentField = (key: string): string => {\n if (HARNESS_CONFIG_FIELDS.has(key))\n return `agent.ts field ${key} belongs in harness config (harness: serverlessPi({ ${key}: ... }))`;\n if (key === 'defaultTools')\n return 'agent.ts field defaultTools is not supported: base tools are declared with tools: baseTools({ ... }) and are off by default';\n if (key === 'subagents' || key === 'memory') return `agent.ts field ${key} is not supported yet`;\n return `agent.ts field ${key} is not an agent field (name, description, avatar, harness, tools, toolPolicy, secrets, channels)`;\n};\n\ninterface DescribeContextIface {\n entries: NamespaceEntryIface[];\n sandboxIdentity: Map<AuthoredValue, string>;\n}\n\nconst describeHarness = (\n harness: AuthoredValue,\n ctx: DescribeContextIface,\n issues: IssueIface[],\n): DescribedAgentIface['harness'] => {\n if (harness == null) return null;\n const ref = fieldOf(harness, 'harness');\n if (!isObjectLike(ref)) {\n issues.push(error('agent.ts harness must be a harness binding, e.g. serverlessPi({ ... })'));\n return null;\n }\n let refJson = toJson(ref, { path: 'harness.harness', issues });\n if (fieldOf(ref, 'kind') === 'bundle' && fieldOf(ref, 'export') === '<pending>') {\n const candidates = ctx.entries.flatMap((entry) =>\n Object.entries(entry.namespace)\n .filter(([, value]) => isDefinedHarnessLike(value))\n .map(([name]) => namedExportName(entry.layout.base, name)),\n );\n if (candidates.length === 1 && candidates[0] != null)\n refJson = { kind: 'bundle', export: candidates[0] };\n else\n issues.push(\n error(\n 'the custom harness must come from defineHarness in @finalai/agents, or be exported once',\n ),\n );\n }\n const config = toJson(fieldOf(harness, 'config') ?? {}, {\n path: 'harness.config',\n issues,\n visit: (value, path) => (isDynamicSentinel(value) ? dynamicSlot(value, path) : undefined),\n });\n return { harness: refJson, config };\n};\n\n// Capabilities bound to sandbox targets (by export name) and those declared on\n// the harness's own host (`harnessHost`).\nconst describeBaseTools = (\n tools: AuthoredValue,\n ctx: DescribeContextIface,\n issues: IssueIface[],\n): { targets: Record<string, string>; host: string[] } | null => {\n if (tools == null) return null;\n if (authoredKindOf(tools) !== AuthoredKind.BaseTools) {\n issues.push(error('agent.ts tools must be baseTools({ shell: target, files: target, ... })'));\n return null;\n }\n const base = fieldOf(tools, 'base');\n const out: Record<string, string> = {};\n const host: string[] = [];\n if (!isPlainObject(base)) return { targets: out, host };\n for (const [capability, target] of Object.entries(base)) {\n if (target == null) continue;\n if (authoredKindOf(target) === AuthoredKind.HarnessHost) {\n host.push(capability);\n continue;\n }\n if (isString(target)) {\n out[capability] = target;\n continue;\n }\n const name = ctx.sandboxIdentity.get(target);\n if (name == null) {\n issues.push(\n error(\n `baseTools ${capability} is bound to a value that is not a sandbox target exported from sandbox.ts`,\n ),\n );\n continue;\n }\n out[capability] = name;\n }\n return { targets: out, host };\n};\n\nconst describeSecrets = (value: AuthoredValue, issues: IssueIface[]): string[] | null => {\n if (value == null) return null;\n const parsed = z.array(z.string().min(1)).safeParse(value);\n if (parsed.success) return parsed.data;\n issues.push(error('agent.ts secrets must be a list of secret names'));\n return null;\n};\n\nconst describeAvatar = (\n value: AuthoredValue,\n issues: IssueIface[],\n): DescribedAgentIface['avatar'] => {\n if (value === undefined) return null;\n const parsed = agentAvatarSchema.safeParse(toJson(value, { path: 'avatar', issues }));\n if (parsed.success) return parsed.data;\n for (const issue of parsed.error.issues) {\n issues.push(\n error(\n `agent.ts avatar${issue.path.length > 0 ? `.${issue.path.join('.')}` : ''}: ${issue.message}`,\n ),\n );\n }\n return null;\n};\n\nconst describeAgent = (\n value: AuthoredValue,\n ctx: DescribeContextIface,\n issues: IssueIface[],\n): DescribedAgentIface | null => {\n if (value == null) return null;\n if (!isPlainObject(value)) {\n issues.push(error('agent.ts must export defineAgent({ ... }) as its default export'));\n return null;\n }\n for (const key of Object.keys(value)) {\n if (!KNOWN_AGENT_FIELDS.has(key)) issues.push(error(unknownAgentField(key)));\n }\n const toolPolicyRaw = value['toolPolicy'];\n let toolPolicy: Record<string, string> | null = null;\n if (isPlainObject(toolPolicyRaw)) {\n toolPolicy = {};\n for (const [key, policy] of Object.entries(toolPolicyRaw)) {\n if (policy === 'allow' || policy === 'ask') toolPolicy[key] = policy;\n else issues.push(error(`agent.ts toolPolicy.${key} must be 'allow' or 'ask'`));\n }\n }\n const channelsRaw = value['channels'];\n let channels: DescribedAgentIface['channels'] = null;\n if (Array.isArray(channelsRaw)) {\n channels = channelsRaw.map((binding, index) => ({\n key: stringOrNull(fieldOf(binding, 'key')),\n channel: toJson(fieldOf(binding, 'channel') ?? null, {\n path: `channels[${index}].channel`,\n issues,\n }),\n config: toJson(fieldOf(binding, 'config') ?? {}, {\n path: `channels[${index}].config`,\n issues,\n }),\n }));\n }\n const baseToolsDescription = describeBaseTools(value['tools'], ctx, issues);\n return {\n type: 'agent',\n name: stringOrNull(value['name']),\n description: stringOrNull(value['description']),\n avatar: describeAvatar(value['avatar'], issues),\n harness: describeHarness(value['harness'], ctx, issues),\n tools: baseToolsDescription?.targets ?? null,\n hostTools: baseToolsDescription?.host ?? null,\n toolPolicy,\n secrets: describeSecrets(value['secrets'], issues),\n channels,\n };\n};\n\nconst probeSelector = (selector: AuthoredValue, issues: IssueIface[]): AuthoredValue | null => {\n if (!isCallable(selector)) return null;\n try {\n const result = selector({\n session: null,\n secrets: { get: async () => null },\n open: async () => {\n throw new Error('sandboxes do not open while compiling');\n },\n });\n if (isEnvironmentLike(result) || isOpenRequestLike(result)) return result;\n // An async selector: what it opens is known only at session start.\n if (isPromiseLike(result)) Promise.resolve(result).catch(() => undefined);\n return null;\n } catch (cause) {\n issues.push(\n error(\n `sandbox.ts selector failed during compilation: ${String(cause)}; export its environment when it needs session context`,\n ),\n );\n return null;\n }\n};\n\nconst describeSandbox = (\n namespace: AuthoredRecord,\n issues: IssueIface[],\n): DescribedSandboxIface => {\n const targets: Record<string, DescribedSandboxTargetIface> = {};\n const providers: Record<string, string> = {};\n const describeTarget = (\n value: AuthoredValue,\n exportName: string,\n path: string,\n ): DescribedSandboxTargetIface | null => {\n if (isDynamicSentinel(value))\n return { exportName, environment: null, dynamic: describeDynamic(value) };\n if (isEnvironmentLike(value) || isOpenRequestLike(value)) {\n return { exportName, environment: lowerEnvironment(value, path, issues), dynamic: null };\n }\n return null;\n };\n for (const [name, value] of Object.entries(namespace)) {\n if (name === 'default') continue;\n const exportName = namedExportName('sandbox', name);\n const providerName = sandboxProviderNameOf(value);\n if (providerName != null) {\n providers[exportName] = providerName;\n continue;\n }\n const target = describeTarget(value, exportName, `sandbox.ts ${name}`);\n if (target != null) targets[name] = target;\n }\n const named = Object.keys(targets);\n const fallback = describeTarget(namespace['default'], 'sandbox', 'sandbox.ts default export');\n const selector = authoredKindOf(namespace['default']) === AuthoredKind.SandboxSelector;\n if (fallback != null) targets['default'] = fallback;\n else if (namespace['default'] != null && !selector) {\n issues.push(\n error(\n 'sandbox.ts default export must be defineSandbox(selector), an environment, or defineDynamic(...)',\n ),\n );\n }\n // A selector that opens an environment it creates itself\n // (`defineSandbox(() => computer().open())`) names no export\n // to bind; a synchronous one is called once to read the request it returns,\n // which becomes the default target.\n if (selector && named.length === 0 && fallback == null) {\n const opened = probeSelector(namespace['default'], issues);\n if (opened != null) {\n targets['default'] = {\n exportName: 'sandbox',\n environment: lowerEnvironment(opened, 'sandbox.ts default export', issues),\n dynamic: null,\n };\n }\n }\n let defaultTarget: string | null = null;\n if (targets['default'] != null) defaultTarget = 'default';\n else if (named.length === 1) defaultTarget = named[0] ?? null;\n if (selector && defaultTarget == null) {\n issues.push(\n error(\n named.length === 0\n ? 'sandbox.ts default export opens a sandbox but no environment is exported; export the environment it opens (export const computer = computer({ ... }))'\n : 'sandbox.ts default export opens a sandbox but several environments are exported; the selector needs exactly one',\n ),\n );\n }\n return { type: 'sandbox', targets, providers, selector, defaultTarget };\n};\n\nconst sandboxIdentityOf = (\n namespace: AuthoredRecord | null,\n sandbox: DescribedSandboxIface | null,\n): Map<AuthoredValue, string> => {\n const identity = new Map<AuthoredValue, string>();\n if (namespace == null || sandbox == null) return identity;\n for (const [name, value] of Object.entries(namespace)) {\n if (name === 'default') {\n if (sandbox.defaultTarget != null) identity.set(value, sandbox.defaultTarget);\n } else if (sandbox.targets[name] != null) identity.set(value, name);\n }\n return identity;\n};\n\nconst describeModuleValue = (\n entry: NamespaceEntryIface,\n ctx: DescribeContextIface,\n sandbox: DescribedSandboxIface | null,\n issues: IssueIface[],\n): DescribedValue | null => {\n const { layout, namespace } = entry;\n const value = namespace['default'];\n switch (layout.slot) {\n case SlotKind.Agent:\n return describeAgent(value, ctx, issues);\n case SlotKind.Sandbox:\n return sandbox;\n case SlotKind.Instructions: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const fragment = lowerInstructions(value, null);\n if (fragment == null) {\n issues.push(\n error(\n `${layout.path} must export defineInstructions({ content, role }) or defineDynamic(...)`,\n ),\n );\n return null;\n }\n return { type: 'instructions', role: fragment.role, content: fragment.content };\n }\n case SlotKind.Skill: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const lowered = lowerSkill({ key: layout.key, value });\n issues.push(...lowered.issues);\n return { type: 'skill', skill: toJson(lowered.skill, { path: layout.path, issues }) };\n }\n case SlotKind.Tool: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const lowered = lowerTool({ name: layout.key, exportName: layout.base, value });\n issues.push(...lowered.issues);\n return {\n type: 'tool',\n descriptor: toJson(lowered.descriptor, { path: layout.path, issues }),\n approval: lowered.approval,\n };\n }\n case SlotKind.Connection: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const lowered = lowerConnection({ key: layout.key, exportName: layout.base, value });\n issues.push(...lowered.issues);\n return {\n type: 'connection',\n binding: toJson(lowered.binding, { path: layout.path, issues }),\n };\n }\n case SlotKind.Schedule:\n return {\n type: 'schedule',\n cron: stringOrNull(fieldOf(value, 'cron')),\n markdown: stringOrNull(fieldOf(value, 'markdown')),\n timezone: stringOrNull(fieldOf(value, 'timezone')),\n target: stringOrNull(fieldOf(value, 'target')),\n };\n case SlotKind.Hook: {\n const events = fieldOf(value, 'events');\n return {\n type: 'hook',\n keys: entriesOf(events).map(([key]) => key),\n };\n }\n case SlotKind.Channel: {\n const routes = fieldOf(value, 'routes');\n return {\n type: 'channel',\n disabled: fieldOf(value, 'disabled') === true,\n installed: toJson(fieldOf(value, 'installed') ?? null, {\n path: `${layout.path} installed`,\n issues,\n }),\n routes: Array.isArray(routes)\n ? routes.map((route) => ({\n method: String(fieldOf(route, 'method')),\n path: String(fieldOf(route, 'path')),\n }))\n : [],\n turnPolicy: stringOrNull(fieldOf(value, 'turnPolicy')),\n config: toJson(fieldOf(value, 'config') ?? {}, { path: `${layout.path} config`, issues }),\n };\n }\n }\n};\n\nexport const describeBundle = (\n entries: NamespaceEntryIface[],\n synthesized: string[],\n): DescribedBundleIface => {\n const sandboxEntry = entries.find((entry) => entry.layout.slot === SlotKind.Sandbox) ?? null;\n const sandboxIssues: IssueIface[] = [];\n let sandbox: DescribedSandboxIface | null = null;\n if (sandboxEntry != null) {\n try {\n sandbox = describeSandbox(sandboxEntry.namespace, sandboxIssues);\n } catch (cause) {\n sandboxIssues.push(error(`sandbox.ts could not be described: ${messageOf(cause)}`));\n }\n }\n const ctx: DescribeContextIface = {\n entries,\n sandboxIdentity: sandboxIdentityOf(sandboxEntry?.namespace ?? null, sandbox),\n };\n const modules: DescribedModuleIface[] = entries.map((entry) => {\n const issues: IssueIface[] = entry.layout.slot === SlotKind.Sandbox ? sandboxIssues : [];\n const hasDefault = 'default' in entry.namespace && entry.namespace['default'] !== undefined;\n let value: DescribedValue | null = null;\n if (hasDefault || entry.layout.slot === SlotKind.Sandbox) {\n try {\n value = describeModuleValue(entry, ctx, sandbox, issues);\n } catch (cause) {\n issues.push(error(`${entry.layout.path} could not be described: ${messageOf(cause)}`));\n }\n } else if (entry.layout.slot !== SlotKind.Agent) {\n issues.push(note(`${entry.layout.path} has no default export; treated as a helper module`));\n }\n return {\n base: entry.layout.base,\n path: entry.layout.path,\n slot: entry.layout.slot,\n key: entry.layout.key,\n hasDefault,\n issues,\n value,\n };\n });\n return { modules, synthesized };\n};\n\n// Export names the bundle synthesizes, in the order describe and the isolate\n// both compute them.\nexport const synthesizedExports = (\n entries: NamespaceEntryIface[],\n): { name: string; value: AuthoredValue }[] => {\n const out: { name: string; value: AuthoredValue }[] = [];\n for (const entry of entries) {\n if (entry.layout.slot !== SlotKind.Agent) continue;\n for (const found of collectAgentDynamics(entry.namespace['default'])) {\n out.push({ name: `${AGENT_DYNAMIC_PREFIX}${found.path}`, value: found.value });\n }\n }\n for (const pending of pendingEntries())\n out.push({ name: pendingExportName(pending.index), value: pending.value });\n return out;\n};\n\nexport const needsCombinedMcpServers = (entries: NamespaceEntryIface[]): boolean =>\n entries.some(\n (entry) =>\n (entry.layout.slot === SlotKind.Tool || entry.layout.slot === SlotKind.Connection) &&\n isDynamicSentinel(entry.namespace['default']),\n );\n\nexport { COMBINED_MCP_SERVERS_EXPORT };\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,YAAY,OAAO;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAUP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;A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AI,KAAK,EAAE,MAAM,kBAAkB,QAAQ,KAAK,GAAG,OAAO,QAAQ,MAAM,CAAC;AAC3E,SAAO;AACT;AAEO,MAAM,0BAA0B,CAAC,YACtC,QAAQ;AAAA,EACN,CAAC,WACE,MAAM,OAAO,SAAS,SAAS,QAAQ,MAAM,OAAO,SAAS,SAAS,eACvE,kBAAkB,MAAM,UAAU,SAAS,CAAC;AAChD;",
4
+ "sourcesContent": ["import {\n agentAvatarSchema,\n channelCredentialsSchema,\n channelSurfaceSchema,\n jsonValueSchema,\n hostedBindingRequirementSchema,\n type JsonObject,\n type JsonValue,\n} from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport {\n AuthoredKind,\n authoredKindOf,\n pendingEntries,\n pendingExportName,\n} from \"../authoring/brand.mjs\";\nimport type {\n DescribedAgentIface,\n DescribedBundleIface,\n DescribedDynamicIface,\n DescribedModuleIface,\n DescribedSandboxIface,\n DescribedSandboxTargetIface,\n DescribedValue,\n} from \"./described.mjs\";\nimport {\n AGENT_DYNAMIC_PREFIX,\n COMBINED_MCP_SERVERS_EXPORT,\n namedExportName,\n SlotKind,\n type LayoutModuleIface,\n} from \"./layout.mjs\";\nimport {\n childPath,\n dynamicEventsOf,\n error,\n isDynamicSentinel,\n isEnvironmentLike,\n isOpenRequestLike,\n lowerConnection,\n lowerEnvironment,\n lowerInstructions,\n lowerSkill,\n lowerTool,\n note,\n sandboxProviderNameOf,\n toJson,\n type IssueIface,\n} from \"./lower.mjs\";\nimport {\n entriesOf,\n fieldOf,\n isCallable,\n isObjectLike,\n isPlainObject,\n isPromiseLike,\n isString,\n messageOf,\n stringOrNull,\n type AuthoredRecord,\n type AuthoredValue,\n} from \"./values.mjs\";\n\n// Static extraction, run inside the realm that evaluated the bundle. Reads\n// authored values; never calls tool bodies, resolvers or routes, and calls a\n// sandbox selector only to read the request a synchronous one returns.\n\nexport interface NamespaceEntryIface {\n layout: LayoutModuleIface;\n namespace: AuthoredRecord;\n}\n\nexport const describeDynamic = (value: AuthoredValue): DescribedDynamicIface => {\n const provider = fieldOf(value, 'provider');\n let hint: DescribedDynamicIface['provider'] = null;\n if (provider != null) {\n const kind = fieldOf(provider, 'kind');\n const ref = fieldOf(provider, 'providerRef');\n const issues: IssueIface[] = [];\n if ((kind === 'package' || kind === 'bundle') && provider != null) {\n hint = { ref: toJson(provider, { path: 'provider', issues }), name: null };\n } else if (ref != null) {\n hint = { ref: toJson(ref, { path: 'provider', issues }), name: null };\n } else {\n hint = {\n ref: null,\n name:\n stringOrNull(fieldOf(provider, 'name')) ??\n stringOrNull(fieldOf(fieldOf(provider, 'definition'), 'name')),\n };\n }\n }\n return {\n type: 'dynamic',\n events: dynamicEventsOf(value),\n description: stringOrNull(fieldOf(value, 'description')),\n preview: stringOrNull(fieldOf(value, 'preview')),\n provider: hint,\n requiredBindings: z\n .array(hostedBindingRequirementSchema)\n .parse(fieldOf(value, 'requiredBindings') ?? []),\n };\n};\n\n// Dynamic sentinels inside agent.ts's harness config, addressed by their authored path. The bundle exports each as\n// `agent:<path>`.\nexport const collectAgentDynamics = (\n agent: AuthoredValue,\n): { path: string; value: AuthoredValue }[] => {\n const found: { path: string; value: AuthoredValue }[] = [];\n const walk = (value: AuthoredValue, path: string, depth: number): void => {\n if (depth > 32) return;\n if (isDynamicSentinel(value)) {\n found.push({ path, value });\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((item, index) => walk(item, childPath(path, index), depth + 1));\n return;\n }\n if (isPlainObject(value) || authoredKindOf(value) != null) {\n for (const [key, item] of entriesOf(value)) walk(item, childPath(path, key), depth + 1);\n }\n };\n walk(fieldOf(fieldOf(agent, 'harness'), 'config'), 'harness.config', 0);\n return found;\n};\n\nconst dynamicSlot = (value: AuthoredValue, path: string): JsonValue => {\n const described = describeDynamic(value);\n const slot: JsonObject = { resolver: `${AGENT_DYNAMIC_PREFIX}${path}`, events: described.events };\n if (described.description != null) slot['description'] = described.description;\n if (described.preview != null) slot['preview'] = described.preview;\n if ((described.requiredBindings?.length ?? 0) > 0)\n slot['requiredBindings'] = jsonValueSchema.parse(described.requiredBindings);\n return { $dynamic: slot };\n};\n\nconst isDefinedHarnessLike = (value: AuthoredValue): boolean =>\n isCallable(value) && isCallable(fieldOf(value, 'describe')) && isCallable(fieldOf(value, 'open'));\n\nconst KNOWN_AGENT_FIELDS: ReadonlySet<string> = new Set([\n 'name',\n 'description',\n 'avatar',\n 'harness',\n 'tools',\n 'toolPolicy',\n 'secrets',\n 'channels',\n]);\n\n// Harness configuration belongs in the harness binding rather than top-level agent fields.\nconst HARNESS_CONFIG_FIELDS: ReadonlySet<string> = new Set([\n 'model',\n 'reasoning',\n 'credentials',\n 'permissions',\n 'permissionMode',\n 'instructions',\n 'skills',\n 'system',\n 'temperature',\n 'providerOptions',\n 'maxSteps',\n 'stopWhen',\n]);\n\nconst unknownAgentField = (key: string): string => {\n if (HARNESS_CONFIG_FIELDS.has(key))\n return `agent.ts field ${key} belongs in harness config (harness: serverlessPi({ ${key}: ... }))`;\n if (key === 'defaultTools')\n return 'agent.ts field defaultTools is not supported: base tools are declared with tools: baseTools({ ... }) and are off by default';\n if (key === 'subagents' || key === 'memory') return `agent.ts field ${key} is not supported yet`;\n return `agent.ts field ${key} is not an agent field (name, description, avatar, harness, tools, toolPolicy, secrets, channels)`;\n};\n\ninterface DescribeContextIface {\n entries: NamespaceEntryIface[];\n sandboxIdentity: Map<AuthoredValue, string>;\n}\n\nconst describeHarness = (\n harness: AuthoredValue,\n ctx: DescribeContextIface,\n issues: IssueIface[],\n): DescribedAgentIface['harness'] => {\n if (harness == null) return null;\n const ref = fieldOf(harness, 'harness');\n if (!isObjectLike(ref)) {\n issues.push(error('agent.ts harness must be a harness binding, e.g. serverlessPi({ ... })'));\n return null;\n }\n let refJson = toJson(ref, { path: 'harness.harness', issues });\n if (fieldOf(ref, 'kind') === 'bundle' && fieldOf(ref, 'export') === '<pending>') {\n const candidates = ctx.entries.flatMap((entry) =>\n Object.entries(entry.namespace)\n .filter(([, value]) => isDefinedHarnessLike(value))\n .map(([name]) => namedExportName(entry.layout.base, name)),\n );\n if (candidates.length === 1 && candidates[0] != null)\n refJson = { kind: 'bundle', export: candidates[0] };\n else\n issues.push(\n error(\n 'the custom harness must come from defineHarness in @finalai/agents, or be exported once',\n ),\n );\n }\n const config = toJson(fieldOf(harness, 'config') ?? {}, {\n path: 'harness.config',\n issues,\n visit: (value, path) => (isDynamicSentinel(value) ? dynamicSlot(value, path) : undefined),\n });\n return { harness: refJson, config };\n};\n\n// Capabilities bound to sandbox targets (by export name) and those declared on\n// the harness's own host (`harnessHost`).\nconst describeBaseTools = (\n tools: AuthoredValue,\n ctx: DescribeContextIface,\n issues: IssueIface[],\n): { targets: Record<string, string>; host: string[] } | null => {\n if (tools == null) return null;\n if (authoredKindOf(tools) !== AuthoredKind.BaseTools) {\n issues.push(error('agent.ts tools must be baseTools({ shell: target, files: target, ... })'));\n return null;\n }\n const base = fieldOf(tools, 'base');\n const out: Record<string, string> = {};\n const host: string[] = [];\n if (!isPlainObject(base)) return { targets: out, host };\n for (const [capability, target] of Object.entries(base)) {\n if (target == null) continue;\n if (authoredKindOf(target) === AuthoredKind.HarnessHost) {\n host.push(capability);\n continue;\n }\n if (isString(target)) {\n out[capability] = target;\n continue;\n }\n const name = ctx.sandboxIdentity.get(target);\n if (name == null) {\n issues.push(\n error(\n `baseTools ${capability} is bound to a value that is not a sandbox target exported from sandbox.ts`,\n ),\n );\n continue;\n }\n out[capability] = name;\n }\n return { targets: out, host };\n};\n\nconst describeSecrets = (value: AuthoredValue, issues: IssueIface[]): string[] | null => {\n if (value == null) return null;\n const parsed = z.array(z.string().min(1)).safeParse(value);\n if (parsed.success) return parsed.data;\n issues.push(error('agent.ts secrets must be a list of secret names'));\n return null;\n};\n\nconst describeAvatar = (\n value: AuthoredValue,\n issues: IssueIface[],\n): DescribedAgentIface['avatar'] => {\n if (value === undefined) return null;\n const parsed = agentAvatarSchema.safeParse(toJson(value, { path: 'avatar', issues }));\n if (parsed.success) return parsed.data;\n for (const issue of parsed.error.issues) {\n issues.push(\n error(\n `agent.ts avatar${issue.path.length > 0 ? `.${issue.path.join('.')}` : ''}: ${issue.message}`,\n ),\n );\n }\n return null;\n};\n\nconst invalidChannelFields = (value: AuthoredValue): string[] => {\n const invalid: string[] = [];\n if (!z.string().min(1).safeParse(fieldOf(value, 'name')).success) invalid.push('name');\n if (!channelCredentialsSchema.safeParse(fieldOf(value, 'credentials')).success)\n invalid.push('credentials');\n const identity = fieldOf(value, 'identity');\n const kind = fieldOf(identity, 'kind');\n if (\n (kind !== 'none' && kind !== 'redirect' && kind !== 'challenge') ||\n (kind === 'redirect' && !isCallable(fieldOf(identity, 'start'))) ||\n (kind === 'challenge' && !isCallable(fieldOf(identity, 'deliver')))\n )\n invalid.push('identity');\n if (!z.array(z.string()).safeParse(fieldOf(fieldOf(value, 'places'), 'kinds')).success)\n invalid.push('places');\n if (!isCallable(fieldOf(value, 'receive'))) invalid.push('receive');\n return invalid;\n};\n\nconst channelSurfaceOf = (value: AuthoredValue) => {\n const routes = fieldOf(value, 'routes');\n const listeners = fieldOf(value, 'listeners');\n return {\n routes: Array.isArray(routes)\n ? routes.map((route) => ({\n method: String(fieldOf(route, 'method')),\n path: String(fieldOf(route, 'path')),\n }))\n : [],\n listeners: Array.isArray(listeners)\n ? listeners.map((listener) => String(fieldOf(listener, 'key')))\n : [],\n placeKinds:\n z.array(z.string()).safeParse(fieldOf(fieldOf(value, 'places'), 'kinds')).data ?? [],\n };\n};\n\nconst describeAgent = (\n value: AuthoredValue,\n ctx: DescribeContextIface,\n issues: IssueIface[],\n): DescribedAgentIface | null => {\n if (value == null) return null;\n if (!isPlainObject(value)) {\n issues.push(error('agent.ts must export defineAgent({ ... }) as its default export'));\n return null;\n }\n for (const key of Object.keys(value)) {\n if (!KNOWN_AGENT_FIELDS.has(key)) issues.push(error(unknownAgentField(key)));\n }\n const toolPolicyRaw = value['toolPolicy'];\n let toolPolicy: Record<string, string> | null = null;\n if (isPlainObject(toolPolicyRaw)) {\n toolPolicy = {};\n for (const [key, policy] of Object.entries(toolPolicyRaw)) {\n if (policy === 'allow' || policy === 'ask') toolPolicy[key] = policy;\n else issues.push(error(`agent.ts toolPolicy.${key} must be 'allow' or 'ask'`));\n }\n }\n const channelsRaw = value['channels'];\n let channels: DescribedAgentIface['channels'] = null;\n if (Array.isArray(channelsRaw)) {\n channels = channelsRaw.map((binding, index) => ({\n key: stringOrNull(fieldOf(binding, 'key')),\n install: stringOrNull(fieldOf(binding, 'install')),\n credentials: channelCredentialsSchema.safeParse(fieldOf(binding, 'credentials')).data ?? null,\n surface:\n channelSurfaceSchema.safeParse(\n fieldOf(binding, 'surface') ??\n (fieldOf(binding, 'places') == null ? null : channelSurfaceOf(binding)),\n ).data ?? null,\n channel: toJson(fieldOf(binding, 'channel') ?? fieldOf(binding, 'installed') ?? null, {\n path: `channels[${index}].channel`,\n issues,\n }),\n config: toJson(fieldOf(binding, 'config') ?? {}, {\n path: `channels[${index}].config`,\n issues,\n }),\n }));\n }\n const baseToolsDescription = describeBaseTools(value['tools'], ctx, issues);\n return {\n type: 'agent',\n name: stringOrNull(value['name']),\n description: stringOrNull(value['description']),\n avatar: describeAvatar(value['avatar'], issues),\n harness: describeHarness(value['harness'], ctx, issues),\n tools: baseToolsDescription?.targets ?? null,\n hostTools: baseToolsDescription?.host ?? null,\n toolPolicy,\n secrets: describeSecrets(value['secrets'], issues),\n channels,\n };\n};\n\nconst probeSelector = (selector: AuthoredValue, issues: IssueIface[]): AuthoredValue | null => {\n if (!isCallable(selector)) return null;\n try {\n const result = selector({\n session: null,\n secrets: { get: async () => null },\n open: async () => {\n throw new Error('sandboxes do not open while compiling');\n },\n });\n if (isEnvironmentLike(result) || isOpenRequestLike(result)) return result;\n // An async selector: what it opens is known only at session start.\n if (isPromiseLike(result)) Promise.resolve(result).catch(() => undefined);\n return null;\n } catch (cause) {\n issues.push(\n error(\n `sandbox.ts selector failed during compilation: ${String(cause)}; export its environment when it needs session context`,\n ),\n );\n return null;\n }\n};\n\nconst describeSandbox = (\n namespace: AuthoredRecord,\n issues: IssueIface[],\n): DescribedSandboxIface => {\n const targets: Record<string, DescribedSandboxTargetIface> = {};\n const providers: Record<string, string> = {};\n const describeTarget = (\n value: AuthoredValue,\n exportName: string,\n path: string,\n ): DescribedSandboxTargetIface | null => {\n if (isDynamicSentinel(value))\n return { exportName, environment: null, dynamic: describeDynamic(value) };\n if (isEnvironmentLike(value) || isOpenRequestLike(value)) {\n return { exportName, environment: lowerEnvironment(value, path, issues), dynamic: null };\n }\n return null;\n };\n for (const [name, value] of Object.entries(namespace)) {\n if (name === 'default') continue;\n const exportName = namedExportName('sandbox', name);\n const providerName = sandboxProviderNameOf(value);\n if (providerName != null) {\n providers[exportName] = providerName;\n continue;\n }\n const target = describeTarget(value, exportName, `sandbox.ts ${name}`);\n if (target != null) targets[name] = target;\n }\n const named = Object.keys(targets);\n const fallback = describeTarget(namespace['default'], 'sandbox', 'sandbox.ts default export');\n const selector = authoredKindOf(namespace['default']) === AuthoredKind.SandboxSelector;\n if (fallback != null) targets['default'] = fallback;\n else if (namespace['default'] != null && !selector) {\n issues.push(\n error(\n 'sandbox.ts default export must be defineSandbox(selector), an environment, or defineDynamic(...)',\n ),\n );\n }\n // A selector that opens an environment it creates itself\n // (`defineSandbox(() => computer().open())`) names no export\n // to bind; a synchronous one is called once to read the request it returns,\n // which becomes the default target.\n if (selector && named.length === 0 && fallback == null) {\n const opened = probeSelector(namespace['default'], issues);\n if (opened != null) {\n targets['default'] = {\n exportName: 'sandbox',\n environment: lowerEnvironment(opened, 'sandbox.ts default export', issues),\n dynamic: null,\n };\n }\n }\n let defaultTarget: string | null = null;\n if (targets['default'] != null) defaultTarget = 'default';\n else if (named.length === 1) defaultTarget = named[0] ?? null;\n if (selector && defaultTarget == null) {\n issues.push(\n error(\n named.length === 0\n ? 'sandbox.ts default export opens a sandbox but no environment is exported; export the environment it opens (export const computer = computer({ ... }))'\n : 'sandbox.ts default export opens a sandbox but several environments are exported; the selector needs exactly one',\n ),\n );\n }\n return { type: 'sandbox', targets, providers, selector, defaultTarget };\n};\n\nconst sandboxIdentityOf = (\n namespace: AuthoredRecord | null,\n sandbox: DescribedSandboxIface | null,\n): Map<AuthoredValue, string> => {\n const identity = new Map<AuthoredValue, string>();\n if (namespace == null || sandbox == null) return identity;\n for (const [name, value] of Object.entries(namespace)) {\n if (name === 'default') {\n if (sandbox.defaultTarget != null) identity.set(value, sandbox.defaultTarget);\n } else if (sandbox.targets[name] != null) identity.set(value, name);\n }\n return identity;\n};\n\nconst describeModuleValue = (\n entry: NamespaceEntryIface,\n ctx: DescribeContextIface,\n sandbox: DescribedSandboxIface | null,\n issues: IssueIface[],\n): DescribedValue | null => {\n const { layout, namespace } = entry;\n const value = namespace['default'];\n switch (layout.slot) {\n case SlotKind.Agent:\n return describeAgent(value, ctx, issues);\n case SlotKind.Sandbox:\n return sandbox;\n case SlotKind.Instructions: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const fragment = lowerInstructions(value, null);\n if (fragment == null) {\n issues.push(\n error(\n `${layout.path} must export defineInstructions({ content, role }) or defineDynamic(...)`,\n ),\n );\n return null;\n }\n return { type: 'instructions', role: fragment.role, content: fragment.content };\n }\n case SlotKind.Skill: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const lowered = lowerSkill({ key: layout.key, value });\n issues.push(...lowered.issues);\n return { type: 'skill', skill: toJson(lowered.skill, { path: layout.path, issues }) };\n }\n case SlotKind.Tool: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const lowered = lowerTool({ name: layout.key, exportName: layout.base, value });\n issues.push(...lowered.issues);\n return {\n type: 'tool',\n descriptor: toJson(lowered.descriptor, { path: layout.path, issues }),\n approval: lowered.approval,\n };\n }\n case SlotKind.Connection: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const lowered = lowerConnection({ key: layout.key, exportName: layout.base, value });\n issues.push(...lowered.issues);\n return {\n type: 'connection',\n binding: toJson(lowered.binding, { path: layout.path, issues }),\n };\n }\n case SlotKind.Schedule:\n return {\n type: 'schedule',\n cron: stringOrNull(fieldOf(value, 'cron')),\n markdown: stringOrNull(fieldOf(value, 'markdown')),\n timezone: stringOrNull(fieldOf(value, 'timezone')),\n target: stringOrNull(fieldOf(value, 'target')),\n };\n case SlotKind.Hook: {\n const events = fieldOf(value, 'events');\n return {\n type: 'hook',\n keys: entriesOf(events).map(([key]) => key),\n };\n }\n case SlotKind.Channel: {\n const routes = fieldOf(value, 'routes');\n return {\n type: 'channel',\n disabled: fieldOf(value, 'disabled') === true,\n installed: toJson(fieldOf(value, 'installed') ?? null, {\n path: `${layout.path} installed`,\n issues,\n }),\n routes: Array.isArray(routes)\n ? routes.map((route) => ({\n method: String(fieldOf(route, 'method')),\n path: String(fieldOf(route, 'path')),\n }))\n : [],\n room: authoredKindOf(value) === AuthoredKind.RoomSurface,\n invalidFields:\n authoredKindOf(value) === AuthoredKind.RoomSurface || fieldOf(value, 'disabled') === true\n ? []\n : invalidChannelFields(value),\n credentials: channelCredentialsSchema.safeParse(fieldOf(value, 'credentials')).data ?? {\n app: null,\n },\n surface: {\n routes: Array.isArray(routes)\n ? routes.map((route) => ({\n method: String(fieldOf(route, 'method')),\n path: String(fieldOf(route, 'path')),\n }))\n : [],\n listeners: Array.isArray(fieldOf(value, 'listeners'))\n ? entriesOf(fieldOf(value, 'listeners')).map(([, listener]) =>\n String(fieldOf(listener, 'key')),\n )\n : [],\n placeKinds:\n z.array(z.string()).safeParse(fieldOf(fieldOf(value, 'places'), 'kinds')).data ?? [],\n },\n config: toJson(fieldOf(value, 'config') ?? {}, { path: `${layout.path} config`, issues }),\n };\n }\n }\n};\n\nexport const describeBundle = (\n entries: NamespaceEntryIface[],\n synthesized: string[],\n): DescribedBundleIface => {\n const sandboxEntry = entries.find((entry) => entry.layout.slot === SlotKind.Sandbox) ?? null;\n const sandboxIssues: IssueIface[] = [];\n let sandbox: DescribedSandboxIface | null = null;\n if (sandboxEntry != null) {\n try {\n sandbox = describeSandbox(sandboxEntry.namespace, sandboxIssues);\n } catch (cause) {\n sandboxIssues.push(error(`sandbox.ts could not be described: ${messageOf(cause)}`));\n }\n }\n const ctx: DescribeContextIface = {\n entries,\n sandboxIdentity: sandboxIdentityOf(sandboxEntry?.namespace ?? null, sandbox),\n };\n const modules: DescribedModuleIface[] = entries.map((entry) => {\n const issues: IssueIface[] = entry.layout.slot === SlotKind.Sandbox ? sandboxIssues : [];\n const hasDefault = 'default' in entry.namespace && entry.namespace['default'] !== undefined;\n let value: DescribedValue | null = null;\n if (hasDefault || entry.layout.slot === SlotKind.Sandbox) {\n try {\n value = describeModuleValue(entry, ctx, sandbox, issues);\n } catch (cause) {\n issues.push(error(`${entry.layout.path} could not be described: ${messageOf(cause)}`));\n }\n } else if (entry.layout.slot !== SlotKind.Agent) {\n issues.push(note(`${entry.layout.path} has no default export; treated as a helper module`));\n }\n return {\n base: entry.layout.base,\n path: entry.layout.path,\n slot: entry.layout.slot,\n key: entry.layout.key,\n hasDefault,\n issues,\n value,\n };\n });\n return { modules, synthesized };\n};\n\n// Export names the bundle synthesizes, in the order describe and the isolate\n// both compute them.\nexport const synthesizedExports = (\n entries: NamespaceEntryIface[],\n): { name: string; value: AuthoredValue }[] => {\n const out: { name: string; value: AuthoredValue }[] = [];\n for (const entry of entries) {\n if (entry.layout.slot !== SlotKind.Agent) continue;\n for (const found of collectAgentDynamics(entry.namespace['default'])) {\n out.push({ name: `${AGENT_DYNAMIC_PREFIX}${found.path}`, value: found.value });\n }\n }\n for (const pending of pendingEntries())\n out.push({ name: pendingExportName(pending.index), value: pending.value });\n return out;\n};\n\nexport const needsCombinedMcpServers = (entries: NamespaceEntryIface[]): boolean =>\n entries.some(\n (entry) =>\n (entry.layout.slot === SlotKind.Tool || entry.layout.slot === SlotKind.Connection) &&\n isDynamicSentinel(entry.namespace['default']),\n );\n\nexport { COMBINED_MCP_SERVERS_EXPORT };\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAA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