@elevasis/sdk 1.23.0 → 1.24.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.
Files changed (50) hide show
  1. package/dist/cli.cjs +5408 -6605
  2. package/dist/index.d.ts +183 -242
  3. package/dist/index.js +1829 -2912
  4. package/dist/node/index.d.ts +3722 -2
  5. package/dist/node/index.js +163 -1
  6. package/dist/test-utils/index.d.ts +60 -72
  7. package/dist/test-utils/index.js +239 -1479
  8. package/dist/types/worker/index.d.ts +2 -0
  9. package/dist/types/worker/utils.d.ts +9 -0
  10. package/dist/worker/index.js +260 -1487
  11. package/package.json +5 -4
  12. package/reference/_navigation.md +1 -0
  13. package/reference/claude-config/rules/active-change-index.md +11 -80
  14. package/reference/claude-config/rules/agent-start-here.md +11 -277
  15. package/reference/claude-config/rules/deployment.md +11 -57
  16. package/reference/claude-config/rules/error-handling.md +11 -56
  17. package/reference/claude-config/rules/execution.md +11 -40
  18. package/reference/claude-config/rules/frontend.md +11 -43
  19. package/reference/claude-config/rules/observability.md +11 -31
  20. package/reference/claude-config/rules/operations.md +11 -80
  21. package/reference/claude-config/rules/organization-model.md +5 -110
  22. package/reference/claude-config/rules/organization-os.md +7 -111
  23. package/reference/claude-config/rules/package-taxonomy.md +11 -33
  24. package/reference/claude-config/rules/platform.md +11 -42
  25. package/reference/claude-config/rules/shared-types.md +10 -48
  26. package/reference/claude-config/rules/task-tracking.md +11 -47
  27. package/reference/claude-config/rules/ui.md +11 -200
  28. package/reference/claude-config/rules/vibe.md +5 -229
  29. package/reference/claude-config/sync-notes/2026-05-04-knowledge-bundle.md +83 -83
  30. package/reference/claude-config/sync-notes/2026-05-15-om-skill-rename-and-write-family.md +2 -2
  31. package/reference/claude-config/sync-notes/2026-05-17-sdk-boundary-consolidation.md +33 -0
  32. package/reference/rules/active-change-index.md +83 -0
  33. package/reference/rules/agent-start-here.md +280 -0
  34. package/reference/rules/deployment.md +60 -0
  35. package/reference/rules/error-handling.md +59 -0
  36. package/reference/rules/execution.md +43 -0
  37. package/reference/rules/frontend.md +46 -0
  38. package/reference/rules/observability.md +34 -0
  39. package/reference/rules/operations.md +85 -0
  40. package/reference/rules/organization-model.md +119 -0
  41. package/reference/rules/organization-os.md +118 -0
  42. package/reference/rules/package-taxonomy.md +36 -0
  43. package/reference/rules/platform.md +45 -0
  44. package/reference/rules/shared-types.md +52 -0
  45. package/reference/rules/task-tracking.md +50 -0
  46. package/reference/rules/ui.md +203 -0
  47. package/reference/rules/vibe.md +238 -0
  48. package/reference/scaffold/core/organization-graph.mdx +4 -5
  49. package/reference/scaffold/core/organization-model.mdx +1 -1
  50. package/reference/scaffold/reference/contracts.md +14 -2
@@ -1,5 +1,6 @@
1
1
  import { workerData, parentPort } from 'worker_threads';
2
2
  import { z, ZodError } from 'zod';
3
+ import 'crypto';
3
4
  import { isatty } from 'tty';
4
5
 
5
6
  var __create = Object.create;
@@ -5531,8 +5532,8 @@ async function processMemory(memoryManager, response, logger, iteration) {
5531
5532
  continue;
5532
5533
  }
5533
5534
  const startTime = Date.now();
5534
- const stringValue = typeof content === "string" ? content : JSON.stringify(content);
5535
- memoryManager.set(key, stringValue);
5535
+ const stringValue2 = typeof content === "string" ? content : JSON.stringify(content);
5536
+ memoryManager.set(key, stringValue2);
5536
5537
  const endTime = Date.now();
5537
5538
  logger.action("memory-set", `Set: ${key}`, iteration, startTime, endTime, endTime - startTime);
5538
5539
  }
