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.
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+
3
+ function normalizeString(value, fallback = null) {
4
+ const trimmed = typeof value === "string" ? value.trim() : "";
5
+ return trimmed || fallback;
6
+ }
7
+
8
+ function ensureArray(value) {
9
+ return Array.isArray(value) ? value : [];
10
+ }
11
+
12
+ function nowIso() {
13
+ return new Date().toISOString();
14
+ }
15
+
16
+ function buildIdentityBindingPublicView(binding) {
17
+ if (!binding) return null;
18
+ return {
19
+ binding_id: binding.binding_id,
20
+ account_id: binding.account_id,
21
+ status: binding.status,
22
+ identity_kind: binding.identity_kind,
23
+ identity_ref: binding.identity_ref,
24
+ registry_scope: binding.registry_scope || null,
25
+ attached_agent_account_id: binding.attached_agent_account_id || null,
26
+ source_transaction_id: binding.source_transaction_id || null,
27
+ expires_at_iso: binding.expires_at_iso || null,
28
+ rotated_from_binding_id: binding.rotated_from_binding_id || null,
29
+ replaced_by_binding_id: binding.replaced_by_binding_id || null,
30
+ created_at_iso: binding.created_at_iso,
31
+ updated_at_iso: binding.updated_at_iso,
32
+ revoked_at_iso: binding.revoked_at_iso || null,
33
+ revoke_reason: binding.revoke_reason || null,
34
+ labels: ensureArray(binding.labels),
35
+ issued_by: binding.issued_by || null
36
+ };
37
+ }
38
+
39
+ function createIdentityBinding(state, body) {
40
+ const payload = body && typeof body === "object" && !Array.isArray(body) ? body : {};
41
+ const createdAtIso = nowIso();
42
+ const binding = {
43
+ binding_id: normalizeString(payload.binding_id, `identity_binding_${state.machineIdentityBindings.size + 1}`),
44
+ account_id: normalizeString(payload.account_id, "acct_demo"),
45
+ status: normalizeString(payload.status, "active"),
46
+ identity_kind: normalizeString(payload.identity_kind, "registry_anchor_identity"),
47
+ identity_ref: normalizeString(payload.identity_ref, `identity_ref_${state.machineIdentityBindings.size + 1}`),
48
+ registry_scope: normalizeString(payload.registry_scope, null),
49
+ attached_agent_account_id: normalizeString(payload.attached_agent_account_id, null),
50
+ source_transaction_id: normalizeString(payload.source_transaction_id, null),
51
+ expires_at_iso: normalizeString(payload.expires_at_iso, null),
52
+ labels: ensureArray(payload.labels).map((value) => String(value || "").trim()).filter(Boolean),
53
+ issued_by: normalizeString(payload.issued_by, "operator"),
54
+ rotated_from_binding_id: normalizeString(payload.rotated_from_binding_id, null),
55
+ replaced_by_binding_id: normalizeString(payload.replaced_by_binding_id, null),
56
+ created_at_iso: createdAtIso,
57
+ updated_at_iso: createdAtIso,
58
+ revoked_at_iso: null,
59
+ revoke_reason: null
60
+ };
61
+ state.machineIdentityBindings.set(binding.binding_id, binding);
62
+ return buildIdentityBindingPublicView(binding);
63
+ }
64
+
65
+ function listIdentityBindings(state, filters) {
66
+ const payload = filters && typeof filters === "object" && !Array.isArray(filters) ? filters : {};
67
+ const accountId = normalizeString(payload.account_id, null);
68
+ const status = normalizeString(payload.status, null);
69
+ return Array.from(state.machineIdentityBindings.values())
70
+ .filter((binding) => {
71
+ if (accountId && binding.account_id !== accountId) return false;
72
+ if (status && binding.status !== status) return false;
73
+ return true;
74
+ })
75
+ .map((binding) => buildIdentityBindingPublicView(binding));
76
+ }
77
+
78
+ function getIdentityBinding(state, bindingId) {
79
+ if (!bindingId || !state.machineIdentityBindings.has(bindingId)) return null;
80
+ return buildIdentityBindingPublicView(state.machineIdentityBindings.get(bindingId));
81
+ }
82
+
83
+ function revokeIdentityBinding(state, bindingId, body) {
84
+ if (!bindingId || !state.machineIdentityBindings.has(bindingId)) return null;
85
+ const payload = body && typeof body === "object" && !Array.isArray(body) ? body : {};
86
+ const current = state.machineIdentityBindings.get(bindingId);
87
+ const next = {
88
+ ...current,
89
+ status: "revoked",
90
+ revoked_at_iso: nowIso(),
91
+ revoke_reason: normalizeString(payload.reason, "operator_revoked"),
92
+ updated_at_iso: nowIso()
93
+ };
94
+ state.machineIdentityBindings.set(bindingId, next);
95
+ return buildIdentityBindingPublicView(next);
96
+ }
97
+
98
+ function getIdentityBindingRotationSummary(state, bindingId) {
99
+ if (!bindingId || !state.machineIdentityBindings.has(bindingId)) return null;
100
+ const binding = state.machineIdentityBindings.get(bindingId);
101
+ return {
102
+ summary_version: "xytara-identity-binding-rotation-summary-v1",
103
+ binding_id: binding.binding_id,
104
+ account_id: binding.account_id,
105
+ status: binding.status,
106
+ predecessor_binding_id: binding.rotated_from_binding_id || null,
107
+ successor_binding_id: binding.replaced_by_binding_id || null,
108
+ expires_at_iso: binding.expires_at_iso || null,
109
+ rotation_state: binding.rotated_from_binding_id || binding.replaced_by_binding_id
110
+ ? "lineage_present"
111
+ : "standalone",
112
+ linked_surfaces: {
113
+ identity_binding_ref: `/v1/identity/bindings/${encodeURIComponent(binding.binding_id)}`
114
+ },
115
+ generated_at_iso: nowIso()
116
+ };
117
+ }
118
+
119
+ function renewIdentityBinding(state, bindingId, body) {
120
+ if (!bindingId || !state.machineIdentityBindings.has(bindingId)) return null;
121
+ const payload = body && typeof body === "object" && !Array.isArray(body) ? body : {};
122
+ const current = state.machineIdentityBindings.get(bindingId);
123
+ const next = {
124
+ ...current,
125
+ expires_at_iso: normalizeString(payload.expires_at_iso, current.expires_at_iso || null),
126
+ updated_at_iso: nowIso()
127
+ };
128
+ state.machineIdentityBindings.set(bindingId, next);
129
+ return buildIdentityBindingPublicView(next);
130
+ }
131
+
132
+ function rotateIdentityBinding(state, bindingId, body) {
133
+ if (!bindingId || !state.machineIdentityBindings.has(bindingId)) return null;
134
+ const payload = body && typeof body === "object" && !Array.isArray(body) ? body : {};
135
+ const current = state.machineIdentityBindings.get(bindingId);
136
+ const successorBindingId = normalizeString(payload.successor_binding_id, `${bindingId}_rotated`);
137
+ const successor = createIdentityBinding(state, {
138
+ binding_id: successorBindingId,
139
+ account_id: current.account_id,
140
+ identity_kind: normalizeString(payload.identity_kind, current.identity_kind),
141
+ identity_ref: normalizeString(payload.identity_ref, current.identity_ref),
142
+ registry_scope: normalizeString(payload.registry_scope, current.registry_scope),
143
+ attached_agent_account_id: normalizeString(payload.attached_agent_account_id, current.attached_agent_account_id),
144
+ source_transaction_id: normalizeString(payload.source_transaction_id, current.source_transaction_id),
145
+ expires_at_iso: normalizeString(payload.expires_at_iso, current.expires_at_iso || null),
146
+ labels: ensureArray(payload.labels).length > 0 ? ensureArray(payload.labels) : ensureArray(current.labels),
147
+ issued_by: normalizeString(payload.issued_by, current.issued_by || "operator"),
148
+ rotated_from_binding_id: current.binding_id
149
+ });
150
+ revokeIdentityBinding(state, bindingId, {
151
+ reason: normalizeString(payload.reason, "rotated_to_successor")
152
+ });
153
+ state.machineIdentityBindings.set(successor.binding_id, {
154
+ ...state.machineIdentityBindings.get(successor.binding_id),
155
+ rotated_from_binding_id: current.binding_id
156
+ });
157
+ state.machineIdentityBindings.set(bindingId, {
158
+ ...state.machineIdentityBindings.get(bindingId),
159
+ replaced_by_binding_id: successor.binding_id
160
+ });
161
+ return {
162
+ rotated_binding: buildIdentityBindingPublicView(state.machineIdentityBindings.get(bindingId)),
163
+ successor_identity_binding: buildIdentityBindingPublicView(state.machineIdentityBindings.get(successor.binding_id))
164
+ };
165
+ }
166
+
167
+ module.exports = {
168
+ createIdentityBinding,
169
+ listIdentityBindings,
170
+ getIdentityBinding,
171
+ getIdentityBindingRotationSummary,
172
+ renewIdentityBinding,
173
+ revokeIdentityBinding,
174
+ rotateIdentityBinding
175
+ };
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ const { buildEconomicsIntelligenceSummary } = require("./commerce_economics");
4
+ const { buildPartnerIntelligencePack } = require("./partner_intelligence");
5
+
6
+ function buildOperatorIntelligencePack(state, input) {
7
+ const payload = input && typeof input === "object" && !Array.isArray(input) ? input : {};
8
+ const accountId = String(payload.account_id || "acct_demo").trim() || "acct_demo";
9
+ const economicsIntelligence = buildEconomicsIntelligenceSummary(state, accountId);
10
+ const partnerIntelligence = buildPartnerIntelligencePack();
11
+
12
+ const actionQueue = [];
13
+
14
+ if (economicsIntelligence.next_best_action && economicsIntelligence.next_best_action !== "continue_current_posture") {
15
+ actionQueue.push({
16
+ lane: "runtime_economics",
17
+ priority: economicsIntelligence.replenishment_risk_state === "high" ? "high" : "medium",
18
+ action: economicsIntelligence.next_best_action,
19
+ reason: `funding posture is ${economicsIntelligence.recommended_funding_posture} with ${economicsIntelligence.replenishment_risk_state} replenishment risk`
20
+ });
21
+ }
22
+
23
+ if (partnerIntelligence.next_best_action) {
24
+ actionQueue.push({
25
+ lane: "partner_adoption",
26
+ priority: partnerIntelligence.onboarding_friction_state === "low" ? "medium" : "high",
27
+ action: partnerIntelligence.next_best_action,
28
+ reason: `partner readiness is ${partnerIntelligence.partner_readiness_state} and onboarding friction is ${partnerIntelligence.onboarding_friction_state}`
29
+ });
30
+ }
31
+
32
+ if (actionQueue.length === 0) {
33
+ actionQueue.push({
34
+ lane: "operator_posture",
35
+ priority: "low",
36
+ action: "continue_current_posture",
37
+ reason: "runtime economics and partner posture are both stable enough to continue current operation"
38
+ });
39
+ }
40
+
41
+ return {
42
+ ok: true,
43
+ account_id: accountId,
44
+ category: "machine-commerce-operator-intelligence-pack",
45
+ overall_operator_state: {
46
+ runtime_economics_state: economicsIntelligence.treasury_health_state,
47
+ partner_adoption_state: partnerIntelligence.partner_readiness_state,
48
+ top_priority: actionQueue[0].priority
49
+ },
50
+ recommended_operator_motion: actionQueue[0].action,
51
+ next_action_queue: actionQueue,
52
+ intelligence_refs: {
53
+ economics_intelligence_ref: `/v1/economics/accounts/${encodeURIComponent(accountId)}/intelligence-summary`,
54
+ partner_intelligence_ref: "/v1/partner-intelligence",
55
+ operator_dashboard_ref: `/v1/economics/accounts/${encodeURIComponent(accountId)}/operator-dashboard`
56
+ },
57
+ explanation_signals: {
58
+ runtime_next_best_action: economicsIntelligence.next_best_action,
59
+ runtime_funding_posture: economicsIntelligence.recommended_funding_posture,
60
+ runtime_replenishment_risk_state: economicsIntelligence.replenishment_risk_state,
61
+ runtime_treasury_health_state: economicsIntelligence.treasury_health_state,
62
+ partner_next_best_action: partnerIntelligence.next_best_action,
63
+ partner_readiness_state: partnerIntelligence.partner_readiness_state,
64
+ partner_onboarding_friction_state: partnerIntelligence.onboarding_friction_state,
65
+ partner_promotion_readiness_state: partnerIntelligence.promotion_readiness_state
66
+ },
67
+ generated_from: {
68
+ economics_category: economicsIntelligence.category,
69
+ partner_category: partnerIntelligence.category
70
+ }
71
+ };
72
+ }
73
+
74
+ function summarizeOperatorIntelligencePack(state, input) {
75
+ const pack = buildOperatorIntelligencePack(state, input);
76
+ return {
77
+ ok: true,
78
+ account_id: pack.account_id,
79
+ category: pack.category,
80
+ recommended_operator_motion: pack.recommended_operator_motion,
81
+ queue_length: pack.next_action_queue.length,
82
+ runtime_economics_state: pack.overall_operator_state.runtime_economics_state,
83
+ partner_adoption_state: pack.overall_operator_state.partner_adoption_state
84
+ };
85
+ }
86
+
87
+ module.exports = {
88
+ buildOperatorIntelligencePack,
89
+ summarizeOperatorIntelligencePack
90
+ };
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ const packageJson = require("../package.json");
4
+ const { buildAdoptionPack } = require("./release_pack");
5
+ const { buildAdapterPartnerPack } = require("./adapter_partner_pack");
6
+
7
+ function classifyPartnerReadinessState(adoptionPack, adapterPartnerPack) {
8
+ const targetCount = adoptionPack.initial_adoption_targets.length;
9
+ const firstSuccessPathCount = adoptionPack.first_success_paths.length;
10
+ const partnerValueCount = adapterPartnerPack.partner_value.length;
11
+ const maturityStepCount = adapterPartnerPack.trust_path.maturity_path.length;
12
+
13
+ if (targetCount >= 4 && firstSuccessPathCount >= 3 && partnerValueCount >= 4 && maturityStepCount >= 5) {
14
+ return "strong";
15
+ }
16
+ if (targetCount >= 2 && firstSuccessPathCount >= 2 && partnerValueCount >= 2) {
17
+ return "working";
18
+ }
19
+ return "early";
20
+ }
21
+
22
+ function classifyOnboardingFrictionState(adapterPartnerPack) {
23
+ const docCount = adapterPartnerPack.start_path.first_docs.length;
24
+ const commandCount = adapterPartnerPack.start_path.first_commands.length;
25
+ const exampleCount = adapterPartnerPack.start_path.first_examples.length;
26
+
27
+ if (docCount >= 2 && commandCount >= 4 && exampleCount >= 2) return "low";
28
+ if (docCount >= 1 && commandCount >= 2) return "manageable";
29
+ return "high";
30
+ }
31
+
32
+ function classifyPromotionReadinessState(adapterPartnerPack) {
33
+ const publicSurfaceCount = Object.keys(adapterPartnerPack.public_surfaces).length;
34
+ const maturityStepCount = adapterPartnerPack.trust_path.maturity_path.length;
35
+ if (publicSurfaceCount >= 5 && maturityStepCount >= 5) return "strong";
36
+ if (publicSurfaceCount >= 3 && maturityStepCount >= 3) return "working";
37
+ return "early";
38
+ }
39
+
40
+ function buildPartnerIntelligencePack() {
41
+ const adoptionPack = buildAdoptionPack();
42
+ const adapterPartnerPack = buildAdapterPartnerPack();
43
+ const partnerReadinessState = classifyPartnerReadinessState(adoptionPack, adapterPartnerPack);
44
+ const onboardingFrictionState = classifyOnboardingFrictionState(adapterPartnerPack);
45
+ const promotionReadinessState = classifyPromotionReadinessState(adapterPartnerPack);
46
+
47
+ let nextBestAction = "promote_partner_start_path";
48
+ if (onboardingFrictionState !== "low") {
49
+ nextBestAction = "tighten_partner_onboarding";
50
+ } else if (promotionReadinessState !== "strong") {
51
+ nextBestAction = "strengthen_promotion_trust_path";
52
+ }
53
+
54
+ return {
55
+ ok: true,
56
+ product: packageJson.name,
57
+ category: "machine-commerce-partner-intelligence-pack",
58
+ partner_readiness_state: partnerReadinessState,
59
+ onboarding_friction_state: onboardingFrictionState,
60
+ promotion_readiness_state: promotionReadinessState,
61
+ first_partner_segment: adapterPartnerPack.adoption_message.first_partner_type,
62
+ recommended_partner_motion: "lead_with_adapter_authors_and_agent_builders",
63
+ next_best_action: nextBestAction,
64
+ explanation_signals: {
65
+ adoption_target_count: adoptionPack.initial_adoption_targets.length,
66
+ target_ecosystem_count: adoptionPack.target_ecosystems.length,
67
+ first_success_path_count: adoptionPack.first_success_paths.length,
68
+ partner_value_count: adapterPartnerPack.partner_value.length,
69
+ onboarding_doc_count: adapterPartnerPack.start_path.first_docs.length,
70
+ onboarding_command_count: adapterPartnerPack.start_path.first_commands.length,
71
+ onboarding_example_count: adapterPartnerPack.start_path.first_examples.length,
72
+ maturity_step_count: adapterPartnerPack.trust_path.maturity_path.length,
73
+ public_surface_count: Object.keys(adapterPartnerPack.public_surfaces).length
74
+ },
75
+ linked_surfaces: {
76
+ adoption_summary_ref: "/v1/release-pack/adoption/summary",
77
+ adapter_partner_summary_ref: "/v1/adapter-partners/summary",
78
+ release_center_summary_ref: "/v1/release-center/summary"
79
+ },
80
+ generated_from: {
81
+ adoption_pack_category: adoptionPack.category,
82
+ adapter_partner_pack_category: adapterPartnerPack.category
83
+ }
84
+ };
85
+ }
86
+
87
+ function summarizePartnerIntelligencePack() {
88
+ const pack = buildPartnerIntelligencePack();
89
+ return {
90
+ ok: true,
91
+ product: pack.product,
92
+ category: pack.category,
93
+ partner_readiness_state: pack.partner_readiness_state,
94
+ onboarding_friction_state: pack.onboarding_friction_state,
95
+ promotion_readiness_state: pack.promotion_readiness_state,
96
+ first_partner_segment: pack.first_partner_segment,
97
+ next_best_action: pack.next_best_action,
98
+ signal_count: Object.keys(pack.explanation_signals).length
99
+ };
100
+ }
101
+
102
+ module.exports = {
103
+ buildPartnerIntelligencePack,
104
+ summarizePartnerIntelligencePack
105
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xytara",
3
- "version": "2.2.0",
3
+ "version": "2.4.0",
4
4
  "description": "Machine commerce SDK for discovery, quoting, execution, lifecycle inspection, and adapters.",
5
5
  "main": "index.js",
6
6
  "bin": {