@elevasis/ui 2.32.0 → 2.33.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 (82) hide show
  1. package/dist/app/index.js +3 -3
  2. package/dist/{chunk-GCOQ3TBG.js → chunk-2GMF5IRF.js} +2 -2
  3. package/dist/{chunk-4MFNGNHF.js → chunk-52NLZN6Z.js} +2 -2
  4. package/dist/{chunk-5FJJ72HU.js → chunk-AHCKOU2M.js} +1 -1
  5. package/dist/chunk-CLDCYJQT.js +1 -0
  6. package/dist/chunk-DWXDNT7P.js +145 -0
  7. package/dist/{chunk-5J4PDX26.js → chunk-E4T2N7P7.js} +14 -2
  8. package/dist/{chunk-RQTWIXJ5.js → chunk-E7C4XEWH.js} +1 -1
  9. package/dist/{chunk-6DWD423K.js → chunk-FFPHJBJC.js} +1 -1
  10. package/dist/{chunk-T35FWDAB.js → chunk-GNRMB6DC.js} +940 -156
  11. package/dist/{chunk-LLRXA7D7.js → chunk-IUKFNASA.js} +1 -1
  12. package/dist/{chunk-QTI3KC7D.js → chunk-JHT5JIJ3.js} +106 -43
  13. package/dist/{chunk-IQHU7O5Y.js → chunk-MHLZ4F4N.js} +1 -1
  14. package/dist/{chunk-VRNMNB3O.js → chunk-NOIRGGW2.js} +1 -1
  15. package/dist/{chunk-MOY4VOHF.js → chunk-QNOVUCSV.js} +1 -1
  16. package/dist/{chunk-4QK76KIF.js → chunk-TKF5S4XP.js} +1 -1
  17. package/dist/{chunk-ZQOKIGZP.js → chunk-UVFOURXR.js} +4 -4
  18. package/dist/{chunk-YLQEVSOR.js → chunk-UW7IV2Y3.js} +202 -54
  19. package/dist/{chunk-IZWTVFJ2.js → chunk-V6SZ4ECN.js} +6 -3
  20. package/dist/{chunk-QQHOKTJA.js → chunk-XG57WXOL.js} +39 -2
  21. package/dist/{chunk-7KZINJLP.js → chunk-XOFSMJLF.js} +4 -4
  22. package/dist/{chunk-WQPX44YM.js → chunk-YAQ25UNM.js} +668 -168
  23. package/dist/{chunk-QXCDKE2O.js → chunk-ZGTDKH3P.js} +9 -28
  24. package/dist/components/index.d.ts +111 -2
  25. package/dist/components/index.js +24 -23
  26. package/dist/components/navigation/index.js +4 -3
  27. package/dist/execution/index.d.ts +5 -1
  28. package/dist/features/clients/index.js +8 -7
  29. package/dist/features/crm/index.js +10 -9
  30. package/dist/features/dashboard/index.d.ts +110 -1
  31. package/dist/features/dashboard/index.js +9 -8
  32. package/dist/features/delivery/index.js +9 -8
  33. package/dist/features/knowledge/index.js +8 -18
  34. package/dist/features/lead-gen/index.js +10 -9
  35. package/dist/features/monitoring/index.js +10 -9
  36. package/dist/features/monitoring/requests/index.d.ts +2 -2
  37. package/dist/features/monitoring/requests/index.js +8 -7
  38. package/dist/features/operations/index.d.ts +442 -73
  39. package/dist/features/operations/index.js +13 -12
  40. package/dist/features/settings/index.js +9 -8
  41. package/dist/hooks/index.d.ts +192 -3
  42. package/dist/hooks/index.js +8 -7
  43. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +190 -1
  44. package/dist/hooks/published.d.ts +192 -3
  45. package/dist/hooks/published.js +8 -7
  46. package/dist/index.d.ts +444 -75
  47. package/dist/index.js +8 -7
  48. package/dist/knowledge/index.d.ts +490 -214
  49. package/dist/knowledge/index.js +1179 -687
  50. package/dist/knowledge-search-index-P7PR626V.js +1514 -0
  51. package/dist/layout/index.js +1 -1
  52. package/dist/provider/index.d.ts +357 -72
  53. package/dist/provider/index.js +7 -6
  54. package/dist/provider/published.d.ts +357 -72
  55. package/dist/provider/published.js +5 -4
  56. package/dist/types/index.d.ts +190 -1
  57. package/dist/utils/index.d.ts +110 -1
  58. package/package.json +39 -39
  59. package/src/README.md +29 -29
  60. package/src/api/README.md +18 -18
  61. package/src/app/README.md +24 -24
  62. package/src/auth/README.md +18 -18
  63. package/src/components/README.md +24 -24
  64. package/src/execution/README.md +16 -16
  65. package/src/features/README.md +28 -28
  66. package/src/graph/README.md +16 -16
  67. package/src/hooks/README.md +23 -23
  68. package/src/initialization/README.md +19 -19
  69. package/src/knowledge/README.md +31 -31
  70. package/src/organization/README.md +18 -18
  71. package/src/profile/README.md +19 -19
  72. package/src/provider/README.md +32 -32
  73. package/src/router/README.md +18 -18
  74. package/src/sse/README.md +13 -13
  75. package/src/test-utils/README.md +7 -7
  76. package/src/theme/README.md +23 -23
  77. package/src/theme/presets/README.md +19 -19
  78. package/src/types/README.md +16 -16
  79. package/src/utils/README.md +18 -18
  80. package/src/zustand/README.md +18 -18
  81. package/dist/chunk-UROTM5OR.js +0 -172
  82. package/dist/knowledge-search-index-5KYPO746.js +0 -1479
@@ -1,74 +1,472 @@
1
1
  import { z } from 'zod';
2
2
 