@@ -6819,226 +6820,7 @@ var ActionSchema = z.object({
6819
6820
  var ActionsDomainSchema = z.record(z.string(), ActionSchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
6820
6821
  message: "Each action entry id must match its map key"
6821
6822
  }).default({});
6822
- var LEAD_GEN_ACTION_ENTRY_INPUTS = [
6823
- {
6824
- id: "lead-gen.company.source",
6825
- order: 10,
6826
- label: "Source companies",
6827
- description: "Import source companies from a list provider.",
6828
- scope: { domain: "sales" },
6829
- resourceId: "lgn-import-workflow",
6830
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/source" }]
6831
- },
6832
- {
6833
- id: "lead-gen.company.apollo-import",
6834
- order: 20,
6835
- label: "Import from Apollo",
6836
- description: "Pull companies and seed contact data from an Apollo search or list.",
6837
- scope: { domain: "sales" },
6838
- resourceId: "lgn-01c-apollo-import-workflow",
6839
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/apollo-import" }]
6840
- },
6841
- {
6842
- id: "lead-gen.contact.discover",
6843
- order: 30,
6844
- label: "Discover contact emails",
6845
- description: "Find email addresses for contacts at qualified companies.",
6846
- scope: { domain: "sales" },
6847
- resourceId: "lgn-04-email-discovery-workflow",
6848
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/discover" }]
6849
- },
6850
- {
6851
- id: "lead-gen.contact.verify-email",
6852
- order: 40,
6853
- label: "Verify emails",
6854
- description: "Check email deliverability before outreach.",
6855
- scope: { domain: "sales" },
6856
- resourceId: "lgn-05-email-verification-workflow",
6857
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/verify-email" }]
6858
- },
6859
- {
6860
- id: "lead-gen.company.apify-crawl",
6861
- order: 50,
6862
- label: "Crawl websites",
6863
- description: "Crawl company websites via Apify and store raw page markdown in enrichmentData.websiteCrawl.pages for downstream LLM analysis.",
6864
- scope: { domain: "sales" },
6865
- resourceId: "lgn-02a-apify-website-crawl-workflow",
6866
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/apify-crawl" }]
6867
- },
6868
- {
6869
- id: "lead-gen.company.website-extract",
6870
- order: 60,
6871
- label: "Extract website signals",
6872
- description: "Scrape and analyze company websites for qualification signals.",
6873
- scope: { domain: "sales" },
6874
- resourceId: "lgn-02-website-extract-workflow",
6875
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/website-extract" }]
6876
- },
6877
- {
6878
- id: "lead-gen.company.qualify",
6879
- order: 70,
6880
- label: "Qualify companies",
6881
- description: "Score and filter companies against the ICP rubric.",
6882
- scope: { domain: "sales" },
6883
- resourceId: "lgn-03-company-qualification-workflow",
6884
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/qualify" }]
6885
- },
6886
- {
6887
- id: "lead-gen.company.dtc-subscription-qualify",
6888
- order: 80,
6889
- label: "Qualify DTC subscription fit",
6890
- description: "Classify subscription potential and consumable-product fit for DTC brands.",
6891
- scope: { domain: "sales" },
6892
- resourceId: "lgn-03b-dtc-subscription-score-workflow",
6893
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/dtc-subscription-qualify" }]
6894
- },
6895
- {
6896
- id: "lead-gen.contact.apollo-decision-maker-enrich",
6897
- order: 90,
6898
- label: "Enrich decision-makers",
6899
- description: "Find and enrich qualified contacts at qualified companies via Apollo.",
6900
- scope: { domain: "sales" },
6901
- resourceId: "lgn-04b-apollo-decision-maker-enrich-workflow",
6902
- invocations: [
6903
- { kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/apollo-decision-maker-enrich" }
6904
- ]
6905
- },
6906
- {
6907
- id: "lead-gen.contact.personalize",
6908
- order: 100,
6909
- label: "Personalize outreach",
6910
- description: "Generate personalized opening lines for each contact.",
6911
- scope: { domain: "sales" },
6912
- resourceId: "ist-personalization-workflow",
6913
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/personalize" }]
6914
- },
6915
- {
6916
- id: "lead-gen.review.outreach-ready",
6917
- order: 110,
6918
- label: "Upload to outreach",
6919
- description: "Upload approved contacts to the outreach sequence after QC review.",
6920
- scope: { domain: "sales" },
6921
- resourceId: "ist-upload-contacts-workflow",
6922
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/review/outreach-ready" }]
6923
- },
6924
- {
6925
- id: "lead-gen.export.list",
6926
- order: 120,
6927
- label: "Export lead list",
6928
- description: "Export approved leads as a downloadable lead list.",
6929
- scope: { domain: "sales" },
6930
- resourceId: "lgn-06-export-list-workflow",
6931
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/export/list" }]
6932
- },
6933
- {
6934
- id: "lead-gen.company.cleanup",
6935
- order: 130,
6936
- label: "Clean up companies",
6937
- description: "Remove disqualified or duplicate companies from the list.",
6938
- scope: { domain: "sales" },
6939
- resourceId: "lgn-company-cleanup-workflow",
6940
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/cleanup" }]
6941
- }
6942
- ];
6943
- var LEAD_GEN_ACTION_ENTRIES = Object.fromEntries(
6944
- LEAD_GEN_ACTION_ENTRY_INPUTS.map((action) => {
6945
- const parsed = ActionSchema.parse(action);
6946
- return [parsed.id, parsed];
6947
- })
6948
- );
6949
- var CRM_ACTION_ENTRY_INPUTS = [
6950
- {
6951
- id: "send_reply",
6952
- order: 210,
6953
- label: "Send Reply",
6954
- description: "Send a contextual reply for an active CRM deal.",
6955
- scope: { domain: "sales" },
6956
- resourceId: "crm-send-reply-workflow",
6957
- affects: ["crm.deal"]
6958
- },
6959
- {
6960
- id: "send_link",
6961
- order: 220,
6962
- label: "Send Booking Link",
6963
- description: "Send a booking link to move a deal toward a scheduled call.",
6964
- scope: { domain: "sales" },
6965
- resourceId: "crm-send-booking-link-workflow",
6966
- affects: ["crm.deal"]
6967
- },
6968
- {
6969
- id: "send_nudge",
6970
- order: 230,
6971
- label: "Send Nudge",
6972
- description: "Send a follow-up nudge for a stalled CRM deal.",
6973
- scope: { domain: "sales" },
6974
- resourceId: "crm-send-nudge-workflow",
6975
- affects: ["crm.deal"]
6976
- },
6977
- {
6978
- id: "rebook",
6979
- order: 240,
6980
- label: "Rebook",
6981
- description: "Rebook a missed or rescheduled CRM appointment.",
6982
- scope: { domain: "sales" },
6983
- resourceId: "crm-rebook-workflow",
6984
- affects: ["crm.deal"]
6985
- },
6986
- {
6987
- id: "move_to_proposal",
6988
- order: 250,
6989
- label: "Move to Proposal",
6990
- description: "Advance a qualified CRM deal into the proposal stage.",
6991
- scope: { domain: "sales" },
6992
- resourceId: "move_to_proposal-workflow",
6993
- affects: ["crm.deal"]
6994
- },
6995
- {
6996
- id: "move_to_closing",
6997
- order: 260,
6998
- label: "Move to Closing",
6999
- description: "Advance a proposal-stage CRM deal into closing.",
7000
- scope: { domain: "sales" },
7001
- resourceId: "move_to_closing-workflow",
7002
- affects: ["crm.deal"]
7003
- },
7004
- {
7005
- id: "move_to_closed_won",
7006
- order: 270,
7007
- label: "Close Won",
7008
- description: "Mark a CRM deal as closed won.",
7009
- scope: { domain: "sales" },
7010
- resourceId: "move_to_closed_won-workflow",
7011
- affects: ["crm.deal"]
7012
- },
7013
- {
7014
- id: "move_to_closed_lost",
7015
- order: 280,
7016
- label: "Close Lost",
7017
- description: "Mark a CRM deal as closed lost.",
7018
- scope: { domain: "sales" },
7019
- resourceId: "move_to_closed_lost-workflow",
7020
- affects: ["crm.deal"]
7021
- },
7022
- {
7023
- id: "move_to_nurturing",
7024
- order: 290,
7025
- label: "Move to Nurturing",
7026
- description: "Move a CRM deal into nurturing for future follow-up.",
7027
- scope: { domain: "sales" },
7028
- resourceId: "move_to_nurturing-workflow",
7029
- affects: ["crm.deal"]
7030
- }
7031
- ];
7032
- var CRM_ACTION_ENTRIES = Object.fromEntries(
7033
- CRM_ACTION_ENTRY_INPUTS.map((action) => {
7034
- const parsed = ActionSchema.parse(action);
7035
- return [parsed.id, parsed];
7036
- })
7037
- );
7038
- var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {
7039
- ...LEAD_GEN_ACTION_ENTRIES,
7040
- ...CRM_ACTION_ENTRIES
7041
- };
6823
+ var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {};
7042
6824
 
7043
6825
  // ../core/src/organization-model/domains/prospecting.ts
7044
6826
  DisplayMetadataSchema.extend({
@@ -7177,7 +6959,6 @@ var DTC_RECORD_COLUMNS = {
7177
6959
  ]
7178
6960
  }
7179
6961
  };
7180
- Object.values(LEAD_GEN_ACTION_ENTRIES);
7181
6962
  var PROSPECTING_STEPS = {
7182
6963
  localServices: {
7183
6964
  sourceCompanies: {
@@ -7423,177 +7204,6 @@ var PROSPECTING_BUILD_TEMPLATE_OPTIONS = BUILD_TEMPLATE_CATALOG.map(({ id, label
7423
7204
  function isProspectingBuildTemplateId(value) {
7424
7205
  return PROSPECTING_BUILD_TEMPLATE_OPTIONS.some((template) => template.id === value);
7425
7206
  }
7426
-
7427
- // ../core/src/organization-model/catalogs/lead-gen.ts
7428
- var LEAD_GEN_STAGE_CATALOG = {
7429
- // Prospecting - company population
7430
- scraped: {
7431
- key: "scraped",
7432
- label: "Scraped",
7433
- description: "Company was scraped from a source directory (Apify actor run).",
7434
- order: 1,
7435
- entity: "company"
7436
- },
7437
- populated: {
7438
- key: "populated",
7439
- label: "Companies found",
7440
- description: "Companies have been found and added to the lead-gen list.",
7441
- order: 2,
7442
- entity: "company"
7443
- },
7444
- crawled: {
7445
- key: "crawled",
7446
- label: "Websites crawled",
7447
- description: "Company websites have been crawled (e.g. via Apify) and raw page content stored for downstream LLM analysis.",
7448
- order: 2.5,
7449
- entity: "company"
7450
- },
7451
- extracted: {
7452
- key: "extracted",
7453
- label: "Websites analyzed",
7454
- description: "Company websites have been analyzed for business signals.",
7455
- order: 3,
7456
- entity: "company"
7457
- },
7458
- enriched: {
7459
- key: "enriched",
7460
- label: "Enriched",
7461
- description: "Company or contact enriched with third-party data (e.g. Tomba, Anymailfinder).",
7462
- order: 4,
7463
- entity: "company"
7464
- },
7465
- "decision-makers-enriched": {
7466
- key: "decision-makers-enriched",
7467
- label: "Decision-makers found",
7468
- description: "Decision-maker contacts discovered and attached to a qualified company.",
7469
- order: 6,
7470
- entity: "company",
7471
- recordEntity: "contact",
7472
- recordStageKey: "discovered"
7473
- },
7474
- // Prospecting - contact discovery
7475
- discovered: {
7476
- key: "discovered",
7477
- label: "Decision-makers found",
7478
- description: "Decision-maker contact details have been found.",
7479
- order: 5,
7480
- entity: "contact"
7481
- },
7482
- verified: {
7483
- key: "verified",
7484
- label: "Emails verified",
7485
- description: "Contact email addresses have been checked for deliverability.",
7486
- order: 7,
7487
- entity: "contact"
7488
- },
7489
- // Qualification
7490
- qualified: {
7491
- key: "qualified",
7492
- label: "Companies qualified",
7493
- description: "Companies have been scored against the qualification criteria.",
7494
- order: 8,
7495
- entity: "company"
7496
- },
7497
- // Outreach
7498
- personalized: {
7499
- key: "personalized",
7500
- label: "Personalized",
7501
- description: "Outreach message personalized for the contact (Instantly personalization workflow).",
7502
- order: 9,
7503
- entity: "contact"
7504
- },
7505
- uploaded: {
7506
- key: "uploaded",
7507
- label: "Reviewed and exported",
7508
- description: "Approved records have been reviewed and exported for handoff.",
7509
- order: 10,
7510
- entity: "company",
7511
- additionalEntities: ["contact"]
7512
- },
7513
- interested: {
7514
- key: "interested",
7515
- label: "Interested",
7516
- description: "Contact replied with a positive signal (Instantly reply-handler transition).",
7517
- order: 11,
7518
- entity: "contact"
7519
- }
7520
- };
7521
-
7522
- // ../core/src/organization-model/domains/sales.ts
7523
- var SalesStageSemanticClassSchema = z.enum(["open", "active", "nurturing", "closed_won", "closed_lost"]);
7524
- var SalesStageSchema = DisplayMetadataSchema.extend({
7525
- id: ModelIdSchema,
7526
- order: z.number().int().min(0),
7527
- semanticClass: SalesStageSemanticClassSchema,
7528
- surfaceIds: ReferenceIdsSchema,
7529
- resourceIds: ReferenceIdsSchema
7530
- });
7531
- z.object({
7532
- id: ModelIdSchema,
7533
- label: z.string().trim().min(1).max(120),
7534
- description: DescriptionSchema.optional(),
7535
- entityId: ModelIdSchema,
7536
- stages: z.array(SalesStageSchema).min(1)
7537
- });
7538
- var CRM_DISCOVERY_REPLIED_STATE = {
7539
- stateKey: "discovery_replied",
7540
- label: "Discovery Replied"
7541
- };
7542
- var CRM_DISCOVERY_LINK_SENT_STATE = {
7543
- stateKey: "discovery_link_sent",
7544
- label: "Discovery Link Sent"
7545
- };
7546
- var CRM_DISCOVERY_NUDGING_STATE = {
7547
- stateKey: "discovery_nudging",
7548
- label: "Discovery Nudging"
7549
- };
7550
- var CRM_DISCOVERY_BOOKING_CANCELLED_STATE = {
7551
- stateKey: "discovery_booking_cancelled",
7552
- label: "Discovery Booking Cancelled"
7553
- };
7554
- var CRM_REPLY_SENT_STATE = {
7555
- stateKey: "reply_sent",
7556
- label: "Reply Sent"
7557
- };
7558
- var CRM_FOLLOWUP_1_SENT_STATE = {
7559
- stateKey: "followup_1_sent",
7560
- label: "Follow-up 1 Sent"
7561
- };
7562
- var CRM_FOLLOWUP_2_SENT_STATE = {
7563
- stateKey: "followup_2_sent",
7564
- label: "Follow-up 2 Sent"
7565
- };
7566
- var CRM_FOLLOWUP_3_SENT_STATE = {
7567
- stateKey: "followup_3_sent",
7568
- label: "Follow-up 3 Sent"
7569
- };
7570
- var CRM_PIPELINE_DEFINITION = {
7571
- pipelineKey: "crm",
7572
- label: "CRM",
7573
- entityKey: "crm.deal",
7574
- stages: [
7575
- {
7576
- stageKey: "interested",
7577
- label: "Interested",
7578
- color: "blue",
7579
- states: [
7580
- CRM_DISCOVERY_REPLIED_STATE,
7581
- CRM_DISCOVERY_LINK_SENT_STATE,
7582
- CRM_DISCOVERY_NUDGING_STATE,
7583
- CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
7584
- CRM_REPLY_SENT_STATE,
7585
- CRM_FOLLOWUP_1_SENT_STATE,
7586
- CRM_FOLLOWUP_2_SENT_STATE,
7587
- CRM_FOLLOWUP_3_SENT_STATE
7588
- ]
7589
- },
7590
- { stageKey: "proposal", label: "Proposal", color: "yellow", states: [] },
7591
- { stageKey: "closing", label: "Closing", color: "orange", states: [] },
7592
- { stageKey: "closed_won", label: "Closed Won", color: "green", states: [] },
7593
- { stageKey: "closed_lost", label: "Closed Lost", color: "red", states: [] },
7594
- { stageKey: "nurturing", label: "Nurturing", color: "grape", states: [] }
7595
- ]
7596
- };
7597
7207
  var OrganizationModelBrandingSchema = z.object({
7598
7208
  organizationName: LabelSchema,
7599
7209
  productName: LabelSchema,
@@ -7768,45 +7378,6 @@ var OfferingsDomainSchema = z.record(z.string(), ProductSchema).refine((record)
7768
7378
  message: "Each product entry id must match its map key"
7769
7379
  }).default({});
7770
7380
  var DEFAULT_ORGANIZATION_MODEL_OFFERINGS = {};
7771
- var ContentNodeBaseSchema = z.object({
7772
- /** Human-readable label for the content node. */
7773
- label: z.string().trim().min(1).max(120).meta({ label: "Label" }),
7774
- /** Optional one-paragraph description. */
7775
- description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description" }),
7776
- /** Optional display order within the system content map. */
7777
- order: z.number().int().optional().meta({ label: "Order" }),
7778
- /**
7779
- * Local NodeId of the parent content node within the SAME system.
7780
- * Per B4/L9: MUST resolve to a sibling in the same `system.content` map.
7781
- * Per L19: parent and child MUST share the same `kind` (meta-category).
7782
- */
7783
- parentContentId: z.string().trim().min(1).max(200).optional().meta({ label: "Parent content id" })
7784
- });
7785
- var ContentNodeSchema = ContentNodeBaseSchema.extend({
7786
- /** Meta-category (e.g. 'schema', 'config', 'knowledge', tenant-defined). */
7787
- kind: z.string().trim().min(1).max(100).meta({ label: "Kind" }),
7788
- /** Specific family within the meta-category (e.g. 'pipeline', 'kv'). */
7789
- type: z.string().trim().min(1).max(100).meta({ label: "Type" }),
7790
- /** Payload data; validated against registered payloadSchema when (kind, type) is known. */
7791
- data: z.record(z.string(), z.unknown()).optional().meta({ label: "Data" })
7792
- });
7793
- z.object({
7794
- /** Meta-category (tenant-defined or registry-shipped). */
7795
- kind: z.string().trim().min(1).max(100).meta({ label: "Kind" }),
7796
- /** Specific family within the meta-category. */
7797
- type: z.string().trim().min(1).max(100).meta({ label: "Type" }),
7798
- /** Human-readable label shown in the KB tree and describe views. */
7799
- label: z.string().trim().min(1).max(120).meta({ label: "Label" }),
7800
- /** Optional description. */
7801
- description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description" }),
7802
- /**
7803
- * Which KB tree group this extension renders in.
7804
- * Per L6: 'business-model' places it alongside Customers / Offerings / Goals.
7805
- */
7806
- treeGroup: z.union([z.enum(["profile", "business-model", "systems", "graph", "governance-wiring"]), z.string().min(1).max(100)]).meta({ label: "Tree group" }),
7807
- /** Untyped payload; shape governed by the registered payloadSchema when available. */
7808
- data: z.record(z.string(), z.unknown()).optional().meta({ label: "Data" })
7809
- });
7810
7381
  var OntologyKindSchema = z.enum([
7811
7382
  "object",
7812
7383
  "link",
@@ -8135,40 +7706,6 @@ function addLegacyActionProjections(index2, diagnostics, sourcesById, actions, e
8135
7706
  });
8136
7707
  }
8137
7708
  }
8138
- function addSystemContentProjections(index2, diagnostics, sourcesById, systemPath, system, schemaPath) {
8139
- const content = system.content ?? {};
8140
- for (const [localId, node] of Object.entries(content)) {
8141
- if (node.kind !== "schema") continue;
8142
- const entries = Object.fromEntries(
8143
- Object.entries(content).filter(([, candidate]) => candidate.parentContentId === localId).map(([entryId, candidate]) => [
8144
- entryId,
8145
- {
8146
- label: candidate.label ?? entryId,
8147
- type: candidate.type,
8148
- ...candidate.description !== void 0 ? { description: candidate.description } : {},
8149
- ...candidate.data !== void 0 ? candidate.data : {}
8150
- }
8151
- ])
8152
- );
8153
- const catalogType = {
8154
- id: formatOntologyId({ scope: systemPath, kind: "catalog", localId }),
8155
- label: node.label ?? localId,
8156
- description: node.description,
8157
- ownerSystemId: systemPath,
8158
- kind: node.type,
8159
- ...typeof node.data?.["entityId"] === "string" ? { appliesTo: formatOntologyId({ scope: systemPath, kind: "object", localId: node.data["entityId"] }) } : {},
8160
- ...Object.keys(entries).length > 0 ? { entries } : {},
8161
- ...node.data !== void 0 ? { data: node.data } : {}
8162
- };
8163
- addRecord(index2, diagnostics, sourcesById, "catalogTypes", catalogType, {
8164
- source: "legacy.system.content",
8165
- path: [...schemaPath, "content", localId],
8166
- kind: "projected",
8167
- systemPath,
8168
- legacyId: `${systemPath}:${localId}`
8169
- });
8170
- }
8171
- }
8172
7709
  function addSystemScopes(index2, diagnostics, sourcesById, systems, prefix, schemaPath) {
8173
7710
  for (const [key, system] of Object.entries(systems)) {
8174
7711
  const systemPath = prefix ? `${prefix}.${key}` : key;
@@ -8177,7 +7714,6 @@ function addSystemScopes(index2, diagnostics, sourcesById, systems, prefix, sche
8177
7714
  ...currentPath,
8178
7715
  "ontology"
8179
7716
  ]);
8180
- addSystemContentProjections(index2, diagnostics, sourcesById, systemPath, system, currentPath);
8181
7717
  addSystemScopes(index2, diagnostics, sourcesById, childSystemsOf(system), systemPath, [
8182
7718
  ...currentPath,
8183
7719
  system.systems !== void 0 ? "systems" : "subsystems"
@@ -8207,7 +7743,7 @@ var SystemPathSchema = z.string().trim().min(1).regex(
8207
7743
  var UiPositionSchema = z.enum(["sidebar-primary", "sidebar-bottom"]).meta({ label: "UI position" });
8208
7744
  var NodeIdStringSchema = z.string().trim().min(1).max(200).regex(
8209
7745
  /^[a-z][a-z-]*:([a-z0-9-]+)(\.[a-z0-9-]+)*(:[a-z0-9.-]+)*$/,
8210
- "Node references must use kind:dotted-path (e.g. system:sales.crm or content-node:sales.crm:pipeline-id)"
7746
+ "Node references must use kind:dotted-path (e.g. system:sales.crm or resource:lead-gen.company.qualify)"
8211
7747
  );
8212
7748
  var SystemUiSchema = z.object({
8213
7749
  path: PathSchema,
@@ -8281,13 +7817,6 @@ var SystemEntrySchema = z.object({
8281
7817
  * shared contract records owned by this system.
8282
7818
  */
8283
7819
  ontology: OntologyScopeSchema.optional(),
8284
- /**
8285
- * @deprecated Compatibility-only bridge for old tenant content nodes and
8286
- * migration readers. New schema/catalog authoring belongs in ontology;
8287
- * new system-local settings belong in config. Bridge nodes are keyed by
8288
- * local NodeId and may still project to content-node:* graph IDs.
8289
- */
8290
- content: z.record(z.string().trim().min(1).max(200), ContentNodeSchema).optional(),
8291
7820
  /**
8292
7821
  * Recursive child systems, authored via nesting (per L11).
8293
7822
  * The key is the local system id; the full path is computed by joining
@@ -8298,7 +7827,7 @@ var SystemEntrySchema = z.object({
8298
7827
  systems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional(),
8299
7828
  /** @deprecated Use systems. Accepted as a compatibility alias during the ontology bridge. */
8300
7829
  subsystems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional()
8301
- }).refine((system) => system.label !== void 0 || system.title !== void 0, {
7830
+ }).strict().refine((system) => system.label !== void 0 || system.title !== void 0, {
8302
7831
  path: ["label"],
8303
7832
  message: "System must provide label or title"
8304
7833
  }).transform((system) => {
@@ -8313,6 +7842,10 @@ var SystemsDomainSchema = z.record(z.string(), SystemEntrySchema).refine((record
8313
7842
  var DEFAULT_ORGANIZATION_MODEL_SYSTEMS = {};
8314
7843
 
8315
7844
  // ../core/src/organization-model/domains/resources.ts
7845
+ var ContractRefSchema = z.string().trim().min(1).max(500).regex(
7846
+ /^[A-Za-z0-9@](?:[A-Za-z0-9_./@-]*[A-Za-z0-9_])?\/?[A-Za-z0-9_./@-]*#[A-Za-z_$][A-Za-z0-9_$]*$/,
7847
+ "ContractRef must be in the format package/subpath#ExportName (e.g. @repo/elevasis-core/contracts/apollo-import#inputSchema)"
7848
+ );
8316
7849
  z.enum(["workflow", "agent", "integration", "script"]).meta({ label: "Resource kind", color: "orange" });
8317
7850
  var ResourceGovernanceStatusSchema = z.enum(["active", "deprecated", "archived"]).meta({ label: "Governance status", color: "teal" });
8318
7851
  var AgentKindSchema = z.enum(["orchestrator", "specialist", "utility", "platform"]).meta({ label: "Agent kind", color: "violet" });
@@ -8341,7 +7874,20 @@ var ResourceOntologyBindingSchema = z.object({
8341
7874
  reads: z.array(OntologyIdSchema).optional(),
8342
7875
  writes: z.array(OntologyIdSchema).optional(),
8343
7876
  usesCatalogs: z.array(OntologyIdSchema).optional(),
8344
- emits: z.array(OntologyIdSchema).optional()
7877
+ emits: z.array(OntologyIdSchema).optional(),
7878
+ /**
7879
+ * Optional typed contract binding for this resource's workflow I/O.
7880
+ * Each ref is a `package/subpath#ExportName` string that resolves to a
7881
+ * Zod schema in `@repo/elevasis-core` (or the consumer's equivalent package).
7882
+ *
7883
+ * Absence of this field preserves all existing behavior — it is additive + optional.
7884
+ * Tier-1 validation (schema.ts): ref-string shape only (browser-safe, no imports).
7885
+ * Tier-2 validation (om:verify): intra-package typed-map resolution asserts ZodType.
7886
+ */
7887
+ contract: z.object({
7888
+ input: ContractRefSchema.optional(),
7889
+ output: ContractRefSchema.optional()
7890
+ }).optional()
8345
7891
  }).superRefine((binding, ctx) => {
8346
7892
  if (binding.primaryAction === void 0) return;
8347
7893
  if (binding.actions?.includes(binding.primaryAction)) return;
@@ -8667,151 +8213,6 @@ var PoliciesDomainSchema = z.record(z.string(), PolicySchema).refine((record) =>
8667
8213
  message: "Each policy entry id must match its map key"
8668
8214
  }).default({});
8669
8215
  var DEFAULT_ORGANIZATION_MODEL_POLICIES = {};
8670
-
8671
- // ../core/src/organization-model/content-kinds/registry.ts
8672
- function defineContentType(def) {
8673
- return def;
8674
- }
8675
- var PipelinePayloadSchema = z.object({
8676
- /**
8677
- * Local NodeId of the entity this pipeline applies to (e.g. 'crm.deal').
8678
- * `.meta({ ref: 'entity' })` enables SchemaDrivenFieldList to render a
8679
- * clickable graph link to the referenced entity node.
8680
- */
8681
- entityId: z.string().trim().min(1).max(200).meta({ label: "Entity", ref: "entity", hint: "The entity type this pipeline tracks" }),
8682
- /**
8683
- * Optional Kanban column color token for UI rendering.
8684
- */
8685
- kanbanColor: z.string().trim().min(1).max(40).optional().meta({ label: "Kanban color", hint: "UI color token" })
8686
- });
8687
- var pipelineKind = defineContentType({
8688
- kind: "schema",
8689
- type: "pipeline",
8690
- label: "Pipeline",
8691
- description: "A named progression pipeline that applies to a specific entity type.",
8692
- payloadSchema: PipelinePayloadSchema,
8693
- parentTypes: []
8694
- });
8695
- var StagePayloadSchema = z.object({
8696
- /**
8697
- * Semantic classification for this stage.
8698
- * Drives color, icon, and CRM-priority logic in consuming views.
8699
- * Optional — prospecting stages use data.entityKind instead.
8700
- * Enum aligned with SalesStageSemanticClassSchema (sales.ts).
8701
- */
8702
- semanticClass: z.enum(["open", "active", "nurturing", "closed_won", "closed_lost", "won", "lost", "closed"]).optional().meta({ label: "Semantic class", hint: "Semantic meaning of this stage", color: "blue" })
8703
- });
8704
- var stageKind = defineContentType({
8705
- kind: "schema",
8706
- type: "stage",
8707
- label: "Stage",
8708
- description: "A stage within a pipeline. Must be parented under a schema:pipeline content node.",
8709
- payloadSchema: StagePayloadSchema,
8710
- parentTypes: ["schema:pipeline"]
8711
- });
8712
- var TemplatePayloadSchema = z.object({
8713
- /**
8714
- * Optional description surfaced in the KB describe view and tooling.
8715
- */
8716
- description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description", hint: "What this template is used for" })
8717
- });
8718
- var templateKind = defineContentType({
8719
- kind: "schema",
8720
- type: "template",
8721
- label: "Template",
8722
- description: "A named build template (e.g. a prospecting pipeline sequence).",
8723
- payloadSchema: TemplatePayloadSchema,
8724
- parentTypes: []
8725
- });
8726
- var TemplateStepPayloadSchema = z.object({
8727
- /**
8728
- * Which entity type this step primarily operates on.
8729
- */
8730
- primaryEntity: z.enum(["company", "contact"]).meta({ label: "Primary entity", hint: "Entity type this step processes", color: "blue" }),
8731
- /**
8732
- * Action key identifying the workflow action executed by this step.
8733
- * `.meta({ ref: 'action' })` enables SchemaDrivenFieldList to render a
8734
- * clickable graph link.
8735
- */
8736
- actionKey: z.string().trim().min(1).max(200).meta({ label: "Action", ref: "action", hint: "Workflow action executed by this step" }),
8737
- /**
8738
- * IDs of sibling step local NodeIds this step depends on.
8739
- */
8740
- dependsOn: z.array(z.string().trim().min(1).max(200)).optional().meta({ label: "Depends on", hint: "Local NodeIds of prerequisite steps" })
8741
- });
8742
- var templateStepKind = defineContentType({
8743
- kind: "schema",
8744
- type: "template-step",
8745
- label: "Template Step",
8746
- description: "A step within a build template. Must be parented under a schema:template content node.",
8747
- payloadSchema: TemplateStepPayloadSchema,
8748
- parentTypes: ["schema:template"]
8749
- });
8750
- var StatusFlowPayloadSchema = z.object({
8751
- /**
8752
- * Which entity scope this status flow governs.
8753
- */
8754
- appliesTo: z.enum(["project", "milestone", "task"]).meta({ label: "Applies to", hint: "Entity scope governed by this status flow", color: "blue" })
8755
- });
8756
- var statusFlowKind = defineContentType({
8757
- kind: "schema",
8758
- type: "status-flow",
8759
- label: "Status Flow",
8760
- description: "A named set of statuses governing a project, milestone, or task entity.",
8761
- payloadSchema: StatusFlowPayloadSchema,
8762
- parentTypes: []
8763
- });
8764
- var StatusPayloadSchema = z.object({
8765
- /**
8766
- * Semantic classification string for this status.
8767
- * Free-form to allow tenant-defined classifications (e.g. 'active', 'blocked',
8768
- * 'completed'). Used by UI to apply color and icon fallbacks.
8769
- * Optional — status nodes may omit this when the label is self-descriptive.
8770
- */
8771
- semanticClass: z.string().trim().min(1).max(100).optional().meta({ label: "Semantic class", hint: "Semantic meaning of this status (e.g. active, blocked, completed)" }),
8772
- /**
8773
- * Optional UI color token override for this status.
8774
- */
8775
- color: z.string().trim().min(1).max(40).optional().meta({ label: "Color", hint: "UI color token" })
8776
- });
8777
- var statusKind = defineContentType({
8778
- kind: "schema",
8779
- type: "status",
8780
- label: "Status",
8781
- description: "A single status within a status flow. Must be parented under a schema:status-flow content node.",
8782
- payloadSchema: StatusPayloadSchema,
8783
- parentTypes: ["schema:status-flow"]
8784
- });
8785
- var ConfigKvPayloadSchema = z.object({
8786
- /**
8787
- * Flat key-value entries. Values are JSON primitives.
8788
- * Keys are short identifiers (e.g. 'maxBatchSize', 'featureEnabled').
8789
- */
8790
- entries: z.record(z.string().trim().min(1).max(200), z.union([z.string(), z.number(), z.boolean(), z.null()])).meta({ label: "Entries", hint: "Key-value configuration entries (string, number, boolean, or null values)" })
8791
- });
8792
- var configKvKind = defineContentType({
8793
- kind: "config",
8794
- type: "kv",
8795
- label: "Key-Value Config",
8796
- description: "A flat key-value configuration store co-located with a system. Values are JSON primitives.",
8797
- payloadSchema: ConfigKvPayloadSchema,
8798
- parentTypes: []
8799
- });
8800
-
8801
- // ../core/src/organization-model/content-kinds/index.ts
8802
- var CONTENT_KIND_REGISTRY = {
8803
- "schema:pipeline": pipelineKind,
8804
- "schema:stage": stageKind,
8805
- "schema:template": templateKind,
8806
- "schema:template-step": templateStepKind,
8807
- "schema:status-flow": statusFlowKind,
8808
- "schema:status": statusKind,
8809
- "config:kv": configKvKind
8810
- };
8811
- function lookupContentType(kind, type3) {
8812
- const key = `${kind}:${type3}`;
8813
- return CONTENT_KIND_REGISTRY[key];
8814
- }
8815
8216
  var SurfaceTypeSchema = z.enum(["page", "dashboard", "graph", "detail", "list", "settings"]).meta({ label: "Surface type", color: "blue" });
8816
8217
  z.object({
8817
8218
  id: ModelIdSchema,
@@ -8882,13 +8283,10 @@ var KnowledgeTargetKindSchema = z.enum([
8882
8283
  "goal",
8883
8284
  "customer-segment",
8884
8285
  "offering",
8885
- "ontology",
8886
- // D4: content nodes are a valid knowledge target after compound-domain data moved into system.content
8887
- "content-node"
8286
+ "ontology"
8888
8287
  ]).meta({ label: "Target kind" });
8889
8288
  var KnowledgeTargetRefSchema = z.object({
8890
8289
  kind: KnowledgeTargetKindSchema,
8891
- // D4: content-node targets use a qualified id format '<system-path>:<local-content-id>'.
8892
8290
  // Ontology targets use the canonical '<scope>:<kind>/<local-id>' ontology id format.
8893
8291
  // Business-logic validation of target existence is done in OrganizationModelSchema.superRefine.
8894
8292
  id: z.string().trim().min(1).max(300)
@@ -8905,6 +8303,15 @@ var KnowledgeTargetRefSchema = z.object({
8905
8303
  });
8906
8304
  var LegacyKnowledgeLinkSchema = z.object({
8907
8305
  nodeId: z.union([NodeIdStringSchema, z.templateLiteral(["ontology:", OntologyIdSchema])])
8306
+ }).superRefine((link, ctx) => {
8307
+ const [kind] = link.nodeId.split(":");
8308
+ if (!KnowledgeTargetKindSchema.safeParse(kind).success) {
8309
+ ctx.addIssue({
8310
+ code: z.ZodIssueCode.custom,
8311
+ path: ["nodeId"],
8312
+ message: `Unknown knowledge target kind "${kind}"`
8313
+ });
8314
+ }
8908
8315
  });
8909
8316
  var CanonicalKnowledgeLinkSchema = z.object({
8910
8317
  target: KnowledgeTargetRefSchema
@@ -9064,7 +8471,10 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
9064
8471
  const childSystems = system.systems ?? system.subsystems;
9065
8472
  if (childSystems !== void 0) {
9066
8473
  result.push(
9067
- ...collectAllSystems(childSystems, path, [...currentSchemaPath, system.systems !== void 0 ? "systems" : "subsystems"])
8474
+ ...collectAllSystems(childSystems, path, [
8475
+ ...currentSchemaPath,
8476
+ system.systems !== void 0 ? "systems" : "subsystems"
8477
+ ])
9068
8478
  );
9069
8479
  }
9070
8480
  }
@@ -9085,7 +8495,9 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
9085
8495
  `System "${system.id}" references unknown parent "${system.parentSystemId}"`
9086
8496
  );
9087
8497
  }
9088
- const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some((candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes("."));
8498
+ const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some(
8499
+ (candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".")
8500
+ );
9089
8501
  const contributesRoutePath = system.ui?.path !== void 0 || system.path !== void 0 || !hasChildren;
9090
8502
  if (contributesRoutePath) {
9091
8503
  const effectivePath = system.ui?.path ?? system.path ?? defaultSystemPathFor(path);
@@ -9107,11 +8519,7 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
9107
8519
  (candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".") && isLifecycleEnabled(candidate.system.lifecycle, candidate.system.enabled)
9108
8520
  );
9109
8521
  if (!hasEnabledDescendant) {
9110
- addIssue(
9111
- ctx,
9112
- [...schemaPath, "lifecycle"],
9113
- `System "${path}" is active but has no active descendants`
9114
- );
8522
+ addIssue(ctx, [...schemaPath, "lifecycle"], `System "${path}" is active but has no active descendants`);
9115
8523
  }
9116
8524
  }
9117
8525
  });
@@ -9343,10 +8751,16 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
9343
8751
  }
9344
8752
  });
9345
8753
  });
9346
- const stageIds = /* @__PURE__ */ new Set();
9347
8754
  const actionIds = new Set(Object.keys(model.actions));
9348
8755
  const offeringsById = new Map(Object.entries(model.offerings));
9349
8756
  const ontologyCompilation = compileOrganizationOntology(model);
8757
+ const stageIds = /* @__PURE__ */ new Set();
8758
+ for (const catalog of Object.values(ontologyCompilation.ontology.catalogTypes)) {
8759
+ if (catalog.kind !== "stage") continue;
8760
+ for (const stageId of Object.keys(catalog.entries ?? {})) {
8761
+ stageIds.add(stageId);
8762
+ }
8763
+ }
9350
8764
  const ontologyIndexByKind = {
9351
8765
  object: ontologyCompilation.ontology.objectTypes,
9352
8766
  link: ontologyCompilation.ontology.linkTypes,
@@ -9522,13 +8936,7 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
9522
8936
  if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
9523
8937
  addIssue(
9524
8938
  ctx,
9525
- [
9526
- "resources",
9527
- resourceId,
9528
- "ontology",
9529
- bindingKey,
9530
- ...Array.isArray(ids) ? [ontologyIndex] : []
9531
- ],
8939
+ ["resources", resourceId, "ontology", bindingKey, ...Array.isArray(ids) ? [ontologyIndex] : []],
9532
8940
  `Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
9533
8941
  );
9534
8942
  }
@@ -9543,6 +8951,23 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
9543
8951
  validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
9544
8952
  validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
9545
8953
  validateResourceOntologyBinding(resource.id, "emits", "event", binding.emits);
8954
+ if (binding.contract !== void 0) {
8955
+ const contractEntries = [
8956
+ ["input", binding.contract.input],
8957
+ ["output", binding.contract.output]
8958
+ ];
8959
+ for (const [side, ref] of contractEntries) {
8960
+ if (ref === void 0) continue;
8961
+ const result = ContractRefSchema.safeParse(ref);
8962
+ if (!result.success) {
8963
+ addIssue(
8964
+ ctx,
8965
+ ["resources", resource.id, "ontology", "contract", side],
8966
+ `Resource "${resource.id}" contract.${side} "${ref}" is not a valid ContractRef (expected "package/subpath#ExportName")`
8967
+ );
8968
+ }
8969
+ }
8970
+ }
9546
8971
  });
9547
8972
  Object.values(model.roles).forEach((role) => {
9548
8973
  if (role.heldBy === void 0) return;
@@ -9577,78 +9002,6 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
9577
9002
  }
9578
9003
  });
9579
9004
  });
9580
- function validateSystemContent(system, systemPath) {
9581
- const childSystems = system.systems ?? system.subsystems;
9582
- const childKey = system.systems !== void 0 ? "systems" : "subsystems";
9583
- const content = system.content;
9584
- if (content === void 0 || Object.keys(content).length === 0) {
9585
- if (childSystems !== void 0) {
9586
- Object.entries(childSystems).forEach(([childLocalId, child]) => {
9587
- validateSystemContent(child, [...systemPath, childKey, childLocalId]);
9588
- });
9589
- }
9590
- return;
9591
- }
9592
- Object.entries(content).forEach(([localId, node]) => {
9593
- if (node.parentContentId !== void 0 && !(node.parentContentId in content)) {
9594
- addIssue(
9595
- ctx,
9596
- [...systemPath, "content", localId, "parentContentId"],
9597
- `Content node "${localId}" parentContentId "${node.parentContentId}" does not resolve within the same system`
9598
- );
9599
- }
9600
- });
9601
- Object.entries(content).forEach(([localId, node]) => {
9602
- const visited = /* @__PURE__ */ new Set();
9603
- let currentId = node.parentContentId;
9604
- while (currentId !== void 0) {
9605
- if (currentId === localId || visited.has(currentId)) {
9606
- addIssue(
9607
- ctx,
9608
- [...systemPath, "content", localId, "parentContentId"],
9609
- `Content node "${localId}" has a parentContentId cycle`
9610
- );
9611
- break;
9612
- }
9613
- visited.add(currentId);
9614
- currentId = content[currentId]?.parentContentId;
9615
- }
9616
- });
9617
- Object.entries(content).forEach(([localId, node]) => {
9618
- const childDef = lookupContentType(node.kind, node.type);
9619
- if (childDef !== void 0 && node.data !== void 0) {
9620
- const result = childDef.payloadSchema.safeParse(node.data);
9621
- if (!result.success) {
9622
- addIssue(
9623
- ctx,
9624
- [...systemPath, "content", localId, "data"],
9625
- `Content node "${localId}" (${node.kind}:${node.type}) data failed payload validation: ${result.error.message}`
9626
- );
9627
- }
9628
- }
9629
- if (node.parentContentId !== void 0 && childDef !== void 0) {
9630
- const parentNode = content[node.parentContentId];
9631
- if (parentNode !== void 0) {
9632
- const parentDef = lookupContentType(parentNode.kind, parentNode.type);
9633
- if (parentDef !== void 0 && childDef.kind !== parentDef.kind) {
9634
- addIssue(
9635
- ctx,
9636
- [...systemPath, "content", localId, "parentContentId"],
9637
- `Content node "${localId}" kind "${childDef.kind}" cannot parent under "${node.parentContentId}" kind "${parentDef.kind}": parentContentId must be same-meta-kind (per L19)`
9638
- );
9639
- }
9640
- }
9641
- }
9642
- });
9643
- if (childSystems !== void 0) {
9644
- Object.entries(childSystems).forEach(([childLocalId, child]) => {
9645
- validateSystemContent(child, [...systemPath, childKey, childLocalId]);
9646
- });
9647
- }
9648
- }
9649
- Object.entries(model.systems).forEach(([systemKey, system]) => {
9650
- validateSystemContent(system, ["systems", systemKey]);
9651
- });
9652
9005
  for (const diagnostic of ontologyCompilation.diagnostics) {
9653
9006
  addIssue(ctx, diagnostic.path, diagnostic.message);
9654
9007
  }
@@ -9656,311 +9009,11 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
9656
9009
 
9657
9010
  // ../core/src/organization-model/defaults.ts
9658
9011
  var DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE = {};
9659
- var DEFAULT_ORGANIZATION_MODEL_ENTITIES2 = DEFAULT_ORGANIZATION_MODEL_ENTITIES;
9012
+ var DEFAULT_ORGANIZATION_MODEL_ENTITIES2 = {};
9660
9013
  var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
9661
9014
  sidebar: {
9662
- primary: {
9663
- dashboard: {
9664
- type: "surface",
9665
- label: "Dashboard",
9666
- path: "/",
9667
- surfaceType: "dashboard",
9668
- icon: "dashboard",
9669
- order: 10,
9670
- targets: { systems: ["dashboard"] }
9671
- },
9672
- business: {
9673
- type: "group",
9674
- label: "Business",
9675
- icon: "briefcase",
9676
- order: 20,
9677
- children: {
9678
- sales: {
9679
- type: "surface",
9680
- label: "Sales",
9681
- path: "/sales",
9682
- surfaceType: "page",
9683
- icon: "sales",
9684
- order: 10,
9685
- targets: { systems: ["sales"] }
9686
- },
9687
- clients: {
9688
- type: "surface",
9689
- label: "Clients",
9690
- path: "/clients",
9691
- surfaceType: "list",
9692
- icon: "clients",
9693
- order: 20,
9694
- targets: { systems: ["clients"] }
9695
- },
9696
- projects: {
9697
- type: "surface",
9698
- label: "Projects",
9699
- path: "/projects",
9700
- surfaceType: "page",
9701
- icon: "projects",
9702
- order: 30,
9703
- targets: { systems: ["projects"] }
9704
- }
9705
- }
9706
- },
9707
- operations: {
9708
- type: "group",
9709
- label: "Operations",
9710
- icon: "operations",
9711
- order: 30,
9712
- children: {
9713
- "operations-overview": {
9714
- type: "surface",
9715
- label: "Overview",
9716
- path: "/operations",
9717
- surfaceType: "page",
9718
- order: 10,
9719
- targets: { systems: ["operations.overview"] }
9720
- },
9721
- "operations-systems": {
9722
- type: "surface",
9723
- label: "Systems",
9724
- path: "/operations/systems",
9725
- surfaceType: "page",
9726
- order: 20,
9727
- targets: { systems: ["operations"] }
9728
- },
9729
- "operations-resources": {
9730
- type: "surface",
9731
- label: "Resources",
9732
- path: "/operations/resources",
9733
- surfaceType: "list",
9734
- order: 30,
9735
- targets: { systems: ["operations.resources"] }
9736
- },
9737
- "operations-command-queue": {
9738
- type: "surface",
9739
- label: "Command Queue",
9740
- path: "/operations/command-queue",
9741
- surfaceType: "list",
9742
- order: 40,
9743
- targets: { systems: ["operations.command-queue"] }
9744
- },
9745
- "operations-task-scheduler": {
9746
- type: "surface",
9747
- label: "Task Scheduler",
9748
- path: "/operations/task-scheduler",
9749
- surfaceType: "list",
9750
- order: 50,
9751
- targets: { systems: ["operations.task-scheduler"] }
9752
- }
9753
- }
9754
- },
9755
- monitoring: {
9756
- type: "group",
9757
- label: "Monitoring",
9758
- icon: "monitoring",
9759
- order: 40,
9760
- children: {
9761
- "monitoring-overview": {
9762
- type: "surface",
9763
- label: "Overview",
9764
- path: "/monitoring",
9765
- surfaceType: "page",
9766
- order: 10,
9767
- targets: { systems: ["monitoring"] }
9768
- },
9769
- "monitoring-calendar": {
9770
- type: "surface",
9771
- label: "Calendar",
9772
- path: "/monitoring/calendar",
9773
- surfaceType: "page",
9774
- order: 20,
9775
- targets: { systems: ["monitoring.calendar"] }
9776
- },
9777
- "monitoring-activity-log": {
9778
- type: "surface",
9779
- label: "Activity Log",
9780
- path: "/monitoring/activity-log",
9781
- surfaceType: "list",
9782
- order: 30,
9783
- targets: { systems: ["monitoring.activity-log"] }
9784
- },
9785
- "monitoring-execution-logs": {
9786
- type: "surface",
9787
- label: "Execution Logs",
9788
- path: "/monitoring/execution-logs",
9789
- surfaceType: "list",
9790
- order: 40,
9791
- targets: { systems: ["monitoring.execution-logs"] }
9792
- },
9793
- "monitoring-execution-health": {
9794
- type: "surface",
9795
- label: "Execution Health",
9796
- path: "/monitoring/execution-health",
9797
- surfaceType: "dashboard",
9798
- order: 50,
9799
- targets: { systems: ["monitoring.execution-health"] }
9800
- },
9801
- "monitoring-notifications": {
9802
- type: "surface",
9803
- label: "Notifications",
9804
- path: "/monitoring/notifications",
9805
- surfaceType: "list",
9806
- order: 60,
9807
- targets: { systems: ["monitoring.notifications"] }
9808
- },
9809
- "monitoring-requests": {
9810
- type: "surface",
9811
- label: "Requests",
9812
- path: "/monitoring/requests",
9813
- surfaceType: "list",
9814
- order: 70,
9815
- targets: { systems: ["monitoring.submitted-requests"] }
9816
- }
9817
- }
9818
- },
9819
- knowledge: {
9820
- type: "surface",
9821
- label: "Knowledge Base",
9822
- path: "/knowledge",
9823
- surfaceType: "page",
9824
- icon: "knowledge",
9825
- order: 50
9826
- }
9827
- },
9828
- bottom: {
9829
- settings: {
9830
- type: "group",
9831
- label: "Settings",
9832
- icon: "settings",
9833
- order: 10,
9834
- children: {
9835
- "settings-account": {
9836
- type: "surface",
9837
- label: "Account",
9838
- path: "/settings/account",
9839
- surfaceType: "settings",
9840
- order: 10,
9841
- targets: { systems: ["settings.account"] }
9842
- },
9843
- "settings-appearance": {
9844
- type: "surface",
9845
- label: "Appearance",
9846
- path: "/settings/appearance",
9847
- surfaceType: "settings",
9848
- order: 20,
9849
- targets: { systems: ["settings.appearance"] }
9850
- },
9851
- "settings-roles": {
9852
- type: "surface",
9853
- label: "My Roles",
9854
- path: "/settings/roles",
9855
- surfaceType: "settings",
9856
- order: 30,
9857
- targets: { systems: ["settings.roles"] }
9858
- },
9859
- "settings-organization": {
9860
- type: "surface",
9861
- label: "Organization",
9862
- path: "/settings/organization",
9863
- surfaceType: "settings",
9864
- order: 40,
9865
- targets: { systems: ["settings.organization"] }
9866
- },
9867
- "settings-credentials": {
9868
- type: "surface",
9869
- label: "Credentials",
9870
- path: "/settings/credentials",
9871
- surfaceType: "settings",
9872
- order: 50,
9873
- targets: { systems: ["settings.credentials"] }
9874
- },
9875
- "settings-api-keys": {
9876
- type: "surface",
9877
- label: "API Keys",
9878
- path: "/settings/api-keys",
9879
- surfaceType: "settings",
9880
- order: 60,
9881
- targets: { systems: ["settings.api-keys"] }
9882
- },
9883
- "settings-webhooks": {
9884
- type: "surface",
9885
- label: "Webhooks",
9886
- path: "/settings/webhooks",
9887
- surfaceType: "settings",
9888
- order: 70,
9889
- targets: { systems: ["settings.webhooks"] }
9890
- },
9891
- "settings-deployments": {
9892
- type: "surface",
9893
- label: "Deployments",
9894
- path: "/settings/deployments",
9895
- surfaceType: "settings",
9896
- order: 80,
9897
- targets: { systems: ["settings.deployments"] }
9898
- }
9899
- }
9900
- },
9901
- admin: {
9902
- type: "group",
9903
- label: "Admin",
9904
- icon: "admin",
9905
- order: 20,
9906
- children: {
9907
- "admin-dashboard": {
9908
- type: "surface",
9909
- label: "Dashboard",
9910
- path: "/admin/dashboard",
9911
- surfaceType: "dashboard",
9912
- order: 10,
9913
- targets: { systems: ["admin"] },
9914
- requiresAdmin: true
9915
- },
9916
- "admin-system-health": {
9917
- type: "surface",
9918
- label: "System Health",
9919
- path: "/admin/system-health",
9920
- surfaceType: "dashboard",
9921
- order: 20,
9922
- targets: { systems: ["admin.system-health"] },
9923
- requiresAdmin: true
9924
- },
9925
- "admin-organizations": {
9926
- type: "surface",
9927
- label: "Organizations",
9928
- path: "/admin/organizations",
9929
- surfaceType: "list",
9930
- order: 30,
9931
- targets: { systems: ["admin.organizations"] },
9932
- requiresAdmin: true
9933
- },
9934
- "admin-users": {
9935
- type: "surface",
9936
- label: "Users",
9937
- path: "/admin/users",
9938
- surfaceType: "list",
9939
- order: 40,
9940
- targets: { systems: ["admin.users"] },
9941
- requiresAdmin: true
9942
- },
9943
- "admin-design-showcase": {
9944
- type: "surface",
9945
- label: "Design Showcase",
9946
- path: "/admin/design-showcase",
9947
- surfaceType: "page",
9948
- order: 50,
9949
- targets: { systems: ["admin.design-showcase"] },
9950
- requiresAdmin: true
9951
- },
9952
- "admin-debug": {
9953
- type: "surface",
9954
- label: "Debug",
9955
- path: "/admin/debug",
9956
- surfaceType: "page",
9957
- order: 60,
9958
- targets: { systems: ["admin.debug"] },
9959
- requiresAdmin: true
9960
- }
9961
- }
9962
- }
9963
- }
9015
+ primary: {},
9016
+ bottom: {}
9964
9017
  }
9965
9018
  };
9966
9019
  var DEFAULT_ORGANIZATION_MODEL = {
@@ -9973,408 +9026,159 @@ var DEFAULT_ORGANIZATION_MODEL = {
9973
9026
  offerings: DEFAULT_ORGANIZATION_MODEL_OFFERINGS,
9974
9027
  roles: DEFAULT_ORGANIZATION_MODEL_ROLES,
9975
9028
  goals: DEFAULT_ORGANIZATION_MODEL_GOALS,
9976
- systems: {
9977
- dashboard: {
9978
- id: "dashboard",
9979
- order: 10,
9980
- label: "Dashboard",
9981
- enabled: true,
9982
- lifecycle: "active",
9983
- path: "/",
9984
- icon: "dashboard"
9985
- },
9986
- platform: {
9987
- id: "platform",
9988
- order: 30,
9989
- label: "Platform",
9990
- description: "Elevasis platform architecture, capabilities, and implementation patterns",
9991
- enabled: true,
9992
- lifecycle: "active",
9993
- color: "cyan",
9994
- icon: "platform"
9995
- },
9996
- finance: {
9997
- id: "finance",
9998
- order: 40,
9999
- label: "Finance",
10000
- description: "Finance operations, accounting, billing, reconciliation, and tax prep",
10001
- enabled: true,
10002
- lifecycle: "active",
10003
- color: "green",
10004
- icon: "finance"
10005
- },
10006
- sales: {
10007
- id: "sales",
10008
- order: 60,
10009
- label: "Sales",
10010
- description: "Revenue workflows and customer acquisition",
10011
- enabled: true,
10012
- lifecycle: "active",
10013
- color: "blue",
10014
- icon: "sales",
10015
- path: "/sales"
10016
- },
10017
- "sales.crm": {
10018
- id: "sales.crm",
10019
- order: 70,
10020
- label: "CRM",
10021
- description: "Relationship pipeline and deal management",
10022
- enabled: true,
10023
- lifecycle: "active",
10024
- actions: Object.values(CRM_ACTION_ENTRIES).map((action) => ({
10025
- actionId: action.id,
10026
- intent: "exposes"
10027
- })),
10028
- color: "blue",
10029
- icon: "crm",
10030
- path: "/crm"
10031
- },
10032
- "sales.lead-gen": {
10033
- id: "sales.lead-gen",
10034
- order: 80,
10035
- label: "Lead Gen",
10036
- description: "Prospecting, qualification, and outreach preparation",
10037
- enabled: true,
10038
- lifecycle: "active",
10039
- actions: Object.values(LEAD_GEN_ACTION_ENTRIES).map((action) => ({
10040
- actionId: action.id,
10041
- intent: "exposes"
10042
- })),
10043
- color: "cyan",
10044
- icon: "lead-gen",
10045
- path: "/lead-gen"
10046
- },
10047
- projects: {
10048
- id: "projects",
10049
- order: 90,
10050
- label: "Projects",
10051
- description: "Projects, milestones, and client work execution",
10052
- enabled: true,
10053
- lifecycle: "active",
10054
- color: "orange",
10055
- icon: "projects",
10056
- path: "/projects"
10057
- },
10058
- clients: {
10059
- id: "clients",
10060
- order: 100,
10061
- label: "Clients",
10062
- description: "Client relationships, accounts, and business context",
10063
- enabled: true,
10064
- lifecycle: "active",
10065
- color: "orange",
10066
- icon: "clients",
10067
- path: "/clients"
10068
- },
10069
- operations: {
10070
- id: "operations",
10071
- order: 110,
10072
- label: "Operations",
10073
- description: "Operational resources, topology, and orchestration visibility",
10074
- enabled: true,
10075
- lifecycle: "active",
10076
- color: "violet",
10077
- icon: "operations"
10078
- },
10079
- "knowledge.command-view": {
10080
- id: "knowledge.command-view",
10081
- order: 120,
10082
- label: "Command View",
10083
- enabled: true,
10084
- lifecycle: "active",
10085
- path: "/knowledge/command-view",
10086
- devOnly: true
10087
- },
10088
- "operations.overview": {
10089
- id: "operations.overview",
10090
- order: 130,
10091
- label: "Overview",
10092
- enabled: true,
10093
- lifecycle: "active",
10094
- path: "/operations"
10095
- },
10096
- "operations.resources": {
10097
- id: "operations.resources",
10098
- order: 140,
10099
- label: "Resources",
10100
- enabled: true,
10101
- lifecycle: "active",
10102
- path: "/operations/resources"
10103
- },
10104
- "operations.command-queue": {
10105
- id: "operations.command-queue",
10106
- order: 150,
10107
- label: "Command Queue",
10108
- enabled: true,
10109
- lifecycle: "active",
10110
- path: "/operations/command-queue"
10111
- },
10112
- "operations.sessions": {
10113
- id: "operations.sessions",
10114
- order: 160,
10115
- label: "Sessions",
10116
- enabled: false,
10117
- lifecycle: "deprecated",
10118
- path: "/operations/sessions"
10119
- },
10120
- "operations.task-scheduler": {
10121
- id: "operations.task-scheduler",
10122
- order: 170,
10123
- label: "Task Scheduler",
10124
- enabled: true,
10125
- lifecycle: "active",
10126
- path: "/operations/task-scheduler"
10127
- },
10128
- monitoring: {
10129
- id: "monitoring",
10130
- order: 180,
10131
- label: "Monitoring",
10132
- enabled: true,
10133
- lifecycle: "active"
10134
- },
10135
- "monitoring.calendar": {
10136
- id: "monitoring.calendar",
10137
- order: 190,
10138
- label: "Calendar",
10139
- description: "Google Calendar events and agenda views",
10140
- enabled: true,
10141
- lifecycle: "active",
10142
- path: "/monitoring/calendar",
10143
- icon: "calendar"
10144
- },
10145
- "monitoring.activity-log": {
10146
- id: "monitoring.activity-log",
10147
- order: 200,
10148
- label: "Activity Log",
10149
- enabled: true,
10150
- lifecycle: "active",
10151
- path: "/monitoring/activity-log"
10152
- },
10153
- "monitoring.execution-logs": {
10154
- id: "monitoring.execution-logs",
10155
- order: 210,
10156
- label: "Execution Logs",
10157
- enabled: true,
10158
- lifecycle: "active",
10159
- path: "/monitoring/execution-logs"
10160
- },
10161
- "monitoring.execution-health": {
10162
- id: "monitoring.execution-health",
10163
- order: 220,
10164
- label: "Execution Health",
10165
- enabled: true,
10166
- lifecycle: "active",
10167
- path: "/monitoring/execution-health"
10168
- },
10169
- "monitoring.cost-analytics": {
10170
- id: "monitoring.cost-analytics",
10171
- order: 230,
10172
- label: "Cost Analytics",
10173
- enabled: false,
10174
- lifecycle: "deprecated",
10175
- path: "/monitoring/cost-analytics"
10176
- },
10177
- "monitoring.notifications": {
10178
- id: "monitoring.notifications",
10179
- order: 240,
10180
- label: "Notifications",
10181
- enabled: true,
10182
- lifecycle: "active",
10183
- path: "/monitoring/notifications"
10184
- },
10185
- "monitoring.submitted-requests": {
10186
- id: "monitoring.submitted-requests",
10187
- order: 250,
10188
- label: "Submitted Requests",
10189
- enabled: true,
10190
- lifecycle: "active",
10191
- path: "/monitoring/requests"
10192
- },
10193
- settings: {
10194
- id: "settings",
10195
- order: 260,
10196
- label: "Settings",
10197
- enabled: true,
10198
- lifecycle: "active",
10199
- icon: "settings"
10200
- },
10201
- "settings.account": {
10202
- id: "settings.account",
10203
- order: 270,
10204
- label: "Account",
10205
- enabled: true,
10206
- lifecycle: "active",
10207
- path: "/settings/account"
10208
- },
10209
- "settings.appearance": {
10210
- id: "settings.appearance",
10211
- order: 280,
10212
- label: "Appearance",
10213
- enabled: true,
10214
- lifecycle: "active",
10215
- path: "/settings/appearance"
10216
- },
10217
- "settings.roles": {
10218
- id: "settings.roles",
10219
- order: 290,
10220
- label: "My Roles",
10221
- enabled: true,
10222
- lifecycle: "active",
10223
- path: "/settings/roles"
10224
- },
10225
- "settings.organization": {
10226
- id: "settings.organization",
10227
- order: 300,
10228
- label: "Organization",
10229
- enabled: true,
10230
- lifecycle: "active",
10231
- path: "/settings/organization"
10232
- },
10233
- "settings.credentials": {
10234
- id: "settings.credentials",
10235
- order: 310,
10236
- label: "Credentials",
10237
- enabled: true,
10238
- lifecycle: "active",
10239
- path: "/settings/credentials"
10240
- },
10241
- "settings.api-keys": {
10242
- id: "settings.api-keys",
10243
- order: 320,
10244
- label: "API Keys",
10245
- enabled: true,
10246
- lifecycle: "active",
10247
- path: "/settings/api-keys"
10248
- },
10249
- "settings.webhooks": {
10250
- id: "settings.webhooks",
10251
- order: 330,
10252
- label: "Webhooks",
10253
- enabled: true,
10254
- lifecycle: "active",
10255
- path: "/settings/webhooks"
10256
- },
10257
- "settings.deployments": {
10258
- id: "settings.deployments",
10259
- order: 340,
10260
- label: "Deployments",
10261
- enabled: true,
10262
- lifecycle: "active",
10263
- path: "/settings/deployments"
10264
- },
10265
- admin: {
10266
- id: "admin",
10267
- order: 350,
10268
- label: "Admin",
10269
- enabled: true,
10270
- lifecycle: "active",
10271
- path: "/admin",
10272
- icon: "admin",
10273
- requiresAdmin: true
10274
- },
10275
- "admin.system-health": {
10276
- id: "admin.system-health",
10277
- order: 360,
10278
- label: "System Health",
10279
- enabled: true,
10280
- lifecycle: "active",
10281
- path: "/admin/system-health"
10282
- },
10283
- "admin.organizations": {
10284
- id: "admin.organizations",
10285
- order: 370,
10286
- label: "Organizations",
10287
- enabled: true,
10288
- lifecycle: "active",
10289
- path: "/admin/organizations"
10290
- },
10291
- "admin.users": {
10292
- id: "admin.users",
10293
- order: 380,
10294
- label: "Users",
10295
- enabled: true,
10296
- lifecycle: "active",
10297
- path: "/admin/users"
10298
- },
10299
- "admin.design-showcase": {
10300
- id: "admin.design-showcase",
10301
- order: 390,
10302
- label: "Design Showcase",
10303
- enabled: true,
10304
- lifecycle: "active",
10305
- path: "/admin/design-showcase"
10306
- },
10307
- "admin.debug": {
10308
- id: "admin.debug",
10309
- order: 400,
10310
- label: "Debug",
10311
- enabled: true,
10312
- lifecycle: "active",
10313
- path: "/admin/debug"
10314
- },
10315
- archive: {
10316
- id: "archive",
10317
- order: 410,
10318
- label: "Archive",
10319
- enabled: true,
10320
- lifecycle: "active",
10321
- path: "/archive",
10322
- icon: "archive",
10323
- devOnly: true
10324
- },
10325
- "archive.agent-chat": {
10326
- id: "archive.agent-chat",
10327
- order: 420,
10328
- label: "Agent Chat",
10329
- enabled: true,
10330
- lifecycle: "active",
10331
- path: "/archive/agent-chat"
10332
- },
10333
- "archive.execution-runner": {
10334
- id: "archive.execution-runner",
10335
- order: 430,
10336
- label: "Execution Runner",
10337
- enabled: true,
10338
- lifecycle: "active",
10339
- path: "/archive/execution-runner"
10340
- },
10341
- seo: {
10342
- id: "seo",
10343
- order: 440,
10344
- label: "SEO",
10345
- enabled: false,
10346
- lifecycle: "deprecated",
10347
- path: "/seo"
10348
- },
10349
- knowledge: {
10350
- id: "knowledge",
10351
- order: 450,
10352
- label: "Knowledge",
10353
- description: "Operational knowledge, playbooks, and strategy docs",
10354
- enabled: true,
10355
- lifecycle: "active",
10356
- color: "teal",
10357
- icon: "knowledge"
10358
- },
10359
- "knowledge.base": {
10360
- id: "knowledge.base",
10361
- order: 460,
10362
- label: "Knowledge Base",
10363
- enabled: true,
10364
- lifecycle: "active",
10365
- path: "/knowledge"
10366
- }
10367
- },
9029
+ // Generic empty systems map. Elevasis-specific systems (platform, sales, sales.crm,
9030
+ // sales.lead-gen, monitoring, settings, admin, etc.) have been relocated to
9031
+ // `@repo/elevasis-core/src/organization-model/systems.ts` via `canonicalOrganizationModel`.
9032
+ // Tenant OM configs supply their own systems via `resolveOrganizationModel`.
9033
+ systems: {},
10368
9034
  ontology: DEFAULT_ONTOLOGY_SCOPE,
10369
9035
  resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
10370
9036
  topology: DEFAULT_ORGANIZATION_MODEL_TOPOLOGY,
10371
- actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
9037
+ // Generic empty actions map. Elevasis-specific action entries have been relocated to
9038
+ // `@repo/elevasis-core/src/organization-model/actions.ts`.
9039
+ actions: {},
10372
9040
  entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
10373
9041
  policies: DEFAULT_ORGANIZATION_MODEL_POLICIES,
10374
- // Phase 4 (D1): statuses top-level field removed; bridge status mirrors may
10375
- // still project from System.content, but primary authoring belongs in ontology.
10376
9042
  knowledge: DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE
10377
9043
  };
9044
+ var SalesStageSemanticClassSchema = z.enum(["open", "active", "nurturing", "closed_won", "closed_lost"]);
9045
+ var SalesStageSchema = DisplayMetadataSchema.extend({
9046
+ id: ModelIdSchema,
9047
+ order: z.number().int().min(0),
9048
+ semanticClass: SalesStageSemanticClassSchema,
9049
+ surfaceIds: ReferenceIdsSchema,
9050
+ resourceIds: ReferenceIdsSchema
9051
+ });
9052
+ z.object({
9053
+ id: ModelIdSchema,
9054
+ label: z.string().trim().min(1).max(120),
9055
+ description: DescriptionSchema.optional(),
9056
+ entityId: ModelIdSchema,
9057
+ stages: z.array(SalesStageSchema).min(1)
9058
+ });
9059
+ var CRM_DISCOVERY_REPLIED_STATE = {
9060
+ stateKey: "discovery_replied",
9061
+ label: "Discovery Replied"
9062
+ };
9063
+ var CRM_DISCOVERY_LINK_SENT_STATE = {
9064
+ stateKey: "discovery_link_sent",
9065
+ label: "Discovery Link Sent"
9066
+ };
9067
+ var CRM_DISCOVERY_NUDGING_STATE = {
9068
+ stateKey: "discovery_nudging",
9069
+ label: "Discovery Nudging"
9070
+ };
9071
+ var CRM_DISCOVERY_BOOKING_CANCELLED_STATE = {
9072
+ stateKey: "discovery_booking_cancelled",
9073
+ label: "Discovery Booking Cancelled"
9074
+ };
9075
+ var CRM_REPLY_SENT_STATE = {
9076
+ stateKey: "reply_sent",
9077
+ label: "Reply Sent"
9078
+ };
9079
+ var CRM_FOLLOWUP_1_SENT_STATE = {
9080
+ stateKey: "followup_1_sent",
9081
+ label: "Follow-up 1 Sent"
9082
+ };
9083
+ var CRM_FOLLOWUP_2_SENT_STATE = {
9084
+ stateKey: "followup_2_sent",
9085
+ label: "Follow-up 2 Sent"
9086
+ };
9087
+ var CRM_FOLLOWUP_3_SENT_STATE = {
9088
+ stateKey: "followup_3_sent",
9089
+ label: "Follow-up 3 Sent"
9090
+ };
9091
+ var CRM_PIPELINE_DEFINITION = {
9092
+ pipelineKey: "crm",
9093
+ label: "CRM",
9094
+ entityKey: "crm.deal",
9095
+ stages: [
9096
+ {
9097
+ stageKey: "interested",
9098
+ label: "Interested",
9099
+ color: "blue",
9100
+ states: [
9101
+ CRM_DISCOVERY_REPLIED_STATE,
9102
+ CRM_DISCOVERY_LINK_SENT_STATE,
9103
+ CRM_DISCOVERY_NUDGING_STATE,
9104
+ CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
9105
+ CRM_REPLY_SENT_STATE,
9106
+ CRM_FOLLOWUP_1_SENT_STATE,
9107
+ CRM_FOLLOWUP_2_SENT_STATE,
9108
+ CRM_FOLLOWUP_3_SENT_STATE
9109
+ ]
9110
+ },
9111
+ { stageKey: "proposal", label: "Proposal", color: "yellow", states: [] },
9112
+ { stageKey: "closing", label: "Closing", color: "orange", states: [] },
9113
+ { stageKey: "closed_won", label: "Closed Won", color: "green", states: [] },
9114
+ { stageKey: "closed_lost", label: "Closed Lost", color: "red", states: [] },
9115
+ { stageKey: "nurturing", label: "Nurturing", color: "grape", states: [] }
9116
+ ]
9117
+ };
9118
+
9119
+ // ../core/src/organization-model/migration-helpers.ts
9120
+ function catalogRecords(model) {
9121
+ return Object.values(compileOrganizationOntology(model).ontology.catalogTypes);
9122
+ }
9123
+ function systemScope(id, fallback) {
9124
+ return parseOntologyId(id).scope || fallback || "";
9125
+ }
9126
+ function entriesOf(catalog) {
9127
+ return Object.entries(catalog.entries ?? {}).map(([id, value]) => [
9128
+ id,
9129
+ value && typeof value === "object" && !Array.isArray(value) ? value : {}
9130
+ ]);
9131
+ }
9132
+ function stringValue(value) {
9133
+ return typeof value === "string" ? value : void 0;
9134
+ }
9135
+ function stringArray(value) {
9136
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
9137
+ }
9138
+ function numberValue(value, fallback = 0) {
9139
+ return typeof value === "number" ? value : fallback;
9140
+ }
9141
+ function appliesToLocalId(catalog) {
9142
+ const appliesTo = catalog.appliesTo;
9143
+ if (appliesTo === void 0) return void 0;
9144
+ return parseOntologyId(appliesTo).localId;
9145
+ }
9146
+ function appliesToEntityKind(catalog) {
9147
+ const id = appliesToLocalId(catalog);
9148
+ if (id === "company" || id === "contact" || id === "project" || id === "milestone" || id === "task") return id;
9149
+ if (id === "deal") return void 0;
9150
+ return void 0;
9151
+ }
9152
+ function getLeadGenStageCatalog(model) {
9153
+ const results = {};
9154
+ for (const catalog of catalogRecords(model).filter(
9155
+ (record) => record.kind === "stage" && (record.ownerSystemId ?? systemScope(record.id)) === "sales.lead-gen"
9156
+ )) {
9157
+ const catalogEntity = appliesToEntityKind(catalog);
9158
+ if (catalogEntity !== "company" && catalogEntity !== "contact") continue;
9159
+ for (const [entryId, entry] of entriesOf(catalog)) {
9160
+ const entity = entry.entity === "contact" ? "contact" : entry.entity === "company" ? "company" : catalogEntity;
9161
+ const additionalEntities = stringArray(entry.additionalEntities).filter(
9162
+ (item) => item === "company" || item === "contact"
9163
+ );
9164
+ const recordEntity = entry.recordEntity === "company" || entry.recordEntity === "contact" ? entry.recordEntity : void 0;
9165
+ const recordStageKey = stringValue(entry.recordStageKey);
9166
+ results[entryId] = {
9167
+ key: entryId,
9168
+ label: stringValue(entry.label) ?? entryId,
9169
+ description: stringValue(entry.description) ?? "",
9170
+ order: numberValue(entry.order),
9171
+ entity,
9172
+ ...additionalEntities.length > 0 ? { additionalEntities } : {},
9173
+ ...recordEntity ? { recordEntity } : {},
9174
+ ...recordStageKey ? { recordStageKey } : {}
9175
+ };
9176
+ }
9177
+ }
9178
+ return Object.fromEntries(
9179
+ Object.entries(results).sort(([, a3], [, b2]) => a3.order - b2.order || a3.key.localeCompare(b2.key))
9180
+ );
9181
+ }
10378
9182
 
10379
9183
  // ../core/src/business/acquisition/ontology-validation.ts
10380
9184
  var CRM_PIPELINE_CATALOG_ONTOLOGY_ID = formatOntologyId({
@@ -10415,14 +9219,14 @@ function createCrmPipelineCatalog() {
10415
9219
  legacyEntityKey: CRM_PIPELINE_DEFINITION.entityKey
10416
9220
  };
10417
9221
  }
10418
- function createLeadGenStageCatalog() {
9222
+ function createLeadGenStageCatalog(model) {
10419
9223
  return {
10420
9224
  id: LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID,
10421
9225
  label: "Lead Gen Processing Stages",
10422
9226
  ownerSystemId: "sales.lead-gen",
10423
9227
  kind: "processing-stage-catalog",
10424
9228
  entries: Object.fromEntries(
10425
- Object.entries(LEAD_GEN_STAGE_CATALOG).map(([key, entry]) => [
9229
+ Object.entries(getLeadGenStageCatalog(model)).map(([key, entry]) => [
10426
9230
  key,
10427
9231
  {
10428
9232
  ...entry
@@ -10442,7 +9246,7 @@ function mergeBridgeCatalogs(model) {
10442
9246
  bridgeCatalogTypes[CRM_PIPELINE_CATALOG_ONTOLOGY_ID] = createCrmPipelineCatalog();
10443
9247
  }
10444
9248
  if (baseCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] === void 0) {
10445
- bridgeCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog();
9249
+ bridgeCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog(model);
10446
9250
  }
10447
9251
  if (Object.keys(bridgeCatalogTypes).length === 0) return model;
10448
9252
  return {
@@ -10511,25 +9315,6 @@ function asCrmStageEntry(key, value) {
10511
9315
  states
10512
9316
  };
10513
9317
  }
10514
- function asLeadGenStageEntry(key, value) {
10515
- const record = isPlainRecord(value) ? value : {};
10516
- const entity = record.entity === "contact" ? "contact" : "company";
10517
- const additionalEntities = Array.isArray(record.additionalEntities) ? record.additionalEntities.filter(
10518
- (item) => item === "company" || item === "contact"
10519
- ) : void 0;
10520
- const recordEntity = record.recordEntity === "company" || record.recordEntity === "contact" ? record.recordEntity : void 0;
10521
- const recordStageKey = typeof record.recordStageKey === "string" ? record.recordStageKey : void 0;
10522
- return {
10523
- key: typeof record.key === "string" ? record.key : key,
10524
- label: typeof record.label === "string" ? record.label : key,
10525
- description: typeof record.description === "string" ? record.description : "",
10526
- order: typeof record.order === "number" ? record.order : 0,
10527
- entity,
10528
- ...additionalEntities !== void 0 ? { additionalEntities } : {},
10529
- ...recordEntity !== void 0 ? { recordEntity } : {},
10530
- ...recordStageKey !== void 0 ? { recordStageKey } : {}
10531
- };
10532
- }
10533
9318
  var CRM_STAGE_KEYS_FROM_ONTOLOGY = Object.keys(
10534
9319
  getCatalogEntries(BUSINESS_ONTOLOGY_VALIDATION_INDEX.crmPipelineCatalog)
10535
9320
  );
@@ -10543,36 +9328,11 @@ var CRM_STATE_KEYS_FROM_ONTOLOGY = Object.values(
10543
9328
  Object.keys(
10544
9329
  getCatalogEntries(BUSINESS_ONTOLOGY_VALIDATION_INDEX.leadGenStageCatalog)
10545
9330
  );
10546
- function getLeadGenStageCatalogFromOntology() {
10547
- return Object.fromEntries(
10548
- Object.entries(getCatalogEntries(BUSINESS_ONTOLOGY_VALIDATION_INDEX.leadGenStageCatalog)).map(([key, value]) => [
10549
- key,
10550
- asLeadGenStageEntry(key, value)
10551
- ])
10552
- );
10553
- }
10554
- function getLeadGenStageEntry(stageKey) {
10555
- return getLeadGenStageCatalogFromOntology()[stageKey];
10556
- }
10557
- function isLeadGenStageKey(stageKey) {
10558
- return getLeadGenStageEntry(stageKey) !== void 0;
10559
- }
10560
- function isLeadGenRecordStageValidForEntity(stageKey, entity) {
10561
- const stage = getLeadGenStageEntry(stageKey);
10562
- return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true || stage.recordEntity === entity);
10563
- }
10564
- function isLeadGenActionKey(actionKey) {
10565
- return actionKey.startsWith("lead-gen.") && BUSINESS_ONTOLOGY_VALIDATION_INDEX.actionTypesByLegacyId[actionKey] !== void 0;
10566
- }
10567
9331
 
10568
9332
  // ../core/src/business/acquisition/api-schemas.ts
10569
9333
  var ProcessingStageStatusSchema = z.enum(["success", "no_result", "skipped", "error"]);
10570
- var LeadGenStageKeySchema = z.string().refine((value) => isLeadGenStageKey(value), {
10571
- message: "processing state key must match LEAD_GEN_STAGE_CATALOG"
10572
- });
10573
- var LeadGenActionKeySchema = z.string().refine((value) => isLeadGenActionKey(value), {
10574
- message: "actionKey must match ACTION_REGISTRY"
10575
- });
9334
+ var LeadGenStageKeySchema = z.string().trim().min(1);
9335
+ var LeadGenActionKeySchema = z.string().trim().min(1);
10576
9336
  var crmStageKeys = CRM_STAGE_KEYS_FROM_ONTOLOGY;
10577
9337
  var crmStateKeys = CRM_STATE_KEYS_FROM_ONTOLOGY;
10578
9338
  var CrmStageKeySchema = z.enum(crmStageKeys);
@@ -10628,7 +9388,7 @@ z.object({
10628
9388
  expectedUpdatedAt: z.string().datetime().optional()
10629
9389
  }).strict();
10630
9390
  z.object({
10631
- pipelineKey: z.literal(CRM_PIPELINE_DEFINITION.pipelineKey),
9391
+ pipelineKey: z.string().min(1),
10632
9392
  stageKey: CrmStageKeySchema,
10633
9393
  stateKey: CrmStateKeySchema.nullable().optional(),
10634
9394
  reason: z.string().optional(),
@@ -10829,9 +9589,7 @@ var IcpRubricSchema = z.object({
10829
9589
  customRules: z.string().optional()
10830
9590
  });
10831
9591
  var PipelineStageSchema = z.object({
10832
- key: z.string().refine((value) => isLeadGenStageKey(value), {
10833
- message: "pipeline stage key must match LEAD_GEN_STAGE_CATALOG"
10834
- }),
9592
+ key: LeadGenStageKeySchema,
10835
9593
  label: z.string().optional(),
10836
9594
  enabled: z.boolean().optional(),
10837
9595
  order: z.number().int().optional()
@@ -11299,16 +10057,7 @@ z.object({
11299
10057
  stage: LeadGenStageKeySchema.optional(),
11300
10058
  limit: z.coerce.number().int().min(1).max(500).default(50),
11301
10059
  offset: z.coerce.number().int().min(0).default(0)
11302
- }).strict().superRefine((query, ctx) => {
11303
- if (!query.stage) return;
11304
- if (!isLeadGenRecordStageValidForEntity(query.stage, query.entity)) {
11305
- ctx.addIssue({
11306
- code: z.ZodIssueCode.custom,
11307
- message: `stage "${query.stage}" is not valid for ${query.entity} records`,
11308
- path: ["stage"]
11309
- });
11310
- }
11311
- });
10060
+ }).strict();
11312
10061
  z.object({
11313
10062
  memberId: UuidSchema
11314
10063
  });
@@ -11785,6 +10534,17 @@ function listAllSystems(model) {
11785
10534
  walk(model.systems, "");
11786
10535
  return results;
11787
10536
  }
10537
+ z.object({
10538
+ success: z.boolean(),
10539
+ tool: z.string(),
10540
+ method: z.string(),
10541
+ result: z.unknown().optional(),
10542
+ error: z.string().optional(),
10543
+ durationMs: z.number().optional()
10544
+ });
10545
+ z.object({
10546
+ credential: z.string().describe("Credential name registered for this integration")
10547
+ });
11788
10548
 
11789
10549
  // ../core/src/platform/registry/validation.ts
11790
10550
  var RegistryValidationError = class extends Error {
@@ -11843,7 +10603,7 @@ function hasOntologySources(organizationModel) {
11843
10603
  return organizationModel.ontology !== void 0 || organizationModel.entities !== void 0 || organizationModel.actions !== void 0 || Object.values(organizationModel.systems ?? {}).some(systemHasOntologySource);
11844
10604
  }
11845
10605
  function systemHasOntologySource(system) {
11846
- if (system.ontology !== void 0 || system.content !== void 0 && Object.keys(system.content).length > 0) return true;
10606
+ if (system.ontology !== void 0) return true;
11847
10607
  return Object.values(system.systems ?? system.subsystems ?? {}).some(systemHasOntologySource);
11848
10608
  }
11849
10609
  function ontologyIndexForKind(index2, kind) {
@@ -11876,7 +10636,8 @@ function sameJson(left, right) {
11876
10636
  function addOntologyBindingIssues(issues, orgName, resource, ontologyIndex) {
11877
10637
  const binding = resource.ontology;
11878
10638
  if (binding === void 0) return;
11879
- if ((resource.kind === "workflow" || resource.kind === "agent") && (binding.actions?.length ?? 0) === 0) {
10639
+ const hasOperationalOntologyBinding = binding.primaryAction !== void 0 || (binding.reads?.length ?? 0) > 0 || (binding.writes?.length ?? 0) > 0 || (binding.usesCatalogs?.length ?? 0) > 0 || (binding.emits?.length ?? 0) > 0;
10640
+ if ((resource.kind === "workflow" || resource.kind === "agent") && hasOperationalOntologyBinding && (binding.actions?.length ?? 0) === 0) {
11880
10641
  addGovernanceIssue(
11881
10642
  issues,
11882
10643
  "missing-ontology-actions",
@@ -12379,8 +11140,7 @@ function validateHumanCheckpoints(orgName, humanCheckpoints, allInternalIds, val
12379
11140
  });
12380
11141
  });
12381
11142
  }
12382
- var listBuilderStageKeys = Object.keys(LEAD_GEN_STAGE_CATALOG);
12383
- var ListBuilderStageKeySchema = z.enum(listBuilderStageKeys);
11143
+ var ListBuilderStageKeySchema = z.string().min(1);
12384
11144
 
12385
11145
  // src/worker/list-builder-workflow.ts
12386
11146
  var ListBuilderResultSchema = z.object({