@attested-intelligence/aga-mcp-server 0.1.0 → 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 (194) hide show
  1. package/PATENTS.md +28 -0
  2. package/README.md +84 -23
  3. package/dist/context.d.ts +39 -0
  4. package/dist/context.d.ts.map +1 -0
  5. package/dist/context.js +113 -0
  6. package/dist/context.js.map +1 -0
  7. package/dist/core/identity.d.ts +14 -0
  8. package/dist/core/identity.d.ts.map +1 -0
  9. package/dist/core/identity.js +16 -0
  10. package/dist/core/identity.js.map +1 -0
  11. package/dist/core/index.d.ts +3 -0
  12. package/dist/core/index.d.ts.map +1 -1
  13. package/dist/core/index.js +3 -0
  14. package/dist/core/index.js.map +1 -1
  15. package/dist/core/measurement.d.ts +16 -0
  16. package/dist/core/measurement.d.ts.map +1 -0
  17. package/dist/core/measurement.js +18 -0
  18. package/dist/core/measurement.js.map +1 -0
  19. package/dist/core/portal.d.ts +1 -1
  20. package/dist/core/portal.d.ts.map +1 -1
  21. package/dist/core/portal.js +10 -5
  22. package/dist/core/portal.js.map +1 -1
  23. package/dist/core/types.d.ts +2 -2
  24. package/dist/core/types.d.ts.map +1 -1
  25. package/dist/crypto/canonicalize.d.ts +7 -0
  26. package/dist/crypto/canonicalize.d.ts.map +1 -0
  27. package/dist/crypto/canonicalize.js +21 -0
  28. package/dist/crypto/canonicalize.js.map +1 -0
  29. package/dist/crypto/index.d.ts +6 -5
  30. package/dist/crypto/index.d.ts.map +1 -1
  31. package/dist/crypto/index.js +6 -5
  32. package/dist/crypto/index.js.map +1 -1
  33. package/dist/crypto/keys.d.ts +10 -0
  34. package/dist/crypto/keys.d.ts.map +1 -0
  35. package/dist/crypto/keys.js +19 -0
  36. package/dist/crypto/keys.js.map +1 -0
  37. package/dist/index.js +1 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/middleware/governance.d.ts +1 -7
  40. package/dist/middleware/governance.d.ts.map +1 -1
  41. package/dist/middleware/governance.js +11 -18
  42. package/dist/middleware/governance.js.map +1 -1
  43. package/dist/prompts/drift-analysis.d.ts +13 -0
  44. package/dist/prompts/drift-analysis.d.ts.map +1 -0
  45. package/dist/prompts/drift-analysis.js +43 -0
  46. package/dist/prompts/drift-analysis.js.map +1 -0
  47. package/dist/prompts/governance-report.d.ts +7 -0
  48. package/dist/prompts/governance-report.d.ts.map +1 -0
  49. package/dist/prompts/governance-report.js +26 -0
  50. package/dist/prompts/governance-report.js.map +1 -0
  51. package/dist/prompts/nccoe-demo.d.ts +14 -0
  52. package/dist/prompts/nccoe-demo.d.ts.map +1 -0
  53. package/dist/prompts/nccoe-demo.js +48 -0
  54. package/dist/prompts/nccoe-demo.js.map +1 -0
  55. package/dist/resources/crypto-primitives.d.ts +3 -0
  56. package/dist/resources/crypto-primitives.d.ts.map +1 -0
  57. package/dist/resources/crypto-primitives.js +52 -0
  58. package/dist/resources/crypto-primitives.js.map +1 -0
  59. package/dist/resources/patent-claims.d.ts +3 -0
  60. package/dist/resources/patent-claims.d.ts.map +1 -0
  61. package/dist/resources/patent-claims.js +67 -0
  62. package/dist/resources/patent-claims.js.map +1 -0
  63. package/dist/resources/sample-bundle.d.ts +6 -0
  64. package/dist/resources/sample-bundle.d.ts.map +1 -0
  65. package/dist/resources/sample-bundle.js +58 -0
  66. package/dist/resources/sample-bundle.js.map +1 -0
  67. package/dist/resources/specification.d.ts +3 -0
  68. package/dist/resources/specification.d.ts.map +1 -0
  69. package/dist/resources/specification.js +107 -0
  70. package/dist/resources/specification.js.map +1 -0
  71. package/dist/server.d.ts +4 -7
  72. package/dist/server.d.ts.map +1 -1
  73. package/dist/server.js +217 -343
  74. package/dist/server.js.map +1 -1
  75. package/dist/storage/sqlite.js +1 -1
  76. package/dist/tools/create-artifact.d.ts +25 -0
  77. package/dist/tools/create-artifact.d.ts.map +1 -0
  78. package/dist/tools/create-artifact.js +85 -0
  79. package/dist/tools/create-artifact.js.map +1 -0
  80. package/dist/tools/delegate-subagent.d.ts +18 -0
  81. package/dist/tools/delegate-subagent.d.ts.map +1 -0
  82. package/dist/tools/delegate-subagent.js +50 -0
  83. package/dist/tools/delegate-subagent.js.map +1 -0
  84. package/dist/tools/disclose-claim.d.ts +14 -0
  85. package/dist/tools/disclose-claim.d.ts.map +1 -0
  86. package/dist/tools/disclose-claim.js +23 -0
  87. package/dist/tools/disclose-claim.js.map +1 -0
  88. package/dist/tools/export-bundle.d.ts +8 -0
  89. package/dist/tools/export-bundle.d.ts.map +1 -0
  90. package/dist/tools/export-bundle.js +25 -0
  91. package/dist/tools/export-bundle.js.map +1 -0
  92. package/dist/tools/full-lifecycle.d.ts +16 -0
  93. package/dist/tools/full-lifecycle.d.ts.map +1 -0
  94. package/dist/tools/full-lifecycle.js +121 -0
  95. package/dist/tools/full-lifecycle.js.map +1 -0
  96. package/dist/tools/generate-receipt.d.ts +16 -0
  97. package/dist/tools/generate-receipt.d.ts.map +1 -0
  98. package/dist/tools/generate-receipt.js +31 -0
  99. package/dist/tools/generate-receipt.js.map +1 -0
  100. package/dist/tools/get-chain.d.ts +14 -0
  101. package/dist/tools/get-chain.d.ts.map +1 -0
  102. package/dist/tools/get-chain.js +45 -0
  103. package/dist/tools/get-chain.js.map +1 -0
  104. package/dist/tools/get-portal-state.d.ts +8 -0
  105. package/dist/tools/get-portal-state.d.ts.map +1 -0
  106. package/dist/tools/get-portal-state.js +15 -0
  107. package/dist/tools/get-portal-state.js.map +1 -0
  108. package/dist/tools/init-chain.d.ts +10 -0
  109. package/dist/tools/init-chain.d.ts.map +1 -0
  110. package/dist/tools/init-chain.js +13 -0
  111. package/dist/tools/init-chain.js.map +1 -0
  112. package/dist/tools/measure-behavior.d.ts +12 -0
  113. package/dist/tools/measure-behavior.d.ts.map +1 -0
  114. package/dist/tools/measure-behavior.js +29 -0
  115. package/dist/tools/measure-behavior.js.map +1 -0
  116. package/dist/tools/measure-subject.d.ts +15 -0
  117. package/dist/tools/measure-subject.d.ts.map +1 -0
  118. package/dist/tools/measure-subject.js +106 -0
  119. package/dist/tools/measure-subject.js.map +1 -0
  120. package/dist/tools/quarantine-status.d.ts +8 -0
  121. package/dist/tools/quarantine-status.d.ts.map +1 -0
  122. package/dist/tools/quarantine-status.js +16 -0
  123. package/dist/tools/quarantine-status.js.map +1 -0
  124. package/dist/tools/revoke-artifact.d.ts +13 -0
  125. package/dist/tools/revoke-artifact.d.ts.map +1 -0
  126. package/dist/tools/revoke-artifact.js +24 -0
  127. package/dist/tools/revoke-artifact.js.map +1 -0
  128. package/dist/tools/rotate-keys.d.ts +13 -0
  129. package/dist/tools/rotate-keys.d.ts.map +1 -0
  130. package/dist/tools/rotate-keys.js +39 -0
  131. package/dist/tools/rotate-keys.js.map +1 -0
  132. package/dist/tools/server-info.d.ts +8 -0
  133. package/dist/tools/server-info.d.ts.map +1 -0
  134. package/dist/tools/server-info.js +24 -0
  135. package/dist/tools/server-info.js.map +1 -0
  136. package/dist/tools/set-verification-tier.d.ts +11 -0
  137. package/dist/tools/set-verification-tier.d.ts.map +1 -0
  138. package/dist/tools/set-verification-tier.js +31 -0
  139. package/dist/tools/set-verification-tier.js.map +1 -0
  140. package/dist/tools/start-monitoring.d.ts +12 -0
  141. package/dist/tools/start-monitoring.d.ts.map +1 -0
  142. package/dist/tools/start-monitoring.js +17 -0
  143. package/dist/tools/start-monitoring.js.map +1 -0
  144. package/dist/tools/trigger-measurement.d.ts +15 -0
  145. package/dist/tools/trigger-measurement.d.ts.map +1 -0
  146. package/dist/tools/trigger-measurement.js +86 -0
  147. package/dist/tools/trigger-measurement.js.map +1 -0
  148. package/dist/tools/verify-artifact.d.ts +13 -0
  149. package/dist/tools/verify-artifact.d.ts.map +1 -0
  150. package/dist/tools/verify-artifact.js +6 -0
  151. package/dist/tools/verify-artifact.js.map +1 -0
  152. package/dist/tools/verify-bundle.d.ts +13 -0
  153. package/dist/tools/verify-bundle.d.ts.map +1 -0
  154. package/dist/tools/verify-bundle.js +6 -0
  155. package/dist/tools/verify-bundle.js.map +1 -0
  156. package/dist/types.d.ts +262 -0
  157. package/dist/types.d.ts.map +1 -0
  158. package/dist/types.js +9 -0
  159. package/dist/types.js.map +1 -0
  160. package/package.json +33 -6
  161. package/AGA_MCP_SERVER_SPEC.md +0 -632
  162. package/src/core/artifact.ts +0 -45
  163. package/src/core/attestation.ts +0 -33
  164. package/src/core/behavioral.ts +0 -132
  165. package/src/core/bundle.ts +0 -31
  166. package/src/core/chain.ts +0 -72
  167. package/src/core/checkpoint.ts +0 -22
  168. package/src/core/delegation.ts +0 -146
  169. package/src/core/disclosure.ts +0 -32
  170. package/src/core/index.ts +0 -11
  171. package/src/core/portal.ts +0 -96
  172. package/src/core/quarantine.ts +0 -16
  173. package/src/core/receipt.ts +0 -33
  174. package/src/core/subject.ts +0 -11
  175. package/src/core/types.ts +0 -244
  176. package/src/crypto/hash.ts +0 -33
  177. package/src/crypto/index.ts +0 -5
  178. package/src/crypto/merkle.ts +0 -43
  179. package/src/crypto/salt.ts +0 -18
  180. package/src/crypto/sign.ts +0 -35
  181. package/src/crypto/types.ts +0 -19
  182. package/src/index.ts +0 -12
  183. package/src/middleware/governance.ts +0 -95
  184. package/src/middleware/index.ts +0 -1
  185. package/src/server.ts +0 -436
  186. package/src/storage/index.ts +0 -3
  187. package/src/storage/interface.ts +0 -21
  188. package/src/storage/memory.ts +0 -27
  189. package/src/storage/sqlite.ts +0 -45
  190. package/src/tools/README.md +0 -13
  191. package/src/utils/canonical.ts +0 -14
  192. package/src/utils/constants.ts +0 -3
  193. package/src/utils/timestamp.ts +0 -12
  194. package/src/utils/uuid.ts +0 -2
