@elevasis/core 0.24.1 → 0.26.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/index.d.ts +239 -86
  2. package/dist/index.js +474 -1346
  3. package/dist/knowledge/index.d.ts +57 -39
  4. package/dist/knowledge/index.js +1 -1
  5. package/dist/organization-model/index.d.ts +239 -86
  6. package/dist/organization-model/index.js +474 -1346
  7. package/dist/test-utils/index.d.ts +24 -31
  8. package/dist/test-utils/index.js +76 -1238
  9. package/package.json +1 -1
  10. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +108 -96
  11. package/src/business/acquisition/api-schemas.test.ts +70 -77
  12. package/src/business/acquisition/api-schemas.ts +21 -42
  13. package/src/business/acquisition/derive-actions.test.ts +11 -21
  14. package/src/business/acquisition/derive-actions.ts +61 -14
  15. package/src/business/acquisition/ontology-validation.ts +4 -4
  16. package/src/business/acquisition/types.ts +7 -8
  17. package/src/execution/engine/llm/adapters/__tests__/openrouter.integration.test.ts +10 -10
  18. package/src/knowledge/__tests__/queries.test.ts +960 -546
  19. package/src/knowledge/format.ts +322 -100
  20. package/src/knowledge/index.ts +18 -5
  21. package/src/knowledge/queries.ts +1004 -240
  22. package/src/organization-model/__tests__/content-kinds-registry.test.ts +35 -210
  23. package/src/organization-model/__tests__/defaults.test.ts +4 -4
  24. package/src/organization-model/__tests__/deprecate-helpers.test.ts +71 -0
  25. package/src/organization-model/__tests__/domains/actions.test.ts +12 -36
  26. package/src/organization-model/__tests__/domains/offerings.test.ts +13 -6
  27. package/src/organization-model/__tests__/domains/resources.test.ts +497 -350
  28. package/src/organization-model/__tests__/domains/systems.test.ts +6 -7
  29. package/src/organization-model/__tests__/flatten-additive-merge.test.ts +68 -80
  30. package/src/organization-model/__tests__/foundation.test.ts +81 -14
  31. package/src/organization-model/__tests__/graph.test.ts +662 -694
  32. package/src/organization-model/__tests__/knowledge.test.ts +31 -17
  33. package/src/organization-model/__tests__/lookup-helpers.test.ts +128 -438
  34. package/src/organization-model/__tests__/migration-helpers.test.ts +362 -591
  35. package/src/organization-model/__tests__/prospecting-ssot.test.ts +68 -103
  36. package/src/organization-model/__tests__/published-zero-leak.test.ts +17 -0
  37. package/src/organization-model/__tests__/recursive-system-schema.test.ts +159 -532
  38. package/src/organization-model/__tests__/resolve.test.ts +88 -49
  39. package/src/organization-model/__tests__/scaffolders.test.ts +93 -0
  40. package/src/organization-model/__tests__/schema.test.ts +65 -56
  41. package/src/organization-model/catalogs/lead-gen.ts +0 -103
  42. package/src/organization-model/defaults.ts +17 -702
  43. package/src/organization-model/domains/actions.ts +116 -333
  44. package/src/organization-model/domains/knowledge.ts +15 -7
  45. package/src/organization-model/domains/projects.ts +4 -4
  46. package/src/organization-model/domains/prospecting.ts +405 -395
  47. package/src/organization-model/domains/resources.ts +206 -135
  48. package/src/organization-model/domains/sales.ts +5 -5
  49. package/src/organization-model/domains/systems.ts +8 -23
  50. package/src/organization-model/graph/build.ts +223 -294
  51. package/src/organization-model/graph/schema.ts +2 -3
  52. package/src/organization-model/graph/types.ts +12 -14
  53. package/src/organization-model/helpers.ts +120 -141
  54. package/src/organization-model/icons.ts +1 -0
  55. package/src/organization-model/index.ts +107 -126
  56. package/src/organization-model/migration-helpers.ts +211 -249
  57. package/src/organization-model/ontology.ts +0 -60
  58. package/src/organization-model/organization-graph.mdx +4 -5
  59. package/src/organization-model/organization-model.mdx +1 -1
  60. package/src/organization-model/published.ts +251 -228
  61. package/src/organization-model/resolve.ts +4 -5
  62. package/src/organization-model/scaffolders/helpers.ts +84 -0
  63. package/src/organization-model/scaffolders/index.ts +19 -0
  64. package/src/organization-model/scaffolders/scaffoldKnowledgeNode.ts +48 -0
  65. package/src/organization-model/scaffolders/scaffoldOntologyRecord.ts +38 -0
  66. package/src/organization-model/scaffolders/scaffoldResource.ts +59 -0
  67. package/src/organization-model/scaffolders/scaffoldSystem.ts +110 -0
  68. package/src/organization-model/scaffolders/types.ts +81 -0
  69. package/src/organization-model/schema.ts +610 -704
  70. package/src/organization-model/types.ts +167 -161
  71. package/src/platform/constants/versions.ts +1 -1
  72. package/src/platform/registry/__tests__/validation.test.ts +23 -0
  73. package/src/platform/registry/validation.ts +13 -2
  74. package/src/reference/_generated/contracts.md +108 -96
  75. package/src/reference/glossary.md +71 -69
  76. package/src/organization-model/content-kinds/config.ts +0 -36
  77. package/src/organization-model/content-kinds/index.ts +0 -78
  78. package/src/organization-model/content-kinds/pipeline.ts +0 -68
  79. package/src/organization-model/content-kinds/registry.ts +0 -44
  80. package/src/organization-model/content-kinds/status.ts +0 -71
  81. package/src/organization-model/content-kinds/template.ts +0 -83
  82. package/src/organization-model/content-kinds/types.ts +0 -117
