@elevasis/core 0.26.0 → 0.27.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 (34) hide show
  1. package/dist/index.d.ts +5 -5
  2. package/dist/index.js +209 -173
  3. package/dist/knowledge/index.d.ts +21 -21
  4. package/dist/organization-model/index.d.ts +5 -5
  5. package/dist/organization-model/index.js +209 -173
  6. package/dist/test-utils/index.d.ts +2 -2
  7. package/dist/test-utils/index.js +182 -126
  8. package/package.json +1 -1
  9. package/src/_gen/__tests__/__snapshots__/contracts.md.snap +976 -1063
  10. package/src/business/acquisition/api-schemas.test.ts +1962 -1841
  11. package/src/business/acquisition/api-schemas.ts +1461 -1464
  12. package/src/business/acquisition/crm-next-action.test.ts +45 -25
  13. package/src/business/acquisition/crm-next-action.ts +227 -220
  14. package/src/business/acquisition/crm-priority.test.ts +41 -8
  15. package/src/business/acquisition/crm-priority.ts +365 -349
  16. package/src/business/acquisition/crm-state-actions.test.ts +208 -153
  17. package/src/business/acquisition/derive-actions.test.ts +90 -13
  18. package/src/business/acquisition/derive-actions.ts +8 -139
  19. package/src/business/acquisition/ontology-validation.ts +72 -158
  20. package/src/business/pdf/sections/investment.ts +1 -1
  21. package/src/business/pdf/sections/summary-investment.ts +1 -1
  22. package/src/execution/engine/tools/tool-maps.ts +872 -831
  23. package/src/organization-model/__tests__/cross-ref.test.ts +167 -0
  24. package/src/organization-model/__tests__/published-zero-leak.test.ts +60 -1
  25. package/src/organization-model/__tests__/resolve.test.ts +1 -1
  26. package/src/organization-model/__tests__/schema-refinements.test.ts +72 -0
  27. package/src/organization-model/cross-ref.ts +175 -0
  28. package/src/organization-model/domains/branding.ts +6 -6
  29. package/src/organization-model/domains/sales.test.ts +104 -218
  30. package/src/organization-model/domains/sales.ts +212 -375
  31. package/src/organization-model/index.ts +1 -0
  32. package/src/organization-model/schema-refinements.ts +667 -0
  33. package/src/organization-model/schema.ts +8 -715
  34. package/src/reference/_generated/contracts.md +976 -1063
package/dist/index.d.ts CHANGED
@@ -875,8 +875,8 @@ declare const StatusSemanticClassSchema: z.ZodEnum<{
875
875
  "delivery.milestone": "delivery.milestone";
876
876
  "delivery.task": "delivery.task";
877
877
  schedule: "schedule";
878
- execution: "execution";
879
878
  queue: "queue";
879
+ execution: "execution";
880
880
  "schedule.run": "schedule.run";
881
881
  request: "request";
882
882
  }>;
@@ -889,8 +889,8 @@ declare const StatusEntrySchema: z.ZodObject<{
889
889
  "delivery.milestone": "delivery.milestone";
890
890
  "delivery.task": "delivery.task";
891
891
  schedule: "schedule";
892
- execution: "execution";
893
892
  queue: "queue";
893
+ execution: "execution";
894
894
  "schedule.run": "schedule.run";
895
895
  request: "request";
896
896
  }>;
@@ -905,8 +905,8 @@ declare const StatusesDomainSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodO
905
905
  "delivery.milestone": "delivery.milestone";
906
906
  "delivery.task": "delivery.task";
907
907
  schedule: "schedule";
908
- execution: "execution";
909
908
  queue: "queue";
909
+ execution: "execution";
910
910
  "schedule.run": "schedule.run";
911
911
  request: "request";
912
912
  }>;
@@ -4002,7 +4002,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
4002
4002
  lastModified: string;
4003
4003
  } | undefined;
4004
4004
  }>>;
