xytara 2.2.0 → 2.4.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/RELEASE_NOTES.md +16 -10
- package/lib/account_auth.js +347 -1
- package/lib/capability_registry.js +572 -0
- package/lib/command_flow.js +20 -1
- package/lib/commerce_authority.js +449 -0
- package/lib/commerce_client.js +38 -0
- package/lib/commerce_economics.js +2471 -1
- package/lib/commerce_identity.js +578 -0
- package/lib/commerce_runtime.js +4 -0
- package/lib/identity_auth.js +175 -0
- package/lib/operator_intelligence.js +90 -0
- package/lib/partner_intelligence.js +105 -0
- package/package.json +1 -1
- package/server.js +1308 -59
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const packageJson = require("../package.json");
|
|
4
|
+
const {
|
|
5
|
+
getCatalog,
|
|
6
|
+
summarizeCatalog,
|
|
7
|
+
buildDefaultTransactionTaskPackCatalog,
|
|
8
|
+
summarizeDefaultTransactionTaskPacks,
|
|
9
|
+
buildTransactionClassPackCatalog,
|
|
10
|
+
summarizeTransactionClassPacks,
|
|
11
|
+
buildPrecommitInteractionPackCatalog,
|
|
12
|
+
summarizePrecommitInteractionPacks,
|
|
13
|
+
buildInteractionSpinePathCatalog,
|
|
14
|
+
summarizeInteractionSpinePaths,
|
|
15
|
+
buildDefaultTransactionGuidedLoopCatalog,
|
|
16
|
+
summarizeDefaultTransactionGuidedLoops,
|
|
17
|
+
buildInteractionResultPackageCatalog,
|
|
18
|
+
summarizeInteractionResultPackages,
|
|
19
|
+
buildInteractionResultPackageContinuationCatalog,
|
|
20
|
+
summarizeInteractionResultPackageContinuations
|
|
21
|
+
} = require("./catalog_contract");
|
|
22
|
+
const {
|
|
23
|
+
buildAdapterPack,
|
|
24
|
+
summarizeAdapterPack
|
|
25
|
+
} = require("./adapter_pack");
|
|
26
|
+
const {
|
|
27
|
+
buildAdapterPromotionPack,
|
|
28
|
+
summarizeAdapterPromotionPack
|
|
29
|
+
} = require("./adapter_promotion_pack");
|
|
30
|
+
const {
|
|
31
|
+
buildAdapterPartnerPack,
|
|
32
|
+
summarizeAdapterPartnerPack
|
|
33
|
+
} = require("./adapter_partner_pack");
|
|
34
|
+
const {
|
|
35
|
+
buildPartnerIntelligencePack
|
|
36
|
+
} = require("./partner_intelligence");
|
|
37
|
+
|
|
38
|
+
function buildCapabilityRegistrySummary() {
|
|
39
|
+
const catalogSummary = summarizeCatalog();
|
|
40
|
+
const taskPackSummary = summarizeDefaultTransactionTaskPacks();
|
|
41
|
+
const classPackSummary = summarizeTransactionClassPacks();
|
|
42
|
+
const precommitSummary = summarizePrecommitInteractionPacks();
|
|
43
|
+
const spineSummary = summarizeInteractionSpinePaths();
|
|
44
|
+
const loopSummary = summarizeDefaultTransactionGuidedLoops();
|
|
45
|
+
const resultPackageSummary = summarizeInteractionResultPackages();
|
|
46
|
+
const continuationSummary = summarizeInteractionResultPackageContinuations();
|
|
47
|
+
const adapterSummary = summarizeAdapterPack();
|
|
48
|
+
const adapterPromotionSummary = summarizeAdapterPromotionPack();
|
|
49
|
+
const adapterPartnerSummary = summarizeAdapterPartnerPack();
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
ok: true,
|
|
53
|
+
product: packageJson.name,
|
|
54
|
+
category: "machine-commerce-capability-registry-summary",
|
|
55
|
+
summary_version: "xytara-capability-registry-summary-v1",
|
|
56
|
+
registry_state: "explicit_runtime_registry_present",
|
|
57
|
+
counts: {
|
|
58
|
+
capability_count: Array.isArray(catalogSummary.tasks) ? catalogSummary.tasks.length : 0,
|
|
59
|
+
workflow_count: Array.isArray(catalogSummary.workflow_summaries) ? catalogSummary.workflow_summaries.length : 0,
|
|
60
|
+
task_pack_count: Number(taskPackSummary.pack_count || 0),
|
|
61
|
+
class_pack_count: Number(classPackSummary.class_pack_count || 0),
|
|
62
|
+
precommit_pack_count: Number(precommitSummary.precommit_pack_count || 0),
|
|
63
|
+
spine_path_count: Number(spineSummary.path_count || 0),
|
|
64
|
+
loop_count: Number(loopSummary.loop_count || 0),
|
|
65
|
+
result_package_count: Number(resultPackageSummary.result_package_count || 0),
|
|
66
|
+
continuation_count: Number(continuationSummary.continuation_count || 0),
|
|
67
|
+
adapter_class_count: Number(adapterSummary.starter_class_count || 0),
|
|
68
|
+
adapter_promotion_step_count: Number(adapterPromotionSummary.maturity_step_count || 0),
|
|
69
|
+
adapter_partner_audience_count: Number(adapterPartnerSummary.audience_count || 0)
|
|
70
|
+
},
|
|
71
|
+
registry_posture: {
|
|
72
|
+
catalog_state: "task_and_workflow_registry_present",
|
|
73
|
+
execution_pack_state: "task_class_precommit_and_loop_packs_present",
|
|
74
|
+
continuation_state: "result_package_and_continuation_registry_present",
|
|
75
|
+
adapter_state: "adapter_registration_promotion_and_partner_registry_present"
|
|
76
|
+
},
|
|
77
|
+
linked_surfaces: {
|
|
78
|
+
capability_registry_ref: "/v1/capability-registry",
|
|
79
|
+
catalog_summary_ref: "/v1/catalog/summary",
|
|
80
|
+
task_packs_summary_ref: "/v1/transaction-center/task-packs/summary",
|
|
81
|
+
class_packs_summary_ref: "/v1/transaction-center/transaction-class-packs/summary",
|
|
82
|
+
precommit_packs_summary_ref: "/v1/transaction-center/precommit-packs/summary",
|
|
83
|
+
adapter_pack_summary_ref: "/v1/adapter-pack/summary",
|
|
84
|
+
adapter_promotion_summary_ref: "/v1/adapter-promotion/summary",
|
|
85
|
+
adapter_partner_summary_ref: "/v1/adapter-partners/summary"
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function buildCapabilityRegistryBundle() {
|
|
91
|
+
return {
|
|
92
|
+
ok: true,
|
|
93
|
+
product: packageJson.name,
|
|
94
|
+
category: "machine-commerce-capability-registry",
|
|
95
|
+
bundle_version: "xytara-capability-registry-bundle-v1",
|
|
96
|
+
capability_registry_summary: buildCapabilityRegistrySummary(),
|
|
97
|
+
catalog: getCatalog(),
|
|
98
|
+
catalog_summary: summarizeCatalog(),
|
|
99
|
+
task_pack_catalog: buildDefaultTransactionTaskPackCatalog(),
|
|
100
|
+
task_pack_summary: summarizeDefaultTransactionTaskPacks(),
|
|
101
|
+
class_pack_catalog: buildTransactionClassPackCatalog(),
|
|
102
|
+
class_pack_summary: summarizeTransactionClassPacks(),
|
|
103
|
+
precommit_pack_catalog: buildPrecommitInteractionPackCatalog(),
|
|
104
|
+
precommit_pack_summary: summarizePrecommitInteractionPacks(),
|
|
105
|
+
spine_path_catalog: buildInteractionSpinePathCatalog(),
|
|
106
|
+
spine_path_summary: summarizeInteractionSpinePaths(),
|
|
107
|
+
loop_catalog: buildDefaultTransactionGuidedLoopCatalog(),
|
|
108
|
+
loop_summary: summarizeDefaultTransactionGuidedLoops(),
|
|
109
|
+
result_package_catalog: buildInteractionResultPackageCatalog(),
|
|
110
|
+
result_package_summary: summarizeInteractionResultPackages(),
|
|
111
|
+
continuation_catalog: buildInteractionResultPackageContinuationCatalog(),
|
|
112
|
+
continuation_summary: summarizeInteractionResultPackageContinuations(),
|
|
113
|
+
adapter_pack: buildAdapterPack(),
|
|
114
|
+
adapter_pack_summary: summarizeAdapterPack(),
|
|
115
|
+
adapter_promotion_pack: buildAdapterPromotionPack(),
|
|
116
|
+
adapter_promotion_summary: summarizeAdapterPromotionPack(),
|
|
117
|
+
adapter_partner_pack: buildAdapterPartnerPack(),
|
|
118
|
+
adapter_partner_summary: summarizeAdapterPartnerPack(),
|
|
119
|
+
linked_surfaces: {
|
|
120
|
+
capability_registry_summary_ref: "/v1/capability-registry/summary",
|
|
121
|
+
catalog_ref: "/v1/catalog",
|
|
122
|
+
task_pack_catalog_ref: "/v1/transaction-center/task-packs",
|
|
123
|
+
class_pack_catalog_ref: "/v1/transaction-center/transaction-class-packs",
|
|
124
|
+
precommit_pack_catalog_ref: "/v1/transaction-center/precommit-packs",
|
|
125
|
+
adapter_pack_ref: "/v1/adapter-pack",
|
|
126
|
+
adapter_promotion_ref: "/v1/adapter-promotion",
|
|
127
|
+
adapter_partner_ref: "/v1/adapter-partners"
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function buildCapabilityRegistryClassificationSummary() {
|
|
133
|
+
const catalog = getCatalog();
|
|
134
|
+
const taskCategories = new Map();
|
|
135
|
+
const workflowCategories = new Map();
|
|
136
|
+
const taskLatencies = new Map();
|
|
137
|
+
const taskFailurePostures = new Map();
|
|
138
|
+
|
|
139
|
+
for (const task of Array.isArray(catalog.tasks) ? catalog.tasks : []) {
|
|
140
|
+
const category = task && task.public_category ? task.public_category : "unknown";
|
|
141
|
+
const latency = task && task.latency_class ? task.latency_class : "unknown";
|
|
142
|
+
const failurePosture = task && task.failure_posture ? task.failure_posture : "unknown";
|
|
143
|
+
taskCategories.set(category, Number(taskCategories.get(category) || 0) + 1);
|
|
144
|
+
taskLatencies.set(latency, Number(taskLatencies.get(latency) || 0) + 1);
|
|
145
|
+
taskFailurePostures.set(failurePosture, Number(taskFailurePostures.get(failurePosture) || 0) + 1);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
for (const workflow of Array.isArray(catalog.workflows) ? catalog.workflows : []) {
|
|
149
|
+
const category = workflow && workflow.category ? workflow.category : "unknown";
|
|
150
|
+
workflowCategories.set(category, Number(workflowCategories.get(category) || 0) + 1);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const precommitCatalog = buildPrecommitInteractionPackCatalog();
|
|
154
|
+
const spineCatalog = buildInteractionSpinePathCatalog();
|
|
155
|
+
const protocols = Array.from(new Set(
|
|
156
|
+
[]
|
|
157
|
+
.concat(Array.isArray(precommitCatalog.precommit_packs) ? precommitCatalog.precommit_packs : [])
|
|
158
|
+
.concat(Array.isArray(spineCatalog.paths) ? spineCatalog.paths : [])
|
|
159
|
+
.map((entry) => entry && entry.protocol ? entry.protocol : null)
|
|
160
|
+
.filter(Boolean)
|
|
161
|
+
));
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
ok: true,
|
|
165
|
+
product: packageJson.name,
|
|
166
|
+
category: "machine-commerce-capability-registry-classification-summary",
|
|
167
|
+
summary_version: "xytara-capability-registry-classification-summary-v1",
|
|
168
|
+
task_categories: Array.from(taskCategories.entries()).map(([category, task_count]) => ({ category, task_count })),
|
|
169
|
+
workflow_categories: Array.from(workflowCategories.entries()).map(([category, workflow_count]) => ({ category, workflow_count })),
|
|
170
|
+
task_latency_classes: Array.from(taskLatencies.entries()).map(([latency_class, task_count]) => ({ latency_class, task_count })),
|
|
171
|
+
task_failure_postures: Array.from(taskFailurePostures.entries()).map(([failure_posture, task_count]) => ({ failure_posture, task_count })),
|
|
172
|
+
protocol_families: protocols,
|
|
173
|
+
linked_surfaces: {
|
|
174
|
+
capability_registry_ref: "/v1/capability-registry",
|
|
175
|
+
capability_registry_lineage_summary_ref: "/v1/capability-registry/lineage-summary",
|
|
176
|
+
catalog_summary_ref: "/v1/catalog/summary"
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function buildCapabilityRegistryLineageSummary() {
|
|
182
|
+
const catalog = getCatalog();
|
|
183
|
+
const taskPackCatalog = buildDefaultTransactionTaskPackCatalog();
|
|
184
|
+
const classPackCatalog = buildTransactionClassPackCatalog();
|
|
185
|
+
const precommitCatalog = buildPrecommitInteractionPackCatalog();
|
|
186
|
+
const spineCatalog = buildInteractionSpinePathCatalog();
|
|
187
|
+
const loopCatalog = buildDefaultTransactionGuidedLoopCatalog();
|
|
188
|
+
|
|
189
|
+
const lineageRows = [];
|
|
190
|
+
|
|
191
|
+
for (const workflow of Array.isArray(catalog.workflows) ? catalog.workflows : []) {
|
|
192
|
+
lineageRows.push({
|
|
193
|
+
source_kind: "workflow",
|
|
194
|
+
source_ref: workflow.workflow_ref,
|
|
195
|
+
relationship: "contains_tasks",
|
|
196
|
+
target_kind: "task",
|
|
197
|
+
target_refs: Array.isArray(workflow.task_refs) ? workflow.task_refs : []
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
for (const pack of Array.isArray(taskPackCatalog.packs) ? taskPackCatalog.packs : []) {
|
|
202
|
+
lineageRows.push({
|
|
203
|
+
source_kind: "task_pack",
|
|
204
|
+
source_ref: pack.pack_ref,
|
|
205
|
+
relationship: pack.workflow_ref ? "binds_workflow_and_tasks" : "binds_tasks",
|
|
206
|
+
target_kind: pack.workflow_ref ? "workflow_and_tasks" : "task",
|
|
207
|
+
target_refs: pack.workflow_ref
|
|
208
|
+
? [pack.workflow_ref].concat(Array.isArray(pack.task_refs) ? pack.task_refs : [])
|
|
209
|
+
: Array.isArray(pack.task_refs) ? pack.task_refs : []
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
for (const pack of Array.isArray(classPackCatalog.packs) ? classPackCatalog.packs : []) {
|
|
214
|
+
lineageRows.push({
|
|
215
|
+
source_kind: "class_pack",
|
|
216
|
+
source_ref: pack.class_pack_ref,
|
|
217
|
+
relationship: "groups_workflow_and_tasks",
|
|
218
|
+
target_kind: "workflow_and_tasks",
|
|
219
|
+
target_refs: [pack.workflow_ref].concat(Array.isArray(pack.task_refs) ? pack.task_refs : []).filter(Boolean)
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
for (const pack of Array.isArray(precommitCatalog.packs) ? precommitCatalog.packs : []) {
|
|
224
|
+
lineageRows.push({
|
|
225
|
+
source_kind: "precommit_pack",
|
|
226
|
+
source_ref: pack.precommit_pack_ref,
|
|
227
|
+
relationship: "prepares_next_ref",
|
|
228
|
+
target_kind: "next_ref",
|
|
229
|
+
target_refs: [pack.recommended_next_ref].filter(Boolean)
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
for (const path of Array.isArray(spineCatalog.paths) ? spineCatalog.paths : []) {
|
|
234
|
+
lineageRows.push({
|
|
235
|
+
source_kind: "spine_path",
|
|
236
|
+
source_ref: path.spine_path_ref,
|
|
237
|
+
relationship: "stitches_tasks",
|
|
238
|
+
target_kind: "task",
|
|
239
|
+
target_refs: Array.isArray(path.task_refs) ? path.task_refs : []
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
for (const loop of Array.isArray(loopCatalog.loops) ? loopCatalog.loops : []) {
|
|
244
|
+
lineageRows.push({
|
|
245
|
+
source_kind: "guided_loop",
|
|
246
|
+
source_ref: loop.loop_ref,
|
|
247
|
+
relationship: "drives_pack",
|
|
248
|
+
target_kind: "pack",
|
|
249
|
+
target_refs: [loop.pack_ref].filter(Boolean)
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
ok: true,
|
|
255
|
+
product: packageJson.name,
|
|
256
|
+
category: "machine-commerce-capability-registry-lineage-summary",
|
|
257
|
+
summary_version: "xytara-capability-registry-lineage-summary-v1",
|
|
258
|
+
lineage_row_count: lineageRows.length,
|
|
259
|
+
lineage_rows: lineageRows,
|
|
260
|
+
linked_surfaces: {
|
|
261
|
+
capability_registry_ref: "/v1/capability-registry",
|
|
262
|
+
capability_registry_summary_ref: "/v1/capability-registry/summary",
|
|
263
|
+
capability_registry_classification_summary_ref: "/v1/capability-registry/classification-summary"
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function buildCapabilityRegistryOperatorBundle(state, input) {
|
|
269
|
+
const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
270
|
+
const accountId = String(payload.account_id || "acct_demo").trim() || "acct_demo";
|
|
271
|
+
const summary = buildCapabilityRegistrySummary();
|
|
272
|
+
const bundle = buildCapabilityRegistryBundle();
|
|
273
|
+
const partnerIntelligence = buildPartnerIntelligencePack();
|
|
274
|
+
|
|
275
|
+
let recommendedRegistryMotion = "maintain_explicit_runtime_registry";
|
|
276
|
+
if (summary.counts.adapter_promotion_step_count < 5) {
|
|
277
|
+
recommendedRegistryMotion = "strengthen_adapter_registry_promotion_path";
|
|
278
|
+
} else if (summary.counts.precommit_pack_count < 3 || summary.counts.class_pack_count < 5) {
|
|
279
|
+
recommendedRegistryMotion = "strengthen_execution_pack_coverage";
|
|
280
|
+
} else if (partnerIntelligence.onboarding_friction_state !== "low") {
|
|
281
|
+
recommendedRegistryMotion = "tighten_registry_entry_clarity";
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
ok: true,
|
|
286
|
+
product: packageJson.name,
|
|
287
|
+
category: "machine-commerce-capability-registry-operator-bundle",
|
|
288
|
+
bundle_version: "xytara-capability-registry-operator-bundle-v1",
|
|
289
|
+
account_id: accountId,
|
|
290
|
+
operator_posture: {
|
|
291
|
+
registry_state: summary.registry_state,
|
|
292
|
+
catalog_state: summary.registry_posture.catalog_state,
|
|
293
|
+
adapter_state: summary.registry_posture.adapter_state,
|
|
294
|
+
partner_readiness_state: partnerIntelligence.partner_readiness_state,
|
|
295
|
+
recommended_registry_motion: recommendedRegistryMotion
|
|
296
|
+
},
|
|
297
|
+
capability_registry_summary: summary,
|
|
298
|
+
capability_registry_bundle: bundle,
|
|
299
|
+
capability_registry_classification_summary: buildCapabilityRegistryClassificationSummary(),
|
|
300
|
+
capability_registry_lineage_summary: buildCapabilityRegistryLineageSummary(),
|
|
301
|
+
partner_intelligence: partnerIntelligence,
|
|
302
|
+
linked_surfaces: {
|
|
303
|
+
capability_registry_ref: "/v1/capability-registry",
|
|
304
|
+
capability_registry_summary_ref: "/v1/capability-registry/summary",
|
|
305
|
+
capability_registry_classification_summary_ref: "/v1/capability-registry/classification-summary",
|
|
306
|
+
capability_registry_lineage_summary_ref: "/v1/capability-registry/lineage-summary",
|
|
307
|
+
partner_intelligence_ref: "/v1/partner-intelligence",
|
|
308
|
+
adapter_partner_summary_ref: "/v1/adapter-partners/summary"
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function buildCapabilityRegistryPolicyPack(state, input) {
|
|
314
|
+
const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
315
|
+
const accountId = String(payload.account_id || "acct_demo").trim() || "acct_demo";
|
|
316
|
+
const summary = buildCapabilityRegistrySummary();
|
|
317
|
+
const classification = buildCapabilityRegistryClassificationSummary();
|
|
318
|
+
const lineage = buildCapabilityRegistryLineageSummary();
|
|
319
|
+
const operatorBundle = buildCapabilityRegistryOperatorBundle(state, { account_id: accountId });
|
|
320
|
+
const partnerIntelligence = buildPartnerIntelligencePack();
|
|
321
|
+
const policyTemplates = [
|
|
322
|
+
{
|
|
323
|
+
template_id: "runtime_registry_maintenance",
|
|
324
|
+
recommended_for: "maintaining a broad explicit runtime registry with stable entry paths",
|
|
325
|
+
focus_surfaces: [
|
|
326
|
+
"/v1/capability-registry",
|
|
327
|
+
"/v1/capability-registry/classification-summary",
|
|
328
|
+
"/v1/capability-registry/lineage-summary"
|
|
329
|
+
],
|
|
330
|
+
operator_actions: [
|
|
331
|
+
"review capability coverage counts",
|
|
332
|
+
"check workflow-to-task lineage continuity",
|
|
333
|
+
"preserve explicit runtime registry posture"
|
|
334
|
+
]
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
template_id: "execution_pack_coverage_strengthening",
|
|
338
|
+
recommended_for: "strengthening task/class/precommit/loop pack coverage across the runtime surface",
|
|
339
|
+
focus_surfaces: [
|
|
340
|
+
"/v1/transaction-center/task-packs/summary",
|
|
341
|
+
"/v1/transaction-center/transaction-class-packs/summary",
|
|
342
|
+
"/v1/transaction-center/precommit-packs/summary",
|
|
343
|
+
"/v1/capability-registry/lineage-summary"
|
|
344
|
+
],
|
|
345
|
+
operator_actions: [
|
|
346
|
+
"tighten class and precommit pack breadth",
|
|
347
|
+
"fill missing execution path coverage",
|
|
348
|
+
"review workflow-to-pack lineage gaps"
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
template_id: "adapter_registry_promotion",
|
|
353
|
+
recommended_for: "lifting extension and partner-facing registry posture for outside builders",
|
|
354
|
+
focus_surfaces: [
|
|
355
|
+
"/v1/adapter-pack/summary",
|
|
356
|
+
"/v1/adapter-promotion/summary",
|
|
357
|
+
"/v1/adapter-partners/summary",
|
|
358
|
+
"/v1/partner-intelligence"
|
|
359
|
+
],
|
|
360
|
+
operator_actions: [
|
|
361
|
+
"strengthen adapter promotion posture",
|
|
362
|
+
"prioritize partner-ready extension families",
|
|
363
|
+
"improve adapter author success ladder"
|
|
364
|
+
]
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
template_id: "entry_clarity_tightening",
|
|
368
|
+
recommended_for: "reducing first-contact friction across the public runtime capability surface",
|
|
369
|
+
focus_surfaces: [
|
|
370
|
+
"/v1/catalog/summary",
|
|
371
|
+
"/v1/capability-registry/summary",
|
|
372
|
+
"/v1/capability-registry/operator-bundle/summary",
|
|
373
|
+
"/v1/partner-intelligence/summary"
|
|
374
|
+
],
|
|
375
|
+
operator_actions: [
|
|
376
|
+
"reduce entry-path ambiguity",
|
|
377
|
+
"tighten public capability grouping",
|
|
378
|
+
"align runtime registry with adoption posture"
|
|
379
|
+
]
|
|
380
|
+
}
|
|
381
|
+
];
|
|
382
|
+
|
|
383
|
+
let recommendedPolicyMotion = "maintain_explicit_runtime_registry";
|
|
384
|
+
if (summary.counts.adapter_promotion_step_count < 5) {
|
|
385
|
+
recommendedPolicyMotion = "promote_adapter_registry";
|
|
386
|
+
} else if (summary.counts.precommit_pack_count < 3 || summary.counts.class_pack_count < 5) {
|
|
387
|
+
recommendedPolicyMotion = "strengthen_execution_pack_coverage";
|
|
388
|
+
} else if (partnerIntelligence.onboarding_friction_state !== "low") {
|
|
389
|
+
recommendedPolicyMotion = "tighten_registry_entry_clarity";
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return {
|
|
393
|
+
ok: true,
|
|
394
|
+
product: packageJson.name,
|
|
395
|
+
category: "machine-commerce-capability-registry-policy-pack",
|
|
396
|
+
pack_version: "xytara-capability-registry-policy-pack-v1",
|
|
397
|
+
account_id: accountId,
|
|
398
|
+
capability_registry_summary: summary,
|
|
399
|
+
capability_registry_classification_summary: classification,
|
|
400
|
+
capability_registry_lineage_summary: lineage,
|
|
401
|
+
operator_posture: operatorBundle.operator_posture,
|
|
402
|
+
recommended_policy_motion: recommendedPolicyMotion,
|
|
403
|
+
policy_templates: policyTemplates,
|
|
404
|
+
policy_context: {
|
|
405
|
+
capability_count: summary.counts.capability_count,
|
|
406
|
+
workflow_count: summary.counts.workflow_count,
|
|
407
|
+
task_pack_count: summary.counts.task_pack_count,
|
|
408
|
+
class_pack_count: summary.counts.class_pack_count,
|
|
409
|
+
precommit_pack_count: summary.counts.precommit_pack_count,
|
|
410
|
+
adapter_class_count: summary.counts.adapter_class_count,
|
|
411
|
+
adapter_promotion_step_count: summary.counts.adapter_promotion_step_count,
|
|
412
|
+
partner_readiness_state: partnerIntelligence.partner_readiness_state,
|
|
413
|
+
onboarding_friction_state: partnerIntelligence.onboarding_friction_state,
|
|
414
|
+
protocol_family_count: Array.isArray(classification.protocol_families) ? classification.protocol_families.length : 0,
|
|
415
|
+
lineage_row_count: lineage.lineage_row_count
|
|
416
|
+
},
|
|
417
|
+
linked_surfaces: {
|
|
418
|
+
capability_registry_ref: "/v1/capability-registry",
|
|
419
|
+
capability_registry_summary_ref: "/v1/capability-registry/summary",
|
|
420
|
+
capability_registry_classification_summary_ref: "/v1/capability-registry/classification-summary",
|
|
421
|
+
capability_registry_lineage_summary_ref: "/v1/capability-registry/lineage-summary",
|
|
422
|
+
capability_registry_operator_bundle_ref: `/v1/capability-registry/operator-bundle?account_id=${encodeURIComponent(accountId)}`,
|
|
423
|
+
partner_intelligence_ref: "/v1/partner-intelligence"
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function summarizeCapabilityRegistryPolicyPack(state, input) {
|
|
429
|
+
const pack = buildCapabilityRegistryPolicyPack(state, input);
|
|
430
|
+
return {
|
|
431
|
+
ok: true,
|
|
432
|
+
product: pack.product,
|
|
433
|
+
category: pack.category,
|
|
434
|
+
pack_version: pack.pack_version,
|
|
435
|
+
account_id: pack.account_id,
|
|
436
|
+
recommended_policy_motion: pack.recommended_policy_motion,
|
|
437
|
+
template_count: Array.isArray(pack.policy_templates) ? pack.policy_templates.length : 0,
|
|
438
|
+
partner_readiness_state: pack.policy_context.partner_readiness_state,
|
|
439
|
+
onboarding_friction_state: pack.policy_context.onboarding_friction_state,
|
|
440
|
+
linked_surfaces: pack.linked_surfaces
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function buildCapabilityRegistryPolicyApplicationSummary(state, input) {
|
|
445
|
+
const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
446
|
+
const accountId = String(payload.account_id || "acct_demo").trim() || "acct_demo";
|
|
447
|
+
const templateId = String(payload.template_id || "").trim();
|
|
448
|
+
const pack = buildCapabilityRegistryPolicyPack(state, { account_id: accountId });
|
|
449
|
+
const selectedTemplate = Array.isArray(pack.policy_templates)
|
|
450
|
+
? pack.policy_templates.find((entry) => entry.template_id === templateId)
|
|
451
|
+
|| pack.policy_templates.find((entry) => {
|
|
452
|
+
if (pack.recommended_policy_motion === "promote_adapter_registry") {
|
|
453
|
+
return entry.template_id === "adapter_registry_promotion";
|
|
454
|
+
}
|
|
455
|
+
if (pack.recommended_policy_motion === "strengthen_execution_pack_coverage") {
|
|
456
|
+
return entry.template_id === "execution_pack_coverage_strengthening";
|
|
457
|
+
}
|
|
458
|
+
if (pack.recommended_policy_motion === "tighten_registry_entry_clarity") {
|
|
459
|
+
return entry.template_id === "entry_clarity_tightening";
|
|
460
|
+
}
|
|
461
|
+
return entry.template_id === "runtime_registry_maintenance";
|
|
462
|
+
})
|
|
463
|
+
|| pack.policy_templates[0]
|
|
464
|
+
: null;
|
|
465
|
+
|
|
466
|
+
return {
|
|
467
|
+
ok: true,
|
|
468
|
+
product: packageJson.name,
|
|
469
|
+
category: "machine-commerce-capability-registry-policy-application-summary",
|
|
470
|
+
summary_version: "xytara-capability-registry-policy-application-summary-v1",
|
|
471
|
+
account_id: accountId,
|
|
472
|
+
recommended_policy_motion: pack.recommended_policy_motion,
|
|
473
|
+
selected_template_id: selectedTemplate ? selectedTemplate.template_id : null,
|
|
474
|
+
available_template_ids: Array.isArray(pack.policy_templates)
|
|
475
|
+
? pack.policy_templates.map((entry) => entry.template_id)
|
|
476
|
+
: [],
|
|
477
|
+
selected_template: selectedTemplate,
|
|
478
|
+
suggested_registry_targets: {
|
|
479
|
+
classification_focus: pack.policy_context.protocol_family_count > 0 ? "protocol_family_coverage_present" : "protocol_family_coverage_needs_review",
|
|
480
|
+
lineage_focus: pack.policy_context.lineage_row_count > 0 ? "lineage_present_reviewable" : "lineage_needs_buildout",
|
|
481
|
+
partner_focus: pack.policy_context.onboarding_friction_state
|
|
482
|
+
},
|
|
483
|
+
linked_surfaces: {
|
|
484
|
+
capability_registry_policy_pack_ref: `/v1/capability-registry/policy-pack?account_id=${encodeURIComponent(accountId)}`,
|
|
485
|
+
capability_registry_operator_bundle_summary_ref: `/v1/capability-registry/operator-bundle/summary?account_id=${encodeURIComponent(accountId)}`,
|
|
486
|
+
partner_intelligence_summary_ref: "/v1/partner-intelligence/summary"
|
|
487
|
+
}
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function buildCapabilityRegistryPackage(state, input) {
|
|
492
|
+
const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
|
|
493
|
+
const accountId = String(payload.account_id || "acct_demo").trim() || "acct_demo";
|
|
494
|
+
const summary = buildCapabilityRegistrySummary();
|
|
495
|
+
const bundle = buildCapabilityRegistryBundle();
|
|
496
|
+
const classification = buildCapabilityRegistryClassificationSummary();
|
|
497
|
+
const lineage = buildCapabilityRegistryLineageSummary();
|
|
498
|
+
const operatorBundle = buildCapabilityRegistryOperatorBundle(state, { account_id: accountId });
|
|
499
|
+
const policyPack = buildCapabilityRegistryPolicyPack(state, { account_id: accountId });
|
|
500
|
+
const policyApplicationSummary = buildCapabilityRegistryPolicyApplicationSummary(state, { account_id: accountId });
|
|
501
|
+
|
|
502
|
+
return {
|
|
503
|
+
ok: true,
|
|
504
|
+
product: packageJson.name,
|
|
505
|
+
category: "machine-commerce-capability-registry-package",
|
|
506
|
+
package_version: "xytara-capability-registry-package-v1",
|
|
507
|
+
account_id: accountId,
|
|
508
|
+
package_posture: {
|
|
509
|
+
registry_state: summary.registry_state,
|
|
510
|
+
catalog_state: summary.registry_posture.catalog_state,
|
|
511
|
+
adapter_state: summary.registry_posture.adapter_state,
|
|
512
|
+
recommended_registry_motion: operatorBundle.operator_posture.recommended_registry_motion,
|
|
513
|
+
recommended_policy_motion: policyPack.recommended_policy_motion
|
|
514
|
+
},
|
|
515
|
+
capability_registry_summary: summary,
|
|
516
|
+
capability_registry_bundle: bundle,
|
|
517
|
+
capability_registry_classification_summary: classification,
|
|
518
|
+
capability_registry_lineage_summary: lineage,
|
|
519
|
+
capability_registry_operator_bundle: operatorBundle,
|
|
520
|
+
capability_registry_policy_pack: policyPack,
|
|
521
|
+
capability_registry_policy_application_summary: policyApplicationSummary,
|
|
522
|
+
linked_surfaces: {
|
|
523
|
+
capability_registry_ref: "/v1/capability-registry",
|
|
524
|
+
capability_registry_summary_ref: "/v1/capability-registry/summary",
|
|
525
|
+
capability_registry_operator_bundle_ref: `/v1/capability-registry/operator-bundle?account_id=${encodeURIComponent(accountId)}`,
|
|
526
|
+
capability_registry_policy_pack_ref: `/v1/capability-registry/policy-pack?account_id=${encodeURIComponent(accountId)}`,
|
|
527
|
+
capability_registry_policy_application_summary_ref: `/v1/capability-registry/policy-application-summary?account_id=${encodeURIComponent(accountId)}`
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
function summarizeCapabilityRegistryPackage(state, input) {
|
|
533
|
+
const pack = buildCapabilityRegistryPackage(state, input);
|
|
534
|
+
return {
|
|
535
|
+
ok: true,
|
|
536
|
+
product: pack.product,
|
|
537
|
+
category: pack.category,
|
|
538
|
+
package_version: pack.package_version,
|
|
539
|
+
account_id: pack.account_id,
|
|
540
|
+
registry_state: pack.package_posture.registry_state,
|
|
541
|
+
recommended_registry_motion: pack.package_posture.recommended_registry_motion,
|
|
542
|
+
recommended_policy_motion: pack.package_posture.recommended_policy_motion
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function summarizeCapabilityRegistryOperatorBundle(state, input) {
|
|
547
|
+
const bundle = buildCapabilityRegistryOperatorBundle(state, input);
|
|
548
|
+
return {
|
|
549
|
+
ok: true,
|
|
550
|
+
product: bundle.product,
|
|
551
|
+
category: bundle.category,
|
|
552
|
+
bundle_version: bundle.bundle_version,
|
|
553
|
+
account_id: bundle.account_id,
|
|
554
|
+
registry_state: bundle.operator_posture.registry_state,
|
|
555
|
+
partner_readiness_state: bundle.operator_posture.partner_readiness_state,
|
|
556
|
+
recommended_registry_motion: bundle.operator_posture.recommended_registry_motion
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
module.exports = {
|
|
561
|
+
buildCapabilityRegistrySummary,
|
|
562
|
+
buildCapabilityRegistryBundle,
|
|
563
|
+
buildCapabilityRegistryClassificationSummary,
|
|
564
|
+
buildCapabilityRegistryLineageSummary,
|
|
565
|
+
buildCapabilityRegistryOperatorBundle,
|
|
566
|
+
buildCapabilityRegistryPolicyPack,
|
|
567
|
+
summarizeCapabilityRegistryPolicyPack,
|
|
568
|
+
buildCapabilityRegistryPolicyApplicationSummary,
|
|
569
|
+
buildCapabilityRegistryPackage,
|
|
570
|
+
summarizeCapabilityRegistryPackage,
|
|
571
|
+
summarizeCapabilityRegistryOperatorBundle
|
|
572
|
+
};
|
package/lib/command_flow.js
CHANGED
|
@@ -6,7 +6,7 @@ const {
|
|
|
6
6
|
hydrateQuoteStates
|
|
7
7
|
} = require("./commerce_runtime");
|
|
8
8
|
const { consumeAccountCredits, buildUsageMeterPreview } = require("./commerce_economics");
|
|
9
|
-
const { resolveSpendCredential } = require("./account_auth");
|
|
9
|
+
const { resolveSpendCredential, evaluateAuthorityBindingAction } = require("./account_auth");
|
|
10
10
|
const { validateIntegrationSelection } = require("../integrations/dispatch");
|
|
11
11
|
const { markPaymentAccepted, verifyPaymentAcceptance } = require("./payment_verification");
|
|
12
12
|
|
|
@@ -77,6 +77,25 @@ function executeCommandRequest(state, payload, headers, options) {
|
|
|
77
77
|
quoted_units: Number.isFinite(Number(payload.quoted_units)) ? Number(payload.quoted_units) : undefined
|
|
78
78
|
});
|
|
79
79
|
const requiredUnits = meteringPreview.usage_units;
|
|
80
|
+
if (delegatedSpend.ok && delegatedSpend.binding) {
|
|
81
|
+
const authorityDecision = evaluateAuthorityBindingAction(delegatedSpend.binding, "delegated_credit_spend", requiredUnits);
|
|
82
|
+
if (!authorityDecision.ok) {
|
|
83
|
+
return {
|
|
84
|
+
status: 403,
|
|
85
|
+
payload: {
|
|
86
|
+
ok: false,
|
|
87
|
+
reason: authorityDecision.reason,
|
|
88
|
+
binding_id: authorityDecision.binding_id || null,
|
|
89
|
+
required_scope: authorityDecision.required_scope || null,
|
|
90
|
+
authority_scope: authorityDecision.authority_scope || [],
|
|
91
|
+
required_consequence_family: authorityDecision.required_consequence_family || null,
|
|
92
|
+
allowed_consequence_families: authorityDecision.allowed_consequence_families || [],
|
|
93
|
+
max_units: authorityDecision.max_units || null,
|
|
94
|
+
attempted_units: authorityDecision.attempted_units || requiredUnits
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
80
99
|
const creditSpend = consumeAccountCredits(state, {
|
|
81
100
|
account_id: quote.account_id,
|
|
82
101
|
agent_id: payload.agent_id || null,
|