package/dist/server.js CHANGED
@@ -1,137 +1,79 @@
1
1
  /**
2
- * AGA MCP Server. The Portal (ref 150) as an MCP service.
2
+ * AGA MCP Server V2.0.0 - The Portal (ref 150) as an MCP service.
3
3
  *
4
- * V3 NIST-aligned behaviors:
5
- * 1. Every measurement generates a receipt (match OR mismatch)
6
- * 2. TTL checked on every measurement (fail-closed)
7
- * 3. Mid-session revocation via revoke_artifact tool
8
- * 4. Governance middleware: portal state checked before tool execution
9
- * 5. Auto-chaining: every operation writes to continuity chain
4
+ * 20 tools, 4 resources, 3 prompts.
5
+ * USPTO Application No. 19/433,835
6
+ * NIST-2025-0035, NCCoE AI Agent Identity and Authorization
10
7
  */
11
8
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
12
9
  import { z } from 'zod';
13
- import { generateKeyPair, pkToHex } from './crypto/sign.js';
14
- import { sha256Str } from './crypto/hash.js';
15
- import { computeSubjectIdFromString } from './core/subject.js';
16
- import { performAttestation } from './core/attestation.js';
17
- import { generateArtifact, hashArtifact } from './core/artifact.js';
18
- import { Portal } from './core/portal.js';
19
- import { generateReceipt } from './core/receipt.js';
20
- import { createGenesisEvent, appendEvent, verifyChainIntegrity } from './core/chain.js';
21
- import { createCheckpoint, eventInclusionProof } from './core/checkpoint.js';
22
- import { generateBundle, verifyBundleOffline } from './core/bundle.js';
23
- import { processDisclosure } from './core/disclosure.js';
24
- import { initQuarantine } from './core/quarantine.js';
25
- import { MemoryStorage } from './storage/index.js';
26
- import { utcNow } from './utils/timestamp.js';
27
- import { deriveArtifact } from './core/delegation.js';
10
+ import { createContext } from './context.js';
28
11
  import { createGovernanceWrapper } from './middleware/governance.js';