4005
- branding: z.ZodObject<{
4005
+ branding: z.ZodDefault<z.ZodObject<{
4006
4006
  organizationName: z.ZodString;
4007
4007
  productName: z.ZodString;
4008
4008
  shortName: z.ZodString;
@@ -4011,7 +4011,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
4011
4011
  light: z.ZodOptional<z.ZodString>;
4012
4012
  dark: z.ZodOptional<z.ZodString>;
4013
4013
  }, z.core.$strip>>;
4014
- }, z.core.$strip>;
4014
+ }, z.core.$strip>>;
4015
4015
  navigation: z.ZodDefault<z.ZodObject<{
4016
4016
  sidebar: z.ZodDefault<z.ZodObject<{
4017
4017
  primary: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<SidebarNode, unknown, z.core.$ZodTypeInternals<SidebarNode, unknown>>>>;
package/dist/index.js CHANGED
@@ -505,8 +505,8 @@ var OrganizationModelBrandingSchema = z.object({
505
505
  });
506
506
  var DEFAULT_ORGANIZATION_MODEL_BRANDING = {
507
507
  organizationName: "Default Organization",
508
- productName: "Elevasis",
509
- shortName: "Elevasis",
508
+ productName: "Organization OS",
509
+ shortName: "Org OS",
510
510
  logos: {}
511
511
  };
512
512
  var SurfaceTypeSchema = z.enum(["page", "dashboard", "graph", "detail", "list", "settings"]).meta({ label: "Surface type", color: "blue" });
@@ -1639,79 +1639,133 @@ var PoliciesDomainSchema = z.record(z.string(), PolicySchema).refine((record) =>
1639
1639
  }).default({});
1640
1640
  var DEFAULT_ORGANIZATION_MODEL_POLICIES = {};
1641
1641
 
1642
- // src/organization-model/schema.ts
1643
- var OrganizationModelDomainKeySchema = z.enum([
1644
- "branding",
1645
- "identity",
1646
- "customers",
1647
- "offerings",
1648
- "roles",
1649
- "goals",
1650
- "systems",
1651
- "ontology",
1652
- "resources",
1653
- "topology",
1654
- "actions",
1655
- "entities",
1656
- "policies",
1657
- "knowledge"
1658
- ]);
1659
- var OrganizationModelDomainMetadataSchema = z.object({
1660
- version: z.literal(1).default(1),
1661
- lastModified: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "lastModified must be an ISO date string (YYYY-MM-DD)")
1662
- });
1663
- var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
1664
- branding: { version: 1, lastModified: "2026-05-10" },
1665
- identity: { version: 1, lastModified: "2026-05-10" },
1666
- customers: { version: 1, lastModified: "2026-05-10" },
1667
- offerings: { version: 1, lastModified: "2026-05-10" },
1668
- roles: { version: 1, lastModified: "2026-05-10" },
1669
- goals: { version: 1, lastModified: "2026-05-10" },
1670
- systems: { version: 1, lastModified: "2026-05-10" },
1671
- ontology: { version: 1, lastModified: "2026-05-14" },
1672
- resources: { version: 1, lastModified: "2026-05-10" },
1673
- topology: { version: 1, lastModified: "2026-05-14" },
1674
- actions: { version: 1, lastModified: "2026-05-10" },
1675
- entities: { version: 1, lastModified: "2026-05-10" },
1676
- policies: { version: 1, lastModified: "2026-05-10" },
1677
- knowledge: { version: 1, lastModified: "2026-05-10" }
1642
+ // src/organization-model/helpers.ts
1643
+ function childSystemsOf2(system) {
1644
+ return system.systems ?? system.subsystems ?? {};
1645
+ }
1646
+ function getSystem(model, path) {
1647
+ const segments = path.split(".");
1648
+ let current = model.systems;
1649
+ let node;
1650
+ for (const seg of segments) {
1651
+ node = current[seg];
1652
+ if (node === void 0) return void 0;
1653
+ current = childSystemsOf2(node);
1654
+ }
1655
+ return node;
1656
+ }
1657
+ function listAllSystems(model) {
1658
+ const results = [];
1659
+ function walk(map, prefix) {
1660
+ for (const [localId, system] of Object.entries(map)) {
1661
+ const fullPath = prefix ? `${prefix}.${localId}` : localId;
1662
+ results.push({ path: fullPath, system });
1663
+ const childSystems = childSystemsOf2(system);
1664
+ if (Object.keys(childSystems).length > 0) {
1665
+ walk(childSystems, fullPath);
1666
+ }
1667
+ }
1668
+ }
1669
+ walk(model.systems, "");
1670
+ return results;
1671
+ }
1672
+ function isPlainJsonObject(value) {
1673
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1674
+ }
1675
+ function mergeJsonConfig(base, override) {
1676
+ const result = { ...base };
1677
+ for (const [key, value] of Object.entries(override)) {
1678
+ const existing = result[key];
1679
+ result[key] = isPlainJsonObject(existing) && isPlainJsonObject(value) ? mergeJsonConfig(existing, value) : value;
1680
+ }
1681
+ return result;
1682
+ }
1683
+ function resolveSystemConfig(model, path) {
1684
+ const system = getSystem(model, path);
1685
+ if (system === void 0) return {};
1686
+ return mergeJsonConfig({}, system.config ?? {});
1687
+ }
1688
+
1689
+ // src/organization-model/cross-ref.ts
1690
+ var ONTOLOGY_REFERENCE_KEY_KINDS = {
1691
+ valueType: "value-type",
1692
+ catalogType: "catalog",
1693
+ objectType: "object",
1694
+ eventType: "event",
1695
+ actionType: "action",
1696
+ linkType: "link",
1697
+ interfaceType: "interface",
1698
+ propertyType: "property",
1699
+ groupType: "group",
1700
+ surfaceType: "surface",
1701
+ stepCatalog: "catalog"
1678
1702
  };
