@open-mercato/cli 0.10.1-develop.8279.1.7d4003fb64 → 0.10.1-develop.8289.1.9a25111d49

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 (148) hide show
  1. package/dist/agentic/guides/ai-workflows.md +1 -0
  2. package/dist/agentic/guides/module-facts.json +2670 -269
  3. package/dist/agentic/guides/module-facts.v2.json +2673 -269
  4. package/dist/agentic/guides/modules/agent_orchestrator/acl-features.md +2 -1
  5. package/dist/agentic/guides/modules/agent_orchestrator/active-extension-bindings.md +1 -1
  6. package/dist/agentic/guides/modules/agent_orchestrator/backend-pages.md +3 -0
  7. package/dist/agentic/guides/modules/agent_orchestrator/cli-commands.md +4 -0
  8. package/dist/agentic/guides/modules/agent_orchestrator/contribution-resolutions.md +6 -0
  9. package/dist/agentic/guides/modules/agent_orchestrator/di-registrations-rich.md +32 -32
  10. package/dist/agentic/guides/modules/agent_orchestrator/di-service-tokens.md +14 -14
  11. package/dist/agentic/guides/modules/agent_orchestrator/domain-commands.md +3 -0
  12. package/dist/agentic/guides/modules/agent_orchestrator/events.md +2 -1
  13. package/dist/agentic/guides/modules/agent_orchestrator/exact-override-targets.md +104 -35
  14. package/dist/agentic/guides/modules/agent_orchestrator/index.md +18 -7
  15. package/dist/agentic/guides/modules/agent_orchestrator/setup.md +1 -1
  16. package/dist/agentic/guides/modules/agent_orchestrator/umes-contributions.md +6 -0
  17. package/dist/agentic/guides/modules/agent_orchestrator/umes-hosts.md +2 -1
  18. package/dist/agentic/guides/modules/agent_orchestrator/workers.md +2 -0
  19. package/dist/agentic/guides/modules/ai_assistant/acl-features.md +4 -1
  20. package/dist/agentic/guides/modules/ai_assistant/ai-tools-mcp-capabilities.md +1 -0
  21. package/dist/agentic/guides/modules/ai_assistant/backend-pages.md +4 -0
  22. package/dist/agentic/guides/modules/ai_assistant/cli-commands.md +1 -0
  23. package/dist/agentic/guides/modules/ai_assistant/contribution-resolutions.md +3 -0
  24. package/dist/agentic/guides/modules/ai_assistant/di-registrations-rich.md +5 -4
  25. package/dist/agentic/guides/modules/ai_assistant/di-service-tokens.md +4 -3
  26. package/dist/agentic/guides/modules/ai_assistant/encryption.md +3 -0
  27. package/dist/agentic/guides/modules/ai_assistant/entities.md +3 -0
  28. package/dist/agentic/guides/modules/ai_assistant/events.md +2 -1
  29. package/dist/agentic/guides/modules/ai_assistant/exact-override-targets.md +23 -7
  30. package/dist/agentic/guides/modules/ai_assistant/index.md +9 -9
  31. package/dist/agentic/guides/modules/ai_assistant/notifications.md +1 -0
  32. package/dist/agentic/guides/modules/ai_assistant/setup.md +1 -1
  33. package/dist/agentic/guides/modules/ai_assistant/umes-contributions.md +3 -0
  34. package/dist/agentic/guides/modules/ai_assistant/umes-hosts.md +4 -0
  35. package/dist/agentic/guides/modules/ai_assistant/workers.md +2 -1
  36. package/dist/agentic/guides/modules/api_docs/index.md +1 -1
  37. package/dist/agentic/guides/modules/api_keys/index.md +1 -1
  38. package/dist/agentic/guides/modules/attachments/active-extension-bindings.md +1 -0
  39. package/dist/agentic/guides/modules/attachments/ai-tools-mcp-capabilities.md +11 -0
  40. package/dist/agentic/guides/modules/attachments/backend-pages.md +1 -0
  41. package/dist/agentic/guides/modules/attachments/cli-commands.md +1 -0
  42. package/dist/agentic/guides/modules/attachments/contribution-resolutions.md +13 -0
  43. package/dist/agentic/guides/modules/attachments/di-registrations-rich.md +6 -6
  44. package/dist/agentic/guides/modules/attachments/di-service-tokens.md +5 -5
  45. package/dist/agentic/guides/modules/attachments/domain-commands.md +11 -0
  46. package/dist/agentic/guides/modules/attachments/encryption.md +12 -0
  47. package/dist/agentic/guides/modules/attachments/entities.md +2 -0
  48. package/dist/agentic/guides/modules/attachments/exact-override-targets.md +14 -6
  49. package/dist/agentic/guides/modules/attachments/index.md +11 -5
  50. package/dist/agentic/guides/modules/attachments/search-entities.md +11 -0
  51. package/dist/agentic/guides/modules/attachments/umes-contributions.md +13 -0
  52. package/dist/agentic/guides/modules/attachments/umes-hosts.md +4 -0
  53. package/dist/agentic/guides/modules/attachments/workers.md +2 -0
  54. package/dist/agentic/guides/modules/audit_logs/active-extension-bindings.md +11 -0
  55. package/dist/agentic/guides/modules/audit_logs/incoming-installed-contributions.md +12 -0
  56. package/dist/agentic/guides/modules/audit_logs/index.md +4 -2
  57. package/dist/agentic/guides/modules/auth/index.md +1 -1
  58. package/dist/agentic/guides/modules/availability/index.md +1 -1
  59. package/dist/agentic/guides/modules/business_rules/index.md +1 -1
  60. package/dist/agentic/guides/modules/carrier_inpost/index.md +1 -1
  61. package/dist/agentic/guides/modules/cart/index.md +1 -1
  62. package/dist/agentic/guides/modules/catalog/index.md +1 -1
  63. package/dist/agentic/guides/modules/channel_apns/index.md +1 -1
  64. package/dist/agentic/guides/modules/channel_discord/index.md +1 -1
  65. package/dist/agentic/guides/modules/channel_expo/index.md +1 -1
  66. package/dist/agentic/guides/modules/channel_fcm/index.md +1 -1
  67. package/dist/agentic/guides/modules/channel_gmail/index.md +1 -1
  68. package/dist/agentic/guides/modules/channel_imap/index.md +1 -1
  69. package/dist/agentic/guides/modules/channel_resend/index.md +1 -1
  70. package/dist/agentic/guides/modules/channel_ses/index.md +1 -1
  71. package/dist/agentic/guides/modules/channel_smtp/index.md +1 -1
  72. package/dist/agentic/guides/modules/checkout/index.md +1 -1
  73. package/dist/agentic/guides/modules/communication_channels/index.md +1 -1
  74. package/dist/agentic/guides/modules/configs/index.md +1 -1
  75. package/dist/agentic/guides/modules/content/index.md +1 -1
  76. package/dist/agentic/guides/modules/currencies/index.md +1 -1
  77. package/dist/agentic/guides/modules/customer_accounts/index.md +1 -1
  78. package/dist/agentic/guides/modules/customer_groups/index.md +1 -1
  79. package/dist/agentic/guides/modules/customers/index.md +1 -1
  80. package/dist/agentic/guides/modules/dashboards/index.md +1 -1
  81. package/dist/agentic/guides/modules/data_sync/index.md +1 -1
  82. package/dist/agentic/guides/modules/design_system/index.md +1 -1
  83. package/dist/agentic/guides/modules/devices/index.md +1 -1
  84. package/dist/agentic/guides/modules/dictionaries/index.md +1 -1
  85. package/dist/agentic/guides/modules/directory/index.md +1 -1
  86. package/dist/agentic/guides/modules/documents/index.md +1 -1
  87. package/dist/agentic/guides/modules/ecommerce/index.md +1 -1
  88. package/dist/agentic/guides/modules/entities/index.md +1 -1
  89. package/dist/agentic/guides/modules/eudr/index.md +1 -1
  90. package/dist/agentic/guides/modules/events/index.md +1 -1
  91. package/dist/agentic/guides/modules/feature_toggles/index.md +1 -1
  92. package/dist/agentic/guides/modules/forms/index.md +1 -1
  93. package/dist/agentic/guides/modules/gateway_autopay/index.md +1 -1
  94. package/dist/agentic/guides/modules/gateway_stripe/index.md +1 -1
  95. package/dist/agentic/guides/modules/gateway_tpay/index.md +1 -1
  96. package/dist/agentic/guides/modules/generators/index.md +1 -1
  97. package/dist/agentic/guides/modules/inbox_ops/index.md +1 -1
  98. package/dist/agentic/guides/modules/integrations/index.md +1 -1
  99. package/dist/agentic/guides/modules/messages/index.md +1 -1
  100. package/dist/agentic/guides/modules/notifications/index.md +1 -1
  101. package/dist/agentic/guides/modules/onboarding/index.md +1 -1
  102. package/dist/agentic/guides/modules/payment_gateways/index.md +1 -1
  103. package/dist/agentic/guides/modules/perspectives/index.md +1 -1
  104. package/dist/agentic/guides/modules/phone_calls/index.md +1 -1
  105. package/dist/agentic/guides/modules/planner/index.md +1 -1
  106. package/dist/agentic/guides/modules/portal/index.md +1 -1
  107. package/dist/agentic/guides/modules/progress/index.md +1 -1
  108. package/dist/agentic/guides/modules/promotions/index.md +1 -1
  109. package/dist/agentic/guides/modules/push_notifications/index.md +1 -1
  110. package/dist/agentic/guides/modules/query_index/index.md +1 -1
  111. package/dist/agentic/guides/modules/record_locks/index.md +1 -1
  112. package/dist/agentic/guides/modules/resources/index.md +1 -1
  113. package/dist/agentic/guides/modules/sales/index.md +1 -1
  114. package/dist/agentic/guides/modules/scheduler/index.md +1 -1
  115. package/dist/agentic/guides/modules/search/index.md +1 -1
  116. package/dist/agentic/guides/modules/security/index.md +1 -1
  117. package/dist/agentic/guides/modules/seeds/index.md +1 -1
  118. package/dist/agentic/guides/modules/shipping_carriers/index.md +1 -1
  119. package/dist/agentic/guides/modules/sso/index.md +1 -1
  120. package/dist/agentic/guides/modules/staff/index.md +1 -1
  121. package/dist/agentic/guides/modules/storage_s3/index.md +1 -1
  122. package/dist/agentic/guides/modules/sync_akeneo/index.md +1 -1
  123. package/dist/agentic/guides/modules/sync_excel/index.md +1 -1
  124. package/dist/agentic/guides/modules/system_status_overlays/index.md +1 -1
  125. package/dist/agentic/guides/modules/telemetry/index.md +1 -1
  126. package/dist/agentic/guides/modules/tillio/index.md +1 -1
  127. package/dist/agentic/guides/modules/translations/index.md +1 -1
  128. package/dist/agentic/guides/modules/warranty_claims/index.md +1 -1
  129. package/dist/agentic/guides/modules/webhooks/index.md +1 -1
  130. package/dist/agentic/guides/modules/wms/index.md +1 -1
  131. package/dist/agentic/guides/modules/workflows/index.md +1 -1
  132. package/dist/agentic/guides/reference-module-facts.json +1 -1
  133. package/dist/agentic/guides/upstream/manifest.json +1 -1
  134. package/dist/agentic/shared/ai/harness/README.md +3 -3
  135. package/dist/agentic/shared/ai/harness/RELEASE.md +4 -4
  136. package/dist/agentic/shared/ai/harness/cases.json +95 -2
  137. package/dist/agentic/shared/ai/harness/cases.schema.json +4 -4
  138. package/dist/agentic/shared/ai/harness/validators.json +1 -1
  139. package/dist/agentic/shared/ai/skills/om-create-ai-agent/SKILL.md +6 -5
  140. package/dist/agentic/shared/ai/skills/om-create-ai-agent/references/surface-selector.md +27 -0
  141. package/dist/lib/generators/extensions/agent-files.js +119 -4
  142. package/dist/lib/generators/extensions/agent-files.js.map +2 -2
  143. package/dist/lib/generators/module-facts.js +6 -4
  144. package/dist/lib/generators/module-facts.js.map +2 -2
  145. package/package.json +7 -7
  146. package/src/lib/generators/__tests__/agent-files-extension.test.ts +178 -0
  147. package/src/lib/generators/extensions/agent-files.ts +154 -4
  148. package/src/lib/generators/module-facts.ts +8 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cli",