3
- // ../core/src/organization-model/domains/systems.ts
3
+ // ../core/src/organization-model/ontology.ts
4
+ var OntologyKindSchema = z.enum([
5
+ "object",
6
+ "link",
7
+ "action",
8
+ "catalog",
9
+ "event",
10
+ "interface",
11
+ "value-type",
12
+ "property",
13
+ "group",
14
+ "surface"
15
+ ]);
16
+ var SYSTEM_PATH_PATTERN = "[a-z0-9][a-z0-9-]*(?:\\.[a-z0-9][a-z0-9-]*)*";
17
+ var LOCAL_ID_PATTERN = "[a-z0-9][a-z0-9._-]*";
18
+ var ONTOLOGY_ID_PATTERN = `^(global|${SYSTEM_PATH_PATTERN}):(${OntologyKindSchema.options.join("|")})\\/(${LOCAL_ID_PATTERN})$`;
19
+ var ONTOLOGY_ID_REGEX = new RegExp(ONTOLOGY_ID_PATTERN);
20
+ var OntologyIdSchema = z.string().trim().min(1).max(300).regex(
21
+ ONTOLOGY_ID_REGEX,
22
+ "Ontology IDs must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
23
+ );
24
+ function parseOntologyId(id) {
25
+ const normalized = OntologyIdSchema.parse(id);
26
+ const match = ONTOLOGY_ID_REGEX.exec(normalized);
27
+ if (match === null) {
28
+ throw new Error(`Invalid ontology ID "${id}"`);
29
+ }
30
+ return {
31
+ id: normalized,
32
+ scope: match[1],
33
+ kind: match[2],
34
+ localId: match[3],
35
+ isGlobal: match[1] === "global"
36
+ };
37
+ }
38
+ function formatOntologyId(input) {
39
+ return OntologyIdSchema.parse(`${input.scope}:${input.kind}/${input.localId}`);
40
+ }
41
+ var OntologyReferenceListSchema = z.array(OntologyIdSchema).default([]).optional();
42
+ var OntologyRecordBaseSchema = z.object({
43
+ id: OntologyIdSchema,
44
+ label: z.string().trim().min(1).max(160).optional(),
45
+ description: z.string().trim().min(1).max(2e3).optional(),
46
+ ownerSystemId: z.string().trim().min(1).max(200).optional(),
47
+ aliases: z.array(OntologyIdSchema).optional()
48
+ }).passthrough();
49
+ var OntologyObjectTypeSchema = OntologyRecordBaseSchema.extend({
50
+ properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
51
+ storage: z.record(z.string(), z.unknown()).optional()
52
+ });
53
+ var OntologyLinkTypeSchema = OntologyRecordBaseSchema.extend({
54
+ from: OntologyIdSchema,
55
+ to: OntologyIdSchema,
56
+ cardinality: z.string().trim().min(1).max(80).optional(),
57
+ via: z.string().trim().min(1).max(255).optional()
58
+ });
59
+ var OntologyActionTypeSchema = OntologyRecordBaseSchema.extend({
60
+ actsOn: OntologyReferenceListSchema,
61
+ input: z.record(z.string().trim().min(1).max(200), z.unknown()).optional(),
62
+ effects: z.array(z.record(z.string(), z.unknown())).optional()
63
+ });
64
+ var OntologyCatalogTypeSchema = OntologyRecordBaseSchema.extend({
65
+ kind: z.string().trim().min(1).max(120).optional(),
66
+ appliesTo: OntologyIdSchema.optional(),
67
+ entries: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
68
+ });
69
+ var OntologyEventTypeSchema = OntologyRecordBaseSchema.extend({
70
+ payload: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
71
+ });
72
+ var OntologyInterfaceTypeSchema = OntologyRecordBaseSchema.extend({
73
+ properties: z.record(z.string().trim().min(1).max(200), z.unknown()).optional()
74
+ });
75
+ var OntologyValueTypeSchema = OntologyRecordBaseSchema.extend({
76
+ primitive: z.string().trim().min(1).max(120).optional()
77
+ });
78
+ var OntologySharedPropertySchema = OntologyRecordBaseSchema.extend({
79
+ valueType: OntologyIdSchema.optional(),
80
+ searchable: z.boolean().optional(),
81
+ pii: z.boolean().optional()
82
+ });
83
+ var OntologyGroupSchema = OntologyRecordBaseSchema.extend({
84
+ members: OntologyReferenceListSchema
85
+ });
86
+ var OntologySurfaceTypeSchema = OntologyRecordBaseSchema.extend({
87
+ route: z.string().trim().min(1).max(500).optional()
88
+ });
89
+ var OntologyScopeSchema = z.object({
90
+ objectTypes: z.record(OntologyIdSchema, OntologyObjectTypeSchema).default({}).optional(),
91
+ linkTypes: z.record(OntologyIdSchema, OntologyLinkTypeSchema).default({}).optional(),
92
+ actionTypes: z.record(OntologyIdSchema, OntologyActionTypeSchema).default({}).optional(),
93
+ catalogTypes: z.record(OntologyIdSchema, OntologyCatalogTypeSchema).default({}).optional(),
94
+ eventTypes: z.record(OntologyIdSchema, OntologyEventTypeSchema).default({}).optional(),
95
+ interfaceTypes: z.record(OntologyIdSchema, OntologyInterfaceTypeSchema).default({}).optional(),
96
+ valueTypes: z.record(OntologyIdSchema, OntologyValueTypeSchema).default({}).optional(),
97
+ sharedProperties: z.record(OntologyIdSchema, OntologySharedPropertySchema).default({}).optional(),
98
+ groups: z.record(OntologyIdSchema, OntologyGroupSchema).default({}).optional(),
99
+ surfaces: z.record(OntologyIdSchema, OntologySurfaceTypeSchema).default({}).optional()
100
+ }).default({});
101
+ var DEFAULT_ONTOLOGY_SCOPE = {
102
+ valueTypes: {
103
+ "global:value-type/uuid": {
104
+ id: "global:value-type/uuid",
105
+ label: "UUID",
106
+ primitive: "string"
107
+ },
108
+ "global:value-type/text": {
109
+ id: "global:value-type/text",
110
+ label: "Text",
111
+ primitive: "string"
112
+ },
113
+ "global:value-type/url": {
114
+ id: "global:value-type/url",
115
+ label: "URL",
116
+ primitive: "string"
117
+ },
118
+ "global:value-type/email": {
119
+ id: "global:value-type/email",
120
+ label: "Email",
121
+ primitive: "string"
122
+ }
123
+ }
124
+ };
125
+ var SCOPE_KIND = {
126
+ objectTypes: "object",
127
+ linkTypes: "link",
128
+ actionTypes: "action",
129
+ catalogTypes: "catalog",
130
+ eventTypes: "event",
131
+ interfaceTypes: "interface",
132
+ valueTypes: "value-type",
133
+ sharedProperties: "property",
134
+ groups: "group",
135
+ surfaces: "surface"
136
+ };
137
+ var SCOPE_KEYS = Object.keys(SCOPE_KIND);
138
+ function ontologyGraphNodeId(id) {
139
+ return `ontology:${OntologyIdSchema.parse(id)}`;
140
+ }
141
+ function listResolvedOntologyRecords(index) {
142
+ return SCOPE_KEYS.flatMap((scopeKey) => {
143
+ const kind = SCOPE_KIND[scopeKey];
144
+ return Object.entries(index[scopeKey]).sort(([leftId], [rightId]) => leftId.localeCompare(rightId)).map(([id, record]) => ({
145
+ id,
146
+ kind,
147
+ record
148
+ }));
149
+ });
150
+ }
151
+ function originFromContext(context) {
152
+ return {
153
+ kind: context.kind,
154
+ source: context.source,
155
+ path: context.path,
156
+ ...context.systemPath !== void 0 ? { systemPath: context.systemPath } : {},
157
+ ...context.legacyId !== void 0 ? { legacyId: context.legacyId } : {}
158
+ };
159
+ }
160
+ function createEmptyIndex() {
161
+ return {
162
+ objectTypes: {},
163
+ linkTypes: {},
164
+ actionTypes: {},
165
+ catalogTypes: {},
166
+ eventTypes: {},
167
+ interfaceTypes: {},
168
+ valueTypes: {},
169
+ sharedProperties: {},
170
+ groups: {},
171
+ surfaces: {}
172
+ };
173
+ }
174
+ function sortResolvedOntologyIndex(index) {
175
+ const sorted = createEmptyIndex();
176
+ for (const scopeKey of SCOPE_KEYS) {
177
+ const target = sorted[scopeKey];
178
+ for (const [id, record] of Object.entries(index[scopeKey]).sort(
179
+ ([leftId], [rightId]) => leftId.localeCompare(rightId)
180
+ )) {
181
+ target[id] = record;
182
+ }
183
+ }
184
+ return sorted;
185
+ }
186
+ function childSystemsOf(system) {
187
+ return system.systems ?? system.subsystems ?? {};
188
+ }
189
+ function addRecord(index, diagnostics, sourcesById, scopeKey, record, context) {
190
+ let parsed;
191
+ try {
192
+ parsed = parseOntologyId(record.id);
193
+ } catch {
194
+ diagnostics.push({
195
+ code: "invalid_ontology_id",
196
+ message: `Invalid ontology ID "${record.id}" from ${context.source} at ${context.path.join(".")}`,
197
+ id: record.id,
198
+ path: context.path,
199
+ source: context.source,
200
+ origin: originFromContext(context)
201
+ });
202
+ return;
203
+ }
204
+ const expectedKind = SCOPE_KIND[scopeKey];
205
+ if (parsed.kind !== expectedKind) {
206
+ diagnostics.push({
207
+ code: "ontology_kind_mismatch",
208
+ message: `Ontology ID "${record.id}" has kind "${parsed.kind}" but was authored in ${scopeKey} (${expectedKind}) at ${context.path.join(".")}`,
209
+ id: record.id,
210
+ path: context.path,
211
+ source: context.source,
212
+ origin: originFromContext(context)
213
+ });
214
+ return;
215
+ }
216
+ const existing = sourcesById.get(parsed.id);
217
+ if (existing !== void 0) {
218
+ diagnostics.push({
219
+ code: "duplicate_ontology_id",
220
+ message: `Duplicate ontology ID "${parsed.id}" from ${context.source} at ${context.path.join(".")} conflicts with ${existing.source} at ${existing.path.join(".")}`,
221
+ id: parsed.id,
222
+ path: context.path,
223
+ source: context.source,
224
+ origin: originFromContext(context),
225
+ existingSource: existing.source,
226
+ existingOrigin: originFromContext(existing)
227
+ });
228
+ return;
229
+ }
230
+ sourcesById.set(parsed.id, context);
231
+ index[scopeKey][parsed.id] = {
232
+ ...record,
233
+ origin: originFromContext(context)
234
+ };
235
+ }
236
+ function addScope(index, diagnostics, sourcesById, scope, source, path) {
237
+ if (scope === void 0) return;
238
+ for (const scopeKey of SCOPE_KEYS) {
239
+ const records = scope[scopeKey] ?? {};
240
+ for (const [key, record] of Object.entries(records)) {
241
+ addRecord(index, diagnostics, sourcesById, scopeKey, record, {
242
+ source,
243
+ path: [...path, scopeKey, key],
244
+ kind: "authored",
245
+ systemPath: source.startsWith("system:") ? source.slice("system:".length, -".ontology".length) : void 0
246
+ });
247
+ }
248
+ }
249
+ }
250
+ function legacyObjectId(entity) {
251
+ return formatOntologyId({ scope: entity.ownedBySystemId, kind: "object", localId: entity.id });
252
+ }
253
+ function legacyActionOwner(action, entities) {
254
+ const firstAffectedEntityId = action.affects?.find((entityId) => entities[entityId] !== void 0);
255
+ if (firstAffectedEntityId !== void 0) {
256
+ return entities[firstAffectedEntityId].ownedBySystemId;
257
+ }
258
+ if (typeof action.scope === "object") {
259
+ return action.scope.domain;
260
+ }
261
+ return "global";
262
+ }
263
+ function addLegacyEntityProjections(index, diagnostics, sourcesById, entities) {
264
+ for (const entity of Object.values(entities)) {
265
+ const objectType = {
266
+ id: legacyObjectId(entity),
267
+ label: entity.label,
268
+ description: entity.description,
269
+ ownerSystemId: entity.ownedBySystemId,
270
+ ...entity.table !== void 0 ? {
271
+ storage: {
272
+ kind: "table",
273
+ table: entity.table
274
+ }
275
+ } : {},
276
+ legacyEntityId: entity.id,
277
+ ...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
278
+ ...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
279
+ };
280
+ addRecord(index, diagnostics, sourcesById, "objectTypes", objectType, {
281
+ source: "legacy.entities",
282
+ path: ["entities", entity.id],
283
+ kind: "projected",
284
+ systemPath: entity.ownedBySystemId,
285
+ legacyId: entity.id
286
+ });
287
+ entity.links?.forEach((link, linkIndex) => {
288
+ const targetEntity = entities[link.toEntity];
289
+ if (targetEntity === void 0) return;
290
+ const linkType = {
291
+ id: formatOntologyId({
292
+ scope: entity.ownedBySystemId,
293
+ kind: "link",
294
+ localId: `${entity.id}-${link.toEntity}-${linkIndex}`
295
+ }),
296
+ label: link.label ?? link.kind,
297
+ ownerSystemId: entity.ownedBySystemId,
298
+ from: legacyObjectId(entity),
299
+ to: legacyObjectId(targetEntity),
300
+ cardinality: link.kind,
301
+ ...link.via !== void 0 ? { via: link.via } : {},
302
+ legacyEntityId: entity.id
303
+ };
304
+ addRecord(index, diagnostics, sourcesById, "linkTypes", linkType, {
305
+ source: "legacy.entities.links",
306
+ path: ["entities", entity.id, "links", linkIndex],
307
+ kind: "projected",
308
+ systemPath: entity.ownedBySystemId,
309
+ legacyId: `${entity.id}.links.${linkIndex}`
310
+ });
311
+ });
312
+ }
313
+ }
314
+ function addLegacyActionProjections(index, diagnostics, sourcesById, actions, entities) {
315
+ for (const action of Object.values(actions)) {
316
+ const ownerSystemId = legacyActionOwner(action, entities);
317
+ const actionType = {
318
+ id: formatOntologyId({ scope: ownerSystemId, kind: "action", localId: action.id }),
319
+ label: action.label,
320
+ description: action.description,
321
+ ownerSystemId,
322
+ actsOn: action.affects?.map((entityId) => entities[entityId] ? legacyObjectId(entities[entityId]) : void 0).filter((id) => id !== void 0),
323
+ ...action.resourceId !== void 0 ? { resourceId: action.resourceId } : {},
324
+ ...action.invocations !== void 0 ? { invocations: action.invocations } : {},
325
+ ...action.lifecycle !== void 0 ? { lifecycle: action.lifecycle } : {},
326
+ legacyActionId: action.id
327
+ };
328
+ addRecord(index, diagnostics, sourcesById, "actionTypes", actionType, {
329
+ source: "legacy.actions",
330
+ path: ["actions", action.id],
331
+ kind: "projected",
332
+ systemPath: ownerSystemId,
333
+ legacyId: action.id
334
+ });
335
+ }
336
+ }
337
+ function addSystemContentProjections(index, diagnostics, sourcesById, systemPath, system, schemaPath) {
338
+ const content = system.content ?? {};
339
+ for (const [localId, node] of Object.entries(content)) {
340
+ if (node.kind !== "schema") continue;
341
+ const entries = Object.fromEntries(
342
+ Object.entries(content).filter(([, candidate]) => candidate.parentContentId === localId).map(([entryId, candidate]) => [
343
+ entryId,
344
+ {
345
+ label: candidate.label ?? entryId,
346
+ type: candidate.type,
347
+ ...candidate.description !== void 0 ? { description: candidate.description } : {},
348
+ ...candidate.data !== void 0 ? candidate.data : {}
349
+ }
350
+ ])
351
+ );
352
+ const catalogType = {
353
+ id: formatOntologyId({ scope: systemPath, kind: "catalog", localId }),
354
+ label: node.label ?? localId,
355
+ description: node.description,
356
+ ownerSystemId: systemPath,
357
+ kind: node.type,
358
+ ...typeof node.data?.["entityId"] === "string" ? { appliesTo: formatOntologyId({ scope: systemPath, kind: "object", localId: node.data["entityId"] }) } : {},
359
+ ...Object.keys(entries).length > 0 ? { entries } : {},
360
+ ...node.data !== void 0 ? { data: node.data } : {},
361
+ legacyContentId: `${systemPath}:${localId}`
362
+ };
363
+ addRecord(index, diagnostics, sourcesById, "catalogTypes", catalogType, {
364
+ source: "legacy.system.content",
365
+ path: [...schemaPath, "content", localId],
366
+ kind: "projected",
367
+ systemPath,
368
+ legacyId: `${systemPath}:${localId}`
369
+ });
370
+ }
371
+ }
372
+ function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schemaPath) {
373
+ for (const [key, system] of Object.entries(systems)) {
374
+ const systemPath = prefix ? `${prefix}.${key}` : key;
375
+ const currentPath = [...schemaPath, key];
376
+ addScope(index, diagnostics, sourcesById, system.ontology, `system:${systemPath}.ontology`, [
377
+ ...currentPath,
378
+ "ontology"
379
+ ]);
380
+ addSystemContentProjections(index, diagnostics, sourcesById, systemPath, system, currentPath);
381
+ addSystemScopes(index, diagnostics, sourcesById, childSystemsOf(system), systemPath, [
382
+ ...currentPath,
383
+ system.systems !== void 0 ? "systems" : "subsystems"
384
+ ]);
385
+ }
386
+ }
387
+ function compileOrganizationOntology(model) {
388
+ const ontology = createEmptyIndex();
389
+ const diagnostics = [];
390
+ const sourcesById = /* @__PURE__ */ new Map();
391
+ addScope(ontology, diagnostics, sourcesById, model.ontology, "organization.ontology", ["ontology"]);
392
+ addSystemScopes(ontology, diagnostics, sourcesById, model.systems ?? {}, "", ["systems"]);
393
+ addLegacyEntityProjections(ontology, diagnostics, sourcesById, model.entities ?? {});
394
+ addLegacyActionProjections(ontology, diagnostics, sourcesById, model.actions ?? {}, model.entities ?? {});
395
+ return { ontology: sortResolvedOntologyIndex(ontology), diagnostics };
396
+ }
4
397
  var ORGANIZATION_MODEL_ICON_TOKENS = [
5
- "nav.dashboard",
6
- "nav.calendar",
7
- "nav.sales",
8
- "nav.crm",
9
- "nav.lead-gen",
10
- "nav.projects",
11
- "nav.operations",
12
- "nav.monitoring",
13
- "nav.knowledge",
14
- "nav.settings",
15
- "nav.admin",
16
- "nav.archive",
17
- "knowledge.playbook",
18
- "knowledge.strategy",
19
- "knowledge.reference",
20
- "feature.dashboard",
21
- "feature.calendar",
22
- "feature.business",
23
- "feature.sales",
24
- "feature.crm",
25
- "feature.finance",
26
- "feature.lead-gen",
27
- "feature.platform",
28
- "feature.projects",
29
- "feature.operations",
30
- "feature.knowledge",
31
- "feature.monitoring",
32
- "feature.settings",
33
- "feature.admin",
34
- "feature.archive",
35
- "feature.seo",
36
- "resource.agent",
37
- "resource.workflow",
38
- "resource.integration",
39
- "resource.database",
40
- "resource.user",
41
- "resource.team",
42
- "integration.gmail",
43
- "integration.google-sheets",
44
- "integration.attio",
45
- "surface.dashboard",
46
- "surface.calendar",
47
- "surface.overview",
48
- "surface.command-view",
49
- "surface.command-queue",
50
- "surface.pipeline",
51
- "surface.lists",
52
- "surface.resources",
53
- "surface.settings",
54
- "status.success",
55
- "status.error",
56
- "status.warning",
57
- "status.info",
58
- "status.pending",
59
- "action.approve",
60
- "action.reject",
61
- "action.retry",
62
- "action.edit",
63
- "action.view",
64
- "action.launch",
65
- "action.message",
66
- "action.escalate",
67
- "action.promote",
68
- "action.submit",
69
- "action.email"
398
+ // Navigation / app areas
399
+ "dashboard",
400
+ "calendar",
401
+ "sales",
402
+ "crm",
403
+ "lead-gen",
404
+ "projects",
405
+ "operations",
406
+ "monitoring",
407
+ "knowledge",
408
+ "settings",
409
+ "admin",
410
+ "archive",
411
+ "business",
412
+ "finance",
413
+ "platform",
414
+ "seo",
415
+ // Knowledge kinds
416
+ "playbook",
417
+ "strategy",
418
+ "reference",
419
+ // Resource kinds
420
+ "agent",
421
+ "workflow",
422
+ "integration",
423
+ "database",
424
+ "user",
425
+ "team",
426
+ // Integration specifics
427
+ "gmail",
428
+ "google-sheets",
429
+ "attio",
430
+ // Surface / UI views
431
+ "overview",
432
+ "command-view",
433
+ "command-queue",
434
+ "pipeline",
435
+ "lists",
436
+ "resources",
437
+ // Actions
438
+ "approve",
439
+ "reject",
440
+ "retry",
441
+ "edit",
442
+ "view",
443
+ "launch",
444
+ "message",
445
+ "escalate",
446
+ "promote",
447
+ "submit",
448
+ "email",
449
+ // Status
450
+ "success",
451
+ "error",
452
+ "warning",
453
+ "info",
454
+ "pending",
455
+ // OM / UI group icons
456
+ "bolt",
457
+ "building",
458
+ "briefcase",
459
+ "apps",
460
+ "graph",
461
+ "shield",
462
+ "users",
463
+ "chart-bar",
464
+ "search"
70
465
  ];