1679
- var OrganizationModelDomainMetadataByDomainSchema = z.object({
1680
- branding: OrganizationModelDomainMetadataSchema,
1681
- identity: OrganizationModelDomainMetadataSchema,
1682
- customers: OrganizationModelDomainMetadataSchema,
1683
- offerings: OrganizationModelDomainMetadataSchema,
1684
- roles: OrganizationModelDomainMetadataSchema,
1685
- goals: OrganizationModelDomainMetadataSchema,
1686
- systems: OrganizationModelDomainMetadataSchema,
1687
- ontology: OrganizationModelDomainMetadataSchema,
1688
- resources: OrganizationModelDomainMetadataSchema,
1689
- topology: OrganizationModelDomainMetadataSchema,
1690
- actions: OrganizationModelDomainMetadataSchema,
1691
- entities: OrganizationModelDomainMetadataSchema,
1692
- policies: OrganizationModelDomainMetadataSchema,
1693
- knowledge: OrganizationModelDomainMetadataSchema
1694
- }).partial().default(DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA).transform((metadata) => ({ ...DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, ...metadata }));
1695
- var OrganizationModelSchemaBase = z.object({
1696
- version: z.literal(1).default(1),
1697
- domainMetadata: OrganizationModelDomainMetadataByDomainSchema,
1698
- branding: OrganizationModelBrandingSchema,
1699
- navigation: OrganizationModelNavigationSchema,
1700
- identity: IdentityDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_IDENTITY),
1701
- customers: CustomersDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_CUSTOMERS),
1702
- offerings: OfferingsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_OFFERINGS),
1703
- roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
1704
- goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
1705
- systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
1706
- ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
1707
- resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
1708
- topology: OmTopologyDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_TOPOLOGY),
1709
- actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
1710
- entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
1711
- policies: PoliciesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_POLICIES),
1712
- // D3: flat Record<id, OrgKnowledgeNode> — no wrapper object
1713
- knowledge: KnowledgeDomainSchema.default({})
1714
- });
1703
+ function buildOmCrossRefIndex(model) {
1704
+ const systemsById = /* @__PURE__ */ new Map();
1705
+ for (const { path, system } of listAllSystems(model)) {
1706
+ systemsById.set(path, system);
1707
+ systemsById.set(system.id, system);
1708
+ }
1709
+ const resourceIds = new Set(Object.keys(model.resources ?? {}));
1710
+ const knowledgeIds = new Set(Object.keys(model.knowledge ?? {}));
1711
+ const roleIds = new Set(Object.keys(model.roles ?? {}));
1712
+ const goalIds = new Set(Object.keys(model.goals ?? {}));
1713
+ const actionIds = new Set(Object.keys(model.actions ?? {}));
1714
+ const customerSegmentIds = new Set(Object.keys(model.customers ?? {}));
1715
+ const offeringIds = new Set(Object.keys(model.offerings ?? {}));
1716
+ const ontologyCompilation = compileOrganizationOntology(model);
1717
+ const ontologyIndexByKind = {
1718
+ object: ontologyCompilation.ontology.objectTypes,
1719
+ link: ontologyCompilation.ontology.linkTypes,
1720
+ action: ontologyCompilation.ontology.actionTypes,
1721
+ catalog: ontologyCompilation.ontology.catalogTypes,
1722
+ event: ontologyCompilation.ontology.eventTypes,
1723
+ interface: ontologyCompilation.ontology.interfaceTypes,
1724
+ "value-type": ontologyCompilation.ontology.valueTypes,
1725
+ property: ontologyCompilation.ontology.sharedProperties,
1726
+ group: ontologyCompilation.ontology.groups,
1727
+ surface: ontologyCompilation.ontology.surfaces
1728
+ };
1729
+ const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index) => Object.keys(index)));
1730
+ const stageIds = /* @__PURE__ */ new Set();
1731
+ for (const catalog of Object.values(ontologyCompilation.ontology.catalogTypes)) {
1732
+ if (catalog.kind !== "stage") continue;
1733
+ const entries = catalog.entries;
1734
+ if (entries !== void 0) {
1735
+ for (const stageId of Object.keys(entries)) {
1736
+ stageIds.add(stageId);
1737
+ }
1738
+ }
1739
+ }
1740
+ return {
1741
+ systemsById,
1742
+ resourceIds,
1743
+ knowledgeIds,
1744
+ roleIds,
1745
+ goalIds,
1746
+ actionIds,
1747
+ customerSegmentIds,
1748
+ offeringIds,
1749
+ ontologyIds,
1750
+ ontologyIndexByKind,
1751
+ stageIds
1752
+ };
1753
+ }
1754
+ function knowledgeTargetExists(index, kind, id) {
1755
+ if (kind === "system") return index.systemsById.has(id);
1756
+ if (kind === "resource") return index.resourceIds.has(id);
1757
+ if (kind === "knowledge") return index.knowledgeIds.has(id);
1758
+ if (kind === "stage") return index.stageIds.has(id);
1759
+ if (kind === "action") return index.actionIds.has(id);
1760
+ if (kind === "role") return index.roleIds.has(id);
1761
+ if (kind === "goal") return index.goalIds.has(id);
1762
+ if (kind === "customer-segment") return index.customerSegmentIds.has(id);
1763
+ if (kind === "offering") return index.offeringIds.has(id);
1764
+ if (kind === "ontology") return index.ontologyIds.has(id);
1765
+ return false;
1766
+ }
1767
+
1768
+ // src/organization-model/schema-refinements.ts
1715
1769
  function addIssue(ctx, path, message) {
1716
1770
  ctx.addIssue({
1717
1771
  code: z.ZodIssueCode.custom,
@@ -1742,7 +1796,7 @@ function isKnowledgeKindCompatibleWithTarget(knowledgeKind, targetKind) {
1742
1796
  function isRecord(value) {
1743
1797
  return typeof value === "object" && value !== null && !Array.isArray(value);
1744
1798
  }
1745
- var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ctx) => {
1799
+ function refineOrganizationModel(model, ctx) {
1746
1800
  function collectAllSystems(systems, prefix = "", schemaPath = ["systems"]) {
1747
1801
  const result = [];
1748
1802
  for (const [key, system] of Object.entries(systems)) {
@@ -1914,7 +1968,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
1914
1968
  });
1915
1969
  });
1916
1970
  Object.values(model.entities).forEach((entity) => {
1917
- if (!systemsById.has(entity.ownedBySystemId)) {
1971
+ if (systemsById.size > 0 && !systemsById.has(entity.ownedBySystemId)) {
1918
1972
  addIssue(
1919
1973
  ctx,
1920
1974
  ["entities", entity.id, "ownedBySystemId"],
@@ -2032,29 +2086,9 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2032
2086
  }
2033
2087
  });
2034
2088
  });
2035
- const actionIds = new Set(Object.keys(model.actions));
2036
- const offeringsById = new Map(Object.entries(model.offerings));
2089
+ const idx = buildOmCrossRefIndex(model);
2090
+ const { ontologyIndexByKind, ontologyIds } = idx;
2037
2091
  const ontologyCompilation = compileOrganizationOntology(model);
2038
- const stageIds = /* @__PURE__ */ new Set();
2039
- for (const catalog of Object.values(ontologyCompilation.ontology.catalogTypes)) {
2040
- if (catalog.kind !== "stage") continue;
2041
- for (const stageId of Object.keys(catalog.entries ?? {})) {
2042
- stageIds.add(stageId);
2043
- }
2044
- }
2045
- const ontologyIndexByKind = {
2046
- object: ontologyCompilation.ontology.objectTypes,
2047
- link: ontologyCompilation.ontology.linkTypes,
2048
- action: ontologyCompilation.ontology.actionTypes,
2049
- catalog: ontologyCompilation.ontology.catalogTypes,
2050
- event: ontologyCompilation.ontology.eventTypes,
2051
- interface: ontologyCompilation.ontology.interfaceTypes,
2052
- "value-type": ontologyCompilation.ontology.valueTypes,
2053
- property: ontologyCompilation.ontology.sharedProperties,
2054
- group: ontologyCompilation.ontology.groups,
2055
- surface: ontologyCompilation.ontology.surfaces
2056
- };
2057
- const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index) => Object.keys(index)));
2058
2092
  function topologyTargetExists(ref) {
2059
2093
  if (ref.kind === "system") return systemsById.has(ref.id);
2060
2094
  if (ref.kind === "resource") return resourcesById.has(ref.id);
@@ -2074,19 +2108,6 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2074
2108
  );