3
- "version": "0.10.1-develop.8279.1.7d4003fb64",
3
+ "version": "0.10.1-develop.8289.1.9a25111d49",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -60,10 +60,10 @@
60
60
  "@mikro-orm/decorators": "^7.1.14",
61
61
  "@mikro-orm/migrations": "^7.1.14",
62
62
  "@mikro-orm/postgresql": "^7.1.14",
63
- "@open-mercato/events": "0.10.1-develop.8279.1.7d4003fb64",
64
- "@open-mercato/queue": "0.10.1-develop.8279.1.7d4003fb64",
65
- "@open-mercato/shared": "0.10.1-develop.8279.1.7d4003fb64",
66
- "@open-mercato/telemetry": "0.10.1-develop.8279.1.7d4003fb64",
63
+ "@open-mercato/events": "0.10.1-develop.8289.1.9a25111d49",
64
+ "@open-mercato/queue": "0.10.1-develop.8289.1.9a25111d49",
65
+ "@open-mercato/shared": "0.10.1-develop.8289.1.9a25111d49",
66
+ "@open-mercato/telemetry": "0.10.1-develop.8289.1.9a25111d49",
67
67
  "cross-spawn": "^7.0.6",
68
68
  "minisearch": "7.2.0",
69
69
  "pg": "8.23.0",
