@inventarch/agent-composition-system 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/LANGUAGE.md +2 -2
  2. package/README.md +3 -1
  3. package/SPEC.md +3 -1
  4. package/dist/adapters.d.ts +2 -69
  5. package/dist/adapters.d.ts.map +1 -1
  6. package/dist/adapters.js +2 -211
  7. package/dist/adapters.js.map +1 -1
  8. package/dist/authoring-format.d.ts +2 -22
  9. package/dist/authoring-format.d.ts.map +1 -1
  10. package/dist/authoring-format.js +2 -287
  11. package/dist/authoring-format.js.map +1 -1
  12. package/dist/authoring-index.d.ts +2 -31
  13. package/dist/authoring-index.d.ts.map +1 -1
  14. package/dist/authoring-index.js +2 -251
  15. package/dist/authoring-index.js.map +1 -1
  16. package/dist/authoring-manifest.d.ts +2 -68
  17. package/dist/authoring-manifest.d.ts.map +1 -1
  18. package/dist/authoring-manifest.js +2 -386
  19. package/dist/authoring-manifest.js.map +1 -1
  20. package/dist/authoring-types.d.ts +2 -224
  21. package/dist/authoring-types.d.ts.map +1 -1
  22. package/dist/authoring-types.js +2 -1
  23. package/dist/authoring-types.js.map +1 -1
  24. package/dist/authoring.d.ts +2 -46
  25. package/dist/authoring.d.ts.map +1 -1
  26. package/dist/authoring.js +2 -564
  27. package/dist/authoring.js.map +1 -1
  28. package/dist/candidate.d.ts +2 -10
  29. package/dist/candidate.d.ts.map +1 -1
  30. package/dist/candidate.js +2 -83
  31. package/dist/candidate.js.map +1 -1
  32. package/dist/compile.d.ts +1 -1
  33. package/dist/compile.d.ts.map +1 -1
  34. package/dist/compile.js +8 -4
  35. package/dist/compile.js.map +1 -1
  36. package/dist/corpus.d.ts +2 -32
  37. package/dist/corpus.d.ts.map +1 -1
  38. package/dist/corpus.js +2 -181
  39. package/dist/corpus.js.map +1 -1
  40. package/dist/index.d.ts +9 -4
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +7 -3
  43. package/dist/index.js.map +1 -1
  44. package/dist/installed-catalog.d.ts +2 -2
  45. package/dist/installed-catalog.d.ts.map +1 -1
  46. package/dist/installed-catalog.js +4 -45
  47. package/dist/installed-catalog.js.map +1 -1
  48. package/dist/installed-read.d.ts +1 -1
  49. package/dist/installed-read.d.ts.map +1 -1
  50. package/dist/installed-read.js +1 -1
  51. package/dist/installed-read.js.map +1 -1
  52. package/dist/installed-source-policy.d.ts +2 -30
  53. package/dist/installed-source-policy.d.ts.map +1 -1
  54. package/dist/installed-source-policy.js +2 -94
  55. package/dist/installed-source-policy.js.map +1 -1
  56. package/dist/lifecycle-profile.d.ts +2 -58
  57. package/dist/lifecycle-profile.d.ts.map +1 -1
  58. package/dist/lifecycle-profile.js +2 -205
  59. package/dist/lifecycle-profile.js.map +1 -1
  60. package/dist/lifecycle-rows.d.ts +2 -11
  61. package/dist/lifecycle-rows.d.ts.map +1 -1
  62. package/dist/lifecycle-rows.js +2 -34
  63. package/dist/lifecycle-rows.js.map +1 -1
  64. package/dist/lifecycle-transport.d.ts +2 -20
  65. package/dist/lifecycle-transport.d.ts.map +1 -1
  66. package/dist/lifecycle-transport.js +2 -126
  67. package/dist/lifecycle-transport.js.map +1 -1
  68. package/dist/lifecycle.d.ts +2 -121
  69. package/dist/lifecycle.d.ts.map +1 -1
  70. package/dist/lifecycle.js +2 -436
  71. package/dist/lifecycle.js.map +1 -1
  72. package/dist/local-store.d.ts +2 -49
  73. package/dist/local-store.d.ts.map +1 -1
  74. package/dist/local-store.js +2 -185
  75. package/dist/local-store.js.map +1 -1
  76. package/dist/native-selection.json +55 -55
  77. package/dist/native.ia.tgz +0 -0
  78. package/dist/projection-codex.d.ts +2 -14
  79. package/dist/projection-codex.d.ts.map +1 -1
  80. package/dist/projection-codex.js +2 -73
  81. package/dist/projection-codex.js.map +1 -1
  82. package/dist/projection-format.d.ts +2 -152
  83. package/dist/projection-format.d.ts.map +1 -1
  84. package/dist/projection-format.js +2 -200
  85. package/dist/projection-format.js.map +1 -1
  86. package/dist/projection-host.d.ts +2 -42
  87. package/dist/projection-host.d.ts.map +1 -1
  88. package/dist/projection-host.js +2 -338
  89. package/dist/projection-host.js.map +1 -1
  90. package/dist/projection-routine.d.ts +2 -3
  91. package/dist/projection-routine.d.ts.map +1 -1
  92. package/dist/projection-routine.js +2 -49
  93. package/dist/projection-routine.js.map +1 -1
  94. package/dist/projections.d.ts +2 -23
  95. package/dist/projections.d.ts.map +1 -1
  96. package/dist/projections.js +2 -430
  97. package/dist/projections.js.map +1 -1
  98. package/dist/publication.d.ts +2 -6
  99. package/dist/publication.d.ts.map +1 -1
  100. package/dist/publication.js +2 -139
  101. package/dist/publication.js.map +1 -1
  102. package/dist/resource-context.d.ts +2 -25
  103. package/dist/resource-context.d.ts.map +1 -1
  104. package/dist/resource-context.js +2 -270
  105. package/dist/resource-context.js.map +1 -1
  106. package/dist/resource-files.d.ts +2 -9
  107. package/dist/resource-files.d.ts.map +1 -1
  108. package/dist/resource-files.js +2 -87
  109. package/dist/resource-files.js.map +1 -1
  110. package/dist/resource-format.d.ts +2 -105
  111. package/dist/resource-format.d.ts.map +1 -1
  112. package/dist/resource-format.js +2 -241
  113. package/dist/resource-format.js.map +1 -1
  114. package/dist/resource-sources.d.ts +2 -6
  115. package/dist/resource-sources.d.ts.map +1 -1
  116. package/dist/resource-sources.js +2 -15
  117. package/dist/resource-sources.js.map +1 -1
  118. package/dist/resources.d.ts +2 -23
  119. package/dist/resources.d.ts.map +1 -1
  120. package/dist/resources.js +2 -82
  121. package/dist/resources.js.map +1 -1
  122. package/dist/sources.d.ts +2 -44
  123. package/dist/sources.d.ts.map +1 -1
  124. package/dist/sources.js +2 -289
  125. package/dist/sources.js.map +1 -1
  126. package/dist/system-package.json +313 -312
  127. package/dist/task-capture-format.d.ts +2 -24
  128. package/dist/task-capture-format.d.ts.map +1 -1
  129. package/dist/task-capture-format.js +2 -61
  130. package/dist/task-capture-format.js.map +1 -1
  131. package/dist/task-capture.d.ts +7 -7
  132. package/dist/task-capture.d.ts.map +1 -1
  133. package/dist/task-capture.js +8 -8
  134. package/dist/task-capture.js.map +1 -1
  135. package/dist/task-context-declaration.d.ts +2 -2
  136. package/dist/task-context-declaration.d.ts.map +1 -1
  137. package/dist/task-context-declaration.js +2 -2
  138. package/dist/task-context-declaration.js.map +1 -1
  139. package/dist/task-teaching-closure.d.ts +3 -3
  140. package/dist/task-teaching-closure.d.ts.map +1 -1
  141. package/dist/task-teaching-closure.js +4 -4
  142. package/dist/task-teaching-closure.js.map +1 -1
  143. package/dist/templates.d.ts +2 -34
  144. package/dist/templates.d.ts.map +1 -1
  145. package/dist/templates.js +2 -109
  146. package/dist/templates.js.map +1 -1
  147. package/dist/tools.d.ts +2 -2
  148. package/dist/tools.d.ts.map +1 -1
  149. package/dist/tools.js +3 -3
  150. package/dist/tools.js.map +1 -1
  151. package/package.json +13 -12
  152. package/references/public-spec.md +1 -1
