@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 { createHmac } from 'crypto';
3
4
 
4
5
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
6
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -3623,8 +3624,8 @@ async function processMemory(memoryManager, response, logger, iteration) {
3623
3624
  continue;
3624
3625
  }
3625
3626
  const startTime = Date.now();
3626
- const stringValue = typeof content === "string" ? content : JSON.stringify(content);
3627
- memoryManager.set(key, stringValue);
3627
+ const stringValue2 = typeof content === "string" ? content : JSON.stringify(content);
3628
+ memoryManager.set(key, stringValue2);
3628
3629
  const endTime = Date.now();
3629
3630
  logger.action("memory-set", `Set: ${key}`, iteration, startTime, endTime, endTime - startTime);
3630
3631
  }
@@ -4911,226 +4912,7 @@ var ActionSchema = z.object({
4911
4912
  var ActionsDomainSchema = z.record(z.string(), ActionSchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
4912
4913
  message: "Each action entry id must match its map key"
4913
4914
  }).default({});
4914
- var LEAD_GEN_ACTION_ENTRY_INPUTS = [
4915
- {
4916
- id: "lead-gen.company.source",
4917
- order: 10,
4918
- label: "Source companies",
4919
- description: "Import source companies from a list provider.",
4920
- scope: { domain: "sales" },
4921
- resourceId: "lgn-import-workflow",
4922
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/source" }]
4923
- },
4924
- {
4925
- id: "lead-gen.company.apollo-import",
4926
- order: 20,
4927
- label: "Import from Apollo",
4928
- description: "Pull companies and seed contact data from an Apollo search or list.",
4929
- scope: { domain: "sales" },
4930
- resourceId: "lgn-01c-apollo-import-workflow",
4931
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/apollo-import" }]
4932
- },
4933
- {
4934
- id: "lead-gen.contact.discover",
4935
- order: 30,
4936
- label: "Discover contact emails",
4937
- description: "Find email addresses for contacts at qualified companies.",
4938
- scope: { domain: "sales" },
4939
- resourceId: "lgn-04-email-discovery-workflow",
4940
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/discover" }]
4941
- },
4942
- {
4943
- id: "lead-gen.contact.verify-email",
4944
- order: 40,
4945
- label: "Verify emails",
4946
- description: "Check email deliverability before outreach.",
4947
- scope: { domain: "sales" },
4948
- resourceId: "lgn-05-email-verification-workflow",
4949
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/verify-email" }]
4950
- },
4951
- {
4952
- id: "lead-gen.company.apify-crawl",
4953
- order: 50,
4954
- label: "Crawl websites",
4955
- description: "Crawl company websites via Apify and store raw page markdown in enrichmentData.websiteCrawl.pages for downstream LLM analysis.",
4956
- scope: { domain: "sales" },
4957
- resourceId: "lgn-02a-apify-website-crawl-workflow",
4958
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/apify-crawl" }]
4959
- },
4960
- {
4961
- id: "lead-gen.company.website-extract",
4962
- order: 60,
4963
- label: "Extract website signals",
4964
- description: "Scrape and analyze company websites for qualification signals.",
4965
- scope: { domain: "sales" },
4966
- resourceId: "lgn-02-website-extract-workflow",
4967
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/website-extract" }]
4968
- },
4969
- {
4970
- id: "lead-gen.company.qualify",
4971
- order: 70,
4972
- label: "Qualify companies",
4973
- description: "Score and filter companies against the ICP rubric.",
4974
- scope: { domain: "sales" },
4975
- resourceId: "lgn-03-company-qualification-workflow",
4976
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/qualify" }]
4977
- },
4978
- {
4979
- id: "lead-gen.company.dtc-subscription-qualify",
4980
- order: 80,
4981
- label: "Qualify DTC subscription fit",
4982
- description: "Classify subscription potential and consumable-product fit for DTC brands.",
4983
- scope: { domain: "sales" },
4984
- resourceId: "lgn-03b-dtc-subscription-score-workflow",
4985
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/dtc-subscription-qualify" }]
4986
- },
4987
- {
4988
- id: "lead-gen.contact.apollo-decision-maker-enrich",
4989
- order: 90,
4990
- label: "Enrich decision-makers",
4991
- description: "Find and enrich qualified contacts at qualified companies via Apollo.",
4992
- scope: { domain: "sales" },
4993
- resourceId: "lgn-04b-apollo-decision-maker-enrich-workflow",
4994
- invocations: [
4995
- { kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/apollo-decision-maker-enrich" }
4996
- ]
4997
- },
4998
- {
4999
- id: "lead-gen.contact.personalize",
5000
- order: 100,
5001
- label: "Personalize outreach",
5002
- description: "Generate personalized opening lines for each contact.",
5003
- scope: { domain: "sales" },
5004
- resourceId: "ist-personalization-workflow",
5005
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/contacts/personalize" }]
5006
- },
5007
- {
5008
- id: "lead-gen.review.outreach-ready",
5009
- order: 110,
5010
- label: "Upload to outreach",
5011
- description: "Upload approved contacts to the outreach sequence after QC review.",
5012
- scope: { domain: "sales" },
5013
- resourceId: "ist-upload-contacts-workflow",
5014
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/review/outreach-ready" }]
5015
- },
5016
- {
5017
- id: "lead-gen.export.list",
5018
- order: 120,
5019
- label: "Export lead list",
5020
- description: "Export approved leads as a downloadable lead list.",
5021
- scope: { domain: "sales" },
5022
- resourceId: "lgn-06-export-list-workflow",
5023
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/export/list" }]
5024
- },
5025
- {
5026
- id: "lead-gen.company.cleanup",
5027
- order: 130,
5028
- label: "Clean up companies",
5029
- description: "Remove disqualified or duplicate companies from the list.",
5030
- scope: { domain: "sales" },
5031
- resourceId: "lgn-company-cleanup-workflow",
5032
- invocations: [{ kind: "api-endpoint", method: "POST", path: "/api/prospecting/companies/cleanup" }]
5033
- }
5034
- ];
5035
- var LEAD_GEN_ACTION_ENTRIES = Object.fromEntries(
5036
- LEAD_GEN_ACTION_ENTRY_INPUTS.map((action) => {
5037
- const parsed = ActionSchema.parse(action);
5038
- return [parsed.id, parsed];
5039
- })
5040
- );
5041
- var CRM_ACTION_ENTRY_INPUTS = [
5042
- {
5043
- id: "send_reply",
5044
- order: 210,
5045
- label: "Send Reply",
5046
- description: "Send a contextual reply for an active CRM deal.",
5047
- scope: { domain: "sales" },
5048
- resourceId: "crm-send-reply-workflow",
5049
- affects: ["crm.deal"]
5050
- },
5051
- {
5052
- id: "send_link",
5053
- order: 220,
5054
- label: "Send Booking Link",
5055
- description: "Send a booking link to move a deal toward a scheduled call.",
5056
- scope: { domain: "sales" },
5057
- resourceId: "crm-send-booking-link-workflow",
5058
- affects: ["crm.deal"]
5059
- },
5060
- {
5061
- id: "send_nudge",
5062
- order: 230,
5063
- label: "Send Nudge",
5064
- description: "Send a follow-up nudge for a stalled CRM deal.",
5065
- scope: { domain: "sales" },
5066
- resourceId: "crm-send-nudge-workflow",
5067
- affects: ["crm.deal"]
5068
- },
5069
- {
5070
- id: "rebook",
5071
- order: 240,
5072
- label: "Rebook",
5073
- description: "Rebook a missed or rescheduled CRM appointment.",
5074
- scope: { domain: "sales" },
5075
- resourceId: "crm-rebook-workflow",
5076
- affects: ["crm.deal"]
5077
- },
5078
- {
5079
- id: "move_to_proposal",
5080
- order: 250,
5081
- label: "Move to Proposal",
5082
- description: "Advance a qualified CRM deal into the proposal stage.",
5083
- scope: { domain: "sales" },
5084
- resourceId: "move_to_proposal-workflow",
5085
- affects: ["crm.deal"]
5086
- },
5087
- {
5088
- id: "move_to_closing",
5089
- order: 260,
5090
- label: "Move to Closing",
5091
- description: "Advance a proposal-stage CRM deal into closing.",
5092
- scope: { domain: "sales" },
5093
- resourceId: "move_to_closing-workflow",
5094
- affects: ["crm.deal"]
5095
- },
5096
- {
5097
- id: "move_to_closed_won",
5098
- order: 270,
5099
- label: "Close Won",
5100
- description: "Mark a CRM deal as closed won.",
5101
- scope: { domain: "sales" },
5102
- resourceId: "move_to_closed_won-workflow",
5103
- affects: ["crm.deal"]
5104
- },
5105
- {
5106
- id: "move_to_closed_lost",
5107
- order: 280,
5108
- label: "Close Lost",
5109
- description: "Mark a CRM deal as closed lost.",
5110
- scope: { domain: "sales" },
5111
- resourceId: "move_to_closed_lost-workflow",
5112
- affects: ["crm.deal"]
5113
- },
5114
- {
5115
- id: "move_to_nurturing",
5116
- order: 290,
5117
- label: "Move to Nurturing",
5118
- description: "Move a CRM deal into nurturing for future follow-up.",
5119
- scope: { domain: "sales" },
5120
- resourceId: "move_to_nurturing-workflow",
5121
- affects: ["crm.deal"]
5122
- }
5123
- ];
5124
- var CRM_ACTION_ENTRIES = Object.fromEntries(
5125
- CRM_ACTION_ENTRY_INPUTS.map((action) => {
5126
- const parsed = ActionSchema.parse(action);
5127
- return [parsed.id, parsed];
5128
- })
5129
- );
5130
- var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {
5131
- ...LEAD_GEN_ACTION_ENTRIES,
5132
- ...CRM_ACTION_ENTRIES
5133
- };
4915
+ var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {};
5134
4916
 
5135
4917
  // ../core/src/organization-model/domains/prospecting.ts
5136
4918
  DisplayMetadataSchema.extend({
@@ -5269,7 +5051,6 @@ var DTC_RECORD_COLUMNS = {
5269
5051
  ]
5270
5052
  }
5271
5053
  };
5272
- Object.values(LEAD_GEN_ACTION_ENTRIES);
5273
5054
  var PROSPECTING_STEPS = {
5274
5055
  localServices: {
5275
5056
  sourceCompanies: {
@@ -5515,177 +5296,6 @@ var PROSPECTING_BUILD_TEMPLATE_OPTIONS = BUILD_TEMPLATE_CATALOG.map(({ id, label
5515
5296
  function isProspectingBuildTemplateId(value) {
5516
5297
  return PROSPECTING_BUILD_TEMPLATE_OPTIONS.some((template) => template.id === value);
5517
5298
  }
5518
-
5519
- // ../core/src/organization-model/catalogs/lead-gen.ts
5520
- var LEAD_GEN_STAGE_CATALOG = {
5521
- // Prospecting - company population
5522
- scraped: {
5523
- key: "scraped",
5524
- label: "Scraped",
5525
- description: "Company was scraped from a source directory (Apify actor run).",
5526
- order: 1,
5527
- entity: "company"
5528
- },
5529
- populated: {
5530
- key: "populated",
5531
- label: "Companies found",
5532
- description: "Companies have been found and added to the lead-gen list.",
5533
- order: 2,
5534
- entity: "company"
5535
- },
5536
- crawled: {
5537
- key: "crawled",
5538
- label: "Websites crawled",
5539
- description: "Company websites have been crawled (e.g. via Apify) and raw page content stored for downstream LLM analysis.",
5540
- order: 2.5,
5541
- entity: "company"
5542
- },
5543
- extracted: {
5544
- key: "extracted",
5545
- label: "Websites analyzed",
5546
- description: "Company websites have been analyzed for business signals.",
5547
- order: 3,
5548
- entity: "company"
5549
- },
5550
- enriched: {
5551
- key: "enriched",
5552
- label: "Enriched",
5553
- description: "Company or contact enriched with third-party data (e.g. Tomba, Anymailfinder).",
5554
- order: 4,
5555
- entity: "company"
5556
- },
5557
- "decision-makers-enriched": {
5558
- key: "decision-makers-enriched",
5559
- label: "Decision-makers found",
5560
- description: "Decision-maker contacts discovered and attached to a qualified company.",
5561
- order: 6,
5562
- entity: "company",
5563
- recordEntity: "contact",
5564
- recordStageKey: "discovered"
5565
- },
5566
- // Prospecting - contact discovery
5567
- discovered: {
5568
- key: "discovered",
5569
- label: "Decision-makers found",
5570
- description: "Decision-maker contact details have been found.",
5571
- order: 5,
5572
- entity: "contact"
5573
- },
5574
- verified: {
5575
- key: "verified",
5576
- label: "Emails verified",
5577
- description: "Contact email addresses have been checked for deliverability.",
5578
- order: 7,
5579
- entity: "contact"
5580
- },
5581
- // Qualification
5582
- qualified: {
5583
- key: "qualified",
5584
- label: "Companies qualified",
5585
- description: "Companies have been scored against the qualification criteria.",
5586
- order: 8,
5587
- entity: "company"
5588
- },
5589
- // Outreach
5590
- personalized: {
5591
- key: "personalized",
5592
- label: "Personalized",
5593
- description: "Outreach message personalized for the contact (Instantly personalization workflow).",
5594
- order: 9,
5595
- entity: "contact"
5596
- },
5597
- uploaded: {
5598
- key: "uploaded",
5599
- label: "Reviewed and exported",
5600
- description: "Approved records have been reviewed and exported for handoff.",
5601
- order: 10,
5602
- entity: "company",
5603
- additionalEntities: ["contact"]
5604
- },
5605
- interested: {
5606
- key: "interested",
5607
- label: "Interested",
5608
- description: "Contact replied with a positive signal (Instantly reply-handler transition).",
5609
- order: 11,
5610
- entity: "contact"
5611
- }
5612
- };
5613
-
5614
- // ../core/src/organization-model/domains/sales.ts
5615
- var SalesStageSemanticClassSchema = z.enum(["open", "active", "nurturing", "closed_won", "closed_lost"]);
5616
- var SalesStageSchema = DisplayMetadataSchema.extend({
5617
- id: ModelIdSchema,
5618
- order: z.number().int().min(0),
5619
- semanticClass: SalesStageSemanticClassSchema,
5620
- surfaceIds: ReferenceIdsSchema,
5621
- resourceIds: ReferenceIdsSchema
5622
- });
5623
- z.object({
5624
- id: ModelIdSchema,
5625
- label: z.string().trim().min(1).max(120),
5626
- description: DescriptionSchema.optional(),
5627
- entityId: ModelIdSchema,
5628
- stages: z.array(SalesStageSchema).min(1)
5629
- });
5630
- var CRM_DISCOVERY_REPLIED_STATE = {
5631
- stateKey: "discovery_replied",
5632
- label: "Discovery Replied"
5633
- };
5634
- var CRM_DISCOVERY_LINK_SENT_STATE = {
5635
- stateKey: "discovery_link_sent",
5636
- label: "Discovery Link Sent"
5637
- };
5638
- var CRM_DISCOVERY_NUDGING_STATE = {
5639
- stateKey: "discovery_nudging",
5640
- label: "Discovery Nudging"
5641
- };
5642
- var CRM_DISCOVERY_BOOKING_CANCELLED_STATE = {
5643
- stateKey: "discovery_booking_cancelled",
5644
- label: "Discovery Booking Cancelled"
5645
- };
5646
- var CRM_REPLY_SENT_STATE = {
5647
- stateKey: "reply_sent",
5648
- label: "Reply Sent"
5649
- };
5650
- var CRM_FOLLOWUP_1_SENT_STATE = {
5651
- stateKey: "followup_1_sent",
5652
- label: "Follow-up 1 Sent"
5653
- };
5654
- var CRM_FOLLOWUP_2_SENT_STATE = {
5655
- stateKey: "followup_2_sent",
5656
- label: "Follow-up 2 Sent"
5657
- };
5658
- var CRM_FOLLOWUP_3_SENT_STATE = {
5659
- stateKey: "followup_3_sent",
5660
- label: "Follow-up 3 Sent"
5661
- };
5662
- var CRM_PIPELINE_DEFINITION = {
5663
- pipelineKey: "crm",
5664
- label: "CRM",
5665
- entityKey: "crm.deal",
5666
- stages: [
5667
- {
5668
- stageKey: "interested",
5669
- label: "Interested",
5670
- color: "blue",
5671
- states: [
5672
- CRM_DISCOVERY_REPLIED_STATE,
5673
- CRM_DISCOVERY_LINK_SENT_STATE,
5674
- CRM_DISCOVERY_NUDGING_STATE,
5675
- CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
5676
- CRM_REPLY_SENT_STATE,
5677
- CRM_FOLLOWUP_1_SENT_STATE,
5678
- CRM_FOLLOWUP_2_SENT_STATE,
5679
- CRM_FOLLOWUP_3_SENT_STATE
5680
- ]
5681
- },
5682
- { stageKey: "proposal", label: "Proposal", color: "yellow", states: [] },
5683
- { stageKey: "closing", label: "Closing", color: "orange", states: [] },
5684
- { stageKey: "closed_won", label: "Closed Won", color: "green", states: [] },
5685
- { stageKey: "closed_lost", label: "Closed Lost", color: "red", states: [] },
5686
- { stageKey: "nurturing", label: "Nurturing", color: "grape", states: [] }
5687
- ]
5688
- };
5689
5299
  var OrganizationModelBrandingSchema = z.object({
5690
5300
  organizationName: LabelSchema,
5691
5301
  productName: LabelSchema,
@@ -5860,45 +5470,6 @@ var OfferingsDomainSchema = z.record(z.string(), ProductSchema).refine((record)
5860
5470
  message: "Each product entry id must match its map key"
5861
5471
  }).default({});
5862
5472
  var DEFAULT_ORGANIZATION_MODEL_OFFERINGS = {};
5863
- var ContentNodeBaseSchema = z.object({
5864
- /** Human-readable label for the content node. */
5865
- label: z.string().trim().min(1).max(120).meta({ label: "Label" }),
5866
- /** Optional one-paragraph description. */
5867
- description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description" }),
5868
- /** Optional display order within the system content map. */
5869
- order: z.number().int().optional().meta({ label: "Order" }),
5870
- /**
5871
- * Local NodeId of the parent content node within the SAME system.
5872
- * Per B4/L9: MUST resolve to a sibling in the same `system.content` map.
5873
- * Per L19: parent and child MUST share the same `kind` (meta-category).
5874
- */
5875
- parentContentId: z.string().trim().min(1).max(200).optional().meta({ label: "Parent content id" })
5876
- });
5877
- var ContentNodeSchema = ContentNodeBaseSchema.extend({
5878
- /** Meta-category (e.g. 'schema', 'config', 'knowledge', tenant-defined). */
5879
- kind: z.string().trim().min(1).max(100).meta({ label: "Kind" }),
5880
- /** Specific family within the meta-category (e.g. 'pipeline', 'kv'). */
5881
- type: z.string().trim().min(1).max(100).meta({ label: "Type" }),
5882
- /** Payload data; validated against registered payloadSchema when (kind, type) is known. */
5883
- data: z.record(z.string(), z.unknown()).optional().meta({ label: "Data" })
5884
- });
5885
- z.object({
5886
- /** Meta-category (tenant-defined or registry-shipped). */
5887
- kind: z.string().trim().min(1).max(100).meta({ label: "Kind" }),
5888
- /** Specific family within the meta-category. */
5889
- type: z.string().trim().min(1).max(100).meta({ label: "Type" }),
5890
- /** Human-readable label shown in the KB tree and describe views. */
5891
- label: z.string().trim().min(1).max(120).meta({ label: "Label" }),
5892
- /** Optional description. */
5893
- description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description" }),
5894
- /**
5895
- * Which KB tree group this extension renders in.
5896
- * Per L6: 'business-model' places it alongside Customers / Offerings / Goals.
5897
- */
5898
- treeGroup: z.union([z.enum(["profile", "business-model", "systems", "graph", "governance-wiring"]), z.string().min(1).max(100)]).meta({ label: "Tree group" }),
5899
- /** Untyped payload; shape governed by the registered payloadSchema when available. */
5900
- data: z.record(z.string(), z.unknown()).optional().meta({ label: "Data" })
5901
- });
5902
5473
  var OntologyKindSchema = z.enum([
5903
5474
  "object",
5904
5475
  "link",
@@ -6227,40 +5798,6 @@ function addLegacyActionProjections(index, diagnostics, sourcesById, actions, en
6227
5798
  });
6228
5799
  }
6229
5800
  }
6230
- function addSystemContentProjections(index, diagnostics, sourcesById, systemPath, system, schemaPath) {
6231
- const content = system.content ?? {};
6232
- for (const [localId, node] of Object.entries(content)) {
6233
- if (node.kind !== "schema") continue;
6234
- const entries = Object.fromEntries(
6235
- Object.entries(content).filter(([, candidate]) => candidate.parentContentId === localId).map(([entryId, candidate]) => [
6236
- entryId,
6237
- {
6238
- label: candidate.label ?? entryId,
6239
- type: candidate.type,
6240
- ...candidate.description !== void 0 ? { description: candidate.description } : {},
6241
- ...candidate.data !== void 0 ? candidate.data : {}
6242
- }
6243
- ])
6244
- );
6245
- const catalogType = {
6246
- id: formatOntologyId({ scope: systemPath, kind: "catalog", localId }),
6247
- label: node.label ?? localId,
6248
- description: node.description,
6249
- ownerSystemId: systemPath,
6250
- kind: node.type,
6251
- ...typeof node.data?.["entityId"] === "string" ? { appliesTo: formatOntologyId({ scope: systemPath, kind: "object", localId: node.data["entityId"] }) } : {},
6252
- ...Object.keys(entries).length > 0 ? { entries } : {},
6253
- ...node.data !== void 0 ? { data: node.data } : {}
6254
- };
6255
- addRecord(index, diagnostics, sourcesById, "catalogTypes", catalogType, {
6256
- source: "legacy.system.content",
6257
- path: [...schemaPath, "content", localId],
6258
- kind: "projected",
6259
- systemPath,
6260
- legacyId: `${systemPath}:${localId}`
6261
- });
6262
- }
6263
- }
6264
5801
  function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schemaPath) {
6265
5802
  for (const [key, system] of Object.entries(systems)) {
6266
5803
  const systemPath = prefix ? `${prefix}.${key}` : key;
@@ -6269,7 +5806,6 @@ function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schem
6269
5806
  ...currentPath,
6270
5807
  "ontology"
6271
5808
  ]);
6272
- addSystemContentProjections(index, diagnostics, sourcesById, systemPath, system, currentPath);
6273
5809
  addSystemScopes(index, diagnostics, sourcesById, childSystemsOf(system), systemPath, [
6274
5810
  ...currentPath,
6275
5811
  system.systems !== void 0 ? "systems" : "subsystems"
@@ -6299,7 +5835,7 @@ var SystemPathSchema = z.string().trim().min(1).regex(
6299
5835
  var UiPositionSchema = z.enum(["sidebar-primary", "sidebar-bottom"]).meta({ label: "UI position" });
6300
5836
  var NodeIdStringSchema = z.string().trim().min(1).max(200).regex(
6301
5837
  /^[a-z][a-z-]*:([a-z0-9-]+)(\.[a-z0-9-]+)*(:[a-z0-9.-]+)*$/,
6302
- "Node references must use kind:dotted-path (e.g. system:sales.crm or content-node:sales.crm:pipeline-id)"
5838
+ "Node references must use kind:dotted-path (e.g. system:sales.crm or resource:lead-gen.company.qualify)"
6303
5839
  );
6304
5840
  var SystemUiSchema = z.object({
6305
5841
  path: PathSchema,
@@ -6373,13 +5909,6 @@ var SystemEntrySchema = z.object({
6373
5909
  * shared contract records owned by this system.
6374
5910
  */
6375
5911
  ontology: OntologyScopeSchema.optional(),
6376
- /**
6377
- * @deprecated Compatibility-only bridge for old tenant content nodes and
6378
- * migration readers. New schema/catalog authoring belongs in ontology;
6379
- * new system-local settings belong in config. Bridge nodes are keyed by
6380
- * local NodeId and may still project to content-node:* graph IDs.
6381
- */
6382
- content: z.record(z.string().trim().min(1).max(200), ContentNodeSchema).optional(),
6383
5912
  /**
6384
5913
  * Recursive child systems, authored via nesting (per L11).
6385
5914
  * The key is the local system id; the full path is computed by joining
@@ -6390,7 +5919,7 @@ var SystemEntrySchema = z.object({
6390
5919
  systems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional(),
6391
5920
  /** @deprecated Use systems. Accepted as a compatibility alias during the ontology bridge. */
6392
5921
  subsystems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional()
6393
- }).refine((system) => system.label !== void 0 || system.title !== void 0, {
5922
+ }).strict().refine((system) => system.label !== void 0 || system.title !== void 0, {
6394
5923
  path: ["label"],
6395
5924
  message: "System must provide label or title"
6396
5925
  }).transform((system) => {
@@ -6405,6 +5934,10 @@ var SystemsDomainSchema = z.record(z.string(), SystemEntrySchema).refine((record
6405
5934
  var DEFAULT_ORGANIZATION_MODEL_SYSTEMS = {};
6406
5935
 
6407
5936
  // ../core/src/organization-model/domains/resources.ts
5937
+ var ContractRefSchema = z.string().trim().min(1).max(500).regex(
5938
+ /^[A-Za-z0-9@](?:[A-Za-z0-9_./@-]*[A-Za-z0-9_])?\/?[A-Za-z0-9_./@-]*#[A-Za-z_$][A-Za-z0-9_$]*$/,
5939
+ "ContractRef must be in the format package/subpath#ExportName (e.g. @repo/elevasis-core/contracts/apollo-import#inputSchema)"
5940
+ );
6408
5941
  z.enum(["workflow", "agent", "integration", "script"]).meta({ label: "Resource kind", color: "orange" });
6409
5942
  var ResourceGovernanceStatusSchema = z.enum(["active", "deprecated", "archived"]).meta({ label: "Governance status", color: "teal" });
6410
5943
  var AgentKindSchema = z.enum(["orchestrator", "specialist", "utility", "platform"]).meta({ label: "Agent kind", color: "violet" });
@@ -6433,7 +5966,20 @@ var ResourceOntologyBindingSchema = z.object({
6433
5966
  reads: z.array(OntologyIdSchema).optional(),
6434
5967
  writes: z.array(OntologyIdSchema).optional(),
6435
5968
  usesCatalogs: z.array(OntologyIdSchema).optional(),
6436
- emits: z.array(OntologyIdSchema).optional()
5969
+ emits: z.array(OntologyIdSchema).optional(),
5970
+ /**
5971
+ * Optional typed contract binding for this resource's workflow I/O.
5972
+ * Each ref is a `package/subpath#ExportName` string that resolves to a
5973
+ * Zod schema in `@repo/elevasis-core` (or the consumer's equivalent package).
5974
+ *
5975
+ * Absence of this field preserves all existing behavior — it is additive + optional.
5976
+ * Tier-1 validation (schema.ts): ref-string shape only (browser-safe, no imports).
5977
+ * Tier-2 validation (om:verify): intra-package typed-map resolution asserts ZodType.
5978
+ */
5979
+ contract: z.object({
5980
+ input: ContractRefSchema.optional(),
5981
+ output: ContractRefSchema.optional()
5982
+ }).optional()
6437
5983
  }).superRefine((binding, ctx) => {
6438
5984
  if (binding.primaryAction === void 0) return;
6439
5985
  if (binding.actions?.includes(binding.primaryAction)) return;
@@ -6759,151 +6305,6 @@ var PoliciesDomainSchema = z.record(z.string(), PolicySchema).refine((record) =>
6759
6305
  message: "Each policy entry id must match its map key"
6760
6306
  }).default({});
6761
6307
  var DEFAULT_ORGANIZATION_MODEL_POLICIES = {};
6762
-
6763
- // ../core/src/organization-model/content-kinds/registry.ts
6764
- function defineContentType(def) {
6765
- return def;
6766
- }
6767
- var PipelinePayloadSchema = z.object({
6768
- /**
6769
- * Local NodeId of the entity this pipeline applies to (e.g. 'crm.deal').
6770
- * `.meta({ ref: 'entity' })` enables SchemaDrivenFieldList to render a
6771
- * clickable graph link to the referenced entity node.
6772
- */
6773
- entityId: z.string().trim().min(1).max(200).meta({ label: "Entity", ref: "entity", hint: "The entity type this pipeline tracks" }),
6774
- /**
6775
- * Optional Kanban column color token for UI rendering.
6776
- */
6777
- kanbanColor: z.string().trim().min(1).max(40).optional().meta({ label: "Kanban color", hint: "UI color token" })
6778
- });
6779
- var pipelineKind = defineContentType({
6780
- kind: "schema",
6781
- type: "pipeline",
6782
- label: "Pipeline",
6783
- description: "A named progression pipeline that applies to a specific entity type.",
6784
- payloadSchema: PipelinePayloadSchema,
6785
- parentTypes: []
6786
- });
6787
- var StagePayloadSchema = z.object({
6788
- /**
6789
- * Semantic classification for this stage.
6790
- * Drives color, icon, and CRM-priority logic in consuming views.
6791
- * Optional — prospecting stages use data.entityKind instead.
6792
- * Enum aligned with SalesStageSemanticClassSchema (sales.ts).
6793
- */
6794
- 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" })
6795
- });
6796
- var stageKind = defineContentType({
6797
- kind: "schema",
6798
- type: "stage",
6799
- label: "Stage",
6800
- description: "A stage within a pipeline. Must be parented under a schema:pipeline content node.",
6801
- payloadSchema: StagePayloadSchema,
6802
- parentTypes: ["schema:pipeline"]
6803
- });
6804
- var TemplatePayloadSchema = z.object({
6805
- /**
6806
- * Optional description surfaced in the KB describe view and tooling.
6807
- */
6808
- description: z.string().trim().min(1).max(2e3).optional().meta({ label: "Description", hint: "What this template is used for" })
6809
- });
6810
- var templateKind = defineContentType({
6811
- kind: "schema",
6812
- type: "template",
6813
- label: "Template",
6814
- description: "A named build template (e.g. a prospecting pipeline sequence).",
6815
- payloadSchema: TemplatePayloadSchema,
6816
- parentTypes: []
6817
- });
6818
- var TemplateStepPayloadSchema = z.object({
6819
- /**
6820
- * Which entity type this step primarily operates on.
6821
- */
6822
- primaryEntity: z.enum(["company", "contact"]).meta({ label: "Primary entity", hint: "Entity type this step processes", color: "blue" }),
6823
- /**
6824
- * Action key identifying the workflow action executed by this step.
6825
- * `.meta({ ref: 'action' })` enables SchemaDrivenFieldList to render a
6826
- * clickable graph link.
6827
- */
6828
- actionKey: z.string().trim().min(1).max(200).meta({ label: "Action", ref: "action", hint: "Workflow action executed by this step" }),
6829
- /**
6830
- * IDs of sibling step local NodeIds this step depends on.
6831
- */
6832
- dependsOn: z.array(z.string().trim().min(1).max(200)).optional().meta({ label: "Depends on", hint: "Local NodeIds of prerequisite steps" })
6833
- });
6834
- var templateStepKind = defineContentType({
6835
- kind: "schema",
6836
- type: "template-step",
6837
- label: "Template Step",
6838
- description: "A step within a build template. Must be parented under a schema:template content node.",
6839
- payloadSchema: TemplateStepPayloadSchema,
6840
- parentTypes: ["schema:template"]
6841
- });
6842
- var StatusFlowPayloadSchema = z.object({
6843
- /**
6844
- * Which entity scope this status flow governs.
6845
- */
6846
- appliesTo: z.enum(["project", "milestone", "task"]).meta({ label: "Applies to", hint: "Entity scope governed by this status flow", color: "blue" })
6847
- });
6848
- var statusFlowKind = defineContentType({
6849
- kind: "schema",
6850
- type: "status-flow",
6851
- label: "Status Flow",
6852
- description: "A named set of statuses governing a project, milestone, or task entity.",
6853
- payloadSchema: StatusFlowPayloadSchema,
6854
- parentTypes: []
6855
- });
6856
- var StatusPayloadSchema = z.object({
6857
- /**
6858
- * Semantic classification string for this status.
6859
- * Free-form to allow tenant-defined classifications (e.g. 'active', 'blocked',
6860
- * 'completed'). Used by UI to apply color and icon fallbacks.
6861
- * Optional — status nodes may omit this when the label is self-descriptive.
6862
- */
6863
- semanticClass: z.string().trim().min(1).max(100).optional().meta({ label: "Semantic class", hint: "Semantic meaning of this status (e.g. active, blocked, completed)" }),
6864
- /**
6865
- * Optional UI color token override for this status.
6866
- */
6867
- color: z.string().trim().min(1).max(40).optional().meta({ label: "Color", hint: "UI color token" })
6868
- });
6869
- var statusKind = defineContentType({
6870
- kind: "schema",
6871
- type: "status",
6872
- label: "Status",
6873
- description: "A single status within a status flow. Must be parented under a schema:status-flow content node.",
6874
- payloadSchema: StatusPayloadSchema,
6875
- parentTypes: ["schema:status-flow"]
6876
- });
6877
- var ConfigKvPayloadSchema = z.object({
6878
- /**
6879
- * Flat key-value entries. Values are JSON primitives.
6880
- * Keys are short identifiers (e.g. 'maxBatchSize', 'featureEnabled').
6881
- */
6882
- 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)" })
6883
- });
6884
- var configKvKind = defineContentType({
6885
- kind: "config",
6886
- type: "kv",
6887
- label: "Key-Value Config",
6888
- description: "A flat key-value configuration store co-located with a system. Values are JSON primitives.",
6889
- payloadSchema: ConfigKvPayloadSchema,
6890
- parentTypes: []
6891
- });
6892
-
6893
- // ../core/src/organization-model/content-kinds/index.ts
6894
- var CONTENT_KIND_REGISTRY = {
6895
- "schema:pipeline": pipelineKind,
6896
- "schema:stage": stageKind,
6897
- "schema:template": templateKind,
6898
- "schema:template-step": templateStepKind,
6899
- "schema:status-flow": statusFlowKind,
6900
- "schema:status": statusKind,
6901
- "config:kv": configKvKind
6902
- };
6903
- function lookupContentType(kind, type) {
6904
- const key = `${kind}:${type}`;
6905
- return CONTENT_KIND_REGISTRY[key];
6906
- }
6907
6308
  var SurfaceTypeSchema = z.enum(["page", "dashboard", "graph", "detail", "list", "settings"]).meta({ label: "Surface type", color: "blue" });
6908
6309
  z.object({
6909
6310
  id: ModelIdSchema,
@@ -6974,13 +6375,10 @@ var KnowledgeTargetKindSchema = z.enum([
6974
6375
  "goal",
6975
6376
  "customer-segment",
6976
6377
  "offering",
6977
- "ontology",
6978
- // D4: content nodes are a valid knowledge target after compound-domain data moved into system.content
6979
- "content-node"
6378
+ "ontology"
6980
6379
  ]).meta({ label: "Target kind" });
6981
6380
  var KnowledgeTargetRefSchema = z.object({
6982
6381
  kind: KnowledgeTargetKindSchema,
6983
- // D4: content-node targets use a qualified id format '<system-path>:<local-content-id>'.
6984
6382
  // Ontology targets use the canonical '<scope>:<kind>/<local-id>' ontology id format.
6985
6383
  // Business-logic validation of target existence is done in OrganizationModelSchema.superRefine.
6986
6384
  id: z.string().trim().min(1).max(300)
@@ -6997,6 +6395,15 @@ var KnowledgeTargetRefSchema = z.object({
6997
6395
  });
6998
6396
  var LegacyKnowledgeLinkSchema = z.object({
6999
6397
  nodeId: z.union([NodeIdStringSchema, z.templateLiteral(["ontology:", OntologyIdSchema])])
6398
+ }).superRefine((link, ctx) => {
6399
+ const [kind] = link.nodeId.split(":");
6400
+ if (!KnowledgeTargetKindSchema.safeParse(kind).success) {
6401
+ ctx.addIssue({
6402
+ code: z.ZodIssueCode.custom,
6403
+ path: ["nodeId"],
6404
+ message: `Unknown knowledge target kind "${kind}"`
6405
+ });
6406
+ }
7000
6407
  });
7001
6408
  var CanonicalKnowledgeLinkSchema = z.object({
7002
6409
  target: KnowledgeTargetRefSchema
@@ -7156,7 +6563,10 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
7156
6563
  const childSystems = system.systems ?? system.subsystems;
7157
6564
  if (childSystems !== void 0) {
7158
6565
  result.push(
7159
- ...collectAllSystems(childSystems, path, [...currentSchemaPath, system.systems !== void 0 ? "systems" : "subsystems"])
6566
+ ...collectAllSystems(childSystems, path, [
6567
+ ...currentSchemaPath,
6568
+ system.systems !== void 0 ? "systems" : "subsystems"
6569
+ ])
7160
6570
  );
7161
6571
  }
7162
6572
  }
@@ -7177,7 +6587,9 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
7177
6587
  `System "${system.id}" references unknown parent "${system.parentSystemId}"`
7178
6588
  );
7179
6589
  }
7180
- const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some((candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes("."));
6590
+ const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some(
6591
+ (candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".")
6592
+ );
7181
6593
  const contributesRoutePath = system.ui?.path !== void 0 || system.path !== void 0 || !hasChildren;
7182
6594
  if (contributesRoutePath) {
7183
6595
  const effectivePath = system.ui?.path ?? system.path ?? defaultSystemPathFor(path);
@@ -7199,11 +6611,7 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
7199
6611
  (candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".") && isLifecycleEnabled(candidate.system.lifecycle, candidate.system.enabled)
7200
6612
  );
7201
6613
  if (!hasEnabledDescendant) {
7202
- addIssue(
7203
- ctx,
7204
- [...schemaPath, "lifecycle"],
7205
- `System "${path}" is active but has no active descendants`
7206
- );
6614
+ addIssue(ctx, [...schemaPath, "lifecycle"], `System "${path}" is active but has no active descendants`);
7207
6615
  }
7208
6616
  }
7209
6617
  });
@@ -7435,10 +6843,16 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
7435
6843
  }
7436
6844
  });
7437
6845
  });
7438
- const stageIds = /* @__PURE__ */ new Set();
7439
6846
  const actionIds = new Set(Object.keys(model.actions));
7440
6847
  const offeringsById = new Map(Object.entries(model.offerings));
7441
6848
  const ontologyCompilation = compileOrganizationOntology(model);
6849
+ const stageIds = /* @__PURE__ */ new Set();
6850
+ for (const catalog of Object.values(ontologyCompilation.ontology.catalogTypes)) {
6851
+ if (catalog.kind !== "stage") continue;
6852
+ for (const stageId of Object.keys(catalog.entries ?? {})) {
6853
+ stageIds.add(stageId);
6854
+ }
6855
+ }
7442
6856
  const ontologyIndexByKind = {
7443
6857
  object: ontologyCompilation.ontology.objectTypes,
7444
6858
  link: ontologyCompilation.ontology.linkTypes,
@@ -7614,13 +7028,7 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
7614
7028
  if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
7615
7029
  addIssue(
7616
7030
  ctx,
7617
- [
7618
- "resources",
7619
- resourceId,
7620
- "ontology",
7621
- bindingKey,
7622
- ...Array.isArray(ids) ? [ontologyIndex] : []
7623
- ],
7031
+ ["resources", resourceId, "ontology", bindingKey, ...Array.isArray(ids) ? [ontologyIndex] : []],
7624
7032
  `Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
7625
7033
  );
7626
7034
  }
@@ -7635,6 +7043,23 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
7635
7043
  validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
7636
7044
  validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
7637
7045
  validateResourceOntologyBinding(resource.id, "emits", "event", binding.emits);
7046
+ if (binding.contract !== void 0) {
7047
+ const contractEntries = [
7048
+ ["input", binding.contract.input],
7049
+ ["output", binding.contract.output]
7050
+ ];
7051
+ for (const [side, ref] of contractEntries) {
7052
+ if (ref === void 0) continue;
7053
+ const result = ContractRefSchema.safeParse(ref);
7054
+ if (!result.success) {
7055
+ addIssue(
7056
+ ctx,
7057
+ ["resources", resource.id, "ontology", "contract", side],
7058
+ `Resource "${resource.id}" contract.${side} "${ref}" is not a valid ContractRef (expected "package/subpath#ExportName")`
7059
+ );
7060
+ }
7061
+ }
7062
+ }
7638
7063
  });
7639
7064
  Object.values(model.roles).forEach((role) => {
7640
7065
  if (role.heldBy === void 0) return;
@@ -7669,78 +7094,6 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
7669
7094
  }
7670
7095
  });
7671
7096
  });
7672
- function validateSystemContent(system, systemPath) {
7673
- const childSystems = system.systems ?? system.subsystems;
7674
- const childKey = system.systems !== void 0 ? "systems" : "subsystems";
7675
- const content = system.content;
7676
- if (content === void 0 || Object.keys(content).length === 0) {
7677
- if (childSystems !== void 0) {
7678
- Object.entries(childSystems).forEach(([childLocalId, child]) => {
7679
- validateSystemContent(child, [...systemPath, childKey, childLocalId]);
7680
- });
7681
- }
7682
- return;
7683
- }
7684
- Object.entries(content).forEach(([localId, node]) => {
7685
- if (node.parentContentId !== void 0 && !(node.parentContentId in content)) {
7686
- addIssue(
7687
- ctx,
7688
- [...systemPath, "content", localId, "parentContentId"],
7689
- `Content node "${localId}" parentContentId "${node.parentContentId}" does not resolve within the same system`
7690
- );
7691
- }
7692
- });
7693
- Object.entries(content).forEach(([localId, node]) => {
7694
- const visited = /* @__PURE__ */ new Set();
7695
- let currentId = node.parentContentId;
7696
- while (currentId !== void 0) {
7697
- if (currentId === localId || visited.has(currentId)) {
7698
- addIssue(
7699
- ctx,
7700
- [...systemPath, "content", localId, "parentContentId"],
7701
- `Content node "${localId}" has a parentContentId cycle`
7702
- );
7703
- break;
7704
- }
7705
- visited.add(currentId);
7706
- currentId = content[currentId]?.parentContentId;
7707
- }
7708
- });
7709
- Object.entries(content).forEach(([localId, node]) => {
7710
- const childDef = lookupContentType(node.kind, node.type);
7711
- if (childDef !== void 0 && node.data !== void 0) {
7712
- const result = childDef.payloadSchema.safeParse(node.data);
7713
- if (!result.success) {
7714
- addIssue(
7715
- ctx,
7716
- [...systemPath, "content", localId, "data"],
7717
- `Content node "${localId}" (${node.kind}:${node.type}) data failed payload validation: ${result.error.message}`
7718
- );
7719
- }
7720
- }
7721
- if (node.parentContentId !== void 0 && childDef !== void 0) {
7722
- const parentNode = content[node.parentContentId];
7723
- if (parentNode !== void 0) {
7724
- const parentDef = lookupContentType(parentNode.kind, parentNode.type);
7725
- if (parentDef !== void 0 && childDef.kind !== parentDef.kind) {
7726
- addIssue(
7727
- ctx,
7728
- [...systemPath, "content", localId, "parentContentId"],
7729
- `Content node "${localId}" kind "${childDef.kind}" cannot parent under "${node.parentContentId}" kind "${parentDef.kind}": parentContentId must be same-meta-kind (per L19)`
7730
- );
7731
- }
7732
- }
7733
- }
7734
- });
7735
- if (childSystems !== void 0) {
7736
- Object.entries(childSystems).forEach(([childLocalId, child]) => {
7737
- validateSystemContent(child, [...systemPath, childKey, childLocalId]);
7738
- });
7739
- }
7740
- }
7741
- Object.entries(model.systems).forEach(([systemKey, system]) => {
7742
- validateSystemContent(system, ["systems", systemKey]);
7743
- });
7744
7097
  for (const diagnostic of ontologyCompilation.diagnostics) {
7745
7098
  addIssue(ctx, diagnostic.path, diagnostic.message);
7746
7099
  }
@@ -7748,311 +7101,11 @@ OrganizationModelSchemaBase.superRefine((model, ctx) => {
7748
7101
 
7749
7102
  // ../core/src/organization-model/defaults.ts
7750
7103
  var DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE = {};
7751
- var DEFAULT_ORGANIZATION_MODEL_ENTITIES2 = DEFAULT_ORGANIZATION_MODEL_ENTITIES;
7104
+ var DEFAULT_ORGANIZATION_MODEL_ENTITIES2 = {};
7752
7105
  var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
7753
7106
  sidebar: {
7754
- primary: {
7755
- dashboard: {
7756
- type: "surface",
7757
- label: "Dashboard",
7758
- path: "/",
7759
- surfaceType: "dashboard",
7760
- icon: "dashboard",
7761
- order: 10,
7762
- targets: { systems: ["dashboard"] }
7763
- },
7764
- business: {
7765
- type: "group",
7766
- label: "Business",
7767
- icon: "briefcase",
7768
- order: 20,
7769
- children: {
7770
- sales: {
7771
- type: "surface",
7772
- label: "Sales",
7773
- path: "/sales",
7774
- surfaceType: "page",
7775
- icon: "sales",
7776
- order: 10,
7777
- targets: { systems: ["sales"] }
7778
- },
7779
- clients: {
7780
- type: "surface",
7781
- label: "Clients",
7782
- path: "/clients",
7783
- surfaceType: "list",
7784
- icon: "clients",
7785
- order: 20,
7786
- targets: { systems: ["clients"] }
7787
- },
7788
- projects: {
7789
- type: "surface",
7790
- label: "Projects",
7791
- path: "/projects",
7792
- surfaceType: "page",
7793
- icon: "projects",
7794
- order: 30,
7795
- targets: { systems: ["projects"] }
7796
- }
7797
- }
7798
- },
7799
- operations: {
7800
- type: "group",
7801
- label: "Operations",
7802
- icon: "operations",
7803
- order: 30,
7804
- children: {
7805
- "operations-overview": {
7806
- type: "surface",
7807
- label: "Overview",
7808
- path: "/operations",
7809
- surfaceType: "page",
7810
- order: 10,
7811
- targets: { systems: ["operations.overview"] }
7812
- },
7813
- "operations-systems": {
7814
- type: "surface",
7815
- label: "Systems",
7816
- path: "/operations/systems",
7817
- surfaceType: "page",
7818
- order: 20,
7819
- targets: { systems: ["operations"] }
7820
- },
7821
- "operations-resources": {
7822
- type: "surface",
7823
- label: "Resources",
7824
- path: "/operations/resources",
7825
- surfaceType: "list",
7826
- order: 30,
7827
- targets: { systems: ["operations.resources"] }
7828
- },
7829
- "operations-command-queue": {
7830
- type: "surface",
7831
- label: "Command Queue",
7832
- path: "/operations/command-queue",
7833
- surfaceType: "list",
7834
- order: 40,
7835
- targets: { systems: ["operations.command-queue"] }
7836
- },
7837
- "operations-task-scheduler": {
7838
- type: "surface",
7839
- label: "Task Scheduler",
7840
- path: "/operations/task-scheduler",
7841
- surfaceType: "list",
7842
- order: 50,
7843
- targets: { systems: ["operations.task-scheduler"] }
7844
- }
7845
- }
7846
- },
7847
- monitoring: {
7848
- type: "group",
7849
- label: "Monitoring",
7850
- icon: "monitoring",
7851
- order: 40,
7852
- children: {
7853
- "monitoring-overview": {
7854
- type: "surface",
7855
- label: "Overview",
7856
- path: "/monitoring",
7857
- surfaceType: "page",
7858
- order: 10,
7859
- targets: { systems: ["monitoring"] }
7860
- },
7861
- "monitoring-calendar": {
7862
- type: "surface",
7863
- label: "Calendar",
7864
- path: "/monitoring/calendar",
7865
- surfaceType: "page",
7866
- order: 20,
7867
- targets: { systems: ["monitoring.calendar"] }
7868
- },
7869
- "monitoring-activity-log": {
7870
- type: "surface",
7871
- label: "Activity Log",
7872
- path: "/monitoring/activity-log",
7873
- surfaceType: "list",
7874
- order: 30,
7875
- targets: { systems: ["monitoring.activity-log"] }
7876
- },
7877
- "monitoring-execution-logs": {
7878
- type: "surface",
7879
- label: "Execution Logs",
7880
- path: "/monitoring/execution-logs",
7881
- surfaceType: "list",
7882
- order: 40,
7883
- targets: { systems: ["monitoring.execution-logs"] }
7884
- },
7885
- "monitoring-execution-health": {
7886
- type: "surface",
7887
- label: "Execution Health",
7888
- path: "/monitoring/execution-health",
7889
- surfaceType: "dashboard",
7890
- order: 50,
7891
- targets: { systems: ["monitoring.execution-health"] }
7892
- },
7893
- "monitoring-notifications": {
7894
- type: "surface",
7895
- label: "Notifications",
7896
- path: "/monitoring/notifications",
7897
- surfaceType: "list",
7898
- order: 60,
7899
- targets: { systems: ["monitoring.notifications"] }
7900
- },
7901
- "monitoring-requests": {
7902
- type: "surface",
7903
- label: "Requests",
7904
- path: "/monitoring/requests",
7905
- surfaceType: "list",
7906
- order: 70,
7907
- targets: { systems: ["monitoring.submitted-requests"] }
7908
- }
7909
- }
7910
- },
7911
- knowledge: {
7912
- type: "surface",
7913
- label: "Knowledge Base",
7914
- path: "/knowledge",
7915
- surfaceType: "page",
7916
- icon: "knowledge",
7917
- order: 50
7918
- }
7919
- },
7920
- bottom: {
7921
- settings: {
7922
- type: "group",
7923
- label: "Settings",
7924
- icon: "settings",
7925
- order: 10,
7926
- children: {
7927
- "settings-account": {
7928
- type: "surface",
7929
- label: "Account",
7930
- path: "/settings/account",
7931
- surfaceType: "settings",
7932
- order: 10,
7933
- targets: { systems: ["settings.account"] }
7934
- },
7935
- "settings-appearance": {
7936
- type: "surface",
7937
- label: "Appearance",
7938
- path: "/settings/appearance",
7939
- surfaceType: "settings",
7940
- order: 20,
7941
- targets: { systems: ["settings.appearance"] }
7942
- },
7943
- "settings-roles": {
7944
- type: "surface",
7945
- label: "My Roles",
7946
- path: "/settings/roles",
7947
- surfaceType: "settings",
7948
- order: 30,
7949
- targets: { systems: ["settings.roles"] }
7950
- },
7951
- "settings-organization": {
7952
- type: "surface",
7953
- label: "Organization",
7954
- path: "/settings/organization",
7955
- surfaceType: "settings",
7956
- order: 40,
7957
- targets: { systems: ["settings.organization"] }
7958
- },
7959
- "settings-credentials": {
7960
- type: "surface",
7961
- label: "Credentials",
7962
- path: "/settings/credentials",
7963
- surfaceType: "settings",
7964
- order: 50,
7965
- targets: { systems: ["settings.credentials"] }
7966
- },
7967
- "settings-api-keys": {
7968
- type: "surface",
7969
- label: "API Keys",
7970
- path: "/settings/api-keys",
7971
- surfaceType: "settings",
7972
- order: 60,
7973
- targets: { systems: ["settings.api-keys"] }
7974
- },
7975
- "settings-webhooks": {
7976
- type: "surface",
7977
- label: "Webhooks",
7978
- path: "/settings/webhooks",
7979
- surfaceType: "settings",
7980
- order: 70,
7981
- targets: { systems: ["settings.webhooks"] }
7982
- },
7983
- "settings-deployments": {
7984
- type: "surface",
7985
- label: "Deployments",
7986
- path: "/settings/deployments",
7987
- surfaceType: "settings",
7988
- order: 80,
7989
- targets: { systems: ["settings.deployments"] }
7990
- }
7991
- }
7992
- },
7993
- admin: {
7994
- type: "group",
7995
- label: "Admin",
7996
- icon: "admin",
7997
- order: 20,
7998
- children: {
7999
- "admin-dashboard": {
8000
- type: "surface",
8001
- label: "Dashboard",
8002
- path: "/admin/dashboard",
8003
- surfaceType: "dashboard",
8004
- order: 10,
8005
- targets: { systems: ["admin"] },
8006
- requiresAdmin: true
8007
- },
8008
- "admin-system-health": {
8009
- type: "surface",
8010
- label: "System Health",
8011
- path: "/admin/system-health",
8012
- surfaceType: "dashboard",
8013
- order: 20,
8014
- targets: { systems: ["admin.system-health"] },
8015
- requiresAdmin: true
8016
- },
8017
- "admin-organizations": {
8018
- type: "surface",
8019
- label: "Organizations",
8020
- path: "/admin/organizations",
8021
- surfaceType: "list",
8022
- order: 30,
8023
- targets: { systems: ["admin.organizations"] },
8024
- requiresAdmin: true
8025
- },
8026
- "admin-users": {
8027
- type: "surface",
8028
- label: "Users",
8029
- path: "/admin/users",
8030
- surfaceType: "list",
8031
- order: 40,
8032
- targets: { systems: ["admin.users"] },
8033
- requiresAdmin: true
8034
- },
8035
- "admin-design-showcase": {
8036
- type: "surface",
8037
- label: "Design Showcase",
8038
- path: "/admin/design-showcase",
8039
- surfaceType: "page",
8040
- order: 50,
8041
- targets: { systems: ["admin.design-showcase"] },
8042
- requiresAdmin: true
8043
- },
8044
- "admin-debug": {
8045
- type: "surface",
8046
- label: "Debug",
8047
- path: "/admin/debug",
8048
- surfaceType: "page",
8049
- order: 60,
8050
- targets: { systems: ["admin.debug"] },
8051
- requiresAdmin: true
8052
- }
8053
- }
8054
- }
8055
- }
7107
+ primary: {},
7108
+ bottom: {}
8056
7109
  }
8057
7110
  };
8058
7111
  var DEFAULT_ORGANIZATION_MODEL = {
@@ -8065,408 +7118,159 @@ var DEFAULT_ORGANIZATION_MODEL = {
8065
7118
  offerings: DEFAULT_ORGANIZATION_MODEL_OFFERINGS,
8066
7119
  roles: DEFAULT_ORGANIZATION_MODEL_ROLES,
8067
7120
  goals: DEFAULT_ORGANIZATION_MODEL_GOALS,
8068
- systems: {
8069
- dashboard: {
8070
- id: "dashboard",
8071
- order: 10,
8072
- label: "Dashboard",
8073
- enabled: true,
8074
- lifecycle: "active",
8075
- path: "/",
8076
- icon: "dashboard"
8077
- },
8078
- platform: {
8079
- id: "platform",
8080
- order: 30,
8081
- label: "Platform",
8082
- description: "Elevasis platform architecture, capabilities, and implementation patterns",
8083
- enabled: true,
8084
- lifecycle: "active",
8085
- color: "cyan",
8086
- icon: "platform"
8087
- },
8088
- finance: {
8089
- id: "finance",
8090
- order: 40,
8091
- label: "Finance",
8092
- description: "Finance operations, accounting, billing, reconciliation, and tax prep",
8093
- enabled: true,
8094
- lifecycle: "active",
8095
- color: "green",
8096
- icon: "finance"
8097
- },
8098
- sales: {
8099
- id: "sales",
8100
- order: 60,
8101
- label: "Sales",
8102
- description: "Revenue workflows and customer acquisition",
8103
- enabled: true,
8104
- lifecycle: "active",
8105
- color: "blue",
8106
- icon: "sales",
8107
- path: "/sales"
8108
- },
8109
- "sales.crm": {
8110
- id: "sales.crm",
8111
- order: 70,
8112
- label: "CRM",
8113
- description: "Relationship pipeline and deal management",
8114
- enabled: true,
8115
- lifecycle: "active",
8116
- actions: Object.values(CRM_ACTION_ENTRIES).map((action) => ({
8117
- actionId: action.id,
8118
- intent: "exposes"
8119
- })),
8120
- color: "blue",
8121
- icon: "crm",
8122
- path: "/crm"
8123
- },
8124
- "sales.lead-gen": {
8125
- id: "sales.lead-gen",
8126
- order: 80,
8127
- label: "Lead Gen",
8128
- description: "Prospecting, qualification, and outreach preparation",
8129
- enabled: true,
8130
- lifecycle: "active",
8131
- actions: Object.values(LEAD_GEN_ACTION_ENTRIES).map((action) => ({
8132
- actionId: action.id,
8133
- intent: "exposes"
8134
- })),
8135
- color: "cyan",
8136
- icon: "lead-gen",
8137
- path: "/lead-gen"
8138
- },
8139
- projects: {
8140
- id: "projects",
8141
- order: 90,
8142
- label: "Projects",
8143
- description: "Projects, milestones, and client work execution",
8144
- enabled: true,
8145
- lifecycle: "active",
8146
- color: "orange",
8147
- icon: "projects",
8148
- path: "/projects"
8149
- },
8150
- clients: {
8151
- id: "clients",
8152
- order: 100,
8153
- label: "Clients",
8154
- description: "Client relationships, accounts, and business context",
8155
- enabled: true,
8156
- lifecycle: "active",
8157
- color: "orange",
8158
- icon: "clients",
8159
- path: "/clients"
8160
- },
8161
- operations: {
8162
- id: "operations",
8163
- order: 110,
8164
- label: "Operations",
8165
- description: "Operational resources, topology, and orchestration visibility",
8166
- enabled: true,
8167
- lifecycle: "active",
8168
- color: "violet",
8169
- icon: "operations"
8170
- },
8171
- "knowledge.command-view": {
8172
- id: "knowledge.command-view",
8173
- order: 120,
8174
- label: "Command View",
8175
- enabled: true,
8176
- lifecycle: "active",
8177
- path: "/knowledge/command-view",
8178
- devOnly: true
8179
- },
8180
- "operations.overview": {
8181
- id: "operations.overview",
8182
- order: 130,
8183
- label: "Overview",
8184
- enabled: true,
8185
- lifecycle: "active",
8186
- path: "/operations"
8187
- },
8188
- "operations.resources": {
8189
- id: "operations.resources",
8190
- order: 140,
8191
- label: "Resources",
8192
- enabled: true,
8193
- lifecycle: "active",
8194
- path: "/operations/resources"
8195
- },
8196
- "operations.command-queue": {
8197
- id: "operations.command-queue",
8198
- order: 150,
8199
- label: "Command Queue",
8200
- enabled: true,
8201
- lifecycle: "active",
8202
- path: "/operations/command-queue"
8203
- },
8204
- "operations.sessions": {
8205
- id: "operations.sessions",
8206
- order: 160,
8207
- label: "Sessions",
8208
- enabled: false,
8209
- lifecycle: "deprecated",
8210
- path: "/operations/sessions"
8211
- },
8212
- "operations.task-scheduler": {
8213
- id: "operations.task-scheduler",
8214
- order: 170,
8215
- label: "Task Scheduler",
8216
- enabled: true,
8217
- lifecycle: "active",
8218
- path: "/operations/task-scheduler"
8219
- },
8220
- monitoring: {
8221
- id: "monitoring",
8222
- order: 180,
8223
- label: "Monitoring",
8224
- enabled: true,
8225
- lifecycle: "active"
8226
- },
8227
- "monitoring.calendar": {
8228
- id: "monitoring.calendar",
8229
- order: 190,
8230
- label: "Calendar",
8231
- description: "Google Calendar events and agenda views",
8232
- enabled: true,
8233
- lifecycle: "active",
8234
- path: "/monitoring/calendar",
8235
- icon: "calendar"
8236
- },
8237
- "monitoring.activity-log": {
8238
- id: "monitoring.activity-log",
8239
- order: 200,
8240
- label: "Activity Log",
8241
- enabled: true,
8242
- lifecycle: "active",
8243
- path: "/monitoring/activity-log"
8244
- },
8245
- "monitoring.execution-logs": {
8246
- id: "monitoring.execution-logs",
8247
- order: 210,
8248
- label: "Execution Logs",
8249
- enabled: true,
8250
- lifecycle: "active",
8251
- path: "/monitoring/execution-logs"
8252
- },
8253
- "monitoring.execution-health": {
8254
- id: "monitoring.execution-health",
8255
- order: 220,
8256
- label: "Execution Health",
8257
- enabled: true,
8258
- lifecycle: "active",
8259
- path: "/monitoring/execution-health"
8260
- },
8261
- "monitoring.cost-analytics": {
8262
- id: "monitoring.cost-analytics",
8263
- order: 230,
8264
- label: "Cost Analytics",
8265
- enabled: false,
8266
- lifecycle: "deprecated",
8267
- path: "/monitoring/cost-analytics"
8268
- },
8269
- "monitoring.notifications": {
8270
- id: "monitoring.notifications",
8271
- order: 240,
8272
- label: "Notifications",
8273
- enabled: true,
8274
- lifecycle: "active",
8275
- path: "/monitoring/notifications"
8276
- },
8277
- "monitoring.submitted-requests": {
8278
- id: "monitoring.submitted-requests",
8279
- order: 250,
8280
- label: "Submitted Requests",
8281
- enabled: true,
8282
- lifecycle: "active",
8283
- path: "/monitoring/requests"
8284
- },
8285
- settings: {
8286
- id: "settings",
8287
- order: 260,
8288
- label: "Settings",
8289
- enabled: true,
8290
- lifecycle: "active",
8291
- icon: "settings"
8292
- },
8293
- "settings.account": {
8294
- id: "settings.account",
8295
- order: 270,
8296
- label: "Account",
8297
- enabled: true,
8298
- lifecycle: "active",
8299
- path: "/settings/account"
8300
- },
8301
- "settings.appearance": {
8302
- id: "settings.appearance",
8303
- order: 280,
8304
- label: "Appearance",
8305
- enabled: true,
8306
- lifecycle: "active",
8307
- path: "/settings/appearance"
8308
- },
8309
- "settings.roles": {
8310
- id: "settings.roles",
8311
- order: 290,
8312
- label: "My Roles",
8313
- enabled: true,
8314
- lifecycle: "active",
8315
- path: "/settings/roles"
8316
- },
8317
- "settings.organization": {
8318
- id: "settings.organization",
8319
- order: 300,
8320
- label: "Organization",
8321
- enabled: true,
8322
- lifecycle: "active",
8323
- path: "/settings/organization"
8324
- },
8325
- "settings.credentials": {
8326
- id: "settings.credentials",
8327
- order: 310,
8328
- label: "Credentials",
8329
- enabled: true,
8330
- lifecycle: "active",
8331
- path: "/settings/credentials"
8332
- },
8333
- "settings.api-keys": {
8334
- id: "settings.api-keys",
8335
- order: 320,
8336
- label: "API Keys",
8337
- enabled: true,
8338
- lifecycle: "active",
8339
- path: "/settings/api-keys"
8340
- },
8341
- "settings.webhooks": {
8342
- id: "settings.webhooks",
8343
- order: 330,
8344
- label: "Webhooks",
8345
- enabled: true,
8346
- lifecycle: "active",
8347
- path: "/settings/webhooks"
8348
- },
8349
- "settings.deployments": {
8350
- id: "settings.deployments",
8351
- order: 340,
8352
- label: "Deployments",
8353
- enabled: true,
8354
- lifecycle: "active",
8355
- path: "/settings/deployments"
8356
- },
8357
- admin: {
8358
- id: "admin",
8359
- order: 350,
8360
- label: "Admin",
8361
- enabled: true,
8362
- lifecycle: "active",
8363
- path: "/admin",
8364
- icon: "admin",
8365
- requiresAdmin: true
8366
- },
8367
- "admin.system-health": {
8368
- id: "admin.system-health",
8369
- order: 360,
8370
- label: "System Health",
8371
- enabled: true,
8372
- lifecycle: "active",
8373
- path: "/admin/system-health"
8374
- },
8375
- "admin.organizations": {
8376
- id: "admin.organizations",
8377
- order: 370,
8378
- label: "Organizations",
8379
- enabled: true,
8380
- lifecycle: "active",
8381
- path: "/admin/organizations"
8382
- },
8383
- "admin.users": {
8384
- id: "admin.users",
8385
- order: 380,
8386
- label: "Users",
8387
- enabled: true,
8388
- lifecycle: "active",
8389
- path: "/admin/users"
8390
- },
8391
- "admin.design-showcase": {
8392
- id: "admin.design-showcase",
8393
- order: 390,
8394
- label: "Design Showcase",
8395
- enabled: true,
8396
- lifecycle: "active",
8397
- path: "/admin/design-showcase"
8398
- },
8399
- "admin.debug": {
8400
- id: "admin.debug",
8401
- order: 400,
8402
- label: "Debug",
8403
- enabled: true,
8404
- lifecycle: "active",
8405
- path: "/admin/debug"
8406
- },
8407
- archive: {
8408
- id: "archive",
8409
- order: 410,
8410
- label: "Archive",
8411
- enabled: true,
8412
- lifecycle: "active",
8413
- path: "/archive",
8414
- icon: "archive",
8415
- devOnly: true
8416
- },
8417
- "archive.agent-chat": {
8418
- id: "archive.agent-chat",
8419
- order: 420,
8420
- label: "Agent Chat",
8421
- enabled: true,
8422
- lifecycle: "active",
8423
- path: "/archive/agent-chat"
8424
- },
8425
- "archive.execution-runner": {
8426
- id: "archive.execution-runner",
8427
- order: 430,
8428
- label: "Execution Runner",
8429
- enabled: true,
8430
- lifecycle: "active",
8431
- path: "/archive/execution-runner"
8432
- },
8433
- seo: {
8434
- id: "seo",
8435
- order: 440,
8436
- label: "SEO",
8437
- enabled: false,
8438
- lifecycle: "deprecated",
8439
- path: "/seo"
8440
- },
8441
- knowledge: {
8442
- id: "knowledge",
8443
- order: 450,
8444
- label: "Knowledge",
8445
- description: "Operational knowledge, playbooks, and strategy docs",
8446
- enabled: true,
8447
- lifecycle: "active",
8448
- color: "teal",
8449
- icon: "knowledge"
8450
- },
8451
- "knowledge.base": {
8452
- id: "knowledge.base",
8453
- order: 460,
8454
- label: "Knowledge Base",
8455
- enabled: true,
8456
- lifecycle: "active",
8457
- path: "/knowledge"
8458
- }
8459
- },
7121
+ // Generic empty systems map. Elevasis-specific systems (platform, sales, sales.crm,
7122
+ // sales.lead-gen, monitoring, settings, admin, etc.) have been relocated to
7123
+ // `@repo/elevasis-core/src/organization-model/systems.ts` via `canonicalOrganizationModel`.
7124
+ // Tenant OM configs supply their own systems via `resolveOrganizationModel`.
7125
+ systems: {},
8460
7126
  ontology: DEFAULT_ONTOLOGY_SCOPE,
8461
7127
  resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
8462
7128
  topology: DEFAULT_ORGANIZATION_MODEL_TOPOLOGY,
8463
- actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
7129
+ // Generic empty actions map. Elevasis-specific action entries have been relocated to
7130
+ // `@repo/elevasis-core/src/organization-model/actions.ts`.
7131
+ actions: {},
8464
7132
  entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
8465
7133
  policies: DEFAULT_ORGANIZATION_MODEL_POLICIES,
8466
- // Phase 4 (D1): statuses top-level field removed; bridge status mirrors may
8467
- // still project from System.content, but primary authoring belongs in ontology.
8468
7134
  knowledge: DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE
8469
7135
  };
7136
+ var SalesStageSemanticClassSchema = z.enum(["open", "active", "nurturing", "closed_won", "closed_lost"]);
7137
+ var SalesStageSchema = DisplayMetadataSchema.extend({
7138
+ id: ModelIdSchema,
7139
+ order: z.number().int().min(0),
7140
+ semanticClass: SalesStageSemanticClassSchema,
7141
+ surfaceIds: ReferenceIdsSchema,
7142
+ resourceIds: ReferenceIdsSchema
7143
+ });
7144
+ z.object({
7145
+ id: ModelIdSchema,
7146
+ label: z.string().trim().min(1).max(120),
7147
+ description: DescriptionSchema.optional(),
7148
+ entityId: ModelIdSchema,
7149
+ stages: z.array(SalesStageSchema).min(1)
7150
+ });
7151
+ var CRM_DISCOVERY_REPLIED_STATE = {
7152
+ stateKey: "discovery_replied",
7153
+ label: "Discovery Replied"
7154
+ };
7155
+ var CRM_DISCOVERY_LINK_SENT_STATE = {
7156
+ stateKey: "discovery_link_sent",
7157
+ label: "Discovery Link Sent"
7158
+ };
7159
+ var CRM_DISCOVERY_NUDGING_STATE = {
7160
+ stateKey: "discovery_nudging",
7161
+ label: "Discovery Nudging"
7162
+ };
7163
+ var CRM_DISCOVERY_BOOKING_CANCELLED_STATE = {
7164
+ stateKey: "discovery_booking_cancelled",
7165
+ label: "Discovery Booking Cancelled"
7166
+ };
7167
+ var CRM_REPLY_SENT_STATE = {
7168
+ stateKey: "reply_sent",
7169
+ label: "Reply Sent"
7170
+ };
7171
+ var CRM_FOLLOWUP_1_SENT_STATE = {
7172
+ stateKey: "followup_1_sent",
7173
+ label: "Follow-up 1 Sent"
7174
+ };
7175
+ var CRM_FOLLOWUP_2_SENT_STATE = {
7176
+ stateKey: "followup_2_sent",
7177
+ label: "Follow-up 2 Sent"
7178
+ };
7179
+ var CRM_FOLLOWUP_3_SENT_STATE = {
7180
+ stateKey: "followup_3_sent",
7181
+ label: "Follow-up 3 Sent"
7182
+ };
7183
+ var CRM_PIPELINE_DEFINITION = {
7184
+ pipelineKey: "crm",
7185
+ label: "CRM",
7186
+ entityKey: "crm.deal",
7187
+ stages: [
7188
+ {
7189
+ stageKey: "interested",
7190
+ label: "Interested",
7191
+ color: "blue",
7192
+ states: [
7193
+ CRM_DISCOVERY_REPLIED_STATE,
7194
+ CRM_DISCOVERY_LINK_SENT_STATE,
7195
+ CRM_DISCOVERY_NUDGING_STATE,
7196
+ CRM_DISCOVERY_BOOKING_CANCELLED_STATE,
7197
+ CRM_REPLY_SENT_STATE,
7198
+ CRM_FOLLOWUP_1_SENT_STATE,
7199
+ CRM_FOLLOWUP_2_SENT_STATE,
7200
+ CRM_FOLLOWUP_3_SENT_STATE
7201
+ ]
7202
+ },
7203
+ { stageKey: "proposal", label: "Proposal", color: "yellow", states: [] },
7204
+ { stageKey: "closing", label: "Closing", color: "orange", states: [] },
7205
+ { stageKey: "closed_won", label: "Closed Won", color: "green", states: [] },
7206
+ { stageKey: "closed_lost", label: "Closed Lost", color: "red", states: [] },
7207
+ { stageKey: "nurturing", label: "Nurturing", color: "grape", states: [] }
7208
+ ]
7209
+ };
7210
+
7211
+ // ../core/src/organization-model/migration-helpers.ts
7212
+ function catalogRecords(model) {
7213
+ return Object.values(compileOrganizationOntology(model).ontology.catalogTypes);
7214
+ }
7215
+ function systemScope(id, fallback) {
7216
+ return parseOntologyId(id).scope || fallback || "";
7217
+ }
7218
+ function entriesOf(catalog) {
7219
+ return Object.entries(catalog.entries ?? {}).map(([id, value]) => [
7220
+ id,
7221
+ value && typeof value === "object" && !Array.isArray(value) ? value : {}
7222
+ ]);
7223
+ }
7224
+ function stringValue(value) {
7225
+ return typeof value === "string" ? value : void 0;
7226
+ }
7227
+ function stringArray(value) {
7228
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
7229
+ }
7230
+ function numberValue(value, fallback = 0) {
7231
+ return typeof value === "number" ? value : fallback;
7232
+ }
7233
+ function appliesToLocalId(catalog) {
7234
+ const appliesTo = catalog.appliesTo;
7235
+ if (appliesTo === void 0) return void 0;
7236
+ return parseOntologyId(appliesTo).localId;
7237
+ }
7238
+ function appliesToEntityKind(catalog) {
7239
+ const id = appliesToLocalId(catalog);
7240
+ if (id === "company" || id === "contact" || id === "project" || id === "milestone" || id === "task") return id;
7241
+ if (id === "deal") return void 0;
7242
+ return void 0;
7243
+ }
7244
+ function getLeadGenStageCatalog(model) {
7245
+ const results = {};
7246
+ for (const catalog of catalogRecords(model).filter(
7247
+ (record) => record.kind === "stage" && (record.ownerSystemId ?? systemScope(record.id)) === "sales.lead-gen"
7248
+ )) {
7249
+ const catalogEntity = appliesToEntityKind(catalog);
7250
+ if (catalogEntity !== "company" && catalogEntity !== "contact") continue;
7251
+ for (const [entryId, entry] of entriesOf(catalog)) {
7252
+ const entity = entry.entity === "contact" ? "contact" : entry.entity === "company" ? "company" : catalogEntity;
7253
+ const additionalEntities = stringArray(entry.additionalEntities).filter(
7254
+ (item) => item === "company" || item === "contact"
7255
+ );
7256
+ const recordEntity = entry.recordEntity === "company" || entry.recordEntity === "contact" ? entry.recordEntity : void 0;
7257
+ const recordStageKey = stringValue(entry.recordStageKey);
7258
+ results[entryId] = {
7259
+ key: entryId,
7260
+ label: stringValue(entry.label) ?? entryId,
7261
+ description: stringValue(entry.description) ?? "",
7262
+ order: numberValue(entry.order),
7263
+ entity,
7264
+ ...additionalEntities.length > 0 ? { additionalEntities } : {},
7265
+ ...recordEntity ? { recordEntity } : {},
7266
+ ...recordStageKey ? { recordStageKey } : {}
7267
+ };
7268
+ }
7269
+ }
7270
+ return Object.fromEntries(
7271
+ Object.entries(results).sort(([, a], [, b]) => a.order - b.order || a.key.localeCompare(b.key))
7272
+ );
7273
+ }
8470
7274
 
8471
7275
  // ../core/src/business/acquisition/ontology-validation.ts
8472
7276
  var CRM_PIPELINE_CATALOG_ONTOLOGY_ID = formatOntologyId({
@@ -8507,14 +7311,14 @@ function createCrmPipelineCatalog() {
8507
7311
  legacyEntityKey: CRM_PIPELINE_DEFINITION.entityKey
8508
7312
  };
8509
7313
  }
8510
- function createLeadGenStageCatalog() {
7314
+ function createLeadGenStageCatalog(model) {
8511
7315
  return {
8512
7316
  id: LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID,
8513
7317
  label: "Lead Gen Processing Stages",
8514
7318
  ownerSystemId: "sales.lead-gen",
8515
7319
  kind: "processing-stage-catalog",
8516
7320
  entries: Object.fromEntries(
8517
- Object.entries(LEAD_GEN_STAGE_CATALOG).map(([key, entry]) => [
7321
+ Object.entries(getLeadGenStageCatalog(model)).map(([key, entry]) => [
8518
7322
  key,
8519
7323
  {
8520
7324
  ...entry
@@ -8534,7 +7338,7 @@ function mergeBridgeCatalogs(model) {
8534
7338
  bridgeCatalogTypes[CRM_PIPELINE_CATALOG_ONTOLOGY_ID] = createCrmPipelineCatalog();
8535
7339
  }
8536
7340
  if (baseCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] === void 0) {
8537
- bridgeCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog();
7341
+ bridgeCatalogTypes[LEAD_GEN_STAGE_CATALOG_ONTOLOGY_ID] = createLeadGenStageCatalog(model);
8538
7342
  }
8539
7343
  if (Object.keys(bridgeCatalogTypes).length === 0) return model;
8540
7344
  return {
@@ -8603,25 +7407,6 @@ function asCrmStageEntry(key, value) {
8603
7407
  states
8604
7408
  };
8605
7409
  }
8606
- function asLeadGenStageEntry(key, value) {
8607
- const record = isPlainRecord(value) ? value : {};
8608
- const entity = record.entity === "contact" ? "contact" : "company";
8609
- const additionalEntities = Array.isArray(record.additionalEntities) ? record.additionalEntities.filter(
8610
- (item) => item === "company" || item === "contact"
8611
- ) : void 0;
8612
- const recordEntity = record.recordEntity === "company" || record.recordEntity === "contact" ? record.recordEntity : void 0;
8613
- const recordStageKey = typeof record.recordStageKey === "string" ? record.recordStageKey : void 0;
8614
- return {
8615
- key: typeof record.key === "string" ? record.key : key,
8616
- label: typeof record.label === "string" ? record.label : key,
8617
- description: typeof record.description === "string" ? record.description : "",
8618
- order: typeof record.order === "number" ? record.order : 0,
8619
- entity,
8620
- ...additionalEntities !== void 0 ? { additionalEntities } : {},
8621
- ...recordEntity !== void 0 ? { recordEntity } : {},
8622
- ...recordStageKey !== void 0 ? { recordStageKey } : {}
8623
- };
8624
- }
8625
7410
  var CRM_STAGE_KEYS_FROM_ONTOLOGY = Object.keys(
8626
7411
  getCatalogEntries(BUSINESS_ONTOLOGY_VALIDATION_INDEX.crmPipelineCatalog)
8627
7412
  );
@@ -8635,36 +7420,11 @@ var CRM_STATE_KEYS_FROM_ONTOLOGY = Object.values(
8635
7420
  Object.keys(
8636
7421
  getCatalogEntries(BUSINESS_ONTOLOGY_VALIDATION_INDEX.leadGenStageCatalog)
8637
7422
  );
8638
- function getLeadGenStageCatalogFromOntology() {
8639
- return Object.fromEntries(
8640
- Object.entries(getCatalogEntries(BUSINESS_ONTOLOGY_VALIDATION_INDEX.leadGenStageCatalog)).map(([key, value]) => [
8641
- key,
8642
- asLeadGenStageEntry(key, value)
8643
- ])
8644
- );
8645
- }
8646
- function getLeadGenStageEntry(stageKey) {
8647
- return getLeadGenStageCatalogFromOntology()[stageKey];
8648
- }
8649
- function isLeadGenStageKey(stageKey) {
8650
- return getLeadGenStageEntry(stageKey) !== void 0;
8651
- }
8652
- function isLeadGenRecordStageValidForEntity(stageKey, entity) {
8653
- const stage = getLeadGenStageEntry(stageKey);
8654
- return stage !== void 0 && (stage.entity === entity || stage.additionalEntities?.includes(entity) === true || stage.recordEntity === entity);
8655
- }
8656
- function isLeadGenActionKey(actionKey) {
8657
- return actionKey.startsWith("lead-gen.") && BUSINESS_ONTOLOGY_VALIDATION_INDEX.actionTypesByLegacyId[actionKey] !== void 0;
8658
- }
8659
7423
 
8660
7424
  // ../core/src/business/acquisition/api-schemas.ts
8661
7425
  var ProcessingStageStatusSchema = z.enum(["success", "no_result", "skipped", "error"]);
8662
- var LeadGenStageKeySchema = z.string().refine((value) => isLeadGenStageKey(value), {
8663
- message: "processing state key must match LEAD_GEN_STAGE_CATALOG"
8664
- });
8665
- var LeadGenActionKeySchema = z.string().refine((value) => isLeadGenActionKey(value), {
8666
- message: "actionKey must match ACTION_REGISTRY"
8667
- });
7426
+ var LeadGenStageKeySchema = z.string().trim().min(1);
7427
+ var LeadGenActionKeySchema = z.string().trim().min(1);
8668
7428
  var crmStageKeys = CRM_STAGE_KEYS_FROM_ONTOLOGY;
8669
7429
  var crmStateKeys = CRM_STATE_KEYS_FROM_ONTOLOGY;
8670
7430
  var CrmStageKeySchema = z.enum(crmStageKeys);
@@ -8720,7 +7480,7 @@ z.object({
8720
7480
  expectedUpdatedAt: z.string().datetime().optional()
8721
7481
  }).strict();
8722
7482
  z.object({
8723
- pipelineKey: z.literal(CRM_PIPELINE_DEFINITION.pipelineKey),
7483
+ pipelineKey: z.string().min(1),
8724
7484
  stageKey: CrmStageKeySchema,
8725
7485
  stateKey: CrmStateKeySchema.nullable().optional(),
8726
7486
  reason: z.string().optional(),
@@ -8921,9 +7681,7 @@ var IcpRubricSchema = z.object({
8921
7681
  customRules: z.string().optional()
8922
7682
  });
8923
7683
  var PipelineStageSchema = z.object({
8924
- key: z.string().refine((value) => isLeadGenStageKey(value), {
8925
- message: "pipeline stage key must match LEAD_GEN_STAGE_CATALOG"
8926
- }),
7684
+ key: LeadGenStageKeySchema,
8927
7685
  label: z.string().optional(),
8928
7686
  enabled: z.boolean().optional(),
8929
7687
  order: z.number().int().optional()
@@ -9391,16 +8149,7 @@ z.object({
9391
8149
  stage: LeadGenStageKeySchema.optional(),
9392
8150
  limit: z.coerce.number().int().min(1).max(500).default(50),
9393
8151
  offset: z.coerce.number().int().min(0).default(0)
9394
- }).strict().superRefine((query, ctx) => {
9395
- if (!query.stage) return;
9396
- if (!isLeadGenRecordStageValidForEntity(query.stage, query.entity)) {
9397
- ctx.addIssue({
9398
- code: z.ZodIssueCode.custom,
9399
- message: `stage "${query.stage}" is not valid for ${query.entity} records`,
9400
- path: ["stage"]
9401
- });
9402
- }
9403
- });
8152
+ }).strict();
9404
8153
  z.object({
9405
8154
  memberId: UuidSchema
9406
8155
  });
@@ -9682,6 +8431,29 @@ var PostMessageLLMAdapter = class {
9682
8431
  function createPostMessageAdapterFactory() {
9683
8432
  return (config) => new PostMessageLLMAdapter(config.provider, config.model);
9684
8433
  }
8434
+ function generateHmacToken(secret, data) {
8435
+ return createHmac("sha256", secret).update(data.toLowerCase().trim()).digest("hex").slice(0, 16);
8436
+ }
8437
+ function classifyPlatformToolError(err, options = {}) {
8438
+ const {
8439
+ timeoutMessages = [],
8440
+ rateLimitCodes = ["rate_limit_exceeded"],
8441
+ rateLimitMessageCodes = [],
8442
+ rateLimitMessageIncludes = []
8443
+ } = options;
8444
+ if (err instanceof Error && timeoutMessages.includes(err.message)) {
8445
+ return "timeout";
8446
+ }
8447
+ if (err instanceof PlatformToolError) {
8448
+ if (rateLimitCodes.includes(err.code)) {
8449
+ return "rate_limit";
8450
+ }
8451
+ if (rateLimitMessageCodes.includes(err.code) && rateLimitMessageIncludes.some((snippet) => err.message.includes(snippet))) {
8452
+ return "rate_limit";
8453
+ }
8454
+ }
8455
+ return "other";
8456
+ }
9685
8457
 
9686
8458
  // src/worker/adapters/create-adapter.ts
9687
8459
  function createAdapter(tool, methods, credential) {
@@ -10011,8 +8783,18 @@ var execution = createAdapter("execution", ["trigger", "triggerAsync"]);
10011
8783
 
10012
8784
  // src/worker/adapters/email.ts
10013
8785
  var email = createAdapter("email", ["send"]);
10014
- var listBuilderStageKeys = Object.keys(LEAD_GEN_STAGE_CATALOG);
10015
- var ListBuilderStageKeySchema = z.enum(listBuilderStageKeys);
8786
+ z.object({
8787
+ success: z.boolean(),
8788
+ tool: z.string(),
8789
+ method: z.string(),
8790
+ result: z.unknown().optional(),
8791
+ error: z.string().optional(),
8792
+ durationMs: z.number().optional()
8793
+ });
8794
+ z.object({
8795
+ credential: z.string().describe("Credential name registered for this integration")
8796
+ });
8797
+ var ListBuilderStageKeySchema = z.string().min(1);
10016
8798
 
10017
8799
  // src/worker/list-builder-workflow.ts
10018
8800
  var ListBuilderResultSchema = z.object({
@@ -10049,15 +8831,6 @@ function getRecordId(record) {
10049
8831
  }
10050
8832
  function assertResultStageTarget(result, defaultStageKey) {
10051
8833
  const stageKey = result.stageKey ?? defaultStageKey;
10052
- const catalogEntry = LEAD_GEN_STAGE_CATALOG[stageKey];
10053
- if (!catalogEntry) {
10054
- throw new Error(`listBuilderWorkflow result stageKey "${stageKey}" is not in LEAD_GEN_STAGE_CATALOG`);
10055
- }
10056
- if (catalogEntry.entity !== result.entity) {
10057
- throw new Error(
10058
- `listBuilderWorkflow result for ${result.entity} "${result.id}" targets ${catalogEntry.entity} stage "${stageKey}"; set result.stageKey to a ${result.entity} stage`
10059
- );
10060
- }
10061
8834
  return stageKey;
10062
8835
  }
10063
8836
  async function filterPendingRecords(records, params, context, options) {
@@ -10567,4 +9340,4 @@ if (workerData != null && workerData.kind === "static") {
10567
9340
  })();
10568
9341
  }
10569
9342
 
10570
- export { ListBuilderResultSchema, ListBuilderResultsSchema, PlatformToolError, acqDb, approval, createAdapter, createAnymailfinderAdapter, createApifyAdapter, createAttioAdapter, createDropboxAdapter, createGmailAdapter, createGoogleSheetsAdapter, createInstantlyAdapter, createMillionVerifierAdapter, createResendAdapter, createSignatureApiAdapter, createStripeAdapter, createTombaAdapter, crm, email, executeWorkflow, execution, list, listBuilderWorkflow, llm, notifications, pdf, platform, projects, scheduler, startWorker, storage };
9343
+ export { ListBuilderResultSchema, ListBuilderResultsSchema, PlatformToolError, acqDb, approval, classifyPlatformToolError, createAdapter, createAnymailfinderAdapter, createApifyAdapter, createAttioAdapter, createDropboxAdapter, createGmailAdapter, createGoogleSheetsAdapter, createInstantlyAdapter, createMillionVerifierAdapter, createResendAdapter, createSignatureApiAdapter, createStripeAdapter, createTombaAdapter, crm, email, executeWorkflow, execution, generateHmacToken, list, listBuilderWorkflow, llm, notifications, pdf, platform, projects, scheduler, startWorker, storage };