71
- var CustomIconTokenSchema = z.string().trim().max(80).regex(/^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/, "Custom icon tokens must start with custom.");
466
+ var CustomIconTokenSchema = z.string().trim().max(80).regex(
467
+ /^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
468
+ 'Custom icon tokens must start with "custom." followed by lowercase alphanumeric segments'
469
+ );
72
470
  var OrganizationModelBuiltinIconTokenSchema = z.enum(ORGANIZATION_MODEL_ICON_TOKENS);
73
471
  var OrganizationModelIconTokenSchema = z.union([
74
472
  OrganizationModelBuiltinIconTokenSchema,
@@ -430,7 +828,99 @@ var LEAD_GEN_ACTION_ENTRIES = Object.fromEntries(
430
828
  return [parsed.id, parsed];
431
829
  })
432
830
  );
433
- var DEFAULT_ORGANIZATION_MODEL_ACTIONS = LEAD_GEN_ACTION_ENTRIES;
831
+ var CRM_ACTION_ENTRY_INPUTS = [
832
+ {
833
+ id: "send_reply",
834
+ order: 210,
835
+ label: "Send Reply",
836
+ description: "Send a contextual reply for an active CRM deal.",
837
+ scope: { domain: "sales" },
838
+ resourceId: "crm-send-reply-workflow",
839
+ affects: ["crm.deal"]
840
+ },
841
+ {
842
+ id: "send_link",
843
+ order: 220,
844
+ label: "Send Booking Link",
845
+ description: "Send a booking link to move a deal toward a scheduled call.",
846
+ scope: { domain: "sales" },
847
+ resourceId: "crm-send-booking-link-workflow",
848
+ affects: ["crm.deal"]
849
+ },
850
+ {
851
+ id: "send_nudge",
852
+ order: 230,
853
+ label: "Send Nudge",
854
+ description: "Send a follow-up nudge for a stalled CRM deal.",
855
+ scope: { domain: "sales" },
856
+ resourceId: "crm-send-nudge-workflow",
857
+ affects: ["crm.deal"]
858
+ },
859
+ {
860
+ id: "rebook",
861
+ order: 240,
862
+ label: "Rebook",
863
+ description: "Rebook a missed or rescheduled CRM appointment.",
864
+ scope: { domain: "sales" },
865
+ resourceId: "crm-rebook-workflow",
866
+ affects: ["crm.deal"]
867
+ },
868
+ {
869
+ id: "move_to_proposal",
870
+ order: 250,
871
+ label: "Move to Proposal",
872
+ description: "Advance a qualified CRM deal into the proposal stage.",
873
+ scope: { domain: "sales" },
874
+ resourceId: "move_to_proposal-workflow",
875
+ affects: ["crm.deal"]
876
+ },
877
+ {
878
+ id: "move_to_closing",
879
+ order: 260,
880
+ label: "Move to Closing",
881
+ description: "Advance a proposal-stage CRM deal into closing.",
882
+ scope: { domain: "sales" },
883
+ resourceId: "move_to_closing-workflow",
884
+ affects: ["crm.deal"]
885
+ },
886
+ {
887
+ id: "move_to_closed_won",
888
+ order: 270,
889
+ label: "Close Won",
890
+ description: "Mark a CRM deal as closed won.",
891
+ scope: { domain: "sales" },
892
+ resourceId: "move_to_closed_won-workflow",
893
+ affects: ["crm.deal"]
894
+ },
895
+ {
896
+ id: "move_to_closed_lost",
897
+ order: 280,
898
+ label: "Close Lost",
899
+ description: "Mark a CRM deal as closed lost.",
900
+ scope: { domain: "sales" },
901
+ resourceId: "move_to_closed_lost-workflow",
902
+ affects: ["crm.deal"]
903
+ },
904
+ {
905
+ id: "move_to_nurturing",
906
+ order: 290,
907
+ label: "Move to Nurturing",
908
+ description: "Move a CRM deal into nurturing for future follow-up.",
909
+ scope: { domain: "sales" },
910
+ resourceId: "move_to_nurturing-workflow",
911
+ affects: ["crm.deal"]
912
+ }
913
+ ];
914
+ var CRM_ACTION_ENTRIES = Object.fromEntries(
915
+ CRM_ACTION_ENTRY_INPUTS.map((action) => {
916
+ const parsed = ActionSchema.parse(action);
917
+ return [parsed.id, parsed];
918
+ })
919
+ );
920
+ var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {
921
+ ...LEAD_GEN_ACTION_ENTRIES,
922
+ ...CRM_ACTION_ENTRIES
923
+ };
434
924
  var ContentNodeBaseSchema = z.object({
435
925
  /** Human-readable label for the content node. */
436
926
  label: z.string().trim().min(1).max(120).meta({ label: "Label" }),
@@ -491,6 +981,17 @@ var SystemUiSchema = z.object({
491
981
  icon: IconNameSchema.optional(),
492
982
  order: z.number().int().optional()
493
983
  });
984
+ var JsonValueSchema = z.lazy(
985
+ () => z.union([
986
+ z.string(),
987
+ z.number(),
988
+ z.boolean(),
989
+ z.null(),
990
+ z.array(JsonValueSchema),
991
+ z.record(z.string(), JsonValueSchema)
992
+ ])
993
+ );
994
+ var SystemConfigSchema = z.record(z.string().trim().min(1).max(200), JsonValueSchema).default({}).optional();
494
995
  var SystemEntrySchema = z.object({
495
996
  /** Stable tenant-defined system id (e.g. "sys.lead-gen" or "sales.crm"). */
496
997
  id: SystemIdSchema,
@@ -536,11 +1037,21 @@ var SystemEntrySchema = z.object({
536
1037
  /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
537
1038
  order: z.number(),
538
1039
  /**
539
- * System-scoped operational data, co-located with the owning system.
540
- * Per L1, L3, L13: keyed by local NodeId (the key is the local id; qualified
541
- * id is `<system-path>:<local-id>`, computed by graph projection).
542
- * Per L14: every ContentNode carries both `kind` and `type`.
543
- * Per D2: unregistered (kind, type) pairs parse successfully.
1040
+ * System-local JSON settings and defaults. Strongly typed OM fields,
1041
+ * secrets, credentials, and runtime state stay outside this bucket.
1042
+ */
1043
+ config: SystemConfigSchema,
1044
+ /**
1045
+ * System-owned ontology declarations. `systems` is now the canonical child
1046
+ * key; this scope holds the object, action, catalog, link, event, and
1047
+ * shared contract records owned by this system.
1048
+ */
1049
+ ontology: OntologyScopeSchema.optional(),
1050
+ /**
1051
+ * @deprecated Compatibility-only bridge for old tenant content nodes and
1052
+ * migration readers. New schema/catalog authoring belongs in ontology;
1053
+ * new system-local settings belong in config. Bridge nodes are keyed by
1054
+ * local NodeId and may still project to content-node:* graph IDs.
544
1055
  */
545
1056
  content: z.record(z.string().trim().min(1).max(200), ContentNodeSchema).optional(),
546
1057
  /**
@@ -550,14 +1061,17 @@ var SystemEntrySchema = z.object({
550
1061
  * Per Phase 4: `id` and `parentSystemId` fields will be removed in favour of
551
1062
  * position-derived paths. Both still exist on this schema for backward compat.
552
1063
  */
1064
+ systems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional(),
1065
+ /** @deprecated Use systems. Accepted as a compatibility alias during the ontology bridge. */
553
1066
  subsystems: z.lazy(() => z.record(z.string().trim().min(1).max(100), SystemEntrySchema)).optional()
554
1067
  }).refine((system) => system.label !== void 0 || system.title !== void 0, {
555
1068
  path: ["label"],
556
1069
  message: "System must provide label or title"
557
1070
  }).transform((system) => {
558
- if (system.status === void 0) return system;
1071
+ const normalizedSystem = system.systems !== void 0 && system.subsystems === void 0 ? { ...system, subsystems: system.systems } : system;
1072
+ if (normalizedSystem.status === void 0) return normalizedSystem;
559
1073
  console.warn("[organization-model] System.status is deprecated; use System.lifecycle instead.");
560
- return system.lifecycle === void 0 ? { ...system, lifecycle: system.status } : system;
1074
+ return normalizedSystem.lifecycle === void 0 ? { ...normalizedSystem, lifecycle: normalizedSystem.status } : normalizedSystem;
561
1075
  });
562
1076
  var SystemsDomainSchema = z.record(z.string(), SystemEntrySchema).refine((record) => Object.entries(record).every(([key, entry]) => entry.id === key), {
563
1077
  message: "Each system entry id must match its map key"
@@ -633,6 +1147,7 @@ z.enum(["workflow", "agent", "integration", "script"]).meta({ label: "Resource k
633
1147
  var ResourceGovernanceStatusSchema = z.enum(["active", "deprecated", "archived"]).meta({ label: "Governance status", color: "teal" });
634
1148
  var AgentKindSchema = z.enum(["orchestrator", "specialist", "utility", "platform"]).meta({ label: "Agent kind", color: "violet" });
635
1149
  var ScriptResourceLanguageSchema = z.enum(["shell", "sql", "typescript", "python"]).meta({ label: "Language" });
1150
+ var CodeReferenceRoleSchema = z.enum(["entrypoint", "handler", "schema", "test", "docs", "config"]).meta({ label: "Code reference role", color: "blue" });
636
1151
  var ResourceIdSchema = z.string().trim().min(1).max(255).regex(/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*$/, "Resource IDs must use letters, numbers, -, _, or . separators");
637
1152
  var EventIdSchema = z.string().trim().min(1).max(300).regex(
638
1153
  /^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*:[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
@@ -650,6 +1165,19 @@ EventEmissionDescriptorSchema.extend({
650
1165
  ownerId: z.union([ResourceIdSchema, ModelIdSchema]),
651
1166
  ownerKind: z.enum(["resource", "entity"]).meta({ label: "Owner kind" })
652
1167
  });
1168
+ var ResourceOntologyBindingSchema = z.object({
1169
+ implements: z.array(OntologyIdSchema).optional(),
1170
+ reads: z.array(OntologyIdSchema).optional(),
1171
+ writes: z.array(OntologyIdSchema).optional(),
1172
+ usesCatalogs: z.array(OntologyIdSchema).optional(),
1173
+ emits: z.array(OntologyIdSchema).optional()
1174
+ });
1175
+ var CodeReferenceSchema = z.object({
1176
+ path: z.string().trim().min(1).max(500).regex(/^[A-Za-z0-9_./$@()[\] -]+$/, "Code reference paths must be repo-relative paths"),
1177
+ role: CodeReferenceRoleSchema,
1178
+ symbol: z.string().trim().min(1).max(200).optional(),
1179
+ description: z.string().trim().min(1).max(300).optional()
1180
+ });
653
1181
  var ResourceEntryBaseSchema = z.object({
654
1182
  /** Canonical resource id; runtime resourceId derives from this value. */
655
1183
  id: ResourceIdSchema,
@@ -659,7 +1187,15 @@ var ResourceEntryBaseSchema = z.object({
659
1187
  systemPath: SystemPathSchema.meta({ ref: "system" }),
660
1188
  /** Optional role responsible for maintaining this resource. */
661
1189
  ownerRoleId: ModelIdSchema.meta({ ref: "role" }).optional(),
662
- status: ResourceGovernanceStatusSchema
1190
+ status: ResourceGovernanceStatusSchema,
1191
+ /**
1192
+ * Ontology contract bindings for the semantic work this resource performs.
1193
+ * `emits` stays nested here so top-level resource emits descriptors remain
1194
+ * compatible with graph event projection during the bridge.
1195
+ */
1196
+ ontology: ResourceOntologyBindingSchema.optional(),
1197
+ /** Repo-relative implementation breadcrumbs for agents and operators. */
1198
+ codeRefs: z.array(CodeReferenceSchema).default([])
663
1199
  });
664
1200
  var WorkflowResourceEntrySchema = ResourceEntryBaseSchema.extend({
665
1201
  kind: z.literal("workflow"),
@@ -706,6 +1242,9 @@ var ResourcesDomainSchema = z.record(z.string(), ResourceEntrySchema).refine((re
706
1242
  var DEFAULT_ORGANIZATION_MODEL_RESOURCES = {};
707
1243
 
708
1244
  // ../core/src/organization-model/helpers.ts
1245
+ function childSystemsOf2(system) {
1246
+ return system.systems ?? system.subsystems ?? {};
1247
+ }
709
1248
  function defaultPathFor(id) {
710
1249
  return `/${id.replaceAll(".", "/")}`;
711
1250
  }
@@ -753,7 +1292,7 @@ function getSystem(model, path) {
753
1292
  for (const seg of segments) {
754
1293
  node = current[seg];
755
1294
  if (node === void 0) return void 0;
756
- current = node.subsystems ?? {};
1295
+ current = childSystemsOf2(node);
757
1296
  }
758
1297
  return node;
759
1298
  }
@@ -765,7 +1304,7 @@ function getSystemAncestors(model, path) {
765
1304
  const node = current[seg];
766
1305
  if (node === void 0) return [];
767
1306
  result.push(node);
768
- current = node.subsystems ?? {};
1307
+ current = childSystemsOf2(node);
769
1308
  }
770
1309
  return result;
771
1310
  }
@@ -775,8 +1314,9 @@ function listAllSystems(model) {
775
1314
  for (const [localId, system] of Object.entries(map)) {
776
1315
  const fullPath = prefix ? `${prefix}.${localId}` : localId;
777
1316
  results.push({ path: fullPath, system });
778
- if (system.subsystems) {
779
- walk(system.subsystems, fullPath);
1317
+ const childSystems = childSystemsOf2(system);
1318
+ if (Object.keys(childSystems).length > 0) {
1319
+ walk(childSystems, fullPath);
780
1320
  }
781
1321
  }
782
1322
  }
@@ -792,6 +1332,30 @@ function getContent(model, qualifiedId) {
792
1332
  const system = getSystem(model, systemPath);
793
1333
  return system?.content?.[localId];
794
1334
  }
1335
+ function isPlainJsonObject(value) {
1336
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1337
+ }
1338
+ function mergeJsonConfig(base, override) {
1339
+ const result = { ...base };
1340
+ for (const [key, value] of Object.entries(override)) {
1341
+ const existing = result[key];
1342
+ result[key] = isPlainJsonObject(existing) && isPlainJsonObject(value) ? mergeJsonConfig(existing, value) : value;
1343
+ }
1344
+ return result;
1345
+ }
1346
+ function resolveSystemConfig(model, path) {
1347
+ const system = getSystem(model, path);
1348
+ if (system === void 0) return {};
1349
+ let resolved = {};
1350
+ for (const node of Object.values(system.content ?? {})) {
1351
+ if (node.kind !== "config" || node.type !== "kv") continue;
1352
+ const entries = node.data?.entries;
1353
+ if (isPlainJsonObject(entries)) {
1354
+ resolved = mergeJsonConfig(resolved, entries);
1355
+ }
1356
+ }
1357
+ return mergeJsonConfig(resolved, system.config ?? {});
1358
+ }
795
1359
  function getResourcesForSystem(model, systemPath, options = {}) {
796
1360
  const { includeDescendants = false } = options;
797
1361
  const prefix = systemPath + ".";
@@ -1843,19 +2407,29 @@ var KnowledgeTargetKindSchema = z.enum([
1843
2407
  "goal",
1844
2408
  "customer-segment",
1845
2409
  "offering",
2410
+ "ontology",
1846
2411
  // D4: content nodes are a valid knowledge target after compound-domain data moved into system.content
1847
2412
  "content-node"
1848
2413
  ]).meta({ label: "Target kind" });
1849
2414
  var KnowledgeTargetRefSchema = z.object({
1850
2415
  kind: KnowledgeTargetKindSchema,
1851
- // D4: content-node targets use a qualified id format '<system-path>:<local-content-id>'
1852
- // which contains a colon separator and cannot satisfy ModelIdSchema. Use a permissive
1853
- // string schema here; business-logic validation of target existence is done in
1854
- // OrganizationModelSchema.superRefine (knowledgeTargetExists).
2416
+ // D4: content-node targets use a qualified id format '<system-path>:<local-content-id>'.
2417
+ // Ontology targets use the canonical '<scope>:<kind>/<local-id>' ontology id format.
2418
+ // Business-logic validation of target existence is done in OrganizationModelSchema.superRefine.
1855
2419
  id: z.string().trim().min(1).max(300)
2420
+ }).superRefine((target, ctx) => {
2421
+ if (target.kind !== "ontology") return;
2422
+ const result = OntologyIdSchema.safeParse(target.id);
2423
+ if (!result.success) {
2424
+ ctx.addIssue({
2425
+ code: z.ZodIssueCode.custom,
2426
+ path: ["id"],
2427
+ message: "Ontology knowledge targets must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
2428
+ });
2429
+ }
1856
2430
  });
1857
2431
  var LegacyKnowledgeLinkSchema = z.object({
1858
- nodeId: NodeIdStringSchema
2432
+ nodeId: z.union([NodeIdStringSchema, z.templateLiteral(["ontology:", OntologyIdSchema])])
1859
2433
  });
1860
2434
  var CanonicalKnowledgeLinkSchema = z.object({
1861
2435
  target: KnowledgeTargetRefSchema
@@ -1886,6 +2460,8 @@ var OrgKnowledgeNodeSchema = z.object({
1886
2460
  icon: IconNameSchema.optional(),
1887
2461
  /** Canonical documentation URL when body content is a local summary. */
1888
2462
  externalUrl: z.string().trim().url().max(500).optional(),
2463
+ /** Optional generated source file path for local MDX-backed knowledge nodes. */
2464
+ sourceFilePath: z.string().trim().min(1).max(500).optional(),
1889
2465
  /** Raw MDX string. Phase 2 will introduce a structured block format. */
1890
2466
  body: z.string().trim().min(1),
1891
2467
  /**
@@ -1986,6 +2562,7 @@ z.enum([
1986
2562
  "roles",
1987
2563
  "goals",
1988
2564
  "systems",
2565
+ "ontology",
1989
2566
  "resources",
1990
2567
  "actions",
1991
2568
  "entities",
@@ -2004,6 +2581,7 @@ var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
2004
2581
  roles: { version: 1, lastModified: "2026-05-10" },
2005
2582
  goals: { version: 1, lastModified: "2026-05-10" },
2006
2583
  systems: { version: 1, lastModified: "2026-05-10" },
2584
+ ontology: { version: 1, lastModified: "2026-05-14" },
2007
2585
  resources: { version: 1, lastModified: "2026-05-10" },
2008
2586
  actions: { version: 1, lastModified: "2026-05-10" },
2009
2587
  entities: { version: 1, lastModified: "2026-05-10" },
@@ -2018,6 +2596,7 @@ var OrganizationModelDomainMetadataByDomainSchema = z.object({
2018
2596
  roles: OrganizationModelDomainMetadataSchema,
2019
2597
  goals: OrganizationModelDomainMetadataSchema,
2020
2598
  systems: OrganizationModelDomainMetadataSchema,
2599
+ ontology: OrganizationModelDomainMetadataSchema,
2021
2600
  resources: OrganizationModelDomainMetadataSchema,
2022
2601
  actions: OrganizationModelDomainMetadataSchema,
2023
2602
  entities: OrganizationModelDomainMetadataSchema,
@@ -2035,6 +2614,7 @@ var OrganizationModelSchemaBase = z.object({
2035
2614
  roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
2036
2615
  goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
2037
2616
  systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
2617
+ ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
2038
2618
  resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
2039
2619
  actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
2040
2620
  entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
@@ -2062,13 +2642,16 @@ function asRoleHolderArray(heldBy) {
2062
2642
  function isKnowledgeKindCompatibleWithTarget(knowledgeKind, targetKind) {
2063
2643
  if (knowledgeKind === "reference") return true;
2064
2644
  if (knowledgeKind === "playbook") {
2065
- return ["system", "resource", "stage", "action"].includes(targetKind);
2645
+ return ["system", "resource", "stage", "action", "ontology"].includes(targetKind);
2066
2646
  }
2067
2647
  if (knowledgeKind === "strategy") {
2068
- return ["system", "goal", "offering", "customer-segment"].includes(targetKind);
2648
+ return ["system", "goal", "offering", "customer-segment", "ontology"].includes(targetKind);
2069
2649
  }
2070
2650
  return false;
2071
2651
  }
2652
+ function isRecord(value) {
2653
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2654
+ }
2072
2655
  var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ctx) => {
2073
2656
  function collectAllSystems(systems, prefix = "", schemaPath = ["systems"]) {
2074
2657
  const result = [];
@@ -2076,8 +2659,11 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2076
2659
  const path = prefix ? `${prefix}.${key}` : key;
2077
2660
  const currentSchemaPath = [...schemaPath, key];
2078
2661
  result.push({ path, schemaPath: currentSchemaPath, system });
2079
- if (system.subsystems !== void 0) {
2080
- result.push(...collectAllSystems(system.subsystems, path, [...currentSchemaPath, "subsystems"]));
2662
+ const childSystems = system.systems ?? system.subsystems;
2663
+ if (childSystems !== void 0) {
2664
+ result.push(
2665
+ ...collectAllSystems(childSystems, path, [...currentSchemaPath, system.systems !== void 0 ? "systems" : "subsystems"])
2666
+ );
2081
2667
  }
2082
2668
  }
2083
2669
  return result;
@@ -2097,7 +2683,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2097
2683
  `System "${system.id}" references unknown parent "${system.parentSystemId}"`
2098
2684
  );
2099
2685
  }
2100
- const hasChildren = Object.keys(system.subsystems ?? {}).length > 0 || allSystems.some((candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes("."));
2686
+ const hasChildren = Object.keys(system.systems ?? system.subsystems ?? {}).length > 0 || allSystems.some((candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes("."));
2101
2687
  const contributesRoutePath = system.ui?.path !== void 0 || system.path !== void 0 || !hasChildren;
2102
2688
  if (contributesRoutePath) {
2103
2689
  const effectivePath = system.ui?.path ?? system.path ?? defaultSystemPathFor(path);
@@ -2113,7 +2699,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2113
2699
  }
2114
2700
  }
2115
2701
  if (hasChildren && isLifecycleEnabled(system.lifecycle, system.enabled)) {
2116
- const hasEnabledDescendant = Object.values(system.subsystems ?? {}).some(
2702
+ const hasEnabledDescendant = Object.values(system.systems ?? system.subsystems ?? {}).some(
2117
2703
  (candidate) => isLifecycleEnabled(candidate.lifecycle, candidate.enabled)
2118
2704
  ) || allSystems.some(
2119
2705
  (candidate) => candidate.path.startsWith(`${path}.`) && !candidate.path.slice(path.length + 1).includes(".") && isLifecycleEnabled(candidate.system.lifecycle, candidate.system.enabled)
@@ -2358,6 +2944,60 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2358
2944
  const stageIds = /* @__PURE__ */ new Set();
2359
2945
  const actionIds = new Set(Object.keys(model.actions));
2360
2946
  const offeringsById = new Map(Object.entries(model.offerings));
2947
+ const ontologyCompilation = compileOrganizationOntology(model);
2948
+ const ontologyIndexByKind = {
2949
+ object: ontologyCompilation.ontology.objectTypes,
2950
+ link: ontologyCompilation.ontology.linkTypes,
2951
+ action: ontologyCompilation.ontology.actionTypes,
2952
+ catalog: ontologyCompilation.ontology.catalogTypes,
2953
+ event: ontologyCompilation.ontology.eventTypes,
2954
+ interface: ontologyCompilation.ontology.interfaceTypes,
2955
+ "value-type": ontologyCompilation.ontology.valueTypes,
2956
+ property: ontologyCompilation.ontology.sharedProperties,
2957
+ group: ontologyCompilation.ontology.groups,
2958
+ surface: ontologyCompilation.ontology.surfaces
2959
+ };
2960
+ const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index) => Object.keys(index)));
2961
+ const ontologyReferenceKeyKinds = {
2962
+ valueType: "value-type",
2963
+ catalogType: "catalog",
2964
+ objectType: "object",
2965
+ eventType: "event",
2966
+ actionType: "action",
2967
+ linkType: "link",
2968
+ interfaceType: "interface",
2969
+ propertyType: "property",
2970
+ groupType: "group",
2971
+ surfaceType: "surface",
2972
+ stepCatalog: "catalog"
2973
+ };
2974
+ function validateKnownOntologyReferences(ownerId, value, path, seen = /* @__PURE__ */ new WeakSet()) {
2975
+ if (Array.isArray(value)) {
2976
+ value.forEach((entry, index) => validateKnownOntologyReferences(ownerId, entry, [...path, index], seen));
2977
+ return;
2978
+ }
2979
+ if (!isRecord(value)) return;
2980
+ if (seen.has(value)) return;
2981
+ seen.add(value);
2982
+ Object.entries(value).forEach(([key, entry]) => {
2983
+ const expectedKind = ontologyReferenceKeyKinds[key];
2984
+ if (expectedKind !== void 0) {
2985
+ if (typeof entry !== "string") {
2986
+ addIssue(ctx, [...path, key], `Ontology record "${ownerId}" ${key} must be an ontology ID string`);
2987
+ } else if (ontologyIndexByKind[expectedKind][entry] === void 0) {
2988
+ addIssue(
2989
+ ctx,
2990
+ [...path, key],
2991
+ `Ontology record "${ownerId}" ${key} references unknown ${expectedKind} ontology ID "${entry}"`
2992
+ );
2993
+ }
2994
+ }
2995
+ validateKnownOntologyReferences(ownerId, entry, [...path, key], seen);
2996
+ });
2997
+ }
2998
+ for (const { id, record } of listResolvedOntologyRecords(ontologyCompilation.ontology)) {
2999
+ validateKnownOntologyReferences(id, record, record.origin.path);
3000
+ }
2361
3001
  Object.values(model.policies).forEach((policy) => {
2362
3002
  policy.appliesTo.systemIds.forEach((systemId, systemIndex) => {
2363
3003
  if (!systemsById.has(systemId)) {
@@ -2411,6 +3051,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2411
3051
  if (kind === "goal") return goalsById.has(id);
2412
3052
  if (kind === "customer-segment") return segmentsById.has(id);
2413
3053
  if (kind === "offering") return offeringsById.has(id);
3054
+ if (kind === "ontology") return ontologyIds.has(id);
2414
3055
  return false;
2415
3056
  }
2416
3057
  Object.entries(model.knowledge).forEach(([nodeId2, node]) => {
@@ -2454,6 +3095,26 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2454
3095
  );
2455
3096
  }
2456
3097
  });
3098
+ function validateResourceOntologyBinding(resourceId, bindingKey, expectedKind, ids) {
3099
+ ids?.forEach((ontologyId, ontologyIndex) => {
3100
+ if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
3101
+ addIssue(
3102
+ ctx,
3103
+ ["resources", resourceId, "ontology", bindingKey, ontologyIndex],
3104
+ `Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
3105
+ );
3106
+ }
3107
+ });
3108
+ }
3109
+ Object.values(model.resources).forEach((resource) => {
3110
+ const binding = resource.ontology;
3111
+ if (binding === void 0) return;
3112
+ validateResourceOntologyBinding(resource.id, "implements", "action", binding.implements);
3113
+ validateResourceOntologyBinding(resource.id, "reads", "object", binding.reads);
3114
+ validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
3115
+ validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
3116
+ validateResourceOntologyBinding(resource.id, "emits", "event", binding.emits);
3117
+ });
2457
3118
  Object.values(model.roles).forEach((role) => {
2458
3119
  if (role.heldBy === void 0) return;
2459
3120
  asRoleHolderArray(role.heldBy).forEach((holder, holderIndex) => {
@@ -2488,11 +3149,13 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2488
3149
  });
2489
3150
  });
2490
3151
  function validateSystemContent(system, systemPath) {
3152
+ const childSystems = system.systems ?? system.subsystems;
3153
+ const childKey = system.systems !== void 0 ? "systems" : "subsystems";
2491
3154
  const content = system.content;
2492
3155
  if (content === void 0 || Object.keys(content).length === 0) {
2493
- if (system.subsystems !== void 0) {
2494
- Object.entries(system.subsystems).forEach(([childKey, child]) => {
2495
- validateSystemContent(child, [...systemPath, "subsystems", childKey]);
3156
+ if (childSystems !== void 0) {
3157
+ Object.entries(childSystems).forEach(([childLocalId, child]) => {
3158
+ validateSystemContent(child, [...systemPath, childKey, childLocalId]);
2496
3159
  });
2497
3160
  }
2498
3161
  return;
@@ -2548,15 +3211,18 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2548
3211
  }
2549
3212
  }
2550
3213
  });
2551
- if (system.subsystems !== void 0) {
2552
- Object.entries(system.subsystems).forEach(([childKey, child]) => {
2553
- validateSystemContent(child, [...systemPath, "subsystems", childKey]);
3214
+ if (childSystems !== void 0) {
3215
+ Object.entries(childSystems).forEach(([childLocalId, child]) => {
3216
+ validateSystemContent(child, [...systemPath, childKey, childLocalId]);
2554
3217
  });
2555
3218
  }
2556
3219
  }
2557
3220
  Object.entries(model.systems).forEach(([systemKey, system]) => {
2558
3221
  validateSystemContent(system, ["systems", systemKey]);
2559
3222
  });
3223
+ for (const diagnostic of ontologyCompilation.diagnostics) {
3224
+ addIssue(ctx, diagnostic.path, diagnostic.message);
3225
+ }
2560
3226
  });
2561
3227
 
2562
3228
  // ../core/src/organization-model/graph/schema.ts
@@ -2577,6 +3243,7 @@ var OrganizationGraphNodeKindSchema = z.enum([
2577
3243
  "surface",
2578
3244
  "navigation-group",
2579
3245
  // Phase 3 preview — Phase 4 populates via graph projection of system.content entries.
3246
+ "ontology",
2580
3247
  "content-node"
2581
3248
  ]);
2582
3249
  var OrganizationGraphEdgeKindSchema = z.enum([
@@ -2591,23 +3258,28 @@ var OrganizationGraphEdgeKindSchema = z.enum([
2591
3258
  "originates_from",
2592
3259
  "triggers",
2593
3260
  "applies_to",
2594
- "effects"
3261
+ "effects",
3262
+ "implements",
3263
+ "reads",
3264
+ "writes",
3265
+ "uses_catalog"
2595
3266
  ]);
2596
3267
  var OrganizationGraphNodeSchema = z.object({
2597
- id: z.string().trim().min(1).max(200),
3268
+ id: z.string().trim().min(1).max(400),
2598
3269
  kind: OrganizationGraphNodeKindSchema,
2599
3270
  label: LabelSchema,
2600
- sourceId: z.string().trim().min(1).max(255).optional(),
3271
+ sourceId: z.string().trim().min(1).max(400).optional(),
2601
3272
  description: DescriptionSchema.optional(),
2602
3273
  icon: IconNameSchema.optional(),
2603
3274
  enabled: z.boolean().optional(),
3275
+ ontologyKind: z.string().trim().min(1).max(80).optional(),
2604
3276
  resourceType: z.enum(["workflow", "agent", "trigger", "integration", "external", "human_checkpoint", "script"]).optional()
2605
3277
  });
2606
3278
  var OrganizationGraphEdgeSchema = z.object({
2607
- id: z.string().trim().min(1).max(250),
3279
+ id: z.string().trim().min(1).max(900),
2608
3280
  kind: OrganizationGraphEdgeKindSchema,
2609
- sourceId: z.string().trim().min(1).max(200),
2610
- targetId: z.string().trim().min(1).max(200),
3281
+ sourceId: z.string().trim().min(1).max(400),
3282
+ targetId: z.string().trim().min(1).max(400),
2611
3283
  label: z.string().trim().min(1).max(120).optional(),
2612
3284
  relationshipType: z.enum(["triggers", "uses", "approval"]).optional()
2613
3285
  });
@@ -2668,7 +3340,7 @@ function getAllBuildTemplates(model) {
2668
3340
  label: s.label ?? stepLocalId,
2669
3341
  ...s.description ? { description: s.description } : {},
2670
3342
  // Pass through all data fields — template-step payload is richer than Pipeline;
2671
- // Wave 2 authors the canonical shape; Wave 4 verifies round-trip fidelity.
3343
+ // Bridge readers preserve the historical shape for round-trip fidelity.
2672
3344
  ...sd
2673
3345
  };
2674
3346
  });
@@ -2832,6 +3504,20 @@ function invocationLabel(invocation) {
2832
3504
  function eventNodeId(eventId) {
2833
3505
  return nodeId("event", eventId);
2834
3506
  }
3507
+ function ontologyLabel(id, label) {
3508
+ return label ?? parseOntologyId(id).localId;
3509
+ }
3510
+ function pushOntologyBindingEdges(edges, edgeIds, resourceNodeId, kind, ids) {
3511
+ ids?.forEach((ontologyId) => {
3512
+ const targetId = ontologyGraphNodeId(ontologyId);
3513
+ pushUniqueEdge(edges, edgeIds, {
3514
+ id: edgeId(kind, resourceNodeId, targetId),
3515
+ kind,
3516
+ sourceId: resourceNodeId,
3517
+ targetId
3518
+ });
3519
+ });
3520
+ }
2835
3521
  function buildResourceEventDescriptor(resourceId, emission) {
2836
3522
  return {
2837
3523
  ...emission,
@@ -2879,6 +3565,7 @@ function buildOrganizationGraph(input) {
2879
3565
  const organizationModelResourceIds = new Set(Object.keys(organizationModel.resources));
2880
3566
  const actionIdsByInvocation = /* @__PURE__ */ new Map();
2881
3567
  const projectedEventNodeIdsByEventId = /* @__PURE__ */ new Map();
3568
+ const ontologyCompilation = compileOrganizationOntology(organizationModel);
2882
3569
  const organizationNode = {
2883
3570
  id: nodeId("organization"),
2884
3571
  kind: "organization",
@@ -2920,6 +3607,78 @@ function buildOrganizationGraph(input) {
2920
3607
  });
2921
3608
  }
2922
3609
  }
3610
+ for (const { id: ontologyId, kind, record } of listResolvedOntologyRecords(ontologyCompilation.ontology).sort(
3611
+ (a, b) => a.id.localeCompare(b.id)
3612
+ )) {
3613
+ const id = ontologyGraphNodeId(ontologyId);
3614
+ const parsedId = parseOntologyId(ontologyId);
3615
+ pushUniqueNode(nodes, nodeIds, {
3616
+ id,
3617
+ kind: "ontology",
3618
+ label: ontologyLabel(ontologyId, record.label),
3619
+ sourceId: ontologyId,
3620
+ description: record.description,
3621
+ ontologyKind: kind
3622
+ });
3623
+ const ownerSystemId = record.ownerSystemId ?? (parsedId.isGlobal ? void 0 : parsedId.scope);
3624
+ if (ownerSystemId !== void 0 && validSystemRefs.has(ownerSystemId)) {
3625
+ pushUniqueEdge(edges, edgeIds, {
3626
+ id: edgeId("contains", systemNodeId(ownerSystemId), id, `ontology-${kind}`),
3627
+ kind: "contains",
3628
+ sourceId: systemNodeId(ownerSystemId),
3629
+ targetId: id
3630
+ });
3631
+ } else {
3632
+ pushUniqueEdge(edges, edgeIds, {
3633
+ id: edgeId("contains", organizationNode.id, id, `ontology-${kind}`),
3634
+ kind: "contains",
3635
+ sourceId: organizationNode.id,
3636
+ targetId: id
3637
+ });
3638
+ }
3639
+ if (kind === "link") {
3640
+ const link = record;
3641
+ pushUniqueEdge(edges, edgeIds, {
3642
+ id: edgeId("links", ontologyGraphNodeId(link.from), ontologyGraphNodeId(link.to), ontologyId),
3643
+ kind: "links",
3644
+ sourceId: ontologyGraphNodeId(link.from),
3645
+ targetId: ontologyGraphNodeId(link.to),
3646
+ label: link.label ?? parsedId.localId
3647
+ });
3648
+ }
3649
+ if (kind === "action") {
3650
+ const action = record;
3651
+ for (const targetOntologyId of action.actsOn ?? []) {
3652
+ pushUniqueEdge(edges, edgeIds, {
3653
+ id: edgeId("affects", id, ontologyGraphNodeId(targetOntologyId), ontologyId),
3654
+ kind: "affects",
3655
+ sourceId: id,
3656
+ targetId: ontologyGraphNodeId(targetOntologyId)
3657
+ });
3658
+ }
3659
+ }
3660
+ if (kind === "catalog") {
3661
+ const catalog = record;
3662
+ if (catalog.appliesTo === void 0) continue;
3663
+ pushUniqueEdge(edges, edgeIds, {
3664
+ id: edgeId("applies_to", id, ontologyGraphNodeId(catalog.appliesTo), ontologyId),
3665
+ kind: "applies_to",
3666
+ sourceId: id,
3667
+ targetId: ontologyGraphNodeId(catalog.appliesTo)
3668
+ });
3669
+ }
3670
+ if (kind === "group") {
3671
+ const group = record;
3672
+ for (const memberOntologyId of group.members ?? []) {
3673
+ pushUniqueEdge(edges, edgeIds, {
3674
+ id: edgeId("contains", id, ontologyGraphNodeId(memberOntologyId), ontologyId),
3675
+ kind: "contains",
3676
+ sourceId: id,
3677
+ targetId: ontologyGraphNodeId(memberOntologyId)
3678
+ });
3679
+ }
3680
+ }
3681
+ }
2923
3682
  for (const role of Object.values(organizationModel.roles).sort((a, b) => a.id.localeCompare(b.id))) {
2924
3683
  const id = nodeId("role", role.id);
2925
3684
  pushUniqueNode(nodes, nodeIds, {
@@ -2971,7 +3730,7 @@ function buildOrganizationGraph(input) {
2971
3730
  targetId: id
2972
3731
  });
2973
3732
  for (const link of node.links) {
2974
- const targetId = link.target.kind === "system" ? systemNodeId(link.target.id) : link.nodeId;
3733
+ const targetId = link.target.kind === "system" ? systemNodeId(link.target.id) : link.target.kind === "ontology" ? ontologyGraphNodeId(link.target.id) : link.nodeId;
2975
3734
  pushUniqueEdge(edges, edgeIds, {
2976
3735
  id: edgeId("governs", id, targetId),
2977
3736
  kind: "governs",
@@ -3136,6 +3895,11 @@ function buildOrganizationGraph(input) {
3136
3895
  targetId: resourceNode.id
3137
3896
  });
3138
3897
  }
3898
+ pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "implements", resource.ontology?.implements);
3899
+ pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "reads", resource.ontology?.reads);
3900
+ pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "writes", resource.ontology?.writes);
3901
+ pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "uses_catalog", resource.ontology?.usesCatalogs);
3902
+ pushOntologyBindingEdges(edges, edgeIds, resourceNode.id, "emits", resource.ontology?.emits);
3139
3903
  if (resource.kind === "workflow" || resource.kind === "agent") {
3140
3904
  for (const emission of resource.emits ?? []) {
3141
3905
  pushEventProjection(
@@ -3510,14 +4274,14 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
3510
4274
  label: "Dashboard",
3511
4275
  path: "/",
3512
4276
  surfaceType: "dashboard",
3513
- icon: "feature.dashboard",
4277
+ icon: "dashboard",
3514
4278
  order: 10,
3515
4279
  targets: { systems: ["dashboard"] }
3516
4280
  },
3517
4281
  business: {
3518
4282
  type: "group",
3519
4283
  label: "Business",
3520
- icon: "feature.business",
4284
+ icon: "business",
3521
4285
  order: 20,
3522
4286
  children: {
3523
4287
  sales: {
@@ -3525,7 +4289,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
3525
4289
  label: "Sales",
3526
4290
  path: "/sales",
3527
4291
  surfaceType: "page",
3528
- icon: "feature.sales",
4292
+ icon: "sales",
3529
4293
  order: 10,
3530
4294
  targets: { systems: ["sales"] }
3531
4295
  },
@@ -3534,7 +4298,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
3534
4298
  label: "Clients",
3535
4299
  path: "/clients",
3536
4300
  surfaceType: "list",
3537
- icon: "feature.projects",
4301
+ icon: "projects",
3538
4302
  order: 20,
3539
4303
  targets: { systems: ["clients"] }
3540
4304
  },
@@ -3543,7 +4307,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
3543
4307
  label: "Projects",
3544
4308
  path: "/projects",
3545
4309
  surfaceType: "page",
3546
- icon: "feature.projects",
4310
+ icon: "projects",
3547
4311
  order: 30,
3548
4312
  targets: { systems: ["projects"] }
3549
4313
  }
@@ -3552,7 +4316,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
3552
4316
  operations: {
3553
4317
  type: "group",
3554
4318
  label: "Operations",
3555
- icon: "feature.operations",
4319
+ icon: "operations",
3556
4320
  order: 30,
3557
4321
  children: {
3558
4322
  "operations-overview": {
@@ -3600,7 +4364,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
3600
4364
  monitoring: {
3601
4365
  type: "group",
3602
4366
  label: "Monitoring",
3603
- icon: "feature.monitoring",
4367
+ icon: "monitoring",
3604
4368
  order: 40,
3605
4369
  children: {
3606
4370
  "monitoring-overview": {
@@ -3662,36 +4426,19 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
3662
4426
  }
3663
4427
  },
3664
4428
  knowledge: {
3665
- type: "group",
3666
- label: "Knowledge",
3667
- icon: "feature.knowledge",
3668
- order: 50,
3669
- children: {
3670
- "knowledge-base": {
3671
- type: "surface",
3672
- label: "Knowledge Base",
3673
- path: "/knowledge",
3674
- surfaceType: "page",
3675
- order: 10,
3676
- targets: { systems: ["knowledge.base"] }
3677
- },
3678
- "knowledge-command-view": {
3679
- type: "surface",
3680
- label: "Command View",
3681
- path: "/knowledge/command-view",
3682
- surfaceType: "graph",
3683
- order: 20,
3684
- targets: { systems: ["knowledge.command-view"] },
3685
- devOnly: true
3686
- }
3687
- }
4429
+ type: "surface",
4430
+ label: "Knowledge Base",
4431
+ path: "/knowledge",
4432
+ surfaceType: "page",
4433
+ icon: "knowledge",
4434
+ order: 50
3688
4435
  }
3689
4436
  },
3690
4437
  bottom: {
3691
4438
  settings: {
3692
4439
  type: "group",
3693
4440
  label: "Settings",
3694
- icon: "feature.settings",
4441
+ icon: "settings",
3695
4442
  order: 10,
3696
4443
  children: {
3697
4444
  "settings-account": {
@@ -3763,7 +4510,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
3763
4510
  admin: {
3764
4511
  type: "group",
3765
4512
  label: "Admin",
3766
- icon: "feature.admin",
4513
+ icon: "admin",
3767
4514
  order: 20,
3768
4515
  children: {
3769
4516
  "admin-dashboard": {
@@ -3843,7 +4590,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
3843
4590
  enabled: true,
3844
4591
  lifecycle: "active",
3845
4592
  path: "/",
3846
- icon: "feature.dashboard"
4593
+ icon: "dashboard"
3847
4594
  },
3848
4595
  platform: {
3849
4596
  id: "platform",
@@ -3853,7 +4600,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
3853
4600
  enabled: true,
3854
4601
  lifecycle: "active",
3855
4602
  color: "cyan",
3856
- icon: "feature.platform"
4603
+ icon: "platform"
3857
4604
  },
3858
4605
  finance: {
3859
4606
  id: "finance",
@@ -3863,7 +4610,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
3863
4610
  enabled: true,
3864
4611
  lifecycle: "active",
3865
4612
  color: "green",
3866
- icon: "feature.finance"
4613
+ icon: "finance"
3867
4614
  },
3868
4615
  sales: {
3869
4616
  id: "sales",
@@ -3873,7 +4620,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
3873
4620
  enabled: true,
3874
4621
  lifecycle: "active",
3875
4622
  color: "blue",
3876
- icon: "feature.sales",
4623
+ icon: "sales",
3877
4624
  path: "/sales"
3878
4625
  },
3879
4626
  "sales.crm": {
@@ -3883,8 +4630,12 @@ var DEFAULT_ORGANIZATION_MODEL = {
3883
4630
  description: "Relationship pipeline and deal management",
3884
4631
  enabled: true,
3885
4632
  lifecycle: "active",
4633
+ actions: Object.values(CRM_ACTION_ENTRIES).map((action) => ({
4634
+ actionId: action.id,
4635
+ intent: "exposes"
4636
+ })),
3886
4637
  color: "blue",
3887
- icon: "feature.crm",
4638
+ icon: "crm",
3888
4639
  path: "/crm"
3889
4640
  },
3890
4641
  "sales.lead-gen": {
@@ -3894,12 +4645,12 @@ var DEFAULT_ORGANIZATION_MODEL = {
3894
4645
  description: "Prospecting, qualification, and outreach preparation",
3895
4646
  enabled: true,
3896
4647
  lifecycle: "active",
3897
- actions: Object.values(DEFAULT_ORGANIZATION_MODEL_ACTIONS).map((action) => ({
4648
+ actions: Object.values(LEAD_GEN_ACTION_ENTRIES).map((action) => ({
3898
4649
  actionId: action.id,
3899
4650
  intent: "exposes"
3900
4651
  })),
3901
4652
  color: "cyan",
3902
- icon: "feature.lead-gen",
4653
+ icon: "lead-gen",
3903
4654
  path: "/lead-gen"
3904
4655
  },
3905
4656
  projects: {
@@ -3910,7 +4661,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
3910
4661
  enabled: true,
3911
4662
  lifecycle: "active",
3912
4663
  color: "orange",
3913
- icon: "feature.projects",
4664
+ icon: "projects",
3914
4665
  path: "/projects"
3915
4666
  },
3916
4667
  clients: {
@@ -3921,7 +4672,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
3921
4672
  enabled: true,
3922
4673
  lifecycle: "active",
3923
4674
  color: "orange",
3924
- icon: "feature.projects",
4675
+ icon: "projects",
3925
4676
  path: "/clients"
3926
4677
  },
3927
4678
  operations: {
@@ -3932,7 +4683,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
3932
4683
  enabled: true,
3933
4684
  lifecycle: "active",
3934
4685
  color: "violet",
3935
- icon: "feature.operations"
4686
+ icon: "operations"
3936
4687
  },
3937
4688
  "knowledge.command-view": {
3938
4689
  id: "knowledge.command-view",
@@ -3998,7 +4749,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
3998
4749
  enabled: true,
3999
4750
  lifecycle: "active",
4000
4751
  path: "/monitoring/calendar",
4001
- icon: "feature.calendar"
4752
+ icon: "calendar"
4002
4753
  },
4003
4754
  "monitoring.activity-log": {
4004
4755
  id: "monitoring.activity-log",
@@ -4054,7 +4805,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
4054
4805
  label: "Settings",
4055
4806
  enabled: true,
4056
4807
  lifecycle: "active",
4057
- icon: "feature.settings"
4808
+ icon: "settings"
4058
4809
  },
4059
4810
  "settings.account": {
4060
4811
  id: "settings.account",
@@ -4127,7 +4878,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
4127
4878
  enabled: true,
4128
4879
  lifecycle: "active",
4129
4880
  path: "/admin",
4130
- icon: "feature.admin",
4881
+ icon: "admin",
4131
4882
  requiresAdmin: true
4132
4883
  },
4133
4884
  "admin.system-health": {
@@ -4177,7 +4928,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
4177
4928
  enabled: true,
4178
4929
  lifecycle: "active",
4179
4930
  path: "/archive",
4180
- icon: "feature.archive",
4931
+ icon: "archive",
4181
4932
  devOnly: true
4182
4933
  },
4183
4934
  "archive.agent-chat": {
@@ -4212,7 +4963,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
4212
4963
  enabled: true,
4213
4964
  lifecycle: "active",
4214
4965
  color: "teal",
4215
- icon: "feature.knowledge"
4966
+ icon: "knowledge"
4216
4967
  },
4217
4968
  "knowledge.base": {
4218
4969
  id: "knowledge.base",
@@ -4223,11 +4974,13 @@ var DEFAULT_ORGANIZATION_MODEL = {
4223
4974
  path: "/knowledge"
4224
4975
  }
4225
4976
  },
4977
+ ontology: DEFAULT_ONTOLOGY_SCOPE,
4226
4978
  resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
4227
4979
  actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
4228
4980
  entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
4229
4981
  policies: DEFAULT_ORGANIZATION_MODEL_POLICIES,
4230
- // Phase 4 (D1): statuses top-level field removed; status data lives in system.content.
4982
+ // Phase 4 (D1): statuses top-level field removed; bridge status mirrors may
4983
+ // still project from System.content, but primary authoring belongs in ontology.
4231
4984
  knowledge: DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE
4232
4985
  };
4233
4986
 
@@ -4235,6 +4988,31 @@ var DEFAULT_ORGANIZATION_MODEL = {
4235
4988
  function isPlainObject(value) {
4236
4989
  return typeof value === "object" && value !== null && !Array.isArray(value);
4237
4990
  }
4991
+ function collectNestedSystemPaths(systems, prefix = "") {
4992
+ const paths = /* @__PURE__ */ new Set();
4993
+ for (const [key, value] of Object.entries(systems)) {
4994
+ if (!isPlainObject(value)) continue;
4995
+ const path = prefix ? `${prefix}.${key}` : key;
4996
+ for (const childKey of ["systems", "subsystems"]) {
4997
+ const childSystems = value[childKey];
4998
+ if (!isPlainObject(childSystems)) continue;
4999
+ for (const childPath of collectNestedSystemPaths(childSystems, path)) {
5000
+ paths.add(childPath);
5001
+ }
5002
+ }
5003
+ if (prefix !== "") {
5004
+ paths.add(path);
5005
+ }
5006
+ }
5007
+ return paths;
5008
+ }
5009
+ function pruneFlatSystemDescendantCollisions(base, override) {
5010
+ const result = { ...base };
5011
+ for (const nestedPath of collectNestedSystemPaths(override)) {
5012
+ delete result[nestedPath];
5013
+ }
5014
+ return result;
5015
+ }
4238
5016
  function deepMerge(base, override) {
4239
5017
  if (override === void 0) {
4240
5018
  return base;
@@ -4249,12 +5027,18 @@ function deepMerge(base, override) {
4249
5027
  for (const [key, value] of Object.entries(override)) {
4250
5028
  if (value === void 0) continue;
4251
5029
  const existing = result[key];
5030
+ if (key === "systems" && isPlainObject(existing) && isPlainObject(value)) {
5031
+ result[key] = deepMerge(pruneFlatSystemDescendantCollisions(existing, value), value);
5032
+ continue;
5033
+ }
4252
5034
  result[key] = isPlainObject(existing) && isPlainObject(value) ? deepMerge(existing, value) : value;
4253
5035
  }
4254
5036
  return result;
4255
5037
  }
4256
- function resolveOrganizationModel(override, organizationId) {
4257
- const merged = deepMerge(DEFAULT_ORGANIZATION_MODEL, override);
5038
+ function resolveOrganizationModel(override, organizationIdOrOptions, options) {
5039
+ const resolvedOptions = typeof organizationIdOrOptions === "object" ? organizationIdOrOptions : options;
5040
+ const mergeDefaults = resolvedOptions?.mergeDefaults ?? true;
5041
+ const merged = mergeDefaults ? deepMerge(DEFAULT_ORGANIZATION_MODEL, override) : override ?? {};
4258
5042
  return OrganizationModelSchema.parse(merged);
4259
5043
  }
4260
5044
 
@@ -4339,4 +5123,4 @@ function projectOrganizationSurfaces(model) {
4339
5123
  });
4340
5124
  }
4341
5125
 
4342
- export { ActionSchema, AgentResourceEntrySchema, CRM_DISCOVERY_BOOKING_CANCELLED_STATE, CRM_DISCOVERY_LINK_SENT_STATE, CRM_DISCOVERY_NUDGING_STATE, CRM_DISCOVERY_REPLIED_STATE, CRM_PIPELINE_DEFINITION, CRM_PRIORITY_BUCKETS, DEFAULT_CRM_PRIORITY_RULE_CONFIG, EntitySchema, IdentityDomainSchema, IntegrationResourceEntrySchema, LEAD_GEN_PIPELINE_DEFINITIONS, LEAD_GEN_STAGE_CATALOG, PROJECTS_VIEW_ACTION_ID, PROSPECTING_STEPS, PolicySchema, RoleSchema, SalesStageSchema, ScriptResourceEntrySchema, SurfaceDefinitionSchema, SystemEntrySchema, WorkflowResourceEntrySchema, ancestorsOf, buildOrganizationGraph, childrenOf, defaultPathFor, devOnlyFor, findById, findByPath, findPipeline, getContent, getResourcesForSystem, getSortedSidebarEntries, getSystem, getSystemAncestors, listAllSystems, lookupContentType, parentOf, projectOrganizationSurfaces, requiresAdminFor, resolveOrganizationModel, topLevel };
5126
+ export { ActionSchema, AgentResourceEntrySchema, CRM_DISCOVERY_BOOKING_CANCELLED_STATE, CRM_DISCOVERY_LINK_SENT_STATE, CRM_DISCOVERY_NUDGING_STATE, CRM_DISCOVERY_REPLIED_STATE, CRM_PIPELINE_DEFINITION, CRM_PRIORITY_BUCKETS, DEFAULT_CRM_PRIORITY_RULE_CONFIG, DEFAULT_ORGANIZATION_MODEL, EntitySchema, IdentityDomainSchema, IntegrationResourceEntrySchema, LEAD_GEN_PIPELINE_DEFINITIONS, LEAD_GEN_STAGE_CATALOG, OntologyIdSchema, PROJECTS_VIEW_ACTION_ID, PROSPECTING_STEPS, PolicySchema, RoleSchema, SalesStageSchema, ScriptResourceEntrySchema, SurfaceDefinitionSchema, SystemEntrySchema, WorkflowResourceEntrySchema, ancestorsOf, buildOrganizationGraph, childrenOf, compileOrganizationOntology, defaultPathFor, devOnlyFor, findById, findByPath, findPipeline, formatOntologyId, getContent, getResourcesForSystem, getSortedSidebarEntries, getSystem, getSystemAncestors, listAllSystems, lookupContentType, ontologyGraphNodeId, parentOf, parseOntologyId, projectOrganizationSurfaces, requiresAdminFor, resolveOrganizationModel, resolveSystemConfig, topLevel };