@agent-surface/compiler 0.16.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Wiseair S.r.l.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # `@agent-surface/compiler`
2
+
3
+ Vite/Rollup compiler for canonical agent capability contracts.
4
+
5
+ ```ts
6
+ import { agentSurface } from "@agent-surface/compiler";
7
+
8
+ export default defineConfig({ plugins: [agentSurface()] });
9
+ ```
10
+
11
+ It traverses the actual production graph, including static/lazy chunks and virtual modules; composes pinned sidecars; emits `agent-surface.contract.json`; injects runtime provenance; and provides `virtual:agent-surface-contract`.
@@ -0,0 +1,35 @@
1
+ import { CapabilityContractManifest } from '@agent-surface/core';
2
+ import { Plugin, InlineConfig } from 'vite';
3
+
4
+ declare function canonicalJson(value: unknown, pretty?: boolean): string;
5
+ declare function sha256(value: string | Uint8Array): string;
6
+ declare function manifestPayload(manifest: Omit<CapabilityContractManifest, "hash"> | CapabilityContractManifest): Omit<CapabilityContractManifest, "hash">;
7
+ declare function computeManifestHash(manifest: Omit<CapabilityContractManifest, "hash"> | CapabilityContractManifest): string;
8
+ declare function canonicalManifestJson(manifest: CapabilityContractManifest): string;
9
+ declare function verifyManifest(manifest: CapabilityContractManifest): void;
10
+
11
+ declare const COMPILER_VERSION = "0.16.0";
12
+ declare const CONTRACT_FILE = "agent-surface.contract.json";
13
+ declare const VIRTUAL_CONTRACT_ID = "virtual:agent-surface-contract";
14
+ interface PinnedContractInput {
15
+ path: string;
16
+ digest: string;
17
+ }
18
+ interface AgentSurfaceCompilerOptions {
19
+ target?: string;
20
+ emit?: boolean;
21
+ fileName?: string;
22
+ externalContracts?: PinnedContractInput[];
23
+ onManifest?: (manifest: CapabilityContractManifest) => void;
24
+ }
25
+ declare function agentSurface(options?: AgentSurfaceCompilerOptions): Plugin;
26
+
27
+ interface CompileCapabilityContractOptions {
28
+ root?: string;
29
+ configFile?: string;
30
+ target?: string;
31
+ vite?: InlineConfig;
32
+ }
33
+ declare function compileCapabilityContract(options?: CompileCapabilityContractOptions): Promise<CapabilityContractManifest>;
34
+
35
+ export { type AgentSurfaceCompilerOptions, COMPILER_VERSION, CONTRACT_FILE, type CompileCapabilityContractOptions, type PinnedContractInput, VIRTUAL_CONTRACT_ID, agentSurface, canonicalJson, canonicalManifestJson, compileCapabilityContract, computeManifestHash, manifestPayload, sha256, verifyManifest };
package/dist/index.js ADDED
@@ -0,0 +1,594 @@
1
+ // src/canonical.ts
2
+ import { createHash } from "crypto";
3
+ function normalize(value) {
4
+ if (Array.isArray(value)) return value.map(normalize);
5
+ if (typeof value !== "object" || value === null) return value;
6
+ return Object.fromEntries(
7
+ Object.entries(value).filter(([, entry]) => entry !== void 0).sort(([a], [b]) => a.localeCompare(b)).map(([key, entry]) => [key, normalize(entry)])
8
+ );
9
+ }
10
+ function canonicalJson(value, pretty = false) {
11
+ return `${JSON.stringify(normalize(value), null, pretty ? 2 : void 0)}
12
+ `;
13
+ }
14
+ function sha256(value) {
15
+ return createHash("sha256").update(value).digest("hex");
16
+ }
17
+ function manifestPayload(manifest) {
18
+ const { hash: _hash, ...payload } = manifest;
19
+ return payload;
20
+ }
21
+ function computeManifestHash(manifest) {
22
+ return sha256(canonicalJson(manifestPayload(manifest)));
23
+ }
24
+ function canonicalManifestJson(manifest) {
25
+ return canonicalJson(manifest, true);
26
+ }
27
+ function verifyManifest(manifest) {
28
+ if (computeManifestHash(manifest) !== manifest.hash) {
29
+ throw new Error(`capability contract hash mismatch: ${manifest.hash}`);
30
+ }
31
+ }
32
+
33
+ // src/plugin.ts
34
+ import { existsSync, readFileSync } from "fs";
35
+ import { dirname, isAbsolute, join, resolve as resolve2 } from "path";
36
+ import {
37
+ DEFAULT_LIMITS,
38
+ parseCapabilityId,
39
+ validateJsonSchemaDocument
40
+ } from "@agent-surface/core";
41
+
42
+ // src/extract.ts
43
+ import { posix, relative, resolve } from "path";
44
+ import ts from "typescript";
45
+ var CORE = "@agent-surface/core";
46
+ var COMPONENT_MACRO = "defineAgentComponentContract";
47
+ var PROCEDURE_MACRO = "defineAgentProcedureContract";
48
+ var EXTERNAL_MACRO = "defineExternalAgentToolContract";
49
+ var WRAPPERS = /* @__PURE__ */ new Set([
50
+ "observationContract",
51
+ "actionContract",
52
+ "fromJsonSchema",
53
+ "defineAgentComponentContract",
54
+ "defineAgentProcedureContract",
55
+ "defineExternalAgentToolContract"
56
+ ]);
57
+ function sourceKind(id) {
58
+ if (/\.tsx(?:\?|$)/.test(id)) return ts.ScriptKind.TSX;
59
+ if (/\.jsx(?:\?|$)/.test(id)) return ts.ScriptKind.JSX;
60
+ if (/\.js(?:\?|$)/.test(id)) return ts.ScriptKind.JS;
61
+ return ts.ScriptKind.TS;
62
+ }
63
+ function unwrap(node) {
64
+ while (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isTypeAssertionExpression(node) || ts.isSatisfiesExpression(node) || ts.isNonNullExpression(node)) {
65
+ node = node.expression;
66
+ }
67
+ return node;
68
+ }
69
+ function propertyName(node) {
70
+ if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node)) {
71
+ return node.text;
72
+ }
73
+ if (ts.isComputedPropertyName(node) && ts.isStringLiteral(unwrap(node.expression))) {
74
+ return unwrap(node.expression).text;
75
+ }
76
+ return void 0;
77
+ }
78
+ function calleeName(node) {
79
+ node = unwrap(node);
80
+ if (ts.isIdentifier(node)) return node.text;
81
+ if (ts.isPropertyAccessExpression(node)) return node.name.text;
82
+ if (ts.isElementAccessExpression(node) && node.argumentExpression && ts.isStringLiteral(unwrap(node.argumentExpression))) {
83
+ return unwrap(node.argumentExpression).text;
84
+ }
85
+ return void 0;
86
+ }
87
+ function normalizedOrigin(root, id) {
88
+ const clean = id.replace(/^\0/, "virtual:").split("?")[0];
89
+ if (clean.startsWith("virtual:")) return clean;
90
+ const path = clean.startsWith("/@fs/") ? clean.slice(4) : clean;
91
+ return posix.normalize(relative(root, resolve(path)).split("\\").join("/"));
92
+ }
93
+ var StaticEvaluator = class {
94
+ constructor(file) {
95
+ this.file = file;
96
+ const visit = (node) => {
97
+ if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {
98
+ this.constants.set(node.name.text, node.initializer);
99
+ }
100
+ ts.forEachChild(node, visit);
101
+ };
102
+ visit(file);
103
+ }
104
+ file;
105
+ constants = /* @__PURE__ */ new Map();
106
+ active = /* @__PURE__ */ new Set();
107
+ evaluate(input, where) {
108
+ const node = unwrap(input);
109
+ if (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) return node.text;
110
+ if (ts.isNumericLiteral(node)) return Number(node.text);
111
+ if (node.kind === ts.SyntaxKind.TrueKeyword) return true;
112
+ if (node.kind === ts.SyntaxKind.FalseKeyword) return false;
113
+ if (node.kind === ts.SyntaxKind.NullKeyword) return null;
114
+ if (ts.isPrefixUnaryExpression(node) && node.operator === ts.SyntaxKind.MinusToken) {
115
+ const value = this.evaluate(node.operand, where);
116
+ if (typeof value === "number") return -value;
117
+ }
118
+ if (ts.isArrayLiteralExpression(node)) {
119
+ return node.elements.map((entry, index) => {
120
+ if (ts.isSpreadElement(entry)) {
121
+ const spread = this.evaluate(entry.expression, `${where}[${index}]`);
122
+ if (!Array.isArray(spread)) throw this.failure(entry, `${where}: array spread is not static`);
123
+ return spread;
124
+ }
125
+ return this.evaluate(entry, `${where}[${index}]`);
126
+ }).flat();
127
+ }
128
+ if (ts.isObjectLiteralExpression(node)) {
129
+ const result = {};
130
+ for (const property of node.properties) {
131
+ if (ts.isSpreadAssignment(property)) {
132
+ const spread = this.evaluate(property.expression, `${where} spread`);
133
+ if (typeof spread !== "object" || spread === null || Array.isArray(spread)) {
134
+ throw this.failure(property, `${where}: object spread is not static`);
135
+ }
136
+ Object.assign(result, spread);
137
+ continue;
138
+ }
139
+ if (ts.isShorthandPropertyAssignment(property)) {
140
+ result[property.name.text] = this.evaluate(property.name, `${where}.${property.name.text}`);
141
+ continue;
142
+ }
143
+ if (!ts.isPropertyAssignment(property)) {
144
+ throw this.failure(property, `${where}: methods/accessors are runtime code`);
145
+ }
146
+ const name = propertyName(property.name);
147
+ if (name === void 0) throw this.failure(property.name, `${where}: computed key is not static`);
148
+ result[name] = this.evaluate(property.initializer, `${where}.${name}`);
149
+ }
150
+ return result;
151
+ }
152
+ if (ts.isIdentifier(node)) {
153
+ if (node.text === "undefined") throw this.failure(node, `${where}: undefined is not serializable`);
154
+ if (node.text === "emptyObjectSchema") {
155
+ return { type: "object", properties: {}, additionalProperties: false };
156
+ }
157
+ const value = this.constants.get(node.text);
158
+ if (!value) throw this.failure(node, `${where}: imported/dynamic value "${node.text}" is not static`);
159
+ if (this.active.has(node.text)) throw this.failure(node, `${where}: cyclic static value "${node.text}"`);
160
+ this.active.add(node.text);
161
+ try {
162
+ return this.evaluate(value, where);
163
+ } finally {
164
+ this.active.delete(node.text);
165
+ }
166
+ }
167
+ if (ts.isCallExpression(node)) {
168
+ const name = calleeName(node.expression);
169
+ if (name && WRAPPERS.has(name) && node.arguments[0]) {
170
+ return this.evaluate(node.arguments[0], where);
171
+ }
172
+ throw this.failure(node, `${where}: call "${name ?? "<computed>"}" is not a compiler macro`);
173
+ }
174
+ if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {
175
+ const owner = this.evaluate(node.expression, where);
176
+ const name = ts.isPropertyAccessExpression(node) ? node.name.text : node.argumentExpression && ts.isStringLiteral(unwrap(node.argumentExpression)) ? unwrap(node.argumentExpression).text : void 0;
177
+ if (name !== void 0 && typeof owner === "object" && owner !== null && !Array.isArray(owner)) {
178
+ const value = owner[name];
179
+ if (value !== void 0) return value;
180
+ }
181
+ }
182
+ throw this.failure(node, `${where}: expression is dynamic or non-serializable`);
183
+ }
184
+ failure(node, message) {
185
+ const position = this.file.getLineAndCharacterOfPosition(node.getStart(this.file));
186
+ return new Error(`${this.file.fileName}:${position.line + 1}:${position.character + 1}: ${message}`);
187
+ }
188
+ };
189
+ function record(value, where) {
190
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
191
+ throw new Error(`${where} must be a static object`);
192
+ }
193
+ return value;
194
+ }
195
+ function string(value, where) {
196
+ if (typeof value !== "string" || value.length === 0) throw new Error(`${where} must be a string`);
197
+ return value;
198
+ }
199
+ function policies(value) {
200
+ if (value === void 0) return void 0;
201
+ if (!Array.isArray(value)) throw new Error("policies must be a static array");
202
+ return value.map((entry) => record(entry, "policy"));
203
+ }
204
+ function combine(inherited, local) {
205
+ const values = [...inherited ?? [], ...local ?? []];
206
+ if (values.length === 0) return void 0;
207
+ const unique = new Map(values.map((value) => [canonicalJson(value), value]));
208
+ return [...unique.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([, value]) => value);
209
+ }
210
+ function entryHash(entry) {
211
+ return sha256(canonicalJson(entry));
212
+ }
213
+ function declarationVariable(call) {
214
+ let node = call;
215
+ while (node.parent && (ts.isParenthesizedExpression(node.parent) || ts.isAsExpression(node.parent) || ts.isSatisfiesExpression(node.parent))) {
216
+ node = node.parent;
217
+ }
218
+ return node.parent && ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) ? node.parent.name.text : void 0;
219
+ }
220
+ function isMacroCall(call, names, namespaces, aliases) {
221
+ const expression = unwrap(call.expression);
222
+ let imported;
223
+ if (ts.isIdentifier(expression)) imported = aliases.get(expression.text);
224
+ else if (ts.isPropertyAccessExpression(expression) && ts.isIdentifier(expression.expression)) {
225
+ if (namespaces.has(expression.expression.text)) imported = expression.name.text;
226
+ } else if (ts.isElementAccessExpression(expression) && ts.isIdentifier(expression.expression) && namespaces.has(expression.expression.text) && expression.argumentExpression && ts.isStringLiteral(unwrap(expression.argumentExpression))) {
227
+ imported = unwrap(expression.argumentExpression).text;
228
+ }
229
+ if (imported === COMPONENT_MACRO) return "component";
230
+ if (imported === PROCEDURE_MACRO) return "procedure";
231
+ if (imported === EXTERNAL_MACRO) return "external";
232
+ return void 0;
233
+ }
234
+ function extractModule(options) {
235
+ const file = ts.createSourceFile(options.id, options.code, ts.ScriptTarget.Latest, true, sourceKind(options.id));
236
+ const namespaces = /* @__PURE__ */ new Set();
237
+ const aliases = /* @__PURE__ */ new Map();
238
+ for (const statement of file.statements) {
239
+ if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) continue;
240
+ if (statement.moduleSpecifier.text !== CORE || !statement.importClause) continue;
241
+ const bindings = statement.importClause.namedBindings;
242
+ if (bindings && ts.isNamespaceImport(bindings)) namespaces.add(bindings.name.text);
243
+ if (bindings && ts.isNamedImports(bindings)) {
244
+ for (const binding of bindings.elements) {
245
+ aliases.set(binding.name.text, binding.propertyName?.text ?? binding.name.text);
246
+ }
247
+ }
248
+ }
249
+ let changed = true;
250
+ while (changed) {
251
+ changed = false;
252
+ const visitAlias = (node) => {
253
+ if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.initializer) {
254
+ const init = unwrap(node.initializer);
255
+ let source;
256
+ if (ts.isIdentifier(init)) source = aliases.get(init.text);
257
+ else if (ts.isPropertyAccessExpression(init) && ts.isIdentifier(init.expression) && namespaces.has(init.expression.text)) {
258
+ source = init.name.text;
259
+ }
260
+ if (source && !aliases.has(node.name.text)) {
261
+ aliases.set(node.name.text, source);
262
+ changed = true;
263
+ }
264
+ }
265
+ ts.forEachChild(node, visitAlias);
266
+ };
267
+ visitAlias(file);
268
+ }
269
+ const macroNames = /* @__PURE__ */ new Set([COMPONENT_MACRO, PROCEDURE_MACRO, EXTERNAL_MACRO]);
270
+ if (![...aliases.values()].some((name) => macroNames.has(name)) && namespaces.size === 0) {
271
+ return { code: options.code, entries: [] };
272
+ }
273
+ const evaluator = new StaticEvaluator(file);
274
+ const entries = [];
275
+ const injections = [];
276
+ const origin = normalizedOrigin(options.root, options.id);
277
+ const visit = (node) => {
278
+ if (ts.isCallExpression(node)) {
279
+ const macro = isMacroCall(node, macroNames, namespaces, aliases);
280
+ if (macro) {
281
+ if (!node.arguments[0]) throw new Error(`${origin}: contract declaration needs an argument`);
282
+ const variable = declarationVariable(node);
283
+ if (!variable) throw new Error(`${origin}: contract declaration must initialize a named module constant`);
284
+ const declarationId = `${origin}#${variable}`;
285
+ const definition = record(evaluator.evaluate(node.arguments[0], declarationId), declarationId);
286
+ const emitted = [];
287
+ if (macro === "component") {
288
+ const type = string(definition.type, `${declarationId}.type`);
289
+ const inheritedPolicies = policies(definition.policies);
290
+ const inheritedTags = definition.tags;
291
+ const groups = [
292
+ ["observations", "observation", "read"],
293
+ ["actions", "action", void 0]
294
+ ];
295
+ for (const [groupName, kind, defaultEffect] of groups) {
296
+ const groupValue = definition[groupName];
297
+ if (groupValue === void 0) continue;
298
+ const group = record(groupValue, `${declarationId}.${groupName}`);
299
+ for (const [name, rawMember] of Object.entries(group)) {
300
+ const member = record(rawMember, `${declarationId}.${groupName}.${name}`);
301
+ const capabilityPolicies = combine(inheritedPolicies, policies(member.policies));
302
+ const capabilityTags = combine(inheritedTags, member.tags);
303
+ const base = {
304
+ declarationId,
305
+ capabilityId: `view:${type}.${name}`,
306
+ kind,
307
+ description: string(member.description, `${declarationId}.${name}.description`),
308
+ effect: string(member.effect ?? defaultEffect, `${declarationId}.${name}.effect`),
309
+ ...member.input ? { inputSchema: member.input } : {},
310
+ ...member.output ? { outputSchema: member.output } : {},
311
+ ...member.confirmation ? { confirmation: member.confirmation } : {},
312
+ ...capabilityPolicies ? { policies: capabilityPolicies } : {},
313
+ ...capabilityTags ? { tags: capabilityTags } : {},
314
+ origin
315
+ };
316
+ emitted.push({ ...base, contractHash: entryHash(base), targets: [options.target] });
317
+ }
318
+ }
319
+ } else {
320
+ const id = string(definition.id, `${declarationId}.id`);
321
+ const base = {
322
+ declarationId,
323
+ capabilityId: id,
324
+ kind: macro === "procedure" ? "procedure" : "external",
325
+ description: string(definition.description, `${declarationId}.description`),
326
+ effect: string(definition.effect, `${declarationId}.effect`),
327
+ ...definition.input ? { inputSchema: definition.input } : {},
328
+ ...definition.output ? { outputSchema: definition.output } : {},
329
+ ...definition.confirmation ? { confirmation: definition.confirmation } : {},
330
+ ...policies(definition.policies) ? { policies: policies(definition.policies) } : {},
331
+ ...definition.tags ? { tags: definition.tags } : {},
332
+ origin
333
+ };
334
+ emitted.push({ ...base, contractHash: entryHash(base), targets: [options.target] });
335
+ }
336
+ entries.push(...emitted);
337
+ if (node.arguments.length < 2) {
338
+ if (macro === "component") {
339
+ const capabilities = {};
340
+ for (const entry of emitted) {
341
+ capabilities[entry.capabilityId] = {
342
+ manifestHash: options.placeholder,
343
+ declarationId: entry.declarationId,
344
+ capabilityId: entry.capabilityId,
345
+ contractHash: entry.contractHash
346
+ };
347
+ }
348
+ const provenance = {
349
+ manifestHash: options.placeholder,
350
+ declarationId,
351
+ capabilities
352
+ };
353
+ injections.push({ position: node.arguments.end, text: `, ${JSON.stringify(provenance)}` });
354
+ } else {
355
+ const entry = emitted[0];
356
+ const token = {
357
+ manifestHash: options.placeholder,
358
+ declarationId,
359
+ capabilityId: entry.capabilityId,
360
+ contractHash: entry.contractHash
361
+ };
362
+ injections.push({ position: node.arguments.end, text: `, ${JSON.stringify(token)}` });
363
+ }
364
+ }
365
+ }
366
+ }
367
+ ts.forEachChild(node, visit);
368
+ };
369
+ visit(file);
370
+ let code = options.code;
371
+ for (const injection of injections.sort((a, b) => b.position - a.position)) {
372
+ code = `${code.slice(0, injection.position)}${injection.text}${code.slice(injection.position)}`;
373
+ }
374
+ return { code, entries };
375
+ }
376
+
377
+ // src/plugin.ts
378
+ var COMPILER_VERSION = "0.16.0";
379
+ var CONTRACT_FILE = "agent-surface.contract.json";
380
+ var VIRTUAL_CONTRACT_ID = "virtual:agent-surface-contract";
381
+ var RESOLVED_VIRTUAL_CONTRACT_ID = `\0${VIRTUAL_CONTRACT_ID}`;
382
+ function mergeEntries(entries) {
383
+ const byKey = /* @__PURE__ */ new Map();
384
+ for (const entry of entries) {
385
+ const key = `${entry.declarationId}\0${entry.capabilityId}`;
386
+ const current = byKey.get(key);
387
+ if (!current) {
388
+ byKey.set(key, { ...entry, targets: [...entry.targets] });
389
+ continue;
390
+ }
391
+ if (current.contractHash !== entry.contractHash) {
392
+ throw new Error(`contract "${entry.declarationId}" / "${entry.capabilityId}" differs across build targets`);
393
+ }
394
+ current.targets = [.../* @__PURE__ */ new Set([...current.targets, ...entry.targets])].sort();
395
+ }
396
+ return [...byKey.values()].sort(
397
+ (a, b) => `${a.declarationId}\0${a.capabilityId}`.localeCompare(`${b.declarationId}\0${b.capabilityId}`)
398
+ );
399
+ }
400
+ function validateEntries(entries) {
401
+ for (const entry of entries) {
402
+ if (entry.kind !== "external" && !parseCapabilityId(entry.capabilityId)) {
403
+ throw new Error(`invalid compiled capability id "${entry.capabilityId}"`);
404
+ }
405
+ for (const [label, schema] of [["input", entry.inputSchema], ["output", entry.outputSchema]]) {
406
+ if (!schema) continue;
407
+ const result = validateJsonSchemaDocument(schema, DEFAULT_LIMITS);
408
+ if (!result.ok) {
409
+ throw new Error(`${entry.declarationId} ${label} schema: ${result.reason}`);
410
+ }
411
+ }
412
+ }
413
+ }
414
+ function readPinnedContract(input, root) {
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) {
427
+ if (id.startsWith("\0") || !isAbsolute(id)) return void 0;
428
+ let dir = dirname(id.split("?")[0]);
429
+ while (dir !== dirname(dir)) {
430
+ const packagePath = join(dir, "package.json");
431
+ if (existsSync(packagePath)) {
432
+ if (seen.has(packagePath)) return void 0;
433
+ seen.add(packagePath);
434
+ const pkg = JSON.parse(readFileSync(packagePath, "utf8"));
435
+ return pkg.agentSurface?.contract ? resolve2(dir, pkg.agentSurface.contract) : void 0;
436
+ }
437
+ dir = dirname(dir);
438
+ }
439
+ return void 0;
440
+ }
441
+ function agentSurface(options = {}) {
442
+ const target = options.target ?? "web-production";
443
+ const placeholder = `__AGENT_SURFACE_MANIFEST_HASH_${Math.random().toString(36).slice(2)}__`;
444
+ const manifestPlaceholder = `__AGENT_SURFACE_MANIFEST_${Math.random().toString(36).slice(2)}__`;
445
+ let root = process.cwd();
446
+ let entries = [];
447
+ let manifest;
448
+ return {
449
+ name: "agent-surface:compiler",
450
+ apply: "build",
451
+ enforce: "pre",
452
+ configResolved(config) {
453
+ root = config.root;
454
+ },
455
+ resolveId(id) {
456
+ return id === VIRTUAL_CONTRACT_ID ? RESOLVED_VIRTUAL_CONTRACT_ID : null;
457
+ },
458
+ load(id) {
459
+ if (id !== RESOLVED_VIRTUAL_CONTRACT_ID) return null;
460
+ return `export default ${manifestPlaceholder};`;
461
+ },
462
+ buildStart() {
463
+ entries = [];
464
+ manifest = void 0;
465
+ },
466
+ transform(code, id) {
467
+ if (id.includes("/node_modules/@agent-surface/") || /\/packages\/(?:core|react|orpc|testing|webmcp|cli|compiler)\//.test(id)) {
468
+ return null;
469
+ }
470
+ if (/\buseAgentComponent\s*\(\s*\{/.test(code)) {
471
+ throw new Error(`${id}: inline useAgentComponent registration is unsupported; bind a compiled contract`);
472
+ }
473
+ if (/\b(?:useAgentAction|useAgentObservation)\s*\(/.test(code)) {
474
+ throw new Error(`${id}: granular runtime capability construction is unsupported by the compiled contract`);
475
+ }
476
+ if (/\bdefineAgentComponent\s*\(/.test(code) || /\bregistry\s*\.\s*register\s*\(\s*\{/.test(code)) {
477
+ throw new Error(`${id}: raw capability registration bypasses the compiled exposure ceiling`);
478
+ }
479
+ if (!code.includes("defineAgentComponentContract") && !code.includes("defineAgentProcedureContract") && !code.includes("defineExternalAgentToolContract")) {
480
+ return null;
481
+ }
482
+ const extracted = extractModule({ code, id, root, target, placeholder });
483
+ entries.push(...extracted.entries);
484
+ return extracted.code === code ? null : { code: extracted.code, map: null };
485
+ },
486
+ buildEnd(error) {
487
+ if (error) return;
488
+ const externalContracts = [];
489
+ const externalEntries = [];
490
+ const seenPackages = /* @__PURE__ */ new Set();
491
+ const sidecars = /* @__PURE__ */ new Set();
492
+ for (const id of this.getModuleIds()) {
493
+ const sidecar = nearestPackageSidecar(id, seenPackages);
494
+ if (sidecar) sidecars.add(sidecar);
495
+ }
496
+ for (const sidecar of sidecars) {
497
+ const bytes = readFileSync(sidecar);
498
+ const external = JSON.parse(bytes.toString("utf8"));
499
+ verifyManifest(external);
500
+ externalEntries.push(...external.capabilities);
501
+ externalContracts.push({ source: sidecar.split("/").slice(-3).join("/"), digest: sha256(bytes) });
502
+ }
503
+ for (const pinned of options.externalContracts ?? []) {
504
+ const external = readPinnedContract(pinned, root);
505
+ externalEntries.push(...external.capabilities);
506
+ externalContracts.push({ source: pinned.path, digest: pinned.digest });
507
+ }
508
+ const capabilities = mergeEntries([...entries, ...externalEntries]);
509
+ validateEntries(capabilities);
510
+ const targets = [...new Set(capabilities.flatMap((entry) => entry.targets))].sort();
511
+ const payload = {
512
+ formatVersion: 3,
513
+ compilerVersion: COMPILER_VERSION,
514
+ targets,
515
+ capabilities,
516
+ externalContracts: externalContracts.sort((a, b) => a.source.localeCompare(b.source)),
517
+ completeness: { status: "proven" }
518
+ };
519
+ manifest = { ...payload, hash: computeManifestHash(payload) };
520
+ options.onManifest?.(manifest);
521
+ },
522
+ renderChunk(code) {
523
+ if (!manifest || !code.includes(placeholder) && !code.includes(manifestPlaceholder)) return null;
524
+ return {
525
+ code: code.replaceAll(placeholder, manifest.hash).replaceAll(manifestPlaceholder, JSON.stringify(manifest)),
526
+ map: null
527
+ };
528
+ },
529
+ generateBundle() {
530
+ if (!manifest || options.emit === false) return;
531
+ this.emitFile({
532
+ type: "asset",
533
+ fileName: options.fileName ?? CONTRACT_FILE,
534
+ source: canonicalManifestJson(manifest)
535
+ });
536
+ }
537
+ };
538
+ }
539
+
540
+ // src/compile.ts
541
+ import { resolve as resolve3 } from "path";
542
+ import { build } from "vite";
543
+ async function compileCapabilityContract(options = {}) {
544
+ let manifest;
545
+ const root = resolve3(options.root ?? process.cwd());
546
+ const result = await build({
547
+ ...options.vite ?? {},
548
+ root,
549
+ ...options.configFile ? { configFile: resolve3(root, options.configFile) } : {},
550
+ logLevel: options.vite?.logLevel ?? "silent",
551
+ build: {
552
+ ...options.vite?.build ?? {},
553
+ write: false
554
+ },
555
+ plugins: [
556
+ ...options.vite?.plugins ?? [],
557
+ agentSurface({
558
+ target: options.target,
559
+ emit: false,
560
+ onManifest: (value) => {
561
+ manifest = value;
562
+ }
563
+ })
564
+ ]
565
+ });
566
+ const outputs = Array.isArray(result) ? result : [result];
567
+ for (const output of outputs) {
568
+ if (!("output" in output)) continue;
569
+ const asset = output.output.find(
570
+ (entry) => entry.type === "asset" && entry.fileName === "agent-surface.contract.json"
571
+ );
572
+ if (asset?.type === "asset") {
573
+ const source = typeof asset.source === "string" ? asset.source : new TextDecoder().decode(asset.source);
574
+ manifest = JSON.parse(source);
575
+ break;
576
+ }
577
+ }
578
+ if (!manifest) throw new Error("compiler did not produce a capability contract");
579
+ return manifest;
580
+ }
581
+ export {
582
+ COMPILER_VERSION,
583
+ CONTRACT_FILE,
584
+ VIRTUAL_CONTRACT_ID,
585
+ agentSurface,
586
+ canonicalJson,
587
+ canonicalManifestJson,
588
+ compileCapabilityContract,
589
+ computeManifestHash,
590
+ manifestPayload,
591
+ sha256,
592
+ verifyManifest
593
+ };
594
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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.localeCompare(b))\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.16.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 `export default ${manifestPlaceholder};`;\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: 3 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 CompiledCapabilityToken,\n CompiledComponentProvenance,\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\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,MAAM,UAAU,MAAS,EACzC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,EACrC,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,CAAC;AAAA,EAClD;AACF;AAEO,SAAS,cAAc,OAAgB,SAAS,OAAe;AACpE,SAAO,GAAG,KAAK,UAAU,UAAU,KAAK,GAAG,MAAM,SAAS,IAAI,MAAS,CAAC;AAAA;AAC1E;AAEO,SAAS,OAAO,OAAoC;AACzD,SAAO,WAAW,QAAQ,EAAE,OAAO,KAAK,EAAE,OAAO,KAAK;AACxD;AAEO,SAAS,gBACd,UAC0C;AAC1C,QAAM,EAAE,MAAM,OAAO,GAAG,QAAQ,IAAI;AACpC,SAAO;AACT;AAEO,SAAS,oBACd,UACQ;AACR,SAAO,OAAO,cAAc,gBAAgB,QAAQ,CAAC,CAAC;AACxD;AAEO,SAAS,sBAAs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,OAAM,IAAI,MAAM,gDAAgD;AAC/E,SAAO;AACT;","names":["resolve","resolve","resolve","resolve"]}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@agent-surface/compiler",
3
+ "version": "0.16.0",
4
+ "description": "Vite compiler for deterministic agent capability contracts",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "LICENSE"
19
+ ],
20
+ "dependencies": {
21
+ "typescript": "^5.9.2",
22
+ "vite": "^7.1.3",
23
+ "@agent-surface/core": "^0.16.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^20.19.0"
27
+ },
28
+ "author": "Paolo Barbato",
29
+ "engines": {
30
+ "node": ">=20.19.0"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/Wiseair-srl/agent-surface.git",
35
+ "directory": "packages/compiler"
36
+ },
37
+ "homepage": "https://agent-surface-docs.vercel.app",
38
+ "bugs": {
39
+ "url": "https://github.com/Wiseair-srl/agent-surface/issues"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "keywords": [
45
+ "agent-surface",
46
+ "vite",
47
+ "compiler",
48
+ "capabilities",
49
+ "manifest"
50
+ ],
51
+ "scripts": {
52
+ "build": "tsup",
53
+ "typecheck": "tsc --noEmit"
54
+ }
55
+ }