@@ -75,10 +75,10 @@
75
75
  "typescript-js": "npm:typescript@6.0.3"
76
76
  },
77
77
  "peerDependencies": {
78
- "@open-mercato/shared": "0.10.1-develop.8279.1.7d4003fb64"
78
+ "@open-mercato/shared": "0.10.1-develop.8289.1.9a25111d49"
79
79
  },
80
80
  "devDependencies": {
81
- "@open-mercato/shared": "0.10.1-develop.8279.1.7d4003fb64",
81
+ "@open-mercato/shared": "0.10.1-develop.8289.1.9a25111d49",
82
82
  "@types/jest": "^30.0.0",
83
83
  "jest": "^30.4.2",
84
84
  "ts-jest": "^29.4.12"
@@ -221,6 +221,79 @@ describe('createAgentFilesExtension', () => {
221
221
  ).toThrow(/malformed SAMPLE\.json/)
222
222
  })
223
223
 
224
+ function writeAgentMd(appBase: string, extraFrontmatter: string[]): string {
225
+ const agentDir = path.join(appBase, 'agents', 'deals_health_check')
226
+ fs.writeFileSync(
227
+ path.join(agentDir, 'AGENT.md'),
228
+ [
229
+ '---',
230
+ 'id: deals.health_check',
231
+ 'label: Deal health check',
232
+ 'description: Assess a deal.',
233
+ ...extraFrontmatter,
234
+ '---',
235
+ 'You assess a deal.',
236
+ ].join('\n'),
237
+ 'utf8',
238
+ )
239
+ return agentDir
240
+ }
241
+
242
+ function readManifest(root: string): string {
243
+ return fs.readFileSync(
244
+ path.join(root, 'packages/enterprise/src/modules/agent_orchestrator/generated/file-agents.generated.ts'),
245
+ 'utf8',
246
+ )
247
+ }
248
+
249
+ it('emits inline-list requiredFeatures into the manifest (deduped)', () => {
250
+ const fixture = makeRepoFixture()
251
+ repoRoot = fixture.repoRoot
252
+ writeAgentMd(fixture.appBase, ['requiredFeatures: [deals.health.run, customers.deals.view, deals.health.run]'])
253
+
254
+ const extension = createAgentFilesExtension()
255
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase))
256
+ extension.generateOutput()
257
+
258
+ const manifest = readManifest(repoRoot)
259
+ expect(manifest).toContain('requiredFeatures: ["deals.health.run","customers.deals.view"],')
260
+ expect(manifest).toContain(' requiredFeatures?: string[]')
261
+ })
262
+
263
+ it('emits block-list requiredFeatures into the manifest', () => {
264
+ const fixture = makeRepoFixture()
265
+ repoRoot = fixture.repoRoot
266
+ writeAgentMd(fixture.appBase, ['requiredFeatures:', ' - deals.health.run', ' - customers.*'])
267
+
268
+ const extension = createAgentFilesExtension()
269
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase))
270
+ extension.generateOutput()
271
+
272
+ expect(readManifest(repoRoot)).toContain('requiredFeatures: ["deals.health.run","customers.*"],')
273
+ })
274
+
275
+ it('omits requiredFeatures from a descriptor that declares none', () => {
276
+ const fixture = makeRepoFixture()
277
+ repoRoot = fixture.repoRoot
278
+
279
+ const extension = createAgentFilesExtension()
280
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase))
281
+ extension.generateOutput()
282
+
283
+ expect(readManifest(repoRoot)).not.toContain('requiredFeatures: [')
284
+ })
285
+
286
+ it('fails generation on a malformed requiredFeatures entry', () => {
287
+ const fixture = makeRepoFixture()
288
+ repoRoot = fixture.repoRoot
289
+ writeAgentMd(fixture.appBase, ['requiredFeatures: [deals health run]'])
290
+
291
+ const extension = createAgentFilesExtension()
292
+ expect(() =>
293
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase)),
294
+ ).toThrow(/invalid requiredFeatures entry "deals health run"/)
295
+ })
296
+
224
297
  it('emits an agent FACTS.json into the manifest as facts', () => {
225
298
  const fixture = makeRepoFixture()
226
299
  repoRoot = fixture.repoRoot
@@ -266,6 +339,78 @@ describe('createAgentFilesExtension', () => {
266
339
  ).toThrow(/malformed FACTS\.json/)
267
340
  })
268
341
 
342
+ it('emits an agent GOVERNANCE.json into the manifest as governance', () => {
343
+ const fixture = makeRepoFixture()
344
+ repoRoot = fixture.repoRoot
345
+ const agentDir = path.join(fixture.appBase, 'agents', 'deals_health_check')
346
+ const governance = {
347
+ principal: { roleFeatures: ['customers.deals.view'], toolAcl: 'intersect' },
348
+ untrustedInputs: [{ label: 'Notes', path: 'deal.notes' }],
349
+ modelSettings: { temperature: 0 },
350
+ }
351
+ fs.writeFileSync(path.join(agentDir, 'GOVERNANCE.json'), JSON.stringify(governance), 'utf8')
352
+
353
+ const extension = createAgentFilesExtension()
354
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase))
355
+ extension.generateOutput()
356
+
357
+ const manifest = fs.readFileSync(
358
+ path.join(repoRoot, 'packages/enterprise/src/modules/agent_orchestrator/generated/file-agents.generated.ts'),
359
+ 'utf8',
360
+ )
361
+ expect(manifest).toContain(
362
+ 'governance: {"principal":{"roleFeatures":["customers.deals.view"],"toolAcl":"intersect"},"modelSettings":{"temperature":0},"untrustedInputs":[{"label":"Notes","path":"deal.notes"}]}',
363
+ )
364
+ expect(manifest).toContain('export type FileAgentGovernance')
365
+ expect(manifest).toContain('"path":"GOVERNANCE.json"')
366
+ })
367
+
368
+ it('omits governance when GOVERNANCE.json is an empty object', () => {
369
+ const fixture = makeRepoFixture()
370
+ repoRoot = fixture.repoRoot
371
+ const agentDir = path.join(fixture.appBase, 'agents', 'deals_health_check')
372
+ fs.writeFileSync(path.join(agentDir, 'GOVERNANCE.json'), '{}', 'utf8')
373
+
374
+ const extension = createAgentFilesExtension()
375
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase))
376
+ extension.generateOutput()
377
+
378
+ const manifest = fs.readFileSync(
379
+ path.join(repoRoot, 'packages/enterprise/src/modules/agent_orchestrator/generated/file-agents.generated.ts'),
380
+ 'utf8',
381
+ )
382
+ expect(manifest).not.toContain('governance: {')
383
+ })
384
+
385
+ it.each([
386
+ ['an unknown key', { allowedActions: [] }, /unknown key "allowedActions"/],
387
+ ['a non-array integrity', { integrity: { id: 'x' } }, /"integrity" must be an array/],
388
+ ['a non-object principal', { principal: ['customers.deals.view'] }, /"principal" must be an object/],
389
+ ['a top-level array', [], /expected a JSON object/],
390
+ ])('fails generation on a GOVERNANCE.json with %s', (_label, content, message) => {
391
+ const fixture = makeRepoFixture()
392
+ repoRoot = fixture.repoRoot
393
+ const agentDir = path.join(fixture.appBase, 'agents', 'deals_health_check')
394
+ fs.writeFileSync(path.join(agentDir, 'GOVERNANCE.json'), JSON.stringify(content), 'utf8')
395
+
396
+ const extension = createAgentFilesExtension()
397
+ expect(() =>
398
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase)),
399
+ ).toThrow(message)
400
+ })
401
+
402
+ it('fails generation on a GOVERNANCE.json that is not valid JSON', () => {
403
+ const fixture = makeRepoFixture()
404
+ repoRoot = fixture.repoRoot
405
+ const agentDir = path.join(fixture.appBase, 'agents', 'deals_health_check')
406
+ fs.writeFileSync(path.join(agentDir, 'GOVERNANCE.json'), '{ principal: ', 'utf8')
407
+
408
+ const extension = createAgentFilesExtension()
409
+ expect(() =>
410
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase)),
411
+ ).toThrow(/malformed GOVERNANCE\.json/)
412
+ })
413
+
269
414
  it('fails generation on a malformed agent dir (missing OUTCOME.md)', () => {
270
415
  const fixture = makeRepoFixture()
271
416
  repoRoot = fixture.repoRoot
@@ -397,6 +542,39 @@ describe('createAgentFilesExtension', () => {
397
542
  ).toThrow(/unsupported keyword "oneOf"/)
398
543
  })
399
544
 
545
+ it('warns, without failing, about an OUTCOME.md object that declares no properties (A-2)', () => {
546
+ const fixture = makeRepoFixture()
547
+ const agentDir = path.join(fixture.appBase, 'agents', 'deals_health_check')
548
+ fs.writeFileSync(
549
+ path.join(agentDir, 'OUTCOME.md'),
550
+ [
551
+ '---',
552
+ 'kind: research',
553
+ '---',
554
+ '```json',
555
+ JSON.stringify({
556
+ type: 'object',
557
+ properties: { summary: { type: 'string' }, meta: { type: 'object' }, rows: { type: 'array', items: { type: 'object' } } },
558
+ }),
559
+ '```',
560
+ ].join('\n'),
561
+ 'utf8',
562
+ )
563
+ const warn = jest.spyOn(console, 'warn').mockImplementation(() => {})
564
+ try {
565
+ const extension = createAgentFilesExtension()
566
+ expect(() =>
567
+ extension.scanModule(createScanContext('agent_examples', fixture.appBase, fixture.pkgBase)),
568
+ ).not.toThrow()
569
+ const messages = warn.mock.calls.map((call) => String(call[0]))
570
+ expect(messages.some((message) => message.includes('the object at $.meta declares no properties'))).toBe(true)
571
+ expect(messages.some((message) => message.includes('the object at $.rows[] declares no properties'))).toBe(true)
572
+ expect(messages.some((message) => message.includes('$.summary'))).toBe(false)
573
+ } finally {
574
+ warn.mockRestore()
575
+ }
576
+ })
577
+
400
578
  it('fails generation when an OUTCOME.md schema node has no supported type (M2)', () => {
401
579
  const fixture = makeRepoFixture()
402
580
  const agentDir = path.join(fixture.appBase, 'agents', 'deals_health_check')
@@ -80,6 +80,8 @@ type DiscoveredAgent = {
80
80
  tools: string[]
81
81
  skills: string[]
82
82
  subAgents: string[]
83
+ /** Invoker ACL features from AGENT.md `requiredFeatures` (deduped; empty when undeclared). */
84
+ requiredFeatures: string[]
83
85
  openCodeAgentName: string
84
86
  /** Resolved agent-local skill content (Phase 3). */
85
87
  skillsContent: DiscoveredSkill[]
@@ -98,6 +100,8 @@ type DiscoveredAgent = {
98
100
  sampleInput?: unknown
99
101
  /** Optional `FACTS.json` declarations driving the Caseload facts panel. */
100
102
  facts?: DiscoveredFact[]
103
+ /** Optional `GOVERNANCE.json` declarations, validated in full when the agent loads. */
104
+ governance?: DiscoveredGovernance
101
105
  /** Baked token-usage breakdown of the agent's construction files (Phase: token accounting). */
102
106
  tokenUsage: FileAgentTokenUsage
103
107
  /** Baked raw content of every construction file, for the read-only Files tab (#12 files). */
@@ -138,6 +142,13 @@ type FileAgentTokenUsage = {
138
142
  subAgents: SubAgentTokenUsage[]
139
143
  }
140
144
 
145
+ type DiscoveredGovernance = {
146
+ principal?: Record<string, unknown>
147
+ integrity?: unknown[]
148
+ untrustedInputs?: unknown[]
149
+ modelSettings?: Record<string, unknown>
150
+ }
151
+
141
152
  type DiscoveredFact = {
142
153
  label: string
143
154
  source: 'input' | 'payload' | 'output'
@@ -147,7 +158,8 @@ type DiscoveredFact = {
147
158
 
148
159
  const FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/
149
160
  const JSON_FENCE_RE = /```json\s*\n([\s\S]*?)\n```/
150
- const LIST_KEYS = ['tools', 'skills', 'subAgents'] as const
161
+ const LIST_KEYS = ['tools', 'skills', 'subAgents', 'requiredFeatures'] as const
162
+ const REQUIRED_FEATURE_RE = /^[A-Za-z0-9_][A-Za-z0-9_.*:-]*$/
151
163
 
152
164
  function stripQuotes(value: string): string {
153
165
  return value.trim().replace(/^['"]/, '').replace(/['"]$/, '').trim()
@@ -171,6 +183,7 @@ type AgentFrontmatter = {
171
183
  tools: string[]
172
184
  skills: string[]
173
185
  subAgents: string[]
186
+ requiredFeatures: string[]
174
187
  maxSteps?: number
175
188
  instructions: string
176
189
  }
@@ -179,7 +192,13 @@ function parseAgentMarkdown(raw: string): AgentFrontmatter | null {
179
192
  const match = FRONTMATTER_RE.exec(raw)
180
193
  if (!match) return null
181
194
  const [, frontmatterBlock, body] = match
182
- const meta: AgentFrontmatter = { tools: [], skills: [], subAgents: [], instructions: body.trim() }
195
+ const meta: AgentFrontmatter = {
196
+ tools: [],
197
+ skills: [],
198
+ subAgents: [],
199
+ requiredFeatures: [],
200
+ instructions: body.trim(),
201
+ }
183
202
  const lines = frontmatterBlock.split('\n')
184
203
  let index = 0
185
204
  while (index < lines.length) {
@@ -223,9 +242,20 @@ function parseAgentMarkdown(raw: string): AgentFrontmatter | null {
223
242
  index += 1
224
243
  }
225
244
  if (!meta.id || !meta.label || !meta.description) return null
245
+ meta.requiredFeatures = Array.from(new Set(meta.requiredFeatures))
226
246
  return meta
227
247
  }
228
248
 
249
+ function assertRequiredFeaturesValid(features: string[], dir: string): void {
250
+ const invalid = features.find((feature) => feature.length > 200 || !REQUIRED_FEATURE_RE.test(feature))
251
+ if (invalid !== undefined) {
252
+ throw new Error(`[internal] invalid requiredFeatures entry "${invalid}" in AGENT.md at ${dir}`)
253
+ }
254
+ if (features.length > 50) {
255
+ throw new Error(`[internal] too many requiredFeatures (max 50) in AGENT.md at ${dir}`)
256
+ }
257
+ }
258
+
229
259
  function parseOutcomeKind(frontmatterBlock: string): 'research' | 'proposal' | 'artifact' | null {
230
260
  for (const line of frontmatterBlock.split('\n')) {
231
261
  const match = /^kind:\s*(.*)$/.exec(line.trim())
@@ -308,6 +338,37 @@ function assertOutcomeSchemaSupported(node: unknown, where: string, path = '$'):
308
338
  }
309
339
  }
310
340
 
341
+ /**
342
+ * JSON paths of the objects in an OUTCOME schema that declare no properties.
343
+ * The runtime compiles such an object to an empty, stripping one, so whatever the
344
+ * model puts in it is dropped on every runtime — an author almost certainly meant
345
+ * to list its properties. Generation warns rather than fails: the schema is valid.
346
+ */
347
+ function findOpenOutcomeObjects(node: unknown, path = '$'): string[] {
348
+ if (typeof node !== 'object' || node === null || Array.isArray(node)) return []
349
+ const schema = node as Record<string, unknown>
350
+ if (schema.type === 'object') {
351
+ const properties =
352
+ typeof schema.properties === 'object' && schema.properties !== null && !Array.isArray(schema.properties)
353
+ ? (schema.properties as Record<string, unknown>)
354
+ : {}
355
+ const keys = Object.keys(properties)
356
+ if (keys.length === 0) return [path]
357
+ return keys.flatMap((key) => findOpenOutcomeObjects(properties[key], `${path}.${key}`))
358
+ }
359
+ if (schema.type === 'array') return findOpenOutcomeObjects(schema.items, `${path}[]`)
360
+ return []
361
+ }
362
+
363
+ function warnOpenOutcomeObjects(schema: Record<string, unknown> | undefined, where: string): void {
364
+ if (!schema) return
365
+ for (const openPath of findOpenOutcomeObjects(schema)) {
366
+ console.warn(
367
+ `[internal] OUTCOME.md at ${where}: the object at ${openPath} declares no properties, so it always validates to {} and any content the agent returns there is dropped. List its properties.`,
368
+ )
369
+ }
370
+ }
371
+
311
372
  function sanitizeAgentName(id: string): string {
312
373
  return id.replace(/[^a-z0-9_-]/gi, '_')
313
374
  }
@@ -387,6 +448,62 @@ function discoverFacts(dir: string): DiscoveredFact[] | undefined {
387
448
  })
388
449
  }
389
450
 
451
+ const GOVERNANCE_FILE = 'GOVERNANCE.json'
452
+ const GOVERNANCE_OBJECT_KEYS = ['principal', 'modelSettings'] as const
453
+ const GOVERNANCE_LIST_KEYS = ['integrity', 'untrustedInputs'] as const
454
+
455
+ function isPlainObject(value: unknown): value is Record<string, unknown> {
456
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
457
+ }
458
+
459
+ /**
460
+ * Read the optional `agents/<id>/GOVERNANCE.json`: the same `principal`,
461
+ * `integrity`, `untrustedInputs` and `modelSettings` declarations `defineAgent`
462
+ * accepts. Only the top-level shape is checked here — an unknown key, a key of
463
+ * the wrong type, or invalid JSON fails generation LOUDLY. The agent loader
464
+ * validates every declaration with the `defineAgent` parsers and refuses to
465
+ * register an agent whose declaration does not parse.
466
+ */
467
+ function discoverGovernance(dir: string): DiscoveredGovernance | undefined {
468
+ const governancePath = path.join(dir, GOVERNANCE_FILE)
469
+ if (!fs.existsSync(governancePath)) return undefined
470
+ let parsed: unknown
471
+ try {
472
+ parsed = JSON.parse(fs.readFileSync(governancePath, 'utf8'))
473
+ } catch (err) {
474
+ const detail = err instanceof Error ? err.message : String(err)
475
+ throw new Error(`[internal] malformed ${GOVERNANCE_FILE} at ${dir}: ${detail}`)
476
+ }
477
+ if (!isPlainObject(parsed)) {
478
+ throw new Error(`[internal] malformed ${GOVERNANCE_FILE} at ${dir}: expected a JSON object`)
479
+ }
480
+ const allowed = [...GOVERNANCE_OBJECT_KEYS, ...GOVERNANCE_LIST_KEYS] as readonly string[]
481
+ const unknownKey = Object.keys(parsed).find((key) => !allowed.includes(key))
482
+ if (unknownKey) {
483
+ throw new Error(
484
+ `[internal] malformed ${GOVERNANCE_FILE} at ${dir}: unknown key "${unknownKey}" (allowed: ${allowed.join(', ')})`,
485
+ )
486
+ }
487
+ const governance: DiscoveredGovernance = {}
488
+ for (const key of GOVERNANCE_OBJECT_KEYS) {
489
+ const value = parsed[key]
490
+ if (value === undefined) continue
491
+ if (!isPlainObject(value)) {
492
+ throw new Error(`[internal] malformed ${GOVERNANCE_FILE} at ${dir}: "${key}" must be an object`)
493
+ }
494
+ governance[key] = value
495
+ }
496
+ for (const key of GOVERNANCE_LIST_KEYS) {
497
+ const value = parsed[key]
498
+ if (value === undefined) continue
499
+ if (!Array.isArray(value)) {
500
+ throw new Error(`[internal] malformed ${GOVERNANCE_FILE} at ${dir}: "${key}" must be an array`)
501
+ }
502
+ governance[key] = value
503
+ }
504
+ return Object.keys(governance).length > 0 ? governance : undefined
505
+ }
506
+
390
507
  /**
391
508
  * Sanitize a skill id into an OpenCode native skill `name`, which must match
392
509
  * `^[a-z0-9]+(-[a-z0-9]+)*$`: lowercase, underscores/dots/spaces → hyphens,
@@ -615,11 +732,13 @@ function discoverSubAgents(agentDir: string): DiscoveredAgent[] {
615
732
  if (!agent) {
616
733
  throw new Error(`[internal] malformed AGENT.md at ${dir}: missing id/label/description`)
617
734
  }
735
+ assertRequiredFeaturesValid(agent.requiredFeatures, dir)
618
736
  const outcome = parseOutcomeMarkdown(fs.readFileSync(outcomePath, 'utf8'))
619
737
  if (!outcome) {
620
738
  throw new Error(`[internal] malformed OUTCOME.md at ${dir}: missing kind or JSON-Schema block`)
621
739
  }
622
740
  if (outcome.schema) assertOutcomeSchemaSupported(outcome.schema, dir)
741
+ warnOpenOutcomeObjects(outcome.schema, dir)
623
742
  if (outcome.kind !== 'research') {
624
743
  throw new Error(
625
744
  `[internal] sub-agent at ${dir} must be research (kind: research); only the primary proposes`,
@@ -664,6 +783,7 @@ function discoverSubAgents(agentDir: string): DiscoveredAgent[] {
664
783
  tools: effectiveTools,
665
784
  skills: agent.skills,
666
785
  subAgents: [],
786
+ requiredFeatures: agent.requiredFeatures,
667
787
  openCodeAgentName: sanitizeAgentName(agent.id!),
668
788
  skillsContent: effectiveSkillsContent,
669
789
  subAgentsContent: [],
@@ -673,6 +793,7 @@ function discoverSubAgents(agentDir: string): DiscoveredAgent[] {
673
793
  model: agent.model,
674
794
  sampleInput: discoverSampleInput(dir),
675
795
  facts: discoverFacts(dir),
796
+ governance: discoverGovernance(dir),
676
797
  tokenUsage: discoverAgentTokenUsage(dir),
677
798
  sourceFiles: collectAgentFiles(dir),
678
799
  })
@@ -777,7 +898,7 @@ function discoverAgentTokenUsage(agentDir: string, depth = 0): FileAgentTokenUsa
777
898
  // --- Raw source-file collection (feeds the read-only Files tab, #12 files) ---
778
899
 
779
900
  /** Files present at the agent root but NOT part of the constructed prompt. */
780
- const AGENT_AUX_FILES = ['SAMPLE.json', 'FACTS.json']
901
+ const AGENT_AUX_FILES = ['SAMPLE.json', 'FACTS.json', GOVERNANCE_FILE]
781
902
 
782
903
  /**
783
904
  * Walks every construction file of a file-defined agent and returns its raw
@@ -1056,6 +1177,9 @@ function renderDescriptor(agent: DiscoveredAgent, indent: string): string {
1056
1177
  .join('\n')
1057
1178
  optional.push(`${indent} subAgentDescriptors: [\n${nested}\n${indent} ],`)
1058
1179
  }
1180
+ if (agent.requiredFeatures.length > 0) {
1181
+ optional.push(`${indent} requiredFeatures: ${JSON.stringify(agent.requiredFeatures)},`)
1182
+ }
1059
1183
  if (agent.maxSteps != null) optional.push(`${indent} maxSteps: ${agent.maxSteps},`)
1060
1184
  if (agent.provider != null) optional.push(`${indent} provider: ${JSON.stringify(agent.provider)},`)
1061
1185
  if (agent.model != null) optional.push(`${indent} model: ${JSON.stringify(agent.model)},`)
@@ -1065,6 +1189,9 @@ function renderDescriptor(agent: DiscoveredAgent, indent: string): string {
1065
1189
  if (agent.facts !== undefined) {
1066
1190
  optional.push(`${indent} facts: ${JSON.stringify(agent.facts)},`)
1067
1191
  }
1192
+ if (agent.governance !== undefined) {
1193
+ optional.push(`${indent} governance: ${JSON.stringify(agent.governance)},`)
1194
+ }
1068
1195
  const skillsContent = agent.skillsContent.map((skill) => ({
1069
1196
  id: skill.id,
1070
1197
  instructions: skill.instructions,
@@ -1163,6 +1290,13 @@ export type FileAgentFact = {
1163
1290
  format?: 'text' | 'number' | 'boolean' | 'percent'
1164
1291
  }
1165
1292
 
1293
+ export type FileAgentGovernance = {
1294
+ principal?: Record<string, unknown>
1295
+ integrity?: unknown[]
1296
+ untrustedInputs?: unknown[]
1297
+ modelSettings?: Record<string, unknown>
1298
+ }
1299
+
1166
1300
  export type FileAgentDescriptor = {
1167
1301
  id: string
1168
1302
  moduleId: string
@@ -1185,7 +1319,7 @@ export type FileAgentDescriptor = {
1185
1319
  tokenUsage?: AgentTokenUsage
1186
1320
  /**
1187
1321
  * Baked raw content of every construction file (AGENT.md, OUTCOME.md, skills,
1188
- * tools, sub-agents, and auxiliary SAMPLE.json/FACTS.json), for the read-only
1322
+ * tools, sub-agents, and auxiliary SAMPLE.json/FACTS.json/GOVERNANCE.json), for the read-only
1189
1323
  * Files tab. Each carries its \`o200k_base\` token count; paths are relative to
1190
1324
  * the agent root (sub-agent files prefixed \`sub-agents/<id>/\`). Baked so the
1191
1325
  * runtime never reads agent dirs from disk.
@@ -1197,6 +1331,11 @@ export type FileAgentDescriptor = {
1197
1331
  * 1). Absent for agents without sub-agents and for sub-agents themselves.
1198
1332
  */
1199
1333
  subAgentDescriptors?: FileAgentDescriptor[]
1334
+ /**
1335
+ * ACL features the invoker must hold to run this agent, from AGENT.md
1336
+ * \`requiredFeatures\`. Absent when the agent declares none.
1337
+ */
1338
+ requiredFeatures?: string[]
1200
1339
  maxSteps?: number
1201
1340
  provider?: string
1202
1341
  model?: string
@@ -1211,6 +1350,13 @@ export type FileAgentDescriptor = {
1211
1350
  * input / proposal payload / run output.
1212
1351
  */
1213
1352
  facts?: FileAgentFact[]
1353
+ /**
1354
+ * Optional governance declarations read from \`agents/<id>/GOVERNANCE.json\`:
1355
+ * the same \`principal\`, \`integrity\`, \`untrustedInputs\` and
1356
+ * \`modelSettings\` keys \`defineAgent\` accepts, as plain JSON. The loader
1357
+ * validates them with the \`defineAgent\` parsers.
1358
+ */
1359
+ governance?: FileAgentGovernance
1214
1360
  }
1215
1361
 
1216
1362
  export const fileAgentDescriptors: FileAgentDescriptor[] = [${
@@ -1242,11 +1388,13 @@ export function createAgentFilesExtension(resolver?: AgentFilesResolver): Genera
1242
1388
  if (!agent) {
1243
1389
  throw new Error(`[internal] malformed AGENT.md at ${dir}: missing id/label/description`)
1244
1390
  }
1391
+ assertRequiredFeaturesValid(agent.requiredFeatures, dir)
1245
1392
  const outcome = parseOutcomeMarkdown(fs.readFileSync(outcomePath, 'utf8'))
1246
1393
  if (!outcome) {
1247
1394
  throw new Error(`[internal] malformed OUTCOME.md at ${dir}: missing kind or JSON-Schema block`)
1248
1395
  }
1249
1396
  if (outcome.schema) assertOutcomeSchemaSupported(outcome.schema, dir)
1397
+ warnOpenOutcomeObjects(outcome.schema, dir)
1250
1398
  // The id is the registry/dup key AND the OpenCode `agent` message field —
1251
1399
  // constrain it to a safe charset (module.entity-style: lowercase alnum + . _ -).
1252
1400
  if (!/^[a-z0-9][a-z0-9._-]*$/.test(agent.id!)) {
@@ -1302,6 +1450,7 @@ export function createAgentFilesExtension(resolver?: AgentFilesResolver): Genera
1302
1450
  tools: effectiveTools,
1303
1451
  skills: agent.skills,
1304
1452
  subAgents: agent.subAgents,
1453
+ requiredFeatures: agent.requiredFeatures,
1305
1454
  openCodeAgentName: sanitizeAgentName(agent.id!),
1306
1455
  skillsContent: effectiveSkillsContent,
1307
1456
  subAgentsContent,
@@ -1311,6 +1460,7 @@ export function createAgentFilesExtension(resolver?: AgentFilesResolver): Genera
1311
1460
  model: agent.model,
1312
1461
  sampleInput: discoverSampleInput(dir),
1313
1462
  facts: discoverFacts(dir),
1463
+ governance: discoverGovernance(dir),
1314
1464
  tokenUsage: discoverAgentTokenUsage(dir),
1315
1465
  sourceFiles: collectAgentFiles(dir),
1316
1466
  })
@@ -2420,6 +2420,10 @@ export interface ModuleFactsJsonEntry {
2420
2420
 
2421
2421
  const EMPTY_SECTION_MARKER = '_none_'
2422
2422
  const MAX_ANCHORED_SECTION_BYTES = 32 * 1024
2423
+ // Room for what renderModuleFactsDirectory wraps around a section (title, back link,
2424
+ // end marker): a section must be split while its table alone still fits the cap.
2425
+ const ANCHORED_SECTION_WRAPPER_RESERVE_BYTES = 512
2426
+ const MAX_COMPACT_SECTION_BYTES = MAX_ANCHORED_SECTION_BYTES - ANCHORED_SECTION_WRAPPER_RESERVE_BYTES
2423
2427
 
2424
2428
  interface ModuleFactsRenderContext {
2425
2429
  sourceRoot: string
@@ -2454,7 +2458,7 @@ function renderGroupedTableSection(
2454
2458
  }
2455
2459
  for (const row of group.rows) {
2456
2460
  const candidateRows = [...currentRows, row]
2457
- if (Buffer.byteLength(renderChunk(candidateRows, chunks.length)) <= MAX_ANCHORED_SECTION_BYTES) {
2461
+ if (Buffer.byteLength(renderChunk(candidateRows, chunks.length)) <= MAX_COMPACT_SECTION_BYTES) {
2458
2462
  currentRows = candidateRows
2459
2463
  continue
2460
2464
  }
@@ -2463,7 +2467,7 @@ function renderGroupedTableSection(
2463
2467
  }
2464
2468
  chunks.push(currentRows)
2465
2469
  currentRows = [row]
2466
- if (Buffer.byteLength(renderChunk(currentRows, chunks.length)) > MAX_ANCHORED_SECTION_BYTES) {
2470
+ if (Buffer.byteLength(renderChunk(currentRows, chunks.length)) > MAX_COMPACT_SECTION_BYTES) {
2467
2471
  throw new Error(`[module-facts] ${sectionHeading} group "${group.title}" contains a row larger than the anchored read cap`)
2468
2472
  }
2469
2473
  }
@@ -2696,7 +2700,7 @@ function renderExtensionHostsSection(
2696
2700
  `| ${host.id} | ${host.family} | ${host.capabilities.join(', ') || '—'} | ${renderExtensionHostContext(host)} | ${host.stability.toUpperCase()} | ${renderExtensionHostSource(host, context)} |`,
2697
2701
  )
2698
2702
  const compact = [...header, ...renderRows(boundHosts)].join('\n')
2699
- if (Buffer.byteLength(compact) <= MAX_ANCHORED_SECTION_BYTES) return compact
2703
+ if (Buffer.byteLength(compact) <= MAX_COMPACT_SECTION_BYTES) return compact
2700
2704
  const families = [...new Set(boundHosts.map((host) => host.family))]
2701
2705
  return renderGroupedTableSection(
2702
2706
  '## UMES hosts',
@@ -2849,7 +2853,7 @@ function renderOverrideTargetsSection(
2849
2853
  return `| ${target.domain} | ${path} | ${modes} | ${fact} | ${renderSourceRefLink(target.source, context)} |`
2850
2854
  })
2851
2855
  const compact = ['## Exact override targets', '', header, divider, ...renderRows(targets)].join('\n')
2852
- if (Buffer.byteLength(compact) <= MAX_ANCHORED_SECTION_BYTES) return compact
2856
+ if (Buffer.byteLength(compact) <= MAX_COMPACT_SECTION_BYTES) return compact
2853
2857
  const domains = [...new Set(targets.map((target) => target.domain))]
2854
2858
  return renderGroupedTableSection(
2855
2859
  '## Exact override targets',