@@ -94,24 +94,6 @@ declare const OntologyScopeSchema: z.ZodDefault<z.ZodObject<{
94
94
  }, z.core.$strip>>;
95
95
  type OntologyScope = z.infer<typeof OntologyScopeSchema>;
96
96
 
97
- /**
98
- * Placeholder discriminated union for ContentNode (Wave 1A).
99
- * Wave 2A wires concrete (kind, type) pairs via the registry.
100
- *
101
- * Per D2: unregistered (kind, type) pairs are allowed and pass through validation.
102
- * Per L14: every node carries BOTH `kind` and `type`.
103
- */
104
- declare const ContentNodeSchema: z.ZodObject<{
105
- label: z.ZodString;
106
- description: z.ZodOptional<z.ZodString>;
107
- order: z.ZodOptional<z.ZodNumber>;
108
- parentContentId: z.ZodOptional<z.ZodString>;
109
- kind: z.ZodString;
110
- type: z.ZodString;
111
- data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
112
- }, z.core.$strip>;
113
- type ContentNode = z.infer<typeof ContentNodeSchema>;
114
-
115
97
  type JsonPrimitive = string | number | boolean | null;
116
98
  type JsonValue = JsonPrimitive | JsonValue[] | {
117
99
  [key: string]: JsonValue;
@@ -153,11 +135,6 @@ interface SystemEntry {
153
135
  config?: Record<string, JsonValue>;
154
136
  ontology?: OntologyScope;
155
137
  systems?: Record<string, SystemEntry>;
156
- /**
157
- * @deprecated Compatibility-only bridge for old tenant data and migration readers.
158
- * Author new semantic catalogs in `ontology` and local settings in `config`.
159
- */
160
- content?: Record<string, ContentNode>;
161
138
  subsystems?: Record<string, SystemEntry>;
162
139
  }
163
140
 
@@ -241,6 +218,7 @@ declare const OrgKnowledgeNodeSchema: z.ZodObject<{
241
218
  crm: "crm";
242
219
  "lead-gen": "lead-gen";
243
220
  projects: "projects";
221
+ clients: "clients";
244
222
  operations: "operations";
245
223
  monitoring: "monitoring";
246
224
  knowledge: "knowledge";
@@ -302,11 +280,10 @@ declare const OrgKnowledgeNodeSchema: z.ZodObject<{
302
280
  ontology: "ontology";
303
281
  role: "role";
304
282
  goal: "goal";
305
- stage: "stage";
306
283
  resource: "resource";
284
+ stage: "stage";
307
285
  "customer-segment": "customer-segment";
308
286
  offering: "offering";
309
- "content-node": "content-node";
310
287
  }>;
311
288
  id: z.ZodString;
312
289
  }, z.core.$strip>;
@@ -314,7 +291,7 @@ declare const OrgKnowledgeNodeSchema: z.ZodObject<{
314
291
  nodeId: z.ZodUnion<readonly [z.ZodString, z.ZodTemplateLiteral<`ontology:${string}`>]>;
315
292
  }, z.core.$strip>]>, z.ZodTransform<{
316
293
  target: {
317
- kind: "knowledge" | "system" | "action" | "ontology" | "role" | "goal" | "stage" | "resource" | "customer-segment" | "offering" | "content-node";
294
+ kind: "knowledge" | "system" | "action" | "ontology" | "role" | "goal" | "resource" | "stage" | "customer-segment" | "offering";
318
295
  id: string;
319
296
  };
320
297
  nodeId: string;
@@ -322,7 +299,7 @@ declare const OrgKnowledgeNodeSchema: z.ZodObject<{
322
299
  nodeId: string;
323
300
  } | {
324
301
  target: {
325
- kind: "knowledge" | "system" | "action" | "ontology" | "role" | "goal" | "stage" | "resource" | "customer-segment" | "offering" | "content-node";
302
+ kind: "knowledge" | "system" | "action" | "ontology" | "role" | "goal" | "resource" | "stage" | "customer-segment" | "offering";
326
303
  id: string;
327
304
  };
328
305
  }>>>>;
@@ -344,6 +321,7 @@ declare const OrganizationModelIconTokenSchema: z.ZodUnion<readonly [z.ZodEnum<{
344
321
  crm: "crm";
345
322
  "lead-gen": "lead-gen";
346
323
  projects: "projects";
324
+ clients: "clients";
347
325
  operations: "operations";
348
326
  monitoring: "monitoring";
349
327
  knowledge: "knowledge";
@@ -810,14 +788,18 @@ declare const OrganizationModelSchema: z.ZodObject<{
810
788
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
811
789
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
812
790
  emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
791
+ contract: z.ZodOptional<z.ZodObject<{
792
+ input: z.ZodOptional<z.ZodString>;
793
+ output: z.ZodOptional<z.ZodString>;
794
+ }, z.core.$strip>>;
813
795
  }, z.core.$strip>>;
814
796
  codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
815
797
  path: z.ZodString;
816
798
  role: z.ZodEnum<{
817
- schema: "schema";
818
799
  config: "config";
819
800
  entrypoint: "entrypoint";
820
801
  handler: "handler";
802
+ schema: "schema";
821
803
  test: "test";
822
804
  docs: "docs";
823
805
  }>;
@@ -856,14 +838,18 @@ declare const OrganizationModelSchema: z.ZodObject<{
856
838
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
857
839
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
858
840
  emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
841
+ contract: z.ZodOptional<z.ZodObject<{
842
+ input: z.ZodOptional<z.ZodString>;
843
+ output: z.ZodOptional<z.ZodString>;
844
+ }, z.core.$strip>>;
859
845
  }, z.core.$strip>>;
860
846
  codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
861
847
  path: z.ZodString;
862
848
  role: z.ZodEnum<{
863
- schema: "schema";
864
849
  config: "config";
865
850
  entrypoint: "entrypoint";
866
851
  handler: "handler";
852
+ schema: "schema";
867
853
  test: "test";
868
854
  docs: "docs";
869
855
  }>;
@@ -933,14 +919,18 @@ declare const OrganizationModelSchema: z.ZodObject<{
933
919
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
934
920
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
935
921
  emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
922
+ contract: z.ZodOptional<z.ZodObject<{
923
+ input: z.ZodOptional<z.ZodString>;
924
+ output: z.ZodOptional<z.ZodString>;
925
+ }, z.core.$strip>>;
936
926
  }, z.core.$strip>>;
937
927
  codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
938
928
  path: z.ZodString;
939
929
  role: z.ZodEnum<{
940
- schema: "schema";
941
930
  config: "config";
942
931
  entrypoint: "entrypoint";
943
932
  handler: "handler";
933
+ schema: "schema";
944
934
  test: "test";
945
935
  docs: "docs";
946
936
  }>;
@@ -968,14 +958,18 @@ declare const OrganizationModelSchema: z.ZodObject<{
968
958
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
969
959
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
970
960
  emits: z.ZodOptional<z.ZodArray<z.ZodString>>;
961
+ contract: z.ZodOptional<z.ZodObject<{
962
+ input: z.ZodOptional<z.ZodString>;
963
+ output: z.ZodOptional<z.ZodString>;
964
+ }, z.core.$strip>>;
971
965
  }, z.core.$strip>>;
972
966
  codeRefs: z.ZodDefault<z.ZodArray<z.ZodObject<{
973
967
  path: z.ZodString;
974
968
  role: z.ZodEnum<{
975
- schema: "schema";
976
969
  config: "config";
977
970
  entrypoint: "entrypoint";
978
971
  handler: "handler";
972
+ schema: "schema";
979
973
  test: "test";
980
974
  docs: "docs";
981
975
  }>;
@@ -1200,6 +1194,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
1200
1194
  crm: "crm";
1201
1195
  "lead-gen": "lead-gen";
1202
1196
  projects: "projects";
1197
+ clients: "clients";
1203
1198
  operations: "operations";
1204
1199
  monitoring: "monitoring";
1205
1200
  knowledge: "knowledge";
@@ -1261,11 +1256,10 @@ declare const OrganizationModelSchema: z.ZodObject<{
1261
1256
  ontology: "ontology";
1262
1257
  role: "role";
1263
1258
  goal: "goal";
1264
- stage: "stage";
1265
1259
  resource: "resource";
1260
+ stage: "stage";
1266
1261
  "customer-segment": "customer-segment";
1267
1262
  offering: "offering";
1268
- "content-node": "content-node";
1269
1263
  }>;
1270
1264
  id: z.ZodString;
1271
1265
  }, z.core.$strip>;
@@ -1273,7 +1267,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
1273
1267
  nodeId: z.ZodUnion<readonly [z.ZodString, z.ZodTemplateLiteral<`ontology:${string}`>]>;
1274
1268
  }, z.core.$strip>]>, z.ZodTransform<{
1275
1269
  target: {
1276
- kind: "knowledge" | "system" | "action" | "ontology" | "role" | "goal" | "stage" | "resource" | "customer-segment" | "offering" | "content-node";
1270
+ kind: "knowledge" | "system" | "action" | "ontology" | "role" | "goal" | "resource" | "stage" | "customer-segment" | "offering";
1277
1271
  id: string;
1278
1272
  };
1279
1273
  nodeId: string;
@@ -1281,7 +1275,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
1281
1275
  nodeId: string;
1282
1276
  } | {
1283
1277
  target: {
1284
- kind: "knowledge" | "system" | "action" | "ontology" | "role" | "goal" | "stage" | "resource" | "customer-segment" | "offering" | "content-node";
1278
+ kind: "knowledge" | "system" | "action" | "ontology" | "role" | "goal" | "resource" | "stage" | "customer-segment" | "offering";
1285
1279
  id: string;
1286
1280
  };
1287
1281
  }>>>>;
@@ -1292,9 +1286,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
1292
1286
 
1293
1287
  type OrganizationModel = z.infer<typeof OrganizationModelSchema>;
1294
1288
 
1295
- type OrganizationGraphNodeKind = 'organization' | 'system' | 'role' | 'action' | 'entity' | 'event' | 'policy' | 'stage' | 'resource' | 'knowledge' | 'customer-segment' | 'offering' | 'goal' | 'surface' | 'navigation-group'
1296
- /** Phase 3 preview — Phase 4 populates this kind via graph projection of system.content entries. */
1297
- | 'ontology' | 'content-node';
1289
+ type OrganizationGraphNodeKind = 'organization' | 'system' | 'role' | 'action' | 'entity' | 'event' | 'policy' | 'stage' | 'resource' | 'knowledge' | 'customer-segment' | 'offering' | 'goal' | 'surface' | 'navigation-group' | 'ontology';
1298
1290
  type OrganizationGraphEdgeKind = 'contains' | 'references' | 'maps_to' | 'uses' | 'governs' | 'links' | 'affects' | 'emits' | 'originates_from' | 'triggers' | 'approval' | 'applies_to' | 'effects' | 'actions' | 'reads' | 'writes' | 'uses_catalog';
1299
1291
 
1300
1292
  interface OrganizationGraphNode {
@@ -1406,6 +1398,32 @@ interface ParsedKnowledgePath {
1406
1398
  * match any supported mount pattern.
1407
1399
  */
1408
1400
  declare function parsePath(pathString: string): ParsedKnowledgePath;
1401
+ /**
1402
+ * The kind of OM node that produced a search hit.
1403
+ *
1404
+ * Maps to the surface being searched:
1405
+ * - `system` — recursive systems tree (model.systems)
1406
+ * - `resource` — model.resources (workflows, agents, integrations, scripts)
1407
+ * - `knowledge` — model.knowledge (playbooks, strategies, references)
1408
+ * - `ontology` — system.ontology and model.ontology (objects, actions, events, catalogs, links, ...)
1409
+ * - `role` — model.roles
1410
+ * - `policy` — model.policies
1411
+ */
1412
+ type OmSearchHitKind = 'system' | 'resource' | 'knowledge' | 'ontology' | 'role' | 'policy';
1413
+ interface OmSearchHit {
1414
+ /** Surface that produced the hit. */
1415
+ kind: OmSearchHitKind;
1416
+ /** Canonical id (system path, resource id, knowledge id, ontology id, role id, policy id). */
1417
+ id: string;
1418
+ /** Display title (label/title/summary fallback). */
1419
+ title: string;
1420
+ /** One-line description or summary (may be empty). */
1421
+ summary: string;
1422
+ /** Ranking score; higher is better. */
1423
+ score: number;
1424
+ /** Optional sub-kind for ontology / resource (`object`, `action`, `event`, `workflow`, ...). */
1425
+ subKind?: string;
1426
+ }
1409
1427
 
1410
1428
  /**
1411
1429
  * Renders a list of `OrgKnowledgeNode` results as a human-friendly text table.
@@ -1457,7 +1475,7 @@ declare function formatJson(input: {
1457
1475
  *
1458
1476
  * Returns an empty string when the array is empty (suitable for `wc -l` piping).
1459
1477
  */
1460
- declare function formatIdsOnly(results: OrgKnowledgeNode[] | string[]): string;
1478
+ declare function formatIdsOnly(results: OrgKnowledgeNode[] | string[] | OmSearchHit[]): string;
1461
1479
 
1462
1480
  export { byKind, byOwner, bySystem, formatIdsOnly, formatJson, formatText, governedBy, governs, parsePath };
1463
1481
  export type { KnowledgeJsonEnvelope, KnowledgeMount, ParsedKnowledgePath };
@@ -90,7 +90,7 @@ function toGraphNodeId(omNodeId) {
90
90
  return `knowledge:${omNodeId}`;
91
91
  }
92
92
  function toTargetGraphNodeId(nodeId) {
93
- if (nodeId.startsWith("system:") || nodeId.startsWith("knowledge:") || nodeId.startsWith("resource:") || nodeId.startsWith("content-node:") || nodeId.startsWith("ontology:")) {
93
+ if (nodeId.startsWith("system:") || nodeId.startsWith("knowledge:") || nodeId.startsWith("resource:") || nodeId.startsWith("ontology:")) {
94
94
  return nodeId;
95
95
  }
96
96
  const ontologyId = OntologyIdSchema.safeParse(nodeId);