xytara 1.7.0 → 1.9.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
@@ -105,6 +105,31 @@ The current `1.7.0` line starts widening that surface into real grouped transact
105
105
 
106
106
  This is the first step beyond “clear default loop” toward “broader useful machine-commerce classes plus clearer commerce-to-proof follow-through.”
107
107
 
108
+ The current `1.8.0` line starts filling a thinner part of the interaction spine before committed execution:
109
+
110
+ - grouped pre-commit pack catalog, summary, and detail routes
111
+ - grouped pre-commit run routes for negotiation, admission, and commit-readiness posture
112
+ - readiness summaries that make the next committed transaction surface more explicit
113
+
114
+ This is intended to make the protocol-entry to committed-transaction transition feel more like one composable machine spine instead of a set of disconnected route families.
115
+
116
+ The same `1.8.0` line also starts exposing grouped interaction spine paths that compose:
117
+
118
+ - pre-commit readiness
119
+ - committed execution
120
+ - proof-aware handoff posture
121
+
122
+ as one clearer cross-layer machine path instead of making callers stitch the layers together manually.
123
+
124
+ The current `1.9.0` line starts hardening the output side of that spine into cleaner extension seams:
125
+
126
+ - interaction result-package catalog, summary, and detail routes
127
+ - direct result-package run surfaces derived from grouped spine paths
128
+ - seam summaries that classify execution/consequence, payment/settlement/treasury, and proof-handoff carry together
129
+ - result-package export surfaces that produce a portable handoff bundle for proof-side follow-through
130
+
131
+ This is intended to make grouped spine outputs easier to treat as stable artifacts and future adapter-ready boundaries instead of one-off route responses.
132
+
108
133
  ## Package Surface
109
134
 
110
135
  The SDK is broad, but it stays organized into a few repeatable families instead of one-off surfaces.
package/index.js CHANGED
@@ -40,7 +40,7 @@ const {
40
40
  } = require("./integrations/registry");
41
41
 
42
42
  const COMMERCE_SDK_NAME = "xytara";
43
- const COMMERCE_SDK_VERSION = "1.7.0";
43
+ const COMMERCE_SDK_VERSION = "1.9.0";
44
44
  const COMMERCE_API_VERSION = "v1";
45
45
 
46
46
  function createClient(options) {
@@ -187,6 +187,151 @@ function buildTransactionClassPacks() {
187
187
  ];
188
188
  }
189
189
 
190
+ function buildPrecommitInteractionPacks() {
191
+ const center = buildDefaultTransactionCenter();
192
+ const defaultSettlementMode = center.default_settlement && center.default_settlement.settlement_mode
193
+ ? center.default_settlement.settlement_mode
194
+ : null;
195
+ const defaultPaymentProtocol = center.default_payment && center.default_payment.protocol
196
+ ? center.default_payment.protocol
197
+ : null;
198
+ return [
199
+ {
200
+ precommit_pack_ref: "precommit.a2a.settlement.readiness",
201
+ title: "A2A Settlement Readiness",
202
+ description: "Negotiate, preview admission, and confirm commit posture before a committed settlement-class transaction.",
203
+ category: "a2a",
204
+ protocol: "a2a",
205
+ task_refs: ["a2a.negotiate", "admission.preview", "a2a.commit"],
206
+ default_payment_protocol: defaultPaymentProtocol,
207
+ default_settlement_mode: defaultSettlementMode,
208
+ commitment_signal: "a2a.commit",
209
+ readiness_kind: "settlement_commit_readiness",
210
+ recommended_next_surface: "/v1/transaction-center/transaction-class-packs/run",
211
+ recommended_next_ref: "transaction.admission.settlement",
212
+ required_inputs: ["counterparty_agent_id", "intent_id", "source_zone_id", "target_zone_id"],
213
+ optional_inputs: ["task_pack_ref", "negotiation_mode", "interaction_class", "payment_protocol", "settlement_mode"]
214
+ },
215
+ {
216
+ precommit_pack_ref: "precommit.a2c.tooling.readiness",
217
+ title: "A2C Tooling Readiness",
218
+ description: "Open the session, preview the tooling pack, and confirm admission posture before committed tooling execution.",
219
+ category: "a2c",
220
+ protocol: "a2c",
221
+ task_refs: ["a2c.session.open", "a2c.pack.preview", "admission.preview"],
222
+ default_payment_protocol: defaultPaymentProtocol,
223
+ default_settlement_mode: defaultSettlementMode,
224
+ commitment_signal: "a2c.pack.preview",
225
+ readiness_kind: "tooling_commit_readiness",
226
+ recommended_next_surface: "/v1/transaction-center/task-packs/invoke",
227
+ recommended_next_ref: "default.a2c.tooling.run",
228
+ required_inputs: ["agent_id", "channel_ref", "pack_ref", "source_zone_id", "target_zone_id"],
229
+ optional_inputs: ["interaction_class", "payment_protocol", "settlement_mode"]
230
+ },
231
+ {
232
+ precommit_pack_ref: "precommit.job.commitment.readiness",
233
+ title: "Job Commitment Readiness",
234
+ description: "Quote, preview admission, and reserve the job before committing the full job transaction class.",
235
+ category: "jobs",
236
+ protocol: "job",
237
+ task_refs: ["jobs.quote", "admission.preview", "jobs.reserve"],
238
+ default_payment_protocol: defaultPaymentProtocol,
239
+ default_settlement_mode: defaultSettlementMode,
240
+ commitment_signal: "jobs.reserve",
241
+ readiness_kind: "job_commitment_readiness",
242
+ recommended_next_surface: "/v1/transaction-center/transaction-class-packs/run",
243
+ recommended_next_ref: "transaction.job.commitment",
244
+ required_inputs: ["job_type", "job_id", "source_zone_id", "target_zone_id", "intent_id"],
245
+ optional_inputs: ["interaction_class", "payment_protocol", "settlement_mode"]
246
+ }
247
+ ];
248
+ }
249
+
250
+ function buildInteractionSpinePaths() {
251
+ const center = buildDefaultTransactionCenter();
252
+ const defaultSettlementMode = center.default_settlement && center.default_settlement.settlement_mode
253
+ ? center.default_settlement.settlement_mode
254
+ : null;
255
+ const defaultPaymentProtocol = center.default_payment && center.default_payment.protocol
256
+ ? center.default_payment.protocol
257
+ : null;
258
+ return [
259
+ {
260
+ spine_path_ref: "spine.a2a.settlement",
261
+ title: "A2A Settlement Spine",
262
+ description: "Compose negotiation, admission, commit, and settlement as one grouped machine-interaction spine path.",
263
+ category: "a2a",
264
+ protocol: "a2a",
265
+ precommit_pack_ref: "precommit.a2a.settlement.readiness",
266
+ committed_ref: "transaction.admission.settlement",
267
+ task_refs: ["a2a.negotiate", "admission.preview", "a2a.commit", "settlement.submit"],
268
+ default_payment_protocol: defaultPaymentProtocol,
269
+ default_settlement_mode: defaultSettlementMode,
270
+ proof_followthrough: "default.proof.bundle.loop",
271
+ required_inputs: ["counterparty_agent_id", "intent_id", "source_zone_id", "target_zone_id"],
272
+ optional_inputs: ["task_pack_ref", "negotiation_mode", "interaction_class", "payment_protocol", "settlement_mode"]
273
+ },
274
+ {
275
+ spine_path_ref: "spine.a2c.tooling",
276
+ title: "A2C Tooling Spine",
277
+ description: "Compose session open, pack preview, admission posture, and committed tooling execution as one grouped path.",
278
+ category: "a2c",
279
+ protocol: "a2c",
280
+ precommit_pack_ref: "precommit.a2c.tooling.readiness",
281
+ committed_ref: "default.a2c.tooling.run",
282
+ task_refs: ["a2c.session.open", "a2c.pack.preview", "admission.preview", "adapter.mcp.invoke"],
283
+ default_payment_protocol: defaultPaymentProtocol,
284
+ default_settlement_mode: defaultSettlementMode,
285
+ proof_followthrough: "default.proof.bundle.loop",
286
+ required_inputs: ["agent_id", "channel_ref", "pack_ref", "tool_name", "source_zone_id", "target_zone_id"],
287
+ optional_inputs: ["arguments", "interaction_class", "payment_protocol", "settlement_mode"]
288
+ },
289
+ {
290
+ spine_path_ref: "spine.job.commitment",
291
+ title: "Job Commitment Spine",
292
+ description: "Compose quote, admission, reserve, and commit as one grouped job interaction spine path.",
293
+ category: "jobs",
294
+ protocol: "job",
295
+ precommit_pack_ref: "precommit.job.commitment.readiness",
296
+ committed_ref: "transaction.job.commitment",
297
+ task_refs: ["jobs.quote", "admission.preview", "jobs.reserve", "jobs.commit"],
298
+ default_payment_protocol: defaultPaymentProtocol,
299
+ default_settlement_mode: defaultSettlementMode,
300
+ proof_followthrough: "default.proof.bundle.loop",
301
+ required_inputs: ["job_type", "job_id", "source_zone_id", "target_zone_id"],
302
+ optional_inputs: ["intent_id", "interaction_class", "payment_protocol", "settlement_mode"]
303
+ }
304
+ ];
305
+ }
306
+
307
+ function buildInteractionResultPackages() {
308
+ return buildInteractionSpinePaths().map((path) => ({
309
+ result_package_ref: path && path.spine_path_ref ? `result.${path.spine_path_ref}` : null,
310
+ source_kind: "interaction_spine_path",
311
+ source_ref: path && path.spine_path_ref ? path.spine_path_ref : null,
312
+ title: path && path.title ? `${path.title} Result Package` : "Interaction Result Package",
313
+ description: path && path.description
314
+ ? `${path.description} Preserve the composed output as a stable result-side package and proof-handoff seam.`
315
+ : "Preserve the composed output as a stable result-side package and proof-handoff seam.",
316
+ category: path && path.category ? path.category : null,
317
+ protocol: path && path.protocol ? path.protocol : null,
318
+ precommit_pack_ref: path && path.precommit_pack_ref ? path.precommit_pack_ref : null,
319
+ committed_ref: path && path.committed_ref ? path.committed_ref : null,
320
+ proof_followthrough: path && path.proof_followthrough ? path.proof_followthrough : null,
321
+ portable_handoff_surface: "/v1/transaction-center/result-packages/export",
322
+ portable_proof_surface: "/v1/proof-center/result-package-handoff/run",
323
+ default_payment_protocol: path && path.default_payment_protocol ? path.default_payment_protocol : null,
324
+ default_settlement_mode: path && path.default_settlement_mode ? path.default_settlement_mode : null,
325
+ seam_layers: [
326
+ "execution_consequence",
327
+ "payment_settlement_treasury",
328
+ "proof_handoff"
329
+ ],
330
+ required_inputs: Array.isArray(path && path.required_inputs) ? path.required_inputs : [],
331
+ optional_inputs: Array.isArray(path && path.optional_inputs) ? path.optional_inputs : []
332
+ }));
333
+ }
334
+
190
335
  function buildDefaultTransactionCenter() {
191
336
  const settlementProfiles = Array.isArray(catalog.settlement_profiles) ? catalog.settlement_profiles : [];
192
337
  const defaultSettlementProfile = settlementProfiles[0] || null;
@@ -403,6 +548,48 @@ function buildTransactionClassPackCatalog() {
403
548
  };
404
549
  }
