@elevasis/core 0.24.0 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/index.d.ts +3117 -2166
  2. package/dist/index.js +574 -16
  3. package/dist/knowledge/index.d.ts +122 -7
  4. package/dist/organization-model/index.d.ts +3117 -2166
  5. package/dist/organization-model/index.js +574 -16
  6. package/dist/test-utils/index.d.ts +135 -45
  7. package/dist/test-utils/index.js +122 -14
  8. package/package.json +3 -3
  9. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +139 -101
  10. package/src/execution/engine/llm/adapters/__tests__/openrouter.integration.test.ts +10 -10
  11. package/src/execution/engine/workflow/types.ts +5 -7
  12. package/src/knowledge/__tests__/queries.test.ts +960 -546
  13. package/src/knowledge/format.ts +322 -100
  14. package/src/knowledge/index.ts +18 -5
  15. package/src/knowledge/queries.ts +1004 -239
  16. package/src/organization-model/__tests__/deprecate-helpers.test.ts +71 -0
  17. package/src/organization-model/__tests__/domains/resources.test.ts +19 -8
  18. package/src/organization-model/__tests__/domains/topology.test.ts +188 -0
  19. package/src/organization-model/__tests__/graph.test.ts +98 -7
  20. package/src/organization-model/__tests__/resolve.test.ts +9 -7
  21. package/src/organization-model/__tests__/scaffolders.test.ts +93 -0
  22. package/src/organization-model/__tests__/schema.test.ts +14 -4
  23. package/src/organization-model/defaults.ts +5 -3
  24. package/src/organization-model/domains/resources.ts +63 -20
  25. package/src/organization-model/domains/topology.ts +261 -0
  26. package/src/organization-model/graph/build.ts +63 -15
  27. package/src/organization-model/graph/schema.ts +4 -3
  28. package/src/organization-model/graph/types.ts +5 -4
  29. package/src/organization-model/helpers.ts +76 -9
  30. package/src/organization-model/icons.ts +1 -0
  31. package/src/organization-model/index.ts +7 -5
  32. package/src/organization-model/ontology.ts +2 -5
  33. package/src/organization-model/organization-model.mdx +16 -11
  34. package/src/organization-model/published.ts +51 -15
  35. package/src/organization-model/scaffolders/helpers.ts +84 -0
  36. package/src/organization-model/scaffolders/index.ts +19 -0
  37. package/src/organization-model/scaffolders/scaffoldKnowledgeNode.ts +48 -0
  38. package/src/organization-model/scaffolders/scaffoldOntologyRecord.ts +38 -0
  39. package/src/organization-model/scaffolders/scaffoldResource.ts +59 -0
  40. package/src/organization-model/scaffolders/scaffoldSystem.ts +110 -0
  41. package/src/organization-model/scaffolders/types.ts +81 -0
  42. package/src/organization-model/schema.ts +51 -11
  43. package/src/organization-model/types.ts +25 -11
  44. package/src/platform/constants/versions.ts +1 -1
  45. package/src/platform/registry/__tests__/validation.test.ts +199 -14
  46. package/src/platform/registry/resource-registry.ts +11 -11
  47. package/src/platform/registry/validation.ts +226 -34
  48. package/src/reference/_generated/contracts.md +139 -101
  49. package/src/reference/glossary.md +74 -72
  50. package/src/supabase/database.types.ts +3156 -3153
