@elevasis/core 0.42.1 → 0.43.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/auth/index.d.ts +6 -1
- package/dist/auth/index.js +6 -0
- package/dist/business/entities-published.d.ts +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +37 -15
- package/dist/knowledge/index.d.ts +92 -4
- package/dist/knowledge/index.js +168 -1
- package/dist/organization-model/index.d.ts +3 -4
- package/dist/organization-model/index.js +37 -15
- package/dist/test-utils/index.d.ts +3 -4
- package/dist/test-utils/index.js +12 -6
- package/package.json +1 -1
- package/src/auth/access-keys.ts +6 -0
- package/src/business/base-entities.ts +1 -1
- package/src/knowledge/cli-helpers.ts +211 -0
- package/src/knowledge/index.ts +13 -0
- package/src/knowledge/published.ts +18 -5
- package/src/organization-model/__tests__/cross-ref.test.ts +11 -1
- package/src/organization-model/__tests__/domains/systems.test.ts +34 -8
- package/src/organization-model/__tests__/scaffolders.test.ts +30 -1
- package/src/organization-model/__tests__/schema-refinements.test.ts +178 -0
- package/src/organization-model/cross-ref.ts +41 -5
- package/src/organization-model/defaults.ts +2 -2
- package/src/organization-model/domains/actions.ts +1 -1
- package/src/organization-model/domains/systems.ts +0 -4
- package/src/organization-model/organization-graph.mdx +9 -8
- package/src/organization-model/resolve.ts +9 -7
- package/src/organization-model/scaffolders/scaffoldKnowledgeNode.ts +1 -0
- package/src/organization-model/scaffolders/scaffoldOntologyRecord.ts +28 -6
- package/src/organization-model/scaffolders/scaffoldResource.ts +1 -0
- package/src/organization-model/scaffolders/scaffoldSystem.ts +2 -1
- package/src/organization-model/schema-refinements.ts +3 -5
- package/src/platform/registry/__tests__/validation.test.ts +28 -0
- package/src/platform/registry/validation.ts +18 -0
- package/src/test-utils/mocks/supabase.ts +1 -1
- package/src/test-utils/mocks/workos.ts +2 -2
package/dist/auth/index.d.ts
CHANGED
|
@@ -4337,7 +4337,6 @@ interface SystemEntry {
|
|
|
4337
4337
|
status?: 'active' | 'deprecated' | 'archived';
|
|
4338
4338
|
path?: string;
|
|
4339
4339
|
icon?: string;
|
|
4340
|
-
color?: string;
|
|
4341
4340
|
uiPosition?: 'sidebar-primary' | 'sidebar-bottom';
|
|
4342
4341
|
enabled?: boolean;
|
|
4343
4342
|
devOnly?: boolean;
|
|
@@ -5516,6 +5515,7 @@ declare const AccessKeys: {
|
|
|
5516
5515
|
readonly systemPath: "permission.roles";
|
|
5517
5516
|
readonly action: "manage";
|
|
5518
5517
|
};
|
|
5518
|
+
/** @reserved Reserved for first-class secret administration routes and command surfaces. */
|
|
5519
5519
|
readonly secretsManage: {
|
|
5520
5520
|
readonly systemPath: "permission.secrets";
|
|
5521
5521
|
readonly action: "manage";
|
|
@@ -5524,6 +5524,7 @@ declare const AccessKeys: {
|
|
|
5524
5524
|
readonly systemPath: "permission.operations";
|
|
5525
5525
|
readonly action: "view";
|
|
5526
5526
|
};
|
|
5527
|
+
/** @reserved Reserved for write-level operations administration beyond read-only monitoring. */
|
|
5527
5528
|
readonly operationsManage: {
|
|
5528
5529
|
readonly systemPath: "permission.operations";
|
|
5529
5530
|
readonly action: "manage";
|
|
@@ -5532,14 +5533,17 @@ declare const AccessKeys: {
|
|
|
5532
5533
|
readonly systemPath: "sales.lead-gen";
|
|
5533
5534
|
readonly action: "manage";
|
|
5534
5535
|
};
|
|
5536
|
+
/** @reserved Reserved for acquisition administration once that permission namespace is wired. */
|
|
5535
5537
|
readonly acquisitionManage: {
|
|
5536
5538
|
readonly systemPath: "permission.acquisition";
|
|
5537
5539
|
readonly action: "manage";
|
|
5538
5540
|
};
|
|
5541
|
+
/** @reserved Reserved for project administration permission catalog compatibility. */
|
|
5539
5542
|
readonly projectsManage: {
|
|
5540
5543
|
readonly systemPath: "permission.projects";
|
|
5541
5544
|
readonly action: "manage";
|
|
5542
5545
|
};
|
|
5546
|
+
/** @reserved Reserved for client administration permission catalog compatibility. */
|
|
5543
5547
|
readonly clientsManage: {
|
|
5544
5548
|
readonly systemPath: "permission.clients";
|
|
5545
5549
|
readonly action: "manage";
|
|
@@ -5548,6 +5552,7 @@ declare const AccessKeys: {
|
|
|
5548
5552
|
readonly systemPath: "diagnostic.operations.overview";
|
|
5549
5553
|
readonly action: "view";
|
|
5550
5554
|
};
|
|
5555
|
+
/** @reserved Reserved for a diagnostics surface that lists recent operations executions. */
|
|
5551
5556
|
readonly operationsRecentExecutions: {
|
|
5552
5557
|
readonly systemPath: "diagnostic.operations.recent-executions";
|
|
5553
5558
|
readonly action: "view";
|
package/dist/auth/index.js
CHANGED
|
@@ -474,14 +474,20 @@ var AccessKeys = {
|
|
|
474
474
|
organizationManage: { systemPath: "permission.org", action: "manage" },
|
|
475
475
|
membersManage: { systemPath: "permission.members", action: "manage" },
|
|
476
476
|
rolesManage: { systemPath: "permission.roles", action: "manage" },
|
|
477
|
+
/** @reserved Reserved for first-class secret administration routes and command surfaces. */
|
|
477
478
|
secretsManage: { systemPath: "permission.secrets", action: "manage" },
|
|
478
479
|
operationsRead: { systemPath: "permission.operations", action: DEFAULT_ACCESS_ACTION },
|
|
480
|
+
/** @reserved Reserved for write-level operations administration beyond read-only monitoring. */
|
|
479
481
|
operationsManage: { systemPath: "permission.operations", action: "manage" },
|
|
480
482
|
leadGenManage: { systemPath: "sales.lead-gen", action: "manage" },
|
|
483
|
+
/** @reserved Reserved for acquisition administration once that permission namespace is wired. */
|
|
481
484
|
acquisitionManage: { systemPath: "permission.acquisition", action: "manage" },
|
|
485
|
+
/** @reserved Reserved for project administration permission catalog compatibility. */
|
|
482
486
|
projectsManage: { systemPath: "permission.projects", action: "manage" },
|
|
487
|
+
/** @reserved Reserved for client administration permission catalog compatibility. */
|
|
483
488
|
clientsManage: { systemPath: "permission.clients", action: "manage" },
|
|
484
489
|
operationsOverview: { systemPath: "diagnostic.operations.overview", action: DEFAULT_ACCESS_ACTION },
|
|
490
|
+
/** @reserved Reserved for a diagnostics surface that lists recent operations executions. */
|
|
485
491
|
operationsRecentExecutions: { systemPath: "diagnostic.operations.recent-executions", action: DEFAULT_ACCESS_ACTION },
|
|
486
492
|
monitoringExecutionLogs: { systemPath: "diagnostic.monitoring.execution-logs", action: DEFAULT_ACCESS_ACTION },
|
|
487
493
|
monitoringNotifications: { systemPath: "diagnostic.monitoring.notifications", action: DEFAULT_ACCESS_ACTION }
|
|
@@ -12,7 +12,7 @@ import { z } from 'zod';
|
|
|
12
12
|
* layer; use the row types internally for direct Supabase access.
|
|
13
13
|
*
|
|
14
14
|
* Usage in a client project:
|
|
15
|
-
* import { BaseProject } from '@elevasis/core'
|
|
15
|
+
* import { BaseProject } from '@elevasis/core'
|
|
16
16
|
* type Project = BaseProject<{ budget: number; riskScore: 'low' | 'medium' | 'high' }>
|
|
17
17
|
*
|
|
18
18
|
* Extending a Zod schema in a client project:
|
package/dist/index.d.ts
CHANGED
|
@@ -918,7 +918,6 @@ interface SystemEntry {
|
|
|
918
918
|
status?: 'active' | 'deprecated' | 'archived';
|
|
919
919
|
path?: string;
|
|
920
920
|
icon?: string;
|
|
921
|
-
color?: string;
|
|
922
921
|
uiPosition?: 'sidebar-primary' | 'sidebar-bottom';
|
|
923
922
|
enabled?: boolean;
|
|
924
923
|
devOnly?: boolean;
|
|
@@ -1091,7 +1090,7 @@ declare const ActionsDomainSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodOb
|
|
|
1091
1090
|
* Generic empty default for the actions domain.
|
|
1092
1091
|
* Elevasis-specific action entries (LEAD_GEN_ACTION_ENTRIES, CRM_ACTION_ENTRIES,
|
|
1093
1092
|
* DEFAULT_ORGANIZATION_MODEL_ACTIONS) have been relocated to
|
|
1094
|
-
*
|
|
1093
|
+
* the tenant-owned organization model package.
|
|
1095
1094
|
* Tenant OM configs supply their own action entries via `resolveOrganizationModel`.
|
|
1096
1095
|
*/
|
|
1097
1096
|
declare const DEFAULT_ORGANIZATION_MODEL_ACTIONS: z.infer<typeof ActionsDomainSchema>;
|
|
@@ -3809,11 +3808,11 @@ declare const SETTINGS_ROLES_SURFACE_ID: "settings.roles";
|
|
|
3809
3808
|
*
|
|
3810
3809
|
* It does NOT contain Elevasis-specific identity, systems, or action entries.
|
|
3811
3810
|
* Runtime consumers that need the full Elevasis canonical model should import
|
|
3812
|
-
* `canonicalOrganizationModel` from
|
|
3811
|
+
* `canonicalOrganizationModel` from the tenant-owned organization model package instead.
|
|
3813
3812
|
*
|
|
3814
3813
|
* Elevasis-specific systems, actions (LEAD_GEN_ACTION_ENTRIES, CRM_ACTION_ENTRIES,
|
|
3815
3814
|
* DEFAULT_ORGANIZATION_MODEL_ACTIONS), and the platform system description have been
|
|
3816
|
-
* relocated to
|
|
3815
|
+
* relocated to the tenant-owned organization model package.
|
|
3817
3816
|
*/
|
|
3818
3817
|
|
|
3819
3818
|
declare const DEFAULT_ORGANIZATION_MODEL: OrganizationModel;
|
package/dist/index.js
CHANGED
|
@@ -1101,8 +1101,6 @@ var SystemEntrySchema = z.object({
|
|
|
1101
1101
|
path: PathSchema.optional(),
|
|
1102
1102
|
/** @deprecated Use ui.icon. Kept for one-cycle Feature compatibility. */
|
|
1103
1103
|
icon: IconNameSchema.optional(),
|
|
1104
|
-
/** @deprecated Feature color token, retained for one-cycle compatibility. */
|
|
1105
|
-
color: ColorTokenSchema.optional(),
|
|
1106
1104
|
/** @deprecated UI placement hint, retained for one-cycle compatibility. */
|
|
1107
1105
|
uiPosition: UiPositionSchema.optional(),
|
|
1108
1106
|
/** @deprecated Use lifecycle. */
|
|
@@ -1803,7 +1801,8 @@ var ONTOLOGY_REFERENCE_KEY_KINDS = {
|
|
|
1803
1801
|
surfaceType: "surface",
|
|
1804
1802
|
stepCatalog: "catalog"
|
|
1805
1803
|
};
|
|
1806
|
-
|
|
1804
|
+
var omCompilationContextCache = /* @__PURE__ */ new WeakMap();
|
|
1805
|
+
function buildOmCrossRefIndexFromOntology(model, ontologyCompilation) {
|
|
1807
1806
|
const systemsById = /* @__PURE__ */ new Map();
|
|
1808
1807
|
for (const { path, system } of listAllSystems(model)) {
|
|
1809
1808
|
systemsById.set(path, system);
|
|
@@ -1817,7 +1816,6 @@ function buildOmCrossRefIndex(model) {
|
|
|
1817
1816
|
const actionIds = new Set(Object.keys(model.actions ?? {}));
|
|
1818
1817
|
const customerSegmentIds = new Set(Object.keys(model.customers ?? {}));
|
|
1819
1818
|
const offeringIds = new Set(Object.keys(model.offerings ?? {}));
|
|
1820
|
-
const ontologyCompilation = compileOrganizationOntology(model);
|
|
1821
1819
|
const ontologyIndexByKind = {
|
|
1822
1820
|
object: ontologyCompilation.ontology.objectTypes,
|
|
1823
1821
|
link: ontologyCompilation.ontology.linkTypes,
|
|
@@ -1856,6 +1854,15 @@ function buildOmCrossRefIndex(model) {
|
|
|
1856
1854
|
stageIds
|
|
1857
1855
|
};
|
|
1858
1856
|
}
|
|
1857
|
+
function buildOmCompilationContext(model) {
|
|
1858
|
+
const cached = omCompilationContextCache.get(model);
|
|
1859
|
+
if (cached !== void 0) return cached;
|
|
1860
|
+
const ontologyCompilation = compileOrganizationOntology(model);
|
|
1861
|
+
const crossRefIndex = buildOmCrossRefIndexFromOntology(model, ontologyCompilation);
|
|
1862
|
+
const context = { crossRefIndex, ontologyCompilation };
|
|
1863
|
+
omCompilationContextCache.set(model, context);
|
|
1864
|
+
return context;
|
|
1865
|
+
}
|
|
1859
1866
|
function knowledgeTargetExists(index, kind, id) {
|
|
1860
1867
|
if (kind === "system") return index.systemsById.has(id);
|
|
1861
1868
|
if (kind === "client") return index.clientIds.has(id);
|
|
@@ -2192,9 +2199,8 @@ function refineOrganizationModel(model, ctx) {
|
|
|
2192
2199
|
}
|
|
2193
2200
|
});
|
|
2194
2201
|
});
|
|
2195
|
-
const idx =
|
|
2202
|
+
const { crossRefIndex: idx, ontologyCompilation } = buildOmCompilationContext(model);
|
|
2196
2203
|
const { ontologyIndexByKind, ontologyIds } = idx;
|
|
2197
|
-
const ontologyCompilation = compileOrganizationOntology(model);
|
|
2198
2204
|
function topologyTargetExists(ref) {
|
|
2199
2205
|
if (ref.kind === "system") return systemsById.has(ref.id);
|
|
2200
2206
|
if (ref.kind === "resource") return resourcesById.has(ref.id);
|
|
@@ -3369,12 +3375,34 @@ Capture the durable operating knowledge here.
|
|
|
3369
3375
|
}
|
|
3370
3376
|
|
|
3371
3377
|
// src/organization-model/scaffolders/scaffoldOntologyRecord.ts
|
|
3378
|
+
function kindSpecificFields(spec) {
|
|
3379
|
+
if (spec.kind === "link") {
|
|
3380
|
+
return {
|
|
3381
|
+
from: makeOntologyId(spec.systemPath, "object", "source-object"),
|
|
3382
|
+
to: makeOntologyId(spec.systemPath, "object", "target-object")
|
|
3383
|
+
};
|
|
3384
|
+
}
|
|
3385
|
+
if (spec.kind === "action") {
|
|
3386
|
+
return { actsOn: [] };
|
|
3387
|
+
}
|
|
3388
|
+
if (spec.kind === "group") {
|
|
3389
|
+
return { members: [] };
|
|
3390
|
+
}
|
|
3391
|
+
return {};
|
|
3392
|
+
}
|
|
3372
3393
|
function scaffoldOntologyRecord(model, spec) {
|
|
3373
3394
|
assertSystemExists(model, spec.systemPath);
|
|
3374
3395
|
const localId = spec.localId ?? spec.id;
|
|
3375
3396
|
const ontologyId = makeOntologyId(spec.systemPath, spec.kind, localId);
|
|
3376
3397
|
const label = spec.label ?? titleize(localId);
|
|
3377
3398
|
const mapName = ontologyMapName(spec.kind);
|
|
3399
|
+
const snippetRecord = {
|
|
3400
|
+
id: ontologyId,
|
|
3401
|
+
label,
|
|
3402
|
+
ownerSystemId: spec.systemPath,
|
|
3403
|
+
...spec.description === void 0 ? {} : { description: spec.description },
|
|
3404
|
+
...kindSpecificFields(spec)
|
|
3405
|
+
};
|
|
3378
3406
|
return {
|
|
3379
3407
|
intent: "ontology",
|
|
3380
3408
|
id: ontologyId,
|
|
@@ -3384,12 +3412,7 @@ function scaffoldOntologyRecord(model, spec) {
|
|
|
3384
3412
|
{
|
|
3385
3413
|
path: "packages/elevasis-core/src/organization-model/systems.ts",
|
|
3386
3414
|
description: `Add this record under ${spec.systemPath}.ontology.${mapName}.`,
|
|
3387
|
-
snippet: `${JSON.stringify(ontologyId)}: {
|
|
3388
|
-
id: ${JSON.stringify(ontologyId)},
|
|
3389
|
-
label: ${JSON.stringify(label)},
|
|
3390
|
-
ownerSystemId: ${JSON.stringify(spec.systemPath)}${spec.description === void 0 ? "" : `,
|
|
3391
|
-
description: ${JSON.stringify(spec.description)}`}
|
|
3392
|
-
}`
|
|
3415
|
+
snippet: `${JSON.stringify(ontologyId)}: ${JSON.stringify(snippetRecord, null, 2)}`
|
|
3393
3416
|
}
|
|
3394
3417
|
],
|
|
3395
3418
|
warnings: [],
|
|
@@ -3503,9 +3526,8 @@ function scaffoldSystem(model, spec) {
|
|
|
3503
3526
|
content: `import type { SystemModule } from '@repo/ui'
|
|
3504
3527
|
|
|
3505
3528
|
export const ${featureSlug.replaceAll("-", "_")}Manifest: SystemModule = {
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
routes: []
|
|
3529
|
+
key: ${JSON.stringify(featureSlug)},
|
|
3530
|
+
systemId: ${JSON.stringify(systemPath)}
|
|
3509
3531
|
}
|
|
3510
3532
|
`
|
|
3511
3533
|
},
|
|
@@ -1,4 +1,28 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
1
|
+
import { z, ZodType } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const ActionInvocationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
4
|
+
kind: z.ZodLiteral<"slash-command">;
|
|
5
|
+
command: z.ZodString;
|
|
6
|
+
toolFactory: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
8
|
+
kind: z.ZodLiteral<"mcp-tool">;
|
|
9
|
+
server: z.ZodString;
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
12
|
+
kind: z.ZodLiteral<"api-endpoint">;
|
|
13
|
+
method: z.ZodEnum<{
|
|
14
|
+
GET: "GET";
|
|
15
|
+
POST: "POST";
|
|
16
|
+
PATCH: "PATCH";
|
|
17
|
+
DELETE: "DELETE";
|
|
18
|
+
}>;
|
|
19
|
+
path: z.ZodString;
|
|
20
|
+
requestSchema: z.ZodOptional<z.ZodString>;
|
|
21
|
+
responseSchema: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
23
|
+
kind: z.ZodLiteral<"script-execution">;
|
|
24
|
+
resourceId: z.ZodString;
|
|
25
|
+
}, z.core.$strip>], "kind">;
|
|
2
26
|
|
|
3
27
|
declare const OntologyScopeSchema: z.ZodDefault<z.ZodObject<{
|
|
4
28
|
objectTypes: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
@@ -142,7 +166,6 @@ interface SystemEntry {
|
|
|
142
166
|
status?: 'active' | 'deprecated' | 'archived';
|
|
143
167
|
path?: string;
|
|
144
168
|
icon?: string;
|
|
145
|
-
color?: string;
|
|
146
169
|
uiPosition?: 'sidebar-primary' | 'sidebar-bottom';
|
|
147
170
|
enabled?: boolean;
|
|
148
171
|
devOnly?: boolean;
|
|
@@ -153,6 +176,7 @@ interface SystemEntry {
|
|
|
153
176
|
systems?: Record<string, SystemEntry>;
|
|
154
177
|
subsystems?: Record<string, SystemEntry>;
|
|
155
178
|
}
|
|
179
|
+
declare const SystemEntrySchema: ZodType<SystemEntry>;
|
|
156
180
|
|
|
157
181
|
declare const SurfaceTypeSchema: z.ZodEnum<{
|
|
158
182
|
dashboard: "dashboard";
|
|
@@ -373,6 +397,25 @@ declare const OrganizationModelIconTokenSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
|
373
397
|
}>, z.ZodString]>;
|
|
374
398
|
type OrganizationModelIconToken = z.infer<typeof OrganizationModelIconTokenSchema>;
|
|
375
399
|
|
|
400
|
+
/**
|
|
401
|
+
* SystemEntry extended with the recursive tree slots (`systems`, `subsystems`).
|
|
402
|
+
* `OrganizationModelSystemEntry` is inferred from `SystemEntrySchema: ZodType<SystemEntry>`
|
|
403
|
+
* so it already carries these fields; this alias re-exports it under the tree-walker name
|
|
404
|
+
* for clarity at call sites.
|
|
405
|
+
*/
|
|
406
|
+
type SystemEntryWithTree = OrganizationModelSystemEntry;
|
|
407
|
+
/**
|
|
408
|
+
* Flat depth-first enumeration of every system in the model tree.
|
|
409
|
+
* Each entry carries the computed full path and the system node.
|
|
410
|
+
* Order: parent before children (pre-order DFS).
|
|
411
|
+
*
|
|
412
|
+
* Example result paths: `'sales'`, `'sales.crm'`, `'sales.crm.dispositions'`
|
|
413
|
+
*/
|
|
414
|
+
declare function listAllSystems(model: OrganizationModel): Array<{
|
|
415
|
+
path: string;
|
|
416
|
+
system: SystemEntryWithTree;
|
|
417
|
+
}>;
|
|
418
|
+
|
|
376
419
|
declare const OrganizationModelSchema: z.ZodObject<{
|
|
377
420
|
version: z.ZodDefault<z.ZodLiteral<1>>;
|
|
378
421
|
snapshotHash: z.ZodOptional<z.ZodString>;
|
|
@@ -1436,6 +1479,8 @@ declare const OrganizationModelSchema: z.ZodObject<{
|
|
|
1436
1479
|
}, z.core.$strip>;
|
|
1437
1480
|
|
|
1438
1481
|
type OrganizationModel = z.infer<typeof OrganizationModelSchema>;
|
|
1482
|
+
type OrganizationModelSystemEntry = z.infer<typeof SystemEntrySchema>;
|
|
1483
|
+
type OrganizationModelActionInvocation = z.infer<typeof ActionInvocationSchema>;
|
|
1439
1484
|
|
|
1440
1485
|
/**
|
|
1441
1486
|
* Command View Types
|
|
@@ -1531,6 +1576,26 @@ declare function governs(graph: OrganizationGraph, nodeId: string): string[];
|
|
|
1531
1576
|
* @returns Array of source graph node IDs (e.g. `['knowledge:knowledge.outreach-playbook', ...]`).
|
|
1532
1577
|
*/
|
|
1533
1578
|
declare function governedBy(graph: OrganizationGraph, nodeId: string): string[];
|
|
1579
|
+
/**
|
|
1580
|
+
* Returns all systems flattened from the recursive OM tree via `listAllSystems`.
|
|
1581
|
+
*
|
|
1582
|
+
* Each entry is `{ path, system }` — the same shape produced by `listAllSystems`.
|
|
1583
|
+
*
|
|
1584
|
+
* @param model - The resolved OrganizationModel.
|
|
1585
|
+
*/
|
|
1586
|
+
declare function listAllSystemsFlat(model: OrganizationModel): ReturnType<typeof listAllSystems>;
|
|
1587
|
+
/**
|
|
1588
|
+
* Returns every resource from the model as a flat array, sorted by id.
|
|
1589
|
+
*
|
|
1590
|
+
* @param model - The resolved OrganizationModel.
|
|
1591
|
+
*/
|
|
1592
|
+
declare function listAllResources(model: OrganizationModel): NonNullable<OrganizationModel['resources']>[string][];
|
|
1593
|
+
/**
|
|
1594
|
+
* Returns every role from the model as a flat array, sorted by id.
|
|
1595
|
+
*
|
|
1596
|
+
* @param model - The resolved OrganizationModel.
|
|
1597
|
+
*/
|
|
1598
|
+
declare function listAllRoles(model: OrganizationModel): NonNullable<OrganizationModel['roles']>[string][];
|
|
1534
1599
|
/** The recognized mount axes for Knowledge Map paths. */
|
|
1535
1600
|
type KnowledgeMount = 'by-system' | 'by-ontology' | 'by-kind' | 'by-owner' | 'graph' | 'node' | 'all-systems' | 'all-resources' | 'all-roles';
|
|
1536
1601
|
/**
|
|
@@ -1653,5 +1718,28 @@ declare function formatJson(input: {
|
|
|
1653
1718
|
*/
|
|
1654
1719
|
declare function formatIdsOnly(results: OrgKnowledgeNode[] | string[] | OmSearchHit[]): string;
|
|
1655
1720
|
|
|
1656
|
-
|
|
1657
|
-
|
|
1721
|
+
declare const OM_SEARCH_HIT_KINDS: OmSearchHitKind[];
|
|
1722
|
+
declare function parseKnowledgeSearchLimit(raw: string | undefined, commandName?: string): number;
|
|
1723
|
+
declare function parseKnowledgeSearchKinds(raw: string | undefined, commandName?: string): OmSearchHitKind[] | undefined;
|
|
1724
|
+
declare function formatKnowledgeSystemsList(entries: ReturnType<typeof listAllSystemsFlat>): string;
|
|
1725
|
+
declare function formatKnowledgeResourcesList(resources: ReturnType<typeof listAllResources>): string;
|
|
1726
|
+
declare function formatKnowledgeRolesList(roles: ReturnType<typeof listAllRoles>): string;
|
|
1727
|
+
interface KnowledgeInvocationSource {
|
|
1728
|
+
kind: 'action' | 'agent-resource';
|
|
1729
|
+
id: string;
|
|
1730
|
+
label: string;
|
|
1731
|
+
targetNodeId: string;
|
|
1732
|
+
invocations: OrganizationModelActionInvocation[];
|
|
1733
|
+
}
|
|
1734
|
+
interface KnowledgeInvocationNeighborsResult {
|
|
1735
|
+
id: string;
|
|
1736
|
+
title: string;
|
|
1737
|
+
invocationSources: KnowledgeInvocationSource[];
|
|
1738
|
+
}
|
|
1739
|
+
declare function normalizeKnowledgeNodeId(id: string): string;
|
|
1740
|
+
declare function formatKnowledgeInvocationLabel(invocation: OrganizationModelActionInvocation): string;
|
|
1741
|
+
declare function resolveKnowledgeInvocationNeighbors(model: OrganizationModel, id: string): KnowledgeInvocationNeighborsResult | undefined;
|
|
1742
|
+
declare function formatKnowledgeInvocationNeighbors(result: KnowledgeInvocationNeighborsResult): string;
|
|
1743
|
+
|
|
1744
|
+
export { OM_SEARCH_HIT_KINDS, byKind, byOwner, bySystem, formatIdsOnly, formatJson, formatKnowledgeInvocationLabel, formatKnowledgeInvocationNeighbors, formatKnowledgeResourcesList, formatKnowledgeRolesList, formatKnowledgeSystemsList, formatText, governedBy, governs, normalizeKnowledgeNodeId, parseKnowledgeSearchKinds, parseKnowledgeSearchLimit, parsePath, resolveKnowledgeInvocationNeighbors };
|
|
1745
|
+
export type { KnowledgeInvocationNeighborsResult, KnowledgeInvocationSource, KnowledgeJsonEnvelope, KnowledgeMount, OmSearchHitKind, ParsedKnowledgePath };
|
package/dist/knowledge/index.js
CHANGED
|
@@ -85,6 +85,24 @@ function ontologyGraphNodeId(id) {
|
|
|
85
85
|
return `ontology:${OntologyIdSchema.parse(id)}`;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
// src/organization-model/helpers.ts
|
|
89
|
+
function childSystemsOf(system) {
|
|
90
|
+
return system.systems ?? system.subsystems ?? {};
|
|
91
|
+
}
|
|
92
|
+
function getSystem(model, path) {
|
|
93
|
+
const flatMatch = model.systems[path];
|
|
94
|
+
if (flatMatch !== void 0) return flatMatch;
|
|
95
|
+
const segments = path.split(".");
|
|
96
|
+
let current = model.systems;
|
|
97
|
+
let node;
|
|
98
|
+
for (const seg of segments) {
|
|
99
|
+
node = current[seg];
|
|
100
|
+
if (node === void 0) return void 0;
|
|
101
|
+
current = childSystemsOf(node);
|
|
102
|
+
}
|
|
103
|
+
return node;
|
|
104
|
+
}
|
|
105
|
+
|
|
88
106
|
// src/knowledge/queries.ts
|
|
89
107
|
function toGraphNodeId(omNodeId) {
|
|
90
108
|
return `knowledge:${omNodeId}`;
|
|
@@ -247,4 +265,153 @@ function formatIdsOnly(results) {
|
|
|
247
265
|
return ids.join("\n");
|
|
248
266
|
}
|
|
249
267
|
|
|
250
|
-
|
|
268
|
+
// src/knowledge/cli-helpers.ts
|
|
269
|
+
var OM_SEARCH_HIT_KINDS = ["system", "resource", "knowledge", "ontology", "role", "policy"];
|
|
270
|
+
function parseKnowledgeSearchLimit(raw, commandName = "knowledge:search") {
|
|
271
|
+
if (raw === void 0) return 10;
|
|
272
|
+
const n = Number.parseInt(raw, 10);
|
|
273
|
+
if (Number.isNaN(n) || n < 0) {
|
|
274
|
+
throw new Error(`${commandName}: --limit must be a non-negative integer (got "${raw}")`);
|
|
275
|
+
}
|
|
276
|
+
return n;
|
|
277
|
+
}
|
|
278
|
+
function parseKnowledgeSearchKinds(raw, commandName = "knowledge:search") {
|
|
279
|
+
if (raw === void 0) return void 0;
|
|
280
|
+
const requested = raw.split(",").map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0);
|
|
281
|
+
const valid = [];
|
|
282
|
+
const invalid = [];
|
|
283
|
+
for (const kind of requested) {
|
|
284
|
+
if (OM_SEARCH_HIT_KINDS.includes(kind)) {
|
|
285
|
+
valid.push(kind);
|
|
286
|
+
} else {
|
|
287
|
+
invalid.push(kind);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
if (invalid.length > 0) {
|
|
291
|
+
throw new Error(`${commandName}: unknown kind(s) "${invalid.join(", ")}". Valid: ${OM_SEARCH_HIT_KINDS.join(", ")}`);
|
|
292
|
+
}
|
|
293
|
+
return valid.length > 0 ? valid : void 0;
|
|
294
|
+
}
|
|
295
|
+
function formatKnowledgeSystemsList(entries) {
|
|
296
|
+
if (entries.length === 0) return "(no results)";
|
|
297
|
+
const pathWidth = Math.max(...entries.map((e) => e.path.length), 4);
|
|
298
|
+
const header = `${"PATH".padEnd(pathWidth)} LABEL`;
|
|
299
|
+
const divider = "-".repeat(header.length + 20);
|
|
300
|
+
const rows = entries.map((e) => {
|
|
301
|
+
const label = e.system.label ?? e.system.title ?? e.path;
|
|
302
|
+
return `${e.path.padEnd(pathWidth)} ${label}`;
|
|
303
|
+
});
|
|
304
|
+
return [header, divider, ...rows].join("\n");
|
|
305
|
+
}
|
|
306
|
+
function formatKnowledgeResourcesList(resources) {
|
|
307
|
+
if (resources.length === 0) return "(no results)";
|
|
308
|
+
const idWidth = Math.max(...resources.map((r) => r.id.length), 4);
|
|
309
|
+
const kindWidth = Math.max(...resources.map((r) => r.kind.length), 4);
|
|
310
|
+
const header = `${"ID".padEnd(idWidth)} ${"KIND".padEnd(kindWidth)} TITLE`;
|
|
311
|
+
const divider = "-".repeat(header.length + 20);
|
|
312
|
+
const rows = resources.map((r) => {
|
|
313
|
+
const title = r.title ?? r.id;
|
|
314
|
+
return `${r.id.padEnd(idWidth)} ${r.kind.padEnd(kindWidth)} ${title}`;
|
|
315
|
+
});
|
|
316
|
+
return [header, divider, ...rows].join("\n");
|
|
317
|
+
}
|
|
318
|
+
function formatKnowledgeRolesList(roles) {
|
|
319
|
+
if (roles.length === 0) return "(no results)";
|
|
320
|
+
const idWidth = Math.max(...roles.map((r) => r.id.length), 4);
|
|
321
|
+
const header = `${"ID".padEnd(idWidth)} TITLE`;
|
|
322
|
+
const divider = "-".repeat(header.length + 20);
|
|
323
|
+
const rows = roles.map((r) => `${r.id.padEnd(idWidth)} ${r.title}`);
|
|
324
|
+
return [header, divider, ...rows].join("\n");
|
|
325
|
+
}
|
|
326
|
+
function normalizeKnowledgeNodeId(id) {
|
|
327
|
+
return id.startsWith("knowledge:") ? id.slice("knowledge:".length) : id;
|
|
328
|
+
}
|
|
329
|
+
function formatKnowledgeInvocationLabel(invocation) {
|
|
330
|
+
switch (invocation.kind) {
|
|
331
|
+
case "slash-command":
|
|
332
|
+
return invocation.command;
|
|
333
|
+
case "mcp-tool":
|
|
334
|
+
return `${invocation.server}/${invocation.name}`;
|
|
335
|
+
case "api-endpoint":
|
|
336
|
+
return `${invocation.method} ${invocation.path}`;
|
|
337
|
+
case "script-execution":
|
|
338
|
+
return invocation.resourceId;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function pushActionSource(sources, seen, action) {
|
|
342
|
+
if (!action || action.invocations.length === 0) return;
|
|
343
|
+
const key = `action:${action.id}`;
|
|
344
|
+
if (seen.has(key)) return;
|
|
345
|
+
seen.add(key);
|
|
346
|
+
sources.push({
|
|
347
|
+
kind: "action",
|
|
348
|
+
id: action.id,
|
|
349
|
+
label: action.label,
|
|
350
|
+
targetNodeId: `action:${action.id}`,
|
|
351
|
+
invocations: action.invocations
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
function pushAgentResourceSource(sources, seen, resource) {
|
|
355
|
+
if (!resource || resource.kind !== "agent" || resource.invocations.length === 0) return;
|
|
356
|
+
const agentResource = resource;
|
|
357
|
+
const key = `agent-resource:${agentResource.id}`;
|
|
358
|
+
if (seen.has(key)) return;
|
|
359
|
+
seen.add(key);
|
|
360
|
+
sources.push({
|
|
361
|
+
kind: "agent-resource",
|
|
362
|
+
id: agentResource.id,
|
|
363
|
+
label: agentResource.id,
|
|
364
|
+
targetNodeId: `resource:${agentResource.id}`,
|
|
365
|
+
invocations: agentResource.invocations
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
function resolveKnowledgeInvocationNeighbors(model, id) {
|
|
369
|
+
const normalizedNodeId = normalizeKnowledgeNodeId(id);
|
|
370
|
+
const node = model.knowledge[normalizedNodeId];
|
|
371
|
+
if (!node) return void 0;
|
|
372
|
+
const sources = [];
|
|
373
|
+
const seen = /* @__PURE__ */ new Set();
|
|
374
|
+
for (const link of node.links) {
|
|
375
|
+
const target = link.target;
|
|
376
|
+
if (target.kind === "action") {
|
|
377
|
+
pushActionSource(sources, seen, model.actions[target.id]);
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if (target.kind === "resource") {
|
|
381
|
+
pushAgentResourceSource(sources, seen, model.resources[target.id]);
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (target.kind === "system") {
|
|
385
|
+
const system = getSystem(model, target.id);
|
|
386
|
+
for (const actionRef of system?.actions ?? []) {
|
|
387
|
+
pushActionSource(sources, seen, model.actions[actionRef.actionId]);
|
|
388
|
+
}
|
|
389
|
+
for (const resource of Object.values(model.resources)) {
|
|
390
|
+
if (resource.systemPath === target.id) {
|
|
391
|
+
pushAgentResourceSource(sources, seen, resource);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return {
|
|
397
|
+
id: node.id,
|
|
398
|
+
title: node.title,
|
|
399
|
+
invocationSources: sources.sort((a, b) => a.targetNodeId.localeCompare(b.targetNodeId))
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
function formatKnowledgeInvocationNeighbors(result) {
|
|
403
|
+
const lines = [`Invocation-bearing graph neighbors for ${result.id}`, ""];
|
|
404
|
+
if (result.invocationSources.length === 0) {
|
|
405
|
+
lines.push(" (none)");
|
|
406
|
+
} else {
|
|
407
|
+
for (const source of result.invocationSources) {
|
|
408
|
+
lines.push(`${source.kind}: ${source.id}`);
|
|
409
|
+
for (const invocation of source.invocations) {
|
|
410
|
+
lines.push(` ${invocation.kind}: ${formatKnowledgeInvocationLabel(invocation)}`);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return lines.join("\n");
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
export { OM_SEARCH_HIT_KINDS, byKind, byOwner, bySystem, formatIdsOnly, formatJson, formatKnowledgeInvocationLabel, formatKnowledgeInvocationNeighbors, formatKnowledgeResourcesList, formatKnowledgeRolesList, formatKnowledgeSystemsList, formatText, governedBy, governs, normalizeKnowledgeNodeId, parseKnowledgeSearchKinds, parseKnowledgeSearchLimit, parsePath, resolveKnowledgeInvocationNeighbors };
|
|
@@ -918,7 +918,6 @@ interface SystemEntry {
|
|
|
918
918
|
status?: 'active' | 'deprecated' | 'archived';
|
|
919
919
|
path?: string;
|
|
920
920
|
icon?: string;
|
|
921
|
-
color?: string;
|
|
922
921
|
uiPosition?: 'sidebar-primary' | 'sidebar-bottom';
|
|
923
922
|
enabled?: boolean;
|
|
924
923
|
devOnly?: boolean;
|
|
@@ -1091,7 +1090,7 @@ declare const ActionsDomainSchema: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodOb
|
|
|
1091
1090
|
* Generic empty default for the actions domain.
|
|
1092
1091
|
* Elevasis-specific action entries (LEAD_GEN_ACTION_ENTRIES, CRM_ACTION_ENTRIES,
|
|
1093
1092
|
* DEFAULT_ORGANIZATION_MODEL_ACTIONS) have been relocated to
|
|
1094
|
-
*
|
|
1093
|
+
* the tenant-owned organization model package.
|
|
1095
1094
|
* Tenant OM configs supply their own action entries via `resolveOrganizationModel`.
|
|
1096
1095
|
*/
|
|
1097
1096
|
declare const DEFAULT_ORGANIZATION_MODEL_ACTIONS: z.infer<typeof ActionsDomainSchema>;
|
|
@@ -3809,11 +3808,11 @@ declare const SETTINGS_ROLES_SURFACE_ID: "settings.roles";
|
|
|
3809
3808
|
*
|
|
3810
3809
|
* It does NOT contain Elevasis-specific identity, systems, or action entries.
|
|
3811
3810
|
* Runtime consumers that need the full Elevasis canonical model should import
|
|
3812
|
-
* `canonicalOrganizationModel` from
|
|
3811
|
+
* `canonicalOrganizationModel` from the tenant-owned organization model package instead.
|
|
3813
3812
|
*
|
|
3814
3813
|
* Elevasis-specific systems, actions (LEAD_GEN_ACTION_ENTRIES, CRM_ACTION_ENTRIES,
|
|
3815
3814
|
* DEFAULT_ORGANIZATION_MODEL_ACTIONS), and the platform system description have been
|
|
3816
|
-
* relocated to
|
|
3815
|
+
* relocated to the tenant-owned organization model package.
|
|
3817
3816
|
*/
|
|
3818
3817
|
|
|
3819
3818
|
declare const DEFAULT_ORGANIZATION_MODEL: OrganizationModel;
|