agent-passport-system 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/agent-passport-system)](https://www.npmjs.com/package/agent-passport-system)
4
4
  [![license](https://img.shields.io/npm/l/agent-passport-system)](https://github.com/aeoess/agent-passport-system/blob/main/LICENSE)
5
- [![tests](https://img.shields.io/badge/tests-65%20passing-brightgreen)](https://github.com/aeoess/agent-passport-system)
5
+ [![tests](https://img.shields.io/badge/tests-165%20passing-brightgreen)](https://github.com/aeoess/agent-passport-system)
6
6
  [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.18749779.svg)](https://doi.org/10.5281/zenodo.18749779)
7
7
 
8
- Cryptographic identity, ethical governance, economic attribution, protocol-native communication, and intent architecture for autonomous AI agents.
8
+ Cryptographic identity, ethical governance, economic attribution, protocol-native communication, intent architecture, cascade revocation, and coordination primitives for autonomous AI agents.
9
9
 
10
- **5 layers. 65 tests. Zero heavy dependencies. Running code.**
10
+ **7 layers. 165 tests. Zero heavy dependencies. Running code. MCP server included.**
11
11
 
12
12
  > *As AI agents from different creators, running different models, serving different humans begin to collaborate — who is responsible, under what authority, according to what values, and who benefits?*
13
13
 
@@ -166,10 +166,83 @@ const eval = evaluateConsensus(delib)
166
166
  // → { converged: true, standardDeviation: 4.2, recommendation: 'converged' }
167
167
  ```
168
168
 
169
+ ### Layer 7 — Coordination Primitives
170
+
171
+ ```typescript
172
+ import {
173
+ createTaskBrief, assignTask, acceptTask,
174
+ submitEvidence, reviewEvidence, handoffEvidence,
175
+ submitDeliverable, completeTask
176
+ } from 'agent-passport-system'
177
+
178
+ // Operator creates a task brief
179
+ const brief = createTaskBrief({
180
+ title: 'Competitive Protocol Analysis',
181
+ roles: { researcher: { count: 1 }, analyst: { count: 1 } },
182
+ deliverables: [
183
+ { id: 'd1', description: 'Evidence packet', assignedRole: 'researcher' },
184
+ { id: 'd2', description: 'Synthesis report', assignedRole: 'analyst' }
185
+ ],
186
+ acceptanceCriteria: [
187
+ { id: 'c1', description: 'Min 3 sources', threshold: 70 }
188
+ ]
189
+ }, operatorKeys)
190
+
191
+ // Assign agents to roles
192
+ const assigned = assignTask(brief, 'researcher', agentId, agentPubKey, ['web_search'], operatorKeys)
193
+
194
+ // Worker accepts
195
+ const accepted = acceptTask(assigned.brief, agentKeys)
196
+
197
+ // Researcher submits evidence (every claim needs a 10+ word quote)
198
+ const evidence = submitEvidence({
199
+ taskId: brief.id, role: 'researcher',
200
+ claims: [
201
+ { claim: 'Protocol X has 50 stars', source: 'github.com/x', quote: 'Repository shows 50 stars as of Feb 2026', confidence: 'verified' }
202
+ ],
203
+ methodology: 'GitHub search + npm registry analysis',
204
+ gaps: [{ area: 'Performance data', reason: 'No benchmarks published' }]
205
+ }, researcherKeys)
206
+
207
+ // Operator reviews (cannot approve below threshold)
208
+ const review = reviewEvidence(evidence.id, {
209
+ verdict: 'approve', score: 85, threshold: 70,
210
+ notes: 'Solid sourcing, gap acknowledged'
211
+ }, operatorKeys)
212
+
213
+ // Handoff to analyst (requires approved review)
214
+ const handoff = handoffEvidence(evidence.id, review.id, 'analyst', analystPubKey, operatorKeys)
215
+
216
+ // Analyst submits deliverable citing evidence
217
+ const deliverable = submitDeliverable({
218
+ taskId: brief.id, role: 'analyst',
219
+ content: 'Protocol X shows moderate adoption...',
220
+ evidencePacketIds: [evidence.id],
221
+ citationCount: 3, gapsFlagged: 1
222
+ }, analystKeys)
223
+
224
+ // Operator closes with metrics
225
+ const completion = completeTask(brief.id, {
226
+ status: 'completed',
227
+ retrospective: {
228
+ overheadRatio: 0.9, gapRate: 0.08,
229
+ reworkCount: 0, errorsCaught: 1
230
+ }
231
+ }, operatorKeys)
232
+ ```
233
+
169
234
  ## Architecture
170
235
 
171
236
  ```
172
237
  ┌─────────────────────────────────────────────────┐
238
+ │ Layer 7: Coordination Primitives │
239
+ │ Task briefs · Role assignment · Evidence · │
240
+ │ Review gates · Handoffs · Deliverables · Metrics│
241
+ ├─────────────────────────────────────────────────┤
242
+ │ Layer 6: Cascade Revocation & Policy Engine │
243
+ │ 3-signature chain · Chain tracking · Batch │
244
+ │ revoke · Validation events · Policy receipts │
245
+ ├─────────────────────────────────────────────────┤
173
246
  │ Layer 5: Intent Architecture │
174
247
  │ Roles · Tradeoff rules · Deliberative │
175
248
  │ consensus · Precedent memory · Signed outcomes │
@@ -202,6 +275,10 @@ const eval = evaluateConsensus(delib)
202
275
 
203
276
  **Layer 5 — Intent Architecture.** Context tells agents what they know. Intent tells them what to care about. Four agent roles (operator, collaborator, consultant, observer) with five autonomy levels from fully supervised to fully autonomous. Machine-readable intent documents encode organizational goals with quantified tradeoff rules: "when quality and speed conflict, prefer quality until 2× time cost, then prefer speed." Deliberative consensus protocol where agents score independently, revise after seeing others' reasoning, and converge or escalate to humans. Every resolved deliberation becomes a citable precedent. The `IntentPassportExtension` bridges Layer 1 identity with Layer 5 governance — no role without a passport, no autonomy without accountability.
204
277
 
278
+ **Layer 6 — Cascade Revocation & Policy Engine.** Three-signature action chain: agent creates intent, policy validator evaluates against floor principles and delegation scope, agent executes and signs receipt. Parent→child chain registry tracks all delegation relationships. Revoking a parent automatically cascade-revokes all descendants. Batch revocation by agent ID. Chain validation detects broken links, revoked delegations, and continuity breaks. Revocation events emitted for real-time monitoring.
279
+
280
+ **Layer 7 — Coordination Primitives.** Protocol-native multi-agent task orchestration. Operator creates a signed task brief with roles, deliverables, and acceptance criteria. Agents are assigned to roles and sign acceptance. Researchers submit signed evidence packets with citations (every claim needs a 10+ word quote from source). Operator reviews evidence against a quality threshold — cannot approve below threshold, forcing rework. Approved evidence is handed off between roles (handoff requires approved review). Analysts submit deliverables citing evidence packets. Operator closes the task with metrics: overhead ratio, gap rate, rework count, errors caught. Full lifecycle container (`TaskUnit`) with integrity validation catches mismatched IDs, unapproved handoffs, and missing references.
281
+
205
282
  ## Human Values Floor — v0.1
206
283
 
207
284
  | ID | Principle | Enforcement |
@@ -216,17 +293,49 @@ const eval = evaluateConsensus(delib)
216
293
 
217
294
  Full manifest: [`values/floor.yaml`](values/floor.yaml)
218
295
 
296
+ ## MCP Server
297
+
298
+ The protocol ships with a coordination-native MCP server — any MCP client (Claude Desktop, Cursor, etc.) can connect agents directly.
299
+
300
+ ```bash
301
+ npm install agent-passport-system-mcp
302
+ ```
303
+
304
+ **14 tools, role-scoped access control.** Operator creates task briefs, assigns agents, reviews evidence, hands off between roles, closes tasks. Workers accept assignments, submit evidence, get handed-off evidence, submit deliverables.
305
+
306
+ ```json
307
+ {
308
+ "mcpServers": {
309
+ "agent-passport": {
310
+ "command": "npx",
311
+ "args": ["agent-passport-system-mcp"],
312
+ "env": {
313
+ "AGENT_KEY": "<public_key>",
314
+ "AGENT_PRIVATE_KEY": "<private_key>",
315
+ "AGENT_ID": "my-agent"
316
+ }
317
+ }
318
+ }
319
+ }
320
+ ```
321
+
322
+ Every operation is Ed25519 signed. Role is auto-detected from task assignments. Role-specific prompts served via MCP prompts API. File-backed task persistence at `~/.agent-passport-tasks.json`.
323
+
324
+ npm: [agent-passport-system-mcp](https://www.npmjs.com/package/agent-passport-system-mcp) · GitHub: [aeoess/agent-passport-mcp](https://github.com/aeoess/agent-passport-mcp)
325
+
219
326
  ## Tests
220
327
 
221
328
  ```bash
222
329
  npm test
223
- # 65 tests across 6 files, 0 failures
330
+ # 165 tests across 12 files, 40 suites, 0 failures
224
331
  ```
225
332
 
226
333
  Includes 23 adversarial tests: Merkle tree tampering, attribution gaming resistance, compliance violations, floor negotiation attacks, wrong-key attestations.
227
334
 
228
335
  15 Agora-specific tests: message signing, tamper detection, registry membership, feed operations, threading, full feed verification.
229
336
 
337
+ 17 coordination tests: task brief creation/verification, role assignment, evidence submission, review gates (score vs threshold), handoff enforcement (requires approved review), deliverable submission, full lifecycle, task unit validation.
338
+
230
339
  ## Paper
231
340
 
232
341
  **"The Agent Social Contract: Cryptographic Identity, Ethical Governance, and Beneficiary Economics for Autonomous AI Agents"**
@@ -246,21 +355,24 @@ By Tymofii Pidlisnyi — Published on Zenodo
246
355
  | Values layer | Attested + auditable | — | Rules | — | — |
247
356
  | Attribution | Merkle proofs | — | — | — | — |
248
357
  | Communication | Signed Agora | — | — | — | — |
249
- | Tests | 65 (23 adversarial) | None | Limited | None | None |
358
+ | Coordination | Task units + MCP server | | | | |
359
+ | Tests | 165 (23 adversarial) | None | Limited | None | None |
250
360
  | Dependencies | Node.js crypto + uuid | — | Multi-LLM | — | Consensus network |
251
361
 
252
362
  ## Structure
253
363
 
254
364
  ```
255
- src/ 19 source files
365
+ src/ 21 source files
256
366
  contract.ts — High-level API (6 functions)
257
367
  core/
258
368
  passport.ts — Ed25519 identity
259
- delegation.ts — Scoped delegation, receipts, revocation
369
+ delegation.ts — Scoped delegation, receipts, cascade revocation
260
370
  values.ts — Floor attestation, compliance, negotiation
261
371
  attribution.ts — Merkle trees, beneficiary tracing
262
372
  agora.ts — Protocol-native signed communication
263
373
  intent.ts — Intent architecture, deliberation, roles
374
+ policy.ts — 3-signature chain, policy validation
375
+ coordination.ts — Task briefs, evidence, review, handoff, deliverables
264
376
  cli/
265
377
  index.ts — CLI (14 commands)
266
378
  crypto/
@@ -269,13 +381,21 @@ src/ 19 source files
269
381
  passport.ts — Layers 1–3 types
270
382
  agora.ts — Layer 4 types
271
383
  intent.ts — Layer 5 types
272
- tests/ 6 test files, 65 tests
384
+ policy.ts — Layer 6 types
385
+ coordination.ts — Layer 7 types
386
+ tests/ 12 test files, 165 tests (40 suites)
273
387
  adversarial.ts — 23 adversarial cases
274
388
  agora.test.ts — 15 Agora tests
275
389
  contract.test.ts — High-level API tests
276
390
  passport.test.ts — v1.0 primitives
277
391
  v1.1-integration.ts — Delegation chains, receipts, revocation
278
392
  v2.0-integration.ts — Full-stack integration (7 acts)
393
+ values.test.ts — Floor loading, attestation, compliance
394
+ delegation.test.ts — Delegation, sub-delegation, depth limits
395
+ attribution.test.ts — Merkle trees, attribution, collaboration
396
+ policy.test.ts — Intent, policy decision, 3-sig chain
397
+ cascade.test.ts — Chain registry, cascade revocation, batch
398
+ coordination.test.ts — Task briefs, evidence, review, handoff, lifecycle
279
399
  values/
280
400
  floor.yaml — Human Values Floor manifest
281
401
  papers/
@@ -289,6 +409,7 @@ Designed and built by **Tymofii Pidlisnyi** with AI assistance from **Claude** (
289
409
  Protocol page: [aeoess.com/protocol.html](https://aeoess.com/protocol.html)
290
410
  Agora: [aeoess.com/agora.html](https://aeoess.com/agora.html)
291
411
  npm: [npmjs.com/package/agent-passport-system](https://www.npmjs.com/package/agent-passport-system)
412
+ MCP server: [npmjs.com/package/agent-passport-system-mcp](https://www.npmjs.com/package/agent-passport-system-mcp)
292
413
 
293
414
  ## LLM Documentation
294
415
 
@@ -0,0 +1,100 @@
1
+ import type { SignedPassport } from '../types/passport.js';
2
+ import type { ACPCheckoutSession, ACPLineItem, ACPMoney, ACPAddress, CommerceConfig, CommerceDelegation, CommercePreflightResult, CommerceActionReceipt, HumanApprovalRequest } from '../types/commerce.js';
3
+ export declare function commercePreflight(opts: {
4
+ signedPassport: SignedPassport;
5
+ delegation: CommerceDelegation;
6
+ merchantName: string;
7
+ estimatedTotal: ACPMoney;
8
+ config?: CommerceConfig;
9
+ }): CommercePreflightResult;
10
+ export declare function createCheckout(opts: {
11
+ signedPassport: SignedPassport;
12
+ delegation: CommerceDelegation;
13
+ config: CommerceConfig;
14
+ items: {
15
+ skuId: string;
16
+ quantity: number;
17
+ }[];
18
+ customer?: {
19
+ name?: string;
20
+ email?: string;
21
+ };
22
+ fulfillmentAddress?: ACPAddress;
23
+ privateKey: string;
24
+ }): Promise<{
25
+ session: ACPCheckoutSession;
26
+ receipt: CommerceActionReceipt;
27
+ }>;
28
+ export declare function updateCheckout(opts: {
29
+ signedPassport: SignedPassport;
30
+ delegation: CommerceDelegation;
31
+ config: CommerceConfig;
32
+ sessionId: string;
33
+ updates: {
34
+ items?: {
35
+ id: string;
36
+ quantity: number;
37
+ }[];
38
+ fulfillmentAddress?: ACPAddress;
39
+ fulfillmentOptionId?: string;
40
+ };
41
+ privateKey: string;
42
+ }): Promise<{
43
+ session: ACPCheckoutSession;
44
+ receipt: CommerceActionReceipt;
45
+ }>;
46
+ export declare function completeCheckout(opts: {
47
+ signedPassport: SignedPassport;
48
+ delegation: CommerceDelegation;
49
+ config: CommerceConfig;
50
+ sessionId: string;
51
+ paymentToken: string;
52
+ paymentMethod?: string;
53
+ privateKey: string;
54
+ }): Promise<{
55
+ session: ACPCheckoutSession;
56
+ receipt: CommerceActionReceipt;
57
+ spendUpdated: CommerceDelegation;
58
+ }>;
59
+ export declare function cancelCheckout(opts: {
60
+ signedPassport: SignedPassport;
61
+ delegation: CommerceDelegation;
62
+ config: CommerceConfig;
63
+ sessionId: string;
64
+ privateKey: string;
65
+ }): Promise<{
66
+ session: ACPCheckoutSession;
67
+ receipt: CommerceActionReceipt;
68
+ }>;
69
+ export declare function requestHumanApproval(opts: {
70
+ agentId: string;
71
+ delegationId: string;
72
+ merchantName: string;
73
+ items: ACPLineItem[];
74
+ totalAmount: ACPMoney;
75
+ reason: string;
76
+ expiresInMinutes?: number;
77
+ }): HumanApprovalRequest;
78
+ export declare function createCommerceDelegation(opts: {
79
+ agentId: string;
80
+ delegationId: string;
81
+ spendLimit: number;
82
+ currency?: string;
83
+ approvedMerchants?: string[];
84
+ requireHumanApproval?: boolean;
85
+ humanApprovalThreshold?: number;
86
+ additionalScopes?: string[];
87
+ }): CommerceDelegation;
88
+ export declare function getSpendSummary(delegation: CommerceDelegation): {
89
+ limit: number;
90
+ spent: number;
91
+ remaining: number;
92
+ currency: string;
93
+ utilizationPercent: number;
94
+ nearLimit: boolean;
95
+ };
96
+ export declare function verifyCommerceReceipt(receipt: CommerceActionReceipt, publicKey: string): {
97
+ valid: boolean;
98
+ errors: string[];
99
+ };
100
+ //# sourceMappingURL=commerce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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AM,EAAE,MAAM,CAAA;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,GAAG,oBAAoB,CAgBvB;AAqED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;CAC5B,GAAG,kBAAkB,CAYrB;AAID,wBAAgB,eAAe,CAAC,UAAU,EAAE,kBAAkB,GAAG;IAC/D,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,SAAS,EAAE,OAAO,CAAA;CACnB,CAcA;AAID,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,MAAM,GAChB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CA0BtC"}
@@ -0,0 +1,389 @@
1
+ // ══════════════════════════════════════════════════════════════════
2
+ // Layer 7 — Agentic Commerce: Implementation
3
+ // ══════════════════════════════════════════════════════════════════
4
+ // Integration with the Agentic Commerce Protocol (ACP) by OpenAI + Stripe.
5
+ //
6
+ // Every commerce action flows through a 4-gate pipeline:
7
+ // 1. Passport verification — is this agent who it claims to be?
8
+ // 2. Delegation scope check — does this agent have commerce:checkout?
9
+ // 3. Spend limit check — would this purchase exceed the cap?
10
+ // 4. Values Floor check (F-003 Scoped Authority) — is this within policy?
11
+ //
12
+ // Only after all 4 gates pass does the agent interact with the merchant.
13
+ // Every completed action produces a signed CommerceActionReceipt.
14
+ // ══════════════════════════════════════════════════════════════════
15
+ import { randomBytes } from 'node:crypto';
16
+ import { sign, verify as ed25519Verify } from '../crypto/keys.js';
17
+ import { canonicalize } from './canonical.js';
18
+ import { verifyPassport } from '../verification/verify.js';
19
+ // ── Commerce Scopes ──
20
+ const COMMERCE_SCOPES = [
21
+ 'commerce:checkout',
22
+ 'commerce:browse',
23
+ 'commerce:purchase',
24
+ 'commerce:cancel',
25
+ ];
26
+ function hasScope(delegation, required) {
27
+ return delegation.scope.includes(required) || delegation.scope.includes('commerce:*');
28
+ }
29
+ // ── Preflight Check: 4-Gate Pipeline ──
30
+ export function commercePreflight(opts) {
31
+ const checks = [];
32
+ const warnings = [];
33
+ // Gate 1: Passport verification
34
+ const passportResult = verifyPassport(opts.signedPassport);
35
+ checks.push({
36
+ check: 'passport_valid',
37
+ passed: passportResult.valid,
38
+ detail: passportResult.valid
39
+ ? `Passport verified for ${opts.signedPassport.passport.agentId}`
40
+ : `Passport failed: ${passportResult.errors.join(', ')}`,
41
+ });
42
+ // Gate 2: Delegation scope
43
+ const hasCheckoutScope = hasScope(opts.delegation, 'commerce:checkout');
44
+ checks.push({
45
+ check: 'delegation_scope',
46
+ passed: hasCheckoutScope,
47
+ detail: hasCheckoutScope
48
+ ? `Agent has commerce:checkout scope via delegation ${opts.delegation.delegationId}`
49
+ : `Agent lacks commerce:checkout scope. Has: [${opts.delegation.scope.join(', ')}]`,
50
+ });
51
+ // Gate 3: Spend limit
52
+ const amountInBase = opts.estimatedTotal.amount;
53
+ const remainingBudget = opts.delegation.spendLimit - opts.delegation.spentAmount;
54
+ const withinBudget = amountInBase <= remainingBudget;
55
+ checks.push({
56
+ check: 'spend_limit',
57
+ passed: withinBudget,
58
+ detail: withinBudget
59
+ ? `Purchase ${amountInBase} within budget (${remainingBudget} remaining of ${opts.delegation.spendLimit})`
60
+ : `Purchase ${amountInBase} exceeds remaining budget of ${remainingBudget} (limit: ${opts.delegation.spendLimit}, spent: ${opts.delegation.spentAmount})`,
61
+ });
62
+ // Gate 3b: Human approval threshold
63
+ if (opts.delegation.requireHumanApproval && opts.delegation.humanApprovalThreshold) {
64
+ if (amountInBase > opts.delegation.humanApprovalThreshold) {
65
+ warnings.push(`Purchase of ${amountInBase} exceeds human approval threshold of ${opts.delegation.humanApprovalThreshold}. Human confirmation required.`);
66
+ }
67
+ }
68
+ // Gate 4: Merchant allowlist (if configured)
69
+ if (opts.delegation.approvedMerchants && opts.delegation.approvedMerchants.length > 0) {
70
+ const merchantApproved = opts.delegation.approvedMerchants.includes(opts.merchantName);
71
+ checks.push({
72
+ check: 'merchant_approved',
73
+ passed: merchantApproved,
74
+ detail: merchantApproved
75
+ ? `Merchant "${opts.merchantName}" is on approved list`
76
+ : `Merchant "${opts.merchantName}" is NOT on approved list: [${opts.delegation.approvedMerchants.join(', ')}]`,
77
+ });
78
+ }
79
+ const permitted = checks.every(c => c.passed);
80
+ return {
81
+ permitted,
82
+ checks,
83
+ delegation: opts.delegation,
84
+ warnings,
85
+ blockedReason: permitted ? undefined : checks.find(c => !c.passed)?.detail,
86
+ };
87
+ }
88
+ // ── ACP Client: Create Checkout Session ──
89
+ export async function createCheckout(opts) {
90
+ // Run preflight — estimate total as 0 for creation (real total comes from merchant)
91
+ const preflight = commercePreflight({
92
+ signedPassport: opts.signedPassport,
93
+ delegation: opts.delegation,
94
+ merchantName: opts.config.merchantName,
95
+ estimatedTotal: { amount: 0, currency: opts.delegation.currency },
96
+ });
97
+ if (!preflight.permitted) {
98
+ throw new Error(`Commerce preflight DENIED: ${preflight.blockedReason}`);
99
+ }
100
+ // Build ACP CreateCheckoutRequest
101
+ const requestBody = {
102
+ items: opts.items.map(i => ({ sku_id: i.skuId, quantity: i.quantity })),
103
+ ...(opts.customer && { customer: opts.customer }),
104
+ ...(opts.fulfillmentAddress && { fulfillment_address: opts.fulfillmentAddress }),
105
+ };
106
+ // Call merchant endpoint
107
+ const url = `${opts.config.merchantBaseUrl}/checkout_sessions`;
108
+ const response = await fetch(url, {
109
+ method: 'POST',
110
+ headers: {
111
+ 'Content-Type': 'application/json',
112
+ ...(opts.config.bearerToken && { 'Authorization': `Bearer ${opts.config.bearerToken}` }),
113
+ },
114
+ body: JSON.stringify(requestBody),
115
+ });
116
+ if (!response.ok) {
117
+ throw new Error(`ACP CreateCheckout failed: ${response.status} ${response.statusText}`);
118
+ }
119
+ const session = await response.json();
120
+ // Generate signed receipt
121
+ const receipt = signCommerceReceipt({
122
+ agentId: opts.signedPassport.passport.agentId,
123
+ delegationId: opts.delegation.delegationId,
124
+ actionType: 'commerce:create_checkout',
125
+ target: url,
126
+ method: 'POST',
127
+ session,
128
+ merchantName: opts.config.merchantName,
129
+ delegationChain: extractDelegationChain(opts.signedPassport),
130
+ beneficiary: opts.signedPassport.passport.metadata?.beneficiaryPrincipalId || 'unknown',
131
+ privateKey: opts.privateKey,
132
+ });
133
+ return { session, receipt };
134
+ }
135
+ // ── ACP Client: Update Checkout Session ──
136
+ export async function updateCheckout(opts) {
137
+ const url = `${opts.config.merchantBaseUrl}/checkout_sessions/${opts.sessionId}`;
138
+ const response = await fetch(url, {
139
+ method: 'PUT',
140
+ headers: {
141
+ 'Content-Type': 'application/json',
142
+ ...(opts.config.bearerToken && { 'Authorization': `Bearer ${opts.config.bearerToken}` }),
143
+ },
144
+ body: JSON.stringify({
145
+ ...(opts.updates.items && { items: opts.updates.items }),
146
+ ...(opts.updates.fulfillmentAddress && { fulfillment_address: opts.updates.fulfillmentAddress }),
147
+ ...(opts.updates.fulfillmentOptionId && { fulfillment_option_id: opts.updates.fulfillmentOptionId }),
148
+ }),
149
+ });
150
+ if (!response.ok) {
151
+ throw new Error(`ACP UpdateCheckout failed: ${response.status} ${response.statusText}`);
152
+ }
153
+ const session = await response.json();
154
+ const receipt = signCommerceReceipt({
155
+ agentId: opts.signedPassport.passport.agentId,
156
+ delegationId: opts.delegation.delegationId,
157
+ actionType: 'commerce:update_checkout',
158
+ target: url,
159
+ method: 'PUT',
160
+ session,
161
+ merchantName: opts.config.merchantName,
162
+ delegationChain: extractDelegationChain(opts.signedPassport),
163
+ beneficiary: opts.signedPassport.passport.metadata?.beneficiaryPrincipalId || 'unknown',
164
+ privateKey: opts.privateKey,
165
+ });
166
+ return { session, receipt };
167
+ }
168
+ // ── ACP Client: Complete Checkout (Payment) ──
169
+ export async function completeCheckout(opts) {
170
+ // Re-run preflight with actual total — fetch current session first
171
+ const getUrl = `${opts.config.merchantBaseUrl}/checkout_sessions/${opts.sessionId}`;
172
+ const getResponse = await fetch(getUrl, {
173
+ headers: opts.config.bearerToken ? { 'Authorization': `Bearer ${opts.config.bearerToken}` } : {},
174
+ });
175
+ if (!getResponse.ok) {
176
+ throw new Error(`ACP GetCheckout failed: ${getResponse.status}`);
177
+ }
178
+ const currentSession = await getResponse.json();
179
+ const total = currentSession.totals.total;
180
+ // Final preflight with real amount
181
+ const preflight = commercePreflight({
182
+ signedPassport: opts.signedPassport,
183
+ delegation: opts.delegation,
184
+ merchantName: opts.config.merchantName,
185
+ estimatedTotal: total,
186
+ });
187
+ if (!preflight.permitted) {
188
+ throw new Error(`Commerce preflight DENIED at payment: ${preflight.blockedReason}`);
189
+ }
190
+ // Check human approval threshold
191
+ if (opts.delegation.requireHumanApproval && opts.delegation.humanApprovalThreshold) {
192
+ if (total.amount > opts.delegation.humanApprovalThreshold) {
193
+ throw new Error(`HUMAN_APPROVAL_REQUIRED: Purchase of ${total.amount} ${total.currency} exceeds threshold of ${opts.delegation.humanApprovalThreshold}. ` +
194
+ `Use requestHumanApproval() to get confirmation before completing.`);
195
+ }
196
+ }
197
+ // Complete checkout via ACP
198
+ const url = `${opts.config.merchantBaseUrl}/checkout_sessions/${opts.sessionId}/complete`;
199
+ const response = await fetch(url, {
200
+ method: 'POST',
201
+ headers: {
202
+ 'Content-Type': 'application/json',
203
+ ...(opts.config.bearerToken && { 'Authorization': `Bearer ${opts.config.bearerToken}` }),
204
+ },
205
+ body: JSON.stringify({
206
+ payment_token: opts.paymentToken,
207
+ ...(opts.paymentMethod && { payment_method: opts.paymentMethod }),
208
+ }),
209
+ });
210
+ if (!response.ok) {
211
+ throw new Error(`ACP CompleteCheckout failed: ${response.status} ${response.statusText}`);
212
+ }
213
+ const session = await response.json();
214
+ // Update spend tracking on the delegation
215
+ const spendUpdated = {
216
+ ...opts.delegation,
217
+ spentAmount: opts.delegation.spentAmount + total.amount,
218
+ };
219
+ // Generate signed receipt with full purchase details
220
+ const receipt = signCommerceReceipt({
221
+ agentId: opts.signedPassport.passport.agentId,
222
+ delegationId: opts.delegation.delegationId,
223
+ actionType: 'commerce:complete_checkout',
224
+ target: url,
225
+ method: 'POST',
226
+ session,
227
+ merchantName: opts.config.merchantName,
228
+ delegationChain: extractDelegationChain(opts.signedPassport),
229
+ beneficiary: opts.signedPassport.passport.metadata?.beneficiaryPrincipalId || 'unknown',
230
+ privateKey: opts.privateKey,
231
+ });
232
+ return { session, receipt, spendUpdated };
233
+ }
234
+ // ── ACP Client: Cancel Checkout ──
235
+ export async function cancelCheckout(opts) {
236
+ const url = `${opts.config.merchantBaseUrl}/checkout_sessions/${opts.sessionId}/cancel`;
237
+ const response = await fetch(url, {
238
+ method: 'POST',
239
+ headers: {
240
+ 'Content-Type': 'application/json',
241
+ ...(opts.config.bearerToken && { 'Authorization': `Bearer ${opts.config.bearerToken}` }),
242
+ },
243
+ });
244
+ if (!response.ok) {
245
+ throw new Error(`ACP CancelCheckout failed: ${response.status} ${response.statusText}`);
246
+ }
247
+ const session = await response.json();
248
+ const receipt = signCommerceReceipt({
249
+ agentId: opts.signedPassport.passport.agentId,
250
+ delegationId: opts.delegation.delegationId,
251
+ actionType: 'commerce:cancel_checkout',
252
+ target: url,
253
+ method: 'POST',
254
+ session,
255
+ merchantName: opts.config.merchantName,
256
+ delegationChain: extractDelegationChain(opts.signedPassport),
257
+ beneficiary: opts.signedPassport.passport.metadata?.beneficiaryPrincipalId || 'unknown',
258
+ privateKey: opts.privateKey,
259
+ });
260
+ return { session, receipt };
261
+ }
262
+ // ── Human Approval Request ──
263
+ export function requestHumanApproval(opts) {
264
+ const now = new Date();
265
+ const expiresAt = new Date(now.getTime() + (opts.expiresInMinutes || 30) * 60 * 1000);
266
+ return {
267
+ requestId: `approval-${randomBytes(8).toString('hex')}`,
268
+ agentId: opts.agentId,
269
+ merchantName: opts.merchantName,
270
+ items: opts.items,
271
+ totalAmount: opts.totalAmount,
272
+ delegationId: opts.delegationId,
273
+ reason: opts.reason,
274
+ createdAt: now.toISOString(),
275
+ expiresAt: expiresAt.toISOString(),
276
+ status: 'pending',
277
+ };
278
+ }
279
+ // ── Commerce Receipt Signing ──
280
+ function signCommerceReceipt(opts) {
281
+ const receipt = {
282
+ receiptId: `rcpt-commerce-${randomBytes(8).toString('hex')}`,
283
+ version: '1.0',
284
+ timestamp: new Date().toISOString(),
285
+ agentId: opts.agentId,
286
+ delegationId: opts.delegationId,
287
+ action: {
288
+ type: opts.actionType,
289
+ target: opts.target,
290
+ method: opts.method,
291
+ scopeUsed: 'commerce:checkout',
292
+ spend: {
293
+ amount: opts.session.totals.total.amount,
294
+ currency: opts.session.totals.total.currency,
295
+ },
296
+ },
297
+ checkout: {
298
+ sessionId: opts.session.id,
299
+ merchantName: opts.merchantName,
300
+ items: opts.session.items.map(i => ({
301
+ skuId: i.skuId,
302
+ name: i.name,
303
+ quantity: i.quantity,
304
+ unitPrice: i.unitPrice.amount,
305
+ })),
306
+ totalAmount: opts.session.totals.total.amount,
307
+ totalCurrency: opts.session.totals.total.currency,
308
+ status: opts.session.status,
309
+ },
310
+ delegationChain: opts.delegationChain,
311
+ beneficiary: opts.beneficiary,
312
+ };
313
+ const payload = canonicalize(receipt);
314
+ const signature = sign(payload, opts.privateKey);
315
+ return { ...receipt, signature };
316
+ }
317
+ // ── Helpers ──
318
+ function extractDelegationChain(sp) {
319
+ const chain = [sp.passport.publicKey];
320
+ if (sp.passport.delegations) {
321
+ for (const d of sp.passport.delegations) {
322
+ if (!chain.includes(d.delegatedBy))
323
+ chain.push(d.delegatedBy);
324
+ }
325
+ }
326
+ return chain;
327
+ }
328
+ // ── Commerce Delegation Factory ──
329
+ export function createCommerceDelegation(opts) {
330
+ return {
331
+ agentId: opts.agentId,
332
+ delegationId: opts.delegationId,
333
+ scope: ['commerce:checkout', 'commerce:browse', ...(opts.additionalScopes || [])],
334
+ spendLimit: opts.spendLimit,
335
+ spentAmount: 0,
336
+ currency: opts.currency || 'usd',
337
+ approvedMerchants: opts.approvedMerchants,
338
+ requireHumanApproval: opts.requireHumanApproval ?? true,
339
+ humanApprovalThreshold: opts.humanApprovalThreshold,
340
+ };
341
+ }
342
+ // ── Spend Analytics ──
343
+ export function getSpendSummary(delegation) {
344
+ const remaining = delegation.spendLimit - delegation.spentAmount;
345
+ const utilization = delegation.spendLimit > 0
346
+ ? (delegation.spentAmount / delegation.spendLimit) * 100
347
+ : 0;
348
+ return {
349
+ limit: delegation.spendLimit,
350
+ spent: delegation.spentAmount,
351
+ remaining,
352
+ currency: delegation.currency,
353
+ utilizationPercent: Math.round(utilization * 100) / 100,
354
+ nearLimit: utilization >= 80,
355
+ };
356
+ }
357
+ // ── Verify Commerce Receipt ──
358
+ export function verifyCommerceReceipt(receipt, publicKey) {
359
+ const errors = [];
360
+ // Verify signature
361
+ const { signature, ...payload } = receipt;
362
+ const canonical = canonicalize(payload);
363
+ try {
364
+ const signatureValid = ed25519Verify(canonical, signature, publicKey);
365
+ if (!signatureValid) {
366
+ errors.push('Commerce receipt signature is invalid');
367
+ }
368
+ }
369
+ catch {
370
+ errors.push('Failed to verify commerce receipt signature');
371
+ }
372
+ // Verify required fields
373
+ if (!receipt.receiptId)
374
+ errors.push('Missing receiptId');
375
+ if (!receipt.agentId)
376
+ errors.push('Missing agentId');
377
+ if (!receipt.delegationId)
378
+ errors.push('Missing delegationId');
379
+ if (!receipt.action?.type)
380
+ errors.push('Missing action type');
381
+ if (!receipt.action?.scopeUsed)
382
+ errors.push('Missing scopeUsed');
383
+ if (!receipt.beneficiary)
384
+ errors.push('Missing beneficiary');
385
+ if (!receipt.checkout?.sessionId)
386
+ errors.push('Missing checkout sessionId');
387
+ return { valid: errors.length === 0, errors };
388
+ }
389
+ //# sourceMappingURL=commerce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commerce.js","sourceRoot":"","sources":["../../../src/core/commerce.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,6CAA6C;AAC7C,qEAAqE;AACrE,2EAA2E;AAC3E,EAAE;AACF,yDAAyD;AACzD,kEAAkE;AAClE,wEAAwE;AACxE,+DAA+D;AAC/D,4EAA4E;AAC5E,EAAE;AACF,yEAAyE;AACzE,kEAAkE;AAClE,qEAAqE;AAErE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAS1D,wBAAwB;AAExB,MAAM,eAAe,GAAG;IACtB,mBAAmB;IACnB,iBAAiB;IACjB,mBAAmB;IACnB,iBAAiB;CACT,CAAA;AAIV,SAAS,QAAQ,CAAC,UAA8B,EAAE,QAAuB;IACvE,OAAO,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAA;AACvF,CAAC;AAED,yCAAyC;AAEzC,MAAM,UAAU,iBAAiB,CAAC,IAMjC;IACC,MAAM,MAAM,GAA6B,EAAE,CAAA;IAC3C,MAAM,QAAQ,GAAa,EAAE,CAAA;IAE7B,gCAAgC;IAChC,MAAM,cAAc,GAAG,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;IAC1D,MAAM,CAAC,IAAI,CAAC;QACV,KAAK,EAAE,gBA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CAAC,OAAO,CAAC,MAAM,EAAE,IAAI;QAAE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;IAC7D,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS;QAAE,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAA;IAChE,IAAI,CAAC,OAAO,CAAC,WAAW;QAAE,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;IAC5D,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS;QAAE,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;IAE3E,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;AAC/C,CAAC"}
@@ -19,4 +19,6 @@ export { createTaskBrief, verifyTaskBrief, assignTask, acceptTask, submitEvidenc
19
19
  export type { CoordinationRole, TaskStatus, ReviewVerdict, TaskBrief, TaskRoleSpec, DeliverableSpec, TaskAssignment, EvidencePacket, EvidenceClaim, ReviewDecision, ReviewIssue, EvidenceHandoff, Deliverable, TaskCompletion, TaskMetrics, TaskUnit, } from './types/coordination.js';
20
20
  export { createActionIntent, verifyActionIntent, evaluateIntent, verifyPolicyDecision, createPolicyReceipt, verifyPolicyReceipt, FloorValidatorV1, requestAction, } from './core/policy.js';
21
21
  export type { ActionIntent, PolicyDecision, PolicyReceipt, PolicyVerdict, PrincipleEvaluation, PolicyValidator, ValidationContext, PolicyEvaluationResult, } from './types/policy.js';
22
+ export { commercePreflight, createCheckout, updateCheckout, completeCheckout, cancelCheckout, requestHumanApproval, createCommerceDelegation, getSpendSummary, verifyCommerceReceipt, } from './core/commerce.js';
23
+ export type { ACPCheckoutSession, ACPLineItem, ACPMoney, ACPTotals, ACPFulfillment, ACPFulfillmentOption, ACPPaymentMethod, ACPCustomer, ACPAddress, ACPOrderEvent, CommerceConfig, CommerceDelegation, CommercePreflightResult, CommercePreflightCheck, CommerceActionReceipt, HumanApprovalRequest, } from './types/commerce.js';
22
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,kBAAkB,EAAE,oBAAoB,EACxC,QAAQ,EAAE,UAAU,EACpB,kBAAkB,EAAE,eAAe,EACpC,MAAM,eAAe,CAAA;AAEtB,YAAY,EACV,WAAW,EAAE,mBAAmB,EAAE,iBAAiB,EACnD,eAAe,EAAE,WAAW,EAAE,iBAAiB,EAChD,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAI1F,OAAO,EACL,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAC/C,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,aAAa,EAAE,aAAa,EAC3C,cAAc,EAAE,aAAa,EAAE,YAAY,EAC3C,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,aAAa,EAAE,WAAW,EACxC,MAAM,sBAAsB,CAAA;AAG7B,OAAO,EACL,SAAS,EAAE,iBAAiB,EAC5B,WAAW,EAAE,iBAAiB,EAC9B,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,kBAAkB,EAAE,uBAAuB,EAC3C,eAAe,EAAE,mBAAmB,EAAE,iBAAiB,EACvD,+BAA+B,EAC/B,q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3C,SAAS,EAAE,YAAY,EAAE,eAAe,EACxC,cAAc,EAAE,cAAc,EAAE,aAAa,EAC7C,cAAc,EAAE,WAAW,EAC3B,eAAe,EAAE,WAAW,EAC5B,cAAc,EAAE,WAAW,EAAE,QAAQ,GACtC,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EACL,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,oBAAoB,EACpC,mBAAmB,EAAE,mBAAmB,EACxC,gBAAgB,EAChB,aAAa,GACd,MAAM,kBAAkB,CAAA;AAEzB,YAAY,EACV,YAAY,EAAE,cAAc,EAAE,aAAa,EAC3C,aAAa,EAAE,mBAAmB,EAClC,eAAe,EAAE,iBAAiB,EAAE,sBAAsB,GAC3D,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EACL,iBAAiB,EACjB,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAChE,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,GACtB,MAAM,oBAAoB,CAAA;AAE3B,YAAY,EACV,kBAAkB,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EACpD,cAAc,EAAE,oBAAoB,EAAE,gBAAgB,EACtD,WAAW,EAAE,UAAU,EAAE,aAAa,EACtC,cAAc,EAAE,kBAAkB,EAClC,uBAAuB,EAAE,sBAAsB,EAC/C,qBAAqB,EAAE,oBAAoB,GAC5C,MAAM,qBAAqB,CAAA"}
package/dist/src/index.js CHANGED
@@ -33,4 +33,6 @@ export { assignRole, createTradeoffRule, evaluateTradeoff, createIntentDocument,
33
33
  export { createTaskBrief, verifyTaskBrief, assignTask, acceptTask, submitEvidence, verifyEvidence, reviewEvidence, verifyReview, handoffEvidence, verifyHandoff, submitDeliverable, verifyDeliverable, completeTask, verifyCompletion, createTaskUnit, getTaskStatus, validateTaskUnit, } from './core/coordination.js';
34
34
  // ── Values Floor Policy Engine ──
35
35
  export { createActionIntent, verifyActionIntent, evaluateIntent, verifyPolicyDecision, createPolicyReceipt, verifyPolicyReceipt, FloorValidatorV1, requestAction, } from './core/policy.js';
36
+ // ── Layer 7: Agentic Commerce (ACP) ──
37
+ export { commercePreflight, createCheckout, updateCheckout, completeCheckout, cancelCheckout, requestHumanApproval, createCommerceDelegation, getSpendSummary, verifyCommerceReceipt, } from './core/commerce.js';
36
38
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,6DAA6D;AAC7D,EAAE;AACF,+BAA+B;AAC/B,8DAA8D;AAC9D,mDAAmD;AACnD,8CAA8C;AAC9C,2DAA2D;AAC3D,sEAAsE;AACtE,4DAA4D;AAC5D,EAAE;AACF,8DAA8D;AAE9D,yCAAyC;AACzC,OAAO,EACL,kBAAkB,EAAE,oBAAoB,EACxC,QAAQ,EAAE,UAAU,EACpB,kBAAkB,EAAE,eAAe,EACpC,MAAM,eAAe,CAAA;AAOtB,2CAA2C;AAC3C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACtF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAE1F,0CAA0C;AAC1C,gEAAgE;AAChE,OAAO,EACL,gBAAgB,EAAE,WAAW,EAAE,gBAAgB,EAC/C,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,aAAa,EAAE,aAAa,EAC3C,cAAc,EAAE,aAAa,EAAE,YAAY,EAC3C,aAAa,EAAE,aAAa,EAC5B,WAAW,EAAE,aAAa,E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B,EAAE,iBAAiB,EACvD,+BAA+B,EAC/B,qBAAqB,EACtB,MAAM,uBAAuB,CAAA;AAE9B,6CAA6C;AAC7C,OAAO,EACL,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EACvE,cAAc,EAAE,aAAa,EAAE,UAAU,EAC1C,MAAM,iBAAiB,CAAA;AA8BxB,qCAAqC;AACrC,OAAO,EACL,UAAU,EACV,kBAAkB,EAAE,gBAAgB,EACpC,oBAAoB,EACpB,kBAAkB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,mBAAmB,EAChF,oBAAoB,EAAE,aAAa,EACnC,6BAA6B,GAC9B,MAAM,kBAAkB,CAAA;AAczB,yCAAyC;AACzC,OAAO,EACL,eAAe,EAAE,eAAe,EAChC,UAAU,EAAE,UAAU,EACtB,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,YAAY,EAC5B,eAAe,EAAE,aAAa,EAC9B,iBAAiB,EAAE,iBAAiB,EACpC,YAAY,EAAE,gBAAgB,EAC9B,cAAc,EAAE,aAAa,EAAE,gBAAgB,GAChD,MAAM,wBAAwB,CAAA;AAW/B,mCAAmC;AACnC,OAAO,EACL,kBAAkB,EAAE,kBAAkB,EACtC,cAAc,EAAE,oBAAoB,EACpC,mBAAmB,EAAE,mBAAmB,EACxC,gBAAgB,EAChB,aAAa,GACd,MAAM,kBAAkB,CAAA;AAQzB,wCAAwC;AACxC,OAAO,EACL,iBAAiB,EACjB,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAChE,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,qBAAqB,GACtB,MAAM,oBAAoB,CAAA"}
@@ -0,0 +1,151 @@
1
+ export interface ACPCheckoutSession {
2
+ id: string;
3
+ status: 'open' | 'completed' | 'cancelled' | 'expired';
4
+ items: ACPLineItem[];
5
+ totals: ACPTotals;
6
+ fulfillment?: ACPFulfillment;
7
+ fulfillmentOptions?: ACPFulfillmentOption[];
8
+ paymentMethods?: ACPPaymentMethod[];
9
+ customer?: ACPCustomer;
10
+ metadata?: Record<string, unknown>;
11
+ createdAt: string;
12
+ updatedAt: string;
13
+ }
14
+ export interface ACPLineItem {
15
+ id: string;
16
+ skuId: string;
17
+ name: string;
18
+ description?: string;
19
+ quantity: number;
20
+ unitPrice: ACPMoney;
21
+ totalPrice: ACPMoney;
22
+ imageUrl?: string;
23
+ productUrl?: string;
24
+ }
25
+ export interface ACPMoney {
26
+ amount: number;
27
+ currency: string;
28
+ }
29
+ export interface ACPTotals {
30
+ subtotal: ACPMoney;
31
+ tax?: ACPMoney;
32
+ shipping?: ACPMoney;
33
+ discount?: ACPMoney;
34
+ total: ACPMoney;
35
+ }
36
+ export interface ACPFulfillment {
37
+ type: 'shipping' | 'pickup' | 'digital';
38
+ address?: ACPAddress;
39
+ optionId?: string;
40
+ }
41
+ export interface ACPFulfillmentOption {
42
+ id: string;
43
+ name: string;
44
+ description?: string;
45
+ price: ACPMoney;
46
+ estimatedDelivery?: string;
47
+ }
48
+ export interface ACPPaymentMethod {
49
+ type: 'shared_payment_token' | 'card' | 'link' | string;
50
+ id?: string;
51
+ }
52
+ export interface ACPCustomer {
53
+ name?: string;
54
+ email?: string;
55
+ phone?: string;
56
+ }
57
+ export interface ACPAddress {
58
+ name?: string;
59
+ lineOne: string;
60
+ lineTwo?: string;
61
+ city: string;
62
+ state?: string;
63
+ country: string;
64
+ postalCode: string;
65
+ }
66
+ export interface ACPOrderEvent {
67
+ eventId: string;
68
+ type: 'order.created' | 'order.updated' | 'order.shipped' | 'order.delivered' | 'order.cancelled';
69
+ checkoutSessionId: string;
70
+ orderId: string;
71
+ timestamp: string;
72
+ data: Record<string, unknown>;
73
+ }
74
+ export interface CommerceConfig {
75
+ merchantBaseUrl: string;
76
+ merchantName: string;
77
+ bearerToken?: string;
78
+ webhookUrl?: string;
79
+ webhookSecret?: string;
80
+ defaultCurrency?: string;
81
+ }
82
+ export interface CommerceDelegation {
83
+ agentId: string;
84
+ delegationId: string;
85
+ scope: string[];
86
+ spendLimit: number;
87
+ spentAmount: number;
88
+ currency: string;
89
+ approvedMerchants?: string[];
90
+ requireHumanApproval?: boolean;
91
+ humanApprovalThreshold?: number;
92
+ }
93
+ export interface CommercePreflightResult {
94
+ permitted: boolean;
95
+ checks: CommercePreflightCheck[];
96
+ delegation?: CommerceDelegation;
97
+ warnings: string[];
98
+ blockedReason?: string;
99
+ }
100
+ export interface CommercePreflightCheck {
101
+ check: string;
102
+ passed: boolean;
103
+ detail: string;
104
+ }
105
+ export interface CommerceActionReceipt {
106
+ receiptId: string;
107
+ version: string;
108
+ timestamp: string;
109
+ agentId: string;
110
+ delegationId: string;
111
+ action: {
112
+ type: 'commerce:create_checkout' | 'commerce:update_checkout' | 'commerce:complete_checkout' | 'commerce:cancel_checkout';
113
+ target: string;
114
+ method: string;
115
+ scopeUsed: string;
116
+ spend: {
117
+ amount: number;
118
+ currency: string;
119
+ };
120
+ };
121
+ checkout: {
122
+ sessionId: string;
123
+ merchantName: string;
124
+ items: {
125
+ skuId: string;
126
+ name: string;
127
+ quantity: number;
128
+ unitPrice: number;
129
+ }[];
130
+ totalAmount: number;
131
+ totalCurrency: string;
132
+ status: string;
133
+ };
134
+ delegationChain: string[];
135
+ beneficiary: string;
136
+ valuesFloorVersion?: string;
137
+ signature: string;
138
+ }
139
+ export interface HumanApprovalRequest {
140
+ requestId: string;
141
+ agentId: string;
142
+ merchantName: string;
143
+ items: ACPLineItem[];
144
+ totalAmount: ACPMoney;
145
+ delegationId: string;
146
+ reason: string;
147
+ createdAt: string;
148
+ expiresAt: string;
149
+ status: 'pending' | 'approved' | 'denied';
150
+ }
151
+ //# sourceMappingURL=commerce.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commerce.d.ts","sourceRoot":"","sources":["../../../src/types/commerce.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,kBAAkB;IACjC,EAAE,EA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AE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;QAC7E,WAAW,EAAE,MAAM,CAAA;QACnB,aAAa,EAAE,MAAM,CAAA;QACrB,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IACD,eAAe,EAAE,MAAM,EAAE,CAAA;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,WAAW,EAAE,CAAA;IACpB,WAAW,EAAE,QAAQ,CAAA;IACrB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAA;CAC1C"}
@@ -0,0 +1,9 @@
1
+ // ══════════════════════════════════════════════════════════════════
2
+ // Layer 7 — Agentic Commerce: Type Definitions
3
+ // ══════════════════════════════════════════════════════════════════
4
+ // Integration with the Agentic Commerce Protocol (ACP) by OpenAI + Stripe.
5
+ // Every commerce action is passport-verified, delegation-scoped,
6
+ // spend-limited, and produces signed ActionReceipts.
7
+ // ══════════════════════════════════════════════════════════════════
8
+ export {};
9
+ //# sourceMappingURL=commerce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commerce.js","sourceRoot":"","sources":["../../../src/types/commerce.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,+CAA+C;AAC/C,qEAAqE;AACrE,2EAA2E;AAC3E,iEAAiE;AACjE,qDAAqD;AACrD,qEAAqE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-passport-system",
3
- "version": "1.5.0",
4
- "description": "The Agent Social Contract — cryptographic identity, ethical governance, beneficiary attribution, and protocol-native communication for autonomous AI agents.",
3
+ "version": "1.6.0",
4
+ "description": "The Agent Social Contract — cryptographic identity, ethical governance, beneficiary attribution, protocol-native communication, and agentic commerce for autonomous AI agents.",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",
7
7
  "types": "dist/src/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "scripts": {
18
18
  "build": "tsc && chmod +x dist/src/cli/index.js",
19
- "test": "tsx --test tests/passport.test.ts tests/v1.1-integration.ts tests/adversarial.ts tests/v2.0-integration.ts tests/contract.test.ts tests/agora.test.ts tests/values.test.ts tests/delegation.test.ts tests/attribution.test.ts tests/policy.test.ts tests/cascade.test.ts tests/coordination.test.ts",
19
+ "test": "tsx --test tests/passport.test.ts tests/v1.1-integration.ts tests/adversarial.ts tests/v2.0-integration.ts tests/contract.test.ts tests/agora.test.ts tests/values.test.ts tests/delegation.test.ts tests/attribution.test.ts tests/policy.test.ts tests/cascade.test.ts tests/coordination.test.ts tests/commerce.test.ts",
20
20
  "test:quick": "tsx --test tests/passport.test.ts",
21
21
  "lint": "tsc --noEmit",
22
22
  "clean": "rm -rf dist",