@@ -1601,6 +1601,7 @@ type Database = {
1601
1601
  origin_execution_id: string | null;
1602
1602
  output: Json | null;
1603
1603
  resource_id: string;
1604
+ resource_snapshot: Json | null;
1604
1605
  resource_status: string;
1605
1606
  resource_type: string;
1606
1607
  resource_version: string | null;
@@ -1626,6 +1627,7 @@ type Database = {
1626
1627
  origin_execution_id?: string | null;
1627
1628
  output?: Json | null;
1628
1629
  resource_id: string;
1630
+ resource_snapshot?: Json | null;
1629
1631
  resource_status?: string;
1630
1632
  resource_type?: string;
1631
1633
  resource_version?: string | null;
@@ -1651,6 +1653,7 @@ type Database = {
1651
1653
  origin_execution_id?: string | null;
1652
1654
  output?: Json | null;
1653
1655
  resource_id?: string;
1656
+ resource_snapshot?: Json | null;
1654
1657
  resource_status?: string;
1655
1658
  resource_type?: string;
1656
1659
  resource_version?: string | null;
@@ -3668,41 +3671,6 @@ declare const OntologyScopeSchema: z.ZodDefault<z.ZodObject<{
3668
3671
  }, z.core.$strip>>;
3669
3672
  type OntologyScope = z.infer<typeof OntologyScopeSchema>;
3670
3673
 
3671
- declare const SurfaceTypeSchema: z.ZodEnum<{
3672
- dashboard: "dashboard";
3673
- settings: "settings";
3674
- graph: "graph";
3675
- list: "list";
3676
- page: "page";
3677
- detail: "detail";
3678
- }>;
3679
- interface SidebarSurfaceNode {
3680
- type: 'surface';
3681
- label: string;
3682
- path: string;
3683
- surfaceType: z.infer<typeof SurfaceTypeSchema>;
3684
- description?: string;
3685
- icon?: string;
3686
- order?: number;
3687
- targets?: {
3688
- systems?: string[];
3689
- entities?: string[];
3690
- resources?: string[];
3691
- actions?: string[];
3692
- };
3693
- devOnly?: boolean;
3694
- requiresAdmin?: boolean;
3695
- }
3696
- interface SidebarGroupNode {
3697
- type: 'group';
3698
- label: string;
3699
- description?: string;
3700
- icon?: string;
3701
- order?: number;
3702
- children: Record<string, SidebarNode>;
3703
- }
3704
- type SidebarNode = SidebarSurfaceNode | SidebarGroupNode;
3705
-
3706
3674
  /**
3707
3675
  * Placeholder discriminated union for ContentNode (Wave 1A).
3708
3676
  * Wave 2A wires concrete (kind, type) pairs via the registry.
@@ -3770,6 +3738,46 @@ interface SystemEntry {
3770
3738
  subsystems?: Record<string, SystemEntry>;
3771
3739
  }
3772
3740
 
3741
+ declare const SurfaceTypeSchema: z.ZodEnum<{
3742
+ dashboard: "dashboard";
3743
+ settings: "settings";
3744
+ graph: "graph";
3745
+ list: "list";
3746
+ page: "page";
3747
+ detail: "detail";
3748
+ }>;
3749
+ interface SidebarSurfaceNode {
3750
+ type: 'surface';
3751
+ label: string;
3752
+ path: string;
3753
+ surfaceType: z.infer<typeof SurfaceTypeSchema>;
3754
+ description?: string;
3755
+ icon?: string;
3756
+ order?: number;
3757
+ targets?: {
3758
+ systems?: string[];
3759
+ entities?: string[];
3760
+ resources?: string[];
3761
+ actions?: string[];
3762
+ };
3763
+ devOnly?: boolean;
3764
+ requiresAdmin?: boolean;
3765
+ }
3766
+ interface SidebarGroupNode {
3767
+ type: 'group';
3768
+ label: string;
3769
+ description?: string;
3770
+ icon?: string;
3771
+ order?: number;
3772
+ children: Record<string, SidebarNode>;
3773
+ }
3774
+ type SidebarNode = SidebarSurfaceNode | SidebarGroupNode;
3775
+
3776
+ type OrganizationModel = z.infer<typeof OrganizationModelSchema>;
3777
+ type DeepPartial<T> = T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? {
3778
+ [K in keyof T]?: DeepPartial<T[K]>;
3779
+ } : T;
3780
+
3773
3781
  declare const OrganizationModelSchema: z.ZodObject<{
3774
3782
  version: z.ZodDefault<z.ZodLiteral<1>>;
3775
3783
  domainMetadata: z.ZodPipe<z.ZodDefault<z.ZodObject<{
@@ -3809,6 +3817,10 @@ declare const OrganizationModelSchema: z.ZodObject<{
3809
3817
  version: z.ZodDefault<z.ZodLiteral<1>>;
3810
3818
  lastModified: z.ZodString;
3811
3819
  }, z.core.$strip>>;
3820
+ topology: z.ZodOptional<z.ZodObject<{
3821
+ version: z.ZodDefault<z.ZodLiteral<1>>;
3822
+ lastModified: z.ZodString;
3823
+ }, z.core.$strip>>;
3812
3824
  actions: z.ZodOptional<z.ZodObject<{
3813
3825
  version: z.ZodDefault<z.ZodLiteral<1>>;
3814
3826
  lastModified: z.ZodString;
@@ -3862,6 +3874,10 @@ declare const OrganizationModelSchema: z.ZodObject<{
3862
3874
  version: 1;
3863
3875
  lastModified: string;
3864
3876
  };
3877
+ topology: {
3878
+ version: 1;
3879
+ lastModified: string;
3880
+ };
3865
3881
  actions: {
3866
3882
  version: 1;
3867
3883
  lastModified: string;
@@ -3915,6 +3931,10 @@ declare const OrganizationModelSchema: z.ZodObject<{
3915
3931
  version: 1;
3916
3932
  lastModified: string;
3917
3933
  } | undefined;
3934
+ topology?: {
3935
+ version: 1;
3936
+ lastModified: string;
3937
+ } | undefined;
3918
3938
  actions?: {
3919
3939
  version: 1;
3920
3940
  lastModified: string;
@@ -4158,6 +4178,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4158
4178
  id: z.ZodString;
4159
4179
  order: z.ZodDefault<z.ZodNumber>;
4160
4180
  systemPath: z.ZodString;
4181
+ title: z.ZodOptional<z.ZodString>;
4182
+ description: z.ZodOptional<z.ZodString>;
4161
4183
  ownerRoleId: z.ZodOptional<z.ZodString>;
4162
4184
  status: z.ZodEnum<{
4163
4185
  deprecated: "deprecated";
@@ -4165,7 +4187,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4165
4187
  archived: "archived";
4166
4188
  }>;
4167
4189
  ontology: z.ZodOptional<z.ZodObject<{
4168
- implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
4190
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
4191
+ primaryAction: z.ZodOptional<z.ZodString>;
4169
4192
  reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
4170
4193
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
4171
4194
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -4185,7 +4208,6 @@ declare const OrganizationModelSchema: z.ZodObject<{
4185
4208
  description: z.ZodOptional<z.ZodString>;
4186
4209
  }, z.core.$strip>>>;
4187
4210
  kind: z.ZodLiteral<"workflow">;
4188
- actionKey: z.ZodOptional<z.ZodString>;
4189
4211
  emits: z.ZodOptional<z.ZodArray<z.ZodObject<{
4190
4212
  eventKey: z.ZodString;
4191
4213
  label: z.ZodString;
@@ -4202,6 +4224,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4202
4224
  id: z.ZodString;
4203
4225
  order: z.ZodDefault<z.ZodNumber>;
4204
4226
  systemPath: z.ZodString;
4227
+ title: z.ZodOptional<z.ZodString>;
4228
+ description: z.ZodOptional<z.ZodString>;
4205
4229
  ownerRoleId: z.ZodOptional<z.ZodString>;
4206
4230
  status: z.ZodEnum<{
4207
4231
  deprecated: "deprecated";
@@ -4209,7 +4233,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4209
4233
  archived: "archived";
4210
4234
  }>;
4211
4235
  ontology: z.ZodOptional<z.ZodObject<{
4212
- implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
4236
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
4237
+ primaryAction: z.ZodOptional<z.ZodString>;
4213
4238
  reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
4214
4239
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
4215
4240
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -4276,6 +4301,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4276
4301
  id: z.ZodString;
4277
4302
  order: z.ZodDefault<z.ZodNumber>;
4278
4303
  systemPath: z.ZodString;
4304
+ title: z.ZodOptional<z.ZodString>;
4305
+ description: z.ZodOptional<z.ZodString>;
4279
4306
  ownerRoleId: z.ZodOptional<z.ZodString>;
4280
4307
  status: z.ZodEnum<{
4281
4308
  deprecated: "deprecated";
@@ -4283,7 +4310,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4283
4310
  archived: "archived";
4284
4311
  }>;
4285
4312
  ontology: z.ZodOptional<z.ZodObject<{
4286
- implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
4313
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
4314
+ primaryAction: z.ZodOptional<z.ZodString>;
4287
4315
  reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
4288
4316
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
4289
4317
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -4308,6 +4336,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4308
4336
  id: z.ZodString;
4309
4337
  order: z.ZodDefault<z.ZodNumber>;
4310
4338
  systemPath: z.ZodString;
4339
+ title: z.ZodOptional<z.ZodString>;
4340
+ description: z.ZodOptional<z.ZodString>;
4311
4341
  ownerRoleId: z.ZodOptional<z.ZodString>;
4312
4342
  status: z.ZodEnum<{
4313
4343
  deprecated: "deprecated";
@@ -4315,7 +4345,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
4315
4345
  archived: "archived";
4316
4346
  }>;
4317
4347
  ontology: z.ZodOptional<z.ZodObject<{
4318
- implements: z.ZodOptional<z.ZodArray<z.ZodString>>;
4348
+ actions: z.ZodOptional<z.ZodArray<z.ZodString>>;
4349
+ primaryAction: z.ZodOptional<z.ZodString>;
4319
4350
  reads: z.ZodOptional<z.ZodArray<z.ZodString>>;
4320
4351
  writes: z.ZodOptional<z.ZodArray<z.ZodString>>;
4321
4352
  usesCatalogs: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -4345,6 +4376,69 @@ declare const OrganizationModelSchema: z.ZodObject<{
4345
4376
  file: z.ZodString;
4346
4377
  }, z.core.$strip>]>;
4347
4378
  }, z.core.$strip>], "kind">>>>;
4379
+ topology: z.ZodDefault<z.ZodDefault<z.ZodObject<{
4380
+ version: z.ZodDefault<z.ZodLiteral<1>>;
4381
+ relationships: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4382
+ from: z.ZodDiscriminatedUnion<[z.ZodObject<{
4383
+ kind: z.ZodLiteral<"system">;
4384
+ id: z.ZodString;
4385
+ }, z.core.$strip>, z.ZodObject<{
4386
+ kind: z.ZodLiteral<"resource">;
4387
+ id: z.ZodString;
4388
+ }, z.core.$strip>, z.ZodObject<{
4389
+ kind: z.ZodLiteral<"ontology">;
4390
+ id: z.ZodString;
4391
+ }, z.core.$strip>, z.ZodObject<{
4392
+ kind: z.ZodLiteral<"policy">;
4393
+ id: z.ZodString;
4394
+ }, z.core.$strip>, z.ZodObject<{
4395
+ kind: z.ZodLiteral<"role">;
4396
+ id: z.ZodString;
4397
+ }, z.core.$strip>, z.ZodObject<{
4398
+ kind: z.ZodLiteral<"trigger">;
4399
+ id: z.ZodString;
4400
+ }, z.core.$strip>, z.ZodObject<{
4401
+ kind: z.ZodLiteral<"humanCheckpoint">;
4402
+ id: z.ZodString;
4403
+ }, z.core.$strip>, z.ZodObject<{
4404
+ kind: z.ZodLiteral<"externalResource">;
4405
+ id: z.ZodString;
4406
+ }, z.core.$strip>], "kind">;
4407
+ kind: z.ZodEnum<{
4408
+ triggers: "triggers";
4409
+ uses: "uses";
4410
+ approval: "approval";
4411
+ }>;
4412
+ to: z.ZodDiscriminatedUnion<[z.ZodObject<{
4413
+ kind: z.ZodLiteral<"system">;
4414
+ id: z.ZodString;
4415
+ }, z.core.$strip>, z.ZodObject<{
4416
+ kind: z.ZodLiteral<"resource">;
4417
+ id: z.ZodString;
4418
+ }, z.core.$strip>, z.ZodObject<{
4419
+ kind: z.ZodLiteral<"ontology">;
4420
+ id: z.ZodString;
4421
+ }, z.core.$strip>, z.ZodObject<{
4422
+ kind: z.ZodLiteral<"policy">;
4423
+ id: z.ZodString;
4424
+ }, z.core.$strip>, z.ZodObject<{
4425
+ kind: z.ZodLiteral<"role">;
4426
+ id: z.ZodString;
4427
+ }, z.core.$strip>, z.ZodObject<{
4428
+ kind: z.ZodLiteral<"trigger">;
4429
+ id: z.ZodString;
4430
+ }, z.core.$strip>, z.ZodObject<{
4431
+ kind: z.ZodLiteral<"humanCheckpoint">;
4432
+ id: z.ZodString;
4433
+ }, z.core.$strip>, z.ZodObject<{
4434
+ kind: z.ZodLiteral<"externalResource">;
4435
+ id: z.ZodString;
4436
+ }, z.core.$strip>], "kind">;
4437
+ systemPath: z.ZodOptional<z.ZodString>;
4438
+ required: z.ZodOptional<z.ZodBoolean>;
4439
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>>>;
4440
+ }, z.core.$strip>>>;
4441
+ }, z.core.$strip>>>;
4348
4442
  actions: z.ZodDefault<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
4349
4443
  id: z.ZodString;
4350
4444
  order: z.ZodNumber;
@@ -4489,6 +4583,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
4489
4583
  crm: "crm";
4490
4584
  "lead-gen": "lead-gen";
4491
4585
  projects: "projects";
4586
+ clients: "clients";
4492
4587
  operations: "operations";
4493
4588
  monitoring: "monitoring";
4494
4589
  knowledge: "knowledge";
@@ -4579,11 +4674,6 @@ declare const OrganizationModelSchema: z.ZodObject<{
4579
4674
  }, z.core.$strip>>>>;
4580
4675
  }, z.core.$strip>;
4581
4676
 
4582
- type OrganizationModel = z.infer<typeof OrganizationModelSchema>;
4583
- type DeepPartial<T> = T extends Array<infer U> ? Array<DeepPartial<U>> : T extends object ? {
4584
- [K in keyof T]?: DeepPartial<T[K]>;
4585
- } : T;
4586
-
4587
4677
  interface TestInitializationError {
4588
4678
  layer: 'auth' | 'profile' | 'organization';
4589
4679
  message: string;
@@ -19685,7 +19685,6 @@ function addLegacyEntityProjections(index2, diagnostics, sourcesById, entities)
19685
19685
  table: entity.table
19686
19686
  }
19687
19687
  } : {},
19688
- legacyEntityId: entity.id,
19689
19688
  ...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
19690
19689
  ...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
19691
19690
  };
@@ -19710,8 +19709,7 @@ function addLegacyEntityProjections(index2, diagnostics, sourcesById, entities)
19710
19709
  from: legacyObjectId(entity),
19711
19710
  to: legacyObjectId(targetEntity),
19712
19711
  cardinality: link.kind,
19713
- ...link.via !== void 0 ? { via: link.via } : {},
19714
- legacyEntityId: entity.id
19712
+ ...link.via !== void 0 ? { via: link.via } : {}
19715
19713
  };
19716
19714
  addRecord(index2, diagnostics, sourcesById, "linkTypes", linkType, {
19717
19715
  source: "legacy.entities.links",
@@ -19769,8 +19767,7 @@ function addSystemContentProjections(index2, diagnostics, sourcesById, systemPat
19769
19767
  kind: node.type,
19770
19768
  ...typeof node.data?.["entityId"] === "string" ? { appliesTo: formatOntologyId({ scope: systemPath, kind: "object", localId: node.data["entityId"] }) } : {},
19771
19769
  ...Object.keys(entries).length > 0 ? { entries } : {},
19772
- ...node.data !== void 0 ? { data: node.data } : {},
19773
- legacyContentId: `${systemPath}:${localId}`
19770
+ ...node.data !== void 0 ? { data: node.data } : {}
19774
19771
  };
19775
19772
  addRecord(index2, diagnostics, sourcesById, "catalogTypes", catalogType, {
19776
19773
  source: "legacy.system.content",
@@ -19998,6 +19995,7 @@ var ORGANIZATION_MODEL_ICON_TOKENS = [
19998
19995
  "crm",
19999
19996
  "lead-gen",
20000
19997
  "projects",
19998
+ "clients",
20001
19999
  "operations",
20002
20000
  "monitoring",
20003
20001
  "knowledge",
@@ -20893,11 +20891,20 @@ EventEmissionDescriptorSchema.extend({
20893
20891
  ownerKind: z.enum(["resource", "entity"]).meta({ label: "Owner kind" })
20894
20892
  });
20895
20893
  var ResourceOntologyBindingSchema = z.object({
20896
- implements: z.array(OntologyIdSchema).optional(),
20894
+ actions: z.array(OntologyIdSchema).optional(),
20895
+ primaryAction: OntologyIdSchema.optional(),
20897
20896
  reads: z.array(OntologyIdSchema).optional(),
20898
20897
  writes: z.array(OntologyIdSchema).optional(),
20899
20898
  usesCatalogs: z.array(OntologyIdSchema).optional(),
20900
20899
  emits: z.array(OntologyIdSchema).optional()
20900
+ }).superRefine((binding, ctx) => {
20901
+ if (binding.primaryAction === void 0) return;
20902
+ if (binding.actions?.includes(binding.primaryAction)) return;
20903
+ ctx.addIssue({
20904
+ code: z.ZodIssueCode.custom,
20905
+ path: ["primaryAction"],
20906
+ message: "Resource ontology primaryAction must be included in actions"
20907
+ });
20901
20908
  });
20902
20909
  var CodeReferenceSchema = z.object({
20903
20910
  path: z.string().trim().min(1).max(500).regex(/^[A-Za-z0-9_./$@()[\] -]+$/, "Code reference paths must be repo-relative paths"),
@@ -20912,6 +20919,10 @@ var ResourceEntryBaseSchema = z.object({
20912
20919
  order: z.number().default(0),
20913
20920
  /** Required single System membership — value is a dot-separated system path (e.g. "sales.lead-gen"). */
20914
20921
  systemPath: SystemPathSchema.meta({ ref: "system" }),
20922
+ /** Executable display title owned by the OM Resource descriptor. */
20923
+ title: LabelSchema.optional(),
20924
+ /** Executable display description owned by the OM Resource descriptor. */
20925
+ description: DescriptionSchema.optional(),
20915
20926
  /** Optional role responsible for maintaining this resource. */
20916
20927
  ownerRoleId: ModelIdSchema.meta({ ref: "role" }).optional(),
20917
20928
  status: ResourceGovernanceStatusSchema,
@@ -20926,8 +20937,6 @@ var ResourceEntryBaseSchema = z.object({
20926
20937
  });
20927
20938
  var WorkflowResourceEntrySchema = ResourceEntryBaseSchema.extend({
20928
20939
  kind: z.literal("workflow"),
20929
- /** Mirrors WorkflowConfig.actionKey when the runtime workflow has one. */
20930
- actionKey: z.string().trim().min(1).max(255).optional(),
20931
20940
  emits: z.array(EventEmissionDescriptorSchema).optional()
20932
20941
  });
20933
20942
  var AgentResourceEntrySchema = ResourceEntryBaseSchema.extend({
@@ -21147,6 +21156,73 @@ var OrgKnowledgeNodeSchema = z.object({
21147
21156
  updatedAt: z.string().trim().min(1).max(50)
21148
21157
  });
21149
21158
  var KnowledgeDomainSchema = z.record(ModelIdSchema, OrgKnowledgeNodeSchema).default({});
21159
+ var SecretLikeMetadataKeySchema = /(?:secret|password|passwd|token|api[-_]?key|credential|private[-_]?key)/i;
21160
+ var SecretLikeMetadataValueSchema = /(?:sk-[A-Za-z0-9_-]{12,}|pk_live_[A-Za-z0-9_-]{12,}|eyJ[A-Za-z0-9_-]{20,}|-----BEGIN (?:RSA |OPENSSH |EC )?PRIVATE KEY-----)/;
21161
+ z.enum([
21162
+ "system",
21163
+ "resource",
21164
+ "ontology",
21165
+ "policy",
21166
+ "role",
21167
+ "trigger",
21168
+ "humanCheckpoint",
21169
+ "externalResource"
21170
+ ]);
21171
+ var OmTopologyRelationshipKindSchema = z.enum(["triggers", "uses", "approval"]);
21172
+ var OmTopologyNodeRefSchema = z.discriminatedUnion("kind", [
21173
+ z.object({ kind: z.literal("system"), id: ModelIdSchema }),
21174
+ z.object({ kind: z.literal("resource"), id: ResourceIdSchema }),
21175
+ z.object({ kind: z.literal("ontology"), id: OntologyIdSchema }),
21176
+ z.object({ kind: z.literal("policy"), id: ModelIdSchema }),
21177
+ z.object({ kind: z.literal("role"), id: ModelIdSchema }),
21178
+ z.object({ kind: z.literal("trigger"), id: ResourceIdSchema }),
21179
+ z.object({ kind: z.literal("humanCheckpoint"), id: ResourceIdSchema }),
21180
+ z.object({ kind: z.literal("externalResource"), id: ResourceIdSchema })
21181
+ ]);
21182
+ var OmTopologyMetadataSchema = z.record(z.string().trim().min(1).max(120), JsonValueSchema).superRefine((metadata, ctx) => {
21183
+ function visit(value, path) {
21184
+ if (typeof value === "string" && SecretLikeMetadataValueSchema.test(value)) {
21185
+ ctx.addIssue({
21186
+ code: z.ZodIssueCode.custom,
21187
+ path,
21188
+ message: "Topology metadata must not contain secret-like values"
21189
+ });
21190
+ return;
21191
+ }
21192
+ if (Array.isArray(value)) {
21193
+ value.forEach((entry, index2) => visit(entry, [...path, index2]));
21194
+ return;
21195
+ }
21196
+ if (typeof value !== "object" || value === null) return;
21197
+ Object.entries(value).forEach(([key, entry]) => {
21198
+ if (SecretLikeMetadataKeySchema.test(key)) {
21199
+ ctx.addIssue({
21200
+ code: z.ZodIssueCode.custom,
21201
+ path: [...path, key],
21202
+ message: `Topology metadata key "${key}" looks secret-like`
21203
+ });
21204
+ }
21205
+ visit(entry, [...path, key]);
21206
+ });
21207
+ }
21208
+ visit(metadata, []);
21209
+ });
21210
+ var OmTopologyRelationshipSchema = z.object({
21211
+ from: OmTopologyNodeRefSchema,
21212
+ kind: OmTopologyRelationshipKindSchema,
21213
+ to: OmTopologyNodeRefSchema,
21214
+ systemPath: SystemPathSchema.optional(),
21215
+ required: z.boolean().optional(),
21216
+ metadata: OmTopologyMetadataSchema.optional()
21217
+ });
21218
+ var OmTopologyDomainSchema = z.object({
21219
+ version: z.literal(1).default(1),
21220
+ relationships: z.record(z.string().trim().min(1).max(255), OmTopologyRelationshipSchema).default({})
21221
+ }).default({ version: 1, relationships: {} });
21222
+ var DEFAULT_ORGANIZATION_MODEL_TOPOLOGY = {
21223
+ version: 1,
21224
+ relationships: {}
21225
+ };
21150
21226
  var PolicyIdSchema = ModelIdSchema;
21151
21227
  var PolicyApplicabilitySchema = z.object({
21152
21228
  systemIds: z.array(ModelIdSchema.meta({ ref: "system" })).default([]),
@@ -21236,6 +21312,7 @@ z.enum([
21236
21312
  "systems",
21237
21313
  "ontology",
21238
21314
  "resources",
21315
+ "topology",
21239
21316
  "actions",
21240
21317
  "entities",
21241
21318
  "policies",
@@ -21255,6 +21332,7 @@ var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
21255
21332
  systems: { version: 1, lastModified: "2026-05-10" },
21256
21333
  ontology: { version: 1, lastModified: "2026-05-14" },
21257
21334
  resources: { version: 1, lastModified: "2026-05-10" },
21335
+ topology: { version: 1, lastModified: "2026-05-14" },
21258
21336
  actions: { version: 1, lastModified: "2026-05-10" },
21259
21337
  entities: { version: 1, lastModified: "2026-05-10" },
21260
21338
  policies: { version: 1, lastModified: "2026-05-10" },
@@ -21270,6 +21348,7 @@ var OrganizationModelDomainMetadataByDomainSchema = z.object({
21270
21348
  systems: OrganizationModelDomainMetadataSchema,
21271
21349
  ontology: OrganizationModelDomainMetadataSchema,
21272
21350
  resources: OrganizationModelDomainMetadataSchema,
21351
+ topology: OrganizationModelDomainMetadataSchema,
21273
21352
  actions: OrganizationModelDomainMetadataSchema,
21274
21353
  entities: OrganizationModelDomainMetadataSchema,
21275
21354
  policies: OrganizationModelDomainMetadataSchema,
@@ -21288,6 +21367,7 @@ var OrganizationModelSchemaBase = z.object({
21288
21367
  systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
21289
21368
  ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
21290
21369
  resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
21370
+ topology: OmTopologyDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_TOPOLOGY),
21291
21371
  actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
21292
21372
  entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
21293
21373
  policies: PoliciesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_POLICIES),
@@ -21630,6 +21710,25 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
21630
21710
  surface: ontologyCompilation.ontology.surfaces
21631
21711
  };
21632
21712
  const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index2) => Object.keys(index2)));
21713
+ function topologyTargetExists(ref) {
21714
+ if (ref.kind === "system") return systemsById.has(ref.id);
21715
+ if (ref.kind === "resource") return resourcesById.has(ref.id);
21716
+ if (ref.kind === "ontology") return ontologyIds.has(ref.id);
21717
+ if (ref.kind === "policy") return policiesById.has(ref.id);
21718
+ if (ref.kind === "role") return rolesById.has(ref.id);
21719
+ return true;
21720
+ }
21721
+ Object.entries(model.topology.relationships).forEach(([relationshipId, relationship]) => {
21722
+ ["from", "to"].forEach((side) => {
21723
+ const ref = relationship[side];
21724
+ if (topologyTargetExists(ref)) return;
21725
+ addIssue(
21726
+ ctx,
21727
+ ["topology", "relationships", relationshipId, side],
21728
+ `Topology relationship "${relationshipId}" ${side} references unknown ${ref.kind} "${ref.id}"`
21729
+ );
21730
+ });
21731
+ });
21633
21732
  const ontologyReferenceKeyKinds = {
21634
21733
  valueType: "value-type",
21635
21734
  catalogType: "catalog",
@@ -21768,11 +21867,18 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
21768
21867
  }
21769
21868
  });
21770
21869
  function validateResourceOntologyBinding(resourceId, bindingKey, expectedKind, ids) {
21771
- ids?.forEach((ontologyId, ontologyIndex) => {
21870
+ const ontologyIds2 = ids === void 0 ? [] : Array.isArray(ids) ? ids : [ids];
21871
+ ontologyIds2.forEach((ontologyId, ontologyIndex) => {
21772
21872
  if (ontologyIndexByKind[expectedKind][ontologyId] === void 0) {
21773
21873
  addIssue(
21774
21874
  ctx,
21775
- ["resources", resourceId, "ontology", bindingKey, ontologyIndex],
21875
+ [
21876
+ "resources",
21877
+ resourceId,
21878
+ "ontology",
21879
+ bindingKey,
21880
+ ...Array.isArray(ids) ? [ontologyIndex] : []
21881
+ ],
21776
21882
  `Resource "${resourceId}" ontology binding "${bindingKey}" references unknown ${expectedKind} ontology ID "${ontologyId}"`
21777
21883
  );
21778
21884
  }
@@ -21781,7 +21887,8 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
21781
21887
  Object.values(model.resources).forEach((resource) => {
21782
21888
  const binding = resource.ontology;
21783
21889
  if (binding === void 0) return;
21784
- validateResourceOntologyBinding(resource.id, "implements", "action", binding.implements);
21890
+ validateResourceOntologyBinding(resource.id, "actions", "action", binding.actions);
21891
+ validateResourceOntologyBinding(resource.id, "primaryAction", "action", binding.primaryAction);
21785
21892
  validateResourceOntologyBinding(resource.id, "reads", "object", binding.reads);
21786
21893
  validateResourceOntologyBinding(resource.id, "writes", "object", binding.writes);
21787
21894
  validateResourceOntologyBinding(resource.id, "usesCatalogs", "catalog", binding.usesCatalogs);
@@ -21915,7 +22022,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
21915
22022
  business: {
21916
22023
  type: "group",
21917
22024
  label: "Business",
21918
- icon: "business",
22025
+ icon: "briefcase",
21919
22026
  order: 20,
21920
22027
  children: {
21921
22028
  sales: {
@@ -21932,7 +22039,7 @@ var DEFAULT_ORGANIZATION_MODEL_NAVIGATION = {
21932
22039
  label: "Clients",
21933
22040
  path: "/clients",
21934
22041
  surfaceType: "list",
21935
- icon: "projects",
22042
+ icon: "clients",
21936
22043
  order: 20,
21937
22044
  targets: { systems: ["clients"] }
21938
22045
  },
@@ -22306,7 +22413,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
22306
22413
  enabled: true,
22307
22414
  lifecycle: "active",
22308
22415
  color: "orange",
22309
- icon: "projects",
22416
+ icon: "clients",
22310
22417
  path: "/clients"
22311
22418
  },
22312
22419
  operations: {
@@ -22610,6 +22717,7 @@ var DEFAULT_ORGANIZATION_MODEL = {
22610
22717
  },
22611
22718
  ontology: DEFAULT_ONTOLOGY_SCOPE,
22612
22719
  resources: DEFAULT_ORGANIZATION_MODEL_RESOURCES,
22720
+ topology: DEFAULT_ORGANIZATION_MODEL_TOPOLOGY,
22613
22721
  actions: DEFAULT_ORGANIZATION_MODEL_ACTIONS,
22614
22722
  entities: DEFAULT_ORGANIZATION_MODEL_ENTITIES2,
22615
22723
  policies: DEFAULT_ORGANIZATION_MODEL_POLICIES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elevasis/core",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "license": "MIT",
5
5
  "description": "Minimal shared constants across Elevasis monorepo",
6
6
  "sideEffects": false,
@@ -41,8 +41,8 @@
41
41
  "rollup-plugin-dts": "^6.3.0",
42
42
  "tsup": "^8.0.0",
43
43
  "typescript": "5.9.2",
44
- "@repo/typescript-config": "0.0.0",
45
- "@repo/eslint-config": "0.0.0"
44
+ "@repo/eslint-config": "0.0.0",
45
+ "@repo/typescript-config": "0.0.0"
46
46
  },
47
47
  "dependencies": {
48
48
  "@anthropic-ai/sdk": "^0.62.0",