@elevasis/sdk 1.21.0 → 1.22.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 (160) hide show
  1. package/dist/cli.cjs +951 -171
  2. package/dist/index.d.ts +632 -341
  3. package/dist/index.js +3102 -142
  4. package/dist/node/index.d.ts +1 -0
  5. package/dist/node/index.js +19 -1
  6. package/dist/test-utils/index.d.ts +313 -4
  7. package/dist/test-utils/index.js +3246 -281
  8. package/dist/worker/index.js +3041 -80
  9. package/package.json +3 -3
  10. package/reference/claude-config/hooks/post-edit-validate.mjs +98 -98
  11. package/reference/claude-config/hooks/scaffold-registry-reminder.mjs +188 -188
  12. package/reference/claude-config/hooks/tool-failure-recovery.mjs +73 -73
  13. package/reference/claude-config/registries/graph-skills.json +4 -4
  14. package/reference/claude-config/registries/knowledge-flags.json +0 -2
  15. package/reference/claude-config/rules/active-change-index.md +80 -80
  16. package/reference/claude-config/rules/agent-start-here.md +277 -277
  17. package/reference/claude-config/rules/deployment.md +57 -57
  18. package/reference/claude-config/rules/error-handling.md +56 -56
  19. package/reference/claude-config/rules/execution.md +40 -40
  20. package/reference/claude-config/rules/frontend.md +4 -4
  21. package/reference/claude-config/rules/observability.md +31 -31
  22. package/reference/claude-config/rules/operations.md +29 -17
  23. package/reference/claude-config/rules/organization-model.md +110 -84
  24. package/reference/claude-config/rules/organization-os.md +115 -113
  25. package/reference/claude-config/rules/package-taxonomy.md +33 -33
  26. package/reference/claude-config/rules/platform.md +42 -42
  27. package/reference/claude-config/rules/shared-types.md +49 -46
  28. package/reference/claude-config/rules/task-tracking.md +47 -47
  29. package/reference/claude-config/rules/ui.md +200 -200
  30. package/reference/claude-config/rules/vibe.md +235 -235
  31. package/reference/claude-config/scripts/statusline-command.js +18 -18
  32. package/reference/claude-config/settings.json +34 -34
  33. package/reference/claude-config/skills/deploy/{SKILL.md → skill.md} +156 -156
  34. package/reference/claude-config/skills/dsp/SKILL.md +66 -66
  35. package/reference/claude-config/skills/elevasis/SKILL.md +235 -235
  36. package/reference/claude-config/skills/explore/SKILL.md +6 -6
  37. package/reference/claude-config/skills/git-sync/SKILL.md +126 -126
  38. package/reference/claude-config/skills/knowledge/SKILL.md +314 -299
  39. package/reference/claude-config/skills/knowledge/operations/codify-level-a.md +100 -100
  40. package/reference/claude-config/skills/knowledge/operations/codify-level-b.md +159 -159
  41. package/reference/claude-config/skills/knowledge/operations/customers.md +109 -109
  42. package/reference/claude-config/skills/knowledge/operations/features.md +76 -76
  43. package/reference/claude-config/skills/knowledge/operations/goals.md +118 -118
  44. package/reference/claude-config/skills/knowledge/operations/identity.md +93 -93
  45. package/reference/claude-config/skills/knowledge/operations/labels.md +94 -94
  46. package/reference/claude-config/skills/knowledge/operations/offerings.md +109 -109
  47. package/reference/claude-config/skills/knowledge/operations/roles.md +99 -99
  48. package/reference/claude-config/skills/knowledge/operations/techStack.md +30 -30
  49. package/reference/claude-config/skills/project/SKILL.md +1088 -1088
  50. package/reference/claude-config/skills/run-ui/SKILL.md +73 -73
  51. package/reference/claude-config/skills/save/SKILL.md +3 -3
  52. package/reference/claude-config/skills/setup/SKILL.md +275 -275
  53. package/reference/claude-config/skills/status/SKILL.md +59 -59
  54. package/reference/claude-config/skills/submit-request/SKILL.md +180 -180
  55. package/reference/claude-config/skills/sync/SKILL.md +47 -47
  56. package/reference/claude-config/skills/tutorial/SKILL.md +259 -259
  57. package/reference/claude-config/skills/tutorial/progress-template.md +74 -74
  58. package/reference/claude-config/skills/tutorial/technical.md +1303 -1303
  59. package/reference/claude-config/skills/tutorial/vibe-coder.md +890 -890
  60. package/reference/claude-config/sync-notes/2026-04-22-git-sync-and-sync-notes.md +27 -27
  61. package/reference/claude-config/sync-notes/2026-04-22-lead-gen-deliverability-removal.md +30 -30
  62. package/reference/claude-config/sync-notes/2026-04-24-test-utils-and-template-tests.md +73 -73
  63. package/reference/claude-config/sync-notes/2026-04-24-ui-consolidation-and-sdk-cli-train.md +86 -86
  64. package/reference/claude-config/sync-notes/2026-04-25-auth-role-system-and-settings-roles.md +55 -55
  65. package/reference/claude-config/sync-notes/2026-04-27-crm-hitl-action-layer-cutover.md +97 -97
  66. package/reference/claude-config/sync-notes/2026-04-27-lead-gen-substrate-train.md +112 -112
  67. package/reference/claude-config/sync-notes/2026-04-29-crm-state-and-lead-gen-processing-status.md +93 -93
  68. package/reference/claude-config/sync-notes/2026-05-02-crm-ownership-next-action.md +58 -58
  69. package/reference/claude-config/sync-notes/2026-05-02-template-hardcode-workos-config.md +56 -56
  70. package/reference/claude-config/sync-notes/2026-05-04-elevasis-workspace.md +71 -71
  71. package/reference/claude-config/sync-notes/2026-05-04-knowledge-bundle.md +83 -83
  72. package/reference/claude-config/sync-notes/2026-05-04-template-skills-run-ui-and-tutorial.md +59 -59
  73. package/reference/claude-config/sync-notes/2026-05-05-list-builder.md +42 -42
  74. package/reference/claude-config/sync-notes/2026-05-06-crm-spine.md +60 -60
  75. package/reference/claude-config/sync-notes/2026-05-06-sdk-changes-release-train.md +37 -37
  76. package/reference/claude-config/sync-notes/2026-05-07-sdk-changes-release-train.md +34 -34
  77. package/reference/claude-config/sync-notes/2026-05-08-resource-governance-scaffold-guidance.md +38 -38
  78. package/reference/claude-config/sync-notes/2026-05-09-clients-domain.md +32 -32
  79. package/reference/claude-config/sync-notes/2026-05-09-command-system.md +33 -33
  80. package/reference/claude-config/sync-notes/2026-05-09-resource-governance-and-misc.md +69 -69
  81. package/reference/claude-config/sync-notes/2026-05-12-sdk-ready-release-train.md +30 -30
  82. package/reference/claude-config/sync-notes/2026-05-14-organization-model-ontology-refactor.md +42 -0
  83. package/reference/claude-config/sync-notes/README.md +43 -43
  84. package/reference/cli.mdx +808 -808
  85. package/reference/concepts.mdx +146 -146
  86. package/reference/deployment/api.mdx +297 -297
  87. package/reference/deployment/command-center.mdx +209 -209
  88. package/reference/deployment/index.mdx +195 -195
  89. package/reference/deployment/provided-features.mdx +107 -107
  90. package/reference/deployment/ui-execution.mdx +250 -250
  91. package/reference/examples/organization-model.ts +146 -83
  92. package/reference/framework/agent.mdx +156 -156
  93. package/reference/framework/index.mdx +195 -195
  94. package/reference/framework/interaction-guidance.mdx +182 -182
  95. package/reference/framework/memory.mdx +326 -326
  96. package/reference/framework/project-structure.mdx +282 -282
  97. package/reference/framework/tutorial-system.mdx +135 -135
  98. package/reference/getting-started.mdx +142 -142
  99. package/reference/index.mdx +106 -106
  100. package/reference/packages/core/src/README.md +14 -14
  101. package/reference/packages/core/src/business/README.md +2 -2
  102. package/reference/packages/core/src/knowledge/README.md +32 -32
  103. package/reference/packages/core/src/organization-model/README.md +149 -149
  104. package/reference/packages/core/src/test-utils/README.md +37 -37
  105. package/reference/packages/ui/src/api/README.md +18 -18
  106. package/reference/packages/ui/src/app/README.md +24 -24
  107. package/reference/packages/ui/src/auth/README.md +18 -18
  108. package/reference/packages/ui/src/components/README.md +24 -24
  109. package/reference/packages/ui/src/execution/README.md +16 -16
  110. package/reference/packages/ui/src/features/README.md +28 -28
  111. package/reference/packages/ui/src/graph/README.md +16 -16
  112. package/reference/packages/ui/src/hooks/README.md +23 -23
  113. package/reference/packages/ui/src/initialization/README.md +19 -19
  114. package/reference/packages/ui/src/knowledge/README.md +31 -31
  115. package/reference/packages/ui/src/organization/README.md +18 -18
  116. package/reference/packages/ui/src/profile/README.md +19 -19
  117. package/reference/packages/ui/src/provider/README.md +32 -32
  118. package/reference/packages/ui/src/router/README.md +18 -18
  119. package/reference/packages/ui/src/sse/README.md +13 -13
  120. package/reference/packages/ui/src/test-utils/README.md +7 -7
  121. package/reference/packages/ui/src/theme/README.md +23 -23
  122. package/reference/packages/ui/src/theme/presets/README.md +19 -19
  123. package/reference/packages/ui/src/types/README.md +16 -16
  124. package/reference/packages/ui/src/utils/README.md +18 -18
  125. package/reference/packages/ui/src/zustand/README.md +18 -18
  126. package/reference/platform-tools/adapters-integration.mdx +301 -301
  127. package/reference/platform-tools/adapters-platform.mdx +553 -553
  128. package/reference/platform-tools/index.mdx +217 -217
  129. package/reference/platform-tools/type-safety.mdx +82 -82
  130. package/reference/resources/index.mdx +349 -349
  131. package/reference/resources/patterns.mdx +449 -449
  132. package/reference/resources/types.mdx +116 -116
  133. package/reference/roadmap.mdx +165 -165
  134. package/reference/runtime.mdx +173 -173
  135. package/reference/scaffold/core/organization-graph.mdx +110 -90
  136. package/reference/scaffold/core/organization-model.mdx +226 -219
  137. package/reference/scaffold/index.mdx +67 -67
  138. package/reference/scaffold/operations/propagation-pipeline.md +77 -77
  139. package/reference/scaffold/operations/scaffold-maintenance.md +12 -12
  140. package/reference/scaffold/operations/workflow-recipes.md +138 -138
  141. package/reference/scaffold/recipes/add-a-feature.md +308 -88
  142. package/reference/scaffold/recipes/add-a-resource.md +134 -110
  143. package/reference/scaffold/recipes/customize-knowledge-browser.md +5 -5
  144. package/reference/scaffold/recipes/customize-organization-model.md +273 -138
  145. package/reference/scaffold/recipes/extend-a-base-entity.md +8 -8
  146. package/reference/scaffold/recipes/extend-crm.md +3 -3
  147. package/reference/scaffold/recipes/extend-lead-gen.md +400 -400
  148. package/reference/scaffold/recipes/gate-by-feature-or-admin.md +118 -118
  149. package/reference/scaffold/recipes/index.md +46 -46
  150. package/reference/scaffold/recipes/query-the-knowledge-graph.md +197 -170
  151. package/reference/scaffold/reference/contracts.md +2101 -2096
  152. package/reference/scaffold/reference/glossary.md +76 -76
  153. package/reference/scaffold/ui/composition-extensibility.mdx +233 -233
  154. package/reference/scaffold/ui/customization.md +243 -243
  155. package/reference/scaffold/ui/feature-flags-and-gating.md +46 -46
  156. package/reference/scaffold/ui/feature-shell.mdx +72 -72
  157. package/reference/scaffold/ui/recipes.md +221 -214
  158. package/reference/spine/spine-primer.md +96 -96
  159. package/reference/templates/index.mdx +47 -47
  160. package/reference/troubleshooting.mdx +223 -223