29
- import { BehavioralMonitor } from './core/behavioral.js';
30
- // ── Default Policies ────────────────────────────────────────────
31
- const DEFAULT_ENFORCEMENT = {
32
- measurement_cadence_ms: 1000, ttl_seconds: 3600,
33
- enforcement_triggers: ['QUARANTINE', 'TERMINATE'],
34
- re_attestation_required: true,
35
- measurement_types: ['FILE_SYSTEM_STATE', 'CONFIG_MANIFEST'],
36
- };
37
- const DEFAULT_CLAIMS = {
38
- claims_taxonomy: [
39
- { claim_id: 'identity.name', sensitivity: 'S3_HIGH', substitutes: ['identity.pseudonym', 'identity.org'], inference_risks: [], permitted_modes: ['PROOF_ONLY'] },
40
- { claim_id: 'identity.pseudonym', sensitivity: 'S2_MODERATE', substitutes: ['identity.org'], inference_risks: [], permitted_modes: ['PROOF_ONLY', 'REVEAL_MIN'] },
41
- { claim_id: 'identity.org', sensitivity: 'S1_LOW', substitutes: [], inference_risks: [], permitted_modes: ['PROOF_ONLY', 'REVEAL_MIN', 'REVEAL_FULL'] },
42
- { claim_id: 'identity.age', sensitivity: 'S3_HIGH', substitutes: ['identity.age_range', 'identity.is_adult'], inference_risks: [], permitted_modes: ['PROOF_ONLY'] },
43
- { claim_id: 'identity.age_range', sensitivity: 'S2_MODERATE', substitutes: ['identity.is_adult'], inference_risks: [], permitted_modes: ['PROOF_ONLY', 'REVEAL_MIN', 'REVEAL_FULL'] },
44
- { claim_id: 'identity.is_adult', sensitivity: 'S1_LOW', substitutes: [], inference_risks: [], permitted_modes: ['PROOF_ONLY', 'REVEAL_FULL'] },
45
- ],
46
- substitution_rules: [],
47
- };
48
- const CLAIM_VALUES = {
49
- 'identity.name': 'Alice Johnson', 'identity.pseudonym': 'AJ-7742', 'identity.org': 'NeuroCrypt',
50
- 'identity.age': 32, 'identity.age_range': '25-34', 'identity.is_adult': true,
51
- };
12
+ // ── Tool handlers ────────────────────────────────────────────────
13
+ import { handleServerInfo } from './tools/server-info.js';
14
+ import { handleInitChain } from './tools/init-chain.js';
15
+ import { handleCreateArtifact } from './tools/create-artifact.js';
16
+ import { handleMeasureSubject } from './tools/measure-subject.js';
17
+ import { handleVerifyArtifact } from './tools/verify-artifact.js';
18
+ import { handleStartMonitoring } from './tools/start-monitoring.js';
19
+ import { handleGetPortalState } from './tools/get-portal-state.js';
20
+ import { handleTriggerMeasurement } from './tools/trigger-measurement.js';
21
+ import { handleGenerateReceipt } from './tools/generate-receipt.js';
22
+ import { handleExportBundle } from './tools/export-bundle.js';
23
+ import { handleVerifyBundle } from './tools/verify-bundle.js';
24
+ import { handleDiscloseClaim } from './tools/disclose-claim.js';
25
+ import { handleGetChain } from './tools/get-chain.js';
26
+ import { handleQuarantineStatus } from './tools/quarantine-status.js';
27
+ import { handleRevokeArtifact } from './tools/revoke-artifact.js';
28
+ import { handleSetVerificationTier } from './tools/set-verification-tier.js';
29
+ import { handleFullLifecycle } from './tools/full-lifecycle.js';
30
+ import { handleMeasureBehavior } from './tools/measure-behavior.js';
31
+ import { handleDelegateSubagent } from './tools/delegate-subagent.js';
32
+ import { handleRotateKeys } from './tools/rotate-keys.js';
33
+ // ── Resources ────────────────────────────────────────────────────
34
+ import { PROTOCOL_SPECIFICATION, SPECIFICATION_URI } from './resources/specification.js';
35
+ import { generateSampleBundle, SAMPLE_BUNDLE_URI } from './resources/sample-bundle.js';
36
+ import { CRYPTO_PRIMITIVES_DOC, CRYPTO_PRIMITIVES_URI } from './resources/crypto-primitives.js';
37
+ import { PATENT_CLAIMS_DOC, PATENT_CLAIMS_URI } from './resources/patent-claims.js';
38
+ // ── Prompts ──────────────────────────────────────────────────────
39
+ import { NCCOE_DEMO_PROMPT } from './prompts/nccoe-demo.js';
40
+ import { GOVERNANCE_REPORT_PROMPT } from './prompts/governance-report.js';
41
+ import { DRIFT_ANALYSIS_PROMPT } from './prompts/drift-analysis.js';
52
42
  // ── Server Factory ──────────────────────────────────────────────
