@agent-surface/compiler 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +31 -4
- package/dist/index.js +118 -36
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -11,15 +11,36 @@ declare function verifyManifest(manifest: CapabilityContractManifest): void;
|
|
|
11
11
|
declare const COMPILER_VERSION = "0.17.0";
|
|
12
12
|
declare const CONTRACT_FILE = "agent-surface.contract.json";
|
|
13
13
|
declare const VIRTUAL_CONTRACT_ID = "virtual:agent-surface-contract";
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* One dependency the consumer has approved as a capability contributor.
|
|
16
|
+
*
|
|
17
|
+
* Keyed by package name rather than path: a path is a property of the installer
|
|
18
|
+
* (pnpm store layout, hoisting, workspace links), while the name is what a
|
|
19
|
+
* reviewer actually approves.
|
|
20
|
+
*/
|
|
21
|
+
interface ExternalContractAllowEntry {
|
|
22
|
+
/** npm package name, exactly as in its package.json. */
|
|
23
|
+
package: string;
|
|
24
|
+
/** sha256 of that package's contribution, as reported by a failing build. */
|
|
16
25
|
digest: string;
|
|
26
|
+
/**
|
|
27
|
+
* Explicit sidecar path, for a contract that is not reachable from the
|
|
28
|
+
* production module graph. Auto-discovered sidecars need no path.
|
|
29
|
+
*/
|
|
30
|
+
path?: string;
|
|
31
|
+
}
|
|
32
|
+
interface ExternalContractPolicy {
|
|
33
|
+
/**
|
|
34
|
+
* Dependencies allowed to contribute capabilities. A contribution from a
|
|
35
|
+
* package absent here fails the build: discovery is not authorization.
|
|
36
|
+
*/
|
|
37
|
+
allow?: ExternalContractAllowEntry[];
|
|
17
38
|
}
|
|
18
39
|
interface AgentSurfaceCompilerOptions {
|
|
19
40
|
target?: string;
|
|
20
41
|
emit?: boolean;
|
|
21
42
|
fileName?: string;
|
|
22
|
-
externalContracts?:
|
|
43
|
+
externalContracts?: ExternalContractPolicy;
|
|
23
44
|
onManifest?: (manifest: CapabilityContractManifest) => void;
|
|
24
45
|
}
|
|
25
46
|
declare function agentSurface(options?: AgentSurfaceCompilerOptions): Plugin;
|
|
@@ -28,8 +49,14 @@ interface CompileCapabilityContractOptions {
|
|
|
28
49
|
root?: string;
|
|
29
50
|
configFile?: string;
|
|
30
51
|
target?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Which dependencies may contribute capabilities. Forwarded to the compiler
|
|
54
|
+
* plugin: without it, every discovered external contract is unauthorized and
|
|
55
|
+
* the build fails.
|
|
56
|
+
*/
|
|
57
|
+
externalContracts?: ExternalContractPolicy;
|
|
31
58
|
vite?: InlineConfig;
|
|
32
59
|
}
|
|
33
60
|
declare function compileCapabilityContract(options?: CompileCapabilityContractOptions): Promise<CapabilityContractManifest>;
|
|
34
61
|
|
|
35
|
-
export { type AgentSurfaceCompilerOptions, COMPILER_VERSION, CONTRACT_FILE, type CompileCapabilityContractOptions, type
|
|
62
|
+
export { type AgentSurfaceCompilerOptions, COMPILER_VERSION, CONTRACT_FILE, type CompileCapabilityContractOptions, type ExternalContractAllowEntry, type ExternalContractPolicy, VIRTUAL_CONTRACT_ID, agentSurface, canonicalJson, canonicalManifestJson, compileCapabilityContract, computeManifestHash, manifestPayload, sha256, verifyManifest };
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ function verifyManifest(manifest) {
|
|
|
32
32
|
|
|
33
33
|
// src/plugin.ts
|
|
34
34
|
import { existsSync, readFileSync } from "fs";
|
|
35
|
-
import { dirname, isAbsolute, join, resolve as resolve2 } from "path";
|
|
35
|
+
import { dirname, isAbsolute, join, relative as relative2, resolve as resolve2, sep } from "path";
|
|
36
36
|
import {
|
|
37
37
|
DEFAULT_LIMITS,
|
|
38
38
|
parseCapabilityId,
|
|
@@ -411,39 +411,83 @@ function validateEntries(entries) {
|
|
|
411
411
|
}
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
-
function
|
|
415
|
-
if (!input.digest) throw new Error(`external contract "${input.path}" is not content-addressed`);
|
|
416
|
-
const path = isAbsolute(input.path) ? input.path : resolve2(root, input.path);
|
|
417
|
-
const bytes = readFileSync(path);
|
|
418
|
-
const actual = sha256(bytes);
|
|
419
|
-
if (actual !== input.digest) {
|
|
420
|
-
throw new Error(`external contract "${input.path}" digest mismatch: expected ${input.digest}, got ${actual}`);
|
|
421
|
-
}
|
|
422
|
-
const manifest = JSON.parse(bytes.toString("utf8"));
|
|
423
|
-
verifyManifest(manifest);
|
|
424
|
-
return manifest;
|
|
425
|
-
}
|
|
426
|
-
function nearestPackageSidecar(id, seen) {
|
|
414
|
+
function nearestPackage(id) {
|
|
427
415
|
if (id.startsWith("\0") || !isAbsolute(id)) return void 0;
|
|
428
416
|
let dir = dirname(id.split("?")[0]);
|
|
429
417
|
while (dir !== dirname(dir)) {
|
|
430
418
|
const packagePath = join(dir, "package.json");
|
|
431
419
|
if (existsSync(packagePath)) {
|
|
432
|
-
if (seen.has(packagePath)) return void 0;
|
|
433
|
-
seen.add(packagePath);
|
|
434
420
|
const pkg = JSON.parse(readFileSync(packagePath, "utf8"));
|
|
435
|
-
|
|
421
|
+
if (!pkg.name) return void 0;
|
|
422
|
+
return {
|
|
423
|
+
name: pkg.name,
|
|
424
|
+
dir,
|
|
425
|
+
packagePath,
|
|
426
|
+
...pkg.agentSurface?.contract ? { sidecar: resolve2(dir, pkg.agentSurface.contract) } : {}
|
|
427
|
+
};
|
|
436
428
|
}
|
|
437
429
|
dir = dirname(dir);
|
|
438
430
|
}
|
|
439
431
|
return void 0;
|
|
440
432
|
}
|
|
433
|
+
function isDependencyModule(id) {
|
|
434
|
+
return id.split("?")[0].includes(`${sep}node_modules${sep}`);
|
|
435
|
+
}
|
|
436
|
+
function readSidecar(path) {
|
|
437
|
+
const bytes = readFileSync(path);
|
|
438
|
+
const manifest = JSON.parse(bytes.toString("utf8"));
|
|
439
|
+
verifyManifest(manifest);
|
|
440
|
+
return { manifest, digest: sha256(bytes) };
|
|
441
|
+
}
|
|
442
|
+
function authorizeContributions(contributions, policy) {
|
|
443
|
+
const allow = new Map((policy?.allow ?? []).map((entry) => [entry.package, entry]));
|
|
444
|
+
const unauthorized = [];
|
|
445
|
+
const mismatched = [];
|
|
446
|
+
const attributions = [];
|
|
447
|
+
for (const contribution of contributions) {
|
|
448
|
+
const approved = allow.get(contribution.package);
|
|
449
|
+
if (!approved) {
|
|
450
|
+
unauthorized.push(
|
|
451
|
+
` ${contribution.package} (${contribution.route}: ${contribution.source})
|
|
452
|
+
{ "package": "${contribution.package}", "digest": "${contribution.contractDigest}" }`
|
|
453
|
+
);
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
if (approved.digest !== contribution.contractDigest) {
|
|
457
|
+
mismatched.push(
|
|
458
|
+
` ${contribution.package}: approved ${approved.digest}, this build computed ${contribution.contractDigest}`
|
|
459
|
+
);
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
attributions.push({
|
|
463
|
+
package: contribution.package,
|
|
464
|
+
source: contribution.source,
|
|
465
|
+
route: contribution.route,
|
|
466
|
+
contractDigest: contribution.contractDigest,
|
|
467
|
+
authorization: { mode: "pinned", expectedDigest: approved.digest }
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
if (unauthorized.length > 0) {
|
|
471
|
+
throw new Error(
|
|
472
|
+
`unauthorized external capability contract(s). A dependency cannot contribute capabilities until the consumer approves it. Add to externalContracts.allow:
|
|
473
|
+
${unauthorized.join("\n")}`
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
if (mismatched.length > 0) {
|
|
477
|
+
throw new Error(
|
|
478
|
+
`external capability contract digest mismatch. The dependency changed what it contributes; review the change before updating the approved digest:
|
|
479
|
+
${mismatched.join("\n")}`
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
return attributions.sort((a, b) => a.package.localeCompare(b.package));
|
|
483
|
+
}
|
|
441
484
|
function agentSurface(options = {}) {
|
|
442
485
|
const target = options.target ?? "web-production";
|
|
443
486
|
const placeholder = `__AGENT_SURFACE_MANIFEST_HASH_${Math.random().toString(36).slice(2)}__`;
|
|
444
487
|
const manifestPlaceholder = `__AGENT_SURFACE_MANIFEST_${Math.random().toString(36).slice(2)}__`;
|
|
445
488
|
let root = process.cwd();
|
|
446
489
|
let entries = [];
|
|
490
|
+
let sourceEntries = /* @__PURE__ */ new Map();
|
|
447
491
|
let manifest;
|
|
448
492
|
return {
|
|
449
493
|
name: "agent-surface:compiler",
|
|
@@ -464,6 +508,7 @@ export default createCapabilityAuthority(manifest);`;
|
|
|
464
508
|
},
|
|
465
509
|
buildStart() {
|
|
466
510
|
entries = [];
|
|
511
|
+
sourceEntries = /* @__PURE__ */ new Map();
|
|
467
512
|
manifest = void 0;
|
|
468
513
|
},
|
|
469
514
|
transform(code, id) {
|
|
@@ -483,40 +528,76 @@ export default createCapabilityAuthority(manifest);`;
|
|
|
483
528
|
return null;
|
|
484
529
|
}
|
|
485
530
|
const extracted = extractModule({ code, id, root, target, placeholder });
|
|
486
|
-
|
|
531
|
+
const owner = isDependencyModule(id) ? nearestPackage(id) : void 0;
|
|
532
|
+
if (owner) {
|
|
533
|
+
const existing = sourceEntries.get(owner.name) ?? [];
|
|
534
|
+
existing.push(...extracted.entries);
|
|
535
|
+
sourceEntries.set(owner.name, existing);
|
|
536
|
+
} else {
|
|
537
|
+
entries.push(...extracted.entries);
|
|
538
|
+
}
|
|
487
539
|
return extracted.code === code ? null : { code: extracted.code, map: null };
|
|
488
540
|
},
|
|
489
541
|
buildEnd(error) {
|
|
490
542
|
if (error) return;
|
|
491
|
-
const
|
|
492
|
-
const
|
|
493
|
-
const seenPackages = /* @__PURE__ */ new Set();
|
|
494
|
-
const sidecars = /* @__PURE__ */ new Set();
|
|
543
|
+
const contributions = [];
|
|
544
|
+
const seenSidecars = /* @__PURE__ */ new Set();
|
|
495
545
|
for (const id of this.getModuleIds()) {
|
|
496
|
-
|
|
497
|
-
|
|
546
|
+
if (!isDependencyModule(id)) continue;
|
|
547
|
+
const owner = nearestPackage(id);
|
|
548
|
+
if (!owner?.sidecar || seenSidecars.has(owner.sidecar)) continue;
|
|
549
|
+
seenSidecars.add(owner.sidecar);
|
|
550
|
+
const { manifest: external, digest } = readSidecar(owner.sidecar);
|
|
551
|
+
contributions.push({
|
|
552
|
+
package: owner.name,
|
|
553
|
+
source: relative2(root, owner.sidecar).split(sep).join("/"),
|
|
554
|
+
route: "sidecar",
|
|
555
|
+
contractDigest: digest,
|
|
556
|
+
entries: external.capabilities
|
|
557
|
+
});
|
|
498
558
|
}
|
|
499
|
-
for (const
|
|
500
|
-
|
|
501
|
-
const
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
559
|
+
for (const allowed of options.externalContracts?.allow ?? []) {
|
|
560
|
+
if (!allowed.path) continue;
|
|
561
|
+
const path = isAbsolute(allowed.path) ? allowed.path : resolve2(root, allowed.path);
|
|
562
|
+
if (seenSidecars.has(path)) continue;
|
|
563
|
+
seenSidecars.add(path);
|
|
564
|
+
const owner = nearestPackage(path);
|
|
565
|
+
if (owner && owner.name !== allowed.package) {
|
|
566
|
+
throw new Error(
|
|
567
|
+
`external contract "${allowed.path}" belongs to "${owner.name}", not the approved "${allowed.package}"`
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
const { manifest: external, digest } = readSidecar(path);
|
|
571
|
+
contributions.push({
|
|
572
|
+
package: owner?.name ?? allowed.package,
|
|
573
|
+
source: allowed.path,
|
|
574
|
+
route: "sidecar",
|
|
575
|
+
contractDigest: digest,
|
|
576
|
+
entries: external.capabilities
|
|
577
|
+
});
|
|
505
578
|
}
|
|
506
|
-
for (const
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
579
|
+
for (const [name, extracted] of [...sourceEntries].sort(([a], [b]) => a.localeCompare(b))) {
|
|
580
|
+
if (extracted.length === 0) continue;
|
|
581
|
+
const sorted = mergeEntries(extracted);
|
|
582
|
+
contributions.push({
|
|
583
|
+
package: name,
|
|
584
|
+
source: sorted[0]?.origin ?? name,
|
|
585
|
+
route: "source",
|
|
586
|
+
contractDigest: sha256(canonicalJson(sorted)),
|
|
587
|
+
entries: sorted
|
|
588
|
+
});
|
|
510
589
|
}
|
|
590
|
+
const externalContracts = authorizeContributions(contributions, options.externalContracts);
|
|
591
|
+
const externalEntries = contributions.flatMap((contribution) => contribution.entries);
|
|
511
592
|
const capabilities = mergeEntries([...entries, ...externalEntries]);
|
|
512
593
|
validateEntries(capabilities);
|
|
513
594
|
const targets = [...new Set(capabilities.flatMap((entry) => entry.targets))].sort();
|
|
514
595
|
const payload = {
|
|
515
|
-
formatVersion:
|
|
596
|
+
formatVersion: 5,
|
|
516
597
|
compilerVersion: COMPILER_VERSION,
|
|
517
598
|
targets,
|
|
518
599
|
capabilities,
|
|
519
|
-
externalContracts
|
|
600
|
+
externalContracts,
|
|
520
601
|
completeness: { status: "proven" }
|
|
521
602
|
};
|
|
522
603
|
manifest = { ...payload, hash: computeManifestHash(payload) };
|
|
@@ -560,6 +641,7 @@ async function compileCapabilityContract(options = {}) {
|
|
|
560
641
|
agentSurface({
|
|
561
642
|
target: options.target,
|
|
562
643
|
emit: false,
|
|
644
|
+
...options.externalContracts ? { externalContracts: options.externalContracts } : {},
|
|
563
645
|
onManifest: (value) => {
|
|
564
646
|
manifest = value;
|
|
565
647
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/canonical.ts","../src/plugin.ts","../src/extract.ts","../src/compile.ts"],"sourcesContent":["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 { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, resolve } 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 } from \"vite\";\nimport { 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\nexport interface PinnedContractInput {\n path: string;\n digest: string;\n}\n\nexport interface AgentSurfaceCompilerOptions {\n target?: string;\n emit?: boolean;\n fileName?: string;\n externalContracts?: PinnedContractInput[];\n onManifest?: (manifest: CapabilityContractManifest) => void;\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\nfunction readPinnedContract(input: PinnedContractInput, root: string): CapabilityContractManifest {\n if (!input.digest) throw new Error(`external contract \"${input.path}\" is not content-addressed`);\n const path = isAbsolute(input.path) ? input.path : resolve(root, input.path);\n const bytes = readFileSync(path);\n const actual = sha256(bytes);\n if (actual !== input.digest) {\n throw new Error(`external contract \"${input.path}\" digest mismatch: expected ${input.digest}, got ${actual}`);\n }\n const manifest = JSON.parse(bytes.toString(\"utf8\")) as CapabilityContractManifest;\n verifyManifest(manifest);\n return manifest;\n}\n\nfunction nearestPackageSidecar(id: string, seen: Set<string>): string | 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 if (seen.has(packagePath)) return undefined;\n seen.add(packagePath);\n const pkg = JSON.parse(readFileSync(packagePath, \"utf8\")) as {\n agentSurface?: { contract?: string };\n };\n return pkg.agentSurface?.contract ? resolve(dir, pkg.agentSurface.contract) : undefined;\n }\n dir = dirname(dir);\n }\n return undefined;\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 let manifest: CapabilityContractManifest | undefined;\n\n return {\n name: \"agent-surface:compiler\",\n apply: \"build\",\n enforce: \"pre\",\n configResolved(config) {\n root = config.root;\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 return `import { createCapabilityAuthority } from \"@agent-surface/core\";\nconst manifest = ${manifestPlaceholder};\nexport { manifest };\nexport default createCapabilityAuthority(manifest);`;\n },\n buildStart() {\n entries = [];\n manifest = undefined;\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 ) {\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 });\n entries.push(...extracted.entries);\n return extracted.code === code ? null : { code: extracted.code, map: null };\n },\n buildEnd(error) {\n if (error) return;\n const externalContracts: CapabilityContractManifest[\"externalContracts\"] = [];\n const externalEntries: CapabilityContractEntry[] = [];\n const seenPackages = new Set<string>();\n const sidecars = new Set<string>();\n for (const id of this.getModuleIds()) {\n const sidecar = nearestPackageSidecar(id, seenPackages);\n if (sidecar) sidecars.add(sidecar);\n }\n for (const sidecar of sidecars) {\n const bytes = readFileSync(sidecar);\n const external = JSON.parse(bytes.toString(\"utf8\")) as CapabilityContractManifest;\n verifyManifest(external);\n externalEntries.push(...external.capabilities);\n externalContracts.push({ source: sidecar.split(\"/\").slice(-3).join(\"/\"), digest: sha256(bytes) });\n }\n for (const pinned of options.externalContracts ?? []) {\n const external = readPinnedContract(pinned, root);\n externalEntries.push(...external.capabilities);\n externalContracts.push({ source: pinned.path, digest: pinned.digest });\n }\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: 4 as const,\n compilerVersion: COMPILER_VERSION,\n targets,\n capabilities,\n externalContracts: externalContracts.sort((a, b) => a.source.localeCompare(b.source)),\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 };\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","import { resolve } from \"node:path\";\nimport type { CapabilityContractManifest } from \"@agent-surface/core\";\nimport { build, type InlineConfig } from \"vite\";\nimport { agentSurface } from \"./plugin.js\";\n\nexport interface CompileCapabilityContractOptions {\n root?: string;\n configFile?: string;\n target?: string;\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 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"],"mappings":";AAAA,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,MA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T;AAAA,IACA,SAAS;AAAA,MACP,GAAI,QAAQ,MAAM,WAAW,CAAC;AAAA,MAC9B,aAAa;AAAA,QACX,QAAQ,QAAQ;AAAA,QAChB,MAAM;AAAA,QACN,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","resolve","resolve","resolve"]}
|
|
1
|
+
{"version":3,"sources":["../src/canonical.ts","../src/plugin.ts","../src/extract.ts","../src/compile.ts"],"sourcesContent":["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 { 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 } 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\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\n return {\n name: \"agent-surface:compiler\",\n apply: \"build\",\n enforce: \"pre\",\n configResolved(config) {\n root = config.root;\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 return `import { createCapabilityAuthority } from \"@agent-surface/core\";\nconst manifest = ${manifestPlaceholder};\nexport { manifest };\nexport default createCapabilityAuthority(manifest);`;\n },\n buildStart() {\n entries = [];\n sourceEntries = new Map();\n manifest = undefined;\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 ) {\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 });\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 if (error) 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 };\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","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"],"mappings":";AAAA,SAAS,kBAAkB;AAG3B,SAAS,UAAU,OAAyB;AAC1C,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,IAAI,SAAS;AACpD,MAAI,OAAO,UAAU,YAAY,UAAU,K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AAmB,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":["relative","resolve","resolve","relative","resolve","resolve"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-surface/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Vite compiler for deterministic agent capability contracts",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"typescript": "^5.9.2",
|
|
22
22
|
"vite": "^7.1.3",
|
|
23
|
-
"@agent-surface/core": "^0.
|
|
23
|
+
"@agent-surface/core": "^0.19.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/node": "^20.19.0"
|