405
550
 
551
+ function buildPrecommitInteractionPackCatalog() {
552
+ const center = buildDefaultTransactionCenter();
553
+ const packs = buildPrecommitInteractionPacks();
554
+ return {
555
+ ok: true,
556
+ brand: center.brand,
557
+ product: "precommit interaction packs",
558
+ default_payment_protocol: center.default_payment && center.default_payment.protocol ? center.default_payment.protocol : null,
559
+ default_settlement_mode: center.default_settlement && center.default_settlement.settlement_mode ? center.default_settlement.settlement_mode : null,
560
+ precommit_pack_count: packs.length,
561
+ precommit_packs: packs
562
+ };
563
+ }
564
+
565
+ function buildInteractionSpinePathCatalog() {
566
+ const center = buildDefaultTransactionCenter();
567
+ const paths = buildInteractionSpinePaths();
568
+ return {
569
+ ok: true,
570
+ brand: center.brand,
571
+ product: "interaction spine paths",
572
+ default_payment_protocol: center.default_payment && center.default_payment.protocol ? center.default_payment.protocol : null,
573
+ default_settlement_mode: center.default_settlement && center.default_settlement.settlement_mode ? center.default_settlement.settlement_mode : null,
574
+ spine_path_count: paths.length,
575
+ spine_paths: paths
576
+ };
577
+ }
578
+
579
+ function buildInteractionResultPackageCatalog() {
580
+ const center = buildDefaultTransactionCenter();
581
+ const packages = buildInteractionResultPackages();
582
+ return {
583
+ ok: true,
584
+ brand: center.brand,
585
+ product: "interaction result packages",
586
+ default_payment_protocol: center.default_payment && center.default_payment.protocol ? center.default_payment.protocol : null,
587
+ default_settlement_mode: center.default_settlement && center.default_settlement.settlement_mode ? center.default_settlement.settlement_mode : null,
588
+ result_package_count: packages.length,
589
+ result_packages: packages
590
+ };
591
+ }
592
+
406
593
  function summarizeTransactionClassPacks() {
407
594
  const catalogResponse = buildTransactionClassPackCatalog();
408
595
  const packs = Array.isArray(catalogResponse.class_packs) ? catalogResponse.class_packs : [];
@@ -419,12 +606,79 @@ function summarizeTransactionClassPacks() {
419
606
  };
420
607
  }
421
608
 
609
+ function summarizePrecommitInteractionPacks() {
610
+ const catalogResponse = buildPrecommitInteractionPackCatalog();
611
+ const packs = Array.isArray(catalogResponse.precommit_packs) ? catalogResponse.precommit_packs : [];
612
+ return {
613
+ ok: true,
614
+ brand: catalogResponse.brand,
615
+ product: catalogResponse.product,
616
+ default_payment_protocol: catalogResponse.default_payment_protocol,
617
+ default_settlement_mode: catalogResponse.default_settlement_mode,
618
+ precommit_pack_count: packs.length,
619
+ precommit_pack_refs: packs.map((entry) => entry && entry.precommit_pack_ref).filter(Boolean),
620
+ categories: Array.from(new Set(packs.map((entry) => entry && entry.category).filter(Boolean))),
621
+ precommit_packs: packs
622
+ };
623
+ }
624
+
625
+ function summarizeInteractionSpinePaths() {
626
+ const catalogResponse = buildInteractionSpinePathCatalog();
627
+ const paths = Array.isArray(catalogResponse.spine_paths) ? catalogResponse.spine_paths : [];
628
+ return {
629
+ ok: true,
630
+ brand: catalogResponse.brand,
631
+ product: catalogResponse.product,
632
+ default_payment_protocol: catalogResponse.default_payment_protocol,
633
+ default_settlement_mode: catalogResponse.default_settlement_mode,
634
+ spine_path_count: paths.length,
635
+ spine_path_refs: paths.map((entry) => entry && entry.spine_path_ref).filter(Boolean),
636
+ categories: Array.from(new Set(paths.map((entry) => entry && entry.category).filter(Boolean))),
637
+ spine_paths: paths
638
+ };
639
+ }
640
+
641
+ function summarizeInteractionResultPackages() {
642
+ const catalogResponse = buildInteractionResultPackageCatalog();
643
+ const packages = Array.isArray(catalogResponse.result_packages) ? catalogResponse.result_packages : [];
644
+ return {
645
+ ok: true,
646
+ brand: catalogResponse.brand,
647
+ product: catalogResponse.product,
648
+ default_payment_protocol: catalogResponse.default_payment_protocol,
649
+ default_settlement_mode: catalogResponse.default_settlement_mode,
650
+ result_package_count: packages.length,
651
+ result_package_refs: packages.map((entry) => entry && entry.result_package_ref).filter(Boolean),
652
+ source_refs: packages.map((entry) => entry && entry.source_ref).filter(Boolean),
653
+ seam_layers: Array.from(new Set(packages.flatMap((entry) => Array.isArray(entry && entry.seam_layers) ? entry.seam_layers : []))),
654
+ result_packages: packages
655
+ };
656
+ }
657
+
422
658
  function getTransactionClassPack(ref) {
423
659
  const normalized = String(ref || "").trim();
424
660
  if (!normalized) return null;
425
661
  return buildTransactionClassPacks().find((entry) => entry && entry.class_pack_ref === normalized) || null;
426
662
  }
427
663
 
