xytara 1.13.0 → 1.15.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
@@ -145,6 +145,24 @@ The current `1.10.0` line starts building on that by exposing reusable continuat
145
145
 
146
146
  This is intended to make the public stack easier to compose after grouped execution, not just easier to inspect.
147
147
 
148
+ The current `1.14.0` line starts hardening that reusable path into a clearer public composition contract:
149
+
150
+ - prepared-artifact composition-contract summaries
151
+ - composition-contract template surfaces for proof-side contract review
152
+ - compact composition-contract bundles for direct transaction-side contract reuse
153
+ - clearer public contract ids across the reusable-default continuation path
154
+
155
+ This is intended to make the transaction-side continuation path easier to treat as a stable public contract instead of only a strong reusable default.
156
+
157
+ The current `1.15.0` line starts turning that same contract path into a clearer adapter-ready public bridge:
158
+
159
+ - prepared-artifact bridge summaries on top of the composition-contract continuation path
160
+ - bridge template surfaces that package the next proof-side review request directly
161
+ - compact bridge bundles for direct transaction-side bridge reuse
162
+ - compact bridge-carry surfaces for direct transaction-side bridge reuse
163
+
164
+ This is intended to make the transaction-side continuation path easier to hand across a stable adapter-ready bridge instead of treating bridge preparation as an implicit follow-on concern.
165
+
148
166
  ## Package Surface
149
167
 
150
168
  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.13.0";
43
+ const COMMERCE_SDK_VERSION = "1.15.0";
44
44
  const COMMERCE_API_VERSION = "v1";
45
45
 
46
46
  function createClient(options) {
@@ -1181,6 +1181,18 @@ function summarizeInteractionResultPackageContinuationPreparationPayload(payload
1181
1181
  const reusableDefaultTemplate = item.reusable_default_template && typeof item.reusable_default_template === "object"
1182
1182
  ? item.reusable_default_template
1183
1183
  : {};
1184
+ const compositionContract = item.composition_contract_summary && typeof item.composition_contract_summary === "object"
1185
+ ? item.composition_contract_summary
1186
+ : {};
1187
+ const compositionContractTemplate = item.composition_contract_template && typeof item.composition_contract_template === "object"
1188
+ ? item.composition_contract_template
1189
+ : {};
1190
+ const adapterBridge = item.adapter_bridge_summary && typeof item.adapter_bridge_summary === "object"
1191
+ ? item.adapter_bridge_summary
1192
+ : {};
1193
+ const adapterBridgeTemplate = item.adapter_bridge_template && typeof item.adapter_bridge_template === "object"
1194
+ ? item.adapter_bridge_template
1195
+ : {};
1184
1196
  return {
1185
1197
  ok: item.ok === true,
1186
1198
  continuation_ref: continuation ? continuation.continuation_ref : null,
@@ -1204,8 +1216,14 @@ function summarizeInteractionResultPackageContinuationPreparationPayload(payload
1204
1216
  ),
1205
1217
  proof_ready: artifact.durable_path && artifact.durable_path.proof_ready === true,
1206
1218
  reusable_by_default: reusableDefault.default_followthrough && reusableDefault.default_followthrough.reusable_by_default === true,
1219
+ composition_contract_ref: compositionContract.composition_contract_ref || null,
1220
+ contract_ready: compositionContract.contract_ready === true,
1221
+ adapter_bridge_ref: adapterBridge.adapter_bridge_ref || null,
1222
+ bridge_ready: adapterBridge.bridge_ready === true,
1207
1223
  future_adapter_hook_count: Number(extension.future_adapter_hook_count || 0),
1208
1224
  reusable_default_target_surface: reusableDefaultTemplate.target_surface || null,
1225
+ composition_contract_target_surface: compositionContractTemplate.target_surface || null,
1226
+ adapter_bridge_target_surface: adapterBridgeTemplate.target_surface || null,
1209
1227
  extension_target_surface: extensionTemplate.target_surface || null
1210
1228
  };
1211
1229
  }
@@ -4390,6 +4408,118 @@ class CommerceClient {
4390
4408
  });