@@ -1,431 +1,3 @@
1
- import { DEFAULT_TOKENIZER } from '@inventarch/runtime';
2
- import { posix } from 'node:path';
3
- import { nativeContext, nativeCoordinate, occurrencesByCoordinate, resolveResourcesWith, verifyResourcesWith, } from './resource-context.js';
4
- import { frozen, hash, keyOf, metadataDigest, occurrenceOf, ordered, portablePath, sha256, ResourceError, } from './resource-format.js';
5
- import { fail, id, inputFailure, PROJECTION_LIMITS, ProjectionError, verifyProjectionDescriptor, } from './projection-format.js';
6
- import { checkFeatures, codexAgentRegistration, discoveryLink, inert, invocation, isCodex, outputPath, pluginFile, PROSE_EFFECT_TOOLS, renderRecord, resourceDestination, resourceMarkdown, serializeExport, verifyCatalog, } from './projection-host.js';
7
- import { resourceVerifier } from './projection-routine.js';
8
- export { PROJECTION_LIMITS, ProjectionError, verifyProjectionDescriptor } from './projection-format.js';
9
- export { claudeProseCatalog, codexProseCatalog, CLAUDE_PROSE_FEATURES, CODEX_PROSE_FEATURES, } from './projection-host.js';
10
- function references(value) {
11
- return value.kind === 'ref' ? [value] : value.kind === 'list' ? value.items.flatMap(references) : [];
12
- }
13
- function fieldReferences(fields) {
14
- return fields.flatMap((f) => 'item' in f ? references(f.item) : [...references(f.value), ...fieldReferences(f.fields ?? [])]);
15
- }
16
- function texts(value) {
17
- return value.kind === 'list' ? value.items.flatMap(texts) : 'text' in value ? [value.text] : [];
18
- }
19
- /** Every field with this key in the record's sections of this name. */
20
- function keyed(record, section, key) {
21
- return record.sections
22
- .filter((s) => s.name === section)
23
- .flatMap((s) => s.fields)
24
- .filter((f) => 'key' in f && f.key === key);
25
- }
26
- /** One export's dependency closure over the host's current scoped reader. */
27
- class NativeClosure {
28
- options;
29
- selected = new Map();
30
- scoped;
31
- owners;
32
- constructor(options, available) {
33
- this.options = options;
34
- this.scoped = options.reader.records({ within: options.within });
35
- // Scoped winners join admitted occurrences through the shared first-match coordinate index.
36
- this.owners = new Map(this.scoped.flatMap((r) => {
37
- const o = available.get(nativeCoordinate(r.identity, r.source.line, r.source.path));
38
- return o ? [[r.identity, o]] : [];
39
- }));
40
- }
41
- exact(owner, discriminator) {
42
- const admitted = this.owners.get(owner.identity), record = this.scoped.find((r) => r.identity === owner.identity);
43
- if (!admitted ||
44
- occurrenceOf(admitted) !== occurrenceOf(owner) ||
45
- !record ||
46
- (discriminator && record.discriminator !== discriminator))
47
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Expected one exact admitted occurrence in the current scope', owner);
48
- return record;
49
- }
50
- resolve(reference, owner) {
51
- const result = this.options.reader.resolve(reference, { within: this.options.within });
52
- if (!result.ok)
53
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Native dependency is unresolved, ambiguous or scope-excluded', owner);
54
- const target = this.owners.get(result.identity);
55
- if (!target)
56
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Native dependency has no exact captured occurrence', owner);
57
- return this.exact(target);
58
- }
59
- add(record, depth = 0, compositionAncestors = []) {
60
- const owner = this.owners.get(record.identity);
61
- if (compositionAncestors.includes(record.identity))
62
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Cyclic native composition dependency', owner);
63
- if (depth > PROJECTION_LIMITS.depth)
64
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Projection dependency depth exceeded', owner);
65
- if (this.selected.has(record.identity))
66
- return;
67
- this.selected.set(record.identity, record);
68
- if (this.selected.size > PROJECTION_LIMITS.occurrences)
69
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Projection occurrence ceiling exceeded');
70
- for (const section of record.sections) {
71
- if (section.name === 'relationships')
72
- continue;
73
- for (const ref of fieldReferences(section.fields)) {
74
- this.add(this.resolve(ref, owner), depth + 1, section.name === 'composition' ? [...compositionAncestors, record.identity] : []);
75
- }
76
- }
77
- for (const edge of record.edges) {
78
- if ((['cite', 'use', 'require'].includes(edge.predicate) && edge.direction === 'out') ||
79
- (edge.predicate === 'govern' && edge.direction === 'in'))
80
- this.add(this.resolve(edge.reference, owner), depth + 1);
81
- }
82
- // Governing edges are resolved through the same scoped reader, never an unfiltered graph.
83
- for (const candidate of this.scoped)
84
- for (const edge of candidate.edges)
85
- if (edge.predicate === 'govern' && edge.direction === 'out') {
86
- const target = this.options.reader.resolve(edge.reference, { within: this.options.within });
87
- if (target.ok && target.identity === record.identity)
88
- this.add(candidate, depth + 1);
89
- }
90
- }
91
- export(entry) {
92
- this.add(this.exact(entry.target));
93
- const p = entry.presentation;
94
- if (p.kind !== 'agent') {
95
- if (!['capability', 'playbook'].includes(this.exact(entry.target).discriminator))
96
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Skill/command target must be an admitted capability or playbook', entry.target);
97
- for (const owner of p.body)
98
- this.add(this.exact(owner));
99
- return;
100
- }
101
- if (occurrenceOf(p.agent) !== occurrenceOf(entry.target))
102
- inputFailure('Agent export target and presentation agent differ');
103
- this.add(this.exact(p.agent, 'agent'));
104
- if (p.voice)
105
- this.add(this.exact(p.voice, 'voice'));
106
- if (p.mandate)
107
- this.add(this.exact(p.mandate, 'mandate'));
108
- // Host tools need native effects to bound them, and only an agent profile composes capabilities.
109
- const owner = p.agentProfile;
110
- if (!owner)
111
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Host tools need native capability effects from an agent profile', entry.target);
112
- const profile = this.exact(owner, 'agent-profile');
113
- if (fieldReferences(keyed(profile, 'composition', 'delegates')).length)
114
- fail('IA-PROJECTION-FEATURE-UNAVAILABLE', 'Native delegation needs a separately qualified host mapping', owner);
115
- const model = keyed(profile, 'execution', 'model-profile')[0];
116
- if (model && 'value' in model && (!('text' in model.value) || model.value.text !== p.model))
117
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Model metadata differs from its native profile', owner);
118
- // Effects are a ceiling: the union of the profile's own capability effects, through the fixed v1 table. Tool names stay host metadata.
119
- const effects = fieldReferences(keyed(profile, 'composition', 'capabilities')).flatMap((ref) => keyed(this.resolve(ref, owner), 'execution', 'effects'));
120
- const ceiling = new Set(effects
121
- .flatMap((f) => ('value' in f ? texts(f.value) : []))
122
- .flatMap((effect) => PROSE_EFFECT_TOOLS.get(effect) ?? []));
123
- if (p.tools.some((tool) => !ceiling.has(tool)))
124
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Host tools exceed the native capability effects', owner);
125
- for (const [field, explicit] of [
126
- ['agent', p.agent],
127
- ['voice', p.voice],
128
- ['mandate', p.mandate],
129
- ]) {
130
- const matches = keyed(profile, 'composition', field);
131
- if (explicit) {
132
- const value = matches[0];
133
- if (matches.length !== 1 ||
134
- !value ||
135
- !('value' in value) ||
136
- value.when ||
137
- value.value.kind !== 'ref' ||
138
- this.resolve(value.value, owner).identity !== explicit.identity)
139
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Authored presentation contradicts its native agent profile', explicit);
140
- }
141
- }
142
- this.add(profile);
143
- }
144
- occurrences() {
145
- return ordered([...this.selected.keys()].map((id) => this.owners.get(id)), occurrenceOf);
146
- }
147
- }
148
- function diagnostic(error) {
149
- if (error instanceof ProjectionError)
150
- return error.diagnostic;
151
- if (error instanceof ResourceError)
152
- return { code: 'IA-RESOURCE-INVALID', message: error.message };
153
- if (error !== null &&
154
- typeof error === 'object' &&
155
- 'code' in error &&
156
- typeof error.code === 'string' &&
157
- error.code.startsWith('IA-DB-'))
158
- return { code: 'IA-PROJECTION-SOURCE-UNAVAILABLE', message: 'Current native scope is unavailable' };
159
- return { code: 'IA-PROJECTION-INPUT-INVALID', message: 'Invalid projection capture, catalog or request' };
160
- }
161
- /** Pure projection over captured inputs and a host-selected current scoped reader. */
162
- export function compileProjection(capture, descriptor, inputResources, options) {
163
- try {
164
- // One verified capture copy and one native context serve the whole compile; per-export checks below still run.
165
- const description = verifyProjectionDescriptor(descriptor), context = nativeContext(capture), resources = verifyResourcesWith(inputResources, context), catalog = verifyCatalog(options.catalog);
166
- id(options.name);
167
- if (!/^\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?$/.test(options.version))
168
- inputFailure('Invalid product version');
169
- if (metadataDigest(description.sourceRevisions) !== metadataDigest(context.sourceRevisions) ||
170
- description.resourcesDigest !== resources.digest ||
171
- description.inventoryDigest !== hash(options.inventoryDigest))
172
- fail('IA-PROJECTION-SOURCE-UNAVAILABLE', 'Projection source/resource/inventory selection is stale');
173
- // This also validates token and whole native view even when no export uses resources.
174
- resolveResourcesWith(resources, context, {
175
- reader: options.reader,
176
- within: options.within,
177
- owners: [],
178
- allowedResources: options.allowedResources,
179
- expectedDigest: options.expectedResourcesDigest,
180
- maxBytes: PROJECTION_LIMITS.totalBytes,
181
- });
182
- const available = occurrencesByCoordinate(context), namespaces = new Set();
183
- for (const entry of description.exports) {
184
- const key = `${entry.presentation.kind === 'agent' && !(isCodex(catalog) && description.product === 'plugin') ? 'agent' : 'invocation'}:${entry.outputName}`;
185
- if (namespaces.has(key))
186
- inputFailure('Conflicting projection output name');
187
- namespaces.add(key);
188
- }
189
- const files = new Map(), outputs = new Map(), omissions = [], exported = [];
190
- const add = (path, bytes, encoding, role, sources, keys) => {
191
- portablePath(path);
192
- const sha = sha256(bytes), existing = files.get(path.toLowerCase());
193
- if (existing && (existing.path !== path || existing.sha256 !== sha || role !== 'resource'))
194
- inputFailure('Conflicting generated output path');
195
- if (bytes.length > PROJECTION_LIMITS.fileBytes)
196
- inputFailure('Generated file exceeds its byte ceiling');
197
- files.set(path.toLowerCase(), {
198
- path,
199
- bytes: bytes.length,
200
- sha256: sha,
201
- encoding,
202
- content: bytes.toString(encoding),
203
- });
204
- const previous = outputs.get(path);
205
- const owners = ordered([...new Map([...(previous?.sources ?? []), ...sources].map((o) => [occurrenceOf(o), o])).values()], occurrenceOf);
206
- outputs.set(path, {
207
- path,
208
- bytes: bytes.length,
209
- sha256: sha,
210
- role,
211
- sources: owners,
212
- resources: ordered([...new Map([...(previous?.resources ?? []), ...keys].map((k) => [keyOf(k), k])).values()], keyOf),
213
- });
214
- };
215
- for (const entry of description.exports) {
216
- try {
217
- const selected = description.profiles.find((p) => p.id === entry.profile);
218
- if (metadataDigest(selected) !== metadataDigest(catalog.profile))
219
- fail('IA-PROJECTION-FEATURE-UNAVAILABLE', 'Selected host profile is unavailable or has changed', entry.target);
220
- checkFeatures(entry, catalog, description.product);
221
- const closure = new NativeClosure(options, available);
222
- closure.export(entry);
223
- const owners = closure.occurrences(), associated = resources.associations.filter((a) => owners.some((o) => occurrenceOf(o) === occurrenceOf(a.owner)));
224
- const declared = associated.find((a) => occurrenceOf(a.owner) === occurrenceOf(entry.target))?.resources ?? [];
225
- if (metadataDigest(entry.resources) !== metadataDigest(declared))
226
- fail('IA-RESOURCE-INVALID', 'Export resources differ from the captured target association', entry.target);
227
- const resolution = resolveResourcesWith(resources, context, {
228
- reader: options.reader,
229
- within: options.within,
230
- owners: associated.map((a) => a.owner),
231
- allowedResources: options.allowedResources,
232
- expectedDigest: options.expectedResourcesDigest,
233
- maxBytes: PROJECTION_LIMITS.totalBytes,
234
- });
235
- const selectedFiles = [...new Map(resolution.items.map((r) => [keyOf(r.file.key), r.file])).values()];
236
- const path = outputPath(description.product, entry, catalog), blocks = [], optionalBlocks = [];
237
- const skillDirectory = path.endsWith('/SKILL.md') ? posix.dirname(path) : null;
238
- const destinations = new Map(selectedFiles.map((f) => [keyOf(f.key), resourceDestination(resources.digest, f)]));
239
- for (const core of [true, false]) {
240
- const selected = owners.filter((owner) => {
241
- const record = closure.selected.get(owner.identity);
242
- return (record.kind === 'governance' || record.discriminator === 'mandate') === core;
243
- });
244
- if (selected.length)
245
- blocks.push(core ? '## Mandatory native guidance' : '## Selected task and role guidance');
246
- for (const owner of selected)
247
- blocks.push(resourceMarkdown(renderRecord(closure.selected.get(owner.identity), owner), { key: owner }, path, destinations, true));
248
- }
249
- for (const file of selectedFiles)
250
- if (file.mediaType === 'text/markdown')
251
- resourceMarkdown(file.content, file, destinations.get(keyOf(file.key)), destinations, false);
252
- // Deduplicate bytes, not uses: every admitted owner/role/order/required/delivery association survives.
253
- // Groups keep the first-use order of resolution.items (owner, then role/order/key), so optional inline
254
- // blocks are offered to the budget in declared order, as resolveResourcesWith admits them, not path order.
255
- const groups = new Map();
256
- for (const item of resolution.items) {
257
- const key = keyOf(item.file.key);
258
- const uses = groups.get(key) ?? [];
259
- uses.push(item);
260
- groups.set(key, uses);
261
- }
262
- for (const [key, uses] of groups) {
263
- const teaching = uses.find((item) => item.use.required && ['body', 'guide'].includes(item.use.role));
264
- const inline = teaching ??
265
- uses.find((item) => item.use.required && item.use.delivery === 'inline') ??
266
- uses.find((item) => item.use.delivery === 'inline');
267
- const reference = teaching ?? uses.find((item) => item.use.required) ?? inline ?? uses[0];
268
- const destination = destinations.get(key);
269
- if (inline) {
270
- if (!['text/markdown', 'text/plain', 'application/json'].includes(inline.file.mediaType))
271
- fail('IA-PROJECTION-FEATURE-UNAVAILABLE', 'This inert profile cannot inline image content', inline.owner);
272
- const content = inline.file.mediaType === 'text/markdown'
273
- ? resourceMarkdown(inline.file.content, inline.file, path, destinations, true)
274
- : inline.file.content;
275
- inert(content);
276
- const block = `## ${inline.use.required ? 'Required' : 'Optional'} ${inline.use.role}\n\nSource: ${inline.citation}\n\n${content}`;
277
- if (inline.use.required)
278
- blocks.push(block);
279
- else
280
- optionalBlocks.push({ key, content: block });
281
- }
282
- blocks.push(`Reference (${reference.use.role}; ${reference.use.required ? 'required package member' : 'optional'}): ${discoveryLink(path, destination, reference.file.key.path)}\n\n` +
283
- uses
284
- .map((item) => `Use (${item.use.role}; ${item.use.required ? 'required package member' : 'optional'}; delivery=${item.use.delivery}; order=${item.use.order}; owner=${occurrenceOf(item.owner)})`)
285
- .join('\n\n'));
286
- }
287
- const routine = skillDirectory && selectedFiles.length ? `${skillDirectory}/scripts/verify-resources.mjs` : null;
288
- const part = skillDirectory && selectedFiles.length ? `${skillDirectory}/parts/resources.md` : null;
289
- if (part)
290
- blocks.push(`Selected multipart index: ${discoveryLink(path, part, 'parts/resources.md')}. Resources are stored once in the product's content-addressed store; relocate the complete product, not one skill folder.`);
291
- if (routine)
292
- blocks.push(`## Verify bundled resources\n\nRun the read-only bundled routine explicitly: \`node scripts/verify-resources.mjs --root <absolute physical product directory>\`. The explicit root must satisfy the existing unaliased-path policy; trusted callers canonicalize OS temporary roots before invocation. It checks the selected file hashes, refuses missing or changed bytes and returns JSON. It needs no checkout or network and grants no execution authority. Routine: ${discoveryLink(path, routine, 'verify-resources.mjs')}`);
293
- const renderBody = (extra) => `\n# ${entry.outputName}\n\n${entry.description}\n\n` +
294
- 'Native declarations below are guidance. Conditional clauses apply only under their stated conditions; this projection activates no IA operation or machine enforcement.\n' +
295
- invocation(entry, catalog, description.product) +
296
- '\n' +
297
- [...blocks, ...extra].join('\n\n') +
298
- '\n';
299
- const budget = description.contextBudget ?? {
300
- bytes: PROJECTION_LIMITS.contextBytes,
301
- tokens: PROJECTION_LIMITS.contextTokens,
302
- };
303
- const fits = (files) => files
304
- .filter((file) => ['agent', 'skill', 'command'].includes(file.role))
305
- .every((file) => Buffer.byteLength(file.content) <= budget.bytes &&
306
- DEFAULT_TOKENIZER.count(file.content) <= budget.tokens);
307
- const serializeBody = (extra) => {
308
- const body = renderBody(extra);
309
- inert(body);
310
- return serializeExport(description.product, entry, catalog, body);
311
- };
312
- let serialized = serializeBody([]);
313
- if (!fits(serialized))
314
- fail('IA-PROJECTION-FEATURE-UNAVAILABLE', 'Required projected context exceeds its byte/token budget; narrow the selected native body or resources', entry.target);
315
- const extra = [];
316
- for (const optional of optionalBlocks) {
317
- const candidate = serializeBody([...extra, optional.content]);
318
- if (fits(candidate)) {
319
- extra.push(optional.content);
320
- serialized = candidate;
321
- }
322
- else
323
- omissions.push({
324
- export: entry.id,
325
- feature: 'context',
326
- reason: `${optional.key}: budget (bundled reference retained)`,
327
- });
328
- }
329
- // Do all export-level validation before admitting its files to the product.
330
- for (const file of serialized) {
331
- if (Buffer.byteLength(file.content) > PROJECTION_LIMITS.fileBytes)
332
- inputFailure('Generated file exceeds its byte ceiling');
333
- portablePath(file.path);
334
- }
335
- for (const destination of destinations.values())
336
- portablePath(destination);
337
- for (const file of selectedFiles)
338
- add(destinations.get(keyOf(file.key)), Buffer.from(file.content, file.encoding), file.encoding, 'resource', owners, [file.key]);
339
- if (routine) {
340
- const inventory = selectedFiles.map((file) => ({
341
- path: destinations.get(keyOf(file.key)),
342
- bytes: file.bytes,
343
- sha256: file.sha256,
344
- }));
345
- add(routine, Buffer.from(resourceVerifier(inventory)), 'utf8', 'host-metadata', [entry.target], []);
346
- }
347
- if (part)
348
- add(part, Buffer.from('# Selected resource parts\n\n' +
349
- selectedFiles
350
- .map((file) => `Source: ${keyOf(file.key)}\n\n${discoveryLink(part, destinations.get(keyOf(file.key)), file.key.path)}`)
351
- .join('\n\n') +
352
- '\n'), 'utf8', 'host-metadata', [entry.target], []);
353
- for (const file of serialized)
354
- add(file.path, Buffer.from(file.content), 'utf8', file.role, owners, selectedFiles.map((f) => f.key));
355
- exported.push({ id: entry.id, target: entry.target, closure: owners });
356
- for (const omission of resolution.omissions)
357
- omissions.push({
358
- export: entry.id,
359
- feature: 'resources',
360
- reason: `${keyOf(omission.key)}: ${omission.reason}`,
361
- });
362
- }
363
- catch (error) {
364
- const result = diagnostic(error);
365
- if (entry.required || result.code === 'IA-PROJECTION-INPUT-INVALID')
366
- throw error;
367
- omissions.push({ export: entry.id, feature: entry.profile, reason: `${result.code}: ${result.message}` });
368
- }
369
- }
370
- if (description.product === 'plugin') {
371
- const file = pluginFile(catalog, options.name, options.version);
372
- add(file.path, Buffer.from(file.content), 'utf8', file.role, exported.map((e) => e.target), []);
373
- }
374
- if (description.product === 'workspace' && isCodex(catalog)) {
375
- const registered = description.exports.filter((entry) => entry.presentation.kind === 'agent' && exported.some((e) => e.id === entry.id));
376
- const file = codexAgentRegistration(registered);
377
- if (file)
378
- add(file.path, Buffer.from(file.content), 'utf8', file.role, registered.map((e) => e.target), []);
379
- }
380
- if (new Set(exported.flatMap((e) => e.closure.map(occurrenceOf))).size > PROJECTION_LIMITS.occurrences)
381
- inputFailure('Generated product exceeds its native occurrence ceiling');
382
- if (files.size > PROJECTION_LIMITS.files ||
383
- [...files.values()].reduce((sum, file) => sum + file.bytes, 0) > PROJECTION_LIMITS.totalBytes)
384
- inputFailure('Generated product exceeds its file/byte ceiling');
385
- const manifestBody = {
386
- format: 'ia.projection-manifest.v1',
387
- product: description.product,
388
- sourceRevisions: description.sourceRevisions,
389
- descriptorDigest: description.digest,
390
- resourcesDigest: resources.digest,
391
- inventoryDigest: description.inventoryDigest,
392
- profiles: description.profiles,
393
- exports: exported,
394
- outputs: ordered([...outputs.values()], (o) => o.path),
395
- omissions,
396
- enforcement: [
397
- {
398
- feature: 'prose-projection',
399
- level: 'guidance',
400
- evidence: `generated:${catalog.profile.id}; installed/live-host qualification not established`,
401
- },
402
- {
403
- feature: 'agent-presentation',
404
- level: 'guidance',
405
- evidence: !isCodex(catalog)
406
- ? 'host tool names within native capability effects; not IA authorization or an enforced allowlist'
407
- : description.product === 'plugin'
408
- ? 'explicit role skills; no native custom-agent registration or model/tool override'
409
- : 'native workspace TOML agents; tool intent is guidance, not an enforced allowlist',
410
- },
411
- ],
412
- };
413
- if (Buffer.byteLength(JSON.stringify(manifestBody)) > PROJECTION_LIMITS.metadataBytes)
414
- inputFailure('Projection manifest exceeds its metadata ceiling');
415
- return frozen({
416
- format: 'ia.projection-result.v1',
417
- status: 'compiled',
418
- manifest: { ...manifestBody, digest: metadataDigest(manifestBody) },
419
- files: ordered([...files.values()], (f) => f.path),
420
- diagnostics: [],
421
- });
422
- }
423
- catch (error) {
424
- return frozen({ format: 'ia.projection-result.v1', status: 'refused', diagnostics: [diagnostic(error)] });
425
- }
426
- }
427
- /** Recompile the exact captured inputs; never trust caller-authored generated files. */
428
- export function serializeProjection(capture, descriptor, resources, options) {
429
- return compileProjection(capture, descriptor, resources, options);
430
- }
1
+ /** @deprecated Import from @inventarch/workspace-runtime/projections. */
2
+ export * from '@inventarch/workspace-runtime/projections';
431
3
  //# sourceMappingURL=projections.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"projections.js","sourceRoot":"","sources":["../src/projections.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAIlC,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,MAAM,EACN,IAAI,EACJ,KAAK,EACL,cAAc,EACd,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,IAAI,EACJ,EAAE,EACF,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,0BAA0B,GAC3B,MAAM,wBAAwB,CAAC;AAUhC,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,aAAa,EACb,KAAK,EACL,UAAU,EACV,OAAO,EACP,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ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,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,EAAE,MAAM,EAAE,yBAAyB,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IAC5G,CAAC;AACH,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,mBAAmB,CACjC,OAAgB,EAChB,UAAmB,EACnB,SAAkB,EAClB,OAA0B;IAE1B,OAAO,iBAAiB,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AACpE,CAAC"}
