@elevasis/sdk 1.44.2 → 1.45.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/dist/cli.cjs +1001 -652
- package/dist/index.d.ts +1045 -509
- package/dist/index.js +748 -690
- package/dist/node/index.d.ts +105 -97
- package/dist/test-utils/index.d.ts +42 -28
- package/dist/test-utils/index.js +549 -732
- package/dist/worker/index.d.ts +12112 -0
- package/dist/worker/index.js +211 -186
- package/package.json +6 -9
- package/reference/_navigation.md +151 -21
- package/reference/_reference-manifest.json +186 -4
- package/reference/claude-config.md +8 -0
- package/reference/core/index.mdx +3 -3
- package/reference/examples/organization-model.ts +117 -111
- package/reference/index.mdx +4 -4
- package/reference/rules/active-change-index.md +40 -54
- package/reference/rules/agent-runtime.md +81 -0
- package/reference/rules/agent-start-here.md +71 -163
- package/reference/rules/deployment.md +33 -10
- package/reference/rules/error-handling.md +26 -0
- package/reference/rules/execution.md +13 -0
- package/reference/rules/frontend.md +10 -3
- package/reference/rules/observability.md +9 -1
- package/reference/rules/operations.md +26 -17
- package/reference/rules/organization-model.md +74 -88
- package/reference/rules/organization-os.md +71 -88
- package/reference/rules/package-taxonomy.md +11 -2
- package/reference/rules/platform.md +13 -7
- package/reference/rules/shared-types.md +15 -0
- package/reference/rules/task-tracking.md +30 -5
- package/reference/rules/ui.md +145 -3
- package/reference/rules/vibe-intents.md +271 -0
- package/reference/rules/vibe.md +17 -243
- package/reference/scaffold/core/organization-graph.mdx +111 -97
- package/reference/scaffold/core/organization-model.mdx +234 -214
- package/reference/scaffold/operations/propagation-pipeline.md +1 -1
- package/reference/scaffold/operations/scaffold-maintenance.md +19 -18
- package/reference/scaffold/operations/workflow-recipes.md +71 -19
- package/reference/scaffold/recipes/add-a-feature.md +156 -146
- package/reference/scaffold/recipes/add-a-resource.md +123 -117
- package/reference/scaffold/recipes/customize-crm-actions.md +25 -10
- package/reference/scaffold/recipes/customize-knowledge-browser.md +52 -117
- package/reference/scaffold/recipes/customize-organization-model.md +161 -149
- package/reference/scaffold/recipes/extend-a-base-entity.md +156 -140
- package/reference/scaffold/recipes/extend-crm.md +16 -11
- package/reference/scaffold/recipes/extend-lead-gen.md +25 -7
- package/reference/scaffold/recipes/gate-by-feature-or-admin.md +160 -118
- package/reference/scaffold/recipes/index.md +2 -2
- package/reference/scaffold/recipes/query-the-knowledge-graph.md +23 -23
- package/reference/scaffold/reference/contracts.md +12 -1
- package/reference/scaffold/reference/glossary.md +3 -3
- package/reference/scaffold/reference/system-interface-capabilities.md +5 -4
- package/reference/scaffold/ui/composition-extensibility.mdx +271 -232
- package/reference/scaffold/ui/feature-flags-and-gating.md +14 -6
- package/reference/scaffold/ui/feature-shell.mdx +279 -62
- package/reference/scaffold/ui/recipes.md +229 -197
- package/reference/sdk/cli-management.mdx +77 -29
- package/reference/sdk/concepts.mdx +2 -0
- package/reference/sdk/define-builders.mdx +76 -0
- package/reference/sdk/deployment/command-center.mdx +6 -2
- package/reference/sdk/deployment/execution-reference.mdx +64 -186
- package/reference/sdk/deployment/index.mdx +2 -0
- package/reference/sdk/exports.mdx +4 -4
- package/reference/sdk/framework/agent.mdx +49 -119
- package/reference/sdk/framework/index.mdx +46 -65
- package/reference/sdk/framework/project-structure.mdx +150 -205
- package/reference/sdk/framework/tutorial-system.mdx +2 -2
- package/reference/sdk/human-in-the-loop.mdx +152 -0
- package/reference/sdk/index.mdx +6 -7
- package/reference/sdk/platform-tools/index.mdx +12 -0
- package/reference/sdk/platform-tools/type-safety.mdx +4 -0
- package/reference/sdk/project-deployment-spec.mdx +131 -0
- package/reference/sdk/resources/index.mdx +23 -7
- package/reference/sdk/resources/patterns.mdx +54 -24
- package/reference/sdk/resources/types.mdx +7 -4
- package/reference/sdk/templates/data-enrichment.mdx +7 -3
- package/reference/sdk/templates/email-sender.mdx +139 -135
- package/reference/sdk/templates/lead-scorer.mdx +5 -1
- package/reference/sdk/templates/pdf-generator.mdx +155 -151
- package/reference/sdk/templates/recurring-job.mdx +195 -189
- package/reference/sdk/templates/text-classifier.mdx +4 -0
- package/reference/sdk/templates/web-scraper.mdx +139 -135
- package/reference/spine/spine-primer.md +135 -96
- package/reference/ui/index.mdx +14 -7
- package/dist/types/worker/adapters/anymailfinder.d.ts +0 -14
- package/dist/types/worker/adapters/apify.d.ts +0 -14
- package/dist/types/worker/adapters/approval.d.ts +0 -23
- package/dist/types/worker/adapters/attio.d.ts +0 -22
- package/dist/types/worker/adapters/clickup.d.ts +0 -22
- package/dist/types/worker/adapters/create-adapter.d.ts +0 -41
- package/dist/types/worker/adapters/crm.d.ts +0 -20
- package/dist/types/worker/adapters/dropbox.d.ts +0 -14
- package/dist/types/worker/adapters/email.d.ts +0 -25
- package/dist/types/worker/adapters/execution.d.ts +0 -22
- package/dist/types/worker/adapters/gmail.d.ts +0 -14
- package/dist/types/worker/adapters/google-sheets.d.ts +0 -14
- package/dist/types/worker/adapters/index.d.ts +0 -33
- package/dist/types/worker/adapters/instantly.d.ts +0 -14
- package/dist/types/worker/adapters/lead.d.ts +0 -28
- package/dist/types/worker/adapters/list.d.ts +0 -9
- package/dist/types/worker/adapters/llm.d.ts +0 -45
- package/dist/types/worker/adapters/millionverifier.d.ts +0 -14
- package/dist/types/worker/adapters/notification.d.ts +0 -28
- package/dist/types/worker/adapters/pdf.d.ts +0 -22
- package/dist/types/worker/adapters/projects.d.ts +0 -20
- package/dist/types/worker/adapters/resend.d.ts +0 -14
- package/dist/types/worker/adapters/scheduler.d.ts +0 -25
- package/dist/types/worker/adapters/signature-api.d.ts +0 -14
- package/dist/types/worker/adapters/storage.d.ts +0 -33
- package/dist/types/worker/adapters/stripe.d.ts +0 -14
- package/dist/types/worker/adapters/tomba.d.ts +0 -14
- package/dist/types/worker/index.d.ts +0 -60
- package/dist/types/worker/platform.d.ts +0 -90
- package/dist/types/worker/utils.d.ts +0 -9
- package/reference/claude-config/Overview.md +0 -230
- package/reference/claude-config/hooks/post-edit-validate.mjs +0 -98
- package/reference/claude-config/hooks/scaffold-registry-reminder.mjs +0 -187
- package/reference/claude-config/hooks/tool-failure-recovery.mjs +0 -73
- package/reference/claude-config/registries/graph-skills.json +0 -4
- package/reference/claude-config/registries/knowledge-flags.json +0 -154
- package/reference/claude-config/registries/skill-coverage.json +0 -20
- package/reference/claude-config/rules/active-change-index.md +0 -22
- package/reference/claude-config/rules/agent-start-here.md +0 -22
- package/reference/claude-config/rules/deployment.md +0 -22
- package/reference/claude-config/rules/error-handling.md +0 -22
- package/reference/claude-config/rules/execution.md +0 -22
- package/reference/claude-config/rules/frontend.md +0 -22
- package/reference/claude-config/rules/observability.md +0 -22
- package/reference/claude-config/rules/operations.md +0 -22
- package/reference/claude-config/rules/organization-model.md +0 -22
- package/reference/claude-config/rules/organization-os.md +0 -22
- package/reference/claude-config/rules/package-taxonomy.md +0 -22
- package/reference/claude-config/rules/platform.md +0 -22
- package/reference/claude-config/rules/shared-types.md +0 -22
- package/reference/claude-config/rules/task-tracking.md +0 -22
- package/reference/claude-config/rules/topbar-actions.md +0 -70
- package/reference/claude-config/rules/ui.md +0 -22
- package/reference/claude-config/rules/vibe.md +0 -22
- package/reference/claude-config/scripts/statusline-command.js +0 -18
- package/reference/claude-config/settings.json +0 -30
- package/reference/claude-config/skills/client/SKILL.md +0 -201
- package/reference/claude-config/skills/deploy/SKILL.md +0 -159
- package/reference/claude-config/skills/dsp/SKILL.md +0 -66
- package/reference/claude-config/skills/elevasis/SKILL.md +0 -251
- package/reference/claude-config/skills/explore/SKILL.md +0 -78
- package/reference/claude-config/skills/git-sync/SKILL.md +0 -166
- package/reference/claude-config/skills/om/SKILL.md +0 -475
- package/reference/claude-config/skills/om/operations/build.md +0 -237
- package/reference/claude-config/skills/om/operations/codify-level-a.md +0 -109
- package/reference/claude-config/skills/om/operations/codify-level-b.md +0 -159
- package/reference/claude-config/skills/om/operations/customers.md +0 -114
- package/reference/claude-config/skills/om/operations/features.md +0 -88
- package/reference/claude-config/skills/om/operations/goals.md +0 -123
- package/reference/claude-config/skills/om/operations/identity.md +0 -97
- package/reference/claude-config/skills/om/operations/labels.md +0 -110
- package/reference/claude-config/skills/om/operations/offerings.md +0 -114
- package/reference/claude-config/skills/om/operations/roles.md +0 -104
- package/reference/claude-config/skills/om/operations/scaffold.md +0 -163
- package/reference/claude-config/skills/om/operations/techStack.md +0 -38
- package/reference/claude-config/skills/project/SKILL.md +0 -1114
- package/reference/claude-config/skills/run-ui/SKILL.md +0 -73
- package/reference/claude-config/skills/save/SKILL.md +0 -183
- package/reference/claude-config/skills/setup/SKILL.md +0 -290
- package/reference/claude-config/skills/status/SKILL.md +0 -59
- package/reference/claude-config/skills/submit-request/SKILL.md +0 -180
- package/reference/claude-config/skills/sync/SKILL.md +0 -47
- package/reference/claude-config/skills/tutorial/SKILL.md +0 -259
- package/reference/claude-config/skills/tutorial/progress-template.md +0 -74
- package/reference/claude-config/skills/tutorial/technical.md +0 -1303
- package/reference/claude-config/skills/tutorial/vibe-coder.md +0 -890
- package/reference/claude-config/sync-notes/2026-04-22-git-sync-and-sync-notes.md +0 -27
- package/reference/claude-config/sync-notes/2026-04-22-lead-gen-deliverability-removal.md +0 -30
- package/reference/claude-config/sync-notes/2026-04-24-test-utils-and-template-tests.md +0 -73
- package/reference/claude-config/sync-notes/2026-04-24-ui-consolidation-and-sdk-cli-train.md +0 -86
- package/reference/claude-config/sync-notes/2026-04-25-auth-role-system-and-settings-roles.md +0 -55
- package/reference/claude-config/sync-notes/2026-04-27-crm-hitl-action-layer-cutover.md +0 -97
- package/reference/claude-config/sync-notes/2026-04-27-lead-gen-substrate-train.md +0 -112
- package/reference/claude-config/sync-notes/2026-04-29-crm-state-and-lead-gen-processing-status.md +0 -93
- package/reference/claude-config/sync-notes/2026-05-02-crm-ownership-next-action.md +0 -58
- package/reference/claude-config/sync-notes/2026-05-02-template-hardcode-workos-config.md +0 -56
- package/reference/claude-config/sync-notes/2026-05-04-elevasis-workspace.md +0 -71
- package/reference/claude-config/sync-notes/2026-05-04-knowledge-bundle.md +0 -83
- package/reference/claude-config/sync-notes/2026-05-04-template-skills-run-ui-and-tutorial.md +0 -59
- package/reference/claude-config/sync-notes/2026-05-05-list-builder.md +0 -42
- package/reference/claude-config/sync-notes/2026-05-06-crm-spine.md +0 -60
- package/reference/claude-config/sync-notes/2026-05-06-sdk-changes-release-train.md +0 -37
- package/reference/claude-config/sync-notes/2026-05-07-sdk-changes-release-train.md +0 -34
- package/reference/claude-config/sync-notes/2026-05-08-resource-governance-scaffold-guidance.md +0 -38
- package/reference/claude-config/sync-notes/2026-05-09-clients-domain.md +0 -32
- package/reference/claude-config/sync-notes/2026-05-09-command-system.md +0 -33
- package/reference/claude-config/sync-notes/2026-05-09-resource-governance-and-misc.md +0 -69
- package/reference/claude-config/sync-notes/2026-05-12-sdk-ready-release-train.md +0 -30
- package/reference/claude-config/sync-notes/2026-05-14-organization-model-ontology-refactor.md +0 -45
- package/reference/claude-config/sync-notes/2026-05-15-om-skill-rename-and-write-family.md +0 -52
- package/reference/claude-config/sync-notes/2026-05-17-sdk-boundary-consolidation.md +0 -33
- package/reference/claude-config/sync-notes/2026-05-20-om-define-helpers.md +0 -32
- package/reference/claude-config/sync-notes/2026-05-22-access-model-and-right-panel.md +0 -43
- package/reference/claude-config/sync-notes/2026-05-22-lead-gen-tenant-config.md +0 -40
- package/reference/claude-config/sync-notes/2026-05-22-org-model-multi-file-split.md +0 -61
- package/reference/claude-config/sync-notes/2026-05-23-branding-names-to-identity.md +0 -49
- package/reference/claude-config/sync-notes/2026-05-23-lead-gen-manage-access.md +0 -31
- package/reference/claude-config/sync-notes/2026-05-23-om-deployment-drift-detection.md +0 -42
- package/reference/claude-config/sync-notes/2026-05-23-om-full-model-deploy-contract.md +0 -33
- package/reference/claude-config/sync-notes/2026-05-23-ui-sdk-package-fixes.md +0 -37
- package/reference/claude-config/sync-notes/2026-05-24-platform-invite-router-core-baseline.md +0 -28
- package/reference/claude-config/sync-notes/2026-05-24-system-interface-readiness.md +0 -43
- package/reference/claude-config/sync-notes/2026-05-25-invitation-login-loader.md +0 -26
- package/reference/claude-config/sync-notes/2026-05-25-om-topbar-requests.md +0 -33
- package/reference/claude-config/sync-notes/2026-05-25-system-interface-profile-registry-and-substrate.md +0 -35
- package/reference/claude-config/sync-notes/2026-05-25-tenant-om-scaffold-cli.md +0 -49
- package/reference/claude-config/sync-notes/2026-05-25-vibe-operate-intent.md +0 -47
- package/reference/claude-config/sync-notes/2026-05-28-om-snapshot-sdk-workflow-config.md +0 -33
- package/reference/claude-config/sync-notes/2026-05-30-client-source-and-om-profiles.md +0 -39
- package/reference/claude-config/sync-notes/2026-06-02-knowledge-nested-group-routing.md +0 -27
- package/reference/claude-config/sync-notes/2026-06-02-nest-projects-under-platform.md +0 -45
- package/reference/claude-config/sync-notes/2026-06-03-skill-autogen-and-client-skill.md +0 -34
- package/reference/claude-config/sync-notes/2026-06-04-scaffold-registry-lane-severity.md +0 -34
- package/reference/claude-config/sync-notes/2026-06-05-appearance-app-mode-decouple.md +0 -29
- package/reference/claude-config/sync-notes/2026-06-05-ontology-endpoint-rename-and-knowledge-browser-ui.md +0 -86
- package/reference/claude-config/sync-notes/2026-06-06-om-build-systems-scaffold.md +0 -47
- package/reference/claude-config/sync-notes/2026-06-06-om-item-copy-references.md +0 -50
- package/reference/claude-config/sync-notes/2026-06-08-knowledge-base-page-not-found-fix.md +0 -76
- package/reference/claude-config/sync-notes/2026-06-09-agent-sessions-public-agent-chat-route.md +0 -75
- package/reference/claude-config/sync-notes/2026-06-09-sdk-cli-load-org-model-resolution.md +0 -42
- package/reference/claude-config/sync-notes/2026-06-12-agent-grants-visualizer-operations.md +0 -30
- package/reference/claude-config/sync-notes/2026-06-14-session-ux-and-project-cli-json.md +0 -33
- package/reference/claude-config/sync-notes/2026-06-14-shared-session-conversation-view.md +0 -26
- package/reference/claude-config/sync-notes/2026-06-15-session-chat-zero-wiring.md +0 -46
- package/reference/claude-config/sync-notes/2026-06-17-agent-session-ux-features.md +0 -34
- package/reference/claude-config/sync-notes/2026-06-25-shared-page-scroll-contract-guard.md +0 -52
- package/reference/claude-config/sync-notes/2026-06-26-leadgen-overview-om-telemetry.md +0 -47
- package/reference/claude-config/sync-notes/2026-07-21-agent-scaffold-hardening.md +0 -75
- package/reference/claude-config/sync-notes/2026-07-23-agent-session-memory.md +0 -49
- package/reference/claude-config/sync-notes/2026-07-23-workos-org-marker.md +0 -50
- package/reference/claude-config/sync-notes/2026-07-24-claude-5-models-and-session-surface-fixes.md +0 -116
- package/reference/claude-config/sync-notes/2026-07-27-agent-strict-output-and-turn-drift.md +0 -73
- package/reference/claude-config/sync-notes/2026-07-28-agent-reply-is-its-own-field.md +0 -84
- package/reference/claude-config/sync-notes/2026-07-30-login-screen-and-member-provisioning-state.md +0 -114
- package/reference/claude-config/sync-notes/2026-08-02-auth-guard-defaults-and-truncation-fix.md +0 -122
- package/reference/claude-config/sync-notes/2026-08-03-cli-gateway-errors-and-request-timeout.md +0 -120
- package/reference/claude-config/sync-notes/README.md +0 -43
- package/reference/sdk/framework/interaction-guidance.mdx +0 -182
- package/reference/sdk/framework/memory.mdx +0 -326
- package/reference/sdk/framework/resource-documentation.mdx +0 -90
- package/reference/sdk/roadmap.mdx +0 -164
package/dist/index.js
CHANGED
|
@@ -623,17 +623,23 @@ var SystemInterfaceResourceScopeSchema = z.array(ModelIdSchema).default([]);
|
|
|
623
623
|
var SystemApiInterfaceReadinessContractSchema = z.object({
|
|
624
624
|
/** Ontology IDs of object types the interface depends on. */
|
|
625
625
|
requiredObjects: z.array(z.string().trim().min(1)).default([]),
|
|
626
|
-
/**
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
626
|
+
/**
|
|
627
|
+
* Ontology IDs of catalog types the interface requires. Must declare at least one
|
|
628
|
+
* entry — a `readinessContract` with no `requiredCatalogs` asserts nothing at all,
|
|
629
|
+
* so it has no `.default([])`; omitting the field is rejected the same as an
|
|
630
|
+
* explicit empty array.
|
|
631
|
+
*/
|
|
632
|
+
requiredCatalogs: z.array(z.string().trim().min(1)).min(1)
|
|
630
633
|
}).strict();
|
|
631
634
|
var SystemApiInterfaceSchema = z.object({
|
|
632
635
|
lifecycle: SystemInterfaceLifecycleSchema.default("active"),
|
|
633
636
|
/**
|
|
634
637
|
* Open-string profile id. Built-in platform presets are looked up through
|
|
635
638
|
* the profile registry; custom ids are validated structurally via
|
|
636
|
-
* `readinessContract`. Optional
|
|
639
|
+
* `readinessContract`. Optional at the schema layer, but readiness
|
|
640
|
+
* computation rejects an interface that omits it with a
|
|
641
|
+
* `missing-readiness-profile` diagnostic — there is no positional
|
|
642
|
+
* fallback to `${systemPath}.${interfaceKey}`.
|
|
637
643
|
*/
|
|
638
644
|
readinessProfile: SystemInterfaceReadinessProfileSchema.optional(),
|
|
639
645
|
/**
|
|
@@ -664,9 +670,6 @@ function registerReadinessProfile(profileId) {
|
|
|
664
670
|
_profileRegistry.set(profileId, entry);
|
|
665
671
|
return entry;
|
|
666
672
|
}
|
|
667
|
-
function profileForInterface(systemPath, interfaceKey, readinessProfile) {
|
|
668
|
-
return readinessProfile ?? `${systemPath}.${interfaceKey}`;
|
|
669
|
-
}
|
|
670
673
|
function isBuiltInReadinessProfile(profileId) {
|
|
671
674
|
return _profileRegistry.get(profileId)?.kind === "built-in";
|
|
672
675
|
}
|
|
@@ -1130,6 +1133,7 @@ function appliesToEntityKind(catalog) {
|
|
|
1130
1133
|
if (id === "deal") return void 0;
|
|
1131
1134
|
return void 0;
|
|
1132
1135
|
}
|
|
1136
|
+
formatOntologyId({ scope: "sales.crm", kind: "catalog", localId: "crm.pipeline" });
|
|
1133
1137
|
function getLeadGenStageCatalog(model) {
|
|
1134
1138
|
const results = {};
|
|
1135
1139
|
for (const catalog of catalogRecords(model).filter(
|
|
@@ -1214,106 +1218,450 @@ var ProspectingBuildTemplateSchema = DisplayMetadataSchema.extend({
|
|
|
1214
1218
|
steps: z.array(ProspectingBuildTemplateStepSchema).min(1)
|
|
1215
1219
|
});
|
|
1216
1220
|
|
|
1217
|
-
// src/
|
|
1218
|
-
var
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1221
|
+
// ../core/src/organization-model/readiness/profile-registry.ts
|
|
1222
|
+
var _builtInProfileValidators = /* @__PURE__ */ new Map();
|
|
1223
|
+
function registerBuiltInReadinessProfile(profileId, registration) {
|
|
1224
|
+
_builtInProfileValidators.set(profileId, registration);
|
|
1225
|
+
}
|
|
1226
|
+
function getBuiltInReadinessProfile(profileId) {
|
|
1227
|
+
return _builtInProfileValidators.get(profileId);
|
|
1228
|
+
}
|
|
1229
|
+
var _interfaceMarkerResolvers = /* @__PURE__ */ new Map();
|
|
1230
|
+
function interfaceMarkerKey(systemPath, interfaceKey) {
|
|
1231
|
+
return `${systemPath}::${interfaceKey}`;
|
|
1232
|
+
}
|
|
1233
|
+
function registerReadinessInterfaceMarker(systemPath, interfaceKey, resolver) {
|
|
1234
|
+
_interfaceMarkerResolvers.set(interfaceMarkerKey(systemPath, interfaceKey), resolver);
|
|
1235
|
+
}
|
|
1236
|
+
function resolveReadinessInterfaceMarker(model, systemPath, interfaceKey) {
|
|
1237
|
+
return _interfaceMarkerResolvers.get(interfaceMarkerKey(systemPath, interfaceKey))?.(model);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
// ../core/src/organization-model/readiness/engine.ts
|
|
1241
|
+
var SystemInterfaceReadinessError = class extends Error {
|
|
1242
|
+
code;
|
|
1243
|
+
statusCode = 503;
|
|
1244
|
+
systemPath;
|
|
1245
|
+
interfaceKey;
|
|
1246
|
+
readinessProfile;
|
|
1247
|
+
issues;
|
|
1248
|
+
constructor(result) {
|
|
1249
|
+
const firstIssue = result.issues[0];
|
|
1250
|
+
super(formatInterfaceReadinessFailure(result));
|
|
1251
|
+
this.name = "SystemInterfaceReadinessError";
|
|
1252
|
+
this.code = firstIssue?.family ?? "SYSTEM_INTERFACE_NOT_READY";
|
|
1253
|
+
this.systemPath = result.systemPath;
|
|
1254
|
+
this.interfaceKey = result.interfaceKey;
|
|
1255
|
+
this.readinessProfile = result.readinessProfile;
|
|
1256
|
+
this.issues = result.issues;
|
|
1224
1257
|
}
|
|
1225
1258
|
};
|
|
1226
|
-
function
|
|
1227
|
-
|
|
1259
|
+
function addReadinessIssue(issues, family, code, message, details = {}) {
|
|
1260
|
+
issues.push({
|
|
1261
|
+
family,
|
|
1262
|
+
code,
|
|
1263
|
+
message,
|
|
1264
|
+
...details
|
|
1265
|
+
});
|
|
1228
1266
|
}
|
|
1229
|
-
function
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1267
|
+
function formatInterfaceIdentity(systemPath, interfaceKey) {
|
|
1268
|
+
return `${systemPath}/${interfaceKey}`;
|
|
1269
|
+
}
|
|
1270
|
+
function readinessMarkerPath(context) {
|
|
1271
|
+
return context.interfaceKey === "api" ? `systems.${context.systemPath}.apiInterface` : void 0;
|
|
1272
|
+
}
|
|
1273
|
+
function readinessMarkerFieldPath(context, suffix) {
|
|
1274
|
+
const base = readinessMarkerPath(context);
|
|
1275
|
+
return base === void 0 ? void 0 : `${base}${suffix}`;
|
|
1276
|
+
}
|
|
1277
|
+
function formatInterfaceReadinessFailure(result) {
|
|
1278
|
+
const identity = formatInterfaceIdentity(result.systemPath, result.interfaceKey);
|
|
1279
|
+
const issueSummary = result.issues.map((issue) => `${issue.family}:${issue.code}: ${issue.message}`).join("; ");
|
|
1280
|
+
return `${identity} readiness failed${result.readinessProfile ? ` (${result.readinessProfile})` : ""}: ${issueSummary}`;
|
|
1281
|
+
}
|
|
1282
|
+
function formatSupportedReadinessProfiles() {
|
|
1283
|
+
return SYSTEM_INTERFACE_PROFILES.map((p) => `"${p.readinessProfile}"`).join(", ");
|
|
1284
|
+
}
|
|
1285
|
+
function isPlainRecord(value) {
|
|
1286
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
1287
|
+
}
|
|
1288
|
+
function getCatalogEntries(catalog) {
|
|
1289
|
+
return isPlainRecord(catalog.entries) ? catalog.entries : {};
|
|
1290
|
+
}
|
|
1291
|
+
function getActiveScopedResources(model, resourceIds, issues, context) {
|
|
1292
|
+
const resources = [];
|
|
1293
|
+
for (const [index, resourceId] of resourceIds.entries()) {
|
|
1294
|
+
const resource = model.resources?.[resourceId];
|
|
1295
|
+
const path = readinessMarkerFieldPath(context, `.resourceIds.${index}`);
|
|
1296
|
+
if (resource === void 0) {
|
|
1297
|
+
addReadinessIssue(
|
|
1298
|
+
issues,
|
|
1299
|
+
"SYSTEM_INTERFACE_NOT_READY",
|
|
1300
|
+
"missing-resource",
|
|
1301
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" scopes missing resource "${resourceId}".`,
|
|
1302
|
+
{ path, ref: resourceId }
|
|
1303
|
+
);
|
|
1304
|
+
continue;
|
|
1305
|
+
}
|
|
1306
|
+
if (resource.systemPath !== context.systemPath) {
|
|
1307
|
+
addReadinessIssue(
|
|
1308
|
+
issues,
|
|
1309
|
+
"SYSTEM_INTERFACE_INVALID",
|
|
1310
|
+
"resource-system-mismatch",
|
|
1311
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" scopes resource "${resourceId}" from system "${resource.systemPath}".`,
|
|
1312
|
+
{ path, ref: resourceId }
|
|
1313
|
+
);
|
|
1314
|
+
continue;
|
|
1315
|
+
}
|
|
1316
|
+
if (resource.status !== "active") {
|
|
1317
|
+
addReadinessIssue(
|
|
1318
|
+
issues,
|
|
1319
|
+
"SYSTEM_INTERFACE_NOT_READY",
|
|
1320
|
+
"inactive-resource",
|
|
1321
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" scopes inactive resource "${resourceId}".`,
|
|
1322
|
+
{ path, ref: resourceId }
|
|
1323
|
+
);
|
|
1324
|
+
continue;
|
|
1325
|
+
}
|
|
1326
|
+
resources.push(resource);
|
|
1327
|
+
}
|
|
1328
|
+
return resources;
|
|
1329
|
+
}
|
|
1330
|
+
function resourceBindingIds(resources, key) {
|
|
1331
|
+
return new Set(resources.flatMap((resource) => resource.ontology?.[key] ?? []));
|
|
1332
|
+
}
|
|
1333
|
+
function requireScopedBinding(issues, boundIds, bindingKey, ontologyId, context) {
|
|
1334
|
+
if (boundIds.has(ontologyId)) return;
|
|
1335
|
+
addReadinessIssue(
|
|
1336
|
+
issues,
|
|
1337
|
+
"SYSTEM_INTERFACE_NOT_READY",
|
|
1338
|
+
"missing-resource-binding",
|
|
1339
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" has no active scoped resource with ontology.${bindingKey} binding "${ontologyId}".`,
|
|
1340
|
+
{ path: readinessMarkerFieldPath(context, ".resourceIds"), ref: ontologyId }
|
|
1341
|
+
);
|
|
1342
|
+
}
|
|
1343
|
+
function ontologyOwnerMatches(ontologyId, expectedSystemPath, catalog) {
|
|
1344
|
+
if (catalog?.ownerSystemId !== void 0) return catalog.ownerSystemId === expectedSystemPath;
|
|
1345
|
+
return parseOntologyId(ontologyId).scope === expectedSystemPath;
|
|
1346
|
+
}
|
|
1347
|
+
function requireObjectReadiness(issues, index, objectId, context) {
|
|
1348
|
+
const object = index.ontology.objectTypes[objectId];
|
|
1349
|
+
if (object === void 0) {
|
|
1350
|
+
addReadinessIssue(
|
|
1351
|
+
issues,
|
|
1352
|
+
"SYSTEM_INTERFACE_NOT_READY",
|
|
1353
|
+
"missing-object",
|
|
1354
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" is missing required object type "${objectId}".`,
|
|
1355
|
+
{ ref: objectId }
|
|
1237
1356
|
);
|
|
1357
|
+
return;
|
|
1238
1358
|
}
|
|
1239
|
-
const
|
|
1240
|
-
if (
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1359
|
+
const ownerSystemId = object.ownerSystemId ?? parseOntologyId(objectId).scope;
|
|
1360
|
+
if (ownerSystemId !== context.systemPath) {
|
|
1361
|
+
addReadinessIssue(
|
|
1362
|
+
issues,
|
|
1363
|
+
"SYSTEM_INTERFACE_INVALID",
|
|
1364
|
+
"foreign-object",
|
|
1365
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires object "${objectId}" owned by "${ownerSystemId}".`,
|
|
1366
|
+
{ ref: objectId }
|
|
1245
1367
|
);
|
|
1246
1368
|
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1369
|
+
}
|
|
1370
|
+
function requireCatalogReadiness(issues, index, catalogId, context) {
|
|
1371
|
+
const catalog = index.ontology.catalogTypes[catalogId];
|
|
1372
|
+
if (catalog === void 0) {
|
|
1373
|
+
addReadinessIssue(
|
|
1374
|
+
issues,
|
|
1375
|
+
"SYSTEM_INTERFACE_NOT_READY",
|
|
1376
|
+
"missing-catalog",
|
|
1377
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" is missing required catalog "${catalogId}".`,
|
|
1378
|
+
{ ref: catalogId }
|
|
1252
1379
|
);
|
|
1380
|
+
return void 0;
|
|
1253
1381
|
}
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1382
|
+
if (context.allowForeignOwner !== true && !ontologyOwnerMatches(catalogId, context.systemPath, catalog)) {
|
|
1383
|
+
addReadinessIssue(
|
|
1384
|
+
issues,
|
|
1385
|
+
"SYSTEM_INTERFACE_INVALID",
|
|
1386
|
+
"foreign-catalog",
|
|
1387
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires catalog "${catalogId}" owned by "${catalog.ownerSystemId ?? parseOntologyId(catalogId).scope}".`,
|
|
1388
|
+
{ ref: catalogId }
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
if (Object.keys(getCatalogEntries(catalog)).length === 0) {
|
|
1392
|
+
addReadinessIssue(
|
|
1393
|
+
issues,
|
|
1394
|
+
"SYSTEM_INTERFACE_NOT_READY",
|
|
1395
|
+
"empty-catalog",
|
|
1396
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires catalog entries for "${catalogId}".`,
|
|
1397
|
+
{ ref: catalogId }
|
|
1398
|
+
);
|
|
1399
|
+
}
|
|
1400
|
+
return catalog;
|
|
1260
1401
|
}
|
|
1261
|
-
|
|
1262
|
-
const
|
|
1263
|
-
const
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
const
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
const item = items[idx];
|
|
1272
|
-
const task = process(item, idx).then((value) => {
|
|
1273
|
-
results.push({ index: idx, value });
|
|
1274
|
-
succeeded++;
|
|
1275
|
-
onSuccess?.(value, item, idx);
|
|
1276
|
-
}).catch((error) => {
|
|
1277
|
-
results.push({ index: idx, error });
|
|
1278
|
-
failed++;
|
|
1279
|
-
onError?.(error, item, idx);
|
|
1280
|
-
}).finally(() => {
|
|
1281
|
-
active.delete(task);
|
|
1282
|
-
enqueue();
|
|
1283
|
-
});
|
|
1284
|
-
active.add(task);
|
|
1285
|
-
}
|
|
1286
|
-
};
|
|
1287
|
-
enqueue();
|
|
1288
|
-
while (active.size > 0) {
|
|
1289
|
-
await Promise.race(active);
|
|
1402
|
+
function requireContractReadiness(issues, index, resources, contract, context) {
|
|
1403
|
+
const reads = resourceBindingIds(resources, "reads");
|
|
1404
|
+
const catalogs = resourceBindingIds(resources, "usesCatalogs");
|
|
1405
|
+
for (const objectId of contract.requiredObjects) {
|
|
1406
|
+
requireObjectReadiness(issues, index, objectId, context);
|
|
1407
|
+
requireScopedBinding(issues, reads, "reads", objectId, context);
|
|
1408
|
+
}
|
|
1409
|
+
for (const catalogId of contract.requiredCatalogs) {
|
|
1410
|
+
requireCatalogReadiness(issues, index, catalogId, context);
|
|
1411
|
+
requireScopedBinding(issues, catalogs, "usesCatalogs", catalogId, context);
|
|
1290
1412
|
}
|
|
1291
|
-
return { results, succeeded, failed };
|
|
1292
1413
|
}
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
});
|
|
1301
|
-
var integrationInput = z.object({
|
|
1302
|
-
credential: z.string().describe("Credential name registered for this integration")
|
|
1303
|
-
});
|
|
1304
|
-
async function runDiagnostic(tool, method, fn) {
|
|
1305
|
-
const start = Date.now();
|
|
1306
|
-
try {
|
|
1307
|
-
const result = await fn();
|
|
1308
|
-
return { success: true, tool, method, result, durationMs: Date.now() - start };
|
|
1309
|
-
} catch (error) {
|
|
1310
|
-
return { success: false, tool, method, error: String(error), durationMs: Date.now() - start };
|
|
1414
|
+
function getSystemInterfaceReadinessMarker(model, request) {
|
|
1415
|
+
const system = getSystem(model, request.systemPath);
|
|
1416
|
+
if (system === void 0) return void 0;
|
|
1417
|
+
const registeredMarker = resolveReadinessInterfaceMarker(model, request.systemPath, request.interfaceKey);
|
|
1418
|
+
if (registeredMarker !== void 0) return registeredMarker;
|
|
1419
|
+
if (request.interfaceKey === "api" && system.apiInterface !== void 0) {
|
|
1420
|
+
return system.apiInterface;
|
|
1311
1421
|
}
|
|
1422
|
+
return void 0;
|
|
1312
1423
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1424
|
+
function compileReadinessOntology(model, readinessProfile, prepareModel) {
|
|
1425
|
+
const preparedModel = prepareModel !== void 0 ? prepareModel(model) : model;
|
|
1426
|
+
const compilation = compileOrganizationOntology(preparedModel);
|
|
1427
|
+
if (compilation.diagnostics.length > 0) {
|
|
1428
|
+
const summary = compilation.diagnostics.map((diagnostic) => diagnostic.message).join("; ");
|
|
1429
|
+
throw new Error(`${readinessProfile} ontology validation index failed to compile: ${summary}`);
|
|
1430
|
+
}
|
|
1431
|
+
return { ontology: compilation.ontology };
|
|
1432
|
+
}
|
|
1433
|
+
function tryCompileReadinessOntology(model, readinessProfile, prepareModel, issues) {
|
|
1434
|
+
try {
|
|
1435
|
+
return compileReadinessOntology(model, readinessProfile, prepareModel);
|
|
1436
|
+
} catch (error) {
|
|
1437
|
+
addReadinessIssue(
|
|
1438
|
+
issues,
|
|
1439
|
+
"SYSTEM_INTERFACE_INVALID",
|
|
1440
|
+
"ontology-compile-failed",
|
|
1441
|
+
error instanceof Error ? error.message : String(error)
|
|
1442
|
+
);
|
|
1443
|
+
return void 0;
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
function computeInterfaceReadiness(model, request) {
|
|
1447
|
+
const issues = [];
|
|
1448
|
+
const system = getSystem(model, request.systemPath);
|
|
1449
|
+
const systemInterface = getSystemInterfaceReadinessMarker(model, request);
|
|
1450
|
+
const readinessProfile = systemInterface?.readinessProfile;
|
|
1451
|
+
const scopedResourceIds = systemInterface?.resourceIds ?? [];
|
|
1452
|
+
if (system === void 0) {
|
|
1453
|
+
addReadinessIssue(
|
|
1454
|
+
issues,
|
|
1455
|
+
"SYSTEM_INTERFACE_MISSING",
|
|
1456
|
+
"missing-system",
|
|
1457
|
+
`System "${request.systemPath}" is missing.`,
|
|
1458
|
+
{ ref: request.systemPath }
|
|
1459
|
+
);
|
|
1460
|
+
return {
|
|
1461
|
+
ready: false,
|
|
1462
|
+
systemPath: request.systemPath,
|
|
1463
|
+
interfaceKey: request.interfaceKey,
|
|
1464
|
+
scopedResourceIds,
|
|
1465
|
+
issues
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
if (systemInterface === void 0) {
|
|
1469
|
+
addReadinessIssue(
|
|
1470
|
+
issues,
|
|
1471
|
+
"SYSTEM_INTERFACE_MISSING",
|
|
1472
|
+
"missing-interface",
|
|
1473
|
+
`System "${request.systemPath}" does not declare interface "${request.interfaceKey}".`,
|
|
1474
|
+
{ path: readinessMarkerPath(request) }
|
|
1475
|
+
);
|
|
1476
|
+
return {
|
|
1477
|
+
ready: false,
|
|
1478
|
+
systemPath: request.systemPath,
|
|
1479
|
+
interfaceKey: request.interfaceKey,
|
|
1480
|
+
scopedResourceIds,
|
|
1481
|
+
issues
|
|
1482
|
+
};
|
|
1483
|
+
}
|
|
1484
|
+
if (systemInterface.lifecycle !== "active") {
|
|
1485
|
+
addReadinessIssue(
|
|
1486
|
+
issues,
|
|
1487
|
+
"SYSTEM_INTERFACE_DISABLED",
|
|
1488
|
+
"inactive-interface",
|
|
1489
|
+
`System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" lifecycle is "${systemInterface.lifecycle}".`,
|
|
1490
|
+
{ path: readinessMarkerFieldPath(request, ".lifecycle") }
|
|
1491
|
+
);
|
|
1492
|
+
return {
|
|
1493
|
+
ready: false,
|
|
1494
|
+
systemPath: request.systemPath,
|
|
1495
|
+
interfaceKey: request.interfaceKey,
|
|
1496
|
+
readinessProfile,
|
|
1497
|
+
scopedResourceIds,
|
|
1498
|
+
issues
|
|
1499
|
+
};
|
|
1500
|
+
}
|
|
1501
|
+
if (readinessProfile === void 0) {
|
|
1502
|
+
addReadinessIssue(
|
|
1503
|
+
issues,
|
|
1504
|
+
"SYSTEM_INTERFACE_INVALID",
|
|
1505
|
+
"missing-readiness-profile",
|
|
1506
|
+
`System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" declares an apiInterface but no readinessProfile. Declare a built-in profile (${formatSupportedReadinessProfiles()}) or a custom id paired with a readinessContract.`,
|
|
1507
|
+
{ path: readinessMarkerFieldPath(request, ".readinessProfile") }
|
|
1508
|
+
);
|
|
1509
|
+
return {
|
|
1510
|
+
ready: false,
|
|
1511
|
+
systemPath: request.systemPath,
|
|
1512
|
+
interfaceKey: request.interfaceKey,
|
|
1513
|
+
scopedResourceIds,
|
|
1514
|
+
issues
|
|
1515
|
+
};
|
|
1516
|
+
}
|
|
1517
|
+
const isBuiltIn = isBuiltInReadinessProfile(readinessProfile);
|
|
1518
|
+
const readinessContract = systemInterface.readinessContract;
|
|
1519
|
+
if (!isBuiltIn && readinessContract === void 0) {
|
|
1520
|
+
addReadinessIssue(
|
|
1521
|
+
issues,
|
|
1522
|
+
"SYSTEM_INTERFACE_INVALID",
|
|
1523
|
+
"missing-readiness-contract",
|
|
1524
|
+
`System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" uses custom readiness profile "${readinessProfile}" but declares no readinessContract. Built-in profiles: ${formatSupportedReadinessProfiles()}.`,
|
|
1525
|
+
{ path: readinessMarkerFieldPath(request, ".readinessContract"), ref: readinessProfile }
|
|
1526
|
+
);
|
|
1527
|
+
return {
|
|
1528
|
+
ready: false,
|
|
1529
|
+
systemPath: request.systemPath,
|
|
1530
|
+
interfaceKey: request.interfaceKey,
|
|
1531
|
+
readinessProfile,
|
|
1532
|
+
scopedResourceIds,
|
|
1533
|
+
issues
|
|
1534
|
+
};
|
|
1535
|
+
}
|
|
1536
|
+
if (scopedResourceIds.length === 0) {
|
|
1537
|
+
addReadinessIssue(
|
|
1538
|
+
issues,
|
|
1539
|
+
"SYSTEM_INTERFACE_NOT_READY",
|
|
1540
|
+
"missing-scoped-resources",
|
|
1541
|
+
`System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" must scope at least one active resource.`,
|
|
1542
|
+
{ path: readinessMarkerFieldPath(request, ".resourceIds") }
|
|
1543
|
+
);
|
|
1544
|
+
}
|
|
1545
|
+
const resources = getActiveScopedResources(model, scopedResourceIds, issues, request);
|
|
1546
|
+
const registration = getBuiltInReadinessProfile(readinessProfile);
|
|
1547
|
+
const index = tryCompileReadinessOntology(model, readinessProfile, registration?.prepareModel, issues);
|
|
1548
|
+
if (index !== void 0) {
|
|
1549
|
+
if (registration !== void 0) {
|
|
1550
|
+
registration.validate(issues, index, resources, model, request);
|
|
1551
|
+
} else if (readinessContract !== void 0) {
|
|
1552
|
+
requireContractReadiness(issues, index, resources, readinessContract, request);
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
return {
|
|
1556
|
+
ready: issues.length === 0,
|
|
1557
|
+
systemPath: request.systemPath,
|
|
1558
|
+
interfaceKey: request.interfaceKey,
|
|
1559
|
+
readinessProfile,
|
|
1560
|
+
scopedResourceIds,
|
|
1561
|
+
issues
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
// src/contract-ref.ts
|
|
1566
|
+
var ContractRefResolutionError = class extends Error {
|
|
1567
|
+
constructor(code, message, ref) {
|
|
1568
|
+
super(message);
|
|
1569
|
+
this.code = code;
|
|
1570
|
+
this.ref = ref;
|
|
1571
|
+
this.name = "ContractRefResolutionError";
|
|
1572
|
+
}
|
|
1573
|
+
};
|
|
1574
|
+
function isZodType(value) {
|
|
1575
|
+
return typeof value === "object" && value !== null && "_def" in value;
|
|
1576
|
+
}
|
|
1577
|
+
function resolveContractRef(ref, registry) {
|
|
1578
|
+
const parsed = parseContractRef(ref);
|
|
1579
|
+
const moduleNamespace = registry[parsed.moduleSpecifier];
|
|
1580
|
+
if (moduleNamespace === void 0) {
|
|
1581
|
+
throw new ContractRefResolutionError(
|
|
1582
|
+
"contract-ref-unknown-module",
|
|
1583
|
+
`ContractRef "${ref}" references unknown module "${parsed.moduleSpecifier}".`,
|
|
1584
|
+
ref
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1587
|
+
const exportValue = moduleNamespace[parsed.exportName];
|
|
1588
|
+
if (exportValue === void 0) {
|
|
1589
|
+
throw new ContractRefResolutionError(
|
|
1590
|
+
"contract-ref-unknown-export",
|
|
1591
|
+
`ContractRef "${ref}" references unknown export "${parsed.exportName}".`,
|
|
1592
|
+
ref
|
|
1593
|
+
);
|
|
1594
|
+
}
|
|
1595
|
+
if (!isZodType(exportValue)) {
|
|
1596
|
+
throw new ContractRefResolutionError(
|
|
1597
|
+
"contract-ref-not-zod-type",
|
|
1598
|
+
`ContractRef "${ref}" resolves to "${parsed.exportName}" but it is not a ZodType.`,
|
|
1599
|
+
ref
|
|
1600
|
+
);
|
|
1601
|
+
}
|
|
1602
|
+
return {
|
|
1603
|
+
ref,
|
|
1604
|
+
moduleSpecifier: parsed.moduleSpecifier,
|
|
1605
|
+
exportName: parsed.exportName,
|
|
1606
|
+
value: exportValue
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
async function concurrentPool(opts) {
|
|
1610
|
+
const { items, concurrency, process, onSuccess, onError } = opts;
|
|
1611
|
+
const results = [];
|
|
1612
|
+
let nextIndex = 0;
|
|
1613
|
+
let succeeded = 0;
|
|
1614
|
+
let failed = 0;
|
|
1615
|
+
const active = /* @__PURE__ */ new Set();
|
|
1616
|
+
const enqueue = () => {
|
|
1617
|
+
while (active.size < concurrency && nextIndex < items.length) {
|
|
1618
|
+
const idx = nextIndex++;
|
|
1619
|
+
const item = items[idx];
|
|
1620
|
+
const task = process(item, idx).then((value) => {
|
|
1621
|
+
results.push({ index: idx, value });
|
|
1622
|
+
succeeded++;
|
|
1623
|
+
onSuccess?.(value, item, idx);
|
|
1624
|
+
}).catch((error) => {
|
|
1625
|
+
results.push({ index: idx, error });
|
|
1626
|
+
failed++;
|
|
1627
|
+
onError?.(error, item, idx);
|
|
1628
|
+
}).finally(() => {
|
|
1629
|
+
active.delete(task);
|
|
1630
|
+
enqueue();
|
|
1631
|
+
});
|
|
1632
|
+
active.add(task);
|
|
1633
|
+
}
|
|
1634
|
+
};
|
|
1635
|
+
enqueue();
|
|
1636
|
+
while (active.size > 0) {
|
|
1637
|
+
await Promise.race(active);
|
|
1638
|
+
}
|
|
1639
|
+
return { results, succeeded, failed };
|
|
1640
|
+
}
|
|
1641
|
+
var diagnosticOutput = z.object({
|
|
1642
|
+
success: z.boolean(),
|
|
1643
|
+
tool: z.string(),
|
|
1644
|
+
method: z.string(),
|
|
1645
|
+
result: z.unknown().optional(),
|
|
1646
|
+
error: z.string().optional(),
|
|
1647
|
+
durationMs: z.number().optional()
|
|
1648
|
+
});
|
|
1649
|
+
var integrationInput = z.object({
|
|
1650
|
+
credential: z.string().describe("Credential name registered for this integration")
|
|
1651
|
+
});
|
|
1652
|
+
async function runDiagnostic(tool, method, fn) {
|
|
1653
|
+
const start = Date.now();
|
|
1654
|
+
try {
|
|
1655
|
+
const result = await fn();
|
|
1656
|
+
return { success: true, tool, method, result, durationMs: Date.now() - start };
|
|
1657
|
+
} catch (error) {
|
|
1658
|
+
return { success: false, tool, method, error: String(error), durationMs: Date.now() - start };
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
var NAME_PREFIXES = /^(dr\.?|prof\.?|mr\.?|mrs\.?|ms\.?|rev\.?)\s+/i;
|
|
1662
|
+
var NAME_SUFFIXES = /[,\s]+(dvm|md|phd|do|jr\.?|sr\.?|ii|iii|iv|esq\.?|rn|lvt|cvt|rvt)\.?$/i;
|
|
1663
|
+
function splitName(name) {
|
|
1664
|
+
const cleaned = name.trim().replace(NAME_PREFIXES, "").replace(NAME_SUFFIXES, "").trim();
|
|
1317
1665
|
const parts = cleaned.split(/\s+/);
|
|
1318
1666
|
return { firstName: parts[0], lastName: parts.length > 1 ? parts.slice(1).join(" ") : void 0 };
|
|
1319
1667
|
}
|
|
@@ -4021,7 +4369,7 @@ function buildIterationResponseSchemaUncached(tools, capabilities) {
|
|
|
4021
4369
|
if (capabilities.message !== "off") {
|
|
4022
4370
|
properties.message = {
|
|
4023
4371
|
type: "string",
|
|
4024
|
-
description:
|
|
4372
|
+
description: 'Your reply to the user, as plain prose. This is the ONLY field the user sees. Use an empty string only when this iteration just calls tools and you have nothing to say yet. Write real line breaks and real quotation marks -- the two characters \\n are not a line break, and \\" is not a quotation mark. Serialization is handled for you.'
|
|
4025
4373
|
};
|
|
4026
4374
|
}
|
|
4027
4375
|
properties.reasoning = { type: "string", description: "Your reasoning process" };
|
|
@@ -4041,7 +4389,15 @@ function buildIterationResponseSchemaUncached(tools, capabilities) {
|
|
|
4041
4389
|
type: "object",
|
|
4042
4390
|
properties: {
|
|
4043
4391
|
key: { type: "string" },
|
|
4044
|
-
value: {
|
|
4392
|
+
value: {
|
|
4393
|
+
type: "string",
|
|
4394
|
+
// `memoryOps` has NO framework prompt section -- a grep across `prompt-sections/`
|
|
4395
|
+
// returns zero memory references -- so this description is the only framework-owned
|
|
4396
|
+
// lever on how a memory value is written. It matters more here than in `message`:
|
|
4397
|
+
// a session-memory value is re-sent on every iteration of every subsequent turn and
|
|
4398
|
+
// never ages out, so one literal escape stored here is one the model re-reads forever.
|
|
4399
|
+
description: "Stored verbatim and replayed to you on every later turn. Write real line breaks and real quotation marks -- the two characters \\n are not a line break."
|
|
4400
|
+
}
|
|
4045
4401
|
},
|
|
4046
4402
|
required: ["key", "value"],
|
|
4047
4403
|
additionalProperties: false
|
|
@@ -4053,598 +4409,10 @@ function buildIterationResponseSchemaUncached(tools, capabilities) {
|
|
|
4053
4409
|
};
|
|
4054
4410
|
}
|
|
4055
4411
|
return {
|
|
4056
|
-
type: "object",
|
|
4057
|
-
properties,
|
|
4058
|
-
required: capabilities.message === "required" ? ["nextActions", "message", "reasoning"] : ["nextActions", "reasoning"],
|
|
4059
|
-
additionalProperties: false
|
|
4060
|
-
};
|
|
4061
|
-
}
|
|
4062
|
-
|
|
4063
|
-
// ../core/src/business/acquisition/ontology-validation.ts
|
|
4064
|
-
var LEAD_GEN_API_INTERFACE = SYSTEM_INTERFACE_PROFILES[0];
|
|
4065
|
-
var CRM_API_INTERFACE = SYSTEM_INTERFACE_PROFILES[1];
|
|
4066
|
-
var LEAD_GEN_CRM_HANDOFF_INTERFACE = SYSTEM_INTERFACE_PROFILES[2];
|
|
4067
|
-
var LEAD_GEN_API_READINESS_LABEL = LEAD_GEN_API_INTERFACE.readinessProfile;
|
|
4068
|
-
var CRM_API_READINESS_LABEL = CRM_API_INTERFACE.readinessProfile;
|
|
4069
|
-
LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile;
|
|
4070
|
-
var LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID = formatOntologyId({
|
|
4071
|
-
scope: "sales.lead-gen",
|
|
4072
|
-
kind: "object",
|
|
4073
|
-
localId: "list"
|
|
4074
|
-
});
|
|
4075
|
-
var LEAD_GEN_COMPANY_OBJECT_ONTOLOGY_ID = formatOntologyId({
|
|
4076
|
-
scope: "sales.lead-gen",
|
|
4077
|
-
kind: "object",
|
|
4078
|
-
localId: "company"
|
|
4079
|
-
});
|
|
4080
|
-
var LEAD_GEN_CONTACT_OBJECT_ONTOLOGY_ID = formatOntologyId({
|
|
4081
|
-
scope: "sales.lead-gen",
|
|
4082
|
-
kind: "object",
|
|
4083
|
-
localId: "contact"
|
|
4084
|
-
});
|
|
4085
|
-
var LEAD_GEN_BUILD_TEMPLATE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
4086
|
-
scope: "sales.lead-gen",
|
|
4087
|
-
kind: "catalog",
|
|
4088
|
-
localId: "build-template"
|
|
4089
|
-
});
|
|
4090
|
-
var LEAD_GEN_COMPANY_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
4091
|
-
scope: "sales.lead-gen",
|
|
4092
|
-
kind: "catalog",
|
|
4093
|
-
localId: "company-stage"
|
|
4094
|
-
});
|
|
4095
|
-
var LEAD_GEN_CONTACT_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
4096
|
-
scope: "sales.lead-gen",
|
|
4097
|
-
kind: "catalog",
|
|
4098
|
-
localId: "contact-stage"
|
|
4099
|
-
});
|
|
4100
|
-
var CRM_PIPELINE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
4101
|
-
scope: "sales.crm",
|
|
4102
|
-
kind: "catalog",
|
|
4103
|
-
localId: "crm.pipeline"
|
|
4104
|
-
});
|
|
4105
|
-
var LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
4106
|
-
scope: "sales.lead-gen",
|
|
4107
|
-
kind: "catalog",
|
|
4108
|
-
localId: "lead-gen.stage-catalog"
|
|
4109
|
-
});
|
|
4110
|
-
var SystemInterfaceReadinessError = class extends Error {
|
|
4111
|
-
code;
|
|
4112
|
-
statusCode = 503;
|
|
4113
|
-
systemPath;
|
|
4114
|
-
interfaceKey;
|
|
4115
|
-
readinessProfile;
|
|
4116
|
-
issues;
|
|
4117
|
-
constructor(result) {
|
|
4118
|
-
const firstIssue = result.issues[0];
|
|
4119
|
-
super(formatInterfaceReadinessFailure(result));
|
|
4120
|
-
this.name = "SystemInterfaceReadinessError";
|
|
4121
|
-
this.code = firstIssue?.family ?? "SYSTEM_INTERFACE_NOT_READY";
|
|
4122
|
-
this.systemPath = result.systemPath;
|
|
4123
|
-
this.interfaceKey = result.interfaceKey;
|
|
4124
|
-
this.readinessProfile = result.readinessProfile;
|
|
4125
|
-
this.issues = result.issues;
|
|
4126
|
-
}
|
|
4127
|
-
};
|
|
4128
|
-
function createLeadGenStageCatalog(model) {
|
|
4129
|
-
return {
|
|
4130
|
-
id: LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID,
|
|
4131
|
-
label: "Lead Gen Processing Stages",
|
|
4132
|
-
ownerSystemId: "sales.lead-gen",
|
|
4133
|
-
kind: "processing-stage-catalog",
|
|
4134
|
-
entries: Object.fromEntries(
|
|
4135
|
-
Object.entries(getLeadGenStageCatalog(model)).map(([key, entry]) => [
|
|
4136
|
-
key,
|
|
4137
|
-
{
|
|
4138
|
-
...entry
|
|
4139
|
-
}
|
|
4140
|
-
])
|
|
4141
|
-
),
|
|
4142
|
-
legacyCatalogKey: "LEAD_GEN_STAGE_CATALOG"
|
|
4143
|
-
};
|
|
4144
|
-
}
|
|
4145
|
-
function isPlainRecord(value) {
|
|
4146
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
4147
|
-
}
|
|
4148
|
-
function addReadinessIssue(issues, family, code, message, details = {}) {
|
|
4149
|
-
issues.push({
|
|
4150
|
-
family,
|
|
4151
|
-
code,
|
|
4152
|
-
message,
|
|
4153
|
-
...details
|
|
4154
|
-
});
|
|
4155
|
-
}
|
|
4156
|
-
function formatInterfaceIdentity(systemPath, interfaceKey) {
|
|
4157
|
-
return `${systemPath}/${interfaceKey}`;
|
|
4158
|
-
}
|
|
4159
|
-
function readinessMarkerPath(context) {
|
|
4160
|
-
return context.interfaceKey === "api" ? `systems.${context.systemPath}.apiInterface` : `systems.${context.systemPath}.derivedCrmHandoffReadiness`;
|
|
4161
|
-
}
|
|
4162
|
-
function formatInterfaceReadinessFailure(result) {
|
|
4163
|
-
const identity = formatInterfaceIdentity(result.systemPath, result.interfaceKey);
|
|
4164
|
-
const issueSummary = result.issues.map((issue) => `${issue.family}:${issue.code}: ${issue.message}`).join("; ");
|
|
4165
|
-
return `${identity} readiness failed${result.readinessProfile ? ` (${result.readinessProfile})` : ""}: ${issueSummary}`;
|
|
4166
|
-
}
|
|
4167
|
-
function formatSupportedReadinessProfiles() {
|
|
4168
|
-
return SYSTEM_INTERFACE_PROFILES.map((p) => `"${p.readinessProfile}"`).join(", ");
|
|
4169
|
-
}
|
|
4170
|
-
function throwIfInterfaceNotReady(result) {
|
|
4171
|
-
if (result.ready) return;
|
|
4172
|
-
throw new SystemInterfaceReadinessError(result);
|
|
4173
|
-
}
|
|
4174
|
-
function getActiveScopedResources(model, resourceIds, issues, context) {
|
|
4175
|
-
const resources = [];
|
|
4176
|
-
for (const [index, resourceId] of resourceIds.entries()) {
|
|
4177
|
-
const resource = model.resources?.[resourceId];
|
|
4178
|
-
const path = `${readinessMarkerPath(context)}.resourceIds.${index}`;
|
|
4179
|
-
if (resource === void 0) {
|
|
4180
|
-
addReadinessIssue(
|
|
4181
|
-
issues,
|
|
4182
|
-
"SYSTEM_INTERFACE_NOT_READY",
|
|
4183
|
-
"missing-resource",
|
|
4184
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" scopes missing resource "${resourceId}".`,
|
|
4185
|
-
{ path, ref: resourceId }
|
|
4186
|
-
);
|
|
4187
|
-
continue;
|
|
4188
|
-
}
|
|
4189
|
-
if (resource.systemPath !== context.systemPath) {
|
|
4190
|
-
addReadinessIssue(
|
|
4191
|
-
issues,
|
|
4192
|
-
"SYSTEM_INTERFACE_INVALID",
|
|
4193
|
-
"resource-system-mismatch",
|
|
4194
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" scopes resource "${resourceId}" from system "${resource.systemPath}".`,
|
|
4195
|
-
{ path, ref: resourceId }
|
|
4196
|
-
);
|
|
4197
|
-
continue;
|
|
4198
|
-
}
|
|
4199
|
-
if (resource.status !== "active") {
|
|
4200
|
-
addReadinessIssue(
|
|
4201
|
-
issues,
|
|
4202
|
-
"SYSTEM_INTERFACE_NOT_READY",
|
|
4203
|
-
"inactive-resource",
|
|
4204
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" scopes inactive resource "${resourceId}".`,
|
|
4205
|
-
{ path, ref: resourceId }
|
|
4206
|
-
);
|
|
4207
|
-
continue;
|
|
4208
|
-
}
|
|
4209
|
-
resources.push(resource);
|
|
4210
|
-
}
|
|
4211
|
-
return resources;
|
|
4212
|
-
}
|
|
4213
|
-
function resourceBindingIds(resources, key) {
|
|
4214
|
-
return new Set(resources.flatMap((resource) => resource.ontology?.[key] ?? []));
|
|
4215
|
-
}
|
|
4216
|
-
function requireScopedBinding(issues, boundIds, bindingKey, ontologyId, context) {
|
|
4217
|
-
if (boundIds.has(ontologyId)) return;
|
|
4218
|
-
addReadinessIssue(
|
|
4219
|
-
issues,
|
|
4220
|
-
"SYSTEM_INTERFACE_NOT_READY",
|
|
4221
|
-
"missing-resource-binding",
|
|
4222
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" has no active scoped resource with ontology.${bindingKey} binding "${ontologyId}".`,
|
|
4223
|
-
{ path: `${readinessMarkerPath(context)}.resourceIds`, ref: ontologyId }
|
|
4224
|
-
);
|
|
4225
|
-
}
|
|
4226
|
-
function ontologyOwnerMatches(ontologyId, expectedSystemPath, catalog) {
|
|
4227
|
-
if (catalog?.ownerSystemId !== void 0) return catalog.ownerSystemId === expectedSystemPath;
|
|
4228
|
-
return parseOntologyId(ontologyId).scope === expectedSystemPath;
|
|
4229
|
-
}
|
|
4230
|
-
function requireObjectReadiness(issues, index, objectId, context) {
|
|
4231
|
-
const object = index.ontology.objectTypes[objectId];
|
|
4232
|
-
if (object === void 0) {
|
|
4233
|
-
addReadinessIssue(
|
|
4234
|
-
issues,
|
|
4235
|
-
"SYSTEM_INTERFACE_NOT_READY",
|
|
4236
|
-
"missing-object",
|
|
4237
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" is missing required object type "${objectId}".`,
|
|
4238
|
-
{ ref: objectId }
|
|
4239
|
-
);
|
|
4240
|
-
return;
|
|
4241
|
-
}
|
|
4242
|
-
const ownerSystemId = object.ownerSystemId ?? parseOntologyId(objectId).scope;
|
|
4243
|
-
if (ownerSystemId !== context.systemPath) {
|
|
4244
|
-
addReadinessIssue(
|
|
4245
|
-
issues,
|
|
4246
|
-
"SYSTEM_INTERFACE_INVALID",
|
|
4247
|
-
"foreign-object",
|
|
4248
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires object "${objectId}" owned by "${ownerSystemId}".`,
|
|
4249
|
-
{ ref: objectId }
|
|
4250
|
-
);
|
|
4251
|
-
}
|
|
4252
|
-
}
|
|
4253
|
-
function requireCatalogReadiness(issues, index, catalogId, context) {
|
|
4254
|
-
const catalog = index.ontology.catalogTypes[catalogId];
|
|
4255
|
-
if (catalog === void 0) {
|
|
4256
|
-
addReadinessIssue(
|
|
4257
|
-
issues,
|
|
4258
|
-
"SYSTEM_INTERFACE_NOT_READY",
|
|
4259
|
-
"missing-catalog",
|
|
4260
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" is missing required catalog "${catalogId}".`,
|
|
4261
|
-
{ ref: catalogId }
|
|
4262
|
-
);
|
|
4263
|
-
return void 0;
|
|
4264
|
-
}
|
|
4265
|
-
if (context.allowForeignOwner !== true && !ontologyOwnerMatches(catalogId, context.systemPath, catalog)) {
|
|
4266
|
-
addReadinessIssue(
|
|
4267
|
-
issues,
|
|
4268
|
-
"SYSTEM_INTERFACE_INVALID",
|
|
4269
|
-
"foreign-catalog",
|
|
4270
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires catalog "${catalogId}" owned by "${catalog.ownerSystemId ?? parseOntologyId(catalogId).scope}".`,
|
|
4271
|
-
{ ref: catalogId }
|
|
4272
|
-
);
|
|
4273
|
-
}
|
|
4274
|
-
if (Object.keys(getCatalogEntries(catalog)).length === 0) {
|
|
4275
|
-
addReadinessIssue(
|
|
4276
|
-
issues,
|
|
4277
|
-
"SYSTEM_INTERFACE_NOT_READY",
|
|
4278
|
-
"empty-catalog",
|
|
4279
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires catalog entries for "${catalogId}".`,
|
|
4280
|
-
{ ref: catalogId }
|
|
4281
|
-
);
|
|
4282
|
-
}
|
|
4283
|
-
return catalog;
|
|
4284
|
-
}
|
|
4285
|
-
function requireLeadGenInterfaceReadiness(issues, index, resources, context) {
|
|
4286
|
-
const reads = resourceBindingIds(resources, "reads");
|
|
4287
|
-
const catalogs = resourceBindingIds(resources, "usesCatalogs");
|
|
4288
|
-
for (const objectId of [
|
|
4289
|
-
LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID,
|
|
4290
|
-
LEAD_GEN_COMPANY_OBJECT_ONTOLOGY_ID,
|
|
4291
|
-
LEAD_GEN_CONTACT_OBJECT_ONTOLOGY_ID
|
|
4292
|
-
]) {
|
|
4293
|
-
requireObjectReadiness(issues, index, objectId, context);
|
|
4294
|
-
requireScopedBinding(issues, reads, "reads", objectId, context);
|
|
4295
|
-
}
|
|
4296
|
-
for (const catalogId of [
|
|
4297
|
-
LEAD_GEN_BUILD_TEMPLATE_CATALOG_ONTOLOGY_ID,
|
|
4298
|
-
LEAD_GEN_COMPANY_STAGE_CATALOG_ONTOLOGY_ID,
|
|
4299
|
-
LEAD_GEN_CONTACT_STAGE_CATALOG_ONTOLOGY_ID
|
|
4300
|
-
]) {
|
|
4301
|
-
requireCatalogReadiness(issues, index, catalogId, context);
|
|
4302
|
-
requireScopedBinding(issues, catalogs, "usesCatalogs", catalogId, context);
|
|
4303
|
-
}
|
|
4304
|
-
const templateStepCatalog = findLeadGenTemplateStepCatalog(index);
|
|
4305
|
-
if (templateStepCatalog === void 0) {
|
|
4306
|
-
addReadinessIssue(
|
|
4307
|
-
issues,
|
|
4308
|
-
"SYSTEM_INTERFACE_NOT_READY",
|
|
4309
|
-
"missing-template-step-catalog",
|
|
4310
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" is missing a lead-gen template-step catalog.`
|
|
4311
|
-
);
|
|
4312
|
-
} else {
|
|
4313
|
-
requireCatalogReadiness(issues, index, templateStepCatalog.id, context);
|
|
4314
|
-
requireScopedBinding(issues, catalogs, "usesCatalogs", templateStepCatalog.id, context);
|
|
4315
|
-
}
|
|
4316
|
-
const leadGenStageCatalog = requireCatalogReadiness(issues, index, LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID, context);
|
|
4317
|
-
return leadGenStageCatalog;
|
|
4318
|
-
}
|
|
4319
|
-
function requireCrmInterfaceReadiness(issues, index, resources, context) {
|
|
4320
|
-
const catalogs = resourceBindingIds(resources, "usesCatalogs");
|
|
4321
|
-
const crmPipelineCatalog = requireCatalogReadiness(issues, index, CRM_PIPELINE_CATALOG_ONTOLOGY_ID, context);
|
|
4322
|
-
requireScopedBinding(issues, catalogs, "usesCatalogs", CRM_PIPELINE_CATALOG_ONTOLOGY_ID, context);
|
|
4323
|
-
return crmPipelineCatalog;
|
|
4324
|
-
}
|
|
4325
|
-
function findSystemInterfaceGrant(model, consumer, provider) {
|
|
4326
|
-
return Object.values(model.topology?.relationships ?? {}).find((relationship) => {
|
|
4327
|
-
const grant = relationship.metadata?.["systemInterfaceGrant"];
|
|
4328
|
-
if (!isPlainRecord(grant) || !isPlainRecord(grant.consumer) || !isPlainRecord(grant.provider)) return false;
|
|
4329
|
-
return grant.consumer.systemPath === consumer.systemPath && grant.consumer.interfaceKey === consumer.interfaceKey && grant.provider.systemPath === provider.systemPath && grant.provider.interfaceKey === provider.interfaceKey;
|
|
4330
|
-
});
|
|
4331
|
-
}
|
|
4332
|
-
function requireHandoffBridgeReadiness(issues, model, context) {
|
|
4333
|
-
const crmResult = computeInterfaceReadiness(model, CRM_API_INTERFACE);
|
|
4334
|
-
if (!crmResult.ready) {
|
|
4335
|
-
for (const issue of crmResult.issues) {
|
|
4336
|
-
addReadinessIssue(
|
|
4337
|
-
issues,
|
|
4338
|
-
"SYSTEM_BRIDGE_NOT_READY",
|
|
4339
|
-
issue.code,
|
|
4340
|
-
`Provider interface ${formatInterfaceIdentity(CRM_API_INTERFACE.systemPath, CRM_API_INTERFACE.interfaceKey)} is not ready: ${issue.message}`,
|
|
4341
|
-
{ path: issue.path, ref: issue.ref }
|
|
4342
|
-
);
|
|
4343
|
-
}
|
|
4344
|
-
}
|
|
4345
|
-
const bridgeGrant = findSystemInterfaceGrant(model, context, CRM_API_INTERFACE);
|
|
4346
|
-
if (bridgeGrant === void 0) {
|
|
4347
|
-
addReadinessIssue(
|
|
4348
|
-
issues,
|
|
4349
|
-
"SYSTEM_BRIDGE_NOT_READY",
|
|
4350
|
-
"missing-topology-grant",
|
|
4351
|
-
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires a scoped topology grant to "${formatInterfaceIdentity(CRM_API_INTERFACE.systemPath, CRM_API_INTERFACE.interfaceKey)}".`
|
|
4352
|
-
);
|
|
4353
|
-
}
|
|
4354
|
-
return bridgeGrant;
|
|
4355
|
-
}
|
|
4356
|
-
function getLeadGenCrmHandoffResourceIds(model) {
|
|
4357
|
-
return Object.values(model.resources ?? {}).filter(
|
|
4358
|
-
(resource) => resource.systemPath === LEAD_GEN_CRM_HANDOFF_INTERFACE.systemPath && resource.ontology?.usesCatalogs?.includes(CRM_PIPELINE_CATALOG_ONTOLOGY_ID) === true
|
|
4359
|
-
).map((resource) => resource.id);
|
|
4360
|
-
}
|
|
4361
|
-
function getSystemInterfaceReadinessMarker(model, request) {
|
|
4362
|
-
const system = getSystem(model, request.systemPath);
|
|
4363
|
-
if (system === void 0) return void 0;
|
|
4364
|
-
if (request.systemPath === LEAD_GEN_CRM_HANDOFF_INTERFACE.systemPath && request.interfaceKey === LEAD_GEN_CRM_HANDOFF_INTERFACE.interfaceKey) {
|
|
4365
|
-
return {
|
|
4366
|
-
lifecycle: "active",
|
|
4367
|
-
readinessProfile: LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile,
|
|
4368
|
-
resourceIds: getLeadGenCrmHandoffResourceIds(model)
|
|
4369
|
-
};
|
|
4370
|
-
}
|
|
4371
|
-
if (request.interfaceKey === "api" && system.apiInterface !== void 0) {
|
|
4372
|
-
return system.apiInterface;
|
|
4373
|
-
}
|
|
4374
|
-
return void 0;
|
|
4375
|
-
}
|
|
4376
|
-
function mergeLeadGenDerivedCatalogs(model) {
|
|
4377
|
-
const baseCatalogTypes = model.ontology?.catalogTypes ?? {};
|
|
4378
|
-
const derivedCatalogTypes = {};
|
|
4379
|
-
if (baseCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] === void 0) {
|
|
4380
|
-
derivedCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog(model);
|
|
4381
|
-
}
|
|
4382
|
-
if (Object.keys(derivedCatalogTypes).length === 0) return model;
|
|
4383
|
-
return {
|
|
4384
|
-
...model,
|
|
4385
|
-
ontology: {
|
|
4386
|
-
...model.ontology ?? {},
|
|
4387
|
-
catalogTypes: {
|
|
4388
|
-
...baseCatalogTypes,
|
|
4389
|
-
...derivedCatalogTypes
|
|
4390
|
-
}
|
|
4391
|
-
}
|
|
4392
|
-
};
|
|
4393
|
-
}
|
|
4394
|
-
function compileBusinessOntology(model, contractId) {
|
|
4395
|
-
const compilation = compileOrganizationOntology(mergeLeadGenDerivedCatalogs(model));
|
|
4396
|
-
if (compilation.diagnostics.length > 0) {
|
|
4397
|
-
const summary = compilation.diagnostics.map((diagnostic) => diagnostic.message).join("; ");
|
|
4398
|
-
throw new Error(`${contractId} ontology validation index failed to compile: ${summary}`);
|
|
4399
|
-
}
|
|
4400
|
-
return {
|
|
4401
|
-
ontology: compilation.ontology,
|
|
4402
|
-
actionTypesByLegacyId: indexActionTypesByLegacyId(compilation.ontology.actionTypes)
|
|
4403
|
-
};
|
|
4404
|
-
}
|
|
4405
|
-
function tryCompileBusinessOntology(model, readinessProfile, issues) {
|
|
4406
|
-
try {
|
|
4407
|
-
return compileBusinessOntology(model, readinessProfile);
|
|
4408
|
-
} catch (error) {
|
|
4409
|
-
addReadinessIssue(
|
|
4410
|
-
issues,
|
|
4411
|
-
"SYSTEM_INTERFACE_INVALID",
|
|
4412
|
-
"ontology-compile-failed",
|
|
4413
|
-
error instanceof Error ? error.message : String(error)
|
|
4414
|
-
);
|
|
4415
|
-
return void 0;
|
|
4416
|
-
}
|
|
4417
|
-
}
|
|
4418
|
-
function requireContractReadiness(issues, index, resources, contract, context) {
|
|
4419
|
-
const reads = resourceBindingIds(resources, "reads");
|
|
4420
|
-
const catalogs = resourceBindingIds(resources, "usesCatalogs");
|
|
4421
|
-
for (const objectId of contract.requiredObjects) {
|
|
4422
|
-
requireObjectReadiness(issues, index, objectId, context);
|
|
4423
|
-
requireScopedBinding(issues, reads, "reads", objectId, context);
|
|
4424
|
-
}
|
|
4425
|
-
for (const catalogId of contract.requiredCatalogs) {
|
|
4426
|
-
requireCatalogReadiness(issues, index, catalogId, context);
|
|
4427
|
-
requireScopedBinding(issues, catalogs, "usesCatalogs", catalogId, context);
|
|
4428
|
-
}
|
|
4429
|
-
}
|
|
4430
|
-
function computeInterfaceReadiness(model, request) {
|
|
4431
|
-
const issues = [];
|
|
4432
|
-
const system = getSystem(model, request.systemPath);
|
|
4433
|
-
const systemInterface = getSystemInterfaceReadinessMarker(model, request);
|
|
4434
|
-
const readinessProfile = systemInterface === void 0 ? void 0 : profileForInterface(request.systemPath, request.interfaceKey, systemInterface.readinessProfile);
|
|
4435
|
-
const scopedResourceIds = systemInterface?.resourceIds ?? [];
|
|
4436
|
-
if (system === void 0) {
|
|
4437
|
-
addReadinessIssue(
|
|
4438
|
-
issues,
|
|
4439
|
-
"SYSTEM_INTERFACE_MISSING",
|
|
4440
|
-
"missing-system",
|
|
4441
|
-
`System "${request.systemPath}" is missing.`,
|
|
4442
|
-
{ ref: request.systemPath }
|
|
4443
|
-
);
|
|
4444
|
-
return {
|
|
4445
|
-
ready: false,
|
|
4446
|
-
systemPath: request.systemPath,
|
|
4447
|
-
interfaceKey: request.interfaceKey,
|
|
4448
|
-
scopedResourceIds,
|
|
4449
|
-
issues
|
|
4450
|
-
};
|
|
4451
|
-
}
|
|
4452
|
-
if (systemInterface === void 0) {
|
|
4453
|
-
addReadinessIssue(
|
|
4454
|
-
issues,
|
|
4455
|
-
"SYSTEM_INTERFACE_MISSING",
|
|
4456
|
-
"missing-interface",
|
|
4457
|
-
`System "${request.systemPath}" does not declare interface "${request.interfaceKey}".`,
|
|
4458
|
-
{ path: readinessMarkerPath(request) }
|
|
4459
|
-
);
|
|
4460
|
-
return {
|
|
4461
|
-
ready: false,
|
|
4462
|
-
systemPath: request.systemPath,
|
|
4463
|
-
interfaceKey: request.interfaceKey,
|
|
4464
|
-
scopedResourceIds,
|
|
4465
|
-
issues
|
|
4466
|
-
};
|
|
4467
|
-
}
|
|
4468
|
-
if (systemInterface.lifecycle !== "active") {
|
|
4469
|
-
addReadinessIssue(
|
|
4470
|
-
issues,
|
|
4471
|
-
"SYSTEM_INTERFACE_DISABLED",
|
|
4472
|
-
"inactive-interface",
|
|
4473
|
-
`System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" lifecycle is "${systemInterface.lifecycle}".`,
|
|
4474
|
-
{ path: `${readinessMarkerPath(request)}.lifecycle` }
|
|
4475
|
-
);
|
|
4476
|
-
}
|
|
4477
|
-
const checkedReadinessProfile = readinessProfile ?? profileForInterface(request.systemPath, request.interfaceKey);
|
|
4478
|
-
const isBuiltIn = isBuiltInReadinessProfile(checkedReadinessProfile);
|
|
4479
|
-
const readinessContract = systemInterface.readinessContract;
|
|
4480
|
-
if (!isBuiltIn && readinessContract === void 0) {
|
|
4481
|
-
addReadinessIssue(
|
|
4482
|
-
issues,
|
|
4483
|
-
"SYSTEM_INTERFACE_INVALID",
|
|
4484
|
-
"missing-readiness-contract",
|
|
4485
|
-
`System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" uses custom readiness profile "${checkedReadinessProfile}" but declares no readinessContract. Built-in profiles: ${formatSupportedReadinessProfiles()}.`,
|
|
4486
|
-
{ path: `${readinessMarkerPath(request)}.readinessContract`, ref: checkedReadinessProfile }
|
|
4487
|
-
);
|
|
4488
|
-
return {
|
|
4489
|
-
ready: false,
|
|
4490
|
-
systemPath: request.systemPath,
|
|
4491
|
-
interfaceKey: request.interfaceKey,
|
|
4492
|
-
readinessProfile: checkedReadinessProfile,
|
|
4493
|
-
scopedResourceIds,
|
|
4494
|
-
issues
|
|
4495
|
-
};
|
|
4496
|
-
}
|
|
4497
|
-
if (scopedResourceIds.length === 0) {
|
|
4498
|
-
addReadinessIssue(
|
|
4499
|
-
issues,
|
|
4500
|
-
"SYSTEM_INTERFACE_NOT_READY",
|
|
4501
|
-
"missing-scoped-resources",
|
|
4502
|
-
`System Interface "${formatInterfaceIdentity(request.systemPath, request.interfaceKey)}" must scope at least one active resource.`,
|
|
4503
|
-
{ path: `${readinessMarkerPath(request)}.resourceIds` }
|
|
4504
|
-
);
|
|
4505
|
-
}
|
|
4506
|
-
const resources = getActiveScopedResources(model, scopedResourceIds, issues, request);
|
|
4507
|
-
const index = tryCompileBusinessOntology(model, checkedReadinessProfile, issues);
|
|
4508
|
-
if (index !== void 0) {
|
|
4509
|
-
if (checkedReadinessProfile === LEAD_GEN_API_INTERFACE.readinessProfile) {
|
|
4510
|
-
requireLeadGenInterfaceReadiness(issues, index, resources, request);
|
|
4511
|
-
} else if (checkedReadinessProfile === CRM_API_INTERFACE.readinessProfile) {
|
|
4512
|
-
requireCrmInterfaceReadiness(issues, index, resources, request);
|
|
4513
|
-
} else if (checkedReadinessProfile === LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile) {
|
|
4514
|
-
requireLeadGenInterfaceReadiness(issues, index, resources, request);
|
|
4515
|
-
requireCrmInterfaceReadiness(issues, index, resources, { ...request, allowForeignOwner: true });
|
|
4516
|
-
requireHandoffBridgeReadiness(issues, model, request);
|
|
4517
|
-
} else if (readinessContract !== void 0) {
|
|
4518
|
-
requireContractReadiness(issues, index, resources, readinessContract, request);
|
|
4519
|
-
}
|
|
4520
|
-
}
|
|
4521
|
-
return {
|
|
4522
|
-
ready: issues.length === 0,
|
|
4523
|
-
systemPath: request.systemPath,
|
|
4524
|
-
interfaceKey: request.interfaceKey,
|
|
4525
|
-
readinessProfile: checkedReadinessProfile,
|
|
4526
|
-
scopedResourceIds,
|
|
4527
|
-
issues
|
|
4528
|
-
};
|
|
4529
|
-
}
|
|
4530
|
-
function requireObjectType(index, objectId, contractId) {
|
|
4531
|
-
if (index.ontology.objectTypes[objectId] === void 0) {
|
|
4532
|
-
throw new Error(`${contractId} is missing required object type: ${objectId}`);
|
|
4533
|
-
}
|
|
4534
|
-
}
|
|
4535
|
-
function requireCatalog(index, catalogId, contractId) {
|
|
4536
|
-
const catalog = index.ontology.catalogTypes[catalogId];
|
|
4537
|
-
if (catalog === void 0) {
|
|
4538
|
-
throw new Error(`${contractId} is missing required catalog: ${catalogId}`);
|
|
4539
|
-
}
|
|
4540
|
-
return catalog;
|
|
4541
|
-
}
|
|
4542
|
-
function requireCatalogEntries(catalog, contractId) {
|
|
4543
|
-
if (Object.keys(getCatalogEntries(catalog)).length === 0) {
|
|
4544
|
-
throw new Error(`${contractId} requires catalog entries for ${catalog.id}`);
|
|
4545
|
-
}
|
|
4546
|
-
}
|
|
4547
|
-
function findLeadGenTemplateStepCatalog(index) {
|
|
4548
|
-
return Object.values(index.ontology.catalogTypes).find(
|
|
4549
|
-
(catalog) => catalog.ownerSystemId === "sales.lead-gen" && catalog.kind === "template-step" && catalog.appliesTo === LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID
|
|
4550
|
-
);
|
|
4551
|
-
}
|
|
4552
|
-
function requireLeadGenApiReadiness(index) {
|
|
4553
|
-
requireObjectType(index, LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL);
|
|
4554
|
-
requireObjectType(index, LEAD_GEN_COMPANY_OBJECT_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL);
|
|
4555
|
-
requireObjectType(index, LEAD_GEN_CONTACT_OBJECT_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL);
|
|
4556
|
-
requireCatalogEntries(
|
|
4557
|
-
requireCatalog(index, LEAD_GEN_BUILD_TEMPLATE_CATALOG_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL),
|
|
4558
|
-
LEAD_GEN_API_READINESS_LABEL
|
|
4559
|
-
);
|
|
4560
|
-
requireCatalogEntries(
|
|
4561
|
-
requireCatalog(index, LEAD_GEN_COMPANY_STAGE_CATALOG_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL),
|
|
4562
|
-
LEAD_GEN_API_READINESS_LABEL
|
|
4563
|
-
);
|
|
4564
|
-
requireCatalogEntries(
|
|
4565
|
-
requireCatalog(index, LEAD_GEN_CONTACT_STAGE_CATALOG_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL),
|
|
4566
|
-
LEAD_GEN_API_READINESS_LABEL
|
|
4567
|
-
);
|
|
4568
|
-
const templateStepCatalog = findLeadGenTemplateStepCatalog(index);
|
|
4569
|
-
if (templateStepCatalog === void 0) {
|
|
4570
|
-
throw new Error(`${LEAD_GEN_API_READINESS_LABEL} is missing a lead-gen template-step catalog`);
|
|
4571
|
-
}
|
|
4572
|
-
requireCatalogEntries(templateStepCatalog, LEAD_GEN_API_READINESS_LABEL);
|
|
4573
|
-
const leadGenStageCatalog = requireCatalog(index, LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID, LEAD_GEN_API_READINESS_LABEL);
|
|
4574
|
-
requireCatalogEntries(leadGenStageCatalog, LEAD_GEN_API_READINESS_LABEL);
|
|
4575
|
-
return leadGenStageCatalog;
|
|
4576
|
-
}
|
|
4577
|
-
function requireCrmApiReadiness(index) {
|
|
4578
|
-
const crmPipelineCatalog = requireCatalog(index, CRM_PIPELINE_CATALOG_ONTOLOGY_ID, CRM_API_READINESS_LABEL);
|
|
4579
|
-
requireCatalogEntries(crmPipelineCatalog, CRM_API_READINESS_LABEL);
|
|
4580
|
-
return crmPipelineCatalog;
|
|
4581
|
-
}
|
|
4582
|
-
function compileBusinessOntologyValidationIndex(model) {
|
|
4583
|
-
throwIfInterfaceNotReady(computeInterfaceReadiness(model, LEAD_GEN_API_INTERFACE));
|
|
4584
|
-
throwIfInterfaceNotReady(computeInterfaceReadiness(model, CRM_API_INTERFACE));
|
|
4585
|
-
const index = compileBusinessOntology(model, "legacy acquisition business ontology");
|
|
4586
|
-
return {
|
|
4587
|
-
...index,
|
|
4588
|
-
leadGenStageCatalog: requireLeadGenApiReadiness(index),
|
|
4589
|
-
crmPipelineCatalog: requireCrmApiReadiness(index)
|
|
4590
|
-
};
|
|
4591
|
-
}
|
|
4592
|
-
function indexActionTypesByLegacyId(actionTypes) {
|
|
4593
|
-
const byLegacyId = {};
|
|
4594
|
-
for (const actionType of Object.values(actionTypes)) {
|
|
4595
|
-
const legacyActionId = actionType["legacyActionId"];
|
|
4596
|
-
if (typeof legacyActionId === "string") {
|
|
4597
|
-
byLegacyId[legacyActionId] = actionType;
|
|
4598
|
-
}
|
|
4599
|
-
}
|
|
4600
|
-
return byLegacyId;
|
|
4601
|
-
}
|
|
4602
|
-
function getCatalogEntries(catalog) {
|
|
4603
|
-
return isPlainRecord(catalog.entries) ? catalog.entries : {};
|
|
4604
|
-
}
|
|
4605
|
-
function asLeadGenStageEntry(key, value) {
|
|
4606
|
-
const record = isPlainRecord(value) ? value : {};
|
|
4607
|
-
const entity = record.entity === "contact" ? "contact" : "company";
|
|
4608
|
-
const additionalEntities = Array.isArray(record.additionalEntities) ? record.additionalEntities.filter(
|
|
4609
|
-
(item) => item === "company" || item === "contact"
|
|
4610
|
-
) : void 0;
|
|
4611
|
-
const recordEntity = record.recordEntity === "company" || record.recordEntity === "contact" ? record.recordEntity : void 0;
|
|
4612
|
-
const recordStageKey = typeof record.recordStageKey === "string" ? record.recordStageKey : void 0;
|
|
4613
|
-
return {
|
|
4614
|
-
key: typeof record.key === "string" ? record.key : key,
|
|
4615
|
-
label: typeof record.label === "string" ? record.label : key,
|
|
4616
|
-
description: typeof record.description === "string" ? record.description : "",
|
|
4617
|
-
order: typeof record.order === "number" ? record.order : 0,
|
|
4618
|
-
entity,
|
|
4619
|
-
...additionalEntities !== void 0 ? { additionalEntities } : {},
|
|
4620
|
-
...recordEntity !== void 0 ? { recordEntity } : {},
|
|
4621
|
-
...recordStageKey !== void 0 ? { recordStageKey } : {}
|
|
4622
|
-
};
|
|
4623
|
-
}
|
|
4624
|
-
function createLeadGenStageValidators(index) {
|
|
4625
|
-
const getCatalog = () => Object.fromEntries(
|
|
4626
|
-
Object.entries(getCatalogEntries(index.leadGenStageCatalog)).map(([key, value]) => [
|
|
4627
|
-
key,
|
|
4628
|
-
asLeadGenStageEntry(key, value)
|
|
4629
|
-
])
|
|
4630
|
-
);
|
|
4631
|
-
const getEntry = (stageKey) => getCatalog()[stageKey];
|
|
4632
|
-
return {
|
|
4633
|
-
getLeadGenStageCatalog: getCatalog,
|
|
4634
|
-
getLeadGenStageEntry: getEntry,
|
|
4635
|
-
isLeadGenStageKey: (stageKey) => getEntry(stageKey) !== void 0,
|
|
4636
|
-
isLeadGenStageValidForEntity: (stageKey, entity) => {
|
|
4637
|
-
const stage = getEntry(stageKey);
|
|
4638
|
-
return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true);
|
|
4639
|
-
},
|
|
4640
|
-
isLeadGenRecordStageValidForEntity: (stageKey, entity) => {
|
|
4641
|
-
const stage = getEntry(stageKey);
|
|
4642
|
-
return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true || stage.recordEntity === entity);
|
|
4643
|
-
},
|
|
4644
|
-
resolveLeadGenRecordStageKey: (stageKey, entity) => {
|
|
4645
|
-
const stage = getEntry(stageKey);
|
|
4646
|
-
return stage?.recordEntity === entity && stage.recordStageKey ? stage.recordStageKey : stageKey;
|
|
4647
|
-
}
|
|
4412
|
+
type: "object",
|
|
4413
|
+
properties,
|
|
4414
|
+
required: capabilities.message === "required" ? ["nextActions", "message", "reasoning"] : ["nextActions", "reasoning"],
|
|
4415
|
+
additionalProperties: false
|
|
4648
4416
|
};
|
|
4649
4417
|
}
|
|
4650
4418
|
|
|
@@ -5015,7 +4783,6 @@ function validateDeclaredSystemInterfaceReadiness(orgName, organizationModel) {
|
|
|
5015
4783
|
message: `System Interface "${path}/${interfaceKey}" references unknown readiness profile "${readinessProfile}".`
|
|
5016
4784
|
});
|
|
5017
4785
|
}
|
|
5018
|
-
continue;
|
|
5019
4786
|
}
|
|
5020
4787
|
const result = computeInterfaceReadiness(model, { systemPath: path, interfaceKey });
|
|
5021
4788
|
for (const issue of result.issues) {
|
|
@@ -7372,6 +7139,297 @@ function deriveActions(deal, actions = []) {
|
|
|
7372
7139
|
return actions.filter((a) => a.isAvailableFor(deal)).map(({ key, label, payloadSchema }) => ({ key, label, payloadSchema }));
|
|
7373
7140
|
}
|
|
7374
7141
|
|
|
7142
|
+
// ../core/src/business/acquisition/ontology-validation.ts
|
|
7143
|
+
var LEAD_GEN_API_INTERFACE = SYSTEM_INTERFACE_PROFILES[0];
|
|
7144
|
+
var CRM_API_INTERFACE = SYSTEM_INTERFACE_PROFILES[1];
|
|
7145
|
+
var LEAD_GEN_CRM_HANDOFF_INTERFACE = SYSTEM_INTERFACE_PROFILES[2];
|
|
7146
|
+
LEAD_GEN_API_INTERFACE.readinessProfile;
|
|
7147
|
+
CRM_API_INTERFACE.readinessProfile;
|
|
7148
|
+
LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile;
|
|
7149
|
+
var LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID = formatOntologyId({
|
|
7150
|
+
scope: "sales.lead-gen",
|
|
7151
|
+
kind: "object",
|
|
7152
|
+
localId: "list"
|
|
7153
|
+
});
|
|
7154
|
+
var LEAD_GEN_COMPANY_OBJECT_ONTOLOGY_ID = formatOntologyId({
|
|
7155
|
+
scope: "sales.lead-gen",
|
|
7156
|
+
kind: "object",
|
|
7157
|
+
localId: "company"
|
|
7158
|
+
});
|
|
7159
|
+
var LEAD_GEN_CONTACT_OBJECT_ONTOLOGY_ID = formatOntologyId({
|
|
7160
|
+
scope: "sales.lead-gen",
|
|
7161
|
+
kind: "object",
|
|
7162
|
+
localId: "contact"
|
|
7163
|
+
});
|
|
7164
|
+
var LEAD_GEN_BUILD_TEMPLATE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
7165
|
+
scope: "sales.lead-gen",
|
|
7166
|
+
kind: "catalog",
|
|
7167
|
+
localId: "build-template"
|
|
7168
|
+
});
|
|
7169
|
+
var LEAD_GEN_COMPANY_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
7170
|
+
scope: "sales.lead-gen",
|
|
7171
|
+
kind: "catalog",
|
|
7172
|
+
localId: "company-stage"
|
|
7173
|
+
});
|
|
7174
|
+
var LEAD_GEN_CONTACT_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
7175
|
+
scope: "sales.lead-gen",
|
|
7176
|
+
kind: "catalog",
|
|
7177
|
+
localId: "contact-stage"
|
|
7178
|
+
});
|
|
7179
|
+
var CRM_PIPELINE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
7180
|
+
scope: "sales.crm",
|
|
7181
|
+
kind: "catalog",
|
|
7182
|
+
localId: "crm.pipeline"
|
|
7183
|
+
});
|
|
7184
|
+
var LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID = formatOntologyId({
|
|
7185
|
+
scope: "sales.lead-gen",
|
|
7186
|
+
kind: "catalog",
|
|
7187
|
+
localId: "lead-gen.stage-catalog"
|
|
7188
|
+
});
|
|
7189
|
+
var LEAD_GEN_API_READINESS_CONTRACT = {
|
|
7190
|
+
requiredObjects: [
|
|
7191
|
+
LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID,
|
|
7192
|
+
LEAD_GEN_COMPANY_OBJECT_ONTOLOGY_ID,
|
|
7193
|
+
LEAD_GEN_CONTACT_OBJECT_ONTOLOGY_ID
|
|
7194
|
+
],
|
|
7195
|
+
requiredCatalogs: [
|
|
7196
|
+
LEAD_GEN_BUILD_TEMPLATE_CATALOG_ONTOLOGY_ID,
|
|
7197
|
+
LEAD_GEN_COMPANY_STAGE_CATALOG_ONTOLOGY_ID,
|
|
7198
|
+
LEAD_GEN_CONTACT_STAGE_CATALOG_ONTOLOGY_ID
|
|
7199
|
+
]
|
|
7200
|
+
};
|
|
7201
|
+
var CRM_API_READINESS_CONTRACT = {
|
|
7202
|
+
requiredObjects: [],
|
|
7203
|
+
requiredCatalogs: [CRM_PIPELINE_CATALOG_ONTOLOGY_ID]
|
|
7204
|
+
};
|
|
7205
|
+
function isPlainRecord2(value) {
|
|
7206
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
7207
|
+
}
|
|
7208
|
+
function createLeadGenStageCatalog(model) {
|
|
7209
|
+
return {
|
|
7210
|
+
id: LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID,
|
|
7211
|
+
label: "Lead Gen Processing Stages",
|
|
7212
|
+
ownerSystemId: "sales.lead-gen",
|
|
7213
|
+
kind: "processing-stage-catalog",
|
|
7214
|
+
entries: Object.fromEntries(
|
|
7215
|
+
Object.entries(getLeadGenStageCatalog(model)).map(([key, entry]) => [
|
|
7216
|
+
key,
|
|
7217
|
+
{
|
|
7218
|
+
...entry
|
|
7219
|
+
}
|
|
7220
|
+
])
|
|
7221
|
+
),
|
|
7222
|
+
legacyCatalogKey: "LEAD_GEN_STAGE_CATALOG"
|
|
7223
|
+
};
|
|
7224
|
+
}
|
|
7225
|
+
function throwIfInterfaceNotReady(result) {
|
|
7226
|
+
if (result.ready) return;
|
|
7227
|
+
throw new SystemInterfaceReadinessError(result);
|
|
7228
|
+
}
|
|
7229
|
+
function requireLeadGenSupplementalReadiness(issues, index, resources, context) {
|
|
7230
|
+
const catalogs = resourceBindingIds(resources, "usesCatalogs");
|
|
7231
|
+
const templateStepCatalog = findLeadGenTemplateStepCatalog(index);
|
|
7232
|
+
if (templateStepCatalog === void 0) {
|
|
7233
|
+
addReadinessIssue(
|
|
7234
|
+
issues,
|
|
7235
|
+
"SYSTEM_INTERFACE_NOT_READY",
|
|
7236
|
+
"missing-template-step-catalog",
|
|
7237
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" is missing a lead-gen template-step catalog.`
|
|
7238
|
+
);
|
|
7239
|
+
} else {
|
|
7240
|
+
requireCatalogReadiness(issues, index, templateStepCatalog.id, context);
|
|
7241
|
+
requireScopedBinding(issues, catalogs, "usesCatalogs", templateStepCatalog.id, context);
|
|
7242
|
+
}
|
|
7243
|
+
requireCatalogReadiness(issues, index, LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID, context);
|
|
7244
|
+
}
|
|
7245
|
+
function requireLeadGenInterfaceReadiness(issues, index, resources, context) {
|
|
7246
|
+
requireContractReadiness(issues, index, resources, LEAD_GEN_API_READINESS_CONTRACT, context);
|
|
7247
|
+
requireLeadGenSupplementalReadiness(issues, index, resources, context);
|
|
7248
|
+
}
|
|
7249
|
+
function requireCrmInterfaceReadiness(issues, index, resources, context) {
|
|
7250
|
+
requireContractReadiness(issues, index, resources, CRM_API_READINESS_CONTRACT, context);
|
|
7251
|
+
}
|
|
7252
|
+
function findSystemInterfaceGrant(model, consumer, provider) {
|
|
7253
|
+
return Object.values(model.topology?.relationships ?? {}).find((relationship) => {
|
|
7254
|
+
const grant = relationship.metadata?.["systemInterfaceGrant"];
|
|
7255
|
+
if (!isPlainRecord2(grant) || !isPlainRecord2(grant.consumer) || !isPlainRecord2(grant.provider)) return false;
|
|
7256
|
+
return grant.consumer.systemPath === consumer.systemPath && grant.consumer.interfaceKey === consumer.interfaceKey && grant.provider.systemPath === provider.systemPath && grant.provider.interfaceKey === provider.interfaceKey;
|
|
7257
|
+
});
|
|
7258
|
+
}
|
|
7259
|
+
function requireHandoffBridgeReadiness(issues, model, context) {
|
|
7260
|
+
const crmResult = computeInterfaceReadiness(model, CRM_API_INTERFACE);
|
|
7261
|
+
if (!crmResult.ready) {
|
|
7262
|
+
for (const issue of crmResult.issues) {
|
|
7263
|
+
addReadinessIssue(
|
|
7264
|
+
issues,
|
|
7265
|
+
"SYSTEM_BRIDGE_NOT_READY",
|
|
7266
|
+
issue.code,
|
|
7267
|
+
`Provider interface ${formatInterfaceIdentity(CRM_API_INTERFACE.systemPath, CRM_API_INTERFACE.interfaceKey)} is not ready: ${issue.message}`,
|
|
7268
|
+
{ path: issue.path, ref: issue.ref }
|
|
7269
|
+
);
|
|
7270
|
+
}
|
|
7271
|
+
}
|
|
7272
|
+
const bridgeGrant = findSystemInterfaceGrant(model, context, CRM_API_INTERFACE);
|
|
7273
|
+
if (bridgeGrant === void 0) {
|
|
7274
|
+
addReadinessIssue(
|
|
7275
|
+
issues,
|
|
7276
|
+
"SYSTEM_BRIDGE_NOT_READY",
|
|
7277
|
+
"missing-topology-grant",
|
|
7278
|
+
`System Interface "${formatInterfaceIdentity(context.systemPath, context.interfaceKey)}" requires a scoped topology grant to "${formatInterfaceIdentity(CRM_API_INTERFACE.systemPath, CRM_API_INTERFACE.interfaceKey)}".`
|
|
7279
|
+
);
|
|
7280
|
+
}
|
|
7281
|
+
return bridgeGrant;
|
|
7282
|
+
}
|
|
7283
|
+
function getLeadGenCrmHandoffResourceIds(model) {
|
|
7284
|
+
return Object.values(model.resources ?? {}).filter(
|
|
7285
|
+
(resource) => resource.systemPath === LEAD_GEN_CRM_HANDOFF_INTERFACE.systemPath && resource.ontology?.usesCatalogs?.includes(CRM_PIPELINE_CATALOG_ONTOLOGY_ID) === true
|
|
7286
|
+
).map((resource) => resource.id);
|
|
7287
|
+
}
|
|
7288
|
+
function mergeLeadGenDerivedCatalogs(model) {
|
|
7289
|
+
const baseCatalogTypes = model.ontology?.catalogTypes ?? {};
|
|
7290
|
+
const derivedCatalogTypes = {};
|
|
7291
|
+
if (baseCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] === void 0) {
|
|
7292
|
+
derivedCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog(model);
|
|
7293
|
+
}
|
|
7294
|
+
if (Object.keys(derivedCatalogTypes).length === 0) return model;
|
|
7295
|
+
return {
|
|
7296
|
+
...model,
|
|
7297
|
+
ontology: {
|
|
7298
|
+
...model.ontology ?? {},
|
|
7299
|
+
catalogTypes: {
|
|
7300
|
+
...baseCatalogTypes,
|
|
7301
|
+
...derivedCatalogTypes
|
|
7302
|
+
}
|
|
7303
|
+
}
|
|
7304
|
+
};
|
|
7305
|
+
}
|
|
7306
|
+
function compileBusinessOntology(model, contractId, includeLeadGenDerivedCatalogs) {
|
|
7307
|
+
const preparedModel = mergeLeadGenDerivedCatalogs(model) ;
|
|
7308
|
+
const compilation = compileOrganizationOntology(preparedModel);
|
|
7309
|
+
if (compilation.diagnostics.length > 0) {
|
|
7310
|
+
const summary = compilation.diagnostics.map((diagnostic) => diagnostic.message).join("; ");
|
|
7311
|
+
throw new Error(`${contractId} ontology validation index failed to compile: ${summary}`);
|
|
7312
|
+
}
|
|
7313
|
+
return {
|
|
7314
|
+
ontology: compilation.ontology,
|
|
7315
|
+
actionTypesByLegacyId: indexActionTypesByLegacyId(compilation.ontology.actionTypes)
|
|
7316
|
+
};
|
|
7317
|
+
}
|
|
7318
|
+
registerBuiltInReadinessProfile(LEAD_GEN_API_INTERFACE.readinessProfile, {
|
|
7319
|
+
validate: (issues, index, resources, _model, context) => requireLeadGenInterfaceReadiness(issues, index, resources, context),
|
|
7320
|
+
prepareModel: mergeLeadGenDerivedCatalogs
|
|
7321
|
+
});
|
|
7322
|
+
registerBuiltInReadinessProfile(CRM_API_INTERFACE.readinessProfile, {
|
|
7323
|
+
validate: (issues, index, resources, _model, context) => requireCrmInterfaceReadiness(issues, index, resources, context)
|
|
7324
|
+
});
|
|
7325
|
+
registerBuiltInReadinessProfile(LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile, {
|
|
7326
|
+
validate: (issues, index, resources, model, context) => {
|
|
7327
|
+
requireLeadGenInterfaceReadiness(issues, index, resources, context);
|
|
7328
|
+
requireCrmInterfaceReadiness(issues, index, resources, { ...context, allowForeignOwner: true });
|
|
7329
|
+
requireHandoffBridgeReadiness(issues, model, context);
|
|
7330
|
+
},
|
|
7331
|
+
prepareModel: mergeLeadGenDerivedCatalogs
|
|
7332
|
+
});
|
|
7333
|
+
registerReadinessInterfaceMarker(
|
|
7334
|
+
LEAD_GEN_CRM_HANDOFF_INTERFACE.systemPath,
|
|
7335
|
+
LEAD_GEN_CRM_HANDOFF_INTERFACE.interfaceKey,
|
|
7336
|
+
(model) => ({
|
|
7337
|
+
lifecycle: "active",
|
|
7338
|
+
readinessProfile: LEAD_GEN_CRM_HANDOFF_INTERFACE.readinessProfile,
|
|
7339
|
+
resourceIds: getLeadGenCrmHandoffResourceIds(model)
|
|
7340
|
+
})
|
|
7341
|
+
);
|
|
7342
|
+
function findLeadGenTemplateStepCatalog(index) {
|
|
7343
|
+
return Object.values(index.ontology.catalogTypes).find(
|
|
7344
|
+
(catalog) => catalog.ownerSystemId === "sales.lead-gen" && catalog.kind === "template-step" && catalog.appliesTo === LEAD_GEN_LIST_OBJECT_ONTOLOGY_ID
|
|
7345
|
+
);
|
|
7346
|
+
}
|
|
7347
|
+
function requireReadyCatalog(index, catalogId, readinessLabel) {
|
|
7348
|
+
const catalog = index.ontology.catalogTypes[catalogId];
|
|
7349
|
+
if (catalog === void 0) {
|
|
7350
|
+
throw new Error(
|
|
7351
|
+
`${readinessLabel} readiness passed but catalog "${catalogId}" is unexpectedly absent from the compiled ontology.`
|
|
7352
|
+
);
|
|
7353
|
+
}
|
|
7354
|
+
return catalog;
|
|
7355
|
+
}
|
|
7356
|
+
function compileBusinessOntologyValidationIndex(model) {
|
|
7357
|
+
throwIfInterfaceNotReady(computeInterfaceReadiness(model, LEAD_GEN_API_INTERFACE));
|
|
7358
|
+
throwIfInterfaceNotReady(computeInterfaceReadiness(model, CRM_API_INTERFACE));
|
|
7359
|
+
const index = compileBusinessOntology(model, "legacy acquisition business ontology");
|
|
7360
|
+
return {
|
|
7361
|
+
...index,
|
|
7362
|
+
leadGenStageCatalog: requireReadyCatalog(
|
|
7363
|
+
index,
|
|
7364
|
+
LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID,
|
|
7365
|
+
"legacy acquisition business ontology"
|
|
7366
|
+
),
|
|
7367
|
+
crmPipelineCatalog: requireReadyCatalog(
|
|
7368
|
+
index,
|
|
7369
|
+
CRM_PIPELINE_CATALOG_ONTOLOGY_ID,
|
|
7370
|
+
"legacy acquisition business ontology"
|
|
7371
|
+
)
|
|
7372
|
+
};
|
|
7373
|
+
}
|
|
7374
|
+
function indexActionTypesByLegacyId(actionTypes) {
|
|
7375
|
+
const byLegacyId = {};
|
|
7376
|
+
for (const actionType of Object.values(actionTypes)) {
|
|
7377
|
+
const legacyActionId = actionType["legacyActionId"];
|
|
7378
|
+
if (typeof legacyActionId === "string") {
|
|
7379
|
+
byLegacyId[legacyActionId] = actionType;
|
|
7380
|
+
}
|
|
7381
|
+
}
|
|
7382
|
+
return byLegacyId;
|
|
7383
|
+
}
|
|
7384
|
+
function getCatalogEntries2(catalog) {
|
|
7385
|
+
return isPlainRecord2(catalog.entries) ? catalog.entries : {};
|
|
7386
|
+
}
|
|
7387
|
+
function asLeadGenStageEntry(key, value) {
|
|
7388
|
+
const record = isPlainRecord2(value) ? value : {};
|
|
7389
|
+
const entity = record.entity === "contact" ? "contact" : "company";
|
|
7390
|
+
const additionalEntities = Array.isArray(record.additionalEntities) ? record.additionalEntities.filter(
|
|
7391
|
+
(item) => item === "company" || item === "contact"
|
|
7392
|
+
) : void 0;
|
|
7393
|
+
const recordEntity = record.recordEntity === "company" || record.recordEntity === "contact" ? record.recordEntity : void 0;
|
|
7394
|
+
const recordStageKey = typeof record.recordStageKey === "string" ? record.recordStageKey : void 0;
|
|
7395
|
+
return {
|
|
7396
|
+
key: typeof record.key === "string" ? record.key : key,
|
|
7397
|
+
label: typeof record.label === "string" ? record.label : key,
|
|
7398
|
+
description: typeof record.description === "string" ? record.description : "",
|
|
7399
|
+
order: typeof record.order === "number" ? record.order : 0,
|
|
7400
|
+
entity,
|
|
7401
|
+
...additionalEntities !== void 0 ? { additionalEntities } : {},
|
|
7402
|
+
...recordEntity !== void 0 ? { recordEntity } : {},
|
|
7403
|
+
...recordStageKey !== void 0 ? { recordStageKey } : {}
|
|
7404
|
+
};
|
|
7405
|
+
}
|
|
7406
|
+
function createLeadGenStageValidators(index) {
|
|
7407
|
+
const getCatalog = () => Object.fromEntries(
|
|
7408
|
+
Object.entries(getCatalogEntries2(index.leadGenStageCatalog)).map(([key, value]) => [
|
|
7409
|
+
key,
|
|
7410
|
+
asLeadGenStageEntry(key, value)
|
|
7411
|
+
])
|
|
7412
|
+
);
|
|
7413
|
+
const getEntry = (stageKey) => getCatalog()[stageKey];
|
|
7414
|
+
return {
|
|
7415
|
+
getLeadGenStageCatalog: getCatalog,
|
|
7416
|
+
getLeadGenStageEntry: getEntry,
|
|
7417
|
+
isLeadGenStageKey: (stageKey) => getEntry(stageKey) !== void 0,
|
|
7418
|
+
isLeadGenStageValidForEntity: (stageKey, entity) => {
|
|
7419
|
+
const stage = getEntry(stageKey);
|
|
7420
|
+
return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true);
|
|
7421
|
+
},
|
|
7422
|
+
isLeadGenRecordStageValidForEntity: (stageKey, entity) => {
|
|
7423
|
+
const stage = getEntry(stageKey);
|
|
7424
|
+
return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true || stage.recordEntity === entity);
|
|
7425
|
+
},
|
|
7426
|
+
resolveLeadGenRecordStageKey: (stageKey, entity) => {
|
|
7427
|
+
const stage = getEntry(stageKey);
|
|
7428
|
+
return stage?.recordEntity === entity && stage.recordStageKey ? stage.recordStageKey : stageKey;
|
|
7429
|
+
}
|
|
7430
|
+
};
|
|
7431
|
+
}
|
|
7432
|
+
|
|
7375
7433
|
// src/project-deployment-spec.ts
|
|
7376
7434
|
function toSdkResourceDescriptor(resource, getResourceOntologyBinding) {
|
|
7377
7435
|
const ontologyBinding = getResourceOntologyBinding?.(resource.id);
|
|
@@ -7520,4 +7578,4 @@ function defineWorkflowConfig(resourceId, descriptors, actionRegistry = []) {
|
|
|
7520
7578
|
}
|
|
7521
7579
|
var ListBuilderStageKeySchema = z.string().min(1);
|
|
7522
7580
|
|
|
7523
|
-
export { ActivityEventSchema, BuildPlanSnapshotStepSchema, ProspectingBuildTemplateSchema as BuildTemplateSchema, ContractRefResolutionError, CrmStageKeySchema, CrmStateKeySchema, EmailSchema, ExecutionError, ListBuilderStageKeySchema, ProcessingStageStatusSchema, RegistryValidationError, ResourceRegistry, StepType, ToolingError, bindResourceDescriptor, compileBusinessOntologyValidationIndex, concurrentPool, createLeadGenStageValidators, defineContract, defineResource, defineResourceOntology, defineResources, defineStep, defineTopology, defineTopologyRelationship, defineWorkflow, defineWorkflowConfig, deriveActions, diagnosticOutput, integrationInput, isBuiltInReadinessProfile, isZodType, lookupReadinessProfile, parseTopologyNodeRef,
|
|
7581
|
+
export { ActivityEventSchema, BuildPlanSnapshotStepSchema, ProspectingBuildTemplateSchema as BuildTemplateSchema, ContractRefResolutionError, CrmStageKeySchema, CrmStateKeySchema, EmailSchema, ExecutionError, ListBuilderStageKeySchema, ProcessingStageStatusSchema, RegistryValidationError, ResourceRegistry, StepType, ToolingError, bindResourceDescriptor, compileBusinessOntologyValidationIndex, concurrentPool, createLeadGenStageValidators, defineContract, defineResource, defineResourceOntology, defineResources, defineStep, defineTopology, defineTopologyRelationship, defineWorkflow, defineWorkflowConfig, deriveActions, diagnosticOutput, integrationInput, isBuiltInReadinessProfile, isZodType, lookupReadinessProfile, parseTopologyNodeRef, projectDeploymentSpec, projectTopologyRelationships, registerReadinessProfile, resolveContractRef, runDiagnostic, splitName, toSdkResourceDescriptor, topologyRef, topologyRelationship, validateDeclaredSystemInterfaceReadiness, validateResourceGovernance, withPlatformAgentResourceDescriptor, withPlatformAgentResourceDescriptors, withPlatformIntegrationResourceDescriptor, withPlatformIntegrationResourceDescriptors, withPlatformResourceDescriptor, withPlatformResourceDescriptors };
|