664
+ function getPrecommitInteractionPack(ref) {
665
+ const normalized = String(ref || "").trim();
666
+ if (!normalized) return null;
667
+ return buildPrecommitInteractionPacks().find((entry) => entry && entry.precommit_pack_ref === normalized) || null;
668
+ }
669
+
670
+ function getInteractionSpinePath(ref) {
671
+ const normalized = String(ref || "").trim();
672
+ if (!normalized) return null;
673
+ return buildInteractionSpinePaths().find((entry) => entry && entry.spine_path_ref === normalized) || null;
674
+ }
675
+
676
+ function getInteractionResultPackage(ref) {
677
+ const normalized = String(ref || "").trim();
678
+ if (!normalized) return null;
679
+ return buildInteractionResultPackages().find((entry) => entry && entry.result_package_ref === normalized) || null;
680
+ }
681
+
428
682
  function buildCatalogResponse() {
429
683
  return {
430
684
  ok: true,
@@ -559,11 +813,17 @@ module.exports = {
559
813
  buildDefaultTransactionEconomics,
560
814
  buildDefaultTransactionCenter,
561
815
  buildDefaultTransactionGuidedLoopCatalog,
816
+ buildInteractionResultPackageCatalog,
817
+ buildInteractionSpinePathCatalog,
818
+ buildPrecommitInteractionPackCatalog,
562
819
  buildDefaultTransactionTaskPackCatalog,
563
820
  buildTransactionClassPackCatalog,
564
821
  getCatalog,
565
822
  getDefaultTransactionGuidedLoop,
566
823
  getDefaultTransactionTaskPack,
824
+ getInteractionResultPackage,
825
+ getInteractionSpinePath,
826
+ getPrecommitInteractionPack,
567
827
  getTransactionClassPack,
568
828
  getTaskDetail,
569
829
  getWorkflowDetail,
@@ -573,5 +833,8 @@ module.exports = {
573
833
  summarizeDefaultTransactionEconomics,
574
834
  summarizeDefaultTransactionGuidedLoops,
575
835
  summarizeDefaultTransactionTaskPacks,
836
+ summarizeInteractionResultPackages,
837
+ summarizeInteractionSpinePaths,
838
+ summarizePrecommitInteractionPacks,
576
839
  summarizeTransactionClassPacks
577
840
  };
@@ -1089,6 +1089,56 @@ function summarizeProofHandoffPayload(payload) {
1089
1089
  };
1090
1090
  }
1091
1091
 
1092
+ function summarizeInteractionResultPackagePayload(payload) {
1093
+ const item = payload && typeof payload === "object" ? payload : {};
1094
+ const seam = item.seam_summary && typeof item.seam_summary === "object" ? item.seam_summary : {};
1095
+ const execution = seam.execution_consequence_summary && typeof seam.execution_consequence_summary === "object"
1096
+ ? seam.execution_consequence_summary
1097
+ : {};
1098
+ const economics = seam.payment_settlement_treasury_summary && typeof seam.payment_settlement_treasury_summary === "object"
1099
+ ? seam.payment_settlement_treasury_summary
1100
+ : {};
1101
+ const proof = seam.proof_handoff_summary && typeof seam.proof_handoff_summary === "object"
1102
+ ? summarizeProofHandoffPayload(seam.proof_handoff_summary)
1103
+ : null;
1104
+ return {
1105
+ ok: item.ok === true,
1106
+ result_package_ref: item.result_package_ref || null,
1107
+ source_ref: item.source_ref || null,
1108
+ committed_ref: item.committed_ref || null,
1109
+ transaction_id: item.transaction_id || null,
1110
+ receipt_id: item.receipt_id || null,
1111
+ delivery_id: item.delivery_id || null,
1112
+ transaction_status: item.transaction_status || execution.transaction_status || null,
1113
+ seam_layer_count: Number(item.seam_layer_count || 0),
1114
+ payment_protocol: economics.payment_protocol || null,
1115
+ settlement_mode: economics.settlement_mode || null,
1116
+ payment_ledger_count: Number(economics.payment_ledger_count || 0),
1117
+ proof_handoff_summary: proof
1118
+ };
1119
+ }
1120
+
1121
+ function summarizeInteractionResultPackagePortableHandoffPayload(payload) {
1122
+ const item = payload && typeof payload === "object" ? payload : {};
1123
+ return {
1124
+ ok: item.ok === true,
1125
+ result_package_ref: item.result_package_ref || null,
1126
+ source_ref: item.source_ref || null,
1127
+ committed_ref: item.committed_ref || null,
1128
+ transaction_id: item.transaction_id || null,
1129
+ receipt_id: item.receipt_id || null,
1130
+ proof_ref: item.proof_ref || null,
1131
+ payment_protocol: item.payment_protocol || null,
1132
+ settlement_mode: item.settlement_mode || null,
1133
+ seam_layer_count: Array.isArray(item.seam_layers)
1134
+ ? item.seam_layers.length
1135
+ : Number(item.seam_layer_count || 0),
1136
+ task_ref_count: Array.isArray(item.task_refs)
1137
+ ? item.task_refs.length
1138
+ : Number(item.task_ref_count || 0)
1139
+ };
1140
+ }
1141
+
1092
1142
  function buildCatalogSummarySource(client) {
1093
1143
  const baseCatalog = client && client.catalogCache && typeof client.catalogCache === "object"
1094
1144
  ? client.catalogCache
@@ -2652,6 +2702,85 @@ class CommerceClient {
2652
2702
  return result && result.data && result.data.class_pack ? result.data.class_pack : null;
2653
2703
  }
2654
2704
 
2705
+ async getPrecommitInteractionPacks(forceRefresh) {
2706
+ if (!forceRefresh && this.catalogSummaryCache && this.catalogSummaryCache.precommitPacks) {
2707
+ return this.catalogSummaryCache.precommitPacks;
2708
+ }
2709
+ const result = await this.getJson("/v1/transaction-center/precommit-packs");
2710
+ if (!forceRefresh) {
2711
+ this.catalogSummaryCache = this.catalogSummaryCache || {};
2712
+ this.catalogSummaryCache.precommitPacks = result.data;
2713
+ }
2714
+ return result.data;
2715
+ }
2716
+
2717
+ async getPrecommitInteractionPacksSummary(forceRefresh) {
2718
+ const result = await this.getJson("/v1/transaction-center/precommit-packs/summary");
2719
+ return result && result.data ? result.data : { ok: true, precommit_pack_count: 0, precommit_pack_refs: [], precommit_packs: [] };
2720
+ }
2721
+
2722
+ async getPrecommitInteractionPack(packRef, forceRefresh) {
2723
+ const normalized = String(packRef || "").trim();
2724
+ if (!normalized) return null;
2725
+ const result = await this.getJson(`/v1/transaction-center/precommit-pack?ref=${encodeURIComponent(normalized)}`);
2726
+ return result && result.data && result.data.precommit_pack ? result.data.precommit_pack : null;
2727
+ }
2728
+
2729
+ async getInteractionSpinePaths(forceRefresh) {
2730
+ if (!forceRefresh && this.catalogSummaryCache && this.catalogSummaryCache.spinePaths) {
2731
+ return this.catalogSummaryCache.spinePaths;
2732
+ }
2733
+ const result = await this.getJson("/v1/transaction-center/spine-paths");
2734
+ if (!forceRefresh) {
2735
+ this.catalogSummaryCache = this.catalogSummaryCache || {};
2736
+ this.catalogSummaryCache.spinePaths = result.data;
2737
+ }
2738
+ return result.data;
2739
+ }
2740
+
2741
+ async getInteractionSpinePathsSummary(forceRefresh) {
2742
+ const result = await this.getJson("/v1/transaction-center/spine-paths/summary");
2743
+ return result && result.data ? result.data : { ok: true, spine_path_count: 0, spine_path_refs: [], spine_paths: [] };
2744
+ }
2745
+
2746
+ async getInteractionSpinePath(pathRef, forceRefresh) {
2747
+ const normalized = String(pathRef || "").trim();
2748
+ if (!normalized) return null;
2749
+ const result = await this.getJson(`/v1/transaction-center/spine-path?ref=${encodeURIComponent(normalized)}`);
2750
+ return result && result.data && result.data.spine_path ? result.data.spine_path : null;
2751
+ }
2752
+
2753
+ async getInteractionResultPackages(forceRefresh) {
2754
+ if (!forceRefresh && this.catalogSummaryCache && this.catalogSummaryCache.resultPackages) {
2755
+ return this.catalogSummaryCache.resultPackages;
2756
+ }
2757
+ const result = await this.getJson("/v1/transaction-center/result-packages");
2758
+ if (!forceRefresh) {
2759
+ this.catalogSummaryCache = this.catalogSummaryCache || {};
2760
+ this.catalogSummaryCache.resultPackages = result.data;
2761
+ }
2762
+ return result.data;
2763
+ }
2764
+
2765
+ async getInteractionResultPackagesSummary(forceRefresh) {
2766
+ const result = await this.getJson("/v1/transaction-center/result-packages/summary");
2767
+ return result && result.data ? result.data : { ok: true, result_package_count: 0, result_package_refs: [], result_packages: [] };
2768
+ }
2769
+
2770
+ async getInteractionResultPackage(resultPackageRef, forceRefresh) {
2771
+ const normalized = String(resultPackageRef || "").trim();
2772
+ if (!normalized) return null;
2773
+ const result = await this.getJson(`/v1/transaction-center/result-package?ref=${encodeURIComponent(normalized)}`);
2774
+ return result && result.data && result.data.result_package ? result.data.result_package : null;
2775
+ }
2776
+
2777
+ async getInteractionResultPackageExportTemplate(resultPackageRef) {
2778
+ const normalized = String(resultPackageRef || "").trim();
2779
+ if (!normalized) return null;
2780
+ const result = await this.getJson(`/v1/transaction-center/result-package/export-template?ref=${encodeURIComponent(normalized)}`);
2781
+ return result && result.data ? result.data : null;
2782
+ }
2783
+
2655
2784
  async listSettlementPayees(forceRefresh) {
2656
2785
  const summary = await this.getSettlementPayeeSummaries(forceRefresh);
2657
2786
  return extractSummaryValues(summary, "settlement_payees", "payee_agent_id");
@@ -3906,6 +4035,142 @@ class CommerceClient {
3906
4035
  };
3907
4036
  }
3908
4037
 
4038
+ async runPrecommitInteractionPack(packRef, body, options) {
4039
+ const opts = options || {};
4040
+ return this.runNamedTaskRoute("/v1/transaction-center/precommit-packs/run", {
4041
+ command: opts.command || String(packRef || "").trim() || "precommit.pack.run",
4042
+ precommit_pack_ref: String(packRef || "").trim(),
4043
+ body: body || {},
4044
+ callback_url: opts.callbackUrl || null,
4045
+ settlement_mode: opts.settlementMode || null,
4046
+ payment_protocol: opts.paymentProtocol || null,
4047
+ protocol: opts.protocol || null,
4048
+ integration_id: opts.integrationId || null,
4049
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4050
+ integration_context: opts.integrationContext || null
4051
+ });
4052
+ }
4053
+
4054
+ async runPrecommitInteractionPackSummary(packRef, body, options) {
4055
+ const result = await this.runPrecommitInteractionPack(packRef, body, options);
4056
+ return {
4057
+ ok: result && result.ok === true,
4058
+ precommit_pack_ref: result && result.precommit_pack ? result.precommit_pack.precommit_pack_ref || null : null,
4059
+ readiness_kind: result && result.precommit_pack ? result.precommit_pack.readiness_kind || null : null,
4060
+ result_set_summary: result && result.result_set_summary ? result.result_set_summary : null,
4061
+ linked_record_summary: result && result.linked_record_summary ? result.linked_record_summary : null,
4062
+ activity_summary: result && result.activity_summary ? result.activity_summary : null,
4063
+ precommit_readiness_summary: result && result.precommit_readiness_summary ? result.precommit_readiness_summary : null
4064
+ };
4065
+ }
4066
+
4067
+ async runInteractionSpinePath(pathRef, body, options) {
4068
+ const opts = options || {};
4069
+ return this.runNamedTaskRoute("/v1/transaction-center/spine-paths/run", {
4070
+ command: opts.command || String(pathRef || "").trim() || "spine.path.run",
4071
+ spine_path_ref: String(pathRef || "").trim(),
4072
+ body: body || {},
4073
+ callback_url: opts.callbackUrl || null,
4074
+ settlement_mode: opts.settlementMode || null,
4075
+ payment_protocol: opts.paymentProtocol || null,
4076
+ protocol: opts.protocol || null,
4077
+ integration_id: opts.integrationId || null,
4078
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4079
+ integration_context: opts.integrationContext || null
4080
+ });
4081
+ }
4082
+
4083
+ async runInteractionSpinePathSummary(pathRef, body, options) {
4084
+ const result = await this.runInteractionSpinePath(pathRef, body, options);
4085
+ return {
4086
+ ok: result && result.ok === true,
4087
+ spine_path_ref: result && result.spine_path ? result.spine_path.spine_path_ref || null : null,
4088
+ committed_ref: result && result.spine_path ? result.spine_path.committed_ref || null : null,
4089
+ result_set_summary: result && result.result_set_summary ? result.result_set_summary : null,
4090
+ linked_record_summary: result && result.linked_record_summary ? result.linked_record_summary : null,
4091
+ activity_summary: result && result.activity_summary ? result.activity_summary : null,
4092
+ spine_summary: result && result.spine_summary ? result.spine_summary : null
4093
+ };
4094
+ }
4095
+
4096
+ async runInteractionResultPackage(resultPackageRef, body, options) {
4097
+ const opts = options || {};
4098
+ return this.runNamedTaskRoute("/v1/transaction-center/result-packages/run", {
4099
+ command: opts.command || String(resultPackageRef || "").trim() || "result.package.run",
4100
+ result_package_ref: String(resultPackageRef || "").trim(),
4101
+ body: body || {},
4102
+ callback_url: opts.callbackUrl || null,
4103
+ settlement_mode: opts.settlementMode || null,
4104
+ payment_protocol: opts.paymentProtocol || null,
4105
+ protocol: opts.protocol || null,
4106
+ integration_id: opts.integrationId || null,
4107
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4108
+ integration_context: opts.integrationContext || null
4109
+ });
4110
+ }
4111
+
4112
+ async runInteractionResultPackageSummary(resultPackageRef, body, options) {
4113
+ const result = await this.runInteractionResultPackage(resultPackageRef, body, options);
4114
+ return {
4115
+ ok: result && result.ok === true,
4116
+ result_package_ref: result && result.result_package ? result.result_package.result_package_ref || null : null,
4117
+ source_ref: result && result.result_package ? result.result_package.source_ref || null : null,
4118
+ result_package_summary: this.summarizeInteractionResultPackage(
4119
+ result && result.result_package_summary ? result.result_package_summary : null
4120
+ ),
4121
+ result_set_summary: result && result.result_set_summary ? result.result_set_summary : null,
4122
+ linked_record_summary: result && result.linked_record_summary ? result.linked_record_summary : null,
4123
+ activity_summary: result && result.activity_summary ? result.activity_summary : null,
4124
+ seam_summary: result && result.seam_summary ? {
4125
+ ...result.seam_summary,
4126
+ proof_handoff_summary: this.summarizeProofHandoff(
4127
+ result.seam_summary && result.seam_summary.proof_handoff_summary
4128
+ ? result.seam_summary.proof_handoff_summary
4129
+ : null
4130
+ )
4131
+ } : null
4132
+ };
4133
+ }
4134
+
4135
+ async exportInteractionResultPackage(resultPackageRef, body, options) {
4136
+ const opts = options || {};
4137
+ return this.runNamedTaskRoute("/v1/transaction-center/result-packages/export", {
4138
+ command: opts.command || String(resultPackageRef || "").trim() || "result.package.export",
4139
+ result_package_ref: String(resultPackageRef || "").trim(),
4140
+ body: body || {},
4141
+ callback_url: opts.callbackUrl || null,
4142
+ settlement_mode: opts.settlementMode || null,
4143
+ payment_protocol: opts.paymentProtocol || null,
4144
+ protocol: opts.protocol || null,
4145
+ integration_id: opts.integrationId || null,
4146
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4147
+ integration_context: opts.integrationContext || null
4148
+ });
4149
+ }
4150
+
4151
+ async exportInteractionResultPackageSummary(resultPackageRef, body, options) {
4152
+ const result = await this.exportInteractionResultPackage(resultPackageRef, body, options);
4153
+ return {
4154
+ ok: result && result.ok === true,
4155
+ result_package_ref: result && result.result_package ? result.result_package.result_package_ref || null : null,
4156
+ source_ref: result && result.result_package ? result.result_package.source_ref || null : null,
4157
+ result_package_summary: this.summarizeInteractionResultPackage(
4158
+ result && result.result_package_summary ? result.result_package_summary : null
4159
+ ),
4160
+ portable_handoff_summary: this.summarizeInteractionResultPackagePortableHandoff(
4161
+ result && result.portable_handoff_summary ? result.portable_handoff_summary : null
4162
+ ),
4163
+ seam_summary: result && result.seam_summary ? {
4164
+ ...result.seam_summary,
4165
+ proof_handoff_summary: this.summarizeProofHandoff(
4166
+ result.seam_summary && result.seam_summary.proof_handoff_summary
4167
+ ? result.seam_summary.proof_handoff_summary
4168
+ : null
4169
+ )
4170
+ } : null
4171
+ };
4172
+ }
4173
+
3909
4174
  async runNamedTaskRoute(path, payload) {
3910
4175
  if (!this.apiKey || !this.walletId || !this.walletSecret) {
3911
4176
  throw new Error("named task routes require apiKey, walletId, and walletSecret");
@@ -5405,6 +5670,14 @@ class CommerceClient {
5405
5670
  return summarizeProofHandoffPayload(payload);
5406
5671
  }
5407
5672
 
5673
+ summarizeInteractionResultPackage(payload) {
5674
+ return summarizeInteractionResultPackagePayload(payload);
5675
+ }
5676
+
5677
+ summarizeInteractionResultPackagePortableHandoff(payload) {
5678
+ return summarizeInteractionResultPackagePortableHandoffPayload(payload);
5679
+ }
5680
+
5408
5681
  summarizeTask(task) {
5409
5682
  return summarizeCatalogTask(task);
5410
5683
  }
@@ -6158,6 +6431,8 @@ module.exports = {
6158
6431
  summarizeQuotePreviewPayload,
6159
6432
  summarizeDefaultTransactionCenterPayload,
6160
6433
  summarizeDefaultTransactionEconomicsPayload,
6434
+ summarizeInteractionResultPackagePayload,
6435
+ summarizeInteractionResultPackagePortableHandoffPayload,
6161
6436
  summarizeDefaultTaskPackCatalogPayload,
6162
6437
  summarizeDefaultGuidedLoopBundlePayload,
6163
6438
  summarizeProofHandoffPayload,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xytara",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "Machine commerce SDK for discovery, quoting, execution, lifecycle inspection, and adapters.",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
package/server.js CHANGED
@@ -7,11 +7,17 @@ const {
7
7
  buildDefaultTransactionCenter,
8
8
  buildDefaultTransactionEconomics,
9
9
  buildDefaultTransactionGuidedLoopCatalog,
10
+ buildInteractionResultPackageCatalog,
11
+ buildInteractionSpinePathCatalog,
12
+ buildPrecommitInteractionPackCatalog,
10
13
  buildDefaultTransactionTaskPackCatalog,
11
14
  buildTransactionClassPackCatalog,
12
15
  getCatalog,
13
16
  getDefaultTransactionGuidedLoop,
14
17
  getDefaultTransactionTaskPack,
18
+ getInteractionResultPackage,
19
+ getInteractionSpinePath,
20
+ getPrecommitInteractionPack,
15
21
  getTransactionClassPack,
16
22
  getTaskDetail,
17
23
  getWorkflowDetail,
@@ -20,7 +26,10 @@ const {
20
26
  summarizeDefaultTransactionCenter,
21
27
  summarizeDefaultTransactionEconomics,
22
28
  summarizeDefaultTransactionGuidedLoops,
29
+ summarizeInteractionResultPackages,
30
+ summarizeInteractionSpinePaths,
23
31
  summarizeDefaultTransactionTaskPacks,
32
+ summarizePrecommitInteractionPacks,
24
33
  summarizeTransactionClassPacks
25
34
  } = require("./lib/catalog_contract");
26
35
  const {
@@ -506,6 +515,276 @@ function buildTransactionClassPackRunPayload(body) {
506
515
  return null;
507
516
  }
508
517
 
518
+ function buildPrecommitInteractionPackRunPayload(body) {
519
+ const requestBody = body && typeof body === "object" && !Array.isArray(body) ? body : {};
520
+ const packBody = requestBody.body && typeof requestBody.body === "object" && !Array.isArray(requestBody.body)
521
+ ? requestBody.body
522
+ : requestBody;
523
+ const packRef = String(requestBody.precommit_pack_ref || "").trim();
524
+ const integrationIds = Array.isArray(requestBody.integration_ids) && requestBody.integration_ids.length > 0
525
+ ? requestBody.integration_ids
526
+ : ["builtin.payment.x402", "builtin.settlement.chain"];
527
+
528
+ if (packRef === "precommit.a2a.settlement.readiness") {
529
+ return buildNamedTaskSetPayload([
530
+ {
531
+ task_id: "task_1",
532
+ task_ref: "a2a.negotiate",
533
+ body: {
534
+ counterparty_agent_id: packBody.counterparty_agent_id,
535
+ task_pack_ref: packBody.task_pack_ref,
536
+ negotiation_mode: packBody.negotiation_mode
537
+ }
538
+ },
539
+ {
540
+ task_id: "task_2",
541
+ task_ref: "admission.preview",
542
+ body: {
543
+ source_zone_id: packBody.source_zone_id,
544
+ target_zone_id: packBody.target_zone_id,
545
+ interaction_class: packBody.interaction_class
546
+ }
547
+ },
548
+ {
549
+ task_id: "task_3",
550
+ task_ref: "a2a.commit",
551
+ body: {
552
+ negotiation_id: packBody.negotiation_id,
553
+ intent_id: packBody.intent_id
554
+ }
555
+ }
556
+ ], {
557
+ ...requestBody,
558
+ ...packBody,
559
+ protocol: requestBody.protocol || null,
560
+ payment_protocol: requestBody.payment_protocol || "x402",
561
+ integration_ids: integrationIds,
562
+ settlement_mode: requestBody.settlement_mode || "evm_payment"
563
+ }, requestBody.command || packRef);
564
+ }
565
+
566
+ if (packRef === "precommit.a2c.tooling.readiness") {
567
+ return buildNamedTaskSetPayload([
568
+ {
569
+ task_id: "task_1",
570
+ task_ref: "a2c.session.open",
571
+ body: {
572
+ agent_id: packBody.agent_id,
573
+ channel_ref: packBody.channel_ref
574
+ }
575
+ },
576
+ {
577
+ task_id: "task_2",
578
+ task_ref: "a2c.pack.preview",
579
+ body: {
580
+ agent_id: packBody.agent_id,
581
+ pack_ref: packBody.pack_ref
582
+ }
583
+ },
584
+ {
585
+ task_id: "task_3",
586
+ task_ref: "admission.preview",
587
+ body: {
588
+ source_zone_id: packBody.source_zone_id,
589
+ target_zone_id: packBody.target_zone_id,
590
+ interaction_class: packBody.interaction_class
591
+ }
592
+ }
593
+ ], {
594
+ ...requestBody,
595
+ ...packBody,
596
+ protocol: requestBody.protocol || null,
597
+ payment_protocol: requestBody.payment_protocol || "x402",
598
+ integration_ids: integrationIds,
599
+ settlement_mode: requestBody.settlement_mode || "evm_payment"
600
+ }, requestBody.command || packRef);
601
+ }
602
+
603
+ if (packRef === "precommit.job.commitment.readiness") {
604
+ return buildNamedTaskSetPayload([
605
+ {
606
+ task_id: "task_1",
607
+ task_ref: "jobs.quote",
608
+ body: {
609
+ job_type: packBody.job_type
610
+ }
611
+ },
612
+ {
613
+ task_id: "task_2",
614
+ task_ref: "admission.preview",
615
+ body: {
616
+ source_zone_id: packBody.source_zone_id,
617
+ target_zone_id: packBody.target_zone_id,
618
+ interaction_class: packBody.interaction_class
619
+ }
620
+ },
621
+ {
622
+ task_id: "task_3",
623
+ task_ref: "jobs.reserve",
624
+ body: {
625
+ job_id: packBody.job_id
626
+ }
627
+ }
628
+ ], {
629
+ ...requestBody,
630
+ ...packBody,
631
+ protocol: requestBody.protocol || null,
632
+ payment_protocol: requestBody.payment_protocol || "x402",
633
+ integration_ids: integrationIds,
634
+ settlement_mode: requestBody.settlement_mode || "evm_payment"
635
+ }, requestBody.command || packRef);
636
+ }
637
+
638
+ return null;
639
+ }
640
+
641
+ function buildInteractionSpinePathRunPayload(body) {
642
+ const requestBody = body && typeof body === "object" && !Array.isArray(body) ? body : {};
643
+ const pathBody = requestBody.body && typeof requestBody.body === "object" && !Array.isArray(requestBody.body)
644
+ ? requestBody.body
645
+ : requestBody;
646
+ const pathRef = String(requestBody.spine_path_ref || "").trim();
647
+ const integrationIds = Array.isArray(requestBody.integration_ids) && requestBody.integration_ids.length > 0
648
+ ? requestBody.integration_ids
649
+ : ["builtin.payment.x402", "builtin.settlement.chain"];
650
+
651
+ if (pathRef === "spine.a2a.settlement") {
652
+ return buildNamedTaskSetPayload([
653
+ {
654
+ task_id: "task_1",
655
+ task_ref: "a2a.negotiate",
656
+ body: {
657
+ counterparty_agent_id: pathBody.counterparty_agent_id,
658
+ task_pack_ref: pathBody.task_pack_ref,
659
+ negotiation_mode: pathBody.negotiation_mode
660
+ }
661
+ },
662
+ {
663
+ task_id: "task_2",
664
+ task_ref: "admission.preview",
665
+ body: {
666
+ source_zone_id: pathBody.source_zone_id,
667
+ target_zone_id: pathBody.target_zone_id,
668
+ interaction_class: pathBody.interaction_class
669
+ }
670
+ },
671
+ {
672
+ task_id: "task_3",
673
+ task_ref: "a2a.commit",
674
+ body: {
675
+ negotiation_id: pathBody.negotiation_id,
676
+ intent_id: pathBody.intent_id
677
+ }
678
+ },
679
+ {
680
+ task_id: "task_4",
681
+ task_ref: "settlement.submit",
682
+ body: {
683
+ intent_id: pathBody.intent_id
684
+ }
685
+ }
686
+ ], {
687
+ ...requestBody,
688
+ ...pathBody,
689
+ protocol: requestBody.protocol || null,
690
+ payment_protocol: requestBody.payment_protocol || "x402",
691
+ integration_ids: integrationIds,
692
+ settlement_mode: requestBody.settlement_mode || "evm_payment"
693
+ }, requestBody.command || pathRef);
694
+ }
695
+
696
+ if (pathRef === "spine.a2c.tooling") {
697
+ return buildNamedTaskSetPayload([
698
+ {
699
+ task_id: "task_1",
700
+ task_ref: "a2c.session.open",
701
+ body: {
702
+ agent_id: pathBody.agent_id,
703
+ channel_ref: pathBody.channel_ref
704
+ }
705
+ },
706
+ {
707
+ task_id: "task_2",
708
+ task_ref: "a2c.pack.preview",
709
+ body: {
710
+ agent_id: pathBody.agent_id,
711
+ pack_ref: pathBody.pack_ref
712
+ }
713
+ },
714
+ {
715
+ task_id: "task_3",
716
+ task_ref: "admission.preview",
717
+ body: {
718
+ source_zone_id: pathBody.source_zone_id,
719
+ target_zone_id: pathBody.target_zone_id,
720
+ interaction_class: pathBody.interaction_class
721
+ }
722
+ },
723
+ {
724
+ task_id: "task_4",
725
+ task_ref: "adapter.mcp.invoke",
726
+ body: {
727
+ tool_name: pathBody.tool_name,
728
+ arguments: pathBody.arguments && typeof pathBody.arguments === "object" && !Array.isArray(pathBody.arguments)
729
+ ? pathBody.arguments
730
+ : {}
731
+ }
732
+ }
733
+ ], {
734
+ ...requestBody,
735
+ ...pathBody,
736
+ protocol: requestBody.protocol || null,
737
+ payment_protocol: requestBody.payment_protocol || "x402",
738
+ integration_ids: integrationIds,
739
+ settlement_mode: requestBody.settlement_mode || "evm_payment"
740
+ }, requestBody.command || pathRef);
741
+ }
742
+
743
+ if (pathRef === "spine.job.commitment") {
744
+ return buildNamedTaskSetPayload([
745
+ {
746
+ task_id: "task_1",
747
+ task_ref: "jobs.quote",
748
+ body: {
749
+ job_type: pathBody.job_type
750
+ }
751
+ },
752
+ {
753
+ task_id: "task_2",
754
+ task_ref: "admission.preview",
755
+ body: {
756
+ source_zone_id: pathBody.source_zone_id,
757
+ target_zone_id: pathBody.target_zone_id,
758
+ interaction_class: pathBody.interaction_class
759
+ }
760
+ },
761
+ {
762
+ task_id: "task_3",
763
+ task_ref: "jobs.reserve",
764
+ body: {
765
+ job_id: pathBody.job_id
766
+ }
767
+ },
768
+ {
769
+ task_id: "task_4",
770
+ task_ref: "jobs.commit",
771
+ body: {
772
+ job_id: pathBody.job_id
773
+ }
774
+ }
775
+ ], {
776
+ ...requestBody,
777
+ ...pathBody,
778
+ protocol: requestBody.protocol || null,
779
+ payment_protocol: requestBody.payment_protocol || "x402",
780
+ integration_ids: integrationIds,
781
+ settlement_mode: requestBody.settlement_mode || "evm_payment"
782
+ }, requestBody.command || pathRef);
783
+ }
784
+
785
+ return null;
786
+ }
787
+
509
788
  function listTransactionRecords(filters) {
510
789
  const transactions = Array.from(state.transactions.values()).map((item) => item.transaction);
511
790
  return listRecords(new Map(transactions.map((item) => [item.transaction_id, item])), filters);
@@ -652,6 +931,162 @@ function buildProofHandoffSummary(result, sourceRef) {
652
931
  };
653
932
  }
654
933
 
934
+ function buildPrecommitReadinessSummary(result, pack) {
935
+ const resultSet = buildResultSetFromCommandResult(result);
936
+ const transaction = resultSet.transaction || {};
937
+ const taskRefs = transaction.execution && transaction.execution.results_by_task_id
938
+ ? Object.values(transaction.execution.results_by_task_id).map((entry) => entry && entry.task_ref).filter(Boolean)
939
+ : [];
940
+ const admissionChecked = taskRefs.includes("admission.preview");
941
+ const negotiationSignals = taskRefs.filter((ref) => ref === "a2a.negotiate" || ref === "a2c.session.open");
942
+ const commitmentSignals = taskRefs.filter((ref) => ref === "a2a.commit" || ref === "a2c.pack.preview" || ref === "jobs.reserve");
943
+ const readinessPosture = admissionChecked && commitmentSignals.length > 0
944
+ ? "ready_for_committed_run"
945
+ : negotiationSignals.length > 0
946
+ ? "negotiation_in_progress"
947
+ : "precommit_partial";
948
+ return {
949
+ ok: true,
950
+ precommit_pack_ref: pack && pack.precommit_pack_ref ? pack.precommit_pack_ref : null,
951
+ readiness_kind: pack && pack.readiness_kind ? pack.readiness_kind : null,
952
+ protocol: transaction.protocol || (pack && pack.protocol ? pack.protocol : null),
953
+ payment_protocol: transaction.payment && transaction.payment.protocol
954
+ ? transaction.payment.protocol
955
+ : (pack && pack.default_payment_protocol ? pack.default_payment_protocol : null),
956
+ settlement_mode: transaction.settlement && transaction.settlement.mode
957
+ ? transaction.settlement.mode
958
+ : (pack && pack.default_settlement_mode ? pack.default_settlement_mode : null),
959
+ task_refs: taskRefs,
960
+ negotiation_signal_count: negotiationSignals.length,
961
+ commitment_signal_count: commitmentSignals.length,
962
+ admission_checked: admissionChecked,
963
+ readiness_posture: readinessPosture,
964
+ recommended_next_surface: pack && pack.recommended_next_surface ? pack.recommended_next_surface : null,
965
+ recommended_next_ref: pack && pack.recommended_next_ref ? pack.recommended_next_ref : null,
966
+ transaction_id: transaction.transaction_id || null
967
+ };
968
+ }
969
+
970
+ function buildInteractionSpineSummary(result, path) {
971
+ const precommitPack = path && path.precommit_pack_ref ? getPrecommitInteractionPack(path.precommit_pack_ref) : null;
972
+ return {
973
+ ok: true,
974
+ spine_path_ref: path && path.spine_path_ref ? path.spine_path_ref : null,
975
+ precommit_pack_ref: path && path.precommit_pack_ref ? path.precommit_pack_ref : null,
976
+ committed_ref: path && path.committed_ref ? path.committed_ref : null,
977
+ proof_followthrough: path && path.proof_followthrough ? path.proof_followthrough : null,
978
+ precommit_readiness_summary: buildPrecommitReadinessSummary(result, precommitPack),
979
+ proof_handoff_summary: buildProofHandoffSummary(result, path && path.committed_ref ? path.committed_ref : null)
980
+ };
981
+ }
982
+
983
+ function buildInteractionResultSeamSummary(result, resultPackage) {
984
+ const resultSet = buildResultSetFromCommandResult(result);
985
+ const linked = buildLinkedRecordSetFromCommandResult(result);
986
+ const transaction = resultSet.transaction || {};
987
+ const receipt = resultSet.receipt || {};
988
+ const delivery = resultSet.delivery || {};
989
+ const payment = transaction.payment && typeof transaction.payment === "object" ? transaction.payment : {};
990
+ const settlement = transaction.settlement && typeof transaction.settlement === "object" ? transaction.settlement : {};
991
+ const treasury = transaction.treasury && typeof transaction.treasury === "object" ? transaction.treasury : {};
992
+ const taskRefs = transaction.execution && transaction.execution.results_by_task_id
993
+ ? Object.values(transaction.execution.results_by_task_id).map((entry) => entry && entry.task_ref).filter(Boolean)
994
+ : [];
995
+ const proofHandoffSummary = buildProofHandoffSummary(result, resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null);
996
+ return {
997
+ ok: true,
998
+ result_package_ref: resultPackage && resultPackage.result_package_ref ? resultPackage.result_package_ref : null,
999
+ source_ref: resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null,
1000
+ execution_consequence_summary: {
1001
+ task_count: taskRefs.length,
1002
+ task_refs: taskRefs,
1003
+ transaction_status: transaction.status || null,
1004
+ receipt_status: receipt.status || null,
1005
+ delivery_status: delivery.status || null,
1006
+ consequence_ready: Boolean(transaction.transaction_id && receipt.receipt_id)
1007
+ },
1008
+ payment_settlement_treasury_summary: {
1009
+ payment_protocol: payment.protocol || null,
1010
+ settlement_mode: settlement.mode || null,
1011
+ treasury_destination_id: treasury.destination_id || null,
1012
+ payee_agent_id: settlement.payee_agent_id || null,
1013
+ payment_ledger_count: Array.isArray(linked.payment_ledger) ? linked.payment_ledger.length : 0
1014
+ },
1015
+ proof_handoff_summary: proofHandoffSummary,
1016
+ recommended_extension_surface: proofHandoffSummary.proof_ready
1017
+ ? "/v1/proof-center/interaction-spine-handoff/run"
1018
+ : "/v1/transaction-center/result-packages/run"
1019
+ };
1020
+ }
1021
+
1022
+ function buildInteractionResultPackageSummary(result, resultPackage) {
1023
+ const resultSet = buildResultSetFromCommandResult(result);
1024
+ const transaction = resultSet.transaction || {};
1025
+ const receipt = resultSet.receipt || {};
1026
+ const delivery = resultSet.delivery || {};
1027
+ return {
1028
+ ok: true,
1029
+ result_package_ref: resultPackage && resultPackage.result_package_ref ? resultPackage.result_package_ref : null,
1030
+ source_ref: resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null,
1031
+ source_kind: resultPackage && resultPackage.source_kind ? resultPackage.source_kind : null,
1032
+ committed_ref: resultPackage && resultPackage.committed_ref ? resultPackage.committed_ref : null,
1033
+ transaction_id: transaction.transaction_id || null,
1034
+ receipt_id: receipt.receipt_id || null,
1035
+ delivery_id: delivery.delivery_id || null,
1036
+ transaction_status: transaction.status || null,
1037
+ proof_ref: receipt.proof_ref || null,
1038
+ seam_layer_count: Array.isArray(resultPackage && resultPackage.seam_layers) ? resultPackage.seam_layers.length : 0
1039
+ };
1040
+ }
1041
+
1042
+ function buildInteractionResultPackagePortableHandoff(result, resultPackage) {
1043
+ const resultSet = buildResultSetFromCommandResult(result);
1044
+ const linked = buildLinkedRecordSetFromCommandResult(result);
1045
+ const transaction = resultSet.transaction || {};
1046
+ const receipt = resultSet.receipt || {};
1047
+ const settlement = transaction.settlement && typeof transaction.settlement === "object" ? transaction.settlement : {};
1048
+ const payment = transaction.payment && typeof transaction.payment === "object" ? transaction.payment : {};
1049
+ const treasury = transaction.treasury && typeof transaction.treasury === "object" ? transaction.treasury : {};
1050
+ const taskRefs = transaction.execution && transaction.execution.results_by_task_id
1051
+ ? Object.values(transaction.execution.results_by_task_id).map((entry) => entry && entry.task_ref).filter(Boolean)
1052
+ : [];
1053
+ return {
1054
+ ok: true,
1055
+ handoff_kind: "interaction_result_package",
1056
+ result_package_ref: resultPackage && resultPackage.result_package_ref ? resultPackage.result_package_ref : null,
1057
+ source_ref: resultPackage && resultPackage.source_ref ? resultPackage.source_ref : null,
1058
+ committed_ref: resultPackage && resultPackage.committed_ref ? resultPackage.committed_ref : null,
1059
+ precommit_pack_ref: resultPackage && resultPackage.precommit_pack_ref ? resultPackage.precommit_pack_ref : null,
1060
+ transaction_id: transaction.transaction_id || null,
1061
+ receipt_id: receipt.receipt_id || null,
1062
+ proof_ref: receipt.proof_ref || null,
1063
+ payment_protocol: payment.protocol || null,
1064
+ settlement_mode: settlement.mode || null,
1065
+ treasury_destination_id: treasury.destination_id || null,
1066
+ task_refs: taskRefs,
1067
+ delivery_count: Array.isArray(linked.deliveries) ? linked.deliveries.length : 0,
1068
+ payment_ledger_count: Array.isArray(linked.payment_ledger) ? linked.payment_ledger.length : 0,
1069
+ seam_layers: Array.isArray(resultPackage && resultPackage.seam_layers) ? resultPackage.seam_layers : []
1070
+ };
1071
+ }
1072
+
1073
+ function summarizeInteractionResultPackagePortableHandoff(handoff) {
1074
+ const item = handoff && typeof handoff === "object" ? handoff : {};
1075
+ return {
1076
+ ok: item.ok === true,
1077
+ result_package_ref: item.result_package_ref || null,
1078
+ source_ref: item.source_ref || null,
1079
+ committed_ref: item.committed_ref || null,
1080
+ transaction_id: item.transaction_id || null,
1081
+ receipt_id: item.receipt_id || null,
1082
+ proof_ref: item.proof_ref || null,
1083
+ payment_protocol: item.payment_protocol || null,
1084
+ settlement_mode: item.settlement_mode || null,
1085
+ seam_layer_count: Array.isArray(item.seam_layers) ? item.seam_layers.length : 0,
1086
+ task_ref_count: Array.isArray(item.task_refs) ? item.task_refs.length : 0
1087
+ };
1088
+ }
1089
+
655
1090
  function buildOperationsDashboard(filters) {
656
1091
  const disputes = listRecords(state.disputes, filters);
657
1092
  const refunds = listRecords(state.refunds, filters);
@@ -760,6 +1195,85 @@ async function routeRequest(req, res) {
760
1195
  return;
761
1196
  }
762
1197
 
1198
+ if (req.method === "GET" && url.pathname === "/v1/transaction-center/precommit-packs") {
1199
+ sendJson(res, 200, buildPrecommitInteractionPackCatalog());
1200
+ return;
1201
+ }
1202
+
1203
+ if (req.method === "GET" && url.pathname === "/v1/transaction-center/precommit-packs/summary") {
1204
+ sendJson(res, 200, summarizePrecommitInteractionPacks());
1205
+ return;
1206
+ }
1207
+
1208
+ if (req.method === "GET" && url.pathname === "/v1/transaction-center/precommit-pack") {
1209
+ const pack = getPrecommitInteractionPack(url.searchParams.get("ref"));
1210
+ if (!pack) {
1211
+ sendJson(res, 404, { ok: false, error: "precommit_pack_not_found" });
1212
+ return;
1213
+ }
1214
+ sendJson(res, 200, { ok: true, precommit_pack: pack });
1215
+ return;
1216
+ }
1217
+
1218
+ if (req.method === "GET" && url.pathname === "/v1/transaction-center/spine-paths") {
1219
+ sendJson(res, 200, buildInteractionSpinePathCatalog());
1220
+ return;
1221
+ }
1222
+
1223
+ if (req.method === "GET" && url.pathname === "/v1/transaction-center/spine-paths/summary") {
1224
+ sendJson(res, 200, summarizeInteractionSpinePaths());
1225
+ return;
1226
+ }
1227
+
1228
+ if (req.method === "GET" && url.pathname === "/v1/transaction-center/spine-path") {
1229
+ const path = getInteractionSpinePath(url.searchParams.get("ref"));
1230
+ if (!path) {
1231
+ sendJson(res, 404, { ok: false, error: "spine_path_not_found" });
1232
+ return;
1233
+ }
1234
+ sendJson(res, 200, { ok: true, spine_path: path });
1235
+ return;
1236
+ }
1237
+
1238
+ if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-packages") {
1239
+ sendJson(res, 200, buildInteractionResultPackageCatalog());
1240
+ return;
1241
+ }
1242
+
1243
+ if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-packages/summary") {
1244
+ sendJson(res, 200, summarizeInteractionResultPackages());
1245
+ return;
1246
+ }
1247
+
1248
+ if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-package") {
1249
+ const resultPackage = getInteractionResultPackage(url.searchParams.get("ref"));
1250
+ if (!resultPackage) {
1251
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
1252
+ return;
1253
+ }
1254
+ sendJson(res, 200, { ok: true, result_package: resultPackage });
1255
+ return;
1256
+ }
1257
+
1258
+ if (req.method === "GET" && url.pathname === "/v1/transaction-center/result-package/export-template") {
1259
+ const resultPackage = getInteractionResultPackage(url.searchParams.get("ref"));
1260
+ if (!resultPackage) {
1261
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
1262
+ return;
1263
+ }
1264
+ sendJson(res, 200, {
1265
+ ok: true,
1266
+ result_package: resultPackage,
1267
+ export_template: {
1268
+ handoff_kind: "interaction_result_package",
1269
+ required_fields: ["result_package_ref", "source_ref", "transaction_id", "receipt_id", "proof_ref"],
1270
+ optional_fields: ["committed_ref", "precommit_pack_ref", "payment_protocol", "settlement_mode", "treasury_destination_id", "task_refs", "delivery_count", "payment_ledger_count", "seam_layers"],
1271
+ recommended_proof_surface: "/v1/proof-center/result-package-handoff/run"
1272
+ }
1273
+ });
1274
+ return;
1275
+ }
1276
+
763
1277
  if (req.method === "GET" && url.pathname === "/v1/transaction-center/transaction-class-packs") {
764
1278
  sendJson(res, 200, buildTransactionClassPackCatalog());
765
1279
  return;
@@ -1287,6 +1801,134 @@ async function routeRequest(req, res) {
1287
1801
  return;
1288
1802
  }
1289
1803
 
1804
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/precommit-packs/run") {
1805
+ const body = await readJsonBody(req);
1806
+ const packRef = String(body && body.precommit_pack_ref || "").trim();
1807
+ const pack = getPrecommitInteractionPack(packRef);
1808
+ if (!pack) {
1809
+ sendJson(res, 404, { ok: false, error: "precommit_pack_not_found" });
1810
+ return;
1811
+ }
1812
+ const payload = buildPrecommitInteractionPackRunPayload(body);
1813
+ if (!payload) {
1814
+ sendJson(res, 404, { ok: false, error: "precommit_pack_not_found" });
1815
+ return;
1816
+ }
1817
+ const result = executeCommandRequest(state, payload, req.headers);
1818
+ if (result.status !== 200) {
1819
+ sendJson(res, result.status, result.payload);
1820
+ return;
1821
+ }
1822
+ sendJson(res, 200, {
1823
+ ok: true,
1824
+ precommit_pack: pack,
1825
+ result: result.payload,
1826
+ result_set_summary: summarizeResultSetPayload(buildResultSetFromCommandResult(result.payload)),
1827
+ linked_record_summary: summarizeLinkedRecordSetPayload(buildLinkedRecordSetFromCommandResult(result.payload)),
1828
+ activity_summary: summarizeActivitySnapshotPayload(buildActivitySnapshotFromCommandResult(result.payload)),
1829
+ precommit_readiness_summary: buildPrecommitReadinessSummary(result.payload, pack)
1830
+ });
1831
+ return;
1832
+ }
1833
+
1834
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/spine-paths/run") {
1835
+ const body = await readJsonBody(req);
1836
+ const pathRef = String(body && body.spine_path_ref || "").trim();
1837
+ const path = getInteractionSpinePath(pathRef);
1838
+ if (!path) {
1839
+ sendJson(res, 404, { ok: false, error: "spine_path_not_found" });
1840
+ return;
1841
+ }
1842
+ const payload = buildInteractionSpinePathRunPayload(body);
1843
+ if (!payload) {
1844
+ sendJson(res, 404, { ok: false, error: "spine_path_not_found" });
1845
+ return;
1846
+ }
1847
+ const result = executeCommandRequest(state, payload, req.headers);
1848
+ if (result.status !== 200) {
1849
+ sendJson(res, result.status, result.payload);
1850
+ return;
1851
+ }
1852
+ sendJson(res, 200, {
1853
+ ok: true,
1854
+ spine_path: path,
1855
+ result: result.payload,
1856
+ result_set_summary: summarizeResultSetPayload(buildResultSetFromCommandResult(result.payload)),
1857
+ linked_record_summary: summarizeLinkedRecordSetPayload(buildLinkedRecordSetFromCommandResult(result.payload)),
1858
+ activity_summary: summarizeActivitySnapshotPayload(buildActivitySnapshotFromCommandResult(result.payload)),
1859
+ spine_summary: buildInteractionSpineSummary(result.payload, path)
1860
+ });
1861
+ return;
1862
+ }
1863
+
1864
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-packages/run") {
1865
+ const body = await readJsonBody(req);
1866
+ const resultPackageRef = String(body && body.result_package_ref || "").trim();
1867
+ const resultPackage = getInteractionResultPackage(resultPackageRef);
1868
+ if (!resultPackage) {
1869
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
1870
+ return;
1871
+ }
1872
+ const payload = buildInteractionSpinePathRunPayload({
1873
+ ...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
1874
+ spine_path_ref: resultPackage.source_ref
1875
+ });
1876
+ if (!payload) {
1877
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
1878
+ return;
1879
+ }
1880
+ const result = executeCommandRequest(state, payload, req.headers);
1881
+ if (result.status !== 200) {
1882
+ sendJson(res, result.status, result.payload);
1883
+ return;
1884
+ }
1885
+ sendJson(res, 200, {
1886
+ ok: true,
1887
+ result_package: resultPackage,
1888
+ result: result.payload,
1889
+ result_package_summary: buildInteractionResultPackageSummary(result.payload, resultPackage),
1890
+ result_set_summary: summarizeResultSetPayload(buildResultSetFromCommandResult(result.payload)),
1891
+ linked_record_summary: summarizeLinkedRecordSetPayload(buildLinkedRecordSetFromCommandResult(result.payload)),
1892
+ activity_summary: summarizeActivitySnapshotPayload(buildActivitySnapshotFromCommandResult(result.payload)),
1893
+ seam_summary: buildInteractionResultSeamSummary(result.payload, resultPackage)
1894
+ });
1895
+ return;
1896
+ }
1897
+
1898
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-packages/export") {
1899
+ const body = await readJsonBody(req);
1900
+ const resultPackageRef = String(body && body.result_package_ref || "").trim();
1901
+ const resultPackage = getInteractionResultPackage(resultPackageRef);
1902
+ if (!resultPackage) {
1903
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
1904
+ return;
1905
+ }
1906
+ const payload = buildInteractionSpinePathRunPayload({
1907
+ ...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
1908
+ spine_path_ref: resultPackage.source_ref
1909
+ });
1910
+ if (!payload) {
1911
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
1912
+ return;
1913
+ }
1914
+ const result = executeCommandRequest(state, payload, req.headers);
1915
+ if (result.status !== 200) {
1916
+ sendJson(res, result.status, result.payload);
1917
+ return;
1918
+ }
1919
+ const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
1920
+ sendJson(res, 200, {
1921
+ ok: true,
1922
+ result_package: resultPackage,
1923
+ result: result.payload,
1924
+ result_package_summary: buildInteractionResultPackageSummary(result.payload, resultPackage),
1925
+ portable_handoff_bundle: portableHandoff,
1926
+ portable_handoff_summary: summarizeInteractionResultPackagePortableHandoff(portableHandoff),
1927
+ seam_summary: buildInteractionResultSeamSummary(result.payload, resultPackage)
1928
+ });
1929
+ return;
1930
+ }
1931
+
1290
1932
  if (req.method === "POST" && url.pathname === "/v1/transaction-center/default-loops/run") {
1291
1933
  const body = await readJsonBody(req);
1292
1934
  const loopRef = String(body && body.loop_ref || "").trim();