53
43
  export async function createAGAServer() {
54
- const server = new McpServer({ name: 'aga-mcp-server', version: '0.1.0' });
55
- const storage = new MemoryStorage();
56
- await storage.initialize();
57
- const issuerKP = generateKeyPair();
58
- const portalKP = generateKeyPair();
59
- const chainKP = generateKeyPair();
60
- const portal = new Portal();
61
- let quarantine = null;
62
- let chainInitialized = false;
63
- // ── Auto-chain helper (auto-inits if needed) ──────────────────
64
- async function autoChain(type, payload) {
65
- if (!chainInitialized) {
66
- const genesis = createGenesisEvent(chainKP, sha256Str('AGA Protocol Specification v1.0.0'));
67
- await storage.storeEvent(genesis);
68
- chainInitialized = true;
69
- portal.sequenceCounter = 0;
70
- portal.lastLeafHash = genesis.leaf_hash;
71
- }
72
- const prev = await storage.getLatestEvent();
73
- if (!prev)
74
- throw new Error('Chain initialization failed');
75
- const event = appendEvent(type, payload, prev, chainKP);
76
- await storage.storeEvent(event);
77
- portal.sequenceCounter = event.sequence_number;
78
- portal.lastLeafHash = event.leaf_hash;
79
- return event;
80
- }
81
- const j = (x) => ({ content: [{ type: 'text', text: JSON.stringify(x, null, 2) }] });
82
- // ── Governance middleware (NCCoE Section 4: Portal as PEP) ────
83
- const quarantineRef = { get current() { return quarantine; } };
84
- const behavioralMonitor = new BehavioralMonitor();
44
+ const server = new McpServer({ name: 'aga-mcp-server', version: '2.0.0' });
45
+ const ctx = await createContext();
46
+ const quarantineRef = { get current() { return ctx.quarantine; } };
85
47
  function governedTool(name, description, schema, handler) {
86
- const wrap = createGovernanceWrapper(portal, quarantineRef, name, behavioralMonitor);
48
+ const wrap = createGovernanceWrapper(ctx.portal, quarantineRef, name, ctx.behavioralMonitor);
87
49
  server.tool(name, description, schema, wrap(handler));
88
50
  }
89
51
  // ══════════════════════════════════════════════════════════════
90
- // TOOL: get_server_info
91
- // ══════════════════════════════════════════════════════════════
92
- server.tool('get_server_info', 'Get AGA server info, public keys, and portal state.', {}, async () => j({
93
- server: 'AGA MCP Server', version: '0.1.0',
94
- protocol: 'Attested Governance Artifacts v1.0.0',
95
- patent: 'USPTO Application No. 19/433,835',
96
- nist_references: ['NIST-2025-0035', 'NCCoE AI Agent Identity'],
97
- issuer_public_key: pkToHex(issuerKP.publicKey),
98
- portal_public_key: pkToHex(portalKP.publicKey),
99
- chain_public_key: pkToHex(chainKP.publicKey),
100
- chain_initialized: chainInitialized,
101
- portal_state: portal.state,
102
- }));
103
- // ══════════════════════════════════════════════════════════════
104
- // TOOL: get_portal_state — V3 RESTORED (was dropped in V2)
105
- // ══════════════════════════════════════════════════════════════
106
- server.tool('get_portal_state', 'Get current portal state, loaded artifact info, and enforcement status.', {}, async () => j({
107
- state: portal.state,
108
- artifact_loaded: !!portal.artifact,
109
- sealed_hash: portal.artifact?.sealed_hash ?? null,
110
- ttl_seconds: portal.artifact?.enforcement_parameters.ttl_seconds ?? null,
111
- issued_at: portal.artifact?.issued_timestamp ?? null,
112
- enforcement_triggers: portal.artifact?.enforcement_parameters.enforcement_triggers ?? [],
113
- sequence_counter: portal.sequenceCounter,
114
- quarantine_active: quarantine?.active ?? false,
115
- }));
116
- // ══════════════════════════════════════════════════════════════
117
- // TOOL: init_chain (Claim 3a)
118
- // ══════════════════════════════════════════════════════════════
119
- server.tool('init_chain', 'Initialize continuity chain with genesis event. (Claim 3a)', { specification_hash: z.string().optional() }, async ({ specification_hash }) => {
120
- if (chainInitialized)
121
- return j({ success: false, error: 'Chain already initialized' });
122
- const genesis = createGenesisEvent(chainKP, specification_hash ?? sha256Str('AGA Protocol Specification v1.0.0'));
123
- await storage.storeEvent(genesis);
124
- chainInitialized = true;
125
- portal.sequenceCounter = 0;
126
- portal.lastLeafHash = genesis.leaf_hash;
127
- return j({ success: true, genesis_event_id: genesis.event_id, genesis_leaf_hash: genesis.leaf_hash });
128
- });
129
- // ══════════════════════════════════════════════════════════════
130
- // TOOL: attest_subject (Claims 1a-1d)
131
- // ══════════════════════════════════════════════════════════════
132
- server.tool('attest_subject', 'Attest subject, generate sealed Policy Artifact. Auto-loads into portal. (Claims 1a-1d)', {
133
- subject_content: z.string().describe('Content/bytes of the subject'),
134
- subject_metadata: z.object({ filename: z.string().optional(), version: z.string().optional(), author: z.string().optional(), content_type: z.string().optional() }),
52
+ // 20 TOOLS
53
+ // ══════════════════════════════════════════════════════════════
54
+ // 1. aga_server_info (ungoverned)
55
+ server.tool('aga_server_info', 'Get AGA server info, public keys, portal state, and framework alignment.', {}, async () => handleServerInfo({}, ctx));
56
+ // Also register as get_server_info for backward compat
57
+ server.tool('get_server_info', 'Get AGA server info (alias for aga_server_info).', {}, async () => handleServerInfo({}, ctx));
58
+ // 2. aga_init_chain (ungoverned)
59
+ server.tool('aga_init_chain', 'Initialize continuity chain with genesis event. (Claim 3a)', { specification_hash: z.string().optional() }, async (args) => handleInitChain(args, ctx));
60
+ // Also register as init_chain for backward compat
61
+ server.tool('init_chain', 'Initialize continuity chain (alias for aga_init_chain). (Claim 3a)', { specification_hash: z.string().optional() }, async (args) => handleInitChain(args, ctx));
62
+ // 3. aga_create_artifact (ungoverned)
63
+ server.tool('aga_create_artifact', 'Attest subject, generate sealed Policy Artifact, load into portal. Accepts content or pre-computed hashes. (Claims 1a-1d)', {
64
+ subject_content: z.string().optional().describe('Content/bytes of the subject'),
65
+ subject_bytes_hash: z.string().optional().describe('Pre-computed SHA-256 bytes hash'),
66
+ subject_metadata_hash: z.string().optional().describe('Pre-computed SHA-256 metadata hash'),
67
+ subject_metadata: z.object({
68
+ filename: z.string().optional(),
69
+ version: z.string().optional(),
70
+ author: z.string().optional(),
71
+ content_type: z.string().optional(),
72
+ }).optional(),
73
+ measurement_cadence_ms: z.number().optional(),
74
+ enforcement_action: z.string().optional(),
75
+ ttl_seconds: z.number().optional(),
76
+ measurement_types: z.array(z.string()).optional(),
135
77
  evidence_items: z.array(z.object({ label: z.string(), content: z.string() })).default([]),
136
78
  behavioral_baseline: z.object({
137
79
  permitted_tools: z.array(z.string()),
@@ -139,231 +81,163 @@ export async function createAGAServer() {
139
81
  forbidden_sequences: z.array(z.array(z.string())),
140
82
  window_ms: z.number(),
141
83
  }).optional(),
142
- }, async ({ subject_content, subject_metadata, evidence_items, behavioral_baseline }) => {
143
- const subId = computeSubjectIdFromString(subject_content, subject_metadata);
144
- const policyRef = sha256Str(JSON.stringify(DEFAULT_ENFORCEMENT));
145
- const att = performAttestation({ subject_identifier: subId, policy_reference: policyRef, evidence_items });
146
- if (!att.success || !att.sealed_hash || !att.seal_salt)
147
- return j({ success: false, error: att.rejection_reason });
148
- const artifact = generateArtifact({
149
- subject_identifier: subId, policy_reference: policyRef, policy_version: 1,
150
- sealed_hash: att.sealed_hash, seal_salt: att.seal_salt,
151
- enforcement_parameters: DEFAULT_ENFORCEMENT, disclosure_policy: DEFAULT_CLAIMS,
152
- evidence_commitments: att.evidence_commitments, issuer_keypair: issuerKP,
153
- });
154
- await storage.storeArtifact(artifact);
155
- portal.reset();
156
- portal.loadArtifact(artifact, pkToHex(issuerKP.publicKey));
157
- quarantine = null;
158
- behavioralMonitor.reset();
159
- if (behavioral_baseline)
160
- behavioralMonitor.setBaseline(behavioral_baseline);
161
- await autoChain('POLICY_ISSUANCE', { artifact_hash: hashArtifact(artifact), sealed_hash: artifact.sealed_hash });
162
- return j({
163
- success: true, artifact_hash: hashArtifact(artifact), sealed_hash: artifact.sealed_hash,
164
- subject_identifier: subId, portal_state: portal.state,
165
- issuer_public_key: pkToHex(issuerKP.publicKey),
166
- });
84
+ }, async (args) => handleCreateArtifact(args, ctx));
85
+ // 4. aga_measure_subject (governed)
86
+ governedTool('aga_measure_subject', 'Measure subject state, compare to sealed reference. Generates signed receipt. (Claims 1e-1g)', {
87
+ subject_content: z.string().optional().describe('Raw content to measure'),
88
+ subject_bytes_hash: z.string().optional().describe('Pre-computed SHA-256 bytes hash (64 hex)'),
89
+ subject_metadata_hash: z.string().optional().describe('Pre-computed SHA-256 metadata hash (64 hex)'),
90
+ subject_metadata: z.object({
91
+ filename: z.string().optional(),
92
+ version: z.string().optional(),
93
+ author: z.string().optional(),
94
+ content_type: z.string().optional(),
95
+ }).optional(),
96
+ }, async (args) => handleMeasureSubject({ ...args, subject_metadata: args.subject_metadata ?? {} }, ctx));
97
+ // 5. aga_verify_artifact (ungoverned)
98
+ server.tool('aga_verify_artifact', 'Verify an artifact signature against an issuer public key.', {
99
+ artifact: z.any().describe('The policy artifact to verify'),
100
+ issuer_public_key: z.string().optional().describe('Issuer public key (hex)'),
101
+ }, async (args) => {
102
+ const pk = args.issuer_public_key ?? (await import('./crypto/sign.js')).pkToHex(ctx.issuerKP.publicKey);
103
+ return handleVerifyArtifact({ artifact: args.artifact ?? ctx.activeArtifact, issuer_public_key: pk }, ctx);
167
104
  });
168
- // ══════════════════════════════════════════════════════════════
169
- // TOOL: measure_integrity (Claims 1e-1g)
170
- // V3: Generates receipt for EVERY measurement (match or mismatch)
171
- // V3: Checks TTL and revocation (fail-closed)
172
- // ══════════════════════════════════════════════════════════════
173
- governedTool('measure_integrity', 'Measure subject state, compare to sealed reference. Generates signed receipt for every measurement. (Claims 1e-1g)', {
174
- subject_content: z.string().describe('Current content of the subject'),
175
- subject_metadata: z.object({ filename: z.string().optional(), version: z.string().optional(), author: z.string().optional(), content_type: z.string().optional() }),
176
- }, async ({ subject_content, subject_metadata }) => {
177
- if (!portal.artifact)
178
- return j({ success: false, error: 'No artifact loaded. Call attest_subject first.' });
179
- if (portal.state === 'TERMINATED')
180
- return j({ success: false, error: 'Portal is terminated. Re-attest required.' });
181
- const result = portal.measure(new TextEncoder().encode(subject_content), subject_metadata);
182
- const artRef = hashArtifact(portal.artifact);
183
- const currentStr = result.currentBytesHash ? `${result.currentBytesHash}||${result.currentMetaHash}` : 'UNAVAILABLE';
184
- const sealedStr = `${result.expectedBytesHash}||${result.expectedMetaHash}`;
185
- // Determine enforcement action
186
- let action = null;
187
- let driftDesc = null;
188
- if (!result.ttl_ok) {
189
- driftDesc = 'TTL expired — fail-closed termination';
190
- action = 'TERMINATE';
191
- }
192
- else if (result.revoked) {
193
- driftDesc = 'Artifact revoked — fail-closed termination';
194
- action = 'TERMINATE';
195
- }
196
- else if (!result.match) {
197
- driftDesc = 'Subject modified hash mismatch';
198
- action = portal.artifact.enforcement_parameters.enforcement_triggers[0] ?? 'ALERT_ONLY';
199
- portal.enforce(action);
200
- if (action === 'QUARANTINE')
201
- quarantine = initQuarantine();
202
- }
203
- // V3: Receipt for EVERY measurement — match or mismatch
204
- const receipt = generateReceipt({
205
- subjectId: portal.artifact.subject_identifier, artifactRef: artRef,
206
- currentHash: currentStr, sealedHash: sealedStr,
207
- driftDetected: !result.match, driftDescription: driftDesc,
208
- action, measurementType: portal.artifact.enforcement_parameters.measurement_types.join(','),
209
- seq: portal.sequenceCounter + 1, prevLeaf: portal.lastLeafHash, portalKP,
210
- });
211
- await storage.storeReceipt(receipt);
212
- await autoChain('INTERACTION_RECEIPT', { receipt_id: receipt.receipt_id, drift_detected: !result.match, enforcement_action: action });
213
- return j({
214
- success: true, match: result.match, drift_detected: !result.match,
215
- ttl_ok: result.ttl_ok, revoked: result.revoked,
216
- enforcement_action: action, portal_state: portal.state,
217
- receipt_id: receipt.receipt_id,
218
- });
105
+ // 6. aga_start_monitoring (governed)
106
+ governedTool('aga_start_monitoring', 'Start or restart behavioral monitoring with a new baseline.', {
107
+ behavioral_baseline: z.object({
108
+ permitted_tools: z.array(z.string()),
109
+ rate_limits: z.record(z.number()),
110
+ forbidden_sequences: z.array(z.array(z.string())),
111
+ window_ms: z.number(),
112
+ }).optional(),
113
+ }, async (args) => handleStartMonitoring(args, ctx));
114
+ // 7. aga_get_portal_state (ungoverned)
115
+ server.tool('aga_get_portal_state', 'Get current portal state, loaded artifact info, and enforcement status.', {}, async () => handleGetPortalState({}, ctx));
116
+ // 8. aga_trigger_measurement (governed)
117
+ governedTool('aga_trigger_measurement', 'Trigger a measurement of subject content and generate a receipt.', {
118
+ subject_content: z.string().optional().describe('Raw content to measure'),
119
+ subject_bytes_hash: z.string().optional().describe('Pre-computed SHA-256 bytes hash (64 hex)'),
120
+ subject_metadata_hash: z.string().optional().describe('Pre-computed SHA-256 metadata hash (64 hex)'),
121
+ measurement_type: z.string().optional(),
122
+ subject_metadata: z.record(z.string()).optional(),
123
+ }, async (args) => handleTriggerMeasurement(args, ctx));
124
+ // 9. aga_generate_receipt (governed)
125
+ governedTool('aga_generate_receipt', 'Generate a signed measurement receipt manually.', {
126
+ subject_content: z.string().optional(),
127
+ drift_detected: z.boolean().optional(),
128
+ drift_description: z.string().optional(),
129
+ measurement_type: z.string().optional(),
130
+ action_type: z.string().optional(),
131
+ action_detail: z.string().optional(),
132
+ }, async (args) => handleGenerateReceipt(args, ctx));
133
+ // 10. aga_export_bundle (governed)
134
+ governedTool('aga_export_bundle', 'Package artifact + receipts + Merkle proofs for offline verification. (Claim 9)', {}, async () => handleExportBundle({}, ctx));
135
+ // 11. aga_verify_bundle (ungoverned - verification is always allowed)
136
+ server.tool('aga_verify_bundle', 'Verify evidence bundle offline - 4-step verification. (Section J)', {
137
+ bundle: z.any(),
138
+ pinned_public_key: z.string().optional(),
139
+ }, async (args) => {
140
+ const pk = args.pinned_public_key ?? (await import('./crypto/sign.js')).pkToHex(ctx.issuerKP.publicKey);
141
+ return handleVerifyBundle({ bundle: args.bundle, pinned_public_key: pk }, ctx);
219
142
  });
220
- // ══════════════════════════════════════════════════════════════
221
- // TOOL: revoke_artifact V3 NEW (NCCoE Phase 3b)
222
- // ══════════════════════════════════════════════════════════════
223
- governedTool('revoke_artifact', 'Revoke an active policy artifact mid-session. Portal terminates on next measurement. (NCCoE Phase 3b)', {
224
- sealed_hash: z.string().describe('Sealed hash of artifact to revoke'),
143
+ // 12. aga_disclose_claim (governed)
144
+ governedTool('aga_disclose_claim', 'Request disclosure of a claim. Auto-substitutes if sensitivity denied. (Claim 2)', {
145
+ claim_id: z.string(),
146
+ requester_id: z.string().default('anonymous'),
147
+ mode: z.enum(['PROOF_ONLY', 'REVEAL_MIN', 'REVEAL_FULL']).default('REVEAL_MIN'),
148
+ disclosure_mode: z.enum(['PROOF_ONLY', 'REVEAL_MIN', 'REVEAL_FULL']).optional(),
149
+ }, async (args) => handleDiscloseClaim({
150
+ claim_id: args.claim_id,
151
+ requester_id: args.requester_id,
152
+ mode: args.disclosure_mode ?? args.mode,
153
+ }, ctx));
154
+ // 13. aga_get_chain (ungoverned)
155
+ server.tool('aga_get_chain', 'Get continuity chain events with optional verification and filtering. (Claim 3c)', {
156
+ start_seq: z.number().optional(),
157
+ end_seq: z.number().optional(),
158
+ verify: z.boolean().optional(),
159
+ filter_type: z.string().optional().describe('Filter: all, behavioral, delegations, receipts, revocations, attestations, disclosure, keys'),
160
+ }, async (args) => handleGetChain(args, ctx));
161
+ // 14. aga_quarantine_status (ungoverned)
162
+ server.tool('aga_quarantine_status', 'Get quarantine state and forensic capture status. (Claim 5)', {}, async () => handleQuarantineStatus({}, ctx));
163
+ // 15. aga_revoke_artifact (governed)
164
+ governedTool('aga_revoke_artifact', 'Revoke an active policy artifact mid-session. Supports TERMINATED or SAFE_STATE transition. (NCCoE Phase 3b)', {
165
+ sealed_hash: z.string().optional().describe('Sealed hash of artifact to revoke'),
225
166
  reason: z.string().describe('Reason for revocation'),
226
- }, async ({ sealed_hash, reason }) => {
227
- portal.revoke(sealed_hash);
228
- const record = {
229
- artifact_sealed_hash: sealed_hash, reason,
230
- revoked_by: pkToHex(issuerKP.publicKey), timestamp: utcNow(),
231
- };
232
- await autoChain('REVOCATION', record);
233
- return j({ success: true, revoked: sealed_hash, portal_state: portal.state, reason });
234
- });
235
- // ══════════════════════════════════════════════════════════════
236
- // TOOL: verify_chain (Claim 3c)
237
- // ══════════════════════════════════════════════════════════════
238
- server.tool('verify_chain', 'Verify continuity chain integrity. (Claim 3c)', {}, async () => {
239
- const events = await storage.getAllEvents();
240
- if (!events.length)
241
- return j({ success: false, error: 'No events in chain' });
242
- const result = verifyChainIntegrity(events);
243
- return j({ success: true, chain_valid: result.valid, events_verified: events.length, broken_at: result.brokenAt, error: result.error });
244
- });
245
- // ══════════════════════════════════════════════════════════════
246
- // TOOL: create_checkpoint (Claims 3d-3f)
247
- // ══════════════════════════════════════════════════════════════
248
- governedTool('create_checkpoint', 'Batch events into Merkle tree, anchor. (Claims 3d-3f)', { anchor_network: z.string().default('local') }, async ({ anchor_network }) => {
249
- const lastCP = await storage.getLatestCheckpoint();
250
- const startSeq = lastCP ? lastCP.batch_end_sequence + 1 : 0;
251
- const latest = await storage.getLatestEvent();
252
- if (!latest)
253
- return j({ success: false, error: 'No events' });
254
- const events = await storage.getEvents(startSeq, latest.sequence_number);
255
- if (!events.length)
256
- return j({ success: false, error: 'No new events since last checkpoint' });
257
- const { checkpoint, payload } = createCheckpoint(events, anchor_network);
258
- await storage.storeCheckpoint(checkpoint);
259
- await autoChain('ANCHOR_BATCH', payload);
260
- return j({ success: true, merkle_root: checkpoint.merkle_root, events_checkpointed: events.length, transaction_id: checkpoint.transaction_id });
261
- });
262
- // ══════════════════════════════════════════════════════════════
263
- // TOOL: generate_evidence_bundle (Claim 9)
264
- // ══════════════════════════════════════════════════════════════
265
- governedTool('generate_evidence_bundle', 'Package artifact + receipts + Merkle proofs for offline verification. (Claim 9)', {}, async () => {
266
- const artifact = await storage.getLatestArtifact();
267
- if (!artifact)
268
- return j({ success: false, error: 'No artifact' });
269
- const cp = await storage.getLatestCheckpoint();
270
- if (!cp)
271
- return j({ success: false, error: 'No checkpoint. Call create_checkpoint first.' });
272
- const receipts = await storage.getReceiptsByArtifact(hashArtifact(artifact));
273
- const batchEvents = await storage.getEvents(cp.batch_start_sequence, cp.batch_end_sequence);
274
- const proofs = receipts
275
- .filter(r => r.sequence_number >= cp.batch_start_sequence && r.sequence_number <= cp.batch_end_sequence)
276
- .map(r => eventInclusionProof(batchEvents, r.sequence_number));
277
- const bundle = generateBundle(artifact, receipts, proofs, cp, portalKP);
278
- return j({ success: true, bundle, offline_verifiable: true, receipt_count: receipts.length, proof_count: proofs.length });
279
- });
280
- // ══════════════════════════════════════════════════════════════
281
- // TOOL: verify_bundle_offline (Section J)
282
- // ══════════════════════════════════════════════════════════════
283
- governedTool('verify_bundle_offline', 'Verify evidence bundle offline. (Section J)', { bundle: z.any(), pinned_public_key: z.string() }, async ({ bundle, pinned_public_key }) => j({ success: true, verification: verifyBundleOffline(bundle, pinned_public_key) }));
284
- // ══════════════════════════════════════════════════════════════
285
- // TOOL: request_claim (Claim 2)
286
- // ══════════════════════════════════════════════════════════════
287
- governedTool('request_claim', 'Request disclosure of a claim. Auto-substitutes if denied. (Claim 2)', { claim_id: z.string(), requester_id: z.string().default('anonymous'), mode: z.enum(['PROOF_ONLY', 'REVEAL_MIN', 'REVEAL_FULL']).default('REVEAL_MIN') }, async ({ claim_id, requester_id, mode }) => {
288
- const latest = await storage.getLatestEvent();
289
- const result = processDisclosure({ requested_claim_id: claim_id, requester_id, mode, timestamp: utcNow() }, DEFAULT_CLAIMS, CLAIM_VALUES, 1, latest?.sequence_number ?? 0, portalKP);
290
- if (result.substitution_receipt)
291
- await autoChain('SUBSTITUTION', result.substitution_receipt);
292
- else
293
- await autoChain('DISCLOSURE', { claim_id, mode, permitted: result.permitted });
294
- return j({ success: true, ...result });
295
- });
296
- // ══════════════════════════════════════════════════════════════
297
- // TOOL: list_claims
298
- // ══════════════════════════════════════════════════════════════
299
- server.tool('list_claims', 'List available claims with sensitivity levels.', {}, async () => {
300
- return j({ claims: DEFAULT_CLAIMS.claims_taxonomy.map(c => ({ claim_id: c.claim_id, sensitivity: c.sensitivity, substitutes: c.substitutes, permitted_modes: c.permitted_modes })) });
301
- });
302
- // ══════════════════════════════════════════════════════════════
303
- // TOOL: delegate_to_subagent (NCCoE: constrained sub-mandates)
304
- // ══════════════════════════════════════════════════════════════
305
- governedTool('delegate_to_subagent', 'Derive a constrained policy artifact for a sub-agent. Scope can only diminish, never expand. (NCCoE constrained delegation)', {
306
- enforcement_triggers: z.array(z.string()).describe('Subset of parent enforcement triggers'),
307
- measurement_types: z.array(z.string()).describe('Subset of parent measurement types'),
308
- requested_ttl_seconds: z.number().describe('Requested TTL (will be clamped to parent remaining)'),
309
- delegation_purpose: z.string().describe('Purpose of the delegation'),
310
- }, async ({ enforcement_triggers, measurement_types, requested_ttl_seconds, delegation_purpose }) => {
311
- if (!portal.artifact)
312
- return j({ success: false, error: 'No artifact loaded. Call attest_subject first.' });
313
- const result = deriveArtifact(portal.artifact, {
314
- enforcement_triggers: enforcement_triggers,
315
- measurement_types: measurement_types,
316
- requested_ttl_seconds,
317
- delegation_purpose,
318
- }, issuerKP);
319
- if (result.success) {
320
- await autoChain('ATTESTATION', {
321
- type: 'DELEGATION',
322
- parent_artifact_hash: result.parent_artifact_hash,
323
- child_artifact_hash: result.child_artifact_hash,
324
- effective_ttl: result.effective_ttl_seconds,
325
- scope_reduction: result.scope_reduction,
326
- purpose: delegation_purpose,
327
- });
328
- }
329
- return j(result);
330
- });
331
- // ══════════════════════════════════════════════════════════════
332
- // TOOL: measure_behavior (NIST-2025-0035)
333
- // ══════════════════════════════════════════════════════════════
334
- server.tool('measure_behavior', 'Measure behavioral patterns of agent tool usage. Detects unauthorized tools, rate violations, and forbidden sequences. (NIST-2025-0035)', {}, async () => {
335
- const measurement = behavioralMonitor.measure();
336
- if (measurement.drift_detected) {
337
- await autoChain('INTERACTION_RECEIPT', {
338
- type: 'BEHAVIORAL_DRIFT',
339
- violations: measurement.violations,
340
- behavioral_hash: measurement.behavioral_hash,
341
- });
342
- }
343
- return j({
344
- success: true,
345
- ...measurement,
346
- violation_count: measurement.violations.length,
347
- });
348
- });
349
- // ══════════════════════════════════════════════════════════════
350
- // TOOL: get_receipts — V3 NEW
351
- // ══════════════════════════════════════════════════════════════
352
- server.tool('get_receipts', 'Get all signed receipts, optionally filtered by artifact.', { artifact_hash: z.string().optional() }, async ({ artifact_hash }) => {
353
- const receipts = artifact_hash
354
- ? await storage.getReceiptsByArtifact(artifact_hash)
355
- : await storage.getAllReceipts();
356
- return j({ count: receipts.length, receipts: receipts.map(r => ({ receipt_id: r.receipt_id, drift_detected: r.drift_detected, enforcement_action: r.enforcement_action, measurement_type: r.measurement_type, timestamp: r.timestamp })) });
357
- });
358
- // ══════════════════════════════════════════════════════════════
359
- // TOOL: get_chain_events — V3 NEW
360
- // ══════════════════════════════════════════════════════════════
361
- server.tool('get_chain_events', 'Get continuity chain events.', { start_seq: z.number().optional(), end_seq: z.number().optional() }, async ({ start_seq, end_seq }) => {
362
- const events = (start_seq !== undefined && end_seq !== undefined)
363
- ? await storage.getEvents(start_seq, end_seq)
364
- : await storage.getAllEvents();
365
- return j({ count: events.length, events: events.map(e => ({ sequence_number: e.sequence_number, event_type: e.event_type, event_id: e.event_id, timestamp: e.timestamp, leaf_hash: e.leaf_hash.slice(0, 16) + '...' })) });
167
+ transition_to: z.enum(['TERMINATED', 'SAFE_STATE']).optional(),
168
+ }, async (args) => handleRevokeArtifact(args, ctx));
169
+ // 16. aga_set_verification_tier (ungoverned)
170
+ server.tool('aga_set_verification_tier', 'Set the verification tier (BRONZE, SILVER, GOLD).', {
171
+ tier: z.enum(['BRONZE', 'SILVER', 'GOLD']),
172
+ }, async (args) => handleSetVerificationTier(args, ctx));
173
+ // 17. aga_demonstrate_lifecycle (ungoverned)
174
+ server.tool('aga_demonstrate_lifecycle', 'Execute full AGA lifecycle demo: attest → measure → drift → revoke → bundle → verify.', {
175
+ subject_content: z.string().optional(),
176
+ subject_metadata: z.record(z.string()).optional(),
177
+ scenario: z.string().optional().describe('Scenario: drone, scada, or custom'),
178
+ include_drift: z.boolean().optional(),
179
+ include_revocation: z.boolean().optional(),
180
+ include_behavioral: z.boolean().optional(),
181
+ }, async (args) => handleFullLifecycle(args, ctx));
182
+ // 18. aga_measure_behavior (ungoverned)
183
+ server.tool('aga_measure_behavior', 'Measure behavioral patterns or record tool invocation. (NIST-2025-0035)', {
184
+ tool_name: z.string().optional().describe('Tool name to record/test'),
185
+ record_only: z.boolean().optional().describe('If true, just record without measuring'),
186
+ }, async (args) => handleMeasureBehavior(args, ctx));
187
+ // 19. aga_delegate_to_subagent (governed)
188
+ governedTool('aga_delegate_to_subagent', 'Derive constrained policy artifact for sub-agent. Scope only diminishes. (NCCoE)', {
189
+ sub_agent_id: z.string().optional(),
190
+ permitted_tools: z.array(z.string()).optional(),
191
+ enforcement_triggers: z.array(z.string()).optional(),
192
+ measurement_types: z.array(z.string()).optional(),
193
+ ttl_seconds: z.number().optional(),
194
+ requested_ttl_seconds: z.number().optional(),
195
+ delegation_purpose: z.string().optional(),
196
+ delegation_reason: z.string().optional(),
197
+ }, async (args) => handleDelegateSubagent(args, ctx));
198
+ // 20. aga_rotate_keys (governed)
199
+ governedTool('aga_rotate_keys', 'Rotate a keypair (issuer, portal, or chain). Old key should be revoked.', {
200
+ key_type: z.enum(['issuer', 'portal', 'chain']).optional(),
201
+ keypair: z.enum(['issuer', 'portal', 'chain']).optional(),
202
+ reason: z.string().optional(),
203
+ }, async (args) => handleRotateKeys(args, ctx));
204
+ // ══════════════════════════════════════════════════════════════
205
+ // 4 RESOURCES
206
+ // ══════════════════════════════════════════════════════════════
207
+ server.resource('protocol-specification', SPECIFICATION_URI, { mimeType: 'text/markdown', description: 'AGA Protocol Specification v2.0.0 with SPIFFE integration and framework alignment' }, async () => ({ contents: [{ uri: SPECIFICATION_URI, mimeType: 'text/markdown', text: PROTOCOL_SPECIFICATION }] }));
208
+ server.resource('sample-bundle', SAMPLE_BUNDLE_URI, { mimeType: 'application/json', description: 'Pre-generated cryptographically signed evidence bundle' }, async () => {
209
+ const { bundle, issuerPkHex } = generateSampleBundle();
210
+ const text = JSON.stringify({ issuer_public_key: issuerPkHex, bundle: JSON.parse(bundle) }, null, 2);
211
+ return { contents: [{ uri: SAMPLE_BUNDLE_URI, mimeType: 'application/json', text }] };
366
212
  });
213
+ server.resource('crypto-primitives', CRYPTO_PRIMITIVES_URI, { mimeType: 'text/markdown', description: 'AGA cryptographic primitives documentation' }, async () => ({ contents: [{ uri: CRYPTO_PRIMITIVES_URI, mimeType: 'text/markdown', text: CRYPTO_PRIMITIVES_DOC }] }));
214
+ server.resource('patent-claims', PATENT_CLAIMS_URI, { mimeType: 'text/markdown', description: 'USPTO 19/433,835 patent claims mapped to 20 tools' }, async () => ({ contents: [{ uri: PATENT_CLAIMS_URI, mimeType: 'text/markdown', text: PATENT_CLAIMS_DOC }] }));
215
+ // ══════════════════════════════════════════════════════════════
216
+ // 3 PROMPTS
217
+ // ══════════════════════════════════════════════════════════════
218
+ server.prompt(NCCOE_DEMO_PROMPT.name, NCCOE_DEMO_PROMPT.description, {
219
+ agent_code: z.string().optional().describe('The agent source code to attest'),
220
+ include_behavioral: z.string().optional().describe('Include behavioral drift detection phase'),
221
+ }, async (args) => ({
222
+ messages: [{
223
+ role: 'user',
224
+ content: { type: 'text', text: NCCOE_DEMO_PROMPT.template(args) },
225
+ }],
226
+ }));
227
+ server.prompt(GOVERNANCE_REPORT_PROMPT.name, GOVERNANCE_REPORT_PROMPT.description, {}, async () => ({
228
+ messages: [{
229
+ role: 'user',
230
+ content: { type: 'text', text: GOVERNANCE_REPORT_PROMPT.template() },
231
+ }],
232
+ }));
233
+ server.prompt(DRIFT_ANALYSIS_PROMPT.name, DRIFT_ANALYSIS_PROMPT.description, {
234
+ drift_type: z.string().optional().describe('Type of drift: binary, behavioral, or both'),
235
+ }, async (args) => ({
236
+ messages: [{
237
+ role: 'user',
238
+ content: { type: 'text', text: DRIFT_ANALYSIS_PROMPT.template(args) },
239
+ }],
240
+ }));
367
241
  return server;
368
242
  }
369
243
  //# sourceMappingURL=server.js.map