1
+ {"version":3,"file":"projections.js","sourceRoot":"","sources":["../src/projections.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,cAAc,2CAA2C,CAAC"}
@@ -1,7 +1,3 @@
1
- import type { OperationAdapter, OperationDefinition } from '@inventarch/agent-system';
2
- /** Explicit host installation only. The inspection catalog never gains a write implicitly. */
3
- export declare function managedPublication(root: string, destination: string, implementationDigest: string, binding?: OperationDefinition): {
4
- definition: OperationDefinition;
5
- adapter: OperationAdapter;
6
- };
1
+ /** @deprecated Import from @inventarch/workspace-runtime/internal/publication. */
2
+ export * from '@inventarch/workspace-runtime/internal/publication';
7
3
  //# sourceMappingURL=publication.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"publication.d.ts","sourceRoot":"","sources":["../src/publication.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAoB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGxG,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,CAAC,EAAE,mBAAmB,GAC5B;IAAE,UAAU,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAgJhE"}
1
+ {"version":3,"file":"publication.d.ts","sourceRoot":"","sources":["../src/publication.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,cAAc,oDAAoD,CAAC"}
@@ -1,140 +1,3 @@
1
- import { createHash } from 'node:crypto';
2
- import { resolve } from 'node:path';
3
- import { inspectPublication, preparePublication } from '@inventarch/runtime';
4
- import { canonical, digest, SessionError } from '@inventarch/session-system';
5
- import { validateShape } from '@inventarch/agent-system';
6
- import { candidateInputSchema } from './candidate.js';
7
- /** Explicit host installation only. The inspection catalog never gains a write implicitly. */
8
- export function managedPublication(root, destination, implementationDigest, binding) {
9
- if (!/^[a-f0-9]{64}$/.test(implementationDigest))
10
- throw new SessionError('IA-CORPUS-DENIED', 'Installed publication implementation is unavailable');
11
- const base = resolve(root), string = { type: 'string' }, object = (properties) => ({
12
- type: 'object',
13
- properties,
14
- required: Object.keys(properties),
15
- additionalProperties: false,
16
- });
17
- const definition = {
18
- id: 'draft.publish',
19
- handler: 'ia.draft.publish.v1',
20
- digest: digest({ implementation: 'ia.draft.publish.v1', implementationDigest, root: base, destination }),
21
- effects: ['local-write'],
22
- recovery: 'reconcile',
23
- timeoutMs: 15000,
24
- input: object({ candidate: candidateInputSchema(), destination: string }),
25
- output: object({
26
- candidateDigest: string,
27
- artifactDigest: string,
28
- destination: string,
29
- published: string,
30
- manifestDigest: string,
31
- }),
32
- };
33
- if (binding) {
34
- if (!binding.id ||
35
- !/^[a-f0-9]{64}$/.test(binding.digest) ||
36
- binding.handler !== definition.handler ||
37
- digest(binding.input) !== digest(definition.input) ||
38
- digest(binding.output) !== digest(definition.output) ||
39
- digest(binding.effects) !== digest(definition.effects) ||
40
- binding.recovery !== definition.recovery ||
41
- binding.timeoutMs !== definition.timeoutMs ||
42
- (binding.maxOutputBytes ?? 65536) !== 65536 ||
43
- binding.purpose !== undefined)
44
- throw new SessionError('IA-CORPUS-DENIED', 'Compiled publication binding is incompatible with the installed adapter');
45
- definition.id = binding.id;
46
- definition.digest = binding.digest;
47
- }
48
- const content = (input, context) => {
49
- const value = input, review = context.review;
50
- if (!validateShape(definition.input, input) ||
51
- value.destination !== destination ||
52
- !context.owner ||
53
- context.owner.sessionId !== context.sessionId ||
54
- !context.assertCurrent ||
55
- context.manifest.operations[definition.id]?.digest !== definition.digest ||
56
- !review ||
57
- review.reviewer !== context.principal ||
58
- review.operation !== definition.id ||
59
- review.bindingDigest !== definition.digest ||
60
- review.inputDigest !== digest(input) ||
61
- review.candidateDigest !== digest(value.candidate) ||
62
- review.artifactDigest !== digest(value.candidate.files) ||
63
- review.destination !== destination ||
64
- review.effect !== 'local-write' ||
65
- !context.grant.destinations?.includes(destination) ||
66
- !context.grant.sources.includes(value.candidate.base.revision))
67
- throw new SessionError('IA-CORPUS-DENIED', 'Publication is outside the exact reviewed binding, source or destination');
68
- for (const file of value.candidate.files)
69
- if (createHash('sha256').update(file.text).digest('hex') !== file.digest)
70
- throw new SessionError('IA-CORPUS-DENIED', 'Reviewed candidate bytes changed');
71
- const manifest = {
72
- version: 1,
73
- kind: 'ia.managed-draft.v1',
74
- sessionId: context.sessionId,
75
- runId: context.runId,
76
- invocationId: context.invocationId,
77
- attemptId: context.attemptId,
78
- principal: context.principal,
79
- operation: definition.id,
80
- bindingDigest: definition.digest,
81
- inputDigest: review.inputDigest,
82
- candidateDigest: review.candidateDigest,
83
- artifactDigest: review.artifactDigest,
84
- destination,
85
- review,
86
- files: value.candidate.files.map((file) => ({
87
- path: file.path,
88
- digest: file.digest,
89
- bytes: Buffer.byteLength(file.text),
90
- })),
91
- };
92
- return {
93
- files: value.candidate.files,
94
- metadata: canonical(manifest) + '\n',
95
- output: {
96
- candidateDigest: review.candidateDigest,
97
- artifactDigest: review.artifactDigest,
98
- destination,
99
- published: destination,
100
- manifestDigest: digest(manifest),
101
- },
102
- };
103
- };
104
- const current = async (context) => {
105
- context.signal.throwIfAborted();
106
- if (!context.assertCurrent)
107
- throw new SessionError('IA-CORPUS-DENIED', 'Publication ownership check is unavailable');
108
- await context.assertCurrent();
109
- context.signal.throwIfAborted();
110
- };
111
- return {
112
- definition,
113
- adapter: {
114
- id: definition.handler,
115
- execute: async (input, context) => {
116
- await current(context);
117
- const value = content(input, context), prepared = preparePublication(base, destination, value.files, value.metadata);
118
- try {
119
- await current(context);
120
- content(input, context);
121
- prepared.publish();
122
- return { effect: 'applied', output: value.output };
123
- }
124
- finally {
125
- prepared.close();
126
- }
127
- },
128
- reconcile: async (input, context) => {
129
- await current(context);
130
- const value = content(input, context);
131
- const status = await inspectPublication(base, destination, value.files, value.metadata, async () => {
132
- await current(context);
133
- content(input, context);
134
- });
135
- return { status, output: status === 'applied' ? value.output : null };
136
- },
137
- },
138
- };
139
- }
1
+ /** @deprecated Import from @inventarch/workspace-runtime/internal/publication. */
2
+ export * from '@inventarch/workspace-runtime/internal/publication';
140
3
  //# sourceMappingURL=publication.js.map