4391
4409
  }
4392
4410
 
4411
+ async prepareInteractionResultPackageCompositionContractSummary(continuationRef, body, options) {
4412
+ const opts = options || {};
4413
+ return this.runNamedTaskRoute("/v1/transaction-center/result-package-continuations/prepare/contract-summary", {
4414
+ command: opts.command || String(continuationRef || "").trim() || "result.package.continuation.contract.summary",
4415
+ continuation_ref: String(continuationRef || "").trim(),
4416
+ body: body || {},
4417
+ callback_url: opts.callbackUrl || null,
4418
+ settlement_mode: opts.settlementMode || null,
4419
+ payment_protocol: opts.paymentProtocol || null,
4420
+ protocol: opts.protocol || null,
4421
+ integration_id: opts.integrationId || null,
4422
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4423
+ integration_context: opts.integrationContext || null
4424
+ });
4425
+ }
4426
+
4427
+ async prepareInteractionResultPackageCompositionContractBundle(continuationRef, body, options) {
4428
+ const opts = options || {};
4429
+ return this.runNamedTaskRoute("/v1/transaction-center/result-package-continuations/prepare/contract-bundle", {
4430
+ command: opts.command || String(continuationRef || "").trim() || "result.package.continuation.contract.bundle",
4431
+ continuation_ref: String(continuationRef || "").trim(),
4432
+ body: body || {},
4433
+ callback_url: opts.callbackUrl || null,
4434
+ settlement_mode: opts.settlementMode || null,
4435
+ payment_protocol: opts.paymentProtocol || null,
4436
+ protocol: opts.protocol || null,
4437
+ integration_id: opts.integrationId || null,
4438
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4439
+ integration_context: opts.integrationContext || null
4440
+ });
4441
+ }
4442
+
4443
+ async prepareInteractionResultPackageCompositionContractTemplate(continuationRef, body, options) {
4444
+ const opts = options || {};
4445
+ return this.runNamedTaskRoute("/v1/transaction-center/result-package-continuations/prepare/contract-template", {
4446
+ command: opts.command || String(continuationRef || "").trim() || "result.package.continuation.contract.template",
4447
+ continuation_ref: String(continuationRef || "").trim(),
4448
+ body: body || {},
4449
+ callback_url: opts.callbackUrl || null,
4450
+ settlement_mode: opts.settlementMode || null,
4451
+ payment_protocol: opts.paymentProtocol || null,
4452
+ protocol: opts.protocol || null,
4453
+ integration_id: opts.integrationId || null,
4454
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4455
+ integration_context: opts.integrationContext || null
4456
+ });
4457
+ }
4458
+
4459
+ async prepareInteractionResultPackageAdapterBridgeSummary(continuationRef, body, options) {
4460
+ const opts = options || {};
4461
+ return this.runNamedTaskRoute("/v1/transaction-center/result-package-continuations/prepare/bridge-summary", {
4462
+ command: opts.command || String(continuationRef || "").trim() || "result.package.continuation.bridge.summary",
4463
+ continuation_ref: String(continuationRef || "").trim(),
4464
+ body: body || {},
4465
+ callback_url: opts.callbackUrl || null,
4466
+ settlement_mode: opts.settlementMode || null,
4467
+ payment_protocol: opts.paymentProtocol || null,
4468
+ protocol: opts.protocol || null,
4469
+ integration_id: opts.integrationId || null,
4470
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4471
+ integration_context: opts.integrationContext || null
4472
+ });
4473
+ }
4474
+
4475
+ async prepareInteractionResultPackageAdapterBridgeTemplate(continuationRef, body, options) {
4476
+ const opts = options || {};
4477
+ return this.runNamedTaskRoute("/v1/transaction-center/result-package-continuations/prepare/bridge-template", {
4478
+ command: opts.command || String(continuationRef || "").trim() || "result.package.continuation.bridge.template",
4479
+ continuation_ref: String(continuationRef || "").trim(),
4480
+ body: body || {},
4481
+ callback_url: opts.callbackUrl || null,
4482
+ settlement_mode: opts.settlementMode || null,
4483
+ payment_protocol: opts.paymentProtocol || null,
4484
+ protocol: opts.protocol || null,
4485
+ integration_id: opts.integrationId || null,
4486
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4487
+ integration_context: opts.integrationContext || null
4488
+ });
4489
+ }
4490
+
4491
+ async prepareInteractionResultPackageAdapterBridgeBundle(continuationRef, body, options) {
4492
+ const opts = options || {};
4493
+ return this.runNamedTaskRoute("/v1/transaction-center/result-package-continuations/prepare/bridge-bundle", {
4494
+ command: opts.command || String(continuationRef || "").trim() || "result.package.continuation.bridge.bundle",
4495
+ continuation_ref: String(continuationRef || "").trim(),
4496
+ body: body || {},
4497
+ callback_url: opts.callbackUrl || null,
4498
+ settlement_mode: opts.settlementMode || null,
4499
+ payment_protocol: opts.paymentProtocol || null,
4500
+ protocol: opts.protocol || null,
4501
+ integration_id: opts.integrationId || null,
4502
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4503
+ integration_context: opts.integrationContext || null
4504
+ });
4505
+ }
4506
+
4507
+ async prepareInteractionResultPackageAdapterBridgeCarry(continuationRef, body, options) {
4508
+ const opts = options || {};
4509
+ return this.runNamedTaskRoute("/v1/transaction-center/result-package-continuations/prepare/bridge-carry", {
4510
+ command: opts.command || String(continuationRef || "").trim() || "result.package.continuation.bridge.carry",
4511
+ continuation_ref: String(continuationRef || "").trim(),
4512
+ body: body || {},
4513
+ callback_url: opts.callbackUrl || null,
4514
+ settlement_mode: opts.settlementMode || null,
4515
+ payment_protocol: opts.paymentProtocol || null,
4516
+ protocol: opts.protocol || null,
4517
+ integration_id: opts.integrationId || null,
4518
+ integration_ids: Array.isArray(opts.integrationIds) ? opts.integrationIds : [],
4519
+ integration_context: opts.integrationContext || null
4520
+ });
4521
+ }
4522
+
4393
4523
  async runNamedTaskRoute(path, payload) {
4394
4524
  if (!this.apiKey || !this.walletId || !this.walletSecret) {
4395
4525
  throw new Error("named task routes require apiKey, walletId, and walletSecret");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xytara",
3
- "version": "1.13.0",
3
+ "version": "1.15.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
@@ -1274,6 +1274,146 @@ function buildPreparedContinuationReusableDefaultTemplate(portableHandoff, conti
1274
1274
  };
1275
1275
  }
1276
1276
 
1277
+ function buildPreparedContinuationCompositionContractSummary(portableHandoff, continuation) {
1278
+ const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
1279
+ const reusableDefault = buildPreparedContinuationReusableDefaultSummary(portableHandoff, continuation);
1280
+ const seamLayers = Array.isArray(handoff.seam_layers) ? handoff.seam_layers : [];
1281
+ return {
1282
+ ok: true,
1283
+ composition_contract_ref: continuation && continuation.continuation_ref
1284
+ ? `contract.${continuation.continuation_ref}`
1285
+ : null,
1286
+ reusable_default_ref: reusableDefault.reusable_default_ref || null,
1287
+ public_contract_ids: [
1288
+ "prepared_artifact",
1289
+ "reusable_default_review",
1290
+ "proof_run"
1291
+ ],
1292
+ contract_carry: {
1293
+ execution_context: {
1294
+ committed_ref: handoff.committed_ref || null,
1295
+ stable: Boolean(handoff.committed_ref)
1296
+ },
1297
+ economic_context: {
1298
+ payment_protocol: handoff.payment_protocol || null,
1299
+ settlement_mode: handoff.settlement_mode || null,
1300
+ treasury_destination_id: handoff.treasury_destination_id || null
1301
+ },
1302
+ proof_context: {
1303
+ source_ref: handoff.source_ref || null,
1304
+ seam_layer_count: seamLayers.length
1305
+ }
1306
+ },
1307
+ helper_only_summary_ids: [
1308
+ "extension_seam_summary",
1309
+ "portable_handoff_summary"
1310
+ ],
1311
+ contract_ready: reusableDefault.default_followthrough && reusableDefault.default_followthrough.reusable_by_default === true,
1312
+ next_surface: "/v1/proof-center/result-package-handoff/review/contract-summary"
1313
+ };
1314
+ }
1315
+
1316
+ function buildPreparedContinuationCompositionContractTemplate(portableHandoff, continuation) {
1317
+ const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
1318
+ const summary = buildPreparedContinuationCompositionContractSummary(portableHandoff, continuation);
1319
+ return {
1320
+ ok: true,
1321
+ composition_contract_ref: summary.composition_contract_ref || null,
1322
+ target_surface: "/v1/proof-center/result-package-handoff/review/contract-summary",
1323
+ request_template: {
1324
+ handoff_bundle: handoff
1325
+ },
1326
+ stable_boundary_ids: [
1327
+ "prepared_artifact_contract",
1328
+ "review_contract_summary",
1329
+ "proof_run"
1330
+ ]
1331
+ };
1332
+ }
1333
+
1334
+ function buildPreparedContinuationCompositionContractBundle(portableHandoff, continuation) {
1335
+ return {
1336
+ ok: true,
1337
+ composition_contract_summary: buildPreparedContinuationCompositionContractSummary(portableHandoff, continuation),
1338
+ composition_contract_template: buildPreparedContinuationCompositionContractTemplate(portableHandoff, continuation)
1339
+ };
1340
+ }
1341
+
1342
+ function buildPreparedContinuationAdapterBridgeSummary(portableHandoff, continuation) {
1343
+ const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
1344
+ const contract = buildPreparedContinuationCompositionContractSummary(portableHandoff, continuation);
1345
+ return {
1346
+ ok: true,
1347
+ adapter_bridge_ref: continuation && continuation.continuation_ref
1348
+ ? `bridge.${continuation.continuation_ref}`
1349
+ : null,
1350
+ composition_contract_ref: contract.composition_contract_ref || null,
1351
+ stable_bridge_ids: [
1352
+ "prepared_artifact_bridge",
1353
+ "review_bridge_summary",
1354
+ "proof_run"
1355
+ ],
1356
+ bridge_carry: {
1357
+ execution_context: {
1358
+ committed_ref: handoff.committed_ref || null,
1359
+ stable: Boolean(handoff.committed_ref)
1360
+ },
1361
+ economic_context: {
1362
+ payment_protocol: handoff.payment_protocol || null,
1363
+ settlement_mode: handoff.settlement_mode || null
1364
+ },
1365
+ proof_context: {
1366
+ source_ref: handoff.source_ref || null,
1367
+ proof_ref: handoff.proof_ref || null
1368
+ }
1369
+ },
1370
+ default_only_summary_ids: [
1371
+ "reusable_default_summary",
1372
+ "reusable_default_template"
1373
+ ],
1374
+ bridge_ready: contract.contract_ready === true,
1375
+ next_surface: "/v1/proof-center/result-package-handoff/review/bridge-summary"
1376
+ };
1377
+ }
1378
+
1379
+ function buildPreparedContinuationAdapterBridgeTemplate(portableHandoff, continuation) {
1380
+ const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
1381
+ const summary = buildPreparedContinuationAdapterBridgeSummary(portableHandoff, continuation);
1382
+ return {
1383
+ ok: true,
1384
+ adapter_bridge_ref: summary.adapter_bridge_ref || null,
1385
+ target_surface: "/v1/proof-center/result-package-handoff/review/bridge-summary",
1386
+ request_template: {
1387
+ handoff_bundle: handoff
1388
+ },
1389
+ stable_boundary_ids: [
1390
+ "prepared_artifact_bridge",
1391
+ "review_bridge_summary",
1392
+ "proof_run"
1393
+ ]
1394
+ };
1395
+ }
1396
+
1397
+ function buildPreparedContinuationAdapterBridgeBundle(portableHandoff, continuation) {
1398
+ return {
1399
+ ok: true,
1400
+ adapter_bridge_summary: buildPreparedContinuationAdapterBridgeSummary(portableHandoff, continuation),
1401
+ adapter_bridge_template: buildPreparedContinuationAdapterBridgeTemplate(portableHandoff, continuation)
1402
+ };
1403
+ }
1404
+
1405
+ function buildPreparedContinuationAdapterBridgeCarry(portableHandoff, continuation) {
1406
+ const summary = buildPreparedContinuationAdapterBridgeSummary(portableHandoff, continuation);
1407
+ return {
1408
+ ok: true,
1409
+ adapter_bridge_ref: summary.adapter_bridge_ref || null,
1410
+ stable_bridge_ids: Array.isArray(summary.stable_bridge_ids) ? summary.stable_bridge_ids : [],
1411
+ bridge_carry: summary.bridge_carry || {},
1412
+ bridge_ready: summary.bridge_ready === true,
1413
+ review_surface: "/v1/proof-center/result-package-handoff/review/bridge-carry"
1414
+ };
1415
+ }
1416
+
1277
1417
  function buildInteractionResultPackageContinuationRequestTemplate(portableHandoff, continuation) {
1278
1418
  const handoff = portableHandoff && typeof portableHandoff === "object" ? portableHandoff : {};
1279
1419
  return {
@@ -2232,6 +2372,8 @@ async function routeRequest(req, res) {
2232
2372
  extension_seam_summary: buildPreparedContinuationExtensionSeamSummary(portableHandoff, continuation),
2233
2373
  reusable_default_summary: buildPreparedContinuationReusableDefaultSummary(portableHandoff, continuation),
2234
2374
  reusable_default_template: buildPreparedContinuationReusableDefaultTemplate(portableHandoff, continuation),
2375
+ ...buildPreparedContinuationCompositionContractBundle(portableHandoff, continuation),
2376
+ ...buildPreparedContinuationAdapterBridgeBundle(portableHandoff, continuation),
2235
2377
  extension_template: buildPreparedContinuationExtensionTemplate(portableHandoff, continuation),
2236
2378
  proof_request_template: buildInteractionResultPackageContinuationRequestTemplate(portableHandoff, continuation)
2237
2379
  });
@@ -2270,6 +2412,8 @@ async function routeRequest(req, res) {
2270
2412
  extension_seam_summary: buildPreparedContinuationExtensionSeamSummary(portableHandoff, continuation),
2271
2413
  reusable_default_summary: buildPreparedContinuationReusableDefaultSummary(portableHandoff, continuation),
2272
2414
  reusable_default_template: buildPreparedContinuationReusableDefaultTemplate(portableHandoff, continuation),
2415
+ ...buildPreparedContinuationCompositionContractBundle(portableHandoff, continuation),
2416
+ ...buildPreparedContinuationAdapterBridgeBundle(portableHandoff, continuation),
2273
2417
  extension_template: buildPreparedContinuationExtensionTemplate(portableHandoff, continuation)
2274
2418
  });
2275
2419
  return;
@@ -2306,6 +2450,223 @@ async function routeRequest(req, res) {
2306
2450
  return;
2307
2451
  }
2308
2452
 
2453
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-package-continuations/prepare/contract-summary") {
2454
+ const body = await readJsonBody(req);
2455
+ const continuationRef = String(body && body.continuation_ref || "").trim();
2456
+ const continuation = getInteractionResultPackageContinuation(continuationRef);
2457
+ if (!continuation) {
2458
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2459
+ return;
2460
+ }
2461
+ const resultPackage = getInteractionResultPackage(continuation.result_package_ref);
2462
+ if (!resultPackage) {
2463
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
2464
+ return;
2465
+ }
2466
+ const payload = buildInteractionSpinePathRunPayload({
2467
+ ...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
2468
+ spine_path_ref: resultPackage.source_ref
2469
+ });
2470
+ if (!payload) {
2471
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2472
+ return;
2473
+ }
2474
+ const result = executeCommandRequest(state, payload, req.headers);
2475
+ if (result.status !== 200) {
2476
+ sendJson(res, result.status, result.payload);
2477
+ return;
2478
+ }
2479
+ const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
2480
+ sendJson(res, 200, buildPreparedContinuationCompositionContractSummary(portableHandoff, continuation));
2481
+ return;
2482
+ }
2483
+
2484
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-package-continuations/prepare/contract-bundle") {
2485
+ const body = await readJsonBody(req);
2486
+ const continuationRef = String(body && body.continuation_ref || "").trim();
2487
+ const continuation = getInteractionResultPackageContinuation(continuationRef);
2488
+ if (!continuation) {
2489
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2490
+ return;
2491
+ }
2492
+ const resultPackage = getInteractionResultPackage(continuation.result_package_ref);
2493
+ if (!resultPackage) {
2494
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
2495
+ return;
2496
+ }
2497
+ const payload = buildInteractionSpinePathRunPayload({
2498
+ ...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
2499
+ spine_path_ref: resultPackage.source_ref
2500
+ });
2501
+ if (!payload) {
2502
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2503
+ return;
2504
+ }
2505
+ const result = executeCommandRequest(state, payload, req.headers);
2506
+ if (result.status !== 200) {
2507
+ sendJson(res, result.status, result.payload);
2508
+ return;
2509
+ }
2510
+ const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
2511
+ sendJson(res, 200, buildPreparedContinuationCompositionContractBundle(portableHandoff, continuation));
2512
+ return;
2513
+ }
2514
+
2515
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-package-continuations/prepare/bridge-summary") {
2516
+ const body = await readJsonBody(req);
2517
+ const continuationRef = String(body && body.continuation_ref || "").trim();
2518
+ const continuation = getInteractionResultPackageContinuation(continuationRef);
2519
+ if (!continuation) {
2520
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2521
+ return;
2522
+ }
2523
+ const resultPackage = getInteractionResultPackage(continuation.result_package_ref);
2524
+ if (!resultPackage) {
2525
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
2526
+ return;
2527
+ }
2528
+ const payload = buildInteractionSpinePathRunPayload({
2529
+ ...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
2530
+ spine_path_ref: resultPackage.source_ref
2531
+ });
2532
+ if (!payload) {
2533
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2534
+ return;
2535
+ }
2536
+ const result = executeCommandRequest(state, payload, req.headers);
2537
+ if (result.status !== 200) {
2538
+ sendJson(res, result.status, result.payload);
2539
+ return;
2540
+ }
2541
+ const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
2542
+ sendJson(res, 200, buildPreparedContinuationAdapterBridgeSummary(portableHandoff, continuation));
2543
+ return;
2544
+ }
2545
+
2546
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-package-continuations/prepare/bridge-template") {
2547
+ const body = await readJsonBody(req);
2548
+ const continuationRef = String(body && body.continuation_ref || "").trim();
2549
+ const continuation = getInteractionResultPackageContinuation(continuationRef);
2550
+ if (!continuation) {
2551
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2552
+ return;
2553
+ }
2554
+ const resultPackage = getInteractionResultPackage(continuation.result_package_ref);
2555
+ if (!resultPackage) {
2556
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
2557
+ return;
2558
+ }
2559
+ const payload = buildInteractionSpinePathRunPayload({
2560
+ ...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
2561
+ spine_path_ref: resultPackage.source_ref
2562
+ });
2563
+ if (!payload) {
2564
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2565
+ return;
2566
+ }
2567
+ const result = executeCommandRequest(state, payload, req.headers);
2568
+ if (result.status !== 200) {
2569
+ sendJson(res, result.status, result.payload);
2570
+ return;
2571
+ }
2572
+ const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
2573
+ sendJson(res, 200, buildPreparedContinuationAdapterBridgeTemplate(portableHandoff, continuation));
2574
+ return;
2575
+ }
2576
+
2577
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-package-continuations/prepare/bridge-bundle") {
2578
+ const body = await readJsonBody(req);
2579
+ const continuationRef = String(body && body.continuation_ref || "").trim();
2580
+ const continuation = getInteractionResultPackageContinuation(continuationRef);
2581
+ if (!continuation) {
2582
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2583
+ return;
2584
+ }
2585
+ const resultPackage = getInteractionResultPackage(continuation.result_package_ref);
2586
+ if (!resultPackage) {
2587
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
2588
+ return;
2589
+ }
2590
+ const payload = buildInteractionSpinePathRunPayload({
2591
+ ...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
2592
+ spine_path_ref: resultPackage.source_ref
2593
+ });
2594
+ if (!payload) {
2595
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2596
+ return;
2597
+ }
2598
+ const result = executeCommandRequest(state, payload, req.headers);
2599
+ if (result.status !== 200) {
2600
+ sendJson(res, result.status, result.payload);
2601
+ return;
2602
+ }
2603
+ const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
2604
+ sendJson(res, 200, buildPreparedContinuationAdapterBridgeBundle(portableHandoff, continuation));
2605
+ return;
2606
+ }
2607
+
2608
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-package-continuations/prepare/bridge-carry") {
2609
+ const body = await readJsonBody(req);
2610
+ const continuationRef = String(body && body.continuation_ref || "").trim();
2611
+ const continuation = getInteractionResultPackageContinuation(continuationRef);
2612
+ if (!continuation) {
2613
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2614
+ return;
2615
+ }
2616
+ const resultPackage = getInteractionResultPackage(continuation.result_package_ref);
2617
+ if (!resultPackage) {
2618
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
2619
+ return;
2620
+ }
2621
+ const payload = buildInteractionSpinePathRunPayload({
2622
+ ...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
2623
+ spine_path_ref: resultPackage.source_ref
2624
+ });
2625
+ if (!payload) {
2626
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2627
+ return;
2628
+ }
2629
+ const result = executeCommandRequest(state, payload, req.headers);
2630
+ if (result.status !== 200) {
2631
+ sendJson(res, result.status, result.payload);
2632
+ return;
2633
+ }
2634
+ const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
2635
+ sendJson(res, 200, buildPreparedContinuationAdapterBridgeCarry(portableHandoff, continuation));
2636
+ return;
2637
+ }
2638
+
2639
+ if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-package-continuations/prepare/contract-template") {
2640
+ const body = await readJsonBody(req);
2641
+ const continuationRef = String(body && body.continuation_ref || "").trim();
2642
+ const continuation = getInteractionResultPackageContinuation(continuationRef);
2643
+ if (!continuation) {
2644
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2645
+ return;
2646
+ }
2647
+ const resultPackage = getInteractionResultPackage(continuation.result_package_ref);
2648
+ if (!resultPackage) {
2649
+ sendJson(res, 404, { ok: false, error: "result_package_not_found" });
2650
+ return;
2651
+ }
2652
+ const payload = buildInteractionSpinePathRunPayload({
2653
+ ...(body && typeof body === "object" && !Array.isArray(body) ? body : {}),
2654
+ spine_path_ref: resultPackage.source_ref
2655
+ });
2656
+ if (!payload) {
2657
+ sendJson(res, 404, { ok: false, error: "result_package_continuation_not_found" });
2658
+ return;
2659
+ }
2660
+ const result = executeCommandRequest(state, payload, req.headers);
2661
+ if (result.status !== 200) {
2662
+ sendJson(res, result.status, result.payload);
2663
+ return;
2664
+ }
2665
+ const portableHandoff = buildInteractionResultPackagePortableHandoff(result.payload, resultPackage);
2666
+ sendJson(res, 200, buildPreparedContinuationCompositionContractTemplate(portableHandoff, continuation));
2667
+ return;
2668
+ }
2669
+
2309
2670
  if (req.method === "POST" && url.pathname === "/v1/transaction-center/result-package-continuations/prepare/default-template") {
2310
2671
  const body = await readJsonBody(req);
2311
2672
  const continuationRef = String(body && body.continuation_ref || "").trim();