@peac/mappings-acp 0.12.5 → 0.12.6

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 (2) hide show
  1. package/README.md +125 -3
  2. package/package.json +20 -7
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @peac/mappings-acp
2
2
 
3
- Agentic Commerce Protocol (ACP) integration for PEAC
3
+ Agentic Commerce Protocol (ACP) session lifecycle and payment observation mapping for PEAC evidence.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,9 +8,131 @@ Agentic Commerce Protocol (ACP) integration for PEAC
8
8
  pnpm add @peac/mappings-acp
9
9
  ```
10
10
 
11
- ## Documentation
11
+ ## What It Does
12
12
 
13
- See [peacprotocol.org](https://www.peacprotocol.org) for full documentation.
13
+ `@peac/mappings-acp` maps Agentic Commerce Protocol (ACP) session events and payment observations to PEAC evidence in the Interaction Record format. It enforces a strict boundary between session lifecycle evidence (access-kind) and commerce evidence (payment-kind): an ACP session reaching "completed" does NOT prove payment settlement. Commerce evidence is only produced when an explicit payment-bearing artifact with a known observed payment state is provided by the caller.
14
+
15
+ ## How Do I Use It?
16
+
17
+ ### Record a session lifecycle event
18
+
19
+ ```typescript
20
+ import { fromACPSessionLifecycleEvent } from '@peac/mappings-acp';
21
+ import type { ACPSessionEvent } from '@peac/mappings-acp';
22
+
23
+ const event: ACPSessionEvent = {
24
+ session_id: 'sess_abc123',
25
+ state: 'completed',
26
+ resource_uri: 'https://api.example.com/v1/resource',
27
+ };
28
+
29
+ // Produces access evidence only; never commerce evidence
30
+ const receiptInput = fromACPSessionLifecycleEvent(event);
31
+ console.log(receiptInput.subject_uri); // 'https://api.example.com/v1/resource'
32
+ // receiptInput is ready to pass to issue()
33
+ ```
34
+
35
+ ### Record a payment observation with explicit payment artifact
36
+
37
+ ```typescript
38
+ import { fromACPPaymentObservation } from '@peac/mappings-acp';
39
+ import type { ACPSessionEvent, ACPPaymentArtifact } from '@peac/mappings-acp';
40
+
41
+ const event: ACPSessionEvent = {
42
+ session_id: 'sess_abc123',
43
+ state: 'completed',
44
+ resource_uri: 'https://api.example.com/v1/resource',
45
+ };
46
+
47
+ const paymentArtifact: ACPPaymentArtifact = {
48
+ rail: 'stripe',
49
+ reference: 'pi_xyz789',
50
+ amount: 1500,
51
+ currency: 'USD',
52
+ observed_payment_state: 'captured',
53
+ };
54
+
55
+ // Commerce evidence: derived from the payment artifact, not session state
56
+ const receiptInput = fromACPPaymentObservation(event, paymentArtifact);
57
+ console.log(receiptInput.payment.rail); // 'stripe'
58
+ console.log(receiptInput.amt); // 1500
59
+ ```
60
+
61
+ ### Record capability negotiations and interventions
62
+
63
+ ```typescript
64
+ import { fromACPCapabilitySnapshot, fromACPInterventionRequired } from '@peac/mappings-acp';
65
+ import type { ACPCapabilityNegotiation, ACPIntervention } from '@peac/mappings-acp';
66
+
67
+ const capabilities: ACPCapabilityNegotiation = {
68
+ session_id: 'sess_abc123',
69
+ seller_capabilities: { streaming: true },
70
+ buyer_capabilities: { maxBudget: 5000 },
71
+ };
72
+ const capInput = fromACPCapabilitySnapshot(capabilities);
73
+
74
+ const intervention: ACPIntervention = {
75
+ session_id: 'sess_abc123',
76
+ resource_uri: 'https://api.example.com/v1/resource',
77
+ type: 'human_approval',
78
+ reason: 'Amount exceeds automatic threshold',
79
+ };
80
+ const interventionInput = fromACPInterventionRequired(intervention);
81
+ ```
82
+
83
+ ### Enforce agent budget limits
84
+
85
+ ```typescript
86
+ import { checkBudget } from '@peac/mappings-acp';
87
+ import type { BudgetConfig } from '@peac/mappings-acp';
88
+
89
+ const config: BudgetConfig = {
90
+ maxPerCallMinor: 50000n, // 500.00 USD max per checkout
91
+ maxDailyMinor: 1000000n, // 10,000.00 USD max per day
92
+ currency: 'USD',
93
+ };
94
+
95
+ const result = checkBudget(850000n, 100000n, 'USD', config);
96
+ if (result.allowed) {
97
+ console.log(`Allowed. Remaining: ${result.remainingMinor}`);
98
+ } else {
99
+ console.log(`Denied: ${result.reason}`);
100
+ }
101
+ ```
102
+
103
+ ### Carry evidence via HTTP headers
104
+
105
+ ```typescript
106
+ import {
107
+ attachCarrierToACPHeaders,
108
+ extractCarrierFromACPHeaders,
109
+ AcpCarrierAdapter,
110
+ } from '@peac/mappings-acp';
111
+
112
+ // Attach a signed receipt to outgoing ACP headers
113
+ const headers = attachCarrierToACPHeaders({}, receiptJws);
114
+
115
+ // Extract from incoming headers
116
+ const result = extractCarrierFromACPHeaders(incomingHeaders);
117
+ if (result) {
118
+ console.log(result.receiptJws);
119
+ console.log(result.receiptRef);
120
+ }
121
+
122
+ // Or use the CarrierAdapter for transport-agnostic integration
123
+ const adapter = new AcpCarrierAdapter();
124
+ ```
125
+
126
+ ## Integrates With
127
+
128
+ - `@peac/kernel` (Layer 0): Core types and constants
129
+ - `@peac/schema` (Layer 1): Zod validators and commerce extension schemas
130
+ - `@peac/protocol` (Layer 3): Receipt issuance using mapped evidence
131
+ - `@peac/mappings-paymentauth` (Layer 4): Complementary paymentauth header mapping
132
+
133
+ ## For Agent Developers
134
+
135
+ If you are building an AI agent that participates in ACP checkout flows: use `fromACPSessionLifecycleEvent` to record session state transitions as access evidence, and `fromACPPaymentObservation` only when you have an explicit payment artifact proving a specific payment state. The `checkBudget` utility provides pure, deterministic budget enforcement for agent spending limits. Use `AcpCarrierAdapter` to carry signed evidence across HTTP boundaries between agents and ACP services.
14
136
 
15
137
  ## License
16
138
 
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@peac/mappings-acp",
3
- "version": "0.12.5",
3
+ "version": "0.12.6",
4
4
  "description": "Agentic Commerce Protocol (ACP) integration for PEAC",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "https://github.com/peacprotocol/peac.git",
9
+ "url": "git+https://github.com/peacprotocol/peac.git",
10
10
  "directory": "packages/mappings/acp"
11
11
  },
12
- "author": "jithinraj <7850727+jithinraj@users.noreply.github.com>",
12
+ "author": "PEAC Protocol Contributors",
13
13
  "license": "Apache-2.0",
14
14
  "bugs": {
15
15
  "url": "https://github.com/peacprotocol/peac/issues"
@@ -23,16 +23,29 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@peac/kernel": "0.12.5",
27
- "@peac/schema": "0.12.5",
28
- "@peac/protocol": "0.12.5"
26
+ "@peac/kernel": "0.12.6",
27
+ "@peac/schema": "0.12.6",
28
+ "@peac/protocol": "0.12.6"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^22.19.11",
32
32
  "typescript": "^5.3.3",
33
33
  "vitest": "^4.0.0",
34
- "@peac/crypto": "0.12.5"
34
+ "@peac/crypto": "0.12.6"
35
35
  },
36
+ "keywords": [
37
+ "peac",
38
+ "peacprotocol",
39
+ "interaction-records",
40
+ "signed-records",
41
+ "receipts",
42
+ "originary",
43
+ "acp",
44
+ "agentic-commerce",
45
+ "checkout",
46
+ "payment-observation",
47
+ "session-lifecycle"
48
+ ],
36
49
  "scripts": {
37
50
  "build": "tsc",
38
51
  "test": "vitest run",