2075
2109
  });
2076
2110
  });
2077
- const ontologyReferenceKeyKinds = {
2078
- valueType: "value-type",
2079
- catalogType: "catalog",
2080
- objectType: "object",
2081
- eventType: "event",
2082
- actionType: "action",
2083
- linkType: "link",
2084
- interfaceType: "interface",
2085
- propertyType: "property",
2086
- groupType: "group",
2087
- surfaceType: "surface",
2088
- stepCatalog: "catalog"
2089
- };
2090
2111
  function validateKnownOntologyReferences(ownerId, value, path, seen = /* @__PURE__ */ new WeakSet()) {
2091
2112
  if (Array.isArray(value)) {
2092
2113
  value.forEach((entry, index) => validateKnownOntologyReferences(ownerId, entry, [...path, index], seen));
@@ -2096,7 +2117,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2096
2117
  if (seen.has(value)) return;
2097
2118
  seen.add(value);
2098
2119
  Object.entries(value).forEach(([key, entry]) => {
2099
- const expectedKind = ontologyReferenceKeyKinds[key];
2120
+ const expectedKind = ONTOLOGY_REFERENCE_KEY_KINDS[key];
2100
2121
  if (expectedKind !== void 0) {
2101
2122
  if (typeof entry !== "string") {
2102
2123
  addIssue(ctx, [...path, key], `Ontology record "${ownerId}" ${key} must be an ontology ID string`);
@@ -2157,22 +2178,9 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2157
2178
  );
2158
2179
  }
2159
2180
  });
2160
- function knowledgeTargetExists(kind, id) {
2161
- if (kind === "system") return systemsById.has(id);
2162
- if (kind === "resource") return resourcesById.has(id);
2163
- if (kind === "knowledge") return knowledgeById.has(id);
2164
- if (kind === "stage") return stageIds.has(id);
2165
- if (kind === "action") return actionIds.has(id);
2166
- if (kind === "role") return rolesById.has(id);
2167
- if (kind === "goal") return goalsById.has(id);
2168
- if (kind === "customer-segment") return segmentsById.has(id);
2169
- if (kind === "offering") return offeringsById.has(id);
2170
- if (kind === "ontology") return ontologyIds.has(id);
2171
- return false;
2172
- }
2173
2181
  Object.entries(model.knowledge).forEach(([nodeId, node]) => {
2174
2182
  node.links.forEach((link, linkIndex) => {
2175
- if (!knowledgeTargetExists(link.target.kind, link.target.id)) {
2183
+ if (!knowledgeTargetExists(idx, link.target.kind, link.target.id)) {
2176
2184
  addIssue(
2177
2185
  ctx,
2178
2186
  ["knowledge", nodeId, "links", linkIndex, "target"],
@@ -2286,7 +2294,82 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
2286
2294
  for (const diagnostic of ontologyCompilation.diagnostics) {
2287
2295
  addIssue(ctx, diagnostic.path, diagnostic.message);
2288
2296
  }
2297
+ }
2298
+
2299
+ // src/organization-model/schema.ts
2300
+ var OrganizationModelDomainKeySchema = z.enum([
2301
+ "branding",
2302
+ "identity",
2303
+ "customers",
2304
+ "offerings",
2305
+ "roles",
2306
+ "goals",
2307
+ "systems",
2308
+ "ontology",
2309
+ "resources",
2310
+ "topology",
2311
+ "actions",
2312
+ "entities",
2313
+ "policies",
2314
+ "knowledge"
2315
+ ]);
2316
+ var OrganizationModelDomainMetadataSchema = z.object({
2317
+ version: z.literal(1).default(1),
2318
+ lastModified: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "lastModified must be an ISO date string (YYYY-MM-DD)")
2289
2319
  });
2320
+ var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
2321
+ branding: { version: 1, lastModified: "2026-05-10" },
2322
+ identity: { version: 1, lastModified: "2026-05-10" },
2323
+ customers: { version: 1, lastModified: "2026-05-10" },
2324
+ offerings: { version: 1, lastModified: "2026-05-10" },
2325
+ roles: { version: 1, lastModified: "2026-05-10" },
2326
+ goals: { version: 1, lastModified: "2026-05-10" },
2327
+ systems: { version: 1, lastModified: "2026-05-10" },
2328
+ ontology: { version: 1, lastModified: "2026-05-14" },
2329
+ resources: { version: 1, lastModified: "2026-05-10" },
2330
+ topology: { version: 1, lastModified: "2026-05-14" },
2331
+ actions: { version: 1, lastModified: "2026-05-10" },
2332
+ entities: { version: 1, lastModified: "2026-05-10" },
2333
+ policies: { version: 1, lastModified: "2026-05-10" },
2334
+ knowledge: { version: 1, lastModified: "2026-05-10" }
2335
+ };
2336
+ var OrganizationModelDomainMetadataByDomainSchema = z.object({
2337
+ branding: OrganizationModelDomainMetadataSchema,
2338
+ identity: OrganizationModelDomainMetadataSchema,
2339
+ customers: OrganizationModelDomainMetadataSchema,
2340
+ offerings: OrganizationModelDomainMetadataSchema,
2341
+ roles: OrganizationModelDomainMetadataSchema,
2342
+ goals: OrganizationModelDomainMetadataSchema,
2343
+ systems: OrganizationModelDomainMetadataSchema,
2344
+ ontology: OrganizationModelDomainMetadataSchema,
2345
+ resources: OrganizationModelDomainMetadataSchema,
2346
+ topology: OrganizationModelDomainMetadataSchema,
2347
+ actions: OrganizationModelDomainMetadataSchema,
2348
+ entities: OrganizationModelDomainMetadataSchema,
2349
+ policies: OrganizationModelDomainMetadataSchema,
2350
+ knowledge: OrganizationModelDomainMetadataSchema
2351
+ }).partial().default(DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA).transform((metadata) => ({ ...DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, ...metadata }));
2352
+ var OrganizationModelSchemaBase = z.object({
2353
+ version: z.literal(1).default(1),
2354
+ domainMetadata: OrganizationModelDomainMetadataByDomainSchema,
2355
+ branding: OrganizationModelBrandingSchema.default(DEFAULT_ORGANIZATION_MODEL_BRANDING),
2356
+ navigation: OrganizationModelNavigationSchema,
2357
+ identity: IdentityDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_IDENTITY),
2358
+ customers: CustomersDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_CUSTOMERS),
2359
+ offerings: OfferingsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_OFFERINGS),
2360
+ roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
2361
+ goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
2362
+ systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
2363
+ ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
2364
+ resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
2365
+ topology: OmTopologyDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_TOPOLOGY),
2366
+ actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
2367
+ entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
2368
+ policies: PoliciesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_POLICIES),
2369
+ // D3: flat Record<id, OrgKnowledgeNode> — no wrapper object
2370
+ knowledge: KnowledgeDomainSchema.default({})
2371
+ });
2372
+ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine(refineOrganizationModel);
2290
2373
  var OrganizationGraphNodeKindSchema = z.enum([
2291
2374
  "organization",
2292
2375
  "system",
@@ -2721,53 +2804,6 @@ var DEFAULT_ORGANIZATION_MODEL_STATUSES = {
2721
2804
  }
2722
2805
  };
2723
2806
 
2724
- // src/organization-model/helpers.ts
2725
- function childSystemsOf2(system) {
2726
- return system.systems ?? system.subsystems ?? {};
2727
- }
2728
- function getSystem(model, path) {
2729
- const segments = path.split(".");
2730
- let current = model.systems;
2731
- let node;
2732
- for (const seg of segments) {
2733
- node = current[seg];
2734
- if (node === void 0) return void 0;
2735
- current = childSystemsOf2(node);
2736
- }
2737
- return node;
2738
- }
2739
- function listAllSystems(model) {
2740
- const results = [];
2741
- function walk(map, prefix) {
2742
- for (const [localId, system] of Object.entries(map)) {
2743
- const fullPath = prefix ? `${prefix}.${localId}` : localId;
2744
- results.push({ path: fullPath, system });
2745
- const childSystems = childSystemsOf2(system);
2746
- if (Object.keys(childSystems).length > 0) {
2747
- walk(childSystems, fullPath);
2748
- }
2749
- }
2750
- }
2751
- walk(model.systems, "");
2752
- return results;
2753
- }
2754
- function isPlainJsonObject(value) {
2755
- return typeof value === "object" && value !== null && !Array.isArray(value);
2756
- }
2757
- function mergeJsonConfig(base, override) {
2758
- const result = { ...base };
2759
- for (const [key, value] of Object.entries(override)) {
2760
- const existing = result[key];
2761
- result[key] = isPlainJsonObject(existing) && isPlainJsonObject(value) ? mergeJsonConfig(existing, value) : value;
2762
- }
2763
- return result;
2764
- }
2765
- function resolveSystemConfig(model, path) {
2766
- const system = getSystem(model, path);
2767
- if (system === void 0) return {};
2768
- return mergeJsonConfig({}, system.config ?? {});
2769
- }
2770
-
2771
2807
  // src/organization-model/resolve.ts
2772
2808
  function isPlainObject(value) {
2773
2809
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -138,25 +138,6 @@ interface SystemEntry {
138
138
  subsystems?: Record<string, SystemEntry>;
139
139
  }
140
140
 
141
- /**
142
- * Command View Types
143
- *
144
- * Unified type definitions for the Command View graph visualization.
145
- * These types are used by both backend serialization and frontend rendering.
146
- *
147
- * Command View shows the resource graph: agents, workflows, triggers, integrations,
148
- * external resources, and human checkpoints with their relationships.
149
- */
150
-
151
- /**
152
- * Relationship types between resources
153
- *
154
- * - triggers: Resource initiates/starts another resource (orange)
155
- * - uses: Resource uses an integration (teal)
156
- * - approval: Resource requires human approval (yellow)
157
- */
158
- type RelationshipType = 'triggers' | 'uses' | 'approval';
159
-
160
141
  declare const SurfaceTypeSchema: z.ZodEnum<{
161
142
  dashboard: "dashboard";
162
143
  settings: "settings";
@@ -547,7 +528,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
547
528
  lastModified: string;
548
529
  } | undefined;
549
530
  }>>;
550
- branding: z.ZodObject<{
531
+ branding: z.ZodDefault<z.ZodObject<{
551
532
  organizationName: z.ZodString;
552
533
  productName: z.ZodString;
553
534
  shortName: z.ZodString;
@@ -556,7 +537,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
556
537
  light: z.ZodOptional<z.ZodString>;
557
538
  dark: z.ZodOptional<z.ZodString>;
558
539
  }, z.core.$strip>>;
559
- }, z.core.$strip>;
540
+ }, z.core.$strip>>;
560
541
  navigation: z.ZodDefault<z.ZodObject<{
561
542
  sidebar: z.ZodDefault<z.ZodObject<{
562
543
  primary: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<SidebarNode, unknown, z.core.$ZodTypeInternals<SidebarNode, unknown>>>>;
@@ -1286,6 +1267,25 @@ declare const OrganizationModelSchema: z.ZodObject<{
1286
1267
 
1287
1268
  type OrganizationModel = z.infer<typeof OrganizationModelSchema>;
1288
1269
 
1270
+ /**
1271
+ * Command View Types
1272
+ *
1273
+ * Unified type definitions for the Command View graph visualization.
1274
+ * These types are used by both backend serialization and frontend rendering.
1275
+ *
1276
+ * Command View shows the resource graph: agents, workflows, triggers, integrations,
1277
+ * external resources, and human checkpoints with their relationships.
1278
+ */
1279
+
1280
+ /**
1281
+ * Relationship types between resources
1282
+ *
1283
+ * - triggers: Resource initiates/starts another resource (orange)
1284
+ * - uses: Resource uses an integration (teal)
1285
+ * - approval: Resource requires human approval (yellow)
1286
+ */
1287
+ type RelationshipType = 'triggers' | 'uses' | 'approval';
1288
+
1289
1289
  type OrganizationGraphNodeKind = 'organization' | 'system' | 'role' | 'action' | 'entity' | 'event' | 'policy' | 'stage' | 'resource' | 'knowledge' | 'customer-segment' | 'offering' | 'goal' | 'surface' | 'navigation-group' | 'ontology';
1290
1290
  type OrganizationGraphEdgeKind = 'contains' | 'references' | 'maps_to' | 'uses' | 'governs' | 'links' | 'affects' | 'emits' | 'originates_from' | 'triggers' | 'approval' | 'applies_to' | 'effects' | 'actions' | 'reads' | 'writes' | 'uses_catalog';
1291
1291
 
@@ -875,8 +875,8 @@ declare const StatusSemanticClassSchema: z.ZodEnum<{
875
875
  "delivery.milestone": "delivery.milestone";
876
876
  "delivery.task": "delivery.task";
877
877
  schedule: "schedule";
878
- execution: "execution";
879
878
  queue: "queue";
879
+ execution: "execution";
880
880
  "schedule.run": "schedule.run";
881
881
  request: "request";
882
882
  }>;
@@ -889,8 +889,8 @@ declare const StatusEntrySchema: z.ZodObject<{
889
889
  "delivery.milestone": "delivery.milestone";
890
890
  "delivery.task": "delivery.task";
891
891
  schedule: "schedule";
892
- execution: "execution";
893
892
  queue: "queue";
893
+ execution: "execution";
894
894
  "schedule.run": "schedule.run";
895
895
  request: "request";
896
896
  }>;
@@ -905,8 +905,8 @@ declare const StatusesDomainSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodO
905
905
  "delivery.milestone": "delivery.milestone";
906
906
  "delivery.task": "delivery.task";
907
907
  schedule: "schedule";
908
- execution: "execution";
909
908
  queue: "queue";
909
+ execution: "execution";
910
910
  "schedule.run": "schedule.run";
911
911
  request: "request";
912
912
  }>;
@@ -4002,7 +4002,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
4002
4002
  lastModified: string;
4003
4003
  } | undefined;
4004
4004
  }>>;
4005
- branding: z.ZodObject<{
4005
+ branding: z.ZodDefault<z.ZodObject<{
4006
4006
  organizationName: z.ZodString;
4007
4007
  productName: z.ZodString;
4008
4008
  shortName: z.ZodString;
@@ -4011,7 +4011,7 @@ declare const OrganizationModelSchema: z.ZodObject<{
4011
4011
  light: z.ZodOptional<z.ZodString>;
4012
4012
  dark: z.ZodOptional<z.ZodString>;
4013
4013
  }, z.core.$strip>>;
4014
- }, z.core.$strip>;
4014
+ }, z.core.$strip>>;
4015
4015
  navigation: z.ZodDefault<z.ZodObject<{
4016
4016
  sidebar: z.ZodDefault<z.ZodObject<{
4017
4017
  primary: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<SidebarNode, unknown, z.core.$ZodTypeInternals<SidebarNode, unknown>>>>;