xytara 1.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.
- package/.env.example +3 -0
- package/LICENSE +201 -0
- package/README.md +257 -0
- package/adapters/AUTHORING_GUIDE.md +89 -0
- package/adapters/ONBOARDING_POSTURE.md +39 -0
- package/adapters/adapter-manifest.schema.json +209 -0
- package/adapters/examples/example-execution-adapter.js +61 -0
- package/adapters/examples/example-execution-adapter.manifest.json +62 -0
- package/adapters/examples/example-settlement-adapter.js +55 -0
- package/adapters/examples/example-settlement-adapter.manifest.json +59 -0
- package/adapters/interfaces.js +56 -0
- package/client.js +3 -0
- package/fixtures/catalog.js +728 -0
- package/index.js +25 -0
- package/lib/catalog_contract.js +141 -0
- package/lib/catalog_views.js +36 -0
- package/lib/command_flow.js +42 -0
- package/lib/commerce_artifacts.js +294 -0
- package/lib/commerce_cases.js +303 -0
- package/lib/commerce_client.js +5373 -0
- package/lib/commerce_quotes.js +113 -0
- package/lib/commerce_reports.js +14315 -0
- package/lib/commerce_runtime.js +215 -0
- package/lib/http_transport.js +40 -0
- package/lib/record_queries.js +47 -0
- package/lib/resource_views.js +31 -0
- package/lib/route_matchers.js +34 -0
- package/lib/route_params.js +19 -0
- package/package.json +55 -0
- package/server.js +626 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "xytara/adapter-manifest.schema.json",
|
|
4
|
+
"title": "xytara Adapter Manifest",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": [
|
|
8
|
+
"adapter_id",
|
|
9
|
+
"adapter_class",
|
|
10
|
+
"adapter_version",
|
|
11
|
+
"interface_version",
|
|
12
|
+
"display_name",
|
|
13
|
+
"description",
|
|
14
|
+
"capabilities",
|
|
15
|
+
"compatibility",
|
|
16
|
+
"health_contract",
|
|
17
|
+
"idempotency_contract",
|
|
18
|
+
"failure_contract",
|
|
19
|
+
"proof_contract"
|
|
20
|
+
],
|
|
21
|
+
"properties": {
|
|
22
|
+
"adapter_id": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"minLength": 1
|
|
25
|
+
},
|
|
26
|
+
"adapter_class": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"enum": [
|
|
29
|
+
"execution_adapter",
|
|
30
|
+
"payment_rail_adapter",
|
|
31
|
+
"settlement_adapter",
|
|
32
|
+
"agent_protocol_adapter",
|
|
33
|
+
"identity_registry_adapter"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"adapter_version": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"minLength": 1
|
|
39
|
+
},
|
|
40
|
+
"interface_version": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"minLength": 1
|
|
43
|
+
},
|
|
44
|
+
"display_name": {
|
|
45
|
+
"type": "string",
|
|
46
|
+
"minLength": 1
|
|
47
|
+
},
|
|
48
|
+
"description": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"minLength": 1
|
|
51
|
+
},
|
|
52
|
+
"capabilities": {
|
|
53
|
+
"type": "array",
|
|
54
|
+
"minItems": 1,
|
|
55
|
+
"items": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"minLength": 1
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"compatibility": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"additionalProperties": false,
|
|
63
|
+
"required": [
|
|
64
|
+
"node",
|
|
65
|
+
"commerce_contract",
|
|
66
|
+
"proof_contract"
|
|
67
|
+
],
|
|
68
|
+
"properties": {
|
|
69
|
+
"node": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"minLength": 1
|
|
72
|
+
},
|
|
73
|
+
"commerce_contract": {
|
|
74
|
+
"type": "string",
|
|
75
|
+
"minLength": 1
|
|
76
|
+
},
|
|
77
|
+
"proof_contract": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"minLength": 1
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"health_contract": {
|
|
84
|
+
"type": "object",
|
|
85
|
+
"additionalProperties": false,
|
|
86
|
+
"required": [
|
|
87
|
+
"check_kind",
|
|
88
|
+
"supports_readiness"
|
|
89
|
+
],
|
|
90
|
+
"properties": {
|
|
91
|
+
"check_kind": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"minLength": 1
|
|
94
|
+
},
|
|
95
|
+
"supports_readiness": {
|
|
96
|
+
"type": "boolean"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"idempotency_contract": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"additionalProperties": false,
|
|
103
|
+
"required": [
|
|
104
|
+
"strategy",
|
|
105
|
+
"scope"
|
|
106
|
+
],
|
|
107
|
+
"properties": {
|
|
108
|
+
"strategy": {
|
|
109
|
+
"type": "string",
|
|
110
|
+
"minLength": 1
|
|
111
|
+
},
|
|
112
|
+
"scope": {
|
|
113
|
+
"type": "string",
|
|
114
|
+
"minLength": 1
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"failure_contract": {
|
|
119
|
+
"type": "object",
|
|
120
|
+
"additionalProperties": false,
|
|
121
|
+
"required": [
|
|
122
|
+
"categories",
|
|
123
|
+
"retryable_categories"
|
|
124
|
+
],
|
|
125
|
+
"properties": {
|
|
126
|
+
"categories": {
|
|
127
|
+
"type": "array",
|
|
128
|
+
"minItems": 1,
|
|
129
|
+
"items": {
|
|
130
|
+
"type": "string",
|
|
131
|
+
"minLength": 1
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"retryable_categories": {
|
|
135
|
+
"type": "array",
|
|
136
|
+
"items": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"minLength": 1
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"proof_contract": {
|
|
144
|
+
"type": "object",
|
|
145
|
+
"additionalProperties": false,
|
|
146
|
+
"required": [
|
|
147
|
+
"emits_proof_compatible_facts",
|
|
148
|
+
"proof_mode"
|
|
149
|
+
],
|
|
150
|
+
"properties": {
|
|
151
|
+
"emits_proof_compatible_facts": {
|
|
152
|
+
"type": "boolean"
|
|
153
|
+
},
|
|
154
|
+
"proof_mode": {
|
|
155
|
+
"type": "string",
|
|
156
|
+
"minLength": 1
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"latency_class": {
|
|
161
|
+
"type": "string"
|
|
162
|
+
},
|
|
163
|
+
"pricing_basis": {
|
|
164
|
+
"type": "string"
|
|
165
|
+
},
|
|
166
|
+
"execution_modes": {
|
|
167
|
+
"type": "array",
|
|
168
|
+
"items": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"minLength": 1
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"required_secrets": {
|
|
174
|
+
"type": "array",
|
|
175
|
+
"items": {
|
|
176
|
+
"type": "string",
|
|
177
|
+
"minLength": 1
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
"required_permissions": {
|
|
181
|
+
"type": "array",
|
|
182
|
+
"items": {
|
|
183
|
+
"type": "string",
|
|
184
|
+
"minLength": 1
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
"supported_profiles": {
|
|
188
|
+
"type": "array",
|
|
189
|
+
"items": {
|
|
190
|
+
"type": "string",
|
|
191
|
+
"minLength": 1
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
"supported_regions": {
|
|
195
|
+
"type": "array",
|
|
196
|
+
"items": {
|
|
197
|
+
"type": "string",
|
|
198
|
+
"minLength": 1
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"supported_settlement_modes": {
|
|
202
|
+
"type": "array",
|
|
203
|
+
"items": {
|
|
204
|
+
"type": "string",
|
|
205
|
+
"minLength": 1
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const manifest = JSON.parse(
|
|
7
|
+
fs.readFileSync(path.resolve(__dirname, "example-execution-adapter.manifest.json"), "utf8")
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
async function getHealth() {
|
|
11
|
+
return {
|
|
12
|
+
status: "ok",
|
|
13
|
+
readiness: "ready",
|
|
14
|
+
adapter_id: manifest.adapter_id
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function describeCapabilities() {
|
|
19
|
+
return {
|
|
20
|
+
adapter_id: manifest.adapter_id,
|
|
21
|
+
adapter_class: manifest.adapter_class,
|
|
22
|
+
capabilities: manifest.capabilities.slice(),
|
|
23
|
+
execution_modes: Array.isArray(manifest.execution_modes) ? manifest.execution_modes.slice() : []
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function preview(request) {
|
|
28
|
+
return {
|
|
29
|
+
adapter_id: manifest.adapter_id,
|
|
30
|
+
accepted: true,
|
|
31
|
+
preview: {
|
|
32
|
+
task_ref: request && request.task_ref ? request.task_ref : "example.task",
|
|
33
|
+
mode: "preview",
|
|
34
|
+
echoed_body: request && request.body ? request.body : {}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function execute(request) {
|
|
40
|
+
return {
|
|
41
|
+
adapter_id: manifest.adapter_id,
|
|
42
|
+
status: "completed",
|
|
43
|
+
result: {
|
|
44
|
+
task_ref: request && request.task_ref ? request.task_ref : "example.task",
|
|
45
|
+
mode: "execute",
|
|
46
|
+
echoed_body: request && request.body ? request.body : {}
|
|
47
|
+
},
|
|
48
|
+
proof_facts: {
|
|
49
|
+
emits_proof_compatible_facts: manifest.proof_contract.emits_proof_compatible_facts,
|
|
50
|
+
proof_mode: manifest.proof_contract.proof_mode
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = {
|
|
56
|
+
manifest,
|
|
57
|
+
getHealth,
|
|
58
|
+
describeCapabilities,
|
|
59
|
+
preview,
|
|
60
|
+
execute
|
|
61
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"adapter_id": "example.execution.echo",
|
|
3
|
+
"adapter_class": "execution_adapter",
|
|
4
|
+
"adapter_version": "1.0.0",
|
|
5
|
+
"interface_version": "commerce-adapter-interface/v1",
|
|
6
|
+
"display_name": "Example Echo Execution Adapter",
|
|
7
|
+
"description": "Reference execution adapter manifest used to validate adapter contract shape.",
|
|
8
|
+
"capabilities": [
|
|
9
|
+
"task.execute",
|
|
10
|
+
"task.validate",
|
|
11
|
+
"task.preview"
|
|
12
|
+
],
|
|
13
|
+
"compatibility": {
|
|
14
|
+
"node": ">=18",
|
|
15
|
+
"commerce_contract": "commerce-repo-final-contract/v1",
|
|
16
|
+
"proof_contract": "proof-repo-final-contract/v1"
|
|
17
|
+
},
|
|
18
|
+
"health_contract": {
|
|
19
|
+
"check_kind": "self_reported",
|
|
20
|
+
"supports_readiness": true
|
|
21
|
+
},
|
|
22
|
+
"idempotency_contract": {
|
|
23
|
+
"strategy": "caller_supplied_key",
|
|
24
|
+
"scope": "task_execution"
|
|
25
|
+
},
|
|
26
|
+
"failure_contract": {
|
|
27
|
+
"categories": [
|
|
28
|
+
"invalid_input",
|
|
29
|
+
"timeout",
|
|
30
|
+
"upstream_unavailable"
|
|
31
|
+
],
|
|
32
|
+
"retryable_categories": [
|
|
33
|
+
"timeout",
|
|
34
|
+
"upstream_unavailable"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"proof_contract": {
|
|
38
|
+
"emits_proof_compatible_facts": true,
|
|
39
|
+
"proof_mode": "execution_facts_only"
|
|
40
|
+
},
|
|
41
|
+
"latency_class": "interactive",
|
|
42
|
+
"pricing_basis": "per_task",
|
|
43
|
+
"execution_modes": [
|
|
44
|
+
"sync",
|
|
45
|
+
"waited"
|
|
46
|
+
],
|
|
47
|
+
"required_secrets": [
|
|
48
|
+
"EXAMPLE_EXECUTION_TOKEN"
|
|
49
|
+
],
|
|
50
|
+
"required_permissions": [
|
|
51
|
+
"network:outbound"
|
|
52
|
+
],
|
|
53
|
+
"supported_profiles": [
|
|
54
|
+
"default"
|
|
55
|
+
],
|
|
56
|
+
"supported_regions": [
|
|
57
|
+
"global"
|
|
58
|
+
],
|
|
59
|
+
"supported_settlement_modes": [
|
|
60
|
+
"none"
|
|
61
|
+
]
|
|
62
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
|
|
6
|
+
const manifest = JSON.parse(
|
|
7
|
+
fs.readFileSync(path.resolve(__dirname, "example-settlement-adapter.manifest.json"), "utf8")
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
async function getHealth() {
|
|
11
|
+
return {
|
|
12
|
+
status: "ok",
|
|
13
|
+
readiness: "ready",
|
|
14
|
+
adapter_id: manifest.adapter_id
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function describeCapabilities() {
|
|
19
|
+
return {
|
|
20
|
+
adapter_id: manifest.adapter_id,
|
|
21
|
+
adapter_class: manifest.adapter_class,
|
|
22
|
+
capabilities: manifest.capabilities.slice(),
|
|
23
|
+
supported_settlement_modes: Array.isArray(manifest.supported_settlement_modes)
|
|
24
|
+
? manifest.supported_settlement_modes.slice()
|
|
25
|
+
: []
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function settle(request) {
|
|
30
|
+
return {
|
|
31
|
+
adapter_id: manifest.adapter_id,
|
|
32
|
+
status: "submitted",
|
|
33
|
+
settlement_ref: `anchor://${request && request.intent_id ? request.intent_id : "demo-intent"}`,
|
|
34
|
+
proof_facts: {
|
|
35
|
+
emits_proof_compatible_facts: manifest.proof_contract.emits_proof_compatible_facts,
|
|
36
|
+
proof_mode: manifest.proof_contract.proof_mode
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function getFinality(reference) {
|
|
42
|
+
return {
|
|
43
|
+
adapter_id: manifest.adapter_id,
|
|
44
|
+
settlement_ref: reference,
|
|
45
|
+
finality_status: "confirmed"
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = {
|
|
50
|
+
manifest,
|
|
51
|
+
getHealth,
|
|
52
|
+
describeCapabilities,
|
|
53
|
+
settle,
|
|
54
|
+
getFinality
|
|
55
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"adapter_id": "example.settlement.anchor",
|
|
3
|
+
"adapter_class": "settlement_adapter",
|
|
4
|
+
"adapter_version": "1.0.0",
|
|
5
|
+
"interface_version": "commerce-adapter-interface/v1",
|
|
6
|
+
"display_name": "Example Settlement Anchor Adapter",
|
|
7
|
+
"description": "Reference settlement adapter manifest used to validate settlement-side adapter contract shape.",
|
|
8
|
+
"capabilities": [
|
|
9
|
+
"settlement.submit",
|
|
10
|
+
"settlement.finality",
|
|
11
|
+
"settlement.reference"
|
|
12
|
+
],
|
|
13
|
+
"compatibility": {
|
|
14
|
+
"node": ">=18",
|
|
15
|
+
"commerce_contract": "commerce-repo-final-contract/v1",
|
|
16
|
+
"proof_contract": "proof-repo-final-contract/v1"
|
|
17
|
+
},
|
|
18
|
+
"health_contract": {
|
|
19
|
+
"check_kind": "self_reported",
|
|
20
|
+
"supports_readiness": true
|
|
21
|
+
},
|
|
22
|
+
"idempotency_contract": {
|
|
23
|
+
"strategy": "caller_supplied_key",
|
|
24
|
+
"scope": "settlement_request"
|
|
25
|
+
},
|
|
26
|
+
"failure_contract": {
|
|
27
|
+
"categories": [
|
|
28
|
+
"invalid_input",
|
|
29
|
+
"timeout",
|
|
30
|
+
"upstream_unavailable",
|
|
31
|
+
"settlement_failure"
|
|
32
|
+
],
|
|
33
|
+
"retryable_categories": [
|
|
34
|
+
"timeout",
|
|
35
|
+
"upstream_unavailable"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"proof_contract": {
|
|
39
|
+
"emits_proof_compatible_facts": true,
|
|
40
|
+
"proof_mode": "settlement_reference_only"
|
|
41
|
+
},
|
|
42
|
+
"latency_class": "governed_async",
|
|
43
|
+
"required_secrets": [
|
|
44
|
+
"EXAMPLE_SETTLEMENT_TOKEN"
|
|
45
|
+
],
|
|
46
|
+
"required_permissions": [
|
|
47
|
+
"network:outbound"
|
|
48
|
+
],
|
|
49
|
+
"supported_profiles": [
|
|
50
|
+
"default",
|
|
51
|
+
"anchored"
|
|
52
|
+
],
|
|
53
|
+
"supported_regions": [
|
|
54
|
+
"global"
|
|
55
|
+
],
|
|
56
|
+
"supported_settlement_modes": [
|
|
57
|
+
"anchor_commit"
|
|
58
|
+
]
|
|
59
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const ADAPTER_INTERFACE_VERSION = "commerce-adapter-interface/v1";
|
|
4
|
+
|
|
5
|
+
function isPlainObject(value) {
|
|
6
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function validateAdapterImplementation(adapter) {
|
|
10
|
+
const errors = [];
|
|
11
|
+
if (!isPlainObject(adapter)) {
|
|
12
|
+
errors.push("adapter must be an object");
|
|
13
|
+
return errors;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (!isPlainObject(adapter.manifest)) {
|
|
17
|
+
errors.push("adapter.manifest must be an object");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (typeof adapter.getHealth !== "function") {
|
|
21
|
+
errors.push("adapter.getHealth must be a function");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (typeof adapter.describeCapabilities !== "function") {
|
|
25
|
+
errors.push("adapter.describeCapabilities must be a function");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (adapter.manifest && adapter.manifest.adapter_class === "execution_adapter") {
|
|
29
|
+
if (typeof adapter.execute !== "function") {
|
|
30
|
+
errors.push("execution adapters must implement execute");
|
|
31
|
+
}
|
|
32
|
+
if (typeof adapter.preview !== "function") {
|
|
33
|
+
errors.push("execution adapters should implement preview");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (adapter.manifest && adapter.manifest.adapter_class === "settlement_adapter") {
|
|
38
|
+
if (typeof adapter.settle !== "function") {
|
|
39
|
+
errors.push("settlement adapters must implement settle");
|
|
40
|
+
}
|
|
41
|
+
if (typeof adapter.getFinality !== "function") {
|
|
42
|
+
errors.push("settlement adapters should implement getFinality");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (adapter.manifest && adapter.manifest.interface_version !== ADAPTER_INTERFACE_VERSION) {
|
|
47
|
+
errors.push(`adapter.manifest.interface_version must be ${ADAPTER_INTERFACE_VERSION}`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return errors;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
ADAPTER_INTERFACE_VERSION,
|
|
55
|
+
validateAdapterImplementation
|
|
56
|
+
};
|
package/client.js
ADDED