@agent-surface/compiler 0.18.0 → 0.19.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/compile.ts","../src/plugin.ts","../src/canonical.ts","../src/extract.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport type { CapabilityContractManifest } from \"@agent-surface/core\";\nimport { build, type InlineConfig } from \"vite\";\nimport { agentSurface, type ExternalContractPolicy } from \"./plugin.js\";\n\nexport interface CompileCapabilityContractOptions {\n root?: string;\n configFile?: string;\n target?: string;\n /**\n * Which dependencies may contribute capabilities. Forwarded to the compiler\n * plugin: without it, every discovered external contract is unauthorized and\n * the build fails.\n */\n externalContracts?: ExternalContractPolicy;\n vite?: InlineConfig;\n}\n\nexport async function compileCapabilityContract(\n options: CompileCapabilityContractOptions = {},\n): Promise<CapabilityContractManifest> {\n let manifest: CapabilityContractManifest | undefined;\n const root = resolve(options.root ?? process.cwd());\n const result = await build({\n ...(options.vite ?? {}),\n root,\n ...(options.configFile ? { configFile: resolve(root, options.configFile) } : {}),\n logLevel: options.vite?.logLevel ?? \"silent\",\n build: {\n ...(options.vite?.build ?? {}),\n write: false,\n },\n plugins: [\n ...(options.vite?.plugins ?? []),\n agentSurface({\n target: options.target,\n emit: false,\n ...(options.externalContracts ? { externalContracts: options.externalContracts } : {}),\n onManifest: (value) => {\n manifest = value;\n },\n }),\n ],\n });\n const outputs = Array.isArray(result) ? result : [result];\n for (const output of outputs) {\n if (!(\"output\" in output)) continue;\n const asset = output.output.find(\n (entry) => entry.type === \"asset\" && entry.fileName === \"agent-surface.contract.json\",\n );\n if (asset?.type === \"asset\") {\n const source = typeof asset.source === \"string\"\n ? asset.source\n : new TextDecoder().decode(asset.source);\n manifest = JSON.parse(source) as CapabilityContractManifest;\n break;\n }\n }\n if (!manifest) throw new Error(\"compiler did not produce a capability contract\");\n return manifest;\n}\n","import { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport {\n DEFAULT_LIMITS,\n parseCapabilityId,\n validateJsonSchemaDocument,\n} from \"@agent-surface/core\";\nimport type { CapabilityContractEntry, CapabilityContractManifest } from \"@agent-surface/core\";\nimport type { Plugin, ResolvedConfig } from \"vite\";\nimport { canonicalJson, canonicalManifestJson, computeManifestHash, sha256, verifyManifest } from \"./canonical.js\";\nimport { extractModule } from \"./extract.js\";\n\nexport const COMPILER_VERSION = \"0.17.0\";\nexport const CONTRACT_FILE = \"agent-surface.contract.json\";\nexport const VIRTUAL_CONTRACT_ID = \"virtual:agent-surface-contract\";\nconst RESOLVED_VIRTUAL_CONTRACT_ID = `\\0${VIRTUAL_CONTRACT_ID}`;\n\n/**\n * One dependency the consumer has approved as a capability contributor.\n *\n * Keyed by package name rather than path: a path is a property of the installer\n * (pnpm store layout, hoisting, workspace links), while the name is what a\n * reviewer actually approves.\n */\nexport interface ExternalContractAllowEntry {\n /** npm package name, exactly as in its package.json. */\n package: string;\n /** sha256 of that package's contribution, as reported by a failing build. */\n digest: string;\n /**\n * Explicit sidecar path, for a contract that is not reachable from the\n * production module graph. Auto-discovered sidecars need no path.\n */\n path?: string;\n}\n\nexport interface ExternalContractPolicy {\n /**\n * Dependencies allowed to contribute capabilities. A contribution from a\n * package absent here fails the build: discovery is not authorization.\n */\n allow?: ExternalContractAllowEntry[];\n}\n\nexport interface AgentSurfaceCompilerOptions {\n target?: string;\n emit?: boolean;\n fileName?: string;\n externalContracts?: ExternalContractPolicy;\n onManifest?: (manifest: CapabilityContractManifest) => void;\n}\n\n/** A dependency's capabilities plus how they were found, before authorization. */\ninterface ExternalContribution {\n package: string;\n source: string;\n route: \"sidecar\" | \"source\";\n contractDigest: string;\n entries: CapabilityContractEntry[];\n}\n\nfunction mergeEntries(entries: CapabilityContractEntry[]): CapabilityContractEntry[] {\n const byKey = new Map<string, CapabilityContractEntry>();\n for (const entry of entries) {\n const key = `${entry.declarationId}\\0${entry.capabilityId}`;\n const current = byKey.get(key);\n if (!current) {\n byKey.set(key, { ...entry, targets: [...entry.targets] });\n continue;\n }\n if (current.contractHash !== entry.contractHash) {\n throw new Error(`contract \"${entry.declarationId}\" / \"${entry.capabilityId}\" differs across build targets`);\n }\n current.targets = [...new Set([...current.targets, ...entry.targets])].sort();\n }\n return [...byKey.values()].sort((a, b) =>\n `${a.declarationId}\\0${a.capabilityId}`.localeCompare(`${b.declarationId}\\0${b.capabilityId}`),\n );\n}\n\nfunction validateEntries(entries: readonly CapabilityContractEntry[]): void {\n for (const entry of entries) {\n if (entry.kind !== \"external\" && !parseCapabilityId(entry.capabilityId)) {\n throw new Error(`invalid compiled capability id \"${entry.capabilityId}\"`);\n }\n for (const [label, schema] of [[\"input\", entry.inputSchema], [\"output\", entry.outputSchema]] as const) {\n if (!schema) continue;\n const result = validateJsonSchemaDocument(schema, DEFAULT_LIMITS);\n if (!result.ok) {\n throw new Error(`${entry.declarationId} ${label} schema: ${result.reason}`);\n }\n }\n }\n}\n\ninterface NearestPackage {\n name: string;\n dir: string;\n packagePath: string;\n sidecar?: string;\n}\n\n/** The package.json governing a module id, with its declared sidecar if any. */\nfunction nearestPackage(id: string): NearestPackage | undefined {\n if (id.startsWith(\"\\0\") || !isAbsolute(id)) return undefined;\n let dir = dirname(id.split(\"?\")[0]!);\n while (dir !== dirname(dir)) {\n const packagePath = join(dir, \"package.json\");\n if (existsSync(packagePath)) {\n const pkg = JSON.parse(readFileSync(packagePath, \"utf8\")) as {\n name?: string;\n agentSurface?: { contract?: string };\n };\n if (!pkg.name) return undefined;\n return {\n name: pkg.name,\n dir,\n packagePath,\n ...(pkg.agentSurface?.contract ? { sidecar: resolve(dir, pkg.agentSurface.contract) } : {}),\n };\n }\n dir = dirname(dir);\n }\n return undefined;\n}\n\n/**\n * A module is first-party when it is not installed as a dependency. Vite\n * resolves to real paths, so a workspace package symlinked into node_modules\n * reads as first-party — which is correct: the authority describes one\n * deployable build, and its own workspace is part of it.\n */\nfunction isDependencyModule(id: string): boolean {\n return id.split(\"?\")[0]!.includes(`${sep}node_modules${sep}`);\n}\n\nfunction readSidecar(path: string): { manifest: CapabilityContractManifest; digest: string } {\n const bytes = readFileSync(path);\n const manifest = JSON.parse(bytes.toString(\"utf8\")) as CapabilityContractManifest;\n verifyManifest(manifest);\n return { manifest, digest: sha256(bytes) };\n}\n\n/**\n * Match each contribution against the consumer's allow list.\n *\n * Discovery is deliberately not authorization: an unapproved dependency is\n * reported with the digest to approve, so the fix is a reviewable one-line\n * addition rather than a flag that turns the check off.\n */\nfunction authorizeContributions(\n contributions: readonly ExternalContribution[],\n policy: ExternalContractPolicy | undefined,\n): CapabilityContractManifest[\"externalContracts\"] {\n const allow = new Map((policy?.allow ?? []).map((entry) => [entry.package, entry]));\n const unauthorized: string[] = [];\n const mismatched: string[] = [];\n const attributions: CapabilityContractManifest[\"externalContracts\"] = [];\n\n for (const contribution of contributions) {\n const approved = allow.get(contribution.package);\n if (!approved) {\n unauthorized.push(\n ` ${contribution.package} (${contribution.route}: ${contribution.source})\\n` +\n ` { \"package\": \"${contribution.package}\", \"digest\": \"${contribution.contractDigest}\" }`,\n );\n continue;\n }\n if (approved.digest !== contribution.contractDigest) {\n mismatched.push(\n ` ${contribution.package}: approved ${approved.digest}, this build computed ${contribution.contractDigest}`,\n );\n continue;\n }\n attributions.push({\n package: contribution.package,\n source: contribution.source,\n route: contribution.route,\n contractDigest: contribution.contractDigest,\n authorization: { mode: \"pinned\", expectedDigest: approved.digest },\n });\n }\n\n if (unauthorized.length > 0) {\n throw new Error(\n `unauthorized external capability contract(s). A dependency cannot contribute capabilities ` +\n `until the consumer approves it. Add to externalContracts.allow:\\n${unauthorized.join(\"\\n\")}`,\n );\n }\n if (mismatched.length > 0) {\n throw new Error(\n `external capability contract digest mismatch. The dependency changed what it contributes; ` +\n `review the change before updating the approved digest:\\n${mismatched.join(\"\\n\")}`,\n );\n }\n return attributions.sort((a, b) => a.package.localeCompare(b.package));\n}\n\n/**\n * Compiled contracts for serve runs, keyed by root and target.\n *\n * The compile is a full production build, so it is memoised: a vitest run with\n * several environments would otherwise pay for it once per environment. Cleared\n * when a module that declares a contract changes, so the dev server does not\n * serve yesterday's ceiling.\n */\nconst serveManifests = new Map<string, Promise<CapabilityContractManifest>>();\n\nfunction compileServeManifest(options: {\n root: string;\n target: string;\n externalContracts?: ExternalContractPolicy;\n /**\n * The serving config's own resolution, forwarded so the inner build resolves\n * imports exactly as the outer one does. Without it a project that aliases\n * inline rather than in a config file — every vitest setup that maps a\n * workspace package, for one — compiles against different modules than it\n * serves, or fails to resolve them at all.\n */\n alias: ResolvedConfig[\"resolve\"][\"alias\"] | undefined;\n configFile: string | false | undefined;\n}): Promise<CapabilityContractManifest> {\n const key = `${options.root}\\0${options.target}`;\n const cached = serveManifests.get(key);\n if (cached) return cached;\n // Imported lazily: compile.ts imports this module, and only one of the two\n // edges may be static.\n const pending = import(\"./compile.js\").then(({ compileCapabilityContract }) =>\n compileCapabilityContract({\n root: options.root,\n target: options.target,\n ...(options.externalContracts ? { externalContracts: options.externalContracts } : {}),\n vite: {\n ...(options.configFile === false ? { configFile: false as const } : {}),\n ...(options.alias ? { resolve: { alias: options.alias } } : {}),\n },\n }),\n );\n serveManifests.set(key, pending);\n // A failed compile must not be cached, or the first broken contract poisons\n // the dev server until it is restarted.\n void pending.catch(() => serveManifests.delete(key));\n return pending;\n}\n\nexport function agentSurface(options: AgentSurfaceCompilerOptions = {}): Plugin {\n const target = options.target ?? \"web-production\";\n const placeholder = `__AGENT_SURFACE_MANIFEST_HASH_${Math.random().toString(36).slice(2)}__`;\n const manifestPlaceholder = `__AGENT_SURFACE_MANIFEST_${Math.random().toString(36).slice(2)}__`;\n let root = process.cwd();\n let entries: CapabilityContractEntry[] = [];\n /** Capabilities extracted from a dependency's own source, by package. */\n let sourceEntries = new Map<string, CapabilityContractEntry[]>();\n let manifest: CapabilityContractManifest | undefined;\n /** True under the dev server and the test runner; false in a production build. */\n let serve = false;\n let serveAlias: ResolvedConfig[\"resolve\"][\"alias\"] | undefined;\n let serveConfigFile: string | false | undefined;\n\n /** The eagerly-compiled manifest, or a clear failure. Serve mode only. */\n const servedManifest = (): CapabilityContractManifest => {\n if (!manifest) throw new Error(\"agent-surface: contract not compiled for this dev/test run\");\n return manifest;\n };\n\n /**\n * What a contract's proof must carry as its manifest hash.\n *\n * In a build that is the placeholder, rewritten once the manifest exists. In\n * serve the real hash is already known, and stamping it here is what lets a\n * registration pass `assertDefinitionAuthorized` outside a build.\n */\n const manifestHashToken = (): string => (serve ? servedManifest().hash : placeholder);\n\n return {\n name: \"agent-surface:compiler\",\n enforce: \"pre\",\n configResolved(config) {\n root = config.root;\n // `serve` covers the dev server AND vitest, which drives the same\n // pipeline. Rollup's output hooks (renderChunk, generateBundle) never run\n // there, so the placeholders they rewrite have to be resolved up front —\n // see `buildStart` below.\n serve = config.command === \"serve\";\n serveAlias = config.resolve?.alias;\n serveConfigFile = config.configFile === undefined ? false : config.configFile;\n },\n resolveId(id) {\n return id === VIRTUAL_CONTRACT_ID ? RESOLVED_VIRTUAL_CONTRACT_ID : null;\n },\n load(id) {\n if (id !== RESOLVED_VIRTUAL_CONTRACT_ID) return null;\n // In a build the manifest is not known until every module has been\n // transformed, so the placeholder stands in and `renderChunk` rewrites\n // it. Under serve it is already computed and can be inlined.\n const inlined = serve ? JSON.stringify(servedManifest()) : manifestPlaceholder;\n return `import { createCapabilityAuthority } from \"@agent-surface/core\";\nconst manifest = ${inlined};\nexport { manifest };\nexport default createCapabilityAuthority(manifest);`;\n },\n async buildStart() {\n entries = [];\n sourceEntries = new Map();\n manifest = undefined;\n if (!serve) return;\n // Serve mode compiles the contract eagerly, through the same production\n // build the CLI uses, because a lazily-transformed module graph cannot\n // tell us the manifest hash that every contract's proof has to carry.\n // Without this the dev server and the test runner would have no\n // authority at all, and every registration would be refused.\n manifest = await compileServeManifest({\n root,\n target,\n alias: serveAlias,\n configFile: serveConfigFile,\n ...(options.externalContracts ? { externalContracts: options.externalContracts } : {}),\n });\n },\n transform(code, id) {\n if (\n id.includes(\"/node_modules/@agent-surface/\") ||\n /\\/packages\\/(?:core|react|orpc|testing|webmcp|cli|compiler)\\//.test(id) ||\n // Vite's optimized-dependency chunks, which exist only under serve.\n // They are bundled OUTPUT — several dependencies concatenated, this\n // package among them — so the guards below would read our own\n // `registry.register({` back out of a vendor chunk and refuse to serve\n // the app. A dependency's real contracts are picked up from its actual\n // module, via the sidecar and source routes, not from optimizer output.\n id.includes(\"/node_modules/.vite/\")\n ) {\n return null;\n }\n if (/\\buseAgentComponent\\s*\\(\\s*\\{/.test(code)) {\n throw new Error(`${id}: inline useAgentComponent registration is unsupported; bind a compiled contract`);\n }\n if (/\\b(?:useAgentAction|useAgentObservation)\\s*\\(/.test(code)) {\n throw new Error(`${id}: granular runtime capability construction is unsupported by the compiled contract`);\n }\n if (/\\bdefineAgentComponent\\s*\\(/.test(code) || /\\bregistry\\s*\\.\\s*register\\s*\\(\\s*\\{/.test(code)) {\n throw new Error(`${id}: raw capability registration bypasses the compiled exposure ceiling`);\n }\n if (\n !code.includes(\"defineAgentComponentContract\") &&\n !code.includes(\"defineAgentProcedureContract\") &&\n !code.includes(\"defineExternalAgentToolContract\")\n ) {\n return null;\n }\n const extracted = extractModule({ code, id, root, target, placeholder: manifestHashToken() });\n // A dependency that calls a contract macro in its own source contributes\n // capabilities with no sidecar and no file to digest. Attribute them to\n // the owning package now, so buildEnd can put them through the same\n // authorization as a sidecar instead of admitting them silently.\n const owner = isDependencyModule(id) ? nearestPackage(id) : undefined;\n if (owner) {\n const existing = sourceEntries.get(owner.name) ?? [];\n existing.push(...extracted.entries);\n sourceEntries.set(owner.name, existing);\n } else {\n entries.push(...extracted.entries);\n }\n return extracted.code === code ? null : { code: extracted.code, map: null };\n },\n buildEnd(error) {\n // Serve already has its manifest, compiled from the whole graph in\n // `buildStart`. Recomputing it here would derive it from whatever modules\n // the dev server happened to request, which is a subset — and a contract\n // narrower than the truth silently refuses real capabilities.\n if (error || serve) return;\n const contributions: ExternalContribution[] = [];\n const seenSidecars = new Set<string>();\n\n // Sidecars declared by packages reachable from the production graph.\n for (const id of this.getModuleIds()) {\n if (!isDependencyModule(id)) continue;\n const owner = nearestPackage(id);\n if (!owner?.sidecar || seenSidecars.has(owner.sidecar)) continue;\n seenSidecars.add(owner.sidecar);\n const { manifest: external, digest } = readSidecar(owner.sidecar);\n contributions.push({\n package: owner.name,\n source: relative(root, owner.sidecar).split(sep).join(\"/\"),\n route: \"sidecar\",\n contractDigest: digest,\n entries: external.capabilities,\n });\n }\n\n // Sidecars named explicitly, for contracts outside the module graph.\n for (const allowed of options.externalContracts?.allow ?? []) {\n if (!allowed.path) continue;\n const path = isAbsolute(allowed.path) ? allowed.path : resolve(root, allowed.path);\n if (seenSidecars.has(path)) continue;\n seenSidecars.add(path);\n // The package name comes from where the file lives, not from the entry\n // that approves it — otherwise a path-pinned contract would always\n // authorize itself under whatever name the consumer happened to write.\n const owner = nearestPackage(path);\n if (owner && owner.name !== allowed.package) {\n throw new Error(\n `external contract \"${allowed.path}\" belongs to \"${owner.name}\", not the approved \"${allowed.package}\"`,\n );\n }\n const { manifest: external, digest } = readSidecar(path);\n contributions.push({\n package: owner?.name ?? allowed.package,\n source: allowed.path,\n route: \"sidecar\",\n contractDigest: digest,\n entries: external.capabilities,\n });\n }\n\n // Contract macros in a dependency's own source: no file to digest, so the\n // digest covers the canonical set of entries it actually contributed.\n for (const [name, extracted] of [...sourceEntries].sort(([a], [b]) => a.localeCompare(b))) {\n if (extracted.length === 0) continue;\n const sorted = mergeEntries(extracted);\n contributions.push({\n package: name,\n source: sorted[0]?.origin ?? name,\n route: \"source\",\n contractDigest: sha256(canonicalJson(sorted)),\n entries: sorted,\n });\n }\n\n const externalContracts = authorizeContributions(contributions, options.externalContracts);\n const externalEntries = contributions.flatMap((contribution) => contribution.entries);\n const capabilities = mergeEntries([...entries, ...externalEntries]);\n validateEntries(capabilities);\n const targets = [...new Set(capabilities.flatMap((entry) => entry.targets))].sort();\n const payload = {\n formatVersion: 5 as const,\n compilerVersion: COMPILER_VERSION,\n targets,\n capabilities,\n externalContracts,\n completeness: { status: \"proven\" as const },\n };\n manifest = { ...payload, hash: computeManifestHash(payload) };\n options.onManifest?.(manifest);\n },\n renderChunk(code) {\n if (!manifest || (!code.includes(placeholder) && !code.includes(manifestPlaceholder))) return null;\n return {\n code: code\n .replaceAll(placeholder, manifest.hash)\n .replaceAll(manifestPlaceholder, JSON.stringify(manifest)),\n map: null,\n };\n },\n generateBundle() {\n if (!manifest || options.emit === false) return;\n this.emitFile({\n type: \"asset\",\n fileName: options.fileName ?? CONTRACT_FILE,\n source: canonicalManifestJson(manifest),\n });\n },\n async handleHotUpdate(ctx) {\n if (!serve) return;\n const code = await ctx.read();\n if (\n !code.includes(\"defineAgentComponentContract\") &&\n !code.includes(\"defineAgentProcedureContract\") &&\n !code.includes(\"defineExternalAgentToolContract\")\n ) {\n return;\n }\n // Editing a contract changes the manifest hash, which every already-loaded\n // proof is pinned to. Patching one module would leave the rest stale and\n // registering against a hash nothing else agrees with, so the whole page\n // goes back for a fresh authority.\n serveManifests.delete(`${root}\\0${target}`);\n manifest = await compileServeManifest({\n root,\n target,\n alias: serveAlias,\n configFile: serveConfigFile,\n ...(options.externalContracts ? { externalContracts: options.externalContracts } : {}),\n });\n const virtual = ctx.server.moduleGraph.getModuleById(RESOLVED_VIRTUAL_CONTRACT_ID);\n if (virtual) ctx.server.moduleGraph.invalidateModule(virtual);\n ctx.server.ws.send({ type: \"full-reload\" });\n return [];\n },\n };\n}\n","import { createHash } from \"node:crypto\";\nimport type { CapabilityContractManifest } from \"@agent-surface/core\";\n\nfunction normalize(value: unknown): unknown {\n if (Array.isArray(value)) return value.map(normalize);\n if (typeof value !== \"object\" || value === null) return value;\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .filter(([, entry]) => entry !== undefined)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([key, entry]) => [key, normalize(entry)]),\n );\n}\n\nexport function canonicalJson(value: unknown, pretty = false): string {\n return `${JSON.stringify(normalize(value), null, pretty ? 2 : undefined)}\\n`;\n}\n\nexport function sha256(value: string | Uint8Array): string {\n return createHash(\"sha256\").update(value).digest(\"hex\");\n}\n\nexport function manifestPayload(\n manifest: Omit<CapabilityContractManifest, \"hash\"> | CapabilityContractManifest,\n): Omit<CapabilityContractManifest, \"hash\"> {\n const { hash: _hash, ...payload } = manifest as CapabilityContractManifest;\n return payload;\n}\n\nexport function computeManifestHash(\n manifest: Omit<CapabilityContractManifest, \"hash\"> | CapabilityContractManifest,\n): string {\n return sha256(canonicalJson(manifestPayload(manifest)));\n}\n\nexport function canonicalManifestJson(manifest: CapabilityContractManifest): string {\n return canonicalJson(manifest, true);\n}\n\nexport function verifyManifest(manifest: CapabilityContractManifest): void {\n if (computeManifestHash(manifest) !== manifest.hash) {\n throw new Error(`capability contract hash mismatch: ${manifest.hash}`);\n }\n}\n","import { posix, relative, resolve } from \"node:path\";\nimport ts from \"typescript\";\nimport type {\n CapabilityContractEntry,\n CapabilityPolicyAttachment,\n JsonSchema,\n} from \"@agent-surface/core\";\nimport { canonicalJson, sha256 } from \"./canonical.js\";\n\nconst CORE = \"@agent-surface/core\";\nconst COMPONENT_MACRO = \"defineAgentComponentContract\";\nconst PROCEDURE_MACRO = \"defineAgentProcedureContract\";\nconst EXTERNAL_MACRO = \"defineExternalAgentToolContract\";\nconst WRAPPERS = new Set([\n \"observationContract\",\n \"actionContract\",\n \"fromJsonSchema\",\n \"defineAgentComponentContract\",\n \"defineAgentProcedureContract\",\n \"defineExternalAgentToolContract\",\n]);\n\ntype Json = null | boolean | number | string | Json[] | { [key: string]: Json };\n\ninterface CompiledCapabilityToken {\n manifestHash: string;\n declarationId: string;\n capabilityId: string;\n contractHash: string;\n}\n\ninterface CompiledComponentProvenance {\n manifestHash: string;\n declarationId: string;\n capabilities: Record<string, CompiledCapabilityToken>;\n}\n\nexport interface ExtractedModule {\n code: string;\n entries: CapabilityContractEntry[];\n}\n\nfunction sourceKind(id: string): ts.ScriptKind {\n if (/\\.tsx(?:\\?|$)/.test(id)) return ts.ScriptKind.TSX;\n if (/\\.jsx(?:\\?|$)/.test(id)) return ts.ScriptKind.JSX;\n if (/\\.js(?:\\?|$)/.test(id)) return ts.ScriptKind.JS;\n return ts.ScriptKind.TS;\n}\n\nfunction unwrap(node: ts.Expression): ts.Expression {\n while (\n ts.isParenthesizedExpression(node) ||\n ts.isAsExpression(node) ||\n ts.isTypeAssertionExpression(node) ||\n ts.isSatisfiesExpression(node) ||\n ts.isNonNullExpression(node)\n ) {\n node = node.expression;\n }\n return node;\n}\n\nfunction propertyName(node: ts.PropertyName): string | undefined {\n if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node)) {\n return node.text;\n }\n if (ts.isComputedPropertyName(node) && ts.isStringLiteral(unwrap(node.expression))) {\n return (unwrap(node.expression) as ts.StringLiteral).text;\n }\n return undefined;\n}\n\nfunction calleeName(node: ts.Expression): string | undefined {\n node = unwrap(node);\n if (ts.isIdentifier(node)) return node.text;\n if (ts.isPropertyAccessExpression(node)) return node.name.text;\n if (\n ts.isElementAccessExpression(node) &&\n node.argumentExpression &&\n ts.isStringLiteral(unwrap(node.argumentExpression))\n ) {\n return (unwrap(node.argumentExpression) as ts.StringLiteral).text;\n }\n return undefined;\n}\n\nfunction normalizedOrigin(root: string, id: string): string {\n const clean = id.replace(/^\\0/, \"virtual:\").split(\"?\")[0]!;\n if (clean.startsWith(\"virtual:\")) return clean;\n const path = clean.startsWith(\"/\\@fs/\") ? clean.slice(4) : clean;\n return posix.normalize(relative(root, resolve(path)).split(\"\\\\\").join(\"/\"));\n}\n\nclass StaticEvaluator {\n private readonly constants = new Map<string, ts.Expression>();\n private readonly active = new Set<string>();\n\n constructor(private readonly file: ts.SourceFile) {\n const visit = (node: ts.Node): void => {\n if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {\n this.constants.set(node.name.text, node.initializer);\n }\n ts.forEachChild(node, visit);\n };\n visit(file);\n }\n\n evaluate(input: ts.Expression, where: string): Json {\n const node = unwrap(input);\n if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) return node.text;\n if (ts.isNumericLiteral(node)) return Number(node.text);\n if (node.kind === ts.SyntaxKind.TrueKeyword) return true;\n if (node.kind === ts.SyntaxKind.FalseKeyword) return false;\n if (node.kind === ts.SyntaxKind.NullKeyword) return null;\n if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.MinusToken) {\n const value = this.evaluate(node.operand, where);\n if (typeof value === \"number\") return -value;\n }\n if (ts.isArrayLiteralExpression(node)) {\n return node.elements.map((entry, index) => {\n if (ts.isSpreadElement(entry)) {\n const spread = this.evaluate(entry.expression, `${where}[${index}]`);\n if (!Array.isArray(spread)) throw this.failure(entry, `${where}: array spread is not static`);\n return spread;\n }\n return this.evaluate(entry as ts.Expression, `${where}[${index}]`);\n }).flat() as Json[];\n }\n if (ts.isObjectLiteralExpression(node)) {\n const result: Record<string, Json> = {};\n for (const property of node.properties) {\n if (ts.isSpreadAssignment(property)) {\n const spread = this.evaluate(property.expression, `${where} spread`);\n if (typeof spread !== \"object\" || spread === null || Array.isArray(spread)) {\n throw this.failure(property, `${where}: object spread is not static`);\n }\n Object.assign(result, spread);\n continue;\n }\n if (ts.isShorthandPropertyAssignment(property)) {\n result[property.name.text] = this.evaluate(property.name, `${where}.${property.name.text}`);\n continue;\n }\n if (!ts.isPropertyAssignment(property)) {\n throw this.failure(property, `${where}: methods/accessors are runtime code`);\n }\n const name = propertyName(property.name);\n if (name === undefined) throw this.failure(property.name, `${where}: computed key is not static`);\n result[name] = this.evaluate(property.initializer, `${where}.${name}`);\n }\n return result;\n }\n if (ts.isIdentifier(node)) {\n if (node.text === \"undefined\") throw this.failure(node, `${where}: undefined is not serializable`);\n if (node.text === \"emptyObjectSchema\") {\n return { type: \"object\", properties: {}, additionalProperties: false };\n }\n const value = this.constants.get(node.text);\n if (!value) throw this.failure(node, `${where}: imported/dynamic value \"${node.text}\" is not static`);\n if (this.active.has(node.text)) throw this.failure(node, `${where}: cyclic static value \"${node.text}\"`);\n this.active.add(node.text);\n try {\n return this.evaluate(value, where);\n } finally {\n this.active.delete(node.text);\n }\n }\n if (ts.isCallExpression(node)) {\n const name = calleeName(node.expression);\n if (name && WRAPPERS.has(name) && node.arguments[0]) {\n return this.evaluate(node.arguments[0], where);\n }\n throw this.failure(node, `${where}: call \"${name ?? \"<computed>\"}\" is not a compiler macro`);\n }\n if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {\n const owner = this.evaluate(node.expression, where);\n const name = ts.isPropertyAccessExpression(node)\n ? node.name.text\n : node.argumentExpression && ts.isStringLiteral(unwrap(node.argumentExpression))\n ? (unwrap(node.argumentExpression) as ts.StringLiteral).text\n : undefined;\n if (name !== undefined && typeof owner === \"object\" && owner !== null && !Array.isArray(owner)) {\n const value = owner[name];\n if (value !== undefined) return value;\n }\n }\n throw this.failure(node, `${where}: expression is dynamic or non-serializable`);\n }\n\n private failure(node: ts.Node, message: string): Error {\n const position = this.file.getLineAndCharacterOfPosition(node.getStart(this.file));\n return new Error(`${this.file.fileName}:${position.line + 1}:${position.character + 1}: ${message}`);\n }\n}\n\nfunction record(value: Json, where: string): Record<string, Json> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n throw new Error(`${where} must be a static object`);\n }\n return value;\n}\n\nfunction string(value: Json | undefined, where: string): string {\n if (typeof value !== \"string\" || value.length === 0) throw new Error(`${where} must be a string`);\n return value;\n}\n\nfunction policies(value: Json | undefined): CapabilityPolicyAttachment[] | undefined {\n if (value === undefined) return undefined;\n if (!Array.isArray(value)) throw new Error(\"policies must be a static array\");\n return value.map((entry) => record(entry, \"policy\")) as unknown as CapabilityPolicyAttachment[];\n}\n\nfunction combine<T>(inherited: readonly T[] | undefined, local: readonly T[] | undefined): T[] | undefined {\n const values = [...(inherited ?? []), ...(local ?? [])];\n if (values.length === 0) return undefined;\n const unique = new Map(values.map((value) => [canonicalJson(value), value]));\n return [...unique.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([, value]) => value);\n}\n\nfunction entryHash(entry: Omit<CapabilityContractEntry, \"contractHash\" | \"targets\">): string {\n return sha256(canonicalJson(entry));\n}\n\nfunction declarationVariable(call: ts.CallExpression): string | undefined {\n let node: ts.Node = call;\n while (\n node.parent &&\n (ts.isParenthesizedExpression(node.parent) ||\n ts.isAsExpression(node.parent) ||\n ts.isSatisfiesExpression(node.parent))\n ) {\n node = node.parent;\n }\n return node.parent && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)\n ? node.parent.name.text\n : undefined;\n}\n\nfunction isMacroCall(\n call: ts.CallExpression,\n names: ReadonlySet<string>,\n namespaces: ReadonlySet<string>,\n aliases: ReadonlyMap<string, string>,\n): \"component\" | \"procedure\" | \"external\" | undefined {\n const expression = unwrap(call.expression);\n let imported: string | undefined;\n if (ts.isIdentifier(expression)) imported = aliases.get(expression.text);\n else if (ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression)) {\n if (namespaces.has(expression.expression.text)) imported = expression.name.text;\n } else if (\n ts.isElementAccessExpression(expression) &&\n ts.isIdentifier(expression.expression) &&\n namespaces.has(expression.expression.text) &&\n expression.argumentExpression &&\n ts.isStringLiteral(unwrap(expression.argumentExpression))\n ) {\n imported = (unwrap(expression.argumentExpression) as ts.StringLiteral).text;\n }\n if (imported === COMPONENT_MACRO) return \"component\";\n if (imported === PROCEDURE_MACRO) return \"procedure\";\n if (imported === EXTERNAL_MACRO) return \"external\";\n return undefined;\n}\n\nexport function extractModule(options: {\n code: string;\n id: string;\n root: string;\n target: string;\n placeholder: string;\n}): ExtractedModule {\n const file = ts.createSourceFile(options.id, options.code, ts.ScriptTarget.Latest, true, sourceKind(options.id));\n const namespaces = new Set<string>();\n const aliases = new Map<string, string>();\n for (const statement of file.statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;\n if (statement.moduleSpecifier.text !== CORE || !statement.importClause) continue;\n const bindings = statement.importClause.namedBindings;\n if (bindings && ts.isNamespaceImport(bindings)) namespaces.add(bindings.name.text);\n if (bindings && ts.isNamedImports(bindings)) {\n for (const binding of bindings.elements) {\n aliases.set(binding.name.text, binding.propertyName?.text ?? binding.name.text);\n }\n }\n }\n // Assigned aliases are resolved transitively within the module.\n let changed = true;\n while (changed) {\n changed = false;\n const visitAlias = (node: ts.Node): void => {\n if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {\n const init = unwrap(node.initializer);\n let source: string | undefined;\n if (ts.isIdentifier(init)) source = aliases.get(init.text);\n else if (ts.isPropertyAccessExpression(init) && ts.isIdentifier(init.expression) && namespaces.has(init.expression.text)) {\n source = init.name.text;\n }\n if (source && !aliases.has(node.name.text)) {\n aliases.set(node.name.text, source);\n changed = true;\n }\n }\n ts.forEachChild(node, visitAlias);\n };\n visitAlias(file);\n }\n\n const macroNames = new Set([COMPONENT_MACRO, PROCEDURE_MACRO, EXTERNAL_MACRO]);\n if (![...aliases.values()].some((name) => macroNames.has(name)) && namespaces.size === 0) {\n return { code: options.code, entries: [] };\n }\n\n const evaluator = new StaticEvaluator(file);\n const entries: CapabilityContractEntry[] = [];\n const injections: Array<{ position: number; text: string }> = [];\n const origin = normalizedOrigin(options.root, options.id);\n\n const visit = (node: ts.Node): void => {\n if (ts.isCallExpression(node)) {\n const macro = isMacroCall(node, macroNames, namespaces, aliases);\n if (macro) {\n if (!node.arguments[0]) throw new Error(`${origin}: contract declaration needs an argument`);\n const variable = declarationVariable(node);\n if (!variable) throw new Error(`${origin}: contract declaration must initialize a named module constant`);\n const declarationId = `${origin}#${variable}`;\n const definition = record(evaluator.evaluate(node.arguments[0], declarationId), declarationId);\n const emitted: CapabilityContractEntry[] = [];\n if (macro === \"component\") {\n const type = string(definition.type, `${declarationId}.type`);\n const inheritedPolicies = policies(definition.policies);\n const inheritedTags = definition.tags as string[] | undefined;\n const groups = [\n [\"observations\", \"observation\", \"read\"],\n [\"actions\", \"action\", undefined],\n ] as const;\n for (const [groupName, kind, defaultEffect] of groups) {\n const groupValue = definition[groupName];\n if (groupValue === undefined) continue;\n const group = record(groupValue, `${declarationId}.${groupName}`);\n for (const [name, rawMember] of Object.entries(group)) {\n const member = record(rawMember, `${declarationId}.${groupName}.${name}`);\n const capabilityPolicies = combine(inheritedPolicies, policies(member.policies));\n const capabilityTags = combine(inheritedTags, member.tags as string[] | undefined);\n const base = {\n declarationId,\n capabilityId: `view:${type}.${name}`,\n kind,\n description: string(member.description, `${declarationId}.${name}.description`),\n effect: string(member.effect ?? defaultEffect, `${declarationId}.${name}.effect`) as CapabilityContractEntry[\"effect\"],\n ...(member.input ? { inputSchema: member.input as JsonSchema } : {}),\n ...(member.output ? { outputSchema: member.output as JsonSchema } : {}),\n ...(member.confirmation ? { confirmation: member.confirmation as \"never\" | \"optional\" | \"required\" } : {}),\n ...(capabilityPolicies ? { policies: capabilityPolicies } : {}),\n ...(capabilityTags ? { tags: capabilityTags } : {}),\n origin,\n } satisfies Omit<CapabilityContractEntry, \"contractHash\" | \"targets\">;\n emitted.push({ ...base, contractHash: entryHash(base), targets: [options.target] });\n }\n }\n } else {\n const id = string(definition.id, `${declarationId}.id`);\n const base = {\n declarationId,\n capabilityId: id,\n kind: macro === \"procedure\" ? \"procedure\" as const : \"external\" as const,\n description: string(definition.description, `${declarationId}.description`),\n effect: string(definition.effect, `${declarationId}.effect`) as CapabilityContractEntry[\"effect\"],\n ...(definition.input ? { inputSchema: definition.input as JsonSchema } : {}),\n ...(definition.output ? { outputSchema: definition.output as JsonSchema } : {}),\n ...(definition.confirmation ? { confirmation: definition.confirmation as \"never\" | \"optional\" | \"required\" } : {}),\n ...(policies(definition.policies) ? { policies: policies(definition.policies) } : {}),\n ...(definition.tags ? { tags: definition.tags as string[] } : {}),\n origin,\n } satisfies Omit<CapabilityContractEntry, \"contractHash\" | \"targets\">;\n emitted.push({ ...base, contractHash: entryHash(base), targets: [options.target] });\n }\n entries.push(...emitted);\n if (node.arguments.length < 2) {\n if (macro === \"component\") {\n const capabilities: Record<string, CompiledCapabilityToken> = {};\n for (const entry of emitted) {\n capabilities[entry.capabilityId] = {\n manifestHash: options.placeholder,\n declarationId: entry.declarationId,\n capabilityId: entry.capabilityId,\n contractHash: entry.contractHash,\n };\n }\n const provenance: CompiledComponentProvenance = {\n manifestHash: options.placeholder,\n declarationId,\n capabilities,\n };\n injections.push({ position: node.arguments.end, text: `, ${JSON.stringify(provenance)}` });\n } else {\n const entry = emitted[0]!;\n const token: CompiledCapabilityToken = {\n manifestHash: options.placeholder,\n declarationId,\n capabilityId: entry.capabilityId,\n contractHash: entry.contractHash,\n };\n injections.push({ position: node.arguments.end, text: `, ${JSON.stringify(token)}` });\n }\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(file);\n\n let code = options.code;\n for (const injection of injections.sort((a, b) => b.position - a.position)) {\n code = `${code.slice(0, injection.position)}${injection.text}${code.slice(injection.position)}`;\n }\n return { code, entries };\n}\n"],"mappings":";AAAA,SAAS,WAAAA,gBAAe;AAExB,SAAS,aAAgC;;;ACFzC,SAAS,YAAY,oBAAoB;AACzC,SAAS,SAAS,YAAY,MAAM,YAAAC,WAAU,WAAAC,UAAS,WAAW;AAClE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACNP,SAAS,kBAAkB;AAG3B,SAAS,UAAU,OAAyB;AAC1C,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,SAAS;AACpD,MAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO;AACxD,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,KAAgC,EAC5C,OAAO,CAAC,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS,EACzC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAO,IAAI,IAAI,KAAK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AAA,IACA,GAAI,QAAQ,aAAa,EAAE,YAAYA,SAAQ,MAAM,QAAQ,UAAU,EAAE,IAAI,CAAC;AAAA,IAC9E,UAAU,QAAQ,MAAM,YAAY;AAAA,IACpC,OAAO;AAAA,MACL,GAAI,QAAQ,MAAM,SAAS,CAAC;AAAA,MAC5B,OAAO;AAAA,IACT;AAAA,IACA,SAAS;AAAA,MACP,GAAI,QAAQ,MAAM,WAAW,CAAC;AAAA,MAC9B,aAAa;AAAA,QACX,QAAQ,QAAQ;AAAA,QAChB,MAAM;AAAA,QACN,GAAI,QAAQ,oBAAoB,EAAE,mBAAmB,QAAQ,kBAAkB,IAAI,CAAC;AAAA,QACpF,YAAY,CAAC,UAAU;AACrB,qBAAW;AAAA,QACb;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACD,QAAM,UAAU,MAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,MAAM;AACxD,aAAW,UAAU,SAAS;AAC5B,QAAI,EAAE,YAAY,QAAS;AAC3B,UAAM,QAAQ,OAAO,OAAO;AAAA,MAC1B,CAAC,UAAU,MAAM,SAAS,WAAW,MAAM,aAAa;AAAA,IAC1D;AACA,QAAI,OAAO,SAAS,SAAS;AAC3B,YAAM,SAAS,OAAO,MAAM,WAAW,WACnC,MAAM,SACN,IAAI,YAAY,EAAE,OAAO,MAAM,MAAM;AACzC,iBAAW,KAAK,MAAM,MAAM;AAC5B;AAAA,IACF;AAAA,EACF;AACA,MAAI,CAAC,SAAU,OAAM,IAAI,MAAM,gDAAgD;AAC/E,SAAO;AACT;","names":["resolve","relative","resolve","resolve","compileCapabilityContract","relative","resolve"]}
@@ -0,0 +1,7 @@
1
+ import {
2
+ compileCapabilityContract
3
+ } from "./chunk-BNIUE5RA.js";
4
+ export {
5
+ compileCapabilityContract
6
+ };
7
+ //# sourceMappingURL=compile-RPDITMVH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}