xytara 2.5.0 → 2.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/.env.example +29 -0
- package/BSV_TERANODE_SETUP.md +43 -0
- package/README.md +66 -7
- package/REAL_PAYMENT_SETUP.md +61 -0
- package/RELEASE_NOTES.md +12 -6
- package/SERVICE_CONTRACT.md +31 -0
- package/START_HERE.md +107 -6
- package/TREASURY_DESTINATIONS.example.json +66 -0
- package/TREASURY_DESTINATIONS.production.template.json +108 -0
- package/adapters/examples/langchain-reference-execution-adapter.js +81 -0
- package/adapters/examples/langchain-reference-execution-adapter.manifest.json +79 -0
- package/adapters/examples/langgraph-reference-execution-adapter.js +81 -0
- package/adapters/examples/langgraph-reference-execution-adapter.manifest.json +79 -0
- package/bin/xytara-first-run.js +244 -0
- package/bin/xytara.js +30 -5
- package/integrations/dispatch.js +7 -2
- package/integrations/registry.js +123 -2
- package/lib/activity_audit_contract.js +322 -0
- package/lib/adapter_depth_contract.js +156 -0
- package/lib/bolt_lane_contract.js +55 -0
- package/lib/bolt_payment_front.js +172 -0
- package/lib/capability_execution_truth.js +269 -0
- package/lib/capability_registry.js +39 -2
- package/lib/checkout_event_security.js +142 -0
- package/lib/command_flow.js +169 -36
- package/lib/commerce_artifacts.js +23 -4
- package/lib/commerce_checkout.js +134 -4
- package/lib/commerce_client.js +20 -0
- package/lib/commerce_economics.js +109 -9
- package/lib/commerce_runtime.js +38 -2
- package/lib/commerce_shell.js +4 -2
- package/lib/external_execution_runtime.js +132 -0
- package/lib/go_live_operator_pack.js +339 -0
- package/lib/http_transport.js +32 -0
- package/lib/integration_matrix_contract.js +6 -0
- package/lib/l402_lane_contract.js +55 -0
- package/lib/l402_payment_front.js +192 -0
- package/lib/network_transport.js +110 -0
- package/lib/operator_intelligence.js +215 -1
- package/lib/payment_config.js +80 -3
- package/lib/payment_front_registry.js +53 -0
- package/lib/payment_protocol_contract.js +165 -0
- package/lib/payment_verification.js +23 -3
- package/lib/pricing_optimization_contract.js +556 -0
- package/lib/release_history.js +15 -0
- package/lib/request_rate_limit.js +144 -0
- package/lib/runtime_bridge.js +10 -2
- package/lib/runtime_operations_worker.js +282 -0
- package/lib/settlement_bsv_live.js +79 -4
- package/lib/stripe_mpp_lane_contract.js +3 -0
- package/lib/stripe_mpp_payment_front.js +158 -0
- package/lib/treasury_destinations_contract.js +543 -0
- package/lib/treasury_egress_policy_contract.js +91 -0
- package/package.json +14 -21
- package/server.js +627 -88
- package/OPERATIONS_RUNBOOK.md +0 -66
- package/OPERATOR_START_HERE.md +0 -63
- package/PROGRAM_COMPLETE_RELEASE.md +0 -63
- package/PROGRAM_STATUS.md +0 -57
- package/PUBLISH_PLAN.md +0 -14
- package/RELEASE_CHECKLIST.md +0 -16
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const crypto = require("crypto");
|
|
4
|
+
|
|
5
|
+
function normalizeString(value) {
|
|
6
|
+
return typeof value === "string" ? value.trim() : "";
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function safeEqualHex(left, right) {
|
|
10
|
+
const a = Buffer.from(String(left || ""), "hex");
|
|
11
|
+
const b = Buffer.from(String(right || ""), "hex");
|
|
12
|
+
if (a.length === 0 || b.length === 0 || a.length !== b.length) return false;
|
|
13
|
+
return crypto.timingSafeEqual(a, b);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function decodeBase64UrlJson(value) {
|
|
17
|
+
try {
|
|
18
|
+
return JSON.parse(Buffer.from(String(value || ""), "base64url").toString("utf8"));
|
|
19
|
+
} catch (_) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function loadBoltFrontConfig() {
|
|
25
|
+
const sharedSecret = normalizeString(process.env.XYTARA_BOLT_SHARED_SECRET);
|
|
26
|
+
return {
|
|
27
|
+
enabled: String(process.env.XYTARA_BOLT_ENABLED || (sharedSecret ? "true" : "false")).trim().toLowerCase() !== "false",
|
|
28
|
+
shared_secret: sharedSecret || null,
|
|
29
|
+
network: normalizeString(process.env.XYTARA_BOLT_NETWORK) || normalizeString(process.env.XYTARA_BSV_TERANODE_NETWORK) || "mainnet",
|
|
30
|
+
proof_mode: normalizeString(process.env.XYTARA_BOLT_PROOF_MODE) || "spv_or_block_header_verifiable",
|
|
31
|
+
max_age_seconds: Math.max(30, Number(process.env.XYTARA_BOLT_MAX_AGE_SECONDS || 300) || 300),
|
|
32
|
+
required_headers: ["authorization"],
|
|
33
|
+
auth_scheme: "BOLT",
|
|
34
|
+
token_shape: "base64url_json_with_utxo_spv_proof_and_hmac_signed_payload"
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function parseBoltAuthorization(headers) {
|
|
39
|
+
const authorization = headers && typeof headers.authorization === "string"
|
|
40
|
+
? headers.authorization.trim()
|
|
41
|
+
: "";
|
|
42
|
+
const match = authorization.match(/^BOLT\s+(.+)$/i);
|
|
43
|
+
if (!match) return null;
|
|
44
|
+
const decoded = decodeBase64UrlJson(match[1]);
|
|
45
|
+
if (!decoded || typeof decoded !== "object") return null;
|
|
46
|
+
return {
|
|
47
|
+
wallet_id: decoded.wallet_id || decoded.gateway_id || "bolt_gateway",
|
|
48
|
+
encoded: decoded.payload || null,
|
|
49
|
+
signature: decoded.signature || null,
|
|
50
|
+
txid: decoded.txid || null,
|
|
51
|
+
spv_proof_ref: decoded.spv_proof_ref || null,
|
|
52
|
+
merkle_path_ref: decoded.merkle_path_ref || null,
|
|
53
|
+
block_header_ref: decoded.block_header_ref || null,
|
|
54
|
+
network: decoded.network || null,
|
|
55
|
+
proof_bundle_ref: decoded.proof_bundle_ref || null,
|
|
56
|
+
scheme: "bolt"
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function verifyBoltPaymentPayload(paymentPayload, quote, walletId, maxAgeSeconds, config) {
|
|
61
|
+
if (!paymentPayload || typeof paymentPayload !== "object") return { ok: false, reason: "bolt_payload_invalid" };
|
|
62
|
+
if (!paymentPayload.quote_id || paymentPayload.quote_id !== quote.quote_id) return { ok: false, reason: "bolt_quote_mismatch" };
|
|
63
|
+
if (paymentPayload.amount_minor !== quote.amount_minor) return { ok: false, reason: "bolt_amount_mismatch" };
|
|
64
|
+
if (paymentPayload.currency !== quote.currency) return { ok: false, reason: "bolt_currency_mismatch" };
|
|
65
|
+
if (paymentPayload.account_id && paymentPayload.account_id !== quote.account_id) return { ok: false, reason: "bolt_account_mismatch" };
|
|
66
|
+
if (walletId && paymentPayload.wallet_id && paymentPayload.wallet_id !== walletId) return { ok: false, reason: "bolt_wallet_mismatch" };
|
|
67
|
+
if (!paymentPayload.nonce || typeof paymentPayload.nonce !== "string") return { ok: false, reason: "bolt_nonce_missing" };
|
|
68
|
+
if (!paymentPayload.issued_at_iso || Number.isNaN(Date.parse(paymentPayload.issued_at_iso))) return { ok: false, reason: "bolt_issued_at_invalid" };
|
|
69
|
+
const ageSeconds = Math.max(0, Math.floor((Date.now() - Date.parse(paymentPayload.issued_at_iso)) / 1000));
|
|
70
|
+
if (ageSeconds > maxAgeSeconds) return { ok: false, reason: "bolt_token_expired" };
|
|
71
|
+
if (!normalizeString(paymentPayload.txid || paymentPayload.transaction_id)) return { ok: false, reason: "bolt_txid_missing" };
|
|
72
|
+
if (
|
|
73
|
+
!normalizeString(paymentPayload.spv_proof_ref || paymentPayload.proof_bundle_ref)
|
|
74
|
+
&& !normalizeString(paymentPayload.merkle_path_ref)
|
|
75
|
+
&& !normalizeString(paymentPayload.block_header_ref)
|
|
76
|
+
) {
|
|
77
|
+
return { ok: false, reason: "bolt_proof_missing" };
|
|
78
|
+
}
|
|
79
|
+
if (
|
|
80
|
+
normalizeString(paymentPayload.network)
|
|
81
|
+
&& normalizeString(config && config.network)
|
|
82
|
+
&& normalizeString(paymentPayload.network) !== normalizeString(config.network)
|
|
83
|
+
) {
|
|
84
|
+
return { ok: false, reason: "bolt_network_mismatch" };
|
|
85
|
+
}
|
|
86
|
+
return { ok: true, age_seconds: ageSeconds };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function verifyBoltAccessToken(headers, quote) {
|
|
90
|
+
const config = loadBoltFrontConfig();
|
|
91
|
+
if (!config.enabled) return { ok: false, status: 503, reason: "bolt_not_enabled" };
|
|
92
|
+
if (!config.shared_secret) return { ok: false, status: 503, reason: "bolt_shared_secret_missing" };
|
|
93
|
+
const payment = parseBoltAuthorization(headers || {});
|
|
94
|
+
if (!payment || !payment.encoded || !payment.signature) {
|
|
95
|
+
return { ok: false, status: 402, reason: "bolt_headers_incomplete" };
|
|
96
|
+
}
|
|
97
|
+
const expectedSignature = crypto.createHmac("sha256", config.shared_secret).update(payment.encoded).digest("hex");
|
|
98
|
+
if (!safeEqualHex(expectedSignature, payment.signature)) {
|
|
99
|
+
return { ok: false, status: 403, reason: "bolt_signature_invalid" };
|
|
100
|
+
}
|
|
101
|
+
const payload = decodeBase64UrlJson(payment.encoded);
|
|
102
|
+
const validation = verifyBoltPaymentPayload(payload, quote, payment.wallet_id, config.max_age_seconds, config);
|
|
103
|
+
if (!validation.ok) return { ok: false, status: 403, reason: validation.reason };
|
|
104
|
+
return {
|
|
105
|
+
ok: true,
|
|
106
|
+
verification_mode: "bolt_gateway_signed",
|
|
107
|
+
wallet_id: payment.wallet_id,
|
|
108
|
+
payment_payload: payload,
|
|
109
|
+
age_seconds: validation.age_seconds,
|
|
110
|
+
bolt: {
|
|
111
|
+
txid: payment.txid || payload.txid || payload.transaction_id || null,
|
|
112
|
+
spv_proof_ref: payment.spv_proof_ref || payload.spv_proof_ref || payload.proof_bundle_ref || null,
|
|
113
|
+
merkle_path_ref: payment.merkle_path_ref || payload.merkle_path_ref || null,
|
|
114
|
+
block_header_ref: payment.block_header_ref || payload.block_header_ref || null,
|
|
115
|
+
proof_bundle_ref: payment.proof_bundle_ref || payload.proof_bundle_ref || null,
|
|
116
|
+
network: payment.network || payload.network || config.network,
|
|
117
|
+
proof_mode: config.proof_mode
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function buildBoltSecuritySummary() {
|
|
123
|
+
const config = loadBoltFrontConfig();
|
|
124
|
+
const blockers = [];
|
|
125
|
+
if (config.enabled && !config.shared_secret) blockers.push("bolt_shared_secret_missing");
|
|
126
|
+
return {
|
|
127
|
+
ok: true,
|
|
128
|
+
category: "machine-commerce-bolt-security-summary",
|
|
129
|
+
summary_version: "xytara-bolt-security-summary-v1",
|
|
130
|
+
enabled: config.enabled,
|
|
131
|
+
shared_secret_configured: Boolean(config.shared_secret),
|
|
132
|
+
network: config.network,
|
|
133
|
+
proof_mode: config.proof_mode,
|
|
134
|
+
max_age_seconds: config.max_age_seconds,
|
|
135
|
+
auth_scheme: config.auth_scheme,
|
|
136
|
+
token_shape: config.token_shape,
|
|
137
|
+
ready: config.enabled && blockers.length === 0,
|
|
138
|
+
blockers,
|
|
139
|
+
linked_surfaces: {
|
|
140
|
+
bolt_lane_ref: "/v1/bolt",
|
|
141
|
+
commands_execute_ref: "/bolt/commands/execute",
|
|
142
|
+
mcp_invoke_ref: "/bolt/mcp/tools/invoke"
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function buildBoltChallengePayload(quote) {
|
|
148
|
+
return {
|
|
149
|
+
ok: false,
|
|
150
|
+
payment_required: {
|
|
151
|
+
scheme: "bolt",
|
|
152
|
+
quote,
|
|
153
|
+
operator_requirements: {
|
|
154
|
+
auth_scheme: "BOLT",
|
|
155
|
+
token_shape: "base64url_json_with_utxo_spv_proof_and_hmac_signed_payload",
|
|
156
|
+
security_ref: "/v1/bolt/security",
|
|
157
|
+
proof_requirements: [
|
|
158
|
+
"txid",
|
|
159
|
+
"one_of:spv_proof_ref|merkle_path_ref|block_header_ref|proof_bundle_ref"
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
module.exports = {
|
|
167
|
+
buildBoltChallengePayload,
|
|
168
|
+
buildBoltSecuritySummary,
|
|
169
|
+
loadBoltFrontConfig,
|
|
170
|
+
parseBoltAuthorization,
|
|
171
|
+
verifyBoltAccessToken
|
|
172
|
+
};
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const packageJson = require("../package.json");
|
|
4
|
+
const { catalog } = require("../fixtures/catalog");
|
|
5
|
+
const { summarizeAdapterDepthPack } = require("./adapter_depth_contract");
|
|
6
|
+
const { loadExecutionTargetRegistry } = require("./external_execution_runtime");
|
|
7
|
+
const { loadBsvSettlementRuntimeConfig } = require("./settlement_bsv_live");
|
|
8
|
+
const { summarizeTreasuryDestinationsPack } = require("./treasury_destinations_contract");
|
|
9
|
+
|
|
10
|
+
const NATIVE_RUNTIME_CATEGORIES = new Set([
|
|
11
|
+
"trust",
|
|
12
|
+
"receipt",
|
|
13
|
+
"runtime",
|
|
14
|
+
"jobs",
|
|
15
|
+
"credits",
|
|
16
|
+
"a2a",
|
|
17
|
+
"a2c",
|
|
18
|
+
"policy",
|
|
19
|
+
"identity",
|
|
20
|
+
"registry",
|
|
21
|
+
"anchoring",
|
|
22
|
+
"discovery",
|
|
23
|
+
"admission"
|
|
24
|
+
]);
|
|
25
|
+
|
|
26
|
+
function normalizeString(value) {
|
|
27
|
+
return typeof value === "string" ? value.trim() : "";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function hasMerchantIdentity() {
|
|
31
|
+
return Boolean(
|
|
32
|
+
normalizeString(process.env.XYTARA_BSV_TERANODE_MERCHANT_ADDRESS)
|
|
33
|
+
|| normalizeString(process.env.XYTARA_BSV_TERANODE_MERCHANT_PAYMAIL)
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isLiveRuntimeMode(mode) {
|
|
38
|
+
return normalizeString(mode).toLowerCase() !== "mock";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function buildSettlementReadiness() {
|
|
42
|
+
const runtimeConfig = loadBsvSettlementRuntimeConfig();
|
|
43
|
+
const treasurySummary = summarizeTreasuryDestinationsPack();
|
|
44
|
+
const liveMode = isLiveRuntimeMode(runtimeConfig.mode);
|
|
45
|
+
const merchantConfigured = hasMerchantIdentity();
|
|
46
|
+
const treasuryConfigured = Number(treasurySummary.configured_profile_count || 0) > 0;
|
|
47
|
+
const ready = liveMode && merchantConfigured && treasuryConfigured;
|
|
48
|
+
return {
|
|
49
|
+
ready,
|
|
50
|
+
runtime_mode: runtimeConfig.mode,
|
|
51
|
+
merchant_identity_configured: merchantConfigured,
|
|
52
|
+
treasury_configured: treasuryConfigured,
|
|
53
|
+
configured_profile_count: Number(treasurySummary.configured_profile_count || 0),
|
|
54
|
+
explicit_per_rail_configured_count: Number(treasurySummary.explicit_per_rail_configured_count || 0)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function findMatchingExecutionTargets(task) {
|
|
59
|
+
const targets = loadExecutionTargetRegistry();
|
|
60
|
+
const taskRefs = new Set(
|
|
61
|
+
[task && task.task_ref, task && task.public_task_ref]
|
|
62
|
+
.map((value) => normalizeString(value))
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
);
|
|
65
|
+
return targets.filter((target) => {
|
|
66
|
+
const targetTaskRef = normalizeString(target && target.task_ref);
|
|
67
|
+
if (targetTaskRef && taskRefs.has(targetTaskRef)) return true;
|
|
68
|
+
if (normalizeString(task && task.public_task_ref) === "adapter.mcp.invoke") {
|
|
69
|
+
return Boolean(normalizeString(target && target.tool_name) || normalizeString(target && target.integration_id));
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function classifyTask(task, settlementReadiness) {
|
|
76
|
+
const matches = findMatchingExecutionTargets(task);
|
|
77
|
+
const providerTargets = matches.map((target) => ({
|
|
78
|
+
target_id: target.target_id,
|
|
79
|
+
provider: target.provider,
|
|
80
|
+
task_ref: target.task_ref || null,
|
|
81
|
+
tool_name: target.tool_name || null,
|
|
82
|
+
integration_id: target.integration_id || null,
|
|
83
|
+
enabled: target.enabled !== false
|
|
84
|
+
}));
|
|
85
|
+
|
|
86
|
+
if (normalizeString(task && task.public_category) === "settlement") {
|
|
87
|
+
return {
|
|
88
|
+
task_ref: task.public_task_ref,
|
|
89
|
+
internal_task_ref: task.task_ref,
|
|
90
|
+
public_title: task.public_title,
|
|
91
|
+
public_category: task.public_category,
|
|
92
|
+
execution_mode: task.execution_mode,
|
|
93
|
+
latency_class: task.latency_class,
|
|
94
|
+
execution_truth: settlementReadiness.ready ? "native_live" : "operator_inputs_pending",
|
|
95
|
+
execution_origin: "native_settlement_runtime",
|
|
96
|
+
commercialization_posture: settlementReadiness.ready ? "sellable_live_now" : "sellable_when_operator_configured",
|
|
97
|
+
matching_execution_target_count: providerTargets.length,
|
|
98
|
+
matching_execution_targets: providerTargets,
|
|
99
|
+
requirements: {
|
|
100
|
+
bsv_runtime_mode: settlementReadiness.runtime_mode,
|
|
101
|
+
merchant_identity_configured: settlementReadiness.merchant_identity_configured,
|
|
102
|
+
treasury_configured: settlementReadiness.treasury_configured
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (normalizeString(task && task.public_category) === "adapter") {
|
|
108
|
+
return {
|
|
109
|
+
task_ref: task.public_task_ref,
|
|
110
|
+
internal_task_ref: task.task_ref,
|
|
111
|
+
public_title: task.public_title,
|
|
112
|
+
public_category: task.public_category,
|
|
113
|
+
execution_mode: task.execution_mode,
|
|
114
|
+
latency_class: task.latency_class,
|
|
115
|
+
execution_truth: providerTargets.length > 0 ? "provider_live" : "provider_wiring_required",
|
|
116
|
+
execution_origin: providerTargets.length > 0 ? "external_execution_target" : "adapter_lane_without_bound_target",
|
|
117
|
+
commercialization_posture: providerTargets.length > 0 ? "sellable_live_now" : "sellable_by_integration",
|
|
118
|
+
matching_execution_target_count: providerTargets.length,
|
|
119
|
+
matching_execution_targets: providerTargets,
|
|
120
|
+
requirements: {
|
|
121
|
+
configured_provider_target_required: true
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (NATIVE_RUNTIME_CATEGORIES.has(normalizeString(task && task.public_category))) {
|
|
127
|
+
return {
|
|
128
|
+
task_ref: task.public_task_ref,
|
|
129
|
+
internal_task_ref: task.task_ref,
|
|
130
|
+
public_title: task.public_title,
|
|
131
|
+
public_category: task.public_category,
|
|
132
|
+
execution_mode: task.execution_mode,
|
|
133
|
+
latency_class: task.latency_class,
|
|
134
|
+
execution_truth: "native_live",
|
|
135
|
+
execution_origin: "native_runtime_contract",
|
|
136
|
+
commercialization_posture: "sellable_live_now",
|
|
137
|
+
matching_execution_target_count: providerTargets.length,
|
|
138
|
+
matching_execution_targets: providerTargets,
|
|
139
|
+
requirements: {
|
|
140
|
+
configured_provider_target_required: false
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
task_ref: task.public_task_ref,
|
|
147
|
+
internal_task_ref: task.task_ref,
|
|
148
|
+
public_title: task.public_title,
|
|
149
|
+
public_category: task.public_category,
|
|
150
|
+
execution_mode: task.execution_mode,
|
|
151
|
+
latency_class: task.latency_class,
|
|
152
|
+
execution_truth: providerTargets.length > 0 ? "provider_live" : "operator_classification_required",
|
|
153
|
+
execution_origin: providerTargets.length > 0 ? "external_execution_target" : "uncategorized_runtime_surface",
|
|
154
|
+
commercialization_posture: providerTargets.length > 0 ? "sellable_live_now" : "hold_until_classified",
|
|
155
|
+
matching_execution_target_count: providerTargets.length,
|
|
156
|
+
matching_execution_targets: providerTargets,
|
|
157
|
+
requirements: {
|
|
158
|
+
configured_provider_target_required: providerTargets.length < 1
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function buildCapabilityExecutionTruthBundle() {
|
|
164
|
+
const settlementReadiness = buildSettlementReadiness();
|
|
165
|
+
const adapterDepth = summarizeAdapterDepthPack();
|
|
166
|
+
const tasks = (Array.isArray(catalog.tasks) ? catalog.tasks : []).map((task) => classifyTask(task, settlementReadiness));
|
|
167
|
+
const counts = {
|
|
168
|
+
task_count: tasks.length,
|
|
169
|
+
native_live_count: tasks.filter((task) => task.execution_truth === "native_live").length,
|
|
170
|
+
provider_live_count: tasks.filter((task) => task.execution_truth === "provider_live").length,
|
|
171
|
+
operator_inputs_pending_count: tasks.filter((task) => task.execution_truth === "operator_inputs_pending").length,
|
|
172
|
+
provider_wiring_required_count: tasks.filter((task) => task.execution_truth === "provider_wiring_required").length,
|
|
173
|
+
operator_classification_required_count: tasks.filter((task) => task.execution_truth === "operator_classification_required").length
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
return {
|
|
177
|
+
ok: true,
|
|
178
|
+
product: packageJson.name,
|
|
179
|
+
category: "machine-commerce-capability-execution-truth",
|
|
180
|
+
bundle_version: "xytara-capability-execution-truth-v1",
|
|
181
|
+
execution_posture: {
|
|
182
|
+
native_runtime_categories: Array.from(NATIVE_RUNTIME_CATEGORIES.values()),
|
|
183
|
+
settlement_readiness: settlementReadiness,
|
|
184
|
+
configured_execution_target_count: loadExecutionTargetRegistry().length,
|
|
185
|
+
adapter_depth_state: adapterDepth.adapter_depth_state,
|
|
186
|
+
adapter_depth_counts: adapterDepth.counts
|
|
187
|
+
},
|
|
188
|
+
counts,
|
|
189
|
+
tasks,
|
|
190
|
+
linked_surfaces: {
|
|
191
|
+
capability_registry_ref: "/v1/capability-registry",
|
|
192
|
+
execution_truth_summary_ref: "/v1/capability-registry/execution-truth/summary",
|
|
193
|
+
adapter_depth_ref: "/v1/adapter-depth",
|
|
194
|
+
adapter_depth_summary_ref: "/v1/adapter-depth/summary",
|
|
195
|
+
treasury_readiness_ref: "/v1/treasury-destinations",
|
|
196
|
+
native_settlement_readiness_ref: "/v1/settlement/bsv-teranode/readiness"
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function summarizeCapabilityExecutionTruthBundle() {
|
|
202
|
+
const bundle = buildCapabilityExecutionTruthBundle();
|
|
203
|
+
return {
|
|
204
|
+
ok: true,
|
|
205
|
+
product: bundle.product,
|
|
206
|
+
category: bundle.category,
|
|
207
|
+
bundle_version: bundle.bundle_version,
|
|
208
|
+
counts: bundle.counts,
|
|
209
|
+
execution_posture: bundle.execution_posture,
|
|
210
|
+
linked_surfaces: bundle.linked_surfaces
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function buildCapabilityCommercializationSummary() {
|
|
215
|
+
const bundle = buildCapabilityExecutionTruthBundle();
|
|
216
|
+
const tasks = Array.isArray(bundle.tasks) ? bundle.tasks : [];
|
|
217
|
+
const selfServeLiveNow = tasks.filter((task) =>
|
|
218
|
+
task.commercialization_posture === "sellable_live_now"
|
|
219
|
+
);
|
|
220
|
+
const operatorEnabledAfterConfig = tasks.filter((task) =>
|
|
221
|
+
task.commercialization_posture === "sellable_when_operator_configured"
|
|
222
|
+
|| task.commercialization_posture === "sellable_by_integration"
|
|
223
|
+
);
|
|
224
|
+
const holdUntilClassified = tasks.filter((task) =>
|
|
225
|
+
task.commercialization_posture === "hold_until_classified"
|
|
226
|
+
);
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
ok: true,
|
|
230
|
+
product: packageJson.name,
|
|
231
|
+
category: "machine-commerce-capability-commercialization-summary",
|
|
232
|
+
summary_version: "xytara-capability-commercialization-summary-v1",
|
|
233
|
+
commercialization_posture: {
|
|
234
|
+
primary_agent_entry_surfaces: ["x402", "mcp", "a2a", "a2c", "http_api"],
|
|
235
|
+
secondary_human_entry_surfaces: ["hosted_checkout", "web_docs", "npm_package"],
|
|
236
|
+
primary_payment_surfaces: ["x402", "credits", "hosted_checkout"],
|
|
237
|
+
discovery_surfaces: ["capability_registry", "catalog", "execution_truth"]
|
|
238
|
+
},
|
|
239
|
+
counts: {
|
|
240
|
+
self_serve_live_now: selfServeLiveNow.length,
|
|
241
|
+
operator_enabled_after_config: operatorEnabledAfterConfig.length,
|
|
242
|
+
hold_until_classified: holdUntilClassified.length
|
|
243
|
+
},
|
|
244
|
+
sellable_now_task_refs: selfServeLiveNow.map((task) => task.task_ref),
|
|
245
|
+
operator_enabled_task_refs: operatorEnabledAfterConfig.map((task) => task.task_ref),
|
|
246
|
+
hold_task_refs: holdUntilClassified.map((task) => task.task_ref),
|
|
247
|
+
recommendations: [
|
|
248
|
+
"Use x402 for machine-native pay-per-use access and keep hosted checkout as the human-friendly money-in lane.",
|
|
249
|
+
"Expose MCP and A2A entry paths for interoperable agent consumption while preserving execution-truth visibility.",
|
|
250
|
+
"Only market provider-backed capabilities as instant self-serve once execution targets are configured and operator readiness is green."
|
|
251
|
+
],
|
|
252
|
+
linked_surfaces: {
|
|
253
|
+
capability_registry_ref: "/v1/capability-registry",
|
|
254
|
+
execution_truth_ref: "/v1/capability-registry/execution-truth",
|
|
255
|
+
execution_truth_summary_ref: "/v1/capability-registry/execution-truth/summary",
|
|
256
|
+
x402_ref: "/v1/x402",
|
|
257
|
+
mcp_ref: "/v1/mcp",
|
|
258
|
+
a2a_ref: "/v1/a2a",
|
|
259
|
+
a2c_ref: "/v1/a2c",
|
|
260
|
+
checkout_ref: "/v1/checkout/purchase-intents"
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
module.exports = {
|
|
266
|
+
buildCapabilityExecutionTruthBundle,
|
|
267
|
+
summarizeCapabilityExecutionTruthBundle,
|
|
268
|
+
buildCapabilityCommercializationSummary
|
|
269
|
+
};
|
|
@@ -34,6 +34,11 @@ const {
|
|
|
34
34
|
const {
|
|
35
35
|
buildPartnerIntelligencePack
|
|
36
36
|
} = require("./partner_intelligence");
|
|
37
|
+
const {
|
|
38
|
+
buildCapabilityExecutionTruthBundle,
|
|
39
|
+
summarizeCapabilityExecutionTruthBundle,
|
|
40
|
+
buildCapabilityCommercializationSummary
|
|
41
|
+
} = require("./capability_execution_truth");
|
|
37
42
|
|
|
38
43
|
function buildCapabilityRegistrySummary() {
|
|
39
44
|
const catalogSummary = summarizeCatalog();
|
|
@@ -76,6 +81,8 @@ function buildCapabilityRegistrySummary() {
|
|
|
76
81
|
},
|
|
77
82
|
linked_surfaces: {
|
|
78
83
|
capability_registry_ref: "/v1/capability-registry",
|
|
84
|
+
execution_truth_summary_ref: "/v1/capability-registry/execution-truth/summary",
|
|
85
|
+
commercialization_summary_ref: "/v1/capability-registry/commercialization-summary",
|
|
79
86
|
catalog_summary_ref: "/v1/catalog/summary",
|
|
80
87
|
task_packs_summary_ref: "/v1/transaction-center/task-packs/summary",
|
|
81
88
|
class_packs_summary_ref: "/v1/transaction-center/transaction-class-packs/summary",
|
|
@@ -94,6 +101,8 @@ function buildCapabilityRegistryBundle() {
|
|
|
94
101
|
category: "machine-commerce-capability-registry",
|
|
95
102
|
bundle_version: "xytara-capability-registry-bundle-v1",
|
|
96
103
|
capability_registry_summary: buildCapabilityRegistrySummary(),
|
|
104
|
+
capability_execution_truth: buildCapabilityExecutionTruthBundle(),
|
|
105
|
+
capability_commercialization_summary: buildCapabilityCommercializationSummary(),
|
|
97
106
|
catalog: getCatalog(),
|
|
98
107
|
catalog_summary: summarizeCatalog(),
|
|
99
108
|
task_pack_catalog: buildDefaultTransactionTaskPackCatalog(),
|
|
@@ -118,6 +127,8 @@ function buildCapabilityRegistryBundle() {
|
|
|
118
127
|
adapter_partner_summary: summarizeAdapterPartnerPack(),
|
|
119
128
|
linked_surfaces: {
|
|
120
129
|
capability_registry_summary_ref: "/v1/capability-registry/summary",
|
|
130
|
+
capability_execution_truth_ref: "/v1/capability-registry/execution-truth",
|
|
131
|
+
capability_commercialization_summary_ref: "/v1/capability-registry/commercialization-summary",
|
|
121
132
|
catalog_ref: "/v1/catalog",
|
|
122
133
|
task_pack_catalog_ref: "/v1/transaction-center/task-packs",
|
|
123
134
|
class_pack_catalog_ref: "/v1/transaction-center/transaction-class-packs",
|
|
@@ -170,8 +181,11 @@ function buildCapabilityRegistryClassificationSummary() {
|
|
|
170
181
|
task_latency_classes: Array.from(taskLatencies.entries()).map(([latency_class, task_count]) => ({ latency_class, task_count })),
|
|
171
182
|
task_failure_postures: Array.from(taskFailurePostures.entries()).map(([failure_posture, task_count]) => ({ failure_posture, task_count })),
|
|
172
183
|
protocol_families: protocols,
|
|
184
|
+
execution_truth_summary: summarizeCapabilityExecutionTruthBundle(),
|
|
173
185
|
linked_surfaces: {
|
|
174
186
|
capability_registry_ref: "/v1/capability-registry",
|
|
187
|
+
capability_execution_truth_ref: "/v1/capability-registry/execution-truth",
|
|
188
|
+
capability_commercialization_summary_ref: "/v1/capability-registry/commercialization-summary",
|
|
175
189
|
capability_registry_lineage_summary_ref: "/v1/capability-registry/lineage-summary",
|
|
176
190
|
catalog_summary_ref: "/v1/catalog/summary"
|
|
177
191
|
}
|
|
@@ -295,6 +309,8 @@ function buildCapabilityRegistryOperatorBundle(state, input) {
|
|
|
295
309
|
recommended_registry_motion: recommendedRegistryMotion
|
|
296
310
|
},
|
|
297
311
|
capability_registry_summary: summary,
|
|
312
|
+
capability_execution_truth: buildCapabilityExecutionTruthBundle(),
|
|
313
|
+
capability_commercialization_summary: buildCapabilityCommercializationSummary(),
|
|
298
314
|
capability_registry_bundle: bundle,
|
|
299
315
|
capability_registry_classification_summary: buildCapabilityRegistryClassificationSummary(),
|
|
300
316
|
capability_registry_lineage_summary: buildCapabilityRegistryLineageSummary(),
|
|
@@ -302,6 +318,8 @@ function buildCapabilityRegistryOperatorBundle(state, input) {
|
|
|
302
318
|
linked_surfaces: {
|
|
303
319
|
capability_registry_ref: "/v1/capability-registry",
|
|
304
320
|
capability_registry_summary_ref: "/v1/capability-registry/summary",
|
|
321
|
+
capability_execution_truth_ref: "/v1/capability-registry/execution-truth",
|
|
322
|
+
capability_commercialization_summary_ref: "/v1/capability-registry/commercialization-summary",
|
|
305
323
|
capability_registry_classification_summary_ref: "/v1/capability-registry/classification-summary",
|
|
306
324
|
capability_registry_lineage_summary_ref: "/v1/capability-registry/lineage-summary",
|
|
307
325
|
partner_intelligence_ref: "/v1/partner-intelligence",
|
|
@@ -316,6 +334,8 @@ function buildCapabilityRegistryPolicyPack(state, input) {
|
|
|
316
334
|
const summary = buildCapabilityRegistrySummary();
|
|
317
335
|
const classification = buildCapabilityRegistryClassificationSummary();
|
|
318
336
|
const lineage = buildCapabilityRegistryLineageSummary();
|
|
337
|
+
const executionTruth = summarizeCapabilityExecutionTruthBundle();
|
|
338
|
+
const commercializationSummary = buildCapabilityCommercializationSummary();
|
|
319
339
|
const operatorBundle = buildCapabilityRegistryOperatorBundle(state, { account_id: accountId });
|
|
320
340
|
const partnerIntelligence = buildPartnerIntelligencePack();
|
|
321
341
|
const policyTemplates = [
|
|
@@ -412,11 +432,19 @@ function buildCapabilityRegistryPolicyPack(state, input) {
|
|
|
412
432
|
partner_readiness_state: partnerIntelligence.partner_readiness_state,
|
|
413
433
|
onboarding_friction_state: partnerIntelligence.onboarding_friction_state,
|
|
414
434
|
protocol_family_count: Array.isArray(classification.protocol_families) ? classification.protocol_families.length : 0,
|
|
415
|
-
lineage_row_count: lineage.lineage_row_count
|
|
435
|
+
lineage_row_count: lineage.lineage_row_count,
|
|
436
|
+
native_live_count: executionTruth.counts.native_live_count,
|
|
437
|
+
provider_live_count: executionTruth.counts.provider_live_count,
|
|
438
|
+
provider_wiring_required_count: executionTruth.counts.provider_wiring_required_count,
|
|
439
|
+
operator_inputs_pending_count: executionTruth.counts.operator_inputs_pending_count,
|
|
440
|
+
self_serve_live_now_count: commercializationSummary.counts.self_serve_live_now,
|
|
441
|
+
operator_enabled_after_config_count: commercializationSummary.counts.operator_enabled_after_config
|
|
416
442
|
},
|
|
417
443
|
linked_surfaces: {
|
|
418
444
|
capability_registry_ref: "/v1/capability-registry",
|
|
419
445
|
capability_registry_summary_ref: "/v1/capability-registry/summary",
|
|
446
|
+
capability_execution_truth_ref: "/v1/capability-registry/execution-truth",
|
|
447
|
+
capability_commercialization_summary_ref: "/v1/capability-registry/commercialization-summary",
|
|
420
448
|
capability_registry_classification_summary_ref: "/v1/capability-registry/classification-summary",
|
|
421
449
|
capability_registry_lineage_summary_ref: "/v1/capability-registry/lineage-summary",
|
|
422
450
|
capability_registry_operator_bundle_ref: `/v1/capability-registry/operator-bundle?account_id=${encodeURIComponent(accountId)}`,
|
|
@@ -495,6 +523,8 @@ function buildCapabilityRegistryPackage(state, input) {
|
|
|
495
523
|
const bundle = buildCapabilityRegistryBundle();
|
|
496
524
|
const classification = buildCapabilityRegistryClassificationSummary();
|
|
497
525
|
const lineage = buildCapabilityRegistryLineageSummary();
|
|
526
|
+
const executionTruth = buildCapabilityExecutionTruthBundle();
|
|
527
|
+
const commercializationSummary = buildCapabilityCommercializationSummary();
|
|
498
528
|
const operatorBundle = buildCapabilityRegistryOperatorBundle(state, { account_id: accountId });
|
|
499
529
|
const policyPack = buildCapabilityRegistryPolicyPack(state, { account_id: accountId });
|
|
500
530
|
const policyApplicationSummary = buildCapabilityRegistryPolicyApplicationSummary(state, { account_id: accountId });
|
|
@@ -513,6 +543,8 @@ function buildCapabilityRegistryPackage(state, input) {
|
|
|
513
543
|
recommended_policy_motion: policyPack.recommended_policy_motion
|
|
514
544
|
},
|
|
515
545
|
capability_registry_summary: summary,
|
|
546
|
+
capability_execution_truth: executionTruth,
|
|
547
|
+
capability_commercialization_summary: commercializationSummary,
|
|
516
548
|
capability_registry_bundle: bundle,
|
|
517
549
|
capability_registry_classification_summary: classification,
|
|
518
550
|
capability_registry_lineage_summary: lineage,
|
|
@@ -522,6 +554,8 @@ function buildCapabilityRegistryPackage(state, input) {
|
|
|
522
554
|
linked_surfaces: {
|
|
523
555
|
capability_registry_ref: "/v1/capability-registry",
|
|
524
556
|
capability_registry_summary_ref: "/v1/capability-registry/summary",
|
|
557
|
+
capability_execution_truth_ref: "/v1/capability-registry/execution-truth",
|
|
558
|
+
capability_commercialization_summary_ref: "/v1/capability-registry/commercialization-summary",
|
|
525
559
|
capability_registry_operator_bundle_ref: `/v1/capability-registry/operator-bundle?account_id=${encodeURIComponent(accountId)}`,
|
|
526
560
|
capability_registry_policy_pack_ref: `/v1/capability-registry/policy-pack?account_id=${encodeURIComponent(accountId)}`,
|
|
527
561
|
capability_registry_policy_application_summary_ref: `/v1/capability-registry/policy-application-summary?account_id=${encodeURIComponent(accountId)}`
|
|
@@ -568,5 +602,8 @@ module.exports = {
|
|
|
568
602
|
buildCapabilityRegistryPolicyApplicationSummary,
|
|
569
603
|
buildCapabilityRegistryPackage,
|
|
570
604
|
summarizeCapabilityRegistryPackage,
|
|
571
|
-
summarizeCapabilityRegistryOperatorBundle
|
|
605
|
+
summarizeCapabilityRegistryOperatorBundle,
|
|
606
|
+
buildCapabilityExecutionTruthBundle,
|
|
607
|
+
summarizeCapabilityExecutionTruthBundle,
|
|
608
|
+
buildCapabilityCommercializationSummary
|
|
572
609
|
};
|