@elevasis/sdk 1.24.0 → 1.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.
package/dist/cli.cjs CHANGED
@@ -36586,917 +36586,1027 @@ config(en_default());
36586
36586
  // src/cli/commands/deploy.ts
36587
36587
  var import_module = require("module");
36588
36588
 
36589
- // ../core/src/organization-model/icons.ts
36590
- var ORGANIZATION_MODEL_ICON_TOKENS = [
36591
- // Navigation / app areas
36592
- "dashboard",
36593
- "calendar",
36594
- "sales",
36595
- "crm",
36596
- "lead-gen",
36597
- "projects",
36598
- "clients",
36599
- "operations",
36600
- "monitoring",
36601
- "knowledge",
36602
- "settings",
36603
- "admin",
36604
- "archive",
36605
- "business",
36606
- "finance",
36607
- "platform",
36608
- "seo",
36609
- // Knowledge kinds
36610
- "playbook",
36611
- "strategy",
36612
- "reference",
36613
- // Resource kinds
36614
- "agent",
36615
- "workflow",
36616
- "integration",
36617
- "database",
36618
- "user",
36619
- "team",
36620
- // Integration specifics
36621
- "gmail",
36622
- "google-sheets",
36623
- "attio",
36624
- // Surface / UI views
36625
- "overview",
36626
- "command-view",
36627
- "command-queue",
36628
- "pipeline",
36629
- "lists",
36630
- "resources",
36631
- // Actions
36632
- "approve",
36633
- "reject",
36634
- "retry",
36635
- "edit",
36636
- "view",
36637
- "launch",
36638
- "message",
36639
- "escalate",
36640
- "promote",
36641
- "submit",
36642
- "email",
36643
- // Status
36644
- "success",
36645
- "error",
36646
- "warning",
36647
- "info",
36648
- "pending",
36649
- // OM / UI group icons
36650
- "bolt",
36651
- "building",
36652
- "briefcase",
36653
- "apps",
36654
- "graph",
36655
- "shield",
36656
- "users",
36657
- "chart-bar",
36658
- "search"
36659
- ];
36660
- var CustomIconTokenSchema = external_exports.string().trim().max(80).regex(
36661
- /^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
36662
- 'Custom icon tokens must start with "custom." followed by lowercase alphanumeric segments'
36663
- );
36664
- var OrganizationModelBuiltinIconTokenSchema = external_exports.enum(ORGANIZATION_MODEL_ICON_TOKENS);
36665
- var OrganizationModelIconTokenSchema = external_exports.union([
36666
- OrganizationModelBuiltinIconTokenSchema,
36667
- CustomIconTokenSchema
36589
+ // ../core/src/organization-model/ontology.ts
36590
+ var OntologyKindSchema = external_exports.enum([
36591
+ "object",
36592
+ "link",
36593
+ "action",
36594
+ "catalog",
36595
+ "event",
36596
+ "interface",
36597
+ "value-type",
36598
+ "property",
36599
+ "group",
36600
+ "surface"
36668
36601
  ]);
36669
-
36670
- // ../core/src/organization-model/domains/shared.ts
36671
- var ModelIdSchema = external_exports.string().trim().min(1).max(100).regex(/^[a-z0-9]+(?:[-._][a-z0-9]+)*$/, "IDs must be lowercase and use -, _, or . separators");
36672
- var LabelSchema = external_exports.string().trim().min(1).max(120);
36673
- var DescriptionSchema = external_exports.string().trim().min(1).max(2e3);
36674
- var ColorTokenSchema = external_exports.string().trim().min(1).max(50);
36675
- var IconNameSchema = OrganizationModelIconTokenSchema;
36676
- var PathSchema = external_exports.string().trim().startsWith("/").max(300);
36677
- var ReferenceIdsSchema = external_exports.array(ModelIdSchema).default([]);
36678
- var DisplayMetadataSchema = external_exports.object({
36679
- label: LabelSchema,
36680
- description: DescriptionSchema.optional(),
36681
- color: ColorTokenSchema.optional(),
36682
- icon: IconNameSchema.optional()
36602
+ var SYSTEM_PATH_PATTERN = "[a-z0-9][a-z0-9-]*(?:\\.[a-z0-9][a-z0-9-]*)*";
36603
+ var LOCAL_ID_PATTERN = "[a-z0-9][a-z0-9._-]*";
36604
+ var ONTOLOGY_ID_PATTERN = `^(global|${SYSTEM_PATH_PATTERN}):(${OntologyKindSchema.options.join("|")})\\/(${LOCAL_ID_PATTERN})$`;
36605
+ var ONTOLOGY_ID_REGEX = new RegExp(ONTOLOGY_ID_PATTERN);
36606
+ var OntologyIdSchema = external_exports.string().trim().min(1).max(300).regex(
36607
+ ONTOLOGY_ID_REGEX,
36608
+ "Ontology IDs must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
36609
+ );
36610
+ function parseOntologyId(id) {
36611
+ const normalized = OntologyIdSchema.parse(id);
36612
+ const match = ONTOLOGY_ID_REGEX.exec(normalized);
36613
+ if (match === null) {
36614
+ throw new Error(`Invalid ontology ID "${id}"`);
36615
+ }
36616
+ return {
36617
+ id: normalized,
36618
+ scope: match[1],
36619
+ kind: match[2],
36620
+ localId: match[3],
36621
+ isGlobal: match[1] === "global"
36622
+ };
36623
+ }
36624
+ function formatOntologyId(input) {
36625
+ return OntologyIdSchema.parse(`${input.scope}:${input.kind}/${input.localId}`);
36626
+ }
36627
+ var OntologyReferenceListSchema = external_exports.array(OntologyIdSchema).default([]).optional();
36628
+ var OntologyRecordBaseSchema = external_exports.object({
36629
+ id: OntologyIdSchema,
36630
+ label: external_exports.string().trim().min(1).max(160).optional(),
36631
+ description: external_exports.string().trim().min(1).max(2e3).optional(),
36632
+ ownerSystemId: external_exports.string().trim().min(1).max(200).optional(),
36633
+ aliases: external_exports.array(OntologyIdSchema).optional()
36634
+ }).passthrough();
36635
+ var OntologyObjectTypeSchema = OntologyRecordBaseSchema.extend({
36636
+ properties: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional(),
36637
+ storage: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
36683
36638
  });
36684
- var TechStackEntrySchema = external_exports.object({
36685
- /** Name of the external platform (e.g. "HubSpot", "Stripe", "Notion"). */
36686
- platform: external_exports.string().trim().min(1).max(200),
36687
- /** Free-form description of what this integration is used for. */
36688
- purpose: external_exports.string().trim().min(1).max(500),
36689
- /**
36690
- * Health of the credential backing this integration.
36691
- * - configured: credential present and valid
36692
- * - pending: not yet set up
36693
- * - expired: credential existed but has lapsed
36694
- * - missing: expected but not present
36695
- */
36696
- credentialStatus: external_exports.enum(["configured", "pending", "expired", "missing"]),
36697
- /**
36698
- * Whether this integration is the primary system of record for its domain
36699
- * (e.g. HubSpot is SoR for contacts). Defaults to false.
36700
- */
36701
- isSystemOfRecord: external_exports.boolean().default(false)
36639
+ var OntologyLinkTypeSchema = OntologyRecordBaseSchema.extend({
36640
+ from: OntologyIdSchema,
36641
+ to: OntologyIdSchema,
36642
+ cardinality: external_exports.string().trim().min(1).max(80).optional(),
36643
+ via: external_exports.string().trim().min(1).max(255).optional()
36702
36644
  });
36703
- var ResourceMappingSchema = DisplayMetadataSchema.extend({
36704
- id: ModelIdSchema,
36705
- resourceId: external_exports.string().trim().min(1).max(255),
36706
- resourceType: external_exports.enum(["workflow", "agent", "trigger", "integration", "external", "human_checkpoint"]),
36707
- systemIds: ReferenceIdsSchema,
36708
- entityIds: ReferenceIdsSchema,
36709
- surfaceIds: ReferenceIdsSchema,
36710
- actionIds: ReferenceIdsSchema,
36711
- /** Optional tech-stack metadata for external-SaaS integrations. */
36712
- techStack: TechStackEntrySchema.optional()
36645
+ var OntologyActionTypeSchema = OntologyRecordBaseSchema.extend({
36646
+ actsOn: OntologyReferenceListSchema,
36647
+ input: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional(),
36648
+ effects: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).optional()
36713
36649
  });
36714
-
36715
- // ../core/src/organization-model/domains/branding.ts
36716
- var OrganizationModelBrandingSchema = external_exports.object({
36717
- organizationName: LabelSchema,
36718
- productName: LabelSchema,
36719
- shortName: external_exports.string().trim().min(1).max(40),
36720
- description: DescriptionSchema.optional(),
36721
- logos: external_exports.object({
36722
- light: external_exports.string().trim().min(1).max(2048).optional(),
36723
- dark: external_exports.string().trim().min(1).max(2048).optional()
36724
- }).default({})
36650
+ var OntologyCatalogTypeSchema = OntologyRecordBaseSchema.extend({
36651
+ kind: external_exports.string().trim().min(1).max(120).optional(),
36652
+ appliesTo: OntologyIdSchema.optional(),
36653
+ entries: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional()
36725
36654
  });
36726
- var DEFAULT_ORGANIZATION_MODEL_BRANDING = {
36727
- organizationName: "Default Organization",
36728
- productName: "Elevasis",
36729
- shortName: "Elevasis",
36730
- logos: {}
36731
- };
36732
-
36733
- // ../core/src/organization-model/domains/navigation.ts
36734
- var SurfaceTypeSchema = external_exports.enum(["page", "dashboard", "graph", "detail", "list", "settings"]).meta({ label: "Surface type", color: "blue" });
36735
- var SurfaceDefinitionSchema = external_exports.object({
36736
- id: ModelIdSchema,
36737
- label: LabelSchema,
36738
- path: PathSchema,
36739
- surfaceType: SurfaceTypeSchema,
36740
- description: DescriptionSchema.optional(),
36741
- enabled: external_exports.boolean().default(true),
36742
- devOnly: external_exports.boolean().optional(),
36743
- icon: IconNameSchema.optional(),
36744
- systemIds: external_exports.array(ModelIdSchema.meta({ ref: "system" })).default([]),
36745
- entityIds: external_exports.array(ModelIdSchema.meta({ ref: "entity" })).default([]),
36746
- resourceIds: external_exports.array(ModelIdSchema.meta({ ref: "resource" })).default([]),
36747
- actionIds: external_exports.array(ModelIdSchema.meta({ ref: "action" })).default([]),
36748
- parentId: ModelIdSchema.meta({ ref: "surface" }).optional()
36655
+ var OntologyEventTypeSchema = OntologyRecordBaseSchema.extend({
36656
+ payload: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional()
36749
36657
  });
36750
- var SidebarSurfaceTargetsSchema = external_exports.object({
36751
- systems: external_exports.array(ModelIdSchema.meta({ ref: "system" })).default([]).optional(),
36752
- entities: external_exports.array(ModelIdSchema.meta({ ref: "entity" })).default([]).optional(),
36753
- resources: external_exports.array(ModelIdSchema.meta({ ref: "resource" })).default([]).optional(),
36754
- actions: external_exports.array(ModelIdSchema.meta({ ref: "action" })).default([]).optional()
36658
+ var OntologyInterfaceTypeSchema = OntologyRecordBaseSchema.extend({
36659
+ properties: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional()
36660
+ });
36661
+ var OntologyValueTypeSchema = OntologyRecordBaseSchema.extend({
36662
+ primitive: external_exports.string().trim().min(1).max(120).optional()
36663
+ });
36664
+ var OntologySharedPropertySchema = OntologyRecordBaseSchema.extend({
36665
+ valueType: OntologyIdSchema.optional(),
36666
+ searchable: external_exports.boolean().optional(),
36667
+ pii: external_exports.boolean().optional()
36668
+ });
36669
+ var OntologyGroupSchema = OntologyRecordBaseSchema.extend({
36670
+ members: OntologyReferenceListSchema
36671
+ });
36672
+ var OntologySurfaceTypeSchema = OntologyRecordBaseSchema.extend({
36673
+ route: external_exports.string().trim().min(1).max(500).optional()
36674
+ });
36675
+ var OntologyScopeSchema = external_exports.object({
36676
+ objectTypes: external_exports.record(OntologyIdSchema, OntologyObjectTypeSchema).default({}).optional(),
36677
+ linkTypes: external_exports.record(OntologyIdSchema, OntologyLinkTypeSchema).default({}).optional(),
36678
+ actionTypes: external_exports.record(OntologyIdSchema, OntologyActionTypeSchema).default({}).optional(),
36679
+ catalogTypes: external_exports.record(OntologyIdSchema, OntologyCatalogTypeSchema).default({}).optional(),
36680
+ eventTypes: external_exports.record(OntologyIdSchema, OntologyEventTypeSchema).default({}).optional(),
36681
+ interfaceTypes: external_exports.record(OntologyIdSchema, OntologyInterfaceTypeSchema).default({}).optional(),
36682
+ valueTypes: external_exports.record(OntologyIdSchema, OntologyValueTypeSchema).default({}).optional(),
36683
+ sharedProperties: external_exports.record(OntologyIdSchema, OntologySharedPropertySchema).default({}).optional(),
36684
+ groups: external_exports.record(OntologyIdSchema, OntologyGroupSchema).default({}).optional(),
36685
+ surfaces: external_exports.record(OntologyIdSchema, OntologySurfaceTypeSchema).default({}).optional()
36755
36686
  }).default({});
36756
- var SidebarNodeSchema = external_exports.lazy(
36757
- () => external_exports.discriminatedUnion("type", [
36758
- external_exports.object({
36759
- type: external_exports.literal("group"),
36760
- label: LabelSchema,
36761
- description: DescriptionSchema.optional(),
36762
- icon: IconNameSchema.optional(),
36763
- order: external_exports.number().int().optional(),
36764
- children: external_exports.record(external_exports.string(), SidebarNodeSchema).default({})
36765
- }),
36766
- external_exports.object({
36767
- type: external_exports.literal("surface"),
36768
- label: LabelSchema,
36769
- path: PathSchema,
36770
- surfaceType: SurfaceTypeSchema,
36771
- description: DescriptionSchema.optional(),
36772
- icon: IconNameSchema.optional(),
36773
- order: external_exports.number().int().optional(),
36774
- targets: SidebarSurfaceTargetsSchema.optional(),
36775
- devOnly: external_exports.boolean().optional(),
36776
- requiresAdmin: external_exports.boolean().optional()
36777
- })
36778
- ])
36779
- );
36780
- var SidebarSectionSchema = external_exports.record(external_exports.string(), SidebarNodeSchema).default({});
36781
- var SidebarNavigationSchema = external_exports.object({
36782
- primary: SidebarSectionSchema,
36783
- bottom: SidebarSectionSchema
36784
- }).default({ primary: {}, bottom: {} });
36785
- var OrganizationModelNavigationSchema = external_exports.object({
36786
- sidebar: SidebarNavigationSchema
36787
- }).default({ sidebar: { primary: {}, bottom: {} } });
36788
- var NavigationGroupSchema = external_exports.object({
36789
- id: ModelIdSchema,
36790
- label: LabelSchema,
36791
- placement: external_exports.string().trim().min(1).max(50),
36792
- surfaceIds: external_exports.array(ModelIdSchema.meta({ ref: "surface" })).default([])
36793
- });
36794
-
36795
- // ../core/src/organization-model/domains/identity.ts
36796
- var BusinessHoursDaySchema = external_exports.object({
36797
- open: external_exports.string().trim().regex(/^\d{2}:\d{2}$/, "Expected HH:MM format"),
36798
- close: external_exports.string().trim().regex(/^\d{2}:\d{2}$/, "Expected HH:MM format")
36799
- });
36800
- var BusinessHoursSchema = external_exports.object({
36801
- monday: BusinessHoursDaySchema.optional(),
36802
- tuesday: BusinessHoursDaySchema.optional(),
36803
- wednesday: BusinessHoursDaySchema.optional(),
36804
- thursday: BusinessHoursDaySchema.optional(),
36805
- friday: BusinessHoursDaySchema.optional(),
36806
- saturday: BusinessHoursDaySchema.optional(),
36807
- sunday: BusinessHoursDaySchema.optional()
36808
- }).default({});
36809
- var IdentityDomainSchema = external_exports.object({
36810
- /** Why the organization exists — one or two plain-language sentences. */
36811
- mission: external_exports.string().trim().max(1e3).default(""),
36812
- /** Long-term direction the organization is moving toward. */
36813
- vision: external_exports.string().trim().max(1e3).default(""),
36814
- /** Legal registered name of the entity. */
36815
- legalName: external_exports.string().trim().max(200).default(""),
36816
- /**
36817
- * Type of legal entity (e.g. "LLC", "Corporation", "Sole Proprietor",
36818
- * "Non-profit"). Free-form string so it covers any jurisdiction.
36819
- */
36820
- entityType: external_exports.string().trim().max(100).default(""),
36821
- /**
36822
- * Primary jurisdiction of registration or operation
36823
- * (e.g. "United States – Delaware", "Canada – Ontario").
36824
- */
36825
- jurisdiction: external_exports.string().trim().max(200).default(""),
36826
- /**
36827
- * Industry category — broad classification (e.g. "Marketing Agency",
36828
- * "Software / SaaS", "Professional Services").
36829
- */
36830
- industryCategory: external_exports.string().trim().max(200).default(""),
36831
- /**
36832
- * Geographic focus — where the organization primarily operates or serves
36833
- * (e.g. "North America", "Global", "Southeast Asia").
36834
- */
36835
- geographicFocus: external_exports.string().trim().max(200).default(""),
36836
- /**
36837
- * IANA timezone identifier for the organization's primary operating timezone
36838
- * (e.g. "America/Los_Angeles", "Europe/London", "UTC").
36839
- */
36840
- timeZone: external_exports.string().trim().max(100).default("UTC"),
36841
- /** Typical operating hours per day of week. Empty object means not configured. */
36842
- businessHours: BusinessHoursSchema,
36843
- /**
36844
- * Long-form markdown capturing client context, problem narrative, and domain
36845
- * background. Populated by /setup; surfaced to agents as organizational context.
36846
- * Optional — many projects have no external client.
36847
- */
36848
- clientBrief: external_exports.string().trim().default("")
36849
- });
36850
- var DEFAULT_ORGANIZATION_MODEL_IDENTITY = {
36851
- mission: "",
36852
- vision: "",
36853
- legalName: "",
36854
- entityType: "",
36855
- jurisdiction: "",
36856
- industryCategory: "",
36857
- geographicFocus: "",
36858
- timeZone: "UTC",
36859
- businessHours: {},
36860
- clientBrief: ""
36687
+ var DEFAULT_ONTOLOGY_SCOPE = {
36688
+ valueTypes: {
36689
+ "global:value-type/uuid": {
36690
+ id: "global:value-type/uuid",
36691
+ label: "UUID",
36692
+ primitive: "string"
36693
+ },
36694
+ "global:value-type/text": {
36695
+ id: "global:value-type/text",
36696
+ label: "Text",
36697
+ primitive: "string"
36698
+ },
36699
+ "global:value-type/url": {
36700
+ id: "global:value-type/url",
36701
+ label: "URL",
36702
+ primitive: "string"
36703
+ },
36704
+ "global:value-type/email": {
36705
+ id: "global:value-type/email",
36706
+ label: "Email",
36707
+ primitive: "string"
36708
+ }
36709
+ }
36861
36710
  };
36862
-
36863
- // ../core/src/organization-model/domains/customers.ts
36864
- var FirmographicsSchema = external_exports.object({
36865
- /** Industry vertical (e.g. "Marketing Agency", "Legal", "Real Estate"). */
36866
- industry: external_exports.string().trim().max(200).optional(),
36867
- /**
36868
- * Company headcount band (e.g. "1–10", "11–50", "51–200", "200+").
36869
- * Free-form string to accommodate any band notation.
36870
- */
36871
- companySize: external_exports.string().trim().max(100).optional(),
36872
- /**
36873
- * Primary geographic region the segment operates in or is targeted from
36874
- * (e.g. "North America", "Europe", "Global").
36875
- */
36876
- region: external_exports.string().trim().max(200).optional()
36877
- });
36878
- var CustomerSegmentSchema = external_exports.object({
36879
- /** Stable unique identifier for the segment (e.g. "segment-smb-agencies"). */
36880
- id: external_exports.string().trim().min(1).max(100),
36881
- /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
36882
- order: external_exports.number(),
36883
- /** Human-readable name shown to agents and in UI (e.g. "SMB Marketing Agencies"). */
36884
- name: external_exports.string().trim().max(200).default(""),
36885
- /** One or two sentences describing who this segment is. */
36886
- description: external_exports.string().trim().max(2e3).default(""),
36887
- /**
36888
- * The primary job(s) this segment is trying to get done — the goal they hire
36889
- * a product/service to accomplish. Plain-language narrative or bullet list.
36890
- */
36891
- jobsToBeDone: external_exports.string().trim().max(2e3).default(""),
36892
- /**
36893
- * Pains frustrations, obstacles, and risks the segment experiences
36894
- * when trying to accomplish their jobs-to-be-done.
36895
- */
36896
- pains: external_exports.array(external_exports.string().trim().max(500)).default([]),
36897
- /**
36898
- * Gains — outcomes and benefits the segment desires; positive motivators
36899
- * beyond merely resolving pains.
36900
- */
36901
- gains: external_exports.array(external_exports.string().trim().max(500)).default([]),
36902
- /** Firmographic profile for targeting and filtering. */
36903
- firmographics: FirmographicsSchema.default({}),
36904
- /**
36905
- * Value proposition — one or two sentences stating why this organization's
36906
- * offering is uniquely suited for this segment's needs.
36907
- */
36908
- valueProp: external_exports.string().trim().max(2e3).default("")
36909
- });
36910
- var CustomersDomainSchema = external_exports.record(external_exports.string(), CustomerSegmentSchema).refine((record2) => Object.entries(record2).every(([key, entry]) => entry.id === key), {
36911
- message: "Each segment entry id must match its map key"
36912
- }).default({});
36913
- var DEFAULT_ORGANIZATION_MODEL_CUSTOMERS = {};
36914
-
36915
- // ../core/src/organization-model/domains/offerings.ts
36916
- var PricingModelSchema = external_exports.enum(["one-time", "subscription", "usage-based", "custom"]).meta({ label: "Pricing model", color: "green" });
36917
- var ProductSchema = external_exports.object({
36918
- /** Stable unique identifier for the product (e.g. "product-starter-plan"). */
36919
- id: external_exports.string().trim().min(1).max(100),
36920
- /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
36921
- order: external_exports.number(),
36922
- /** Human-readable name shown to agents and in UI (e.g. "Starter Plan"). */
36923
- name: external_exports.string().trim().max(200).default(""),
36924
- /** One or two sentences describing what this product/service delivers. */
36925
- description: external_exports.string().trim().max(2e3).default(""),
36926
- /**
36927
- * How this product is priced:
36928
- * - "one-time" — single purchase (setup fee, project fee)
36929
- * - "subscription" — recurring (monthly/annual SaaS, retainer)
36930
- * - "usage-based" — metered by consumption (API calls, seats)
36931
- * - "custom" — negotiated or bespoke pricing
36932
- */
36933
- pricingModel: PricingModelSchema.default("custom"),
36934
- /** Base price amount (≥ 0). Currency unit defined by `currency`. */
36935
- price: external_exports.number().min(0).default(0),
36936
- /**
36937
- * ISO 4217 currency code (e.g. "USD", "EUR", "GBP").
36938
- * Free-form string to accommodate any currency; defaults to "USD".
36939
- */
36940
- currency: external_exports.string().trim().max(10).default("USD"),
36941
- /**
36942
- * IDs of customer segments this product targets.
36943
- * Each id must reference a declared `customers.segments[].id`.
36944
- * Cross-reference enforced in `OrganizationModelSchema.superRefine()`.
36945
- */
36946
- targetSegmentIds: external_exports.array(external_exports.string().trim().min(1)).default([]),
36947
- /**
36948
- * Optional: ID of the platform system responsible for delivering this product.
36949
- * When present, must reference a declared `systems.systems[].id`.
36950
- * Cross-reference enforced in `OrganizationModelSchema.superRefine()`.
36951
- */
36952
- deliveryFeatureId: external_exports.string().trim().min(1).optional()
36953
- });
36954
- var OfferingsDomainSchema = external_exports.record(external_exports.string(), ProductSchema).refine((record2) => Object.entries(record2).every(([key, entry]) => entry.id === key), {
36955
- message: "Each product entry id must match its map key"
36956
- }).default({});
36957
- var DEFAULT_ORGANIZATION_MODEL_OFFERINGS = {};
36958
-
36959
- // ../core/src/organization-model/domains/entities.ts
36960
- var EntityIdSchema = ModelIdSchema;
36961
- var EntityLinkKindSchema = external_exports.enum(["belongs-to", "has-many", "has-one", "many-to-many"]).meta({ label: "Link kind" });
36962
- var EntityLinkSchema = external_exports.object({
36963
- toEntity: EntityIdSchema.meta({ ref: "entity" }),
36964
- kind: EntityLinkKindSchema,
36965
- via: external_exports.string().trim().min(1).max(255).optional(),
36966
- label: LabelSchema.optional()
36967
- });
36968
- var EntitySchema = external_exports.object({
36969
- id: EntityIdSchema,
36970
- /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
36971
- order: external_exports.number(),
36972
- label: LabelSchema,
36973
- description: DescriptionSchema.optional(),
36974
- ownedBySystemId: ModelIdSchema.meta({ ref: "system" }),
36975
- table: external_exports.string().trim().min(1).max(255).optional(),
36976
- rowSchema: ModelIdSchema.optional(),
36977
- stateCatalogId: ModelIdSchema.optional(),
36978
- links: external_exports.array(EntityLinkSchema).optional()
36979
- });
36980
- var EntitiesDomainSchema = external_exports.record(external_exports.string(), EntitySchema).refine((record2) => Object.entries(record2).every(([key, entry]) => entry.id === key), {
36981
- message: "Each entity entry id must match its map key"
36982
- }).default({});
36983
- var ENTITY_ENTRY_INPUTS = [
36984
- {
36985
- id: "crm.deal",
36986
- order: 10,
36987
- label: "Deal",
36988
- description: "A CRM opportunity or sales pipeline record.",
36989
- ownedBySystemId: "sales.crm",
36990
- table: "crm_deals",
36991
- stateCatalogId: "crm.pipeline",
36992
- links: [{ toEntity: "crm.contact", kind: "has-many", via: "deal_contacts", label: "contacts" }]
36993
- },
36994
- {
36995
- id: "crm.contact",
36996
- order: 20,
36997
- label: "CRM Contact",
36998
- description: "A person associated with a CRM relationship or deal.",
36999
- ownedBySystemId: "sales.crm",
37000
- table: "crm_contacts"
37001
- },
37002
- {
37003
- id: "leadgen.list",
37004
- order: 30,
37005
- label: "Lead List",
37006
- description: "A prospecting list that groups companies and contacts for acquisition workflows.",
37007
- ownedBySystemId: "sales.lead-gen",
37008
- table: "acq_lists",
37009
- links: [
37010
- { toEntity: "leadgen.company", kind: "has-many", via: "acq_list_companies", label: "companies" },
37011
- { toEntity: "leadgen.contact", kind: "has-many", via: "acq_list_members", label: "contacts" }
37012
- ]
37013
- },
37014
- {
37015
- id: "leadgen.company",
37016
- order: 40,
37017
- label: "Lead Company",
37018
- description: "A company record sourced, enriched, and qualified during prospecting.",
37019
- ownedBySystemId: "sales.lead-gen",
37020
- table: "acq_list_companies",
37021
- stateCatalogId: "lead-gen.company",
37022
- links: [
37023
- { toEntity: "leadgen.list", kind: "belongs-to", via: "list_id", label: "list" },
37024
- { toEntity: "leadgen.contact", kind: "has-many", via: "company_id", label: "contacts" }
37025
- ]
37026
- },
37027
- {
37028
- id: "leadgen.contact",
37029
- order: 50,
37030
- label: "Lead Contact",
37031
- description: "A prospect contact discovered or enriched during lead generation.",
37032
- ownedBySystemId: "sales.lead-gen",
37033
- table: "acq_list_members",
37034
- stateCatalogId: "lead-gen.contact",
37035
- links: [
37036
- { toEntity: "leadgen.list", kind: "belongs-to", via: "list_id", label: "list" },
37037
- { toEntity: "leadgen.company", kind: "belongs-to", via: "company_id", label: "company" }
37038
- ]
37039
- },
37040
- {
37041
- id: "delivery.project",
37042
- order: 60,
37043
- label: "Project",
37044
- description: "A client delivery project.",
37045
- ownedBySystemId: "projects",
37046
- table: "projects",
37047
- links: [
37048
- { toEntity: "delivery.milestone", kind: "has-many", via: "project_id", label: "milestones" },
37049
- { toEntity: "delivery.task", kind: "has-many", via: "project_id", label: "tasks" }
37050
- ]
37051
- },
37052
- {
37053
- id: "delivery.milestone",
37054
- order: 70,
37055
- label: "Milestone",
37056
- description: "A delivery checkpoint within a project.",
37057
- ownedBySystemId: "projects",
37058
- table: "project_milestones",
37059
- links: [
37060
- { toEntity: "delivery.project", kind: "belongs-to", via: "project_id", label: "project" },
37061
- { toEntity: "delivery.task", kind: "has-many", via: "milestone_id", label: "tasks" }
37062
- ]
37063
- },
37064
- {
37065
- id: "delivery.task",
37066
- order: 80,
37067
- label: "Task",
37068
- description: "A delivery task that can move through the task status catalog.",
37069
- ownedBySystemId: "projects",
37070
- table: "project_tasks",
37071
- stateCatalogId: "delivery.task",
37072
- links: [
37073
- { toEntity: "delivery.project", kind: "belongs-to", via: "project_id", label: "project" },
37074
- { toEntity: "delivery.milestone", kind: "belongs-to", via: "milestone_id", label: "milestone" }
37075
- ]
36711
+ var SCOPE_KIND = {
36712
+ objectTypes: "object",
36713
+ linkTypes: "link",
36714
+ actionTypes: "action",
36715
+ catalogTypes: "catalog",
36716
+ eventTypes: "event",
36717
+ interfaceTypes: "interface",
36718
+ valueTypes: "value-type",
36719
+ sharedProperties: "property",
36720
+ groups: "group",
36721
+ surfaces: "surface"
36722
+ };
36723
+ var SCOPE_KEYS = Object.keys(SCOPE_KIND);
36724
+ function ontologyGraphNodeId(id) {
36725
+ return `ontology:${OntologyIdSchema.parse(id)}`;
36726
+ }
36727
+ function listResolvedOntologyRecords(index) {
36728
+ return SCOPE_KEYS.flatMap((scopeKey) => {
36729
+ const kind = SCOPE_KIND[scopeKey];
36730
+ return Object.entries(index[scopeKey]).sort(([leftId], [rightId]) => leftId.localeCompare(rightId)).map(([id, record2]) => ({
36731
+ id,
36732
+ kind,
36733
+ record: record2
36734
+ }));
36735
+ });
36736
+ }
36737
+ function originFromContext(context) {
36738
+ return {
36739
+ kind: context.kind,
36740
+ source: context.source,
36741
+ path: context.path,
36742
+ ...context.systemPath !== void 0 ? { systemPath: context.systemPath } : {},
36743
+ ...context.legacyId !== void 0 ? { legacyId: context.legacyId } : {}
36744
+ };
36745
+ }
36746
+ function createEmptyIndex() {
36747
+ return {
36748
+ objectTypes: {},
36749
+ linkTypes: {},
36750
+ actionTypes: {},
36751
+ catalogTypes: {},
36752
+ eventTypes: {},
36753
+ interfaceTypes: {},
36754
+ valueTypes: {},
36755
+ sharedProperties: {},
36756
+ groups: {},
36757
+ surfaces: {}
36758
+ };
36759
+ }
36760
+ function sortResolvedOntologyIndex(index) {
36761
+ const sorted = createEmptyIndex();
36762
+ for (const scopeKey of SCOPE_KEYS) {
36763
+ const target = sorted[scopeKey];
36764
+ for (const [id, record2] of Object.entries(index[scopeKey]).sort(
36765
+ ([leftId], [rightId]) => leftId.localeCompare(rightId)
36766
+ )) {
36767
+ target[id] = record2;
36768
+ }
36769
+ }
36770
+ return sorted;
36771
+ }
36772
+ function childSystemsOf(system) {
36773
+ return system.systems ?? system.subsystems ?? {};
36774
+ }
36775
+ function addRecord(index, diagnostics, sourcesById, scopeKey, record2, context) {
36776
+ let parsed;
36777
+ try {
36778
+ parsed = parseOntologyId(record2.id);
36779
+ } catch {
36780
+ diagnostics.push({
36781
+ code: "invalid_ontology_id",
36782
+ message: `Invalid ontology ID "${record2.id}" from ${context.source} at ${context.path.join(".")}`,
36783
+ id: record2.id,
36784
+ path: context.path,
36785
+ source: context.source,
36786
+ origin: originFromContext(context)
36787
+ });
36788
+ return;
36789
+ }
36790
+ const expectedKind = SCOPE_KIND[scopeKey];
36791
+ if (parsed.kind !== expectedKind) {
36792
+ diagnostics.push({
36793
+ code: "ontology_kind_mismatch",
36794
+ message: `Ontology ID "${record2.id}" has kind "${parsed.kind}" but was authored in ${scopeKey} (${expectedKind}) at ${context.path.join(".")}`,
36795
+ id: record2.id,
36796
+ path: context.path,
36797
+ source: context.source,
36798
+ origin: originFromContext(context)
36799
+ });
36800
+ return;
36801
+ }
36802
+ const existing = sourcesById.get(parsed.id);
36803
+ if (existing !== void 0) {
36804
+ diagnostics.push({
36805
+ code: "duplicate_ontology_id",
36806
+ message: `Duplicate ontology ID "${parsed.id}" from ${context.source} at ${context.path.join(".")} conflicts with ${existing.source} at ${existing.path.join(".")}`,
36807
+ id: parsed.id,
36808
+ path: context.path,
36809
+ source: context.source,
36810
+ origin: originFromContext(context),
36811
+ existingSource: existing.source,
36812
+ existingOrigin: originFromContext(existing)
36813
+ });
36814
+ return;
36815
+ }
36816
+ sourcesById.set(parsed.id, context);
36817
+ index[scopeKey][parsed.id] = {
36818
+ ...record2,
36819
+ origin: originFromContext(context)
36820
+ };
36821
+ }
36822
+ function addScope(index, diagnostics, sourcesById, scope, source, path3) {
36823
+ if (scope === void 0) return;
36824
+ for (const scopeKey of SCOPE_KEYS) {
36825
+ const records = scope[scopeKey] ?? {};
36826
+ for (const [key, record2] of Object.entries(records)) {
36827
+ addRecord(index, diagnostics, sourcesById, scopeKey, record2, {
36828
+ source,
36829
+ path: [...path3, scopeKey, key],
36830
+ kind: "authored",
36831
+ systemPath: source.startsWith("system:") ? source.slice("system:".length, -".ontology".length) : void 0
36832
+ });
36833
+ }
36834
+ }
36835
+ }
36836
+ function legacyObjectId(entity) {
36837
+ return formatOntologyId({ scope: entity.ownedBySystemId, kind: "object", localId: entity.id });
36838
+ }
36839
+ function legacyActionOwner(action, entities) {
36840
+ const firstAffectedEntityId = action.affects?.find((entityId) => entities[entityId] !== void 0);
36841
+ if (firstAffectedEntityId !== void 0) {
36842
+ return entities[firstAffectedEntityId].ownedBySystemId;
36843
+ }
36844
+ if (typeof action.scope === "object") {
36845
+ return action.scope.domain;
36846
+ }
36847
+ return "global";
36848
+ }
36849
+ function addLegacyEntityProjections(index, diagnostics, sourcesById, entities) {
36850
+ for (const entity of Object.values(entities)) {
36851
+ const objectType = {
36852
+ id: legacyObjectId(entity),
36853
+ label: entity.label,
36854
+ description: entity.description,
36855
+ ownerSystemId: entity.ownedBySystemId,
36856
+ ...entity.table !== void 0 ? {
36857
+ storage: {
36858
+ kind: "table",
36859
+ table: entity.table
36860
+ }
36861
+ } : {},
36862
+ ...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
36863
+ ...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
36864
+ };
36865
+ addRecord(index, diagnostics, sourcesById, "objectTypes", objectType, {
36866
+ source: "legacy.entities",
36867
+ path: ["entities", entity.id],
36868
+ kind: "projected",
36869
+ systemPath: entity.ownedBySystemId,
36870
+ legacyId: entity.id
36871
+ });
36872
+ entity.links?.forEach((link, linkIndex) => {
36873
+ const targetEntity = entities[link.toEntity];
36874
+ if (targetEntity === void 0) return;
36875
+ const linkType = {
36876
+ id: formatOntologyId({
36877
+ scope: entity.ownedBySystemId,
36878
+ kind: "link",
36879
+ localId: `${entity.id}-${link.toEntity}-${linkIndex}`
36880
+ }),
36881
+ label: link.label ?? link.kind,
36882
+ ownerSystemId: entity.ownedBySystemId,
36883
+ from: legacyObjectId(entity),
36884
+ to: legacyObjectId(targetEntity),
36885
+ cardinality: link.kind,
36886
+ ...link.via !== void 0 ? { via: link.via } : {}
36887
+ };
36888
+ addRecord(index, diagnostics, sourcesById, "linkTypes", linkType, {
36889
+ source: "legacy.entities.links",
36890
+ path: ["entities", entity.id, "links", linkIndex],
36891
+ kind: "projected",
36892
+ systemPath: entity.ownedBySystemId,
36893
+ legacyId: `${entity.id}.links.${linkIndex}`
36894
+ });
36895
+ });
36896
+ }
36897
+ }
36898
+ function addLegacyActionProjections(index, diagnostics, sourcesById, actions, entities) {
36899
+ for (const action of Object.values(actions)) {
36900
+ const ownerSystemId = legacyActionOwner(action, entities);
36901
+ const actionType = {
36902
+ id: formatOntologyId({ scope: ownerSystemId, kind: "action", localId: action.id }),
36903
+ label: action.label,
36904
+ description: action.description,
36905
+ ownerSystemId,
36906
+ actsOn: action.affects?.map((entityId) => entities[entityId] ? legacyObjectId(entities[entityId]) : void 0).filter((id) => id !== void 0),
36907
+ ...action.resourceId !== void 0 ? { resourceId: action.resourceId } : {},
36908
+ ...action.invocations !== void 0 ? { invocations: action.invocations } : {},
36909
+ ...action.lifecycle !== void 0 ? { lifecycle: action.lifecycle } : {},
36910
+ legacyActionId: action.id
36911
+ };
36912
+ addRecord(index, diagnostics, sourcesById, "actionTypes", actionType, {
36913
+ source: "legacy.actions",
36914
+ path: ["actions", action.id],
36915
+ kind: "projected",
36916
+ systemPath: ownerSystemId,
36917
+ legacyId: action.id
36918
+ });
36919
+ }
36920
+ }
36921
+ function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schemaPath) {
36922
+ for (const [key, system] of Object.entries(systems)) {
36923
+ const systemPath = prefix ? `${prefix}.${key}` : key;
36924
+ const currentPath = [...schemaPath, key];
36925
+ addScope(index, diagnostics, sourcesById, system.ontology, `system:${systemPath}.ontology`, [
36926
+ ...currentPath,
36927
+ "ontology"
36928
+ ]);
36929
+ addSystemScopes(index, diagnostics, sourcesById, childSystemsOf(system), systemPath, [
36930
+ ...currentPath,
36931
+ system.systems !== void 0 ? "systems" : "subsystems"
36932
+ ]);
36933
+ }
36934
+ }
36935
+ function compileOrganizationOntology(model) {
36936
+ const ontology = createEmptyIndex();
36937
+ const diagnostics = [];
36938
+ const sourcesById = /* @__PURE__ */ new Map();
36939
+ addScope(ontology, diagnostics, sourcesById, model.ontology, "organization.ontology", ["ontology"]);
36940
+ addSystemScopes(ontology, diagnostics, sourcesById, model.systems ?? {}, "", ["systems"]);
36941
+ addLegacyEntityProjections(ontology, diagnostics, sourcesById, model.entities ?? {});
36942
+ addLegacyActionProjections(ontology, diagnostics, sourcesById, model.actions ?? {}, model.entities ?? {});
36943
+ return { ontology: sortResolvedOntologyIndex(ontology), diagnostics };
36944
+ }
36945
+
36946
+ // ../core/src/organization-model/helpers.ts
36947
+ function childSystemsOf2(system) {
36948
+ return system.systems ?? system.subsystems ?? {};
36949
+ }
36950
+ function getSystem(model, path3) {
36951
+ const segments = path3.split(".");
36952
+ let current = model.systems;
36953
+ let node;
36954
+ for (const seg of segments) {
36955
+ node = current[seg];
36956
+ if (node === void 0) return void 0;
36957
+ current = childSystemsOf2(node);
36958
+ }
36959
+ return node;
36960
+ }
36961
+ function listAllSystems(model) {
36962
+ const results = [];
36963
+ function walk(map2, prefix) {
36964
+ for (const [localId2, system] of Object.entries(map2)) {
36965
+ const fullPath = prefix ? `${prefix}.${localId2}` : localId2;
36966
+ results.push({ path: fullPath, system });
36967
+ const childSystems = childSystemsOf2(system);
36968
+ if (Object.keys(childSystems).length > 0) {
36969
+ walk(childSystems, fullPath);
36970
+ }
36971
+ }
36972
+ }
36973
+ walk(model.systems, "");
36974
+ return results;
36975
+ }
36976
+
36977
+ // ../core/src/organization-model/cross-ref.ts
36978
+ var ONTOLOGY_REFERENCE_KEY_KINDS = {
36979
+ valueType: "value-type",
36980
+ catalogType: "catalog",
36981
+ objectType: "object",
36982
+ eventType: "event",
36983
+ actionType: "action",
36984
+ linkType: "link",
36985
+ interfaceType: "interface",
36986
+ propertyType: "property",
36987
+ groupType: "group",
36988
+ surfaceType: "surface",
36989
+ stepCatalog: "catalog"
36990
+ };
36991
+ function buildOmCrossRefIndex(model) {
36992
+ const systemsById = /* @__PURE__ */ new Map();
36993
+ for (const { path: path3, system } of listAllSystems(model)) {
36994
+ systemsById.set(path3, system);
36995
+ systemsById.set(system.id, system);
36996
+ }
36997
+ const resourceIds = new Set(Object.keys(model.resources ?? {}));
36998
+ const knowledgeIds = new Set(Object.keys(model.knowledge ?? {}));
36999
+ const roleIds = new Set(Object.keys(model.roles ?? {}));
37000
+ const goalIds = new Set(Object.keys(model.goals ?? {}));
37001
+ const actionIds = new Set(Object.keys(model.actions ?? {}));
37002
+ const customerSegmentIds = new Set(Object.keys(model.customers ?? {}));
37003
+ const offeringIds = new Set(Object.keys(model.offerings ?? {}));
37004
+ const ontologyCompilation = compileOrganizationOntology(model);
37005
+ const ontologyIndexByKind = {
37006
+ object: ontologyCompilation.ontology.objectTypes,
37007
+ link: ontologyCompilation.ontology.linkTypes,
37008
+ action: ontologyCompilation.ontology.actionTypes,
37009
+ catalog: ontologyCompilation.ontology.catalogTypes,
37010
+ event: ontologyCompilation.ontology.eventTypes,
37011
+ interface: ontologyCompilation.ontology.interfaceTypes,
37012
+ "value-type": ontologyCompilation.ontology.valueTypes,
37013
+ property: ontologyCompilation.ontology.sharedProperties,
37014
+ group: ontologyCompilation.ontology.groups,
37015
+ surface: ontologyCompilation.ontology.surfaces
37016
+ };
37017
+ const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index) => Object.keys(index)));
37018
+ const stageIds = /* @__PURE__ */ new Set();
37019
+ for (const catalog of Object.values(ontologyCompilation.ontology.catalogTypes)) {
37020
+ if (catalog.kind !== "stage") continue;
37021
+ const entries = catalog.entries;
37022
+ if (entries !== void 0) {
37023
+ for (const stageId of Object.keys(entries)) {
37024
+ stageIds.add(stageId);
37025
+ }
37026
+ }
37076
37027
  }
37028
+ return {
37029
+ systemsById,
37030
+ resourceIds,
37031
+ knowledgeIds,
37032
+ roleIds,
37033
+ goalIds,
37034
+ actionIds,
37035
+ customerSegmentIds,
37036
+ offeringIds,
37037
+ ontologyIds,
37038
+ ontologyIndexByKind,
37039
+ stageIds
37040
+ };
37041
+ }
37042
+ function knowledgeTargetExists(index, kind, id) {
37043
+ if (kind === "system") return index.systemsById.has(id);
37044
+ if (kind === "resource") return index.resourceIds.has(id);
37045
+ if (kind === "knowledge") return index.knowledgeIds.has(id);
37046
+ if (kind === "stage") return index.stageIds.has(id);
37047
+ if (kind === "action") return index.actionIds.has(id);
37048
+ if (kind === "role") return index.roleIds.has(id);
37049
+ if (kind === "goal") return index.goalIds.has(id);
37050
+ if (kind === "customer-segment") return index.customerSegmentIds.has(id);
37051
+ if (kind === "offering") return index.offeringIds.has(id);
37052
+ if (kind === "ontology") return index.ontologyIds.has(id);
37053
+ return false;
37054
+ }
37055
+
37056
+ // ../core/src/organization-model/icons.ts
37057
+ var ORGANIZATION_MODEL_ICON_TOKENS = [
37058
+ // Navigation / app areas
37059
+ "dashboard",
37060
+ "calendar",
37061
+ "sales",
37062
+ "crm",
37063
+ "lead-gen",
37064
+ "projects",
37065
+ "clients",
37066
+ "operations",
37067
+ "monitoring",
37068
+ "knowledge",
37069
+ "settings",
37070
+ "admin",
37071
+ "archive",
37072
+ "business",
37073
+ "finance",
37074
+ "platform",
37075
+ "seo",
37076
+ // Knowledge kinds
37077
+ "playbook",
37078
+ "strategy",
37079
+ "reference",
37080
+ // Resource kinds
37081
+ "agent",
37082
+ "workflow",
37083
+ "integration",
37084
+ "database",
37085
+ "user",
37086
+ "team",
37087
+ // Integration specifics
37088
+ "gmail",
37089
+ "google-sheets",
37090
+ "attio",
37091
+ // Surface / UI views
37092
+ "overview",
37093
+ "command-view",
37094
+ "command-queue",
37095
+ "pipeline",
37096
+ "lists",
37097
+ "resources",
37098
+ // Actions
37099
+ "approve",
37100
+ "reject",
37101
+ "retry",
37102
+ "edit",
37103
+ "view",
37104
+ "launch",
37105
+ "message",
37106
+ "escalate",
37107
+ "promote",
37108
+ "submit",
37109
+ "email",
37110
+ // Status
37111
+ "success",
37112
+ "error",
37113
+ "warning",
37114
+ "info",
37115
+ "pending",
37116
+ // OM / UI group icons
37117
+ "bolt",
37118
+ "building",
37119
+ "briefcase",
37120
+ "apps",
37121
+ "graph",
37122
+ "shield",
37123
+ "users",
37124
+ "chart-bar",
37125
+ "search"
37077
37126
  ];
37078
- var DEFAULT_ORGANIZATION_MODEL_ENTITIES = Object.fromEntries(
37079
- ENTITY_ENTRY_INPUTS.map((entity) => {
37080
- const parsed = EntitySchema.parse(entity);
37081
- return [parsed.id, parsed];
37082
- })
37127
+ var CustomIconTokenSchema = external_exports.string().trim().max(80).regex(
37128
+ /^custom\.[a-z0-9]+(?:[-._][a-z0-9]+)*$/,
37129
+ 'Custom icon tokens must start with "custom." followed by lowercase alphanumeric segments'
37083
37130
  );
37084
-
37085
- // ../core/src/organization-model/domains/actions.ts
37086
- var ActionResourceIdSchema = external_exports.string().trim().min(1).max(255).regex(/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*$/, "Resource IDs must use letters, numbers, -, _, or . separators");
37087
- var ActionInvocationKindSchema = external_exports.enum(["slash-command", "mcp-tool", "api-endpoint", "script-execution"]).meta({ label: "Invocation kind" });
37088
- var ActionIdSchema = ModelIdSchema;
37089
- var ActionScopeSchema = external_exports.union([
37090
- external_exports.literal("global"),
37091
- external_exports.object({
37092
- domain: ModelIdSchema
37093
- })
37131
+ var OrganizationModelBuiltinIconTokenSchema = external_exports.enum(ORGANIZATION_MODEL_ICON_TOKENS);
37132
+ var OrganizationModelIconTokenSchema = external_exports.union([
37133
+ OrganizationModelBuiltinIconTokenSchema,
37134
+ CustomIconTokenSchema
37094
37135
  ]);
37095
- var ActionRefSchema = external_exports.object({
37096
- actionId: ActionIdSchema.meta({ ref: "action" }),
37097
- intent: external_exports.enum(["exposes", "consumes"]).meta({ label: "Intent" })
37098
- });
37099
- var SlashCommandInvocationSchema = external_exports.object({
37100
- kind: external_exports.literal("slash-command"),
37101
- command: external_exports.string().trim().min(1).max(200).regex(/^\/[^\s].*$/, "Slash commands must start with /"),
37102
- toolFactory: ModelIdSchema.optional()
37103
- });
37104
- var McpToolInvocationSchema = external_exports.object({
37105
- kind: external_exports.literal("mcp-tool"),
37106
- server: ModelIdSchema,
37107
- name: ModelIdSchema
37136
+
37137
+ // ../core/src/organization-model/domains/shared.ts
37138
+ var ModelIdSchema = external_exports.string().trim().min(1).max(100).regex(/^[a-z0-9]+(?:[-._][a-z0-9]+)*$/, "IDs must be lowercase and use -, _, or . separators");
37139
+ var LabelSchema = external_exports.string().trim().min(1).max(120);
37140
+ var DescriptionSchema = external_exports.string().trim().min(1).max(2e3);
37141
+ var ColorTokenSchema = external_exports.string().trim().min(1).max(50);
37142
+ var IconNameSchema = OrganizationModelIconTokenSchema;
37143
+ var PathSchema = external_exports.string().trim().startsWith("/").max(300);
37144
+ var ReferenceIdsSchema = external_exports.array(ModelIdSchema).default([]);
37145
+ var DisplayMetadataSchema = external_exports.object({
37146
+ label: LabelSchema,
37147
+ description: DescriptionSchema.optional(),
37148
+ color: ColorTokenSchema.optional(),
37149
+ icon: IconNameSchema.optional()
37108
37150
  });
37109
- var ApiEndpointInvocationSchema = external_exports.object({
37110
- kind: external_exports.literal("api-endpoint"),
37111
- method: external_exports.enum(["GET", "POST", "PATCH", "DELETE"]).meta({ label: "HTTP method" }),
37112
- path: external_exports.string().trim().startsWith("/").max(500),
37113
- requestSchema: ModelIdSchema.optional(),
37114
- responseSchema: ModelIdSchema.optional()
37151
+ var TechStackEntrySchema = external_exports.object({
37152
+ /** Name of the external platform (e.g. "HubSpot", "Stripe", "Notion"). */
37153
+ platform: external_exports.string().trim().min(1).max(200),
37154
+ /** Free-form description of what this integration is used for. */
37155
+ purpose: external_exports.string().trim().min(1).max(500),
37156
+ /**
37157
+ * Health of the credential backing this integration.
37158
+ * - configured: credential present and valid
37159
+ * - pending: not yet set up
37160
+ * - expired: credential existed but has lapsed
37161
+ * - missing: expected but not present
37162
+ */
37163
+ credentialStatus: external_exports.enum(["configured", "pending", "expired", "missing"]),
37164
+ /**
37165
+ * Whether this integration is the primary system of record for its domain
37166
+ * (e.g. HubSpot is SoR for contacts). Defaults to false.
37167
+ */
37168
+ isSystemOfRecord: external_exports.boolean().default(false)
37115
37169
  });
37116
- var ScriptExecutionInvocationSchema = external_exports.object({
37117
- kind: external_exports.literal("script-execution"),
37118
- resourceId: ActionResourceIdSchema
37170
+ var ResourceMappingSchema = DisplayMetadataSchema.extend({
37171
+ id: ModelIdSchema,
37172
+ resourceId: external_exports.string().trim().min(1).max(255),
37173
+ resourceType: external_exports.enum(["workflow", "agent", "trigger", "integration", "external", "human_checkpoint"]),
37174
+ systemIds: ReferenceIdsSchema,
37175
+ entityIds: ReferenceIdsSchema,
37176
+ surfaceIds: ReferenceIdsSchema,
37177
+ actionIds: ReferenceIdsSchema,
37178
+ /** Optional tech-stack metadata for external-SaaS integrations. */
37179
+ techStack: TechStackEntrySchema.optional()
37119
37180
  });
37120
- var ActionInvocationSchema = external_exports.discriminatedUnion("kind", [
37121
- SlashCommandInvocationSchema,
37122
- McpToolInvocationSchema,
37123
- ApiEndpointInvocationSchema,
37124
- ScriptExecutionInvocationSchema
37125
- ]);
37126
- var ActionSchema = external_exports.object({
37127
- id: ActionIdSchema,
37128
- /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
37129
- order: external_exports.number(),
37181
+
37182
+ // ../core/src/organization-model/domains/branding.ts
37183
+ var OrganizationModelBrandingSchema = external_exports.object({
37184
+ organizationName: LabelSchema,
37185
+ productName: LabelSchema,
37186
+ shortName: external_exports.string().trim().min(1).max(40),
37187
+ description: DescriptionSchema.optional(),
37188
+ logos: external_exports.object({
37189
+ light: external_exports.string().trim().min(1).max(2048).optional(),
37190
+ dark: external_exports.string().trim().min(1).max(2048).optional()
37191
+ }).default({})
37192
+ });
37193
+ var DEFAULT_ORGANIZATION_MODEL_BRANDING = {
37194
+ organizationName: "Default Organization",
37195
+ productName: "Organization OS",
37196
+ shortName: "Org OS",
37197
+ logos: {}
37198
+ };
37199
+
37200
+ // ../core/src/organization-model/domains/navigation.ts
37201
+ var SurfaceTypeSchema = external_exports.enum(["page", "dashboard", "graph", "detail", "list", "settings"]).meta({ label: "Surface type", color: "blue" });
37202
+ var SurfaceDefinitionSchema = external_exports.object({
37203
+ id: ModelIdSchema,
37130
37204
  label: LabelSchema,
37205
+ path: PathSchema,
37206
+ surfaceType: SurfaceTypeSchema,
37131
37207
  description: DescriptionSchema.optional(),
37132
- scope: ActionScopeSchema.default("global"),
37133
- resourceId: ActionResourceIdSchema.optional(),
37134
- affects: external_exports.array(EntityIdSchema.meta({ ref: "entity" })).optional(),
37135
- invocations: external_exports.array(ActionInvocationSchema).default([]),
37136
- knowledge: external_exports.array(ModelIdSchema.meta({ ref: "knowledge" })).default([]).optional(),
37137
- lifecycle: external_exports.enum(["draft", "beta", "active", "deprecated", "archived"]).meta({ label: "Lifecycle", color: "teal" }).default("active")
37208
+ enabled: external_exports.boolean().default(true),
37209
+ devOnly: external_exports.boolean().optional(),
37210
+ icon: IconNameSchema.optional(),
37211
+ systemIds: external_exports.array(ModelIdSchema.meta({ ref: "system" })).default([]),
37212
+ entityIds: external_exports.array(ModelIdSchema.meta({ ref: "entity" })).default([]),
37213
+ resourceIds: external_exports.array(ModelIdSchema.meta({ ref: "resource" })).default([]),
37214
+ actionIds: external_exports.array(ModelIdSchema.meta({ ref: "action" })).default([]),
37215
+ parentId: ModelIdSchema.meta({ ref: "surface" }).optional()
37138
37216
  });
37139
- var ActionsDomainSchema = external_exports.record(external_exports.string(), ActionSchema).refine((record2) => Object.entries(record2).every(([key, entry]) => entry.id === key), {
37140
- message: "Each action entry id must match its map key"
37217
+ var SidebarSurfaceTargetsSchema = external_exports.object({
37218
+ systems: external_exports.array(ModelIdSchema.meta({ ref: "system" })).default([]).optional(),
37219
+ entities: external_exports.array(ModelIdSchema.meta({ ref: "entity" })).default([]).optional(),
37220
+ resources: external_exports.array(ModelIdSchema.meta({ ref: "resource" })).default([]).optional(),
37221
+ actions: external_exports.array(ModelIdSchema.meta({ ref: "action" })).default([]).optional()
37141
37222
  }).default({});
37142
- var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {};
37143
-
37144
- // ../core/src/organization-model/ontology.ts
37145
- var OntologyKindSchema = external_exports.enum([
37146
- "object",
37147
- "link",
37148
- "action",
37149
- "catalog",
37150
- "event",
37151
- "interface",
37152
- "value-type",
37153
- "property",
37154
- "group",
37155
- "surface"
37156
- ]);
37157
- var SYSTEM_PATH_PATTERN = "[a-z0-9][a-z0-9-]*(?:\\.[a-z0-9][a-z0-9-]*)*";
37158
- var LOCAL_ID_PATTERN = "[a-z0-9][a-z0-9._-]*";
37159
- var ONTOLOGY_ID_PATTERN = `^(global|${SYSTEM_PATH_PATTERN}):(${OntologyKindSchema.options.join("|")})\\/(${LOCAL_ID_PATTERN})$`;
37160
- var ONTOLOGY_ID_REGEX = new RegExp(ONTOLOGY_ID_PATTERN);
37161
- var OntologyIdSchema = external_exports.string().trim().min(1).max(300).regex(
37162
- ONTOLOGY_ID_REGEX,
37163
- "Ontology IDs must use <system-path>:<kind>/<local-id> or global:<kind>/<local-id>"
37223
+ var SidebarNodeSchema = external_exports.lazy(
37224
+ () => external_exports.discriminatedUnion("type", [
37225
+ external_exports.object({
37226
+ type: external_exports.literal("group"),
37227
+ label: LabelSchema,
37228
+ description: DescriptionSchema.optional(),
37229
+ icon: IconNameSchema.optional(),
37230
+ order: external_exports.number().int().optional(),
37231
+ children: external_exports.record(external_exports.string(), SidebarNodeSchema).default({})
37232
+ }),
37233
+ external_exports.object({
37234
+ type: external_exports.literal("surface"),
37235
+ label: LabelSchema,
37236
+ path: PathSchema,
37237
+ surfaceType: SurfaceTypeSchema,
37238
+ description: DescriptionSchema.optional(),
37239
+ icon: IconNameSchema.optional(),
37240
+ order: external_exports.number().int().optional(),
37241
+ targets: SidebarSurfaceTargetsSchema.optional(),
37242
+ devOnly: external_exports.boolean().optional(),
37243
+ requiresAdmin: external_exports.boolean().optional()
37244
+ })
37245
+ ])
37164
37246
  );
37165
- function parseOntologyId(id) {
37166
- const normalized = OntologyIdSchema.parse(id);
37167
- const match = ONTOLOGY_ID_REGEX.exec(normalized);
37168
- if (match === null) {
37169
- throw new Error(`Invalid ontology ID "${id}"`);
37170
- }
37171
- return {
37172
- id: normalized,
37173
- scope: match[1],
37174
- kind: match[2],
37175
- localId: match[3],
37176
- isGlobal: match[1] === "global"
37177
- };
37178
- }
37179
- function formatOntologyId(input) {
37180
- return OntologyIdSchema.parse(`${input.scope}:${input.kind}/${input.localId}`);
37181
- }
37182
- var OntologyReferenceListSchema = external_exports.array(OntologyIdSchema).default([]).optional();
37183
- var OntologyRecordBaseSchema = external_exports.object({
37184
- id: OntologyIdSchema,
37185
- label: external_exports.string().trim().min(1).max(160).optional(),
37186
- description: external_exports.string().trim().min(1).max(2e3).optional(),
37187
- ownerSystemId: external_exports.string().trim().min(1).max(200).optional(),
37188
- aliases: external_exports.array(OntologyIdSchema).optional()
37189
- }).passthrough();
37190
- var OntologyObjectTypeSchema = OntologyRecordBaseSchema.extend({
37191
- properties: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional(),
37192
- storage: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
37193
- });
37194
- var OntologyLinkTypeSchema = OntologyRecordBaseSchema.extend({
37195
- from: OntologyIdSchema,
37196
- to: OntologyIdSchema,
37197
- cardinality: external_exports.string().trim().min(1).max(80).optional(),
37198
- via: external_exports.string().trim().min(1).max(255).optional()
37199
- });
37200
- var OntologyActionTypeSchema = OntologyRecordBaseSchema.extend({
37201
- actsOn: OntologyReferenceListSchema,
37202
- input: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional(),
37203
- effects: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).optional()
37204
- });
37205
- var OntologyCatalogTypeSchema = OntologyRecordBaseSchema.extend({
37206
- kind: external_exports.string().trim().min(1).max(120).optional(),
37207
- appliesTo: OntologyIdSchema.optional(),
37208
- entries: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional()
37209
- });
37210
- var OntologyEventTypeSchema = OntologyRecordBaseSchema.extend({
37211
- payload: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional()
37212
- });
37213
- var OntologyInterfaceTypeSchema = OntologyRecordBaseSchema.extend({
37214
- properties: external_exports.record(external_exports.string().trim().min(1).max(200), external_exports.unknown()).optional()
37215
- });
37216
- var OntologyValueTypeSchema = OntologyRecordBaseSchema.extend({
37217
- primitive: external_exports.string().trim().min(1).max(120).optional()
37218
- });
37219
- var OntologySharedPropertySchema = OntologyRecordBaseSchema.extend({
37220
- valueType: OntologyIdSchema.optional(),
37221
- searchable: external_exports.boolean().optional(),
37222
- pii: external_exports.boolean().optional()
37223
- });
37224
- var OntologyGroupSchema = OntologyRecordBaseSchema.extend({
37225
- members: OntologyReferenceListSchema
37247
+ var SidebarSectionSchema = external_exports.record(external_exports.string(), SidebarNodeSchema).default({});
37248
+ var SidebarNavigationSchema = external_exports.object({
37249
+ primary: SidebarSectionSchema,
37250
+ bottom: SidebarSectionSchema
37251
+ }).default({ primary: {}, bottom: {} });
37252
+ var OrganizationModelNavigationSchema = external_exports.object({
37253
+ sidebar: SidebarNavigationSchema
37254
+ }).default({ sidebar: { primary: {}, bottom: {} } });
37255
+ var NavigationGroupSchema = external_exports.object({
37256
+ id: ModelIdSchema,
37257
+ label: LabelSchema,
37258
+ placement: external_exports.string().trim().min(1).max(50),
37259
+ surfaceIds: external_exports.array(ModelIdSchema.meta({ ref: "surface" })).default([])
37226
37260
  });
37227
- var OntologySurfaceTypeSchema = OntologyRecordBaseSchema.extend({
37228
- route: external_exports.string().trim().min(1).max(500).optional()
37261
+
37262
+ // ../core/src/organization-model/domains/identity.ts
37263
+ var BusinessHoursDaySchema = external_exports.object({
37264
+ open: external_exports.string().trim().regex(/^\d{2}:\d{2}$/, "Expected HH:MM format"),
37265
+ close: external_exports.string().trim().regex(/^\d{2}:\d{2}$/, "Expected HH:MM format")
37229
37266
  });
37230
- var OntologyScopeSchema = external_exports.object({
37231
- objectTypes: external_exports.record(OntologyIdSchema, OntologyObjectTypeSchema).default({}).optional(),
37232
- linkTypes: external_exports.record(OntologyIdSchema, OntologyLinkTypeSchema).default({}).optional(),
37233
- actionTypes: external_exports.record(OntologyIdSchema, OntologyActionTypeSchema).default({}).optional(),
37234
- catalogTypes: external_exports.record(OntologyIdSchema, OntologyCatalogTypeSchema).default({}).optional(),
37235
- eventTypes: external_exports.record(OntologyIdSchema, OntologyEventTypeSchema).default({}).optional(),
37236
- interfaceTypes: external_exports.record(OntologyIdSchema, OntologyInterfaceTypeSchema).default({}).optional(),
37237
- valueTypes: external_exports.record(OntologyIdSchema, OntologyValueTypeSchema).default({}).optional(),
37238
- sharedProperties: external_exports.record(OntologyIdSchema, OntologySharedPropertySchema).default({}).optional(),
37239
- groups: external_exports.record(OntologyIdSchema, OntologyGroupSchema).default({}).optional(),
37240
- surfaces: external_exports.record(OntologyIdSchema, OntologySurfaceTypeSchema).default({}).optional()
37267
+ var BusinessHoursSchema = external_exports.object({
37268
+ monday: BusinessHoursDaySchema.optional(),
37269
+ tuesday: BusinessHoursDaySchema.optional(),
37270
+ wednesday: BusinessHoursDaySchema.optional(),
37271
+ thursday: BusinessHoursDaySchema.optional(),
37272
+ friday: BusinessHoursDaySchema.optional(),
37273
+ saturday: BusinessHoursDaySchema.optional(),
37274
+ sunday: BusinessHoursDaySchema.optional()
37241
37275
  }).default({});
37242
- var DEFAULT_ONTOLOGY_SCOPE = {
37243
- valueTypes: {
37244
- "global:value-type/uuid": {
37245
- id: "global:value-type/uuid",
37246
- label: "UUID",
37247
- primitive: "string"
37248
- },
37249
- "global:value-type/text": {
37250
- id: "global:value-type/text",
37251
- label: "Text",
37252
- primitive: "string"
37253
- },
37254
- "global:value-type/url": {
37255
- id: "global:value-type/url",
37256
- label: "URL",
37257
- primitive: "string"
37258
- },
37259
- "global:value-type/email": {
37260
- id: "global:value-type/email",
37261
- label: "Email",
37262
- primitive: "string"
37263
- }
37264
- }
37265
- };
37266
- var SCOPE_KIND = {
37267
- objectTypes: "object",
37268
- linkTypes: "link",
37269
- actionTypes: "action",
37270
- catalogTypes: "catalog",
37271
- eventTypes: "event",
37272
- interfaceTypes: "interface",
37273
- valueTypes: "value-type",
37274
- sharedProperties: "property",
37275
- groups: "group",
37276
- surfaces: "surface"
37276
+ var IdentityDomainSchema = external_exports.object({
37277
+ /** Why the organization exists — one or two plain-language sentences. */
37278
+ mission: external_exports.string().trim().max(1e3).default(""),
37279
+ /** Long-term direction the organization is moving toward. */
37280
+ vision: external_exports.string().trim().max(1e3).default(""),
37281
+ /** Legal registered name of the entity. */
37282
+ legalName: external_exports.string().trim().max(200).default(""),
37283
+ /**
37284
+ * Type of legal entity (e.g. "LLC", "Corporation", "Sole Proprietor",
37285
+ * "Non-profit"). Free-form string so it covers any jurisdiction.
37286
+ */
37287
+ entityType: external_exports.string().trim().max(100).default(""),
37288
+ /**
37289
+ * Primary jurisdiction of registration or operation
37290
+ * (e.g. "United States – Delaware", "Canada – Ontario").
37291
+ */
37292
+ jurisdiction: external_exports.string().trim().max(200).default(""),
37293
+ /**
37294
+ * Industry category — broad classification (e.g. "Marketing Agency",
37295
+ * "Software / SaaS", "Professional Services").
37296
+ */
37297
+ industryCategory: external_exports.string().trim().max(200).default(""),
37298
+ /**
37299
+ * Geographic focus — where the organization primarily operates or serves
37300
+ * (e.g. "North America", "Global", "Southeast Asia").
37301
+ */
37302
+ geographicFocus: external_exports.string().trim().max(200).default(""),
37303
+ /**
37304
+ * IANA timezone identifier for the organization's primary operating timezone
37305
+ * (e.g. "America/Los_Angeles", "Europe/London", "UTC").
37306
+ */
37307
+ timeZone: external_exports.string().trim().max(100).default("UTC"),
37308
+ /** Typical operating hours per day of week. Empty object means not configured. */
37309
+ businessHours: BusinessHoursSchema,
37310
+ /**
37311
+ * Long-form markdown capturing client context, problem narrative, and domain
37312
+ * background. Populated by /setup; surfaced to agents as organizational context.
37313
+ * Optional — many projects have no external client.
37314
+ */
37315
+ clientBrief: external_exports.string().trim().default("")
37316
+ });
37317
+ var DEFAULT_ORGANIZATION_MODEL_IDENTITY = {
37318
+ mission: "",
37319
+ vision: "",
37320
+ legalName: "",
37321
+ entityType: "",
37322
+ jurisdiction: "",
37323
+ industryCategory: "",
37324
+ geographicFocus: "",
37325
+ timeZone: "UTC",
37326
+ businessHours: {},
37327
+ clientBrief: ""
37277
37328
  };
37278
- var SCOPE_KEYS = Object.keys(SCOPE_KIND);
37279
- function ontologyGraphNodeId(id) {
37280
- return `ontology:${OntologyIdSchema.parse(id)}`;
37281
- }
37282
- function listResolvedOntologyRecords(index) {
37283
- return SCOPE_KEYS.flatMap((scopeKey) => {
37284
- const kind = SCOPE_KIND[scopeKey];
37285
- return Object.entries(index[scopeKey]).sort(([leftId], [rightId]) => leftId.localeCompare(rightId)).map(([id, record2]) => ({
37286
- id,
37287
- kind,
37288
- record: record2
37289
- }));
37290
- });
37291
- }
37292
- function originFromContext(context) {
37293
- return {
37294
- kind: context.kind,
37295
- source: context.source,
37296
- path: context.path,
37297
- ...context.systemPath !== void 0 ? { systemPath: context.systemPath } : {},
37298
- ...context.legacyId !== void 0 ? { legacyId: context.legacyId } : {}
37299
- };
37300
- }
37301
- function createEmptyIndex() {
37302
- return {
37303
- objectTypes: {},
37304
- linkTypes: {},
37305
- actionTypes: {},
37306
- catalogTypes: {},
37307
- eventTypes: {},
37308
- interfaceTypes: {},
37309
- valueTypes: {},
37310
- sharedProperties: {},
37311
- groups: {},
37312
- surfaces: {}
37313
- };
37314
- }
37315
- function sortResolvedOntologyIndex(index) {
37316
- const sorted = createEmptyIndex();
37317
- for (const scopeKey of SCOPE_KEYS) {
37318
- const target = sorted[scopeKey];
37319
- for (const [id, record2] of Object.entries(index[scopeKey]).sort(
37320
- ([leftId], [rightId]) => leftId.localeCompare(rightId)
37321
- )) {
37322
- target[id] = record2;
37323
- }
37324
- }
37325
- return sorted;
37326
- }
37327
- function childSystemsOf(system) {
37328
- return system.systems ?? system.subsystems ?? {};
37329
- }
37330
- function addRecord(index, diagnostics, sourcesById, scopeKey, record2, context) {
37331
- let parsed;
37332
- try {
37333
- parsed = parseOntologyId(record2.id);
37334
- } catch {
37335
- diagnostics.push({
37336
- code: "invalid_ontology_id",
37337
- message: `Invalid ontology ID "${record2.id}" from ${context.source} at ${context.path.join(".")}`,
37338
- id: record2.id,
37339
- path: context.path,
37340
- source: context.source,
37341
- origin: originFromContext(context)
37342
- });
37343
- return;
37344
- }
37345
- const expectedKind = SCOPE_KIND[scopeKey];
37346
- if (parsed.kind !== expectedKind) {
37347
- diagnostics.push({
37348
- code: "ontology_kind_mismatch",
37349
- message: `Ontology ID "${record2.id}" has kind "${parsed.kind}" but was authored in ${scopeKey} (${expectedKind}) at ${context.path.join(".")}`,
37350
- id: record2.id,
37351
- path: context.path,
37352
- source: context.source,
37353
- origin: originFromContext(context)
37354
- });
37355
- return;
37356
- }
37357
- const existing = sourcesById.get(parsed.id);
37358
- if (existing !== void 0) {
37359
- diagnostics.push({
37360
- code: "duplicate_ontology_id",
37361
- message: `Duplicate ontology ID "${parsed.id}" from ${context.source} at ${context.path.join(".")} conflicts with ${existing.source} at ${existing.path.join(".")}`,
37362
- id: parsed.id,
37363
- path: context.path,
37364
- source: context.source,
37365
- origin: originFromContext(context),
37366
- existingSource: existing.source,
37367
- existingOrigin: originFromContext(existing)
37368
- });
37369
- return;
37370
- }
37371
- sourcesById.set(parsed.id, context);
37372
- index[scopeKey][parsed.id] = {
37373
- ...record2,
37374
- origin: originFromContext(context)
37375
- };
37376
- }
37377
- function addScope(index, diagnostics, sourcesById, scope, source, path3) {
37378
- if (scope === void 0) return;
37379
- for (const scopeKey of SCOPE_KEYS) {
37380
- const records = scope[scopeKey] ?? {};
37381
- for (const [key, record2] of Object.entries(records)) {
37382
- addRecord(index, diagnostics, sourcesById, scopeKey, record2, {
37383
- source,
37384
- path: [...path3, scopeKey, key],
37385
- kind: "authored",
37386
- systemPath: source.startsWith("system:") ? source.slice("system:".length, -".ontology".length) : void 0
37387
- });
37388
- }
37389
- }
37390
- }
37391
- function legacyObjectId(entity) {
37392
- return formatOntologyId({ scope: entity.ownedBySystemId, kind: "object", localId: entity.id });
37393
- }
37394
- function legacyActionOwner(action, entities) {
37395
- const firstAffectedEntityId = action.affects?.find((entityId) => entities[entityId] !== void 0);
37396
- if (firstAffectedEntityId !== void 0) {
37397
- return entities[firstAffectedEntityId].ownedBySystemId;
37398
- }
37399
- if (typeof action.scope === "object") {
37400
- return action.scope.domain;
37401
- }
37402
- return "global";
37403
- }
37404
- function addLegacyEntityProjections(index, diagnostics, sourcesById, entities) {
37405
- for (const entity of Object.values(entities)) {
37406
- const objectType = {
37407
- id: legacyObjectId(entity),
37408
- label: entity.label,
37409
- description: entity.description,
37410
- ownerSystemId: entity.ownedBySystemId,
37411
- ...entity.table !== void 0 ? {
37412
- storage: {
37413
- kind: "table",
37414
- table: entity.table
37415
- }
37416
- } : {},
37417
- ...entity.rowSchema !== void 0 ? { rowSchema: entity.rowSchema } : {},
37418
- ...entity.stateCatalogId !== void 0 ? { stateCatalogId: entity.stateCatalogId } : {}
37419
- };
37420
- addRecord(index, diagnostics, sourcesById, "objectTypes", objectType, {
37421
- source: "legacy.entities",
37422
- path: ["entities", entity.id],
37423
- kind: "projected",
37424
- systemPath: entity.ownedBySystemId,
37425
- legacyId: entity.id
37426
- });
37427
- entity.links?.forEach((link, linkIndex) => {
37428
- const targetEntity = entities[link.toEntity];
37429
- if (targetEntity === void 0) return;
37430
- const linkType = {
37431
- id: formatOntologyId({
37432
- scope: entity.ownedBySystemId,
37433
- kind: "link",
37434
- localId: `${entity.id}-${link.toEntity}-${linkIndex}`
37435
- }),
37436
- label: link.label ?? link.kind,
37437
- ownerSystemId: entity.ownedBySystemId,
37438
- from: legacyObjectId(entity),
37439
- to: legacyObjectId(targetEntity),
37440
- cardinality: link.kind,
37441
- ...link.via !== void 0 ? { via: link.via } : {}
37442
- };
37443
- addRecord(index, diagnostics, sourcesById, "linkTypes", linkType, {
37444
- source: "legacy.entities.links",
37445
- path: ["entities", entity.id, "links", linkIndex],
37446
- kind: "projected",
37447
- systemPath: entity.ownedBySystemId,
37448
- legacyId: `${entity.id}.links.${linkIndex}`
37449
- });
37450
- });
37451
- }
37452
- }
37453
- function addLegacyActionProjections(index, diagnostics, sourcesById, actions, entities) {
37454
- for (const action of Object.values(actions)) {
37455
- const ownerSystemId = legacyActionOwner(action, entities);
37456
- const actionType = {
37457
- id: formatOntologyId({ scope: ownerSystemId, kind: "action", localId: action.id }),
37458
- label: action.label,
37459
- description: action.description,
37460
- ownerSystemId,
37461
- actsOn: action.affects?.map((entityId) => entities[entityId] ? legacyObjectId(entities[entityId]) : void 0).filter((id) => id !== void 0),
37462
- ...action.resourceId !== void 0 ? { resourceId: action.resourceId } : {},
37463
- ...action.invocations !== void 0 ? { invocations: action.invocations } : {},
37464
- ...action.lifecycle !== void 0 ? { lifecycle: action.lifecycle } : {},
37465
- legacyActionId: action.id
37466
- };
37467
- addRecord(index, diagnostics, sourcesById, "actionTypes", actionType, {
37468
- source: "legacy.actions",
37469
- path: ["actions", action.id],
37470
- kind: "projected",
37471
- systemPath: ownerSystemId,
37472
- legacyId: action.id
37473
- });
37474
- }
37475
- }
37476
- function addSystemScopes(index, diagnostics, sourcesById, systems, prefix, schemaPath) {
37477
- for (const [key, system] of Object.entries(systems)) {
37478
- const systemPath = prefix ? `${prefix}.${key}` : key;
37479
- const currentPath = [...schemaPath, key];
37480
- addScope(index, diagnostics, sourcesById, system.ontology, `system:${systemPath}.ontology`, [
37481
- ...currentPath,
37482
- "ontology"
37483
- ]);
37484
- addSystemScopes(index, diagnostics, sourcesById, childSystemsOf(system), systemPath, [
37485
- ...currentPath,
37486
- system.systems !== void 0 ? "systems" : "subsystems"
37487
- ]);
37329
+
37330
+ // ../core/src/organization-model/domains/customers.ts
37331
+ var FirmographicsSchema = external_exports.object({
37332
+ /** Industry vertical (e.g. "Marketing Agency", "Legal", "Real Estate"). */
37333
+ industry: external_exports.string().trim().max(200).optional(),
37334
+ /**
37335
+ * Company headcount band (e.g. "1–10", "11–50", "51–200", "200+").
37336
+ * Free-form string to accommodate any band notation.
37337
+ */
37338
+ companySize: external_exports.string().trim().max(100).optional(),
37339
+ /**
37340
+ * Primary geographic region the segment operates in or is targeted from
37341
+ * (e.g. "North America", "Europe", "Global").
37342
+ */
37343
+ region: external_exports.string().trim().max(200).optional()
37344
+ });
37345
+ var CustomerSegmentSchema = external_exports.object({
37346
+ /** Stable unique identifier for the segment (e.g. "segment-smb-agencies"). */
37347
+ id: external_exports.string().trim().min(1).max(100),
37348
+ /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
37349
+ order: external_exports.number(),
37350
+ /** Human-readable name shown to agents and in UI (e.g. "SMB Marketing Agencies"). */
37351
+ name: external_exports.string().trim().max(200).default(""),
37352
+ /** One or two sentences describing who this segment is. */
37353
+ description: external_exports.string().trim().max(2e3).default(""),
37354
+ /**
37355
+ * The primary job(s) this segment is trying to get done — the goal they hire
37356
+ * a product/service to accomplish. Plain-language narrative or bullet list.
37357
+ */
37358
+ jobsToBeDone: external_exports.string().trim().max(2e3).default(""),
37359
+ /**
37360
+ * Pains — frustrations, obstacles, and risks the segment experiences
37361
+ * when trying to accomplish their jobs-to-be-done.
37362
+ */
37363
+ pains: external_exports.array(external_exports.string().trim().max(500)).default([]),
37364
+ /**
37365
+ * Gains — outcomes and benefits the segment desires; positive motivators
37366
+ * beyond merely resolving pains.
37367
+ */
37368
+ gains: external_exports.array(external_exports.string().trim().max(500)).default([]),
37369
+ /** Firmographic profile for targeting and filtering. */
37370
+ firmographics: FirmographicsSchema.default({}),
37371
+ /**
37372
+ * Value proposition — one or two sentences stating why this organization's
37373
+ * offering is uniquely suited for this segment's needs.
37374
+ */
37375
+ valueProp: external_exports.string().trim().max(2e3).default("")
37376
+ });
37377
+ var CustomersDomainSchema = external_exports.record(external_exports.string(), CustomerSegmentSchema).refine((record2) => Object.entries(record2).every(([key, entry]) => entry.id === key), {
37378
+ message: "Each segment entry id must match its map key"
37379
+ }).default({});
37380
+ var DEFAULT_ORGANIZATION_MODEL_CUSTOMERS = {};
37381
+
37382
+ // ../core/src/organization-model/domains/offerings.ts
37383
+ var PricingModelSchema = external_exports.enum(["one-time", "subscription", "usage-based", "custom"]).meta({ label: "Pricing model", color: "green" });
37384
+ var ProductSchema = external_exports.object({
37385
+ /** Stable unique identifier for the product (e.g. "product-starter-plan"). */
37386
+ id: external_exports.string().trim().min(1).max(100),
37387
+ /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
37388
+ order: external_exports.number(),
37389
+ /** Human-readable name shown to agents and in UI (e.g. "Starter Plan"). */
37390
+ name: external_exports.string().trim().max(200).default(""),
37391
+ /** One or two sentences describing what this product/service delivers. */
37392
+ description: external_exports.string().trim().max(2e3).default(""),
37393
+ /**
37394
+ * How this product is priced:
37395
+ * - "one-time" — single purchase (setup fee, project fee)
37396
+ * - "subscription" — recurring (monthly/annual SaaS, retainer)
37397
+ * - "usage-based" — metered by consumption (API calls, seats)
37398
+ * - "custom" — negotiated or bespoke pricing
37399
+ */
37400
+ pricingModel: PricingModelSchema.default("custom"),
37401
+ /** Base price amount (≥ 0). Currency unit defined by `currency`. */
37402
+ price: external_exports.number().min(0).default(0),
37403
+ /**
37404
+ * ISO 4217 currency code (e.g. "USD", "EUR", "GBP").
37405
+ * Free-form string to accommodate any currency; defaults to "USD".
37406
+ */
37407
+ currency: external_exports.string().trim().max(10).default("USD"),
37408
+ /**
37409
+ * IDs of customer segments this product targets.
37410
+ * Each id must reference a declared `customers.segments[].id`.
37411
+ * Cross-reference enforced in `OrganizationModelSchema.superRefine()`.
37412
+ */
37413
+ targetSegmentIds: external_exports.array(external_exports.string().trim().min(1)).default([]),
37414
+ /**
37415
+ * Optional: ID of the platform system responsible for delivering this product.
37416
+ * When present, must reference a declared `systems.systems[].id`.
37417
+ * Cross-reference enforced in `OrganizationModelSchema.superRefine()`.
37418
+ */
37419
+ deliveryFeatureId: external_exports.string().trim().min(1).optional()
37420
+ });
37421
+ var OfferingsDomainSchema = external_exports.record(external_exports.string(), ProductSchema).refine((record2) => Object.entries(record2).every(([key, entry]) => entry.id === key), {
37422
+ message: "Each product entry id must match its map key"
37423
+ }).default({});
37424
+ var DEFAULT_ORGANIZATION_MODEL_OFFERINGS = {};
37425
+
37426
+ // ../core/src/organization-model/domains/entities.ts
37427
+ var EntityIdSchema = ModelIdSchema;
37428
+ var EntityLinkKindSchema = external_exports.enum(["belongs-to", "has-many", "has-one", "many-to-many"]).meta({ label: "Link kind" });
37429
+ var EntityLinkSchema = external_exports.object({
37430
+ toEntity: EntityIdSchema.meta({ ref: "entity" }),
37431
+ kind: EntityLinkKindSchema,
37432
+ via: external_exports.string().trim().min(1).max(255).optional(),
37433
+ label: LabelSchema.optional()
37434
+ });
37435
+ var EntitySchema = external_exports.object({
37436
+ id: EntityIdSchema,
37437
+ /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
37438
+ order: external_exports.number(),
37439
+ label: LabelSchema,
37440
+ description: DescriptionSchema.optional(),
37441
+ ownedBySystemId: ModelIdSchema.meta({ ref: "system" }),
37442
+ table: external_exports.string().trim().min(1).max(255).optional(),
37443
+ rowSchema: ModelIdSchema.optional(),
37444
+ stateCatalogId: ModelIdSchema.optional(),
37445
+ links: external_exports.array(EntityLinkSchema).optional()
37446
+ });
37447
+ var EntitiesDomainSchema = external_exports.record(external_exports.string(), EntitySchema).refine((record2) => Object.entries(record2).every(([key, entry]) => entry.id === key), {
37448
+ message: "Each entity entry id must match its map key"
37449
+ }).default({});
37450
+ var ENTITY_ENTRY_INPUTS = [
37451
+ {
37452
+ id: "crm.deal",
37453
+ order: 10,
37454
+ label: "Deal",
37455
+ description: "A CRM opportunity or sales pipeline record.",
37456
+ ownedBySystemId: "sales.crm",
37457
+ table: "crm_deals",
37458
+ stateCatalogId: "crm.pipeline",
37459
+ links: [{ toEntity: "crm.contact", kind: "has-many", via: "deal_contacts", label: "contacts" }]
37460
+ },
37461
+ {
37462
+ id: "crm.contact",
37463
+ order: 20,
37464
+ label: "CRM Contact",
37465
+ description: "A person associated with a CRM relationship or deal.",
37466
+ ownedBySystemId: "sales.crm",
37467
+ table: "crm_contacts"
37468
+ },
37469
+ {
37470
+ id: "leadgen.list",
37471
+ order: 30,
37472
+ label: "Lead List",
37473
+ description: "A prospecting list that groups companies and contacts for acquisition workflows.",
37474
+ ownedBySystemId: "sales.lead-gen",
37475
+ table: "acq_lists",
37476
+ links: [
37477
+ { toEntity: "leadgen.company", kind: "has-many", via: "acq_list_companies", label: "companies" },
37478
+ { toEntity: "leadgen.contact", kind: "has-many", via: "acq_list_members", label: "contacts" }
37479
+ ]
37480
+ },
37481
+ {
37482
+ id: "leadgen.company",
37483
+ order: 40,
37484
+ label: "Lead Company",
37485
+ description: "A company record sourced, enriched, and qualified during prospecting.",
37486
+ ownedBySystemId: "sales.lead-gen",
37487
+ table: "acq_list_companies",
37488
+ stateCatalogId: "lead-gen.company",
37489
+ links: [
37490
+ { toEntity: "leadgen.list", kind: "belongs-to", via: "list_id", label: "list" },
37491
+ { toEntity: "leadgen.contact", kind: "has-many", via: "company_id", label: "contacts" }
37492
+ ]
37493
+ },
37494
+ {
37495
+ id: "leadgen.contact",
37496
+ order: 50,
37497
+ label: "Lead Contact",
37498
+ description: "A prospect contact discovered or enriched during lead generation.",
37499
+ ownedBySystemId: "sales.lead-gen",
37500
+ table: "acq_list_members",
37501
+ stateCatalogId: "lead-gen.contact",
37502
+ links: [
37503
+ { toEntity: "leadgen.list", kind: "belongs-to", via: "list_id", label: "list" },
37504
+ { toEntity: "leadgen.company", kind: "belongs-to", via: "company_id", label: "company" }
37505
+ ]
37506
+ },
37507
+ {
37508
+ id: "delivery.project",
37509
+ order: 60,
37510
+ label: "Project",
37511
+ description: "A client delivery project.",
37512
+ ownedBySystemId: "projects",
37513
+ table: "projects",
37514
+ links: [
37515
+ { toEntity: "delivery.milestone", kind: "has-many", via: "project_id", label: "milestones" },
37516
+ { toEntity: "delivery.task", kind: "has-many", via: "project_id", label: "tasks" }
37517
+ ]
37518
+ },
37519
+ {
37520
+ id: "delivery.milestone",
37521
+ order: 70,
37522
+ label: "Milestone",
37523
+ description: "A delivery checkpoint within a project.",
37524
+ ownedBySystemId: "projects",
37525
+ table: "project_milestones",
37526
+ links: [
37527
+ { toEntity: "delivery.project", kind: "belongs-to", via: "project_id", label: "project" },
37528
+ { toEntity: "delivery.task", kind: "has-many", via: "milestone_id", label: "tasks" }
37529
+ ]
37530
+ },
37531
+ {
37532
+ id: "delivery.task",
37533
+ order: 80,
37534
+ label: "Task",
37535
+ description: "A delivery task that can move through the task status catalog.",
37536
+ ownedBySystemId: "projects",
37537
+ table: "project_tasks",
37538
+ stateCatalogId: "delivery.task",
37539
+ links: [
37540
+ { toEntity: "delivery.project", kind: "belongs-to", via: "project_id", label: "project" },
37541
+ { toEntity: "delivery.milestone", kind: "belongs-to", via: "milestone_id", label: "milestone" }
37542
+ ]
37488
37543
  }
37489
- }
37490
- function compileOrganizationOntology(model) {
37491
- const ontology = createEmptyIndex();
37492
- const diagnostics = [];
37493
- const sourcesById = /* @__PURE__ */ new Map();
37494
- addScope(ontology, diagnostics, sourcesById, model.ontology, "organization.ontology", ["ontology"]);
37495
- addSystemScopes(ontology, diagnostics, sourcesById, model.systems ?? {}, "", ["systems"]);
37496
- addLegacyEntityProjections(ontology, diagnostics, sourcesById, model.entities ?? {});
37497
- addLegacyActionProjections(ontology, diagnostics, sourcesById, model.actions ?? {}, model.entities ?? {});
37498
- return { ontology: sortResolvedOntologyIndex(ontology), diagnostics };
37499
- }
37544
+ ];
37545
+ var DEFAULT_ORGANIZATION_MODEL_ENTITIES = Object.fromEntries(
37546
+ ENTITY_ENTRY_INPUTS.map((entity) => {
37547
+ const parsed = EntitySchema.parse(entity);
37548
+ return [parsed.id, parsed];
37549
+ })
37550
+ );
37551
+
37552
+ // ../core/src/organization-model/domains/actions.ts
37553
+ var ActionResourceIdSchema = external_exports.string().trim().min(1).max(255).regex(/^[A-Za-z0-9]+(?:[-._][A-Za-z0-9]+)*$/, "Resource IDs must use letters, numbers, -, _, or . separators");
37554
+ var ActionInvocationKindSchema = external_exports.enum(["slash-command", "mcp-tool", "api-endpoint", "script-execution"]).meta({ label: "Invocation kind" });
37555
+ var ActionIdSchema = ModelIdSchema;
37556
+ var ActionScopeSchema = external_exports.union([
37557
+ external_exports.literal("global"),
37558
+ external_exports.object({
37559
+ domain: ModelIdSchema
37560
+ })
37561
+ ]);
37562
+ var ActionRefSchema = external_exports.object({
37563
+ actionId: ActionIdSchema.meta({ ref: "action" }),
37564
+ intent: external_exports.enum(["exposes", "consumes"]).meta({ label: "Intent" })
37565
+ });
37566
+ var SlashCommandInvocationSchema = external_exports.object({
37567
+ kind: external_exports.literal("slash-command"),
37568
+ command: external_exports.string().trim().min(1).max(200).regex(/^\/[^\s].*$/, "Slash commands must start with /"),
37569
+ toolFactory: ModelIdSchema.optional()
37570
+ });
37571
+ var McpToolInvocationSchema = external_exports.object({
37572
+ kind: external_exports.literal("mcp-tool"),
37573
+ server: ModelIdSchema,
37574
+ name: ModelIdSchema
37575
+ });
37576
+ var ApiEndpointInvocationSchema = external_exports.object({
37577
+ kind: external_exports.literal("api-endpoint"),
37578
+ method: external_exports.enum(["GET", "POST", "PATCH", "DELETE"]).meta({ label: "HTTP method" }),
37579
+ path: external_exports.string().trim().startsWith("/").max(500),
37580
+ requestSchema: ModelIdSchema.optional(),
37581
+ responseSchema: ModelIdSchema.optional()
37582
+ });
37583
+ var ScriptExecutionInvocationSchema = external_exports.object({
37584
+ kind: external_exports.literal("script-execution"),
37585
+ resourceId: ActionResourceIdSchema
37586
+ });
37587
+ var ActionInvocationSchema = external_exports.discriminatedUnion("kind", [
37588
+ SlashCommandInvocationSchema,
37589
+ McpToolInvocationSchema,
37590
+ ApiEndpointInvocationSchema,
37591
+ ScriptExecutionInvocationSchema
37592
+ ]);
37593
+ var ActionSchema = external_exports.object({
37594
+ id: ActionIdSchema,
37595
+ /** Domain-map iteration order. Convention: multiples of 10 (10, 20, 30, ...) to allow easy insertion. */
37596
+ order: external_exports.number(),
37597
+ label: LabelSchema,
37598
+ description: DescriptionSchema.optional(),
37599
+ scope: ActionScopeSchema.default("global"),
37600
+ resourceId: ActionResourceIdSchema.optional(),
37601
+ affects: external_exports.array(EntityIdSchema.meta({ ref: "entity" })).optional(),
37602
+ invocations: external_exports.array(ActionInvocationSchema).default([]),
37603
+ knowledge: external_exports.array(ModelIdSchema.meta({ ref: "knowledge" })).default([]).optional(),
37604
+ lifecycle: external_exports.enum(["draft", "beta", "active", "deprecated", "archived"]).meta({ label: "Lifecycle", color: "teal" }).default("active")
37605
+ });
37606
+ var ActionsDomainSchema = external_exports.record(external_exports.string(), ActionSchema).refine((record2) => Object.entries(record2).every(([key, entry]) => entry.id === key), {
37607
+ message: "Each action entry id must match its map key"
37608
+ }).default({});
37609
+ var DEFAULT_ORGANIZATION_MODEL_ACTIONS = {};
37500
37610
 
37501
37611
  // ../core/src/organization-model/domains/systems.ts
37502
37612
  var SystemKindSchema = external_exports.enum(["product", "operational", "platform", "diagnostic"]).meta({ label: "System kind", color: "blue" });
@@ -38088,79 +38198,7 @@ var PoliciesDomainSchema = external_exports.record(external_exports.string(), Po
38088
38198
  }).default({});
38089
38199
  var DEFAULT_ORGANIZATION_MODEL_POLICIES = {};
38090
38200
 
38091
- // ../core/src/organization-model/schema.ts
38092
- var OrganizationModelDomainKeySchema = external_exports.enum([
38093
- "branding",
38094
- "identity",
38095
- "customers",
38096
- "offerings",
38097
- "roles",
38098
- "goals",
38099
- "systems",
38100
- "ontology",
38101
- "resources",
38102
- "topology",
38103
- "actions",
38104
- "entities",
38105
- "policies",
38106
- "knowledge"
38107
- ]);
38108
- var OrganizationModelDomainMetadataSchema = external_exports.object({
38109
- version: external_exports.literal(1).default(1),
38110
- lastModified: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/, "lastModified must be an ISO date string (YYYY-MM-DD)")
38111
- });
38112
- var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
38113
- branding: { version: 1, lastModified: "2026-05-10" },
38114
- identity: { version: 1, lastModified: "2026-05-10" },
38115
- customers: { version: 1, lastModified: "2026-05-10" },
38116
- offerings: { version: 1, lastModified: "2026-05-10" },
38117
- roles: { version: 1, lastModified: "2026-05-10" },
38118
- goals: { version: 1, lastModified: "2026-05-10" },
38119
- systems: { version: 1, lastModified: "2026-05-10" },
38120
- ontology: { version: 1, lastModified: "2026-05-14" },
38121
- resources: { version: 1, lastModified: "2026-05-10" },
38122
- topology: { version: 1, lastModified: "2026-05-14" },
38123
- actions: { version: 1, lastModified: "2026-05-10" },
38124
- entities: { version: 1, lastModified: "2026-05-10" },
38125
- policies: { version: 1, lastModified: "2026-05-10" },
38126
- knowledge: { version: 1, lastModified: "2026-05-10" }
38127
- };
38128
- var OrganizationModelDomainMetadataByDomainSchema = external_exports.object({
38129
- branding: OrganizationModelDomainMetadataSchema,
38130
- identity: OrganizationModelDomainMetadataSchema,
38131
- customers: OrganizationModelDomainMetadataSchema,
38132
- offerings: OrganizationModelDomainMetadataSchema,
38133
- roles: OrganizationModelDomainMetadataSchema,
38134
- goals: OrganizationModelDomainMetadataSchema,
38135
- systems: OrganizationModelDomainMetadataSchema,
38136
- ontology: OrganizationModelDomainMetadataSchema,
38137
- resources: OrganizationModelDomainMetadataSchema,
38138
- topology: OrganizationModelDomainMetadataSchema,
38139
- actions: OrganizationModelDomainMetadataSchema,
38140
- entities: OrganizationModelDomainMetadataSchema,
38141
- policies: OrganizationModelDomainMetadataSchema,
38142
- knowledge: OrganizationModelDomainMetadataSchema
38143
- }).partial().default(DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA).transform((metadata) => ({ ...DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, ...metadata }));
38144
- var OrganizationModelSchemaBase = external_exports.object({
38145
- version: external_exports.literal(1).default(1),
38146
- domainMetadata: OrganizationModelDomainMetadataByDomainSchema,
38147
- branding: OrganizationModelBrandingSchema,
38148
- navigation: OrganizationModelNavigationSchema,
38149
- identity: IdentityDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_IDENTITY),
38150
- customers: CustomersDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_CUSTOMERS),
38151
- offerings: OfferingsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_OFFERINGS),
38152
- roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
38153
- goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
38154
- systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
38155
- ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
38156
- resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
38157
- topology: OmTopologyDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_TOPOLOGY),
38158
- actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
38159
- entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
38160
- policies: PoliciesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_POLICIES),
38161
- // D3: flat Record<id, OrgKnowledgeNode> — no wrapper object
38162
- knowledge: KnowledgeDomainSchema.default({})
38163
- });
38201
+ // ../core/src/organization-model/schema-refinements.ts
38164
38202
  function addIssue(ctx, path3, message) {
38165
38203
  ctx.addIssue({
38166
38204
  code: external_exports.ZodIssueCode.custom,
@@ -38191,7 +38229,7 @@ function isKnowledgeKindCompatibleWithTarget(knowledgeKind, targetKind) {
38191
38229
  function isRecord(value) {
38192
38230
  return typeof value === "object" && value !== null && !Array.isArray(value);
38193
38231
  }
38194
- var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ctx) => {
38232
+ function refineOrganizationModel(model, ctx) {
38195
38233
  function collectAllSystems(systems, prefix = "", schemaPath = ["systems"]) {
38196
38234
  const result = [];
38197
38235
  for (const [key, system] of Object.entries(systems)) {
@@ -38363,7 +38401,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38363
38401
  });
38364
38402
  });
38365
38403
  Object.values(model.entities).forEach((entity) => {
38366
- if (!systemsById.has(entity.ownedBySystemId)) {
38404
+ if (systemsById.size > 0 && !systemsById.has(entity.ownedBySystemId)) {
38367
38405
  addIssue(
38368
38406
  ctx,
38369
38407
  ["entities", entity.id, "ownedBySystemId"],
@@ -38481,29 +38519,9 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38481
38519
  }
38482
38520
  });
38483
38521
  });
38484
- const actionIds = new Set(Object.keys(model.actions));
38485
- const offeringsById = new Map(Object.entries(model.offerings));
38522
+ const idx = buildOmCrossRefIndex(model);
38523
+ const { ontologyIndexByKind, ontologyIds } = idx;
38486
38524
  const ontologyCompilation = compileOrganizationOntology(model);
38487
- const stageIds = /* @__PURE__ */ new Set();
38488
- for (const catalog of Object.values(ontologyCompilation.ontology.catalogTypes)) {
38489
- if (catalog.kind !== "stage") continue;
38490
- for (const stageId of Object.keys(catalog.entries ?? {})) {
38491
- stageIds.add(stageId);
38492
- }
38493
- }
38494
- const ontologyIndexByKind = {
38495
- object: ontologyCompilation.ontology.objectTypes,
38496
- link: ontologyCompilation.ontology.linkTypes,
38497
- action: ontologyCompilation.ontology.actionTypes,
38498
- catalog: ontologyCompilation.ontology.catalogTypes,
38499
- event: ontologyCompilation.ontology.eventTypes,
38500
- interface: ontologyCompilation.ontology.interfaceTypes,
38501
- "value-type": ontologyCompilation.ontology.valueTypes,
38502
- property: ontologyCompilation.ontology.sharedProperties,
38503
- group: ontologyCompilation.ontology.groups,
38504
- surface: ontologyCompilation.ontology.surfaces
38505
- };
38506
- const ontologyIds = new Set(Object.values(ontologyIndexByKind).flatMap((index) => Object.keys(index)));
38507
38525
  function topologyTargetExists(ref) {
38508
38526
  if (ref.kind === "system") return systemsById.has(ref.id);
38509
38527
  if (ref.kind === "resource") return resourcesById.has(ref.id);
@@ -38524,19 +38542,6 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38524
38542
  );
38525
38543
  });
38526
38544
  });
38527
- const ontologyReferenceKeyKinds = {
38528
- valueType: "value-type",
38529
- catalogType: "catalog",
38530
- objectType: "object",
38531
- eventType: "event",
38532
- actionType: "action",
38533
- linkType: "link",
38534
- interfaceType: "interface",
38535
- propertyType: "property",
38536
- groupType: "group",
38537
- surfaceType: "surface",
38538
- stepCatalog: "catalog"
38539
- };
38540
38545
  function validateKnownOntologyReferences(ownerId, value, path3, seen = /* @__PURE__ */ new WeakSet()) {
38541
38546
  if (Array.isArray(value)) {
38542
38547
  value.forEach((entry, index) => validateKnownOntologyReferences(ownerId, entry, [...path3, index], seen));
@@ -38546,7 +38551,7 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38546
38551
  if (seen.has(value)) return;
38547
38552
  seen.add(value);
38548
38553
  Object.entries(value).forEach(([key, entry]) => {
38549
- const expectedKind = ontologyReferenceKeyKinds[key];
38554
+ const expectedKind = ONTOLOGY_REFERENCE_KEY_KINDS[key];
38550
38555
  if (expectedKind !== void 0) {
38551
38556
  if (typeof entry !== "string") {
38552
38557
  addIssue(ctx, [...path3, key], `Ontology record "${ownerId}" ${key} must be an ontology ID string`);
@@ -38607,22 +38612,9 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38607
38612
  );
38608
38613
  }
38609
38614
  });
38610
- function knowledgeTargetExists(kind, id) {
38611
- if (kind === "system") return systemsById.has(id);
38612
- if (kind === "resource") return resourcesById.has(id);
38613
- if (kind === "knowledge") return knowledgeById.has(id);
38614
- if (kind === "stage") return stageIds.has(id);
38615
- if (kind === "action") return actionIds.has(id);
38616
- if (kind === "role") return rolesById.has(id);
38617
- if (kind === "goal") return goalsById.has(id);
38618
- if (kind === "customer-segment") return segmentsById.has(id);
38619
- if (kind === "offering") return offeringsById.has(id);
38620
- if (kind === "ontology") return ontologyIds.has(id);
38621
- return false;
38622
- }
38623
38615
  Object.entries(model.knowledge).forEach(([nodeId2, node]) => {
38624
38616
  node.links.forEach((link, linkIndex) => {
38625
- if (!knowledgeTargetExists(link.target.kind, link.target.id)) {
38617
+ if (!knowledgeTargetExists(idx, link.target.kind, link.target.id)) {
38626
38618
  addIssue(
38627
38619
  ctx,
38628
38620
  ["knowledge", nodeId2, "links", linkIndex, "target"],
@@ -38736,7 +38728,82 @@ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine((model, ct
38736
38728
  for (const diagnostic of ontologyCompilation.diagnostics) {
38737
38729
  addIssue(ctx, diagnostic.path, diagnostic.message);
38738
38730
  }
38731
+ }
38732
+
38733
+ // ../core/src/organization-model/schema.ts
38734
+ var OrganizationModelDomainKeySchema = external_exports.enum([
38735
+ "branding",
38736
+ "identity",
38737
+ "customers",
38738
+ "offerings",
38739
+ "roles",
38740
+ "goals",
38741
+ "systems",
38742
+ "ontology",
38743
+ "resources",
38744
+ "topology",
38745
+ "actions",
38746
+ "entities",
38747
+ "policies",
38748
+ "knowledge"
38749
+ ]);
38750
+ var OrganizationModelDomainMetadataSchema = external_exports.object({
38751
+ version: external_exports.literal(1).default(1),
38752
+ lastModified: external_exports.string().regex(/^\d{4}-\d{2}-\d{2}$/, "lastModified must be an ISO date string (YYYY-MM-DD)")
38753
+ });
38754
+ var DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA = {
38755
+ branding: { version: 1, lastModified: "2026-05-10" },
38756
+ identity: { version: 1, lastModified: "2026-05-10" },
38757
+ customers: { version: 1, lastModified: "2026-05-10" },
38758
+ offerings: { version: 1, lastModified: "2026-05-10" },
38759
+ roles: { version: 1, lastModified: "2026-05-10" },
38760
+ goals: { version: 1, lastModified: "2026-05-10" },
38761
+ systems: { version: 1, lastModified: "2026-05-10" },
38762
+ ontology: { version: 1, lastModified: "2026-05-14" },
38763
+ resources: { version: 1, lastModified: "2026-05-10" },
38764
+ topology: { version: 1, lastModified: "2026-05-14" },
38765
+ actions: { version: 1, lastModified: "2026-05-10" },
38766
+ entities: { version: 1, lastModified: "2026-05-10" },
38767
+ policies: { version: 1, lastModified: "2026-05-10" },
38768
+ knowledge: { version: 1, lastModified: "2026-05-10" }
38769
+ };
38770
+ var OrganizationModelDomainMetadataByDomainSchema = external_exports.object({
38771
+ branding: OrganizationModelDomainMetadataSchema,
38772
+ identity: OrganizationModelDomainMetadataSchema,
38773
+ customers: OrganizationModelDomainMetadataSchema,
38774
+ offerings: OrganizationModelDomainMetadataSchema,
38775
+ roles: OrganizationModelDomainMetadataSchema,
38776
+ goals: OrganizationModelDomainMetadataSchema,
38777
+ systems: OrganizationModelDomainMetadataSchema,
38778
+ ontology: OrganizationModelDomainMetadataSchema,
38779
+ resources: OrganizationModelDomainMetadataSchema,
38780
+ topology: OrganizationModelDomainMetadataSchema,
38781
+ actions: OrganizationModelDomainMetadataSchema,
38782
+ entities: OrganizationModelDomainMetadataSchema,
38783
+ policies: OrganizationModelDomainMetadataSchema,
38784
+ knowledge: OrganizationModelDomainMetadataSchema
38785
+ }).partial().default(DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA).transform((metadata) => ({ ...DEFAULT_ORGANIZATION_MODEL_DOMAIN_METADATA, ...metadata }));
38786
+ var OrganizationModelSchemaBase = external_exports.object({
38787
+ version: external_exports.literal(1).default(1),
38788
+ domainMetadata: OrganizationModelDomainMetadataByDomainSchema,
38789
+ branding: OrganizationModelBrandingSchema.default(DEFAULT_ORGANIZATION_MODEL_BRANDING),
38790
+ navigation: OrganizationModelNavigationSchema,
38791
+ identity: IdentityDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_IDENTITY),
38792
+ customers: CustomersDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_CUSTOMERS),
38793
+ offerings: OfferingsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_OFFERINGS),
38794
+ roles: RolesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ROLES),
38795
+ goals: GoalsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_GOALS),
38796
+ systems: SystemsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_SYSTEMS),
38797
+ ontology: OntologyScopeSchema.default(DEFAULT_ONTOLOGY_SCOPE),
38798
+ resources: ResourcesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_RESOURCES),
38799
+ topology: OmTopologyDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_TOPOLOGY),
38800
+ actions: ActionsDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ACTIONS),
38801
+ entities: EntitiesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_ENTITIES),
38802
+ policies: PoliciesDomainSchema.default(DEFAULT_ORGANIZATION_MODEL_POLICIES),
38803
+ // D3: flat Record<id, OrgKnowledgeNode> — no wrapper object
38804
+ knowledge: KnowledgeDomainSchema.default({})
38739
38805
  });
38806
+ var OrganizationModelSchema = OrganizationModelSchemaBase.superRefine(refineOrganizationModel);
38740
38807
 
38741
38808
  // ../core/src/organization-model/defaults.ts
38742
38809
  var DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE = {};
@@ -38773,26 +38840,6 @@ var DEFAULT_ORGANIZATION_MODEL = {
38773
38840
  knowledge: DEFAULT_ORGANIZATION_MODEL_KNOWLEDGE
38774
38841
  };
38775
38842
 
38776
- // ../core/src/organization-model/helpers.ts
38777
- function childSystemsOf2(system) {
38778
- return system.systems ?? system.subsystems ?? {};
38779
- }
38780
- function listAllSystems(model) {
38781
- const results = [];
38782
- function walk(map2, prefix) {
38783
- for (const [localId2, system] of Object.entries(map2)) {
38784
- const fullPath = prefix ? `${prefix}.${localId2}` : localId2;
38785
- results.push({ path: fullPath, system });
38786
- const childSystems = childSystemsOf2(system);
38787
- if (Object.keys(childSystems).length > 0) {
38788
- walk(childSystems, fullPath);
38789
- }
38790
- }
38791
- }
38792
- walk(model.systems, "");
38793
- return results;
38794
- }
38795
-
38796
38843
  // ../core/src/organization-model/migration-helpers.ts
38797
38844
  function catalogRecords(model) {
38798
38845
  return Object.values(compileOrganizationOntology(model).ontology.catalogTypes);
@@ -44110,7 +44157,7 @@ function wrapAction(commandName, fn) {
44110
44157
  // package.json
44111
44158
  var package_default = {
44112
44159
  name: "@elevasis/sdk",
44113
- version: "1.24.0",
44160
+ version: "1.25.0",
44114
44161
  description: "SDK for building Elevasis organization resources",
44115
44162
  type: "module",
44116
44163
  bin: {
@@ -44316,6 +44363,38 @@ function bumpVersion(current, type) {
44316
44363
  return `${major}.${minor}.${patch + 1}`;
44317
44364
  }
44318
44365
  }
44366
+ function updateDeploymentVersionSource(source, newVersion) {
44367
+ let offset = 0;
44368
+ while (offset < source.length) {
44369
+ const keyIndex = source.indexOf("version", offset);
44370
+ if (keyIndex === -1) break;
44371
+ const before = source[keyIndex - 1];
44372
+ const after = source[keyIndex + "version".length];
44373
+ const isIdentifierBoundary = (before === void 0 || !/[A-Za-z0-9_$]/.test(before)) && (after === void 0 || !/[A-Za-z0-9_$]/.test(after));
44374
+ if (!isIdentifierBoundary) {
44375
+ offset = keyIndex + "version".length;
44376
+ continue;
44377
+ }
44378
+ let cursor = keyIndex + "version".length;
44379
+ while (/\s/.test(source[cursor] ?? "")) cursor += 1;
44380
+ if (source[cursor] !== ":") {
44381
+ offset = cursor;
44382
+ continue;
44383
+ }
44384
+ cursor += 1;
44385
+ while (/\s/.test(source[cursor] ?? "")) cursor += 1;
44386
+ const quote = source[cursor];
44387
+ if (quote !== "'" && quote !== '"') {
44388
+ offset = cursor;
44389
+ continue;
44390
+ }
44391
+ const valueStart = cursor + 1;
44392
+ const valueEnd = source.indexOf(quote, valueStart);
44393
+ if (valueEnd === -1) break;
44394
+ return `${source.slice(0, valueStart)}${newVersion}${source.slice(valueEnd)}`;
44395
+ }
44396
+ throw new Error("Unable to find a quoted version property in the deployment entry file");
44397
+ }
44319
44398
  function listOrganizationModelContractRefs(org) {
44320
44399
  return Object.values(org.organizationModel?.resources ?? {}).flatMap((resource) => {
44321
44400
  const contract = resource?.ontology?.contract;
@@ -44381,6 +44460,7 @@ function registerDeployCommand(program3) {
44381
44460
  let org;
44382
44461
  let activeWorkflows = [];
44383
44462
  let activeAgents = [];
44463
+ let bumpedEntrySource = null;
44384
44464
  try {
44385
44465
  const entryModule = await loadTsModule(entryPath);
44386
44466
  const deploymentModule = entryModule;
@@ -44409,11 +44489,10 @@ function registerDeployCommand(program3) {
44409
44489
  const newVersion = bumpVersion(currentVersion, bumpType);
44410
44490
  const absEntryPath = resolvePackageRelative(entryPath);
44411
44491
  const entryContent = await (0, import_promises.readFile)(absEntryPath, "utf-8");
44412
- const updatedContent = entryContent.replace(
44413
- /version:\s*['"][\d]+\.[\d]+\.[\d]+['"]/,
44414
- `version: '${newVersion}'`
44415
- );
44416
- await (0, import_promises.writeFile)(absEntryPath, updatedContent, "utf-8");
44492
+ bumpedEntrySource = {
44493
+ absEntryPath,
44494
+ content: updateDeploymentVersionSource(entryContent, newVersion)
44495
+ };
44417
44496
  org.version = newVersion;
44418
44497
  }
44419
44498
  console.log("");
@@ -44474,7 +44553,8 @@ function registerDeployCommand(program3) {
44474
44553
  const absEntryForImport = resolvePackageRelative(entryPath).replace(/\.ts$/, ".js");
44475
44554
  const wrapperContent = `import org from ${JSON.stringify(absEntryForImport)}
44476
44555
  import { startWorker } from '@elevasis/sdk/worker'
44477
- startWorker(org)
44556
+ ` + (bumpedEntrySource ? `org.version = ${JSON.stringify(org.version)}
44557
+ ` : "") + `startWorker(org)
44478
44558
  `;
44479
44559
  await (0, import_promises.writeFile)(wrapperPath, wrapperContent, "utf-8");
44480
44560
  await (0, import_promises.mkdir)(resolvePackageRelative("dist"), { recursive: true });
@@ -44542,6 +44622,9 @@ startWorker(org)
44542
44622
  const totalResources = activeWorkflows.length + activeAgents.length;
44543
44623
  const elapsed = ((Date.now() - startTime) / 1e3).toFixed(1);
44544
44624
  if (result.status === "active") {
44625
+ if (bumpedEntrySource) {
44626
+ await (0, import_promises.writeFile)(bumpedEntrySource.absEntryPath, bumpedEntrySource.content, "utf-8");
44627
+ }
44545
44628
  console.log("");
44546
44629
  console.log(
44547
44630
  source_default.green.bold(` Deployed! ${totalResources} resource${totalResources !== 1 ? "s" : ""} live.`)
@@ -47722,7 +47805,7 @@ function resolveKnowledgeInvocationNeighbors(model, id) {
47722
47805
  continue;
47723
47806
  }
47724
47807
  if (target.kind === "system") {
47725
- const system = model.systems[target.id];
47808
+ const system = getSystem(model, target.id);
47726
47809
  for (const actionRef of system?.actions ?? []) {
47727
47810
  pushActionSource(sources, seen, model.actions[actionRef.actionId]);
47728
47811
  }
@@ -48312,6 +48395,7 @@ var ListRequestsQuerySchema = external_exports.object({
48312
48395
  var REQUEST_TYPE_HELP = RequestTypeEnum.options.join(" | ");
48313
48396
  var REQUEST_CATEGORY_HELP = RequestCategoryEnum.options.join(" | ");
48314
48397
  var REQUEST_SEVERITY_HELP = RequestSeverityEnum.options.join(" | ");
48398
+ var REQUEST_STATUS_HELP = RequestStatusEnum.options.join(" | ");
48315
48399
  function registerRequestCommands(program3) {
48316
48400
  program3.command("request:submit").description(
48317
48401
  `Submit a structured request report via POST /api/external/requests
@@ -48367,6 +48451,59 @@ ${issues}`);
48367
48451
  }
48368
48452
  })
48369
48453
  );
48454
+ program3.command("request:list").description(
48455
+ `List reported requests via GET /api/external/requests
48456
+ Example: elevasis-sdk request:list --status open --severity critical
48457
+ status: ${REQUEST_STATUS_HELP}
48458
+ severity: ${REQUEST_SEVERITY_HELP}`
48459
+ ).option("--status <status>", `Filter by status (${REQUEST_STATUS_HELP})`).option("--severity <severity>", `Filter by severity (${REQUEST_SEVERITY_HELP})`).option("--project-id <uuid>", "Filter by project id").option("--limit <n>", "Max rows to return (1-200, default 50)").option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
48460
+ wrapAction("request:list", async (options) => {
48461
+ const params = new URLSearchParams();
48462
+ if (options.status) params.set("status", options.status);
48463
+ if (options.severity) params.set("severity", options.severity);
48464
+ if (options.projectId) params.set("project_id", options.projectId);
48465
+ if (options.limit) params.set("limit", options.limit);
48466
+ const qs = params.toString();
48467
+ const apiUrl = resolveApiUrl(options.apiUrl);
48468
+ const result = await apiGet(`/api/external/requests${qs ? `?${qs}` : ""}`, apiUrl);
48469
+ if (options.pretty) {
48470
+ const rows = result.requests;
48471
+ if (rows.length === 0) {
48472
+ console.log(source_default.yellow("\nNo requests found"));
48473
+ return;
48474
+ }
48475
+ console.log(source_default.green(`
48476
+ ${rows.length} request${rows.length === 1 ? "" : "s"}`));
48477
+ for (const r of rows) {
48478
+ console.log(source_default.gray(` ${r.id} [${r.severity}/${r.status}] ${r.title}`));
48479
+ }
48480
+ console.log();
48481
+ } else {
48482
+ console.log(JSON.stringify(result, null, 2));
48483
+ }
48484
+ })
48485
+ );
48486
+ program3.command("request:get <id>").description(
48487
+ "Get a reported request by id via GET /api/external/requests/:id\n Example: elevasis-sdk request:get 1a2b3c4d-5e6f-7890-abcd-ef1234567890"
48488
+ ).option("--api-url <url>", "API base URL").option("--pretty", "Render human-readable output instead of raw JSON").action(
48489
+ wrapAction("request:get", async (id, options) => {
48490
+ const apiUrl = resolveApiUrl(options.apiUrl);
48491
+ const result = await apiGet(`/api/external/requests/${encodeURIComponent(id)}`, apiUrl);
48492
+ if (options.pretty) {
48493
+ const r = result.request;
48494
+ console.log(source_default.green("\nRequest"));
48495
+ console.log(source_default.gray(` ID: ${r.id}`));
48496
+ console.log(source_default.gray(` Title: ${r.title}`));
48497
+ console.log(source_default.gray(` Severity: ${r.severity}`));
48498
+ console.log(source_default.gray(` Category: ${r.category}`));
48499
+ console.log(source_default.gray(` Status: ${r.status}`));
48500
+ console.log(source_default.gray(` Reported: ${r.reported_at}`));
48501
+ console.log();
48502
+ } else {
48503
+ console.log(JSON.stringify(result, null, 2));
48504
+ }
48505
+ })
48506
+ );
48370
48507
  }
48371
48508
 
48372
48509
  // src/cli/commands/ui/ui-switcher.ts
@@ -49828,6 +49965,8 @@ Commands:
49828
49965
  elevasis-sdk knowledge:cat <id> Print raw MDX body of a knowledge node
49829
49966
  elevasis-sdk knowledge:graph <id> Show outgoing and incoming edges for a node
49830
49967
  elevasis-sdk request:submit -f <path> Submit a structured request report
49968
+ elevasis-sdk request:list [--status open] List reported requests
49969
+ elevasis-sdk request:get <id> Get a reported request by id
49831
49970
  elevasis-sdk ui:use-local Use a local @elevasis/ui tarball
49832
49971
  elevasis-sdk ui:use-published Restore published @elevasis/ui
49833
49972
  elevasis-sdk cli [domain] Generate a registered command catalog