package/dist/cli.cjs CHANGED
@@ -36613,73 +36613,78 @@ var DateRangeSchema = external_exports.object({
36613
36613
 
36614
36614
  // ../core/src/organization-model/icons.ts
36615
36615
  var ORGANIZATION_MODEL_ICON_TOKENS = [
36616
- "nav.dashboard",
36617
- "nav.calendar",
36618
- "nav.sales",
36619
- "nav.crm",
36620
- "nav.lead-gen",
36621
- "nav.projects",
36622
- "nav.operations",
36623
- "nav.monitoring",
36624
- "nav.knowledge",
36625
- "nav.settings",
36626
- "nav.admin",
36627
- "nav.archive",
36628
- "knowledge.playbook",
36629
- "knowledge.strategy",
36630
- "knowledge.reference",
36631
- "feature.dashboard",
36632
- "feature.calendar",
36633
- "feature.business",
36634
- "feature.sales",
36635
- "feature.crm",
36636
- "feature.finance",
36637
- "feature.lead-gen",
36638
- "feature.platform",
36639
- "feature.projects",
36640
- "feature.operations",
36641
- "feature.knowledge",
36642
- "feature.monitoring",
36643
- "feature.settings",
36644
- "feature.admin",
36645
- "feature.archive",
36646
- "feature.seo",
36647
- "resource.agent",
36648
- "resource.workflow",
36649
- "resource.integration",
36650
- "resource.database",
36651
- "resource.user",
36652
- "resource.team",
36653
- "integration.gmail",
36654
- "integration.google-sheets",
36655
- "integration.attio",
36656
- "surface.dashboard",
36657
- "surface.calendar",
36658
- "surface.overview",
36659
- "surface.command-view",
36660
- "surface.command-queue",
36661
- "surface.pipeline",
36662
- "surface.lists",
36663
- "surface.resources",
36664
- "surface.settings",
36665
- "status.success",
36666
- "status.error",
36667
- "status.warning",
36668
- "status.info",
36669
- "status.pending",
36670
- "action.approve",
36671
- "action.reject",
36672
- "action.retry",
36673
- "action.edit",
36674
- "action.view",
36675
- "action.launch",
36676
- "action.message",
36677
- "action.escalate",
36678
- "action.promote",
36679
- "action.submit",
36680
- "action.email"
36616
+ // Navigation / app areas
36617
+ "dashboard",
36618
+ "calendar",
36619
+ "sales",
36620
+ "crm",
36621
+ "lead-gen",
36622
+ "projects",
36623
+ "operations",
36624
+ "monitoring",
36625
+ "knowledge",
36626
+ "settings",
36627
+ "admin",
36628
+ "archive",
36629
+ "business",
36630
+ "finance",
36631
+ "platform",
36632
+ "seo",
36633
+ // Knowledge kinds
36634
+ "playbook",
36635
+ "strategy",
36636
+ "reference",
36637
+ // Resource kinds
36638
+ "agent",
36639
+ "workflow",
36640
+ "integration",
36641
+ "database",
36642
+ "user",
36643
+ "team",
36644
+ // Integration specifics
36645
+ "gmail",
36646
+ "google-sheets",
36647
+ "attio",
36648
+ // Surface / UI views
36649
+ "overview",
36650
+ "command-view",
36651
+ "command-queue",
36652
+ "pipeline",
36653
+ "lists",
36654
+ "resources",
36655
+ // Actions
36656
+ "approve",
36657
+ "reject",
36658
+ "retry",
36659
+ "edit",
36660
+ "view",
36661
+ "launch",
36662
+ "message",
36663
+ "escalate",
36664
+ "promote",
36665
+ "submit",
36666
+ "email",
36667
+ // Status
36668
+ "success",
36669
+ "error",
36670
+ "warning",
36671
+ "info",
36672
+ "pending",
36673
+ // OM / UI group icons
36674
+ "bolt",
36675
+ "building",
36676
+ "briefcase",
36677
+ "apps",
36678
+ "graph",
36679
+ "shield",
36680
+ "users",
36681
+ "chart-bar",
36682
+ "search"
36681
36683
  ];
36682
- var CustomIconTokenSchema = external_exports.string().trim().max(80).regex(/^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/, "Custom icon tokens must start with custom.");
36684
+ var CustomIconTokenSchema = external_exports.string().trim().max(80).regex(
36685
+ /^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
36686
+ 'Custom icon tokens must start with "custom." followed by lowercase alphanumeric segments'
36687
+ );
36683
36688
  var OrganizationModelBuiltinIconTokenSchema = external_exports.enum(ORGANIZATION_MODEL_ICON_TOKENS);
36684
36689
  var OrganizationModelIconTokenSchema = external_exports.union([
36685
36690
  OrganizationModelBuiltinIconTokenSchema,
@@ -37041,7 +37046,99 @@ var LEAD_GEN_ACTION_ENTRIES = Object.fromEntries(
37041
37046
  return [parsed.id, parsed];
37042
37047
  })
37043
37048
  );
37044
- var DEFAULT_ORGANIZATION_MODEL_ACTIONS = LEAD_GEN_ACTION_ENTRIES;
37049
+ var CRM_ACTION_ENTRY_INPUTS = [
37050
+ {
37051
+ id: "send_reply",
37052
+ order: 210,
37053
+ label: "Send Reply",
37054
+ description: "Send a contextual reply for an active CRM deal.",
37055
+ scope: { domain: "sales" },
37056
+ resourceId: "crm-send-reply-workflow",
37057
+ affects: ["crm.deal"]
37058
+ },
37059
+ {
37060
+ id: "send_link",
37061
+ order: 220,
37062
+ label: "Send Booking Link",
37063
+ description: "Send a booking link to move a deal toward a scheduled call.",
37064
+ scope: { domain: "sales" },
37065
+ resourceId: "crm-send-booking-link-workflow",
37066
+ affects: ["crm.deal"]
37067
+ },
37068
+ {
37069
+ id: "send_nudge",
37070
+ order: 230,
37071
+ label: "Send Nudge",
37072
+ description: "Send a follow-up nudge for a stalled CRM deal.",
37073
+ scope: { domain: "sales" },
37074
+ resourceId: "crm-send-nudge-workflow",
37075
+ affects: ["crm.deal"]
37076
+ },
37077
+ {
37078
+ id: "rebook",
37079
+ order: 240,
37080
+ label: "Rebook",
37081
+ description: "Rebook a missed or rescheduled CRM appointment.",
37082
+ scope: { domain: "sales" },
37083
+ resourceId: "crm-rebook-workflow",
37084
+ affects: ["crm.deal"]
37085
+ },
37086
+ {
37087
+ id: "move_to_proposal",
37088
+ order: 250,
37089
+ label: "Move to Proposal",
37090
+ description: "Advance a qualified CRM deal into the proposal stage.",
37091
+ scope: { domain: "sales" },
37092
+ resourceId: "move_to_proposal-workflow",
37093
+ affects: ["crm.deal"]
37094
+ },
37095
+ {
37096
+ id: "move_to_closing",
37097
+ order: 260,
37098
+ label: "Move to Closing",
37099
+ description: "Advance a proposal-stage CRM deal into closing.",
37100
+ scope: { domain: "sales" },
37101
+ resourceId: "move_to_closing-workflow",
37102
+ affects: ["crm.deal"]
37103
+ },
37104
+ {
37105
+ id: "move_to_closed_won",
37106
+ order: 270,
37107
+ label: "Close Won",
37108
+ description: "Mark a CRM deal as closed won.",
37109
+ scope: { domain: "sales" },
37110
+ resourceId: "move_to_closed_won-workflow",
37111
+ affects: ["crm.deal"]
37112
+ },
37113
+ {
37114
+ id: "move_to_closed_lost",
37115
+ order: 280,
37116
+ label: "Close Lost",
37117
+ description: "Mark a CRM deal as closed lost.",
37118
+ scope: { domain: "sales" },
37119
+ resourceId: "move_to_closed_lost-workflow",
37120
+ affects: ["crm.deal"]
37121
+ },
37122
+ {
37123
+ id: "move_to_nurturing",
37124
+ order: 290,
37125
+ label: "Move to Nurturing",
37126
+ description: "Move a CRM deal into nurturing for future follow-up.",
37127
+ scope: { domain: "sales" },
37128
+ resourceId: "move_to_nurturing-workflow",
37129
+ affects: ["crm.deal"]
37130
+ }
37131
+ ];
37132
+ var CRM_ACTION_ENTRIES = Object.fromEntries(
37133
+ CRM_ACTION_ENTRY_INPUTS.map((action) => {
37134
+ const parsed = ActionSchema.parse(action);
37135
+ return [parsed.id, parsed];
37136
+ })
37137
+ );
37138
+ var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {
37139
+ ...LEAD_GEN_ACTION_ENTRIES,
37140
+ ...CRM_ACTION_ENTRIES
37141
+ };
37045
37142
 
37046
37143
  // ../core/src/organization-model/content-kinds/types.ts
37047
37144
  var ContentNodeBaseSchema = external_exports.object({
@@ -37084,6 +37181,401 @@ var ExtensionNodeSchema = external_exports.object({
37084
37181
  data: external_exports.record(external_exports.string(), external_exports.unknown()).optional().meta({ label: "Data" })
37085
37182
  });
37086
37183
 
37184
+ // ../core/src/organization-model/ontology.ts
37185
+ var OntologyKindSchema = external_exports.enum([
37186
+ "object",
37187
+ "link",
37188
+ "action",
37189
+ "catalog",
37190
+ "event",
37191
+ "interface",
37192
+ "value-type",
37193
+ "property",
37194
+ "group",
37195
+ "surface"
37196
+ ]);
37197
+ var SYSTEM_PATH_PATTERN = "[a-z0-9][a-z0-9-]*(?:\\.[a-z0-9][a-z0-9-]*)*";
37198
+ var LOCAL_ID_PATTERN = "[a-z0-9][a-z0-9._-]*";
37199
+ var ONTOLOGY_ID_PATTERN = `^(global|${SYSTEM_PATH_PATTERN}):(${OntologyKindSchema.options.join("|")})\\/(${LOCAL_ID_PATTERN})$`;
37200
+ var ONTOLOGY_ID_REGEX = new RegExp(ONTOLOGY_ID_PATTERN);
37201
+ var OntologyIdSchema = external_exports.string().trim().min(1).max(300).regex(
37202
+ ONTOLOGY_ID_REGEX,
37203
+ "Ontology IDs must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
37204
+ );
37205
+ function parseOntologyId(id) {
37206
+ const normalized = OntologyIdSchema.parse(id);
37207
+ const match = ONTOLOGY_ID_REGEX.exec(normalized);
37208
+ if (match === null) {
37209
+ throw new Error(`Invalid ontology ID "${id}"`);
37210
+ }
37211
+ return {
37212
+ id: normalized,
37213
+ scope: match[1],
37214
+ kind: match[2],
37215
+ localId: match[3],
37216
+ isGlobal: match[1] === "global"
37217
+ };
37218
+ }
37219
+ function formatOntologyId(input) {
37220
+ return OntologyIdSchema.parse(`${input.scope}:${input.kind}/${input.localId}`);
37221
+ }
37222
+ var OntologyReferenceListSchema = external_exports.array(OntologyIdSchema).default([]).optional();
37223
+ var OntologyRecordBaseSchema = external_exports.object({
37224
+ id: OntologyIdSchema,
37225
+ label: external_exports.string().trim().min(1).max(160).optional(),
37226
+ description: external_exports.string().trim().min(1).max(2e3).optional(),
37227
+ ownerSystemId: external_exports.string().trim().min(1).max(200).optional(),
37228
+ aliases: external_exports.array(OntologyIdSchema).optional()
37229
+ }).passthrough();
37230
+ var OntologyObjectTypeSchema = OntologyRecordBaseSchema.extend({
37231
+ properties: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional(),
37232
+ storage: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
37233
+ });
37234
+ var OntologyLinkTypeSchema = OntologyRecordBaseSchema.extend({
37235
+ from: OntologyIdSchema,
37236
+ to: OntologyIdSchema,
37237
+ cardinality: external_exports.string().trim().min(1).max(80).optional(),
37238
+ via: external_exports.string().trim().min(1).max(255).optional()
37239
+ });
37240
+ var OntologyActionTypeSchema = OntologyRecordBaseSchema.extend({
37241
+ actsOn: OntologyReferenceListSchema,
37242
+ input: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional(),
37243
+ effects: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).optional()
37244
+ });
37245
+ var OntologyCatalogTypeSchema = OntologyRecordBaseSchema.extend({
37246
+ kind: external_exports.string().trim().min(1).max(120).optional(),
37247
+ appliesTo: OntologyIdSchema.optional(),
37248
+ entries: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional()
37249
+ });
37250
+ var OntologyEventTypeSchema = OntologyRecordBaseSchema.extend({
37251
+ payload: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional()
37252
+ });
37253
+ var OntologyInterfaceTypeSchema = OntologyRecordBaseSchema.extend({
37254
+ properties: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional()
37255
+ });
37256
+ var OntologyValueTypeSchema = OntologyRecordBaseSchema.extend({
37257
+ primitive: external_exports.string().trim().min(1).max(120).optional()
37258
+ });
37259
+ var OntologySharedPropertySchema = OntologyRecordBaseSchema.extend({
37260
+ valueType: OntologyIdSchema.optional(),
37261
+ searchable: external_exports.boolean().optional(),
37262
+ pii: external_exports.boolean().optional()
37263
+ });
37264
+ var OntologyGroupSchema = OntologyRecordBaseSchema.extend({
37265
+ members: OntologyReferenceListSchema
37266
+ });
37267
+ var OntologySurfaceTypeSchema = OntologyRecordBaseSchema.extend({
37268
+ route: external_exports.string().trim().min(1).max(500).optional()
37269
+ });
37270
+ var OntologyScopeSchema = external_exports.object({
37271
+ objectTypes: external_exports.record(OntologyIdSchema, OntologyObjectTypeSchema).default({}).optional(),
37272
+ linkTypes: external_exports.record(OntologyIdSchema, OntologyLinkTypeSchema).default({}).optional(),
37273
+ actionTypes: external_exports.record(OntologyIdSchema, OntologyActionTypeSchema).default({}).optional(),
37274
+ catalogTypes: external_exports.record(OntologyIdSchema, OntologyCatalogTypeSchema).default({}).optional(),
37275
+ eventTypes: external_exports.record(OntologyIdSchema, OntologyEventTypeSchema).default({}).optional(),
37276
+ interfaceTypes: external_exports.record(OntologyIdSchema, OntologyInterfaceTypeSchema).default({}).optional(),
37277
+ valueTypes: external_exports.record(OntologyIdSchema, OntologyValueTypeSchema).default({}).optional(),
37278
+ sharedProperties: external_exports.record(OntologyIdSchema, OntologySharedPropertySchema).default({}).optional(),
37279
+ groups: external_exports.record(OntologyIdSchema, OntologyGroupSchema).default({}).optional(),
37280
+ surfaces: external_exports.record(OntologyIdSchema, OntologySurfaceTypeSchema).default({}).optional()
37281
+ }).default({});
37282
+ var DEFAULT_ONTOLOGY_SCOPE = {
37283
+ valueTypes: {
37284
+ "global:value-type/uuid": {
37285
+ id: "global:value-type/uuid",
37286
+ label: "UUID",
37287
+ primitive: "string"
37288
+ },
37289
+ "global:value-type/text": {
37290
+ id: "global:value-type/text",
37291
+ label: "Text",
37292
+ primitive: "string"
37293
+ },
37294
+ "global:value-type/url": {
37295
+ id: "global:value-type/url",
37296
+ label: "URL",
37297
+ primitive: "string"
37298
+ },
37299
+ "global:value-type/email": {
37300
+ id: "global:value-type/email",
37301
+ label: "Email",
37302
+ primitive: "string"
37303
+ }
37304
+ }
37305
+ };
37306
+ var SCOPE_KIND = {
37307
+ objectTypes: "object",
37308
+ linkTypes: "link",
37309
+ actionTypes: "action",
37310
+ catalogTypes: "catalog",
37311
+ eventTypes: "event",
37312
+ interfaceTypes: "interface",
37313
+ valueTypes: "value-type",
37314
+ sharedProperties: "property",
37315
+ groups: "group",
37316
+ surfaces: "surface"
37317
+ };
37318
+ var SCOPE_KEYS = Object.keys(SCOPE_KIND);
37319
+ function ontologyGraphNodeId(id) {
37320
+ return `ontology:${OntologyIdSchema.parse(id)}`;
37321
+ }
37322
+ function listResolvedOntologyRecords(index) {
37323
+ return SCOPE_KEYS.flatMap((scopeKey) => {
37324
+ const kind = SCOPE_KIND[scopeKey];
37325
+ return Object.entries(index[scopeKey]).sort(([leftId], [rightId]) => leftId.localeCompare(rightId)).map(([id, record2]) => ({
37326
+ id,
37327
+ kind,
37328
+ record: record2
37329
+ }));
37330
+ });
37331
+ }
37332
+ function originFromContext(context) {
37333
+ return {
37334
+ kind: context.kind,
37335
+ source: context.source,
37336
+ path: context.path,
37337
+ ...context.systemPath !== void 0 ? { systemPath: context.systemPath } : {},
37338
+ ...context.legacyId !== void 0 ? { legacyId: context.legacyId } : {}
37339
+ };
37340
+ }
37341
+ function createEmptyIndex() {
37342
+ return {
37343
+ objectTypes: {},
37344
+ linkTypes: {},
37345
+ actionTypes: {},
37346
+ catalogTypes: {},
37347
+ eventTypes: {},
37348
+ interfaceTypes: {},
37349
+ valueTypes: {},
37350
+ sharedProperties: {},
37351
+ groups: {},
37352
+ surfaces: {}
37353
+ };
37354
+ }
37355
+ function sortResolvedOntologyIndex(index) {
37356
+ const sorted = createEmptyIndex();
37357
+ for (const scopeKey of SCOPE_KEYS) {
37358
+ const target = sorted[scopeKey];
37359
+ for (const [id, record2] of Object.entries(index[scopeKey]).sort(
37360
+ ([leftId], [rightId]) => leftId.localeCompare(rightId)
37361
+ )) {
37362
+ target[id] = record2;
37363
+ }
37364
+ }
37365
+ return sorted;
37366
+ }
37367
+ function childSystemsOf(system) {
37368
+ return system.systems ?? system.subsystems ?? {};
37369
+ }
37370
+ function addRecord(index, diagnostics, sourcesById, scopeKey, record2, context) {
37371
+ let parsed;
37372
+ try {
37373
+ parsed = parseOntologyId(record2.id);
37374
+ } catch {
37375
+ diagnostics.push({
37376
+ code: "invalid_ontology_id",
37377
+ message: `Invalid ontology ID "${record2.id}" from ${context.source} at ${context.path.join(".")}`,
37378
+ id: record2.id,
37379
+ path: context.path,
37380
+ source: context.source,
37381
+ origin: originFromContext(context)
37382
+ });
37383
+ return;
37384
+ }
37385
+ const expectedKind = SCOPE_KIND[scopeKey];
37386
+ if (parsed.kind !== expectedKind) {
37387
+ diagnostics.push({
37388
+ code: "ontology_kind_mismatch",
37389
+ message: `Ontology ID "${record2.id}" has kind "${parsed.kind}" but was authored in ${scopeKey} (${expectedKind}) at ${context.path.join(".")}`,
37390
+ id: record2.id,
37391
+ path: context.path,
37392
+ source: context.source,
37393
+ origin: originFromContext(context)
37394
+ });
37395
+ return;
37396
+ }
37397
+ const existing = sourcesById.get(parsed.id);
37398
+ if (existing !== void 0) {
37399
+ diagnostics.push({
37400
+ code: "duplicate_ontology_id",
37401
+ message: `Duplicate ontology ID "${parsed.id}" from ${context.source} at ${context.path.join(".")} conflicts with ${existing.source} at ${existing.path.join(".")}`,
37402
+ id: parsed.id,
37403
+ path: context.path,
37404
+ source: context.source,
37405
+ origin: originFromContext(context),
37406
+ existingSource: existing.source,
37407
+ existingOrigin: originFromContext(existing)
37408
+ });
37409
+ return;
37410
+ }
37411
+ sourcesById.set(parsed.id, context);
37412
+ index[scopeKey][parsed.id] = {
37413
+ ...record2,
37414
+ origin: originFromContext(context)
37415
+ };
37416
+ }
37417
+ function addScope(index, diagnostics, sourcesById, scope, source, path3) {
37418
+ if (scope === void 0) return;
37419
+ for (const scopeKey of SCOPE_KEYS) {
37420
+ const records = scope[scopeKey] ?? {};
37421
+ for (const [key, record2] of Object.entries(records)) {
37422
+ addRecord(index, diagnostics, sourcesById, scopeKey, record2, {
37423
+ source,
37424
+ path: [...path3, scopeKey, key],
37425
+ kind: "authored",
37426
+ systemPath: source.startsWith("system:") ? source.slice("system:".length, -".ontology".length) : void 0
37427
+ });
37428
+ }
37429
+ }
37430
+ }
37431
+ function legacyObjectId(entity) {
37432
+ return formatOntologyId({ scope: entity.ownedBySystemId, kind: "object", localId: entity.id });
37433
+ }
37434
+ function legacyActionOwner(action, entities) {
37435
+ const firstAffectedEntityId = action.affects?.find((entityId) => entities[entityId] !== void 0);
37436
+ if (firstAffectedEntityId !== void 0) {
37437
+ return entities[firstAffectedEntityId].ownedBySystemId;
37438
+ }
37439
+ if (typeof action.scope === "object") {
37440
+ return action.scope.domain;
37441
+ }
37442
+ return "global";
37443
+ }
37444
+ function addLegacyEntityProjections(index, diagnostics, sourcesById, entities) {
37445
+ for (const entity of Object.values(entities)) {
37446
+ const objectType = {
37447
+ id: legacyObjectId(entity),
37448
+ label: entity.label,
37449
+ description: entity.description,
37450
+ ownerSystemId: entity.ownedBySystemId,
37451
+ ...entity.table !== void 0 ? {
37452
+ storage: {
37453
+ kind: "table",
37454
+ table: entity.table
37455
+ }
37456
+ } : {},
37457
+ legacyEntityId: entity.id,
37458
+ ...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
37459
+ ...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
37460
+ };
37461
+ addRecord(index, diagnostics, sourcesById, "objectTypes", objectType, {
37462
+ source: "legacy.entities",
37463
+ path: ["entities", entity.id],
37464
+ kind: "projected",
37465
+ systemPath: entity.ownedBySystemId,
37466
+ legacyId: entity.id
37467
+ });
37468
+ entity.links?.forEach((link, linkIndex) => {
37469
+ const targetEntity = entities[link.toEntity];
37470
+ if (targetEntity === void 0) return;
37471
+ const linkType = {
37472
+ id: formatOntologyId({
37473
+ scope: entity.ownedBySystemId,
37474
+ kind: "link",
37475
+ localId: `${entity.id}-${link.toEntity}-${linkIndex}`
37476
+ }),
37477
+ label: link.label ?? link.kind,
37478
+ ownerSystemId: entity.ownedBySystemId,
37479
+ from: legacyObjectId(entity),
37480
+ to: legacyObjectId(targetEntity),
37481
+ cardinality: link.kind,
37482
+ ...link.via !== void 0 ? { via: link.via } : {},
37483
+ legacyEntityId: entity.id
37484
+ };
37485
+ addRecord(index, diagnostics, sourcesById, "linkTypes", linkType, {
37486
+ source: "legacy.entities.links",
37487
+ path: ["entities", entity.id, "links", linkIndex],
37488
+ kind: "projected",
37489
+ systemPath: entity.ownedBySystemId,
37490
+ legacyId: `${entity.id}.links.${linkIndex}`
37491
+ });
37492
+ });
37493
+ }
37494
+ }
37495
+ function addLegacyActionProjections(index, diagnostics, sourcesById, actions, entities) {
37496
+ for (const action of Object.values(actions)) {
37497
+ const ownerSystemId = legacyActionOwner(action, entities);
37498
+ const actionType = {
37499
+ id: formatOntologyId({ scope: ownerSystemId, kind: "action", localId: action.id }),
37500
+ label: action.label,
37501
+ description: action.description,
37502
+ ownerSystemId,
37503
+ actsOn: action.affects?.map((entityId) => entities[entityId] ? legacyObjectId(entities[entityId]) : void 0).filter((id) => id !== void 0),
37504
+ ...action.resourceId !== void 0 ? { resourceId: action.resourceId } : {},
37505
+ ...action.invocations !== void 0 ? { invocations: action.invocations } : {},
37506
+ ...action.lifecycle !== void 0 ? { lifecycle: action.lifecycle } : {},
37507
+ legacyActionId: action.id
37508
+ };
37509
+ addRecord(index, diagnostics, sourcesById, "actionTypes", actionType, {
37510
+ source: "legacy.actions",
37511
+ path: ["actions", action.id],
37512
+ kind: "projected",
37513
+ systemPath: ownerSystemId,
37514
+ legacyId: action.id
37515
+ });
37516
+ }
37517
+ }
37518
+ function addSystemContentProjections(index, diagnostics, sourcesById, systemPath, system, schemaPath) {
37519
+ const content = system.content ?? {};
37520
+ for (const [localId, node] of Object.entries(content)) {
37521
+ if (node.kind !== "schema") continue;
37522
+ const entries = Object.fromEntries(
37523
+ Object.entries(content).filter(([, candidate]) => candidate.parentContentId === localId).map(([entryId, candidate]) => [
37524
+ entryId,
37525
+ {
37526
+ label: candidate.label ?? entryId,
37527
+ type: candidate.type,
37528
+ ...candidate.description !== void 0 ? { description: candidate.description } : {},
37529
+ ...candidate.data !== void 0 ? candidate.data : {}
37530
+ }
37531
+ ])
37532
+ );
37533
+ const catalogType = {
37534
+ id: formatOntologyId({ scope: systemPath, kind: "catalog", localId }),
37535
+ label: node.label ?? localId,
37536
+ description: node.description,
37537
+ ownerSystemId: systemPath,
37538
+ kind: node.type,
37539
+ ...typeof node.data?.["entityId"] === "string" ? { appliesTo: formatOntologyId({ scope: systemPath, kind: "object", localId: node.data["entityId"] }) } : {},
37540
+ ...Object.keys(entries).length > 0 ? { entries } : {},
37541
+ ...node.data !== void 0 ? { data: node.data } : {},
37542
+ legacyContentId: `${systemPath}:${localId}`
37543
+ };
37544
+ addRecord(index, diagnostics, sourcesById, "catalogTypes", catalogType, {
37545
+ source: "legacy.system.content",
37546
+ path: [...schemaPath, "content", localId],
37547
+ kind: "projected",
37548
+ systemPath,
37549
+ legacyId: `${systemPath}:${localId}`
37550
+ });
37551
+ }
37552
+ }
37553
+ function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schemaPath) {
37554
+ for (const [key, system] of Object.entries(systems)) {
37555
+ const systemPath = prefix ? `${prefix}.${key}` : key;
37556
+ const currentPath = [...schemaPath, key];
37557
+ addScope(index, diagnostics, sourcesById, system.ontology, `system:${systemPath}.ontology`, [
37558
+ ...currentPath,
37559
+ "ontology"
37560
+ ]);
37561
+ addSystemContentProjections(index, diagnostics, sourcesById, systemPath, system, currentPath);
37562
+ addSystemScopes(index, diagnostics, sourcesById, childSystemsOf(system), systemPath, [
37563
+ ...currentPath,
37564
+ system.systems !== void 0 ? "systems" : "subsystems"
37565
+ ]);
37566
+ }
37567
+ }
37568
+ function compileOrganizationOntology(model) {
37569
+ const ontology = createEmptyIndex();
37570
+ const diagnostics = [];
37571
+ const sourcesById = /* @__PURE__ */ new Map();
37572
+ addScope(ontology, diagnostics, sourcesById, model.ontology, "organization.ontology", ["ontology"]);
37573
+ addSystemScopes(ontology, diagnostics, sourcesById, model.systems ?? {}, "", ["systems"]);
37574
+ addLegacyEntityProjections(ontology, diagnostics, sourcesById, model.entities ?? {});
37575
+ addLegacyActionProjections(ontology, diagnostics, sourcesById, model.actions ?? {}, model.entities ?? {});
37576
+ return { ontology: sortResolvedOntologyIndex(ontology), diagnostics };
37577
+ }
37578
+
37087
37579
  // ../core/src/organization-model/domains/systems.ts
37088
37580
  var SystemKindSchema = external_exports.enum(["product", "operational", "platform", "diagnostic"]).meta({ label: "System kind", color: "blue" });
37089
37581
  var SystemLifecycleSchema = external_exports.enum(["draft", "beta", "active", "deprecated", "archived"]).meta({ label: "Lifecycle", color: "teal" });
@@ -37104,6 +37596,17 @@ var SystemUiSchema = external_exports.object({
37104
37596
  icon: IconNameSchema.optional(),
37105
37597
  order: external_exports.number().int().optional()
37106
37598
  });
37599
+ var JsonValueSchema = external_exports.lazy(
37600
+ () => external_exports.union([
37601
+ external_exports.string(),
37602
+ external_exports.number(),
37603
+ external_exports.boolean(),
37604
+ external_exports.null(),
37605
+ external_exports.array(JsonValueSchema),
37606
+ external_exports.record(external_exports.string(), JsonValueSchema)
37607
+ ])
37608
+ );
37609
+ var SystemConfigSchema = external_exports.record(external_exports.string().trim().min(1).max(200), JsonValueSchema).default({}).optional();
37107
37610
  var SystemEntrySchema = external_exports.object({
37108
37611
  /** Stable tenant-defined system id (e.g. "sys.lead-gen" or "sales.crm"). */
37109
37612
  id: SystemIdSchema,
@@ -37149,11 +37652,21 @@ var SystemEntrySchema = external_exports.object({
37149
37652
  /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
37150
37653
  order: external_exports.number(),
37151
37654
  /**
37152
- * System-scoped operational data, co-located with the owning system.
37153
- * Per L1, L3, L13: keyed by local NodeId (the key is the local id; qualified
37154
- * id is `<system-path>:<local-id>`, computed by graph projection).
37155
- * Per L14: every ContentNode carries both `kind` and `type`.
37156
- * Per D2: unregistered (kind, type) pairs parse successfully.
37655
+ * System-local JSON settings and defaults. Strongly typed OM fields,
37656
+ * secrets, credentials, and runtime state stay outside this bucket.
37657
+ */
37658
+ config: SystemConfigSchema,
37659
+ /**
37660
+ * System-owned ontology declarations. `systems` is now the canonical child
37661
+ * key; this scope holds the object, action, catalog, link, event, and
37662
+ * shared contract records owned by this system.
37663
+ */
37664
+ ontology: OntologyScopeSchema.optional(),
37665
+ /**
37666
+ * @deprecated Compatibility-only bridge for old tenant content nodes and
37667
+ * migration readers. New schema/catalog authoring belongs in ontology;
37668
+ * new system-local settings belong in config. Bridge nodes are keyed by
37669
+ * local NodeId and may still project to content-node:* graph IDs.
37157
37670
  */
37158
37671
  content: external_exports.record(external_exports.string().trim().min(1).max(200), ContentNodeSchema).optional(),
37159
37672
  /**
@@ -37163,14 +37676,17 @@ var SystemEntrySchema = external_exports.object({
37163
37676
  * Per Phase 4: `id` and `parentSystemId` fields will be removed in favour of
37164
37677
  * position-derived paths. Both still exist on this schema for backward compat.
37165
37678
  */
37679
+ systems: external_exports.lazy(() => external_exports.record(external_exports.string().trim().min(1).max(100), SystemEntrySchema)).optional(),
37680
+ /** @deprecated Use systems. Accepted as a compatibility alias during the ontology bridge. */
37166
37681
  subsystems: external_exports.lazy(() => external_exports.record(external_exports.string().trim().min(1).max(100), SystemEntrySchema)).optional()
37167
37682
  }).refine((system) => system.label !== void 0 || system.title !== void 0, {
37168
37683
  path: ["label"],
37169
37684
  message: "System must provide label or title"
37170
37685
  }).transform((system) => {
37171
- if (system.status === void 0) return system;
37686
+ const normalizedSystem = system.systems !== void 0 && system.subsystems === void 0 ? { ...system, subsystems: system.systems } : system;
37687
+ if (normalizedSystem.status === void 0) return normalizedSystem;
37172
37688
  console.warn("[organization-model] System.status is deprecated; use System.lifecycle instead.");
37173
- return system.lifecycle === void 0 ? { ...system, lifecycle: system.status } : system;
37689
+ return normalizedSystem.lifecycle === void 0 ? { ...normalizedSystem, lifecycle: normalizedSystem.status } : normalizedSystem;
37174
37690
  });
37175
37691
  var SystemsDomainSchema = external_exports.record(external_exports.string(), SystemEntrySchema).refine((record2) => Object.entries(record2).every(([key, entry]) => entry.id === key), {
37176
37692
  message: "Each system entry id must match its map key"
@@ -37579,6 +38095,7 @@ var ResourceKindSchema = external_exports.enum(["workflow", "agent", "integratio
37579
38095
  var ResourceGovernanceStatusSchema = external_exports.enum(["active", "deprecated", "archived"]).meta({ label: "Governance status", color: "teal" });
37580
38096
  var AgentKindSchema = external_exports.enum(["orchestrator", "specialist", "utility", "platform"]).meta({ label: "Agent kind", color: "violet" });
37581
38097
  var ScriptResourceLanguageSchema = external_exports.enum(["shell", "sql", "typescript", "python"]).meta({ label: "Language" });
38098
+ var CodeReferenceRoleSchema = external_exports.enum(["entrypoint", "handler", "schema", "test", "docs", "config"]).meta({ label: "Code reference role", color: "blue" });
37582
38099
  var ResourceIdSchema = external_exports.string().trim().min(1).max(255).regex(/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*$/, "Resource IDs must use letters, numbers, -, _, or . separators");
37583
38100
  var EventIdSchema = external_exports.string().trim().min(1).max(300).regex(
37584
38101
  /^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*:[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
@@ -37596,6 +38113,19 @@ var EventDescriptorSchema = EventEmissionDescriptorSchema.extend({
37596
38113
  ownerId: external_exports.union([ResourceIdSchema, ModelIdSchema]),
37597
38114
  ownerKind: external_exports.enum(["resource", "entity"]).meta({ label: "Owner kind" })
37598
38115
  });
38116
+ var ResourceOntologyBindingSchema = external_exports.object({
38117
+ implements: external_exports.array(OntologyIdSchema).optional(),
38118
+ reads: external_exports.array(OntologyIdSchema).optional(),
38119
+ writes: external_exports.array(OntologyIdSchema).optional(),
38120
+ usesCatalogs: external_exports.array(OntologyIdSchema).optional(),
38121
+ emits: external_exports.array(OntologyIdSchema).optional()
38122
+ });
38123
+ var CodeReferenceSchema = external_exports.object({
38124
+ path: external_exports.string().trim().min(1).max(500).regex(/^[A-Za-z0-9_./$@()[\] -]+$/, "Code reference paths must be repo-relative paths"),
38125
+ role: CodeReferenceRoleSchema,
38126
+ symbol: external_exports.string().trim().min(1).max(200).optional(),
38127
+ description: external_exports.string().trim().min(1).max(300).optional()
38128
+ });
37599
38129
  var ResourceEntryBaseSchema = external_exports.object({
37600
38130
  /** Canonical resource id; runtime resourceId derives from this value. */
37601
38131
  id: ResourceIdSchema,
@@ -37605,7 +38135,15 @@ var ResourceEntryBaseSchema = external_exports.object({
37605
38135
  systemPath: SystemPathSchema.meta({ ref: "system" }),
37606
38136
  /** Optional role responsible for maintaining this resource. */
37607
38137
  ownerRoleId: ModelIdSchema.meta({ ref: "role" }).optional(),
37608
- status: ResourceGovernanceStatusSchema
38138
+ status: ResourceGovernanceStatusSchema,
38139
+ /**
38140
+ * Ontology contract bindings for the semantic work this resource performs.
38141
+ * `emits` stays nested here so top-level resource emits descriptors remain
38142
+ * compatible with graph event projection during the bridge.
38143
+ */
38144
+ ontology: ResourceOntologyBindingSchema.optional(),
38145
+ /** Repo-relative implementation breadcrumbs for agents and operators. */
38146
+ codeRefs: external_exports.array(CodeReferenceSchema).default([])
37609
38147
  });
37610
38148
  var WorkflowResourceEntrySchema = ResourceEntryBaseSchema.extend({
37611
38149
  kind: external_exports.literal("workflow"),
@@ -37766,19 +38304,29 @@ var KnowledgeTargetKindSchema = external_exports.enum([
37766
38304
  "goal",
37767
38305
  "customer-segment",
37768
38306
  "offering",
38307
+ "ontology",
37769
38308
  // D4: content nodes are a valid knowledge target after compound-domain data moved into system.content
37770
38309
  "content-node"
37771
38310
  ]).meta({ label: "Target kind" });
37772
38311
  var KnowledgeTargetRefSchema = external_exports.object({
37773
38312
  kind: KnowledgeTargetKindSchema,
37774
- // D4: content-node targets use a qualified id format '<system-path>:<local-content-id>'
37775
- // which contains a colon separator and cannot satisfy ModelIdSchema. Use a permissive
37776
- // string schema here; business-logic validation of target existence is done in
37777
- // OrganizationModelSchema.superRefine (knowledgeTargetExists).
38313
+ // D4: content-node targets use a qualified id format '<system-path>:<local-content-id>'.
38314
+ // Ontology targets use the canonical '<scope>:<kind>/<local-id>' ontology id format.
38315
+ // Business-logic validation of target existence is done in OrganizationModelSchema.superRefine.
37778
38316
  id: external_exports.string().trim().min(1).max(300)
38317
+ }).superRefine((target, ctx) => {
38318
+ if (target.kind !== "ontology") return;
38319
+ const result = OntologyIdSchema.safeParse(target.id);
38320
+ if (!result.success) {
38321
+ ctx.addIssue({
38322
+ code: external_exports.ZodIssueCode.custom,
38323
+ path: ["id"],
38324
+ message: "Ontology knowledge targets must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
38325
+ });
38326
+ }
37779
38327
  });
37780
38328
  var LegacyKnowledgeLinkSchema = external_exports.object({
37781
- nodeId: NodeIdStringSchema
38329
+ nodeId: external_exports.union([NodeIdStringSchema, external_exports.templateLiteral(["ontology:", OntologyIdSchema])])
37782
38330
  });
37783
38331
  var CanonicalKnowledgeLinkSchema = external_exports.object({
37784
38332
  target: KnowledgeTargetRefSchema
@@ -37809,6 +38357,8 @@ var OrgKnowledgeNodeSchema = external_exports.object({
37809
38357
  icon: IconNameSchema.optional(),
37810
38358
  /** Canonical documentation URL when body content is a local summary. */
37811
38359
  externalUrl: external_exports.string().trim().url().max(500).optional(),
38360
+ /** Optional generated source file path for local MDX-backed knowledge nodes. */
38361
+ sourceFilePath: external_exports.string().trim().min(1).max(500).optional(),
37812
38362
  /** Raw MDX string. Phase 2 will introduce a structured block format. */
37813
38363
  body: external_exports.string().trim().min(1),
37814
38364
  /**
@@ -37911,6 +38461,7 @@ var OrganizationModelDomainKeySchema = external_exports.enum([
37911
38461
  "roles",
37912
38462
  "goals",
37913
38463
  "systems",
38464
+ "ontology",
37914
38465
  "resources",
37915
38466
  "actions",
37916
38467
  "entities",
@@ -37929,6 +38480,7 @@ var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
37929
38480
  roles: { version: 1, lastModified: "2026-05-10" },
37930
38481
  goals: { version: 1, lastModified: "2026-05-10" },
37931
38482
  systems: { version: 1, lastModified: "2026-05-10" },
38483
+ ontology: { version: 1, lastModified: "2026-05-14" },
37932
38484
  resources: { version: 1, lastModified: "2026-05-10" },
37933
38485
  actions: { version: 1, lastModified: "2026-05-10" },
37934
38486
  entities: { version: 1, lastModified: "2026-05-10" },
@@ -37943,6 +38495,7 @@ var OrganizationModelDomainMetadataByDomainSchema = external_exports.object({
37943
38495
  roles: OrganizationModelDomainMetadataSchema,
37944
38496
  goals: OrganizationModelDomainMetadataSchema,
37945
38497
  systems: OrganizationModelDomainMetadataSchema,
38498
+ ontology: OrganizationModelDomainMetadataSchema,
37946
38499
  resources: OrganizationModelDomainMetadataSchema,
37947
38500
  actions: OrganizationModelDomainMetadataSchema,
37948
38501
  entities: OrganizationModelDomainMetadataSchema,
@@ -37960,6 +38513,7 @@ var OrganizationModelSchemaBase = external_exports.object({
37960
38513
  roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
37961
38514
  goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
37962
38515
  systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
38516
+ ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
37963
38517
  resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
37964
38518
  actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
37965
38519
  entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
@@ -37987,13 +38541,16 @@ function asRoleHolderArray(heldBy) {
37987
38541
  function isKnowledgeKindCompatibleWithTarget(knowledgeKind, targetKind) {
37988
38542
  if (knowledgeKind === "reference") return true;
37989
38543
  if (knowledgeKind === "playbook") {
37990
- return ["system", "resource", "stage", "action"].includes(targetKind);
38544
+ return ["system", "resource", "stage", "action", "ontology"].includes(targetKind);
37991
38545
  }
37992
38546
  if (knowledgeKind === "strategy") {
37993
- return ["system", "goal", "offering", "customer-segment"].includes(targetKind);
38547
+ return ["system", "goal", "offering", "customer-segment", "ontology"].includes(targetKind);
37994
38548
  }
37995
38549
  return false;
37996
38550
  }
38551
+ function isRecord(value) {
38552
+ return typeof value === "object" && value !== null && !Array.isArray(value);
38553
+ }
37997
38554
  var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ctx) => {
37998
38555
  function collectAllSystems(systems, prefix = "", schemaPath = ["systems"]) {
37999
38556
  const result = [];
@@ -38001,8 +38558,11 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38001
38558
  const path3 = prefix ? `${prefix}.${key}` : key;
38002
38559
  const currentSchemaPath = [...schemaPath, key];
38003
38560
  result.push({ path: path3, schemaPath: currentSchemaPath, system });
38004
- if (system.subsystems !== void 0) {
38005
- result.push(...collectAllSystems(system.subsystems, path3, [...currentSchemaPath, "subsystems"]));
38561
+ const childSystems = system.systems ?? system.subsystems;
38562
+ if (childSystems !== void 0) {
38563
+ result.push(
38564
+ ...collectAllSystems(childSystems, path3, [...currentSchemaPath, system.systems !== void 0 ? "systems" : "subsystems"])
38565
+ );
38006
38566
  }
38007
38567
  }
38008
38568
  return result;
@@ -38022,7 +38582,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38022
38582
  `System "${system.id}" references unknown parent "${system.parentSystemId}"`
38023
38583
  );
38024
38584
  }
38025
- const hasChildren = Object.keys(system.subsystems ?? {}).length > 0 || allSystems.some((candidate) => candidate.path.startsWith(`${path3}.`) && !candidate.path.slice(path3.length + 1).includes("."));
38585
+ const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some((candidate) => candidate.path.startsWith(`${path3}.`) && !candidate.path.slice(path3.length + 1).includes("."));
38026
38586
  const contributesRoutePath = system.ui?.path !== void 0 || system.path !== void 0 || !hasChildren;
38027
38587
  if (contributesRoutePath) {
38028
38588
  const effectivePath = system.ui?.path ?? system.path ?? defaultSystemPathFor(path3);
@@ -38038,7 +38598,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38038
38598
  }
38039
38599
  }
38040
38600
  if (hasChildren && isLifecycleEnabled(system.lifecycle, system.enabled)) {
38041
- const hasEnabledDescendant = Object.values(system.subsystems ?? {}).some(
38601
+ const hasEnabledDescendant = Object.values(system.systems ?? system.subsystems ?? {}).some(
38042
38602
  (candidate) => isLifecycleEnabled(candidate.lifecycle, candidate.enabled)
38043
38603
  ) || allSystems.some(
38044
38604
  (candidate) => candidate.path.startsWith(`${path3}.`) && !candidate.path.slice(path3.length + 1).includes(".") && isLifecycleEnabled(candidate.system.lifecycle, candidate.system.enabled)
@@ -38283,6 +38843,60 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38283
38843
  const stageIds = /* @__PURE__ */ new Set();
38284
38844
  const actionIds = new Set(Object.keys(model.actions));
38285
38845
  const offeringsById = new Map(Object.entries(model.offerings));
38846
+ const ontologyCompilation = compileOrganizationOntology(model);
38847
+ const ontologyIndexByKind = {
38848
+ object: ontologyCompilation.ontology.objectTypes,
38849
+ link: ontologyCompilation.ontology.linkTypes,
38850
+ action: ontologyCompilation.ontology.actionTypes,
38851
+ catalog: ontologyCompilation.ontology.catalogTypes,
38852
+ event: ontologyCompilation.ontology.eventTypes,
38853
+ interface: ontologyCompilation.ontology.interfaceTypes,
38854
+ "value-type": ontologyCompilation.ontology.valueTypes,
38855
+ property: ontologyCompilation.ontology.sharedProperties,
38856
+ group: ontologyCompilation.ontology.groups,
38857
+ surface: ontologyCompilation.ontology.surfaces
38858
+ };
38859
+ const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index) => Object.keys(index)));
38860
+ const ontologyReferenceKeyKinds = {
38861
+ valueType: "value-type",
38862
+ catalogType: "catalog",
38863
+ objectType: "object",
38864
+ eventType: "event",
38865
+ actionType: "action",
38866
+ linkType: "link",
38867
+ interfaceType: "interface",
38868
+ propertyType: "property",
38869
+ groupType: "group",
38870
+ surfaceType: "surface",
38871
+ stepCatalog: "catalog"
38872
+ };
38873
+ function validateKnownOntologyReferences(ownerId, value, path3, seen = /* @__PURE__ */ new WeakSet()) {
38874
+ if (Array.isArray(value)) {
38875
+ value.forEach((entry, index) => validateKnownOntologyReferences(ownerId, entry, [...path3, index], seen));
38876
+ return;
38877
+ }
38878
+ if (!isRecord(value)) return;
38879
+ if (seen.has(value)) return;
38880
+ seen.add(value);
38881
+ Object.entries(value).forEach(([key, entry]) => {
38882
+ const expectedKind = ontologyReferenceKeyKinds[key];
38883
+ if (expectedKind !== void 0) {
38884
+ if (typeof entry !== "string") {
38885
+ addIssue(ctx, [...path3, key], `Ontology record "${ownerId}" ${key} must be an ontology ID string`);
38886
+ } else if (ontologyIndexByKind[expectedKind][entry] === void 0) {
38887
+ addIssue(
38888
+ ctx,
38889
+ [...path3, key],
38890
+ `Ontology record "${ownerId}" ${key} references unknown ${expectedKind} ontology ID "${entry}"`
38891
+ );
38892
+ }
38893
+ }
38894
+ validateKnownOntologyReferences(ownerId, entry, [...path3, key], seen);
38895
+ });
38896
+ }
38897
+ for (const { id, record: record2 } of listResolvedOntologyRecords(ontologyCompilation.ontology)) {
38898
+ validateKnownOntologyReferences(id, record2, record2.origin.path);
38899
+ }
38286
38900
  Object.values(model.policies).forEach((policy) => {
38287
38901
  policy.appliesTo.systemIds.forEach((systemId, systemIndex) => {
38288
38902
  if (!systemsById.has(systemId)) {
@@ -38336,6 +38950,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38336
38950
  if (kind === "goal") return goalsById.has(id);
38337
38951
  if (kind === "customer-segment") return segmentsById.has(id);
38338
38952
  if (kind === "offering") return offeringsById.has(id);
38953
+ if (kind === "ontology") return ontologyIds.has(id);
38339
38954
  return false;
38340
38955
  }
38341
38956
  Object.entries(model.knowledge).forEach(([nodeId2, node]) => {
@@ -38379,6 +38994,26 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38379
38994
  );
38380
38995
  }
38381
38996
  });
38997
+ function validateResourceOntologyBinding(resourceId, bindingKey, expectedKind, ids) {
38998
+ ids?.forEach((ontologyId, ontologyIndex) => {
38999
+ if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
39000
+ addIssue(
39001
+ ctx,
39002
+ ["resources", resourceId, "ontology", bindingKey, ontologyIndex],
39003
+ `Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
39004
+ );
39005
+ }
39006
+ });
39007
+ }
39008
+ Object.values(model.resources).forEach((resource) => {
39009
+ const binding = resource.ontology;
39010
+ if (binding === void 0) return;
39011
+ validateResourceOntologyBinding(resource.id, "implements", "action", binding.implements);
39012
+ validateResourceOntologyBinding(resource.id, "reads", "object", binding.reads);
39013
+ validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
39014
+ validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
39015
+ validateResourceOntologyBinding(resource.id, "emits", "event", binding.emits);
39016
+ });
38382
39017
  Object.values(model.roles).forEach((role) => {
38383
39018
  if (role.heldBy === void 0) return;
38384
39019
  asRoleHolderArray(role.heldBy).forEach((holder, holderIndex) => {
@@ -38413,11 +39048,13 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38413
39048
  });
38414
39049
  });
38415
39050
  function validateSystemContent(system, systemPath) {
39051
+ const childSystems = system.systems ?? system.subsystems;
39052
+ const childKey = system.systems !== void 0 ? "systems" : "subsystems";
38416
39053
  const content = system.content;
38417
39054
  if (content === void 0 || Object.keys(content).length === 0) {
38418
- if (system.subsystems !== void 0) {
38419
- Object.entries(system.subsystems).forEach(([childKey, child]) => {
38420
- validateSystemContent(child, [...systemPath, "subsystems", childKey]);
39055
+ if (childSystems !== void 0) {
39056
+ Object.entries(childSystems).forEach(([childLocalId, child]) => {
39057
+ validateSystemContent(child, [...systemPath, childKey, childLocalId]);
38421
39058
  });
38422
39059
  }
38423
39060
  return;
@@ -38473,15 +39110,18 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38473
39110
  }
38474
39111
  }
38475
39112
  });
38476
- if (system.subsystems !== void 0) {
38477
- Object.entries(system.subsystems).forEach(([childKey, child]) => {
38478
- validateSystemContent(child, [...systemPath, "subsystems", childKey]);
39113
+ if (childSystems !== void 0) {
39114
+ Object.entries(childSystems).forEach(([childLocalId, child]) => {
39115
+ validateSystemContent(child, [...systemPath, childKey, childLocalId]);
38479
39116
  });
38480
39117
  }
38481
39118
  }
38482
39119
  Object.entries(model.systems).forEach(([systemKey, system]) => {
38483
39120
  validateSystemContent(system, ["systems", systemKey]);
38484
39121
  });
39122
+ for (const diagnostic of ontologyCompilation.diagnostics) {
39123
+ addIssue(ctx, diagnostic.path, diagnostic.message);
39124
+ }
38485
39125
  });
38486
39126
 
38487
39127
  // ../core/src/organization-model/graph/schema.ts
@@ -38502,6 +39142,7 @@ var OrganizationGraphNodeKindSchema = external_exports.enum([
38502
39142
  "surface",
38503
39143
  "navigation-group",
38504
39144
  // Phase 3 preview — Phase 4 populates via graph projection of system.content entries.
39145
+ "ontology",
38505
39146
  "content-node"
38506
39147
  ]);
38507
39148
  var OrganizationGraphEdgeKindSchema = external_exports.enum([
@@ -38516,23 +39157,28 @@ var OrganizationGraphEdgeKindSchema = external_exports.enum([
38516
39157
  "originates_from",
38517
39158
  "triggers",
38518
39159
  "applies_to",
38519
- "effects"
39160
+ "effects",
39161
+ "implements",
39162
+ "reads",
39163
+ "writes",
39164
+ "uses_catalog"
38520
39165
  ]);
38521
39166
  var OrganizationGraphNodeSchema = external_exports.object({
38522
- id: external_exports.string().trim().min(1).max(200),
39167
+ id: external_exports.string().trim().min(1).max(400),
38523
39168
  kind: OrganizationGraphNodeKindSchema,
38524
39169
  label: LabelSchema,
38525
- sourceId: external_exports.string().trim().min(1).max(255).optional(),
39170
+ sourceId: external_exports.string().trim().min(1).max(400).optional(),
38526
39171
  description: DescriptionSchema.optional(),
38527
39172
  icon: IconNameSchema.optional(),
38528
39173
  enabled: external_exports.boolean().optional(),
39174
+ ontologyKind: external_exports.string().trim().min(1).max(80).optional(),
38529
39175
  resourceType: external_exports.enum(["workflow", "agent", "trigger", "integration", "external", "human_checkpoint", "script"]).optional()
38530
39176
  });
38531
39177
  var OrganizationGraphEdgeSchema = external_exports.object({
38532
- id: external_exports.string().trim().min(1).max(250),
39178
+ id: external_exports.string().trim().min(1).max(900),
38533
39179
  kind: OrganizationGraphEdgeKindSchema,
38534
- sourceId: external_exports.string().trim().min(1).max(200),
38535
- targetId: external_exports.string().trim().min(1).max(200),
39180
+ sourceId: external_exports.string().trim().min(1).max(400),
39181
+ targetId: external_exports.string().trim().min(1).max(400),
38536
39182
  label: external_exports.string().trim().min(1).max(120).optional(),
38537
39183
  relationshipType: external_exports.enum(["triggers", "uses", "approval"]).optional()
38538
39184
  });
@@ -38555,14 +39201,18 @@ function isReservedResourceId(resourceId) {
38555
39201
  }
38556
39202
 
38557
39203
  // ../core/src/organization-model/helpers.ts
39204
+ function childSystemsOf2(system) {
39205
+ return system.systems ?? system.subsystems ?? {};
39206
+ }
38558
39207
  function listAllSystems(model) {
38559
39208
  const results = [];
38560
39209
  function walk(map2, prefix) {
38561
39210
  for (const [localId, system] of Object.entries(map2)) {
38562
39211
  const fullPath = prefix ? `${prefix}.${localId}` : localId;
38563
39212
  results.push({ path: fullPath, system });
38564
- if (system.subsystems) {
38565
- walk(system.subsystems, fullPath);
39213
+ const childSystems = childSystemsOf2(system);
39214
+ if (Object.keys(childSystems).length > 0) {
39215
+ walk(childSystems, fullPath);
38566
39216
  }
38567
39217
  }
38568
39218
  }
@@ -42519,14 +43169,14 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
42519
43169
  label: "Dashboard",
42520
43170
  path: "/",
42521
43171
  surfaceType: "dashboard",
42522
- icon: "feature.dashboard",
43172
+ icon: "dashboard",
42523
43173
  order: 10,
42524
43174
  targets: { systems: ["dashboard"] }
42525
43175
  },
42526
43176
  business: {
42527
43177
  type: "group",
42528
43178
  label: "Business",
42529
- icon: "feature.business",
43179
+ icon: "business",
42530
43180
  order: 20,
42531
43181
  children: {
42532
43182
  sales: {
@@ -42534,7 +43184,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
42534
43184
  label: "Sales",
42535
43185
  path: "/sales",
42536
43186
  surfaceType: "page",
42537
- icon: "feature.sales",
43187
+ icon: "sales",
42538
43188
  order: 10,
42539
43189
  targets: { systems: ["sales"] }
42540
43190
  },
@@ -42543,7 +43193,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
42543
43193
  label: "Clients",
42544
43194
  path: "/clients",
42545
43195
  surfaceType: "list",
42546
- icon: "feature.projects",
43196
+ icon: "projects",
42547
43197
  order: 20,
42548
43198
  targets: { systems: ["clients"] }
42549
43199
  },
@@ -42552,7 +43202,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
42552
43202
  label: "Projects",
42553
43203
  path: "/projects",
42554
43204
  surfaceType: "page",
42555
- icon: "feature.projects",
43205
+ icon: "projects",
42556
43206
  order: 30,
42557
43207
  targets: { systems: ["projects"] }
42558
43208
  }
@@ -42561,7 +43211,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
42561
43211
  operations: {
42562
43212
  type: "group",
42563
43213
  label: "Operations",
42564
- icon: "feature.operations",
43214
+ icon: "operations",
42565
43215
  order: 30,
42566
43216
  children: {
42567
43217
  "operations-overview": {
@@ -42609,7 +43259,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
42609
43259
  monitoring: {
42610
43260
  type: "group",
42611
43261
  label: "Monitoring",
42612
- icon: "feature.monitoring",
43262
+ icon: "monitoring",
42613
43263
  order: 40,
42614
43264
  children: {
42615
43265
  "monitoring-overview": {
@@ -42671,36 +43321,19 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
42671
43321
  }
42672
43322
  },
42673
43323
  knowledge: {
42674
- type: "group",
42675
- label: "Knowledge",
42676
- icon: "feature.knowledge",
42677
- order: 50,
42678
- children: {
42679
- "knowledge-base": {
42680
- type: "surface",
42681
- label: "Knowledge Base",
42682
- path: "/knowledge",
42683
- surfaceType: "page",
42684
- order: 10,
42685
- targets: { systems: ["knowledge.base"] }
42686
- },
42687
- "knowledge-command-view": {
42688
- type: "surface",
42689
- label: "Command View",
42690
- path: "/knowledge/command-view",
42691
- surfaceType: "graph",
42692
- order: 20,
42693
- targets: { systems: ["knowledge.command-view"] },
42694
- devOnly: true
42695
- }
42696
- }
43324
+ type: "surface",
43325
+ label: "Knowledge Base",
43326
+ path: "/knowledge",
43327
+ surfaceType: "page",
43328
+ icon: "knowledge",
43329
+ order: 50
42697
43330
  }
42698
43331
  },
42699
43332
  bottom: {
42700
43333
  settings: {
42701
43334
  type: "group",
42702
43335
  label: "Settings",
42703
- icon: "feature.settings",
43336
+ icon: "settings",
42704
43337
  order: 10,
42705
43338
  children: {
42706
43339
  "settings-account": {
@@ -42772,7 +43405,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
42772
43405
  admin: {
42773
43406
  type: "group",
42774
43407
  label: "Admin",
42775
- icon: "feature.admin",
43408
+ icon: "admin",
42776
43409
  order: 20,
42777
43410
  children: {
42778
43411
  "admin-dashboard": {
@@ -42852,7 +43485,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
42852
43485
  enabled: true,
42853
43486
  lifecycle: "active",
42854
43487
  path: "/",
42855
- icon: "feature.dashboard"
43488
+ icon: "dashboard"
42856
43489
  },
42857
43490
  platform: {
42858
43491
  id: "platform",
@@ -42862,7 +43495,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
42862
43495
  enabled: true,
42863
43496
  lifecycle: "active",
42864
43497
  color: "cyan",
42865
- icon: "feature.platform"
43498
+ icon: "platform"
42866
43499
  },
42867
43500
  finance: {
42868
43501
  id: "finance",
@@ -42872,7 +43505,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
42872
43505
  enabled: true,
42873
43506
  lifecycle: "active",
42874
43507
  color: "green",
42875
- icon: "feature.finance"
43508
+ icon: "finance"
42876
43509
  },
42877
43510
  sales: {
42878
43511
  id: "sales",
@@ -42882,7 +43515,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
42882
43515
  enabled: true,
42883
43516
  lifecycle: "active",
42884
43517
  color: "blue",
42885
- icon: "feature.sales",
43518
+ icon: "sales",
42886
43519
  path: "/sales"
42887
43520
  },
42888
43521
  "sales.crm": {
@@ -42892,8 +43525,12 @@ var DEFAULT_ORGANIZATION_MODEL = {
42892
43525
  description: "Relationship pipeline and deal management",
42893
43526
  enabled: true,
42894
43527
  lifecycle: "active",
43528
+ actions: Object.values(CRM_ACTION_ENTRIES).map((action) => ({
43529
+ actionId: action.id,
43530
+ intent: "exposes"
43531
+ })),
42895
43532
  color: "blue",
42896
- icon: "feature.crm",
43533
+ icon: "crm",
42897
43534
  path: "/crm"
42898
43535
  },
42899
43536
  "sales.lead-gen": {
@@ -42903,12 +43540,12 @@ var DEFAULT_ORGANIZATION_MODEL = {
42903
43540
  description: "Prospecting, qualification, and outreach preparation",
42904
43541
  enabled: true,
42905
43542
  lifecycle: "active",
42906
- actions: Object.values(DEFAULT_ORGANIZATION_MODEL_ACTIONS).map((action) => ({
43543
+ actions: Object.values(LEAD_GEN_ACTION_ENTRIES).map((action) => ({
42907
43544
  actionId: action.id,
42908
43545
  intent: "exposes"
42909
43546
  })),
42910
43547
  color: "cyan",
42911
- icon: "feature.lead-gen",
43548
+ icon: "lead-gen",
42912
43549
  path: "/lead-gen"
42913
43550
  },
42914
43551
  projects: {
@@ -42919,7 +43556,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
42919
43556
  enabled: true,
42920
43557
  lifecycle: "active",
42921
43558
  color: "orange",
42922
- icon: "feature.projects",
43559
+ icon: "projects",
42923
43560
  path: "/projects"
42924
43561
  },
42925
43562
  clients: {
@@ -42930,7 +43567,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
42930
43567
  enabled: true,
42931
43568
  lifecycle: "active",
42932
43569
  color: "orange",
42933
- icon: "feature.projects",
43570
+ icon: "projects",
42934
43571
  path: "/clients"
42935
43572
  },
42936
43573
  operations: {
@@ -42941,7 +43578,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
42941
43578
  enabled: true,
42942
43579
  lifecycle: "active",
42943
43580
  color: "violet",
42944
- icon: "feature.operations"
43581
+ icon: "operations"
42945
43582
  },
42946
43583
  "knowledge.command-view": {
42947
43584
  id: "knowledge.command-view",
@@ -43007,7 +43644,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
43007
43644
  enabled: true,
43008
43645
  lifecycle: "active",
43009
43646
  path: "/monitoring/calendar",
43010
- icon: "feature.calendar"
43647
+ icon: "calendar"
43011
43648
  },
43012
43649
  "monitoring.activity-log": {
43013
43650
  id: "monitoring.activity-log",
@@ -43063,7 +43700,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
43063
43700
  label: "Settings",
43064
43701
  enabled: true,
43065
43702
  lifecycle: "active",
43066
- icon: "feature.settings"
43703
+ icon: "settings"
43067
43704
  },
43068
43705
  "settings.account": {
43069
43706
  id: "settings.account",
@@ -43136,7 +43773,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
43136
43773
  enabled: true,
43137
43774
  lifecycle: "active",
43138
43775
  path: "/admin",
43139
- icon: "feature.admin",
43776
+ icon: "admin",
43140
43777
  requiresAdmin: true
43141
43778
  },
43142
43779
  "admin.system-health": {
@@ -43186,7 +43823,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
43186
43823
  enabled: true,
43187
43824
  lifecycle: "active",
43188
43825
  path: "/archive",
43189
- icon: "feature.archive",
43826
+ icon: "archive",
43190
43827
  devOnly: true
43191
43828
  },
43192
43829
  "archive.agent-chat": {
@@ -43221,7 +43858,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
43221
43858
  enabled: true,
43222
43859
  lifecycle: "active",
43223
43860
  color: "teal",
43224
- icon: "feature.knowledge"
43861
+ icon: "knowledge"
43225
43862
  },
43226
43863
  "knowledge.base": {
43227
43864
  id: "knowledge.base",
@@ -43232,11 +43869,13 @@ var DEFAULT_ORGANIZATION_MODEL = {
43232
43869
  path: "/knowledge"
43233
43870
  }
43234
43871
  },
43872
+ ontology: DEFAULT_ONTOLOGY_SCOPE,
43235
43873
  resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
43236
43874
  actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
43237
43875
  entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
43238
43876
  policies: DEFAULT_ORGANIZATION_MODEL_POLICIES,
43239
- // Phase 4 (D1): statuses top-level field removed; status data lives in system.content.
43877
+ // Phase 4 (D1): statuses top-level field removed; bridge status mirrors may
43878
+ // still project from System.content, but primary authoring belongs in ontology.
43240
43879
  knowledge: DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE
43241
43880
  };
43242
43881
 
@@ -43286,7 +43925,7 @@ function getAllBuildTemplates(model) {
43286
43925
  label: s.label ?? stepLocalId,
43287
43926
  ...s.description ? { description: s.description } : {},
43288
43927
  // Pass through all data fields — template-step payload is richer than Pipeline;
43289
- // Wave 2 authors the canonical shape; Wave 4 verifies round-trip fidelity.
43928
+ // Bridge readers preserve the historical shape for round-trip fidelity.
43290
43929
  ...sd
43291
43930
  };
43292
43931
  });
@@ -43450,6 +44089,20 @@ function invocationLabel(invocation) {
43450
44089
  function eventNodeId(eventId) {
43451
44090
  return nodeId("event", eventId);
43452
44091
  }
44092
+ function ontologyLabel(id, label) {
44093
+ return label ?? parseOntologyId(id).localId;
44094
+ }
44095
+ function pushOntologyBindingEdges(edges, edgeIds, resourceNodeId, kind, ids) {
44096
+ ids?.forEach((ontologyId) => {
44097
+ const targetId = ontologyGraphNodeId(ontologyId);
44098
+ pushUniqueEdge(edges, edgeIds, {
44099
+ id: edgeId(kind, resourceNodeId, targetId),
44100
+ kind,
44101
+ sourceId: resourceNodeId,
44102
+ targetId
44103
+ });
44104
+ });
44105
+ }
43453
44106
  function buildResourceEventDescriptor(resourceId, emission) {
43454
44107
  return {
43455
44108
  ...emission,
@@ -43497,6 +44150,7 @@ function buildOrganizationGraph(input) {
43497
44150
  const organizationModelResourceIds = new Set(Object.keys(organizationModel.resources));
43498
44151
  const actionIdsByInvocation = /* @__PURE__ */ new Map();
43499
44152
  const projectedEventNodeIdsByEventId = /* @__PURE__ */ new Map();
44153
+ const ontologyCompilation = compileOrganizationOntology(organizationModel);
43500
44154
  const organizationNode = {
43501
44155
  id: nodeId("organization"),
43502
44156
  kind: "organization",
@@ -43538,6 +44192,78 @@ function buildOrganizationGraph(input) {
43538
44192
  });
43539
44193
  }
43540
44194
  }
44195
+ for (const { id: ontologyId, kind, record: record2 } of listResolvedOntologyRecords(ontologyCompilation.ontology).sort(
44196
+ (a, b) => a.id.localeCompare(b.id)
44197
+ )) {
44198
+ const id = ontologyGraphNodeId(ontologyId);
44199
+ const parsedId = parseOntologyId(ontologyId);
44200
+ pushUniqueNode(nodes, nodeIds, {
44201
+ id,
44202
+ kind: "ontology",
44203
+ label: ontologyLabel(ontologyId, record2.label),
44204
+ sourceId: ontologyId,
44205
+ description: record2.description,
44206
+ ontologyKind: kind
44207
+ });
44208
+ const ownerSystemId = record2.ownerSystemId ?? (parsedId.isGlobal ? void 0 : parsedId.scope);
44209
+ if (ownerSystemId !== void 0 && validSystemRefs.has(ownerSystemId)) {
44210
+ pushUniqueEdge(edges, edgeIds, {
44211
+ id: edgeId("contains", systemNodeId(ownerSystemId), id, `ontology-${kind}`),
44212
+ kind: "contains",
44213
+ sourceId: systemNodeId(ownerSystemId),
44214
+ targetId: id
44215
+ });
44216
+ } else {
44217
+ pushUniqueEdge(edges, edgeIds, {
44218
+ id: edgeId("contains", organizationNode.id, id, `ontology-${kind}`),
44219
+ kind: "contains",
44220
+ sourceId: organizationNode.id,
44221
+ targetId: id
44222
+ });
44223
+ }
44224
+ if (kind === "link") {
44225
+ const link = record2;
44226
+ pushUniqueEdge(edges, edgeIds, {
44227
+ id: edgeId("links", ontologyGraphNodeId(link.from), ontologyGraphNodeId(link.to), ontologyId),
44228
+ kind: "links",
44229
+ sourceId: ontologyGraphNodeId(link.from),
44230
+ targetId: ontologyGraphNodeId(link.to),
44231
+ label: link.label ?? parsedId.localId
44232
+ });
44233
+ }
44234
+ if (kind === "action") {
44235
+ const action = record2;
44236
+ for (const targetOntologyId of action.actsOn ?? []) {
44237
+ pushUniqueEdge(edges, edgeIds, {
44238
+ id: edgeId("affects", id, ontologyGraphNodeId(targetOntologyId), ontologyId),
44239
+ kind: "affects",
44240
+ sourceId: id,
44241
+ targetId: ontologyGraphNodeId(targetOntologyId)
44242
+ });
44243
+ }
44244
+ }
44245
+ if (kind === "catalog") {
44246
+ const catalog = record2;
44247
+ if (catalog.appliesTo === void 0) continue;
44248
+ pushUniqueEdge(edges, edgeIds, {
44249
+ id: edgeId("applies_to", id, ontologyGraphNodeId(catalog.appliesTo), ontologyId),
44250
+ kind: "applies_to",
44251
+ sourceId: id,
44252
+ targetId: ontologyGraphNodeId(catalog.appliesTo)
44253
+ });
44254
+ }
44255
+ if (kind === "group") {
44256
+ const group = record2;
44257
+ for (const memberOntologyId of group.members ?? []) {
44258
+ pushUniqueEdge(edges, edgeIds, {
44259
+ id: edgeId("contains", id, ontologyGraphNodeId(memberOntologyId), ontologyId),
44260
+ kind: "contains",
44261
+ sourceId: id,
44262
+ targetId: ontologyGraphNodeId(memberOntologyId)
44263
+ });
44264
+ }
44265
+ }
44266
+ }
43541
44267
  for (const role of Object.values(organizationModel.roles).sort((a, b) => a.id.localeCompare(b.id))) {
43542
44268
  const id = nodeId("role", role.id);
43543
44269
  pushUniqueNode(nodes, nodeIds, {
@@ -43589,7 +44315,7 @@ function buildOrganizationGraph(input) {
43589
44315
  targetId: id
43590
44316
  });
43591
44317
  for (const link of node.links) {
43592
- const targetId = link.target.kind === "system" ? systemNodeId(link.target.id) : link.nodeId;
44318
+ const targetId = link.target.kind === "system" ? systemNodeId(link.target.id) : link.target.kind === "ontology" ? ontologyGraphNodeId(link.target.id) : link.nodeId;
43593
44319
  pushUniqueEdge(edges, edgeIds, {
43594
44320
  id: edgeId("governs", id, targetId),
43595
44321
  kind: "governs",
@@ -43754,6 +44480,11 @@ function buildOrganizationGraph(input) {
43754
44480
  targetId: resourceNode.id
43755
44481
  });
43756
44482
  }
44483
+ pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "implements", resource.ontology?.implements);
44484
+ pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "reads", resource.ontology?.reads);
44485
+ pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "writes", resource.ontology?.writes);
44486
+ pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "uses_catalog", resource.ontology?.usesCatalogs);
44487
+ pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "emits", resource.ontology?.emits);
43757
44488
  if (resource.kind === "workflow" || resource.kind === "agent") {
43758
44489
  for (const emission of resource.emits ?? []) {
43759
44490
  pushEventProjection(
@@ -44317,7 +45048,7 @@ function wrapAction(commandName, fn) {
44317
45048
  // package.json
44318
45049
  var package_default = {
44319
45050
  name: "@elevasis/sdk",
44320
- version: "1.21.0",
45051
+ version: "1.22.0",
44321
45052
  description: "SDK for building Elevasis organization resources",
44322
45053
  type: "module",
44323
45054
  bin: {
@@ -46888,6 +47619,16 @@ function registerProjectCommands(program3) {
46888
47619
  function toGraphNodeId(omNodeId) {
46889
47620
  return `knowledge:${omNodeId}`;
46890
47621
  }
47622
+ function toTargetGraphNodeId(nodeId2) {
47623
+ if (nodeId2.startsWith("system:") || nodeId2.startsWith("knowledge:") || nodeId2.startsWith("resource:") || nodeId2.startsWith("content-node:") || nodeId2.startsWith("ontology:")) {
47624
+ return nodeId2;
47625
+ }
47626
+ const ontologyId = OntologyIdSchema.safeParse(nodeId2);
47627
+ if (ontologyId.success) {
47628
+ return ontologyGraphNodeId(ontologyId.data);
47629
+ }
47630
+ return `system:${nodeId2}`;
47631
+ }
46891
47632
  function buildKnowledgeSourceIdMap(graph) {
46892
47633
  const map2 = /* @__PURE__ */ new Map();
46893
47634
  for (const node of graph.nodes) {
@@ -46913,6 +47654,22 @@ function bySystem(graph, systemId, knowledgeNodes) {
46913
47654
  }
46914
47655
  return knowledgeNodes.filter((n) => matchingOmIds.has(n.id));
46915
47656
  }
47657
+ function byOntology(graph, ontologyId, knowledgeNodes) {
47658
+ const targetGraphNodeId = toTargetGraphNodeId(ontologyId);
47659
+ const governingKnowledgeNodeIds = /* @__PURE__ */ new Set();
47660
+ for (const edge of graph.edges) {
47661
+ if (edge.kind === "governs" && edge.targetId === targetGraphNodeId && edge.sourceId.startsWith("knowledge:")) {
47662
+ governingKnowledgeNodeIds.add(edge.sourceId);
47663
+ }
47664
+ }
47665
+ const sourceIdMap = buildKnowledgeSourceIdMap(graph);
47666
+ const matchingOmIds = /* @__PURE__ */ new Set();
47667
+ for (const graphNodeId of governingKnowledgeNodeIds) {
47668
+ const omId = sourceIdMap.get(graphNodeId);
47669
+ if (omId) matchingOmIds.add(omId);
47670
+ }
47671
+ return knowledgeNodes.filter((n) => matchingOmIds.has(n.id));
47672
+ }
46916
47673
  function byKind(_graph, kind, knowledgeNodes) {
46917
47674
  return knowledgeNodes.filter((n) => n.kind === kind);
46918
47675
  }
@@ -46930,7 +47687,7 @@ function governs(graph, nodeId2) {
46930
47687
  return results;
46931
47688
  }
46932
47689
  function governedBy(graph, nodeId2) {
46933
- const targetId = nodeId2.startsWith("system:") || nodeId2.startsWith("knowledge:") || nodeId2.startsWith("resource:") ? nodeId2 : `system:${nodeId2}`;
47690
+ const targetId = toTargetGraphNodeId(nodeId2);
46934
47691
  const results = [];
46935
47692
  for (const edge of graph.edges) {
46936
47693
  if (edge.kind === "governs" && edge.targetId === targetId) {
@@ -46958,6 +47715,12 @@ function parsePath(pathString) {
46958
47715
  }
46959
47716
  return { mount: "by-system", args: [rest.join("/")] };
46960
47717
  }
47718
+ if (first === "by-ontology") {
47719
+ if (rest.length === 0) {
47720
+ throw new Error(`parsePath: /by-ontology requires an ontologyId argument, got: "${pathString}"`);
47721
+ }
47722
+ return { mount: "by-ontology", args: [rest.join("/")] };
47723
+ }
46961
47724
  if (first === "by-kind") {
46962
47725
  if (rest.length === 0) {
46963
47726
  throw new Error(`parsePath: /by-kind requires a kind argument, got: "${pathString}"`);
@@ -47078,7 +47841,7 @@ async function loadOrgModel(projectRoot) {
47078
47841
  // src/cli/commands/knowledge/ls.ts
47079
47842
  function registerKnowledgeLs(program3) {
47080
47843
  program3.command("knowledge:ls <path>").description(
47081
- "List knowledge nodes for a Knowledge Map path\n Examples:\n elevasis-sdk knowledge:ls /by-kind/playbook\n elevasis-sdk knowledge:ls /by-system/sales.crm\n elevasis-sdk knowledge:ls /by-owner/role.ops-lead\n elevasis-sdk knowledge:ls /graph/knowledge.outreach-playbook/governs\n elevasis-sdk knowledge:ls /graph/system:sales.crm/governed-by"
47844
+ "List knowledge nodes for a Knowledge Map path\n Examples:\n elevasis-sdk knowledge:ls /by-kind/playbook\n elevasis-sdk knowledge:ls /by-system/sales.crm\n elevasis-sdk knowledge:ls /by-ontology/sales.crm:object/deal\n elevasis-sdk knowledge:ls /by-owner/role.ops-lead\n elevasis-sdk knowledge:ls /graph/knowledge.outreach-playbook/governs\n elevasis-sdk knowledge:ls /graph/system:sales.crm/governed-by"
47082
47845
  ).option("--json", "Print wrapped JSON envelope { path, mount, args, results }").option("--ids-only", "Print one ID per line (for piping)").action(
47083
47846
  wrapAction("knowledge:ls", async (pathArg, options) => {
47084
47847
  let parsed;
@@ -47094,12 +47857,18 @@ function registerKnowledgeLs(program3) {
47094
47857
  const graph = buildOrganizationGraph({ organizationModel: model });
47095
47858
  const knowledgeNodes = Object.values(model.knowledge);
47096
47859
  let results;
47860
+ let isGraphMount = false;
47097
47861
  switch (parsed.mount) {
47098
47862
  case "by-system": {
47099
47863
  const systemId = parsed.args[0].replace(/\//g, ".");
47100
47864
  results = bySystem(graph, systemId, knowledgeNodes);
47101
47865
  break;
47102
47866
  }
47867
+ case "by-ontology": {
47868
+ const ontologyId = parsed.args[0];
47869
+ results = byOntology(graph, ontologyId, knowledgeNodes);
47870
+ break;
47871
+ }
47103
47872
  case "by-kind": {
47104
47873
  const kind = parsed.args[0];
47105
47874
  results = byKind(graph, kind, knowledgeNodes);
@@ -47111,6 +47880,7 @@ function registerKnowledgeLs(program3) {
47111
47880
  break;
47112
47881
  }
47113
47882
  case "graph": {
47883
+ isGraphMount = true;
47114
47884
  const nodeId2 = parsed.args[0];
47115
47885
  const verb = parsed.args[1];
47116
47886
  if (verb === "governs") {
@@ -47135,6 +47905,12 @@ function registerKnowledgeLs(program3) {
47135
47905
  } else if (options.idsOnly) {
47136
47906
  const out = formatIdsOnly(results);
47137
47907
  if (out) process.stdout.write(out + "\n");
47908
+ } else if (isGraphMount) {
47909
+ if (results.length === 0) {
47910
+ process.stdout.write("(no results)\n");
47911
+ } else {
47912
+ process.stdout.write(results.join("\n") + "\n");
47913
+ }
47138
47914
  } else {
47139
47915
  process.stdout.write(formatText(results) + "\n");
47140
47916
  }
@@ -47157,22 +47933,7 @@ function registerKnowledgeCat(program3) {
47157
47933
  process.exit(1);
47158
47934
  }
47159
47935
  if (options.json) {
47160
- process.stdout.write(
47161
- JSON.stringify(
47162
- {
47163
- id: node.id,
47164
- kind: node.kind,
47165
- title: node.title,
47166
- summary: node.summary,
47167
- body: node.body,
47168
- links: node.links,
47169
- ownerIds: node.ownerIds,
47170
- updatedAt: node.updatedAt
47171
- },
47172
- null,
47173
- 2
47174
- ) + "\n"
47175
- );
47936
+ process.stdout.write(JSON.stringify(node, null, 2) + "\n");
47176
47937
  } else {
47177
47938
  process.stdout.write(node.body + "\n");
47178
47939
  }
@@ -47190,7 +47951,8 @@ function registerKnowledgeGraph(program3) {
47190
47951
  const model = await loadOrgModel(projectRoot);
47191
47952
  const graph = buildOrganizationGraph({ organizationModel: model });
47192
47953
  const outgoing = governs(graph, id);
47193
- const incoming = governedBy(graph, id);
47954
+ const incomingNodeId = id.startsWith("knowledge.") ? `knowledge:${id}` : id;
47955
+ const incoming = governedBy(graph, incomingNodeId);
47194
47956
  if (options.json) {
47195
47957
  process.stdout.write(
47196
47958
  JSON.stringify(
@@ -47495,6 +48257,18 @@ var ROUTING_STOPWORDS = /* @__PURE__ */ new Set([
47495
48257
  function toRegistryPath(path3) {
47496
48258
  return path3.replace(/\\/g, "/");
47497
48259
  }
48260
+ function sourceBaseFromLabel(sourceLabel) {
48261
+ if (!sourceLabel) return void 0;
48262
+ const normalized = toRegistryPath(sourceLabel).replace(/\/+$/, "");
48263
+ const globIndex = normalized.indexOf("*");
48264
+ if (globIndex === -1) return normalized;
48265
+ return normalized.slice(0, globIndex).replace(/\/+$/, "");
48266
+ }
48267
+ function toSourceFilePath(sourceLabel, relativePath) {
48268
+ const normalizedRelativePath = toRegistryPath(relativePath);
48269
+ const sourceBase = sourceBaseFromLabel(sourceLabel);
48270
+ return sourceBase ? `${sourceBase}/${normalizedRelativePath}` : normalizedRelativePath;
48271
+ }
47498
48272
  function slugify(value) {
47499
48273
  return value.trim().toLowerCase().replace(/['"]/g, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
47500
48274
  }
@@ -47658,7 +48432,13 @@ function generateKnowledgeNodes(options) {
47658
48432
  const files = listMdxFiles(options.sourceDir).sort(
47659
48433
  (a, b) => (0, import_node_path2.relative)(options.sourceDir, a).localeCompare((0, import_node_path2.relative)(options.sourceDir, b))
47660
48434
  );
47661
- const nodes = files.map(readKnowledgeNodeMdx);
48435
+ const nodes = files.map((file2) => {
48436
+ const relativePath = (0, import_node_path2.relative)(options.sourceDir, file2);
48437
+ return {
48438
+ ...readKnowledgeNodeMdx(file2),
48439
+ sourceFilePath: toSourceFilePath(options.sourceLabel, relativePath)
48440
+ };
48441
+ });
47662
48442
  const sourcePaths = Object.fromEntries(
47663
48443
  files.map((file2, index) => [nodes[index].id, toRegistryPath((0, import_node_path2.relative)(options.sourceDir, file2))])
47664
48444
  );