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