@pylabmit/agent-cmdb 1.5.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/LICENSE +21 -0
- package/README.md +249 -0
- package/dist/agent-preflight.d.ts +6 -0
- package/dist/agent-preflight.d.ts.map +1 -0
- package/dist/agent-preflight.js +55 -0
- package/dist/agent-preflight.js.map +1 -0
- package/dist/brain.d.ts +12 -0
- package/dist/brain.d.ts.map +1 -0
- package/dist/brain.js +372 -0
- package/dist/brain.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +495 -0
- package/dist/cli.js.map +1 -0
- package/dist/digest.d.ts +14 -0
- package/dist/digest.d.ts.map +1 -0
- package/dist/digest.js +122 -0
- package/dist/digest.js.map +1 -0
- package/dist/doctor.d.ts +9 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +170 -0
- package/dist/doctor.js.map +1 -0
- package/dist/duration.d.ts +2 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/duration.js +15 -0
- package/dist/duration.js.map +1 -0
- package/dist/engine.d.ts +12 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +12 -0
- package/dist/engine.js.map +1 -0
- package/dist/freshness.d.ts +3 -0
- package/dist/freshness.d.ts.map +1 -0
- package/dist/freshness.js +19 -0
- package/dist/freshness.js.map +1 -0
- package/dist/graph-engine.d.ts +4 -0
- package/dist/graph-engine.d.ts.map +1 -0
- package/dist/graph-engine.js +36 -0
- package/dist/graph-engine.js.map +1 -0
- package/dist/interface.d.ts +34 -0
- package/dist/interface.d.ts.map +1 -0
- package/dist/interface.js +91 -0
- package/dist/interface.js.map +1 -0
- package/dist/loader.d.ts +9 -0
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +199 -0
- package/dist/loader.js.map +1 -0
- package/dist/policy-engine.d.ts +7 -0
- package/dist/policy-engine.d.ts.map +1 -0
- package/dist/policy-engine.js +143 -0
- package/dist/policy-engine.js.map +1 -0
- package/dist/preflight-action.d.ts +3 -0
- package/dist/preflight-action.d.ts.map +1 -0
- package/dist/preflight-action.js +101 -0
- package/dist/preflight-action.js.map +1 -0
- package/dist/preflight.d.ts +4 -0
- package/dist/preflight.d.ts.map +1 -0
- package/dist/preflight.js +36 -0
- package/dist/preflight.js.map +1 -0
- package/dist/route-resolver.d.ts +6 -0
- package/dist/route-resolver.d.ts.map +1 -0
- package/dist/route-resolver.js +130 -0
- package/dist/route-resolver.js.map +1 -0
- package/dist/store.d.ts +15 -0
- package/dist/store.d.ts.map +1 -0
- package/dist/store.js +230 -0
- package/dist/store.js.map +1 -0
- package/dist/types.d.ts +277 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validator.d.ts +6 -0
- package/dist/validator.d.ts.map +1 -0
- package/dist/validator.js +165 -0
- package/dist/validator.js.map +1 -0
- package/examples/basic/control-plane.yaml +122 -0
- package/examples/multi-agent/control-plane.yaml +352 -0
- package/package.json +79 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { parseDuration } from './duration.js';
|
|
2
|
+
export function resolveSourceRoute(controlPlane, request) {
|
|
3
|
+
const normalizedRequest = normalizeSourceRouteRequest(request);
|
|
4
|
+
const profile = ensureProfile(controlPlane, normalizedRequest.profile);
|
|
5
|
+
const route = profile.routes.find((candidate) => candidate.intent === normalizedRequest.intent);
|
|
6
|
+
if (!route) {
|
|
7
|
+
throw new Error(`No source route configured for profile ${normalizedRequest.profile} and intent ${normalizedRequest.intent}.`);
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
profile: profile.id,
|
|
11
|
+
intent: normalizedRequest.intent,
|
|
12
|
+
sources: route.sources.map((sourceId) => ensureSource(controlPlane, sourceId)),
|
|
13
|
+
guardrails: profile.guardrails,
|
|
14
|
+
notes: route.notes,
|
|
15
|
+
...resolveFreshness(route.sources.map((sourceId) => ensureSource(controlPlane, sourceId)), normalizedRequest.freshness, normalizedRequest.now)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function inspectProfile(controlPlane, profileId) {
|
|
19
|
+
const profile = ensureProfile(controlPlane, requireNonEmptyString(profileId, 'Profile id'));
|
|
20
|
+
return {
|
|
21
|
+
id: profile.id,
|
|
22
|
+
name: profile.name,
|
|
23
|
+
purpose: profile.purpose,
|
|
24
|
+
guardrails: [...profile.guardrails],
|
|
25
|
+
routes: profile.routes.map((route) => ({
|
|
26
|
+
intent: route.intent,
|
|
27
|
+
sources: [...route.sources],
|
|
28
|
+
notes: route.notes
|
|
29
|
+
}))
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function ensureProfile(controlPlane, profileId) {
|
|
33
|
+
const profile = controlPlane.profiles.find((candidate) => candidate.id === profileId);
|
|
34
|
+
if (!profile) {
|
|
35
|
+
throw new Error(`Unknown profile: ${profileId}.`);
|
|
36
|
+
}
|
|
37
|
+
return profile;
|
|
38
|
+
}
|
|
39
|
+
export function ensureSource(controlPlane, sourceId) {
|
|
40
|
+
const source = controlPlane.sources.find((candidate) => candidate.id === sourceId);
|
|
41
|
+
if (!source) {
|
|
42
|
+
throw new Error(`Unknown source referenced by route: ${sourceId}.`);
|
|
43
|
+
}
|
|
44
|
+
return source;
|
|
45
|
+
}
|
|
46
|
+
function normalizeSourceRouteRequest(request) {
|
|
47
|
+
const record = requireRecord(request, 'Source route request');
|
|
48
|
+
return {
|
|
49
|
+
profile: requireNonEmptyString(record.profile, 'Source route request profile'),
|
|
50
|
+
intent: requireNonEmptyString(record.intent, 'Source route request intent'),
|
|
51
|
+
freshness: normalizeFreshness(record.freshness),
|
|
52
|
+
now: record.now === undefined ? undefined : requireNonEmptyString(record.now, 'Source route request now')
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function resolveFreshness(sources, freshness, nowInput) {
|
|
56
|
+
if (!freshness || freshness.length === 0) {
|
|
57
|
+
return {
|
|
58
|
+
staleSourceIds: [],
|
|
59
|
+
freshness: []
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const bySource = new Map(freshness.map((entry) => [entry.sourceId, entry]));
|
|
63
|
+
const now = nowInput ? parseTimestamp(nowInput, 'Source route request now') : Date.now();
|
|
64
|
+
const statuses = sources
|
|
65
|
+
.filter((source) => source.freshnessTtl)
|
|
66
|
+
.map((source) => {
|
|
67
|
+
const ttl = source.freshnessTtl;
|
|
68
|
+
if (!ttl) {
|
|
69
|
+
throw new Error(`Source ${source.id} has missing freshness TTL.`);
|
|
70
|
+
}
|
|
71
|
+
const snapshot = bySource.get(source.id);
|
|
72
|
+
if (!snapshot) {
|
|
73
|
+
return {
|
|
74
|
+
sourceId: source.id,
|
|
75
|
+
ttl,
|
|
76
|
+
stale: true,
|
|
77
|
+
reason: 'No freshness snapshot supplied.'
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
const lastUpdatedMs = parseTimestamp(snapshot.lastUpdated, `Freshness lastUpdated for ${source.id}`);
|
|
81
|
+
const ageMs = Math.max(0, now - lastUpdatedMs);
|
|
82
|
+
const stale = ageMs > parseDuration(ttl);
|
|
83
|
+
return {
|
|
84
|
+
sourceId: source.id,
|
|
85
|
+
ttl,
|
|
86
|
+
lastUpdated: snapshot.lastUpdated,
|
|
87
|
+
ageMs,
|
|
88
|
+
stale,
|
|
89
|
+
reason: stale ? `Source ${source.id} is older than ${ttl}.` : undefined
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
staleSourceIds: statuses.filter((status) => status.stale).map((status) => status.sourceId),
|
|
94
|
+
freshness: statuses
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function normalizeFreshness(value) {
|
|
98
|
+
if (value === undefined)
|
|
99
|
+
return undefined;
|
|
100
|
+
if (!Array.isArray(value)) {
|
|
101
|
+
throw new Error('Source route request freshness must be an array.');
|
|
102
|
+
}
|
|
103
|
+
return value.map((entry) => {
|
|
104
|
+
const record = requireRecord(entry, 'Source freshness input');
|
|
105
|
+
return {
|
|
106
|
+
sourceId: requireNonEmptyString(record.sourceId, 'Source freshness sourceId'),
|
|
107
|
+
lastUpdated: requireNonEmptyString(record.lastUpdated, 'Source freshness lastUpdated')
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function parseTimestamp(value, label) {
|
|
112
|
+
const timestamp = Date.parse(value);
|
|
113
|
+
if (Number.isNaN(timestamp)) {
|
|
114
|
+
throw new Error(`${label} must be an ISO timestamp.`);
|
|
115
|
+
}
|
|
116
|
+
return timestamp;
|
|
117
|
+
}
|
|
118
|
+
function requireRecord(value, label) {
|
|
119
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
120
|
+
throw new Error(`${label} must be an object.`);
|
|
121
|
+
}
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
function requireNonEmptyString(value, label) {
|
|
125
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
126
|
+
throw new Error(`${label} must be a non-empty string.`);
|
|
127
|
+
}
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=route-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-resolver.js","sourceRoot":"","sources":["../src/route-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAY9C,MAAM,UAAU,kBAAkB,CAChC,YAA0B,EAC1B,OAA2B;IAE3B,MAAM,iBAAiB,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAC;IAC/D,MAAM,OAAO,GAAG,aAAa,CAAC,YAAY,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACvE,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,KAAK,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEhG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,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,4BAA4B,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,aAAa,CAAC,KAAc,EAAE,KAAa;IAClD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qBAAqB,CAAC,CAAC;IACjD,CAAC;IACD,OAAO,KAAgC,CAAC;AAC1C,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc,EAAE,KAAa;IAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,8BAA8B,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ChangeInput, ChangeQuery, ChangeRecord, EvidenceInput, EvidenceQuery, EvidenceRecord } from './types.js';
|
|
2
|
+
export declare class CorruptStoreError extends Error {
|
|
3
|
+
constructor(fileName: string, lineNumber: number, detail: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class StoreWriteError extends Error {
|
|
6
|
+
constructor(storeDir: string, fileName: string, detail: string);
|
|
7
|
+
}
|
|
8
|
+
export declare function appendEvidence(storeDir: string, input: EvidenceInput): Promise<EvidenceRecord>;
|
|
9
|
+
export declare function listEvidence(storeDir: string, query?: EvidenceQuery): Promise<EvidenceRecord[]>;
|
|
10
|
+
export declare function appendChange(storeDir: string, input: ChangeInput): Promise<ChangeRecord>;
|
|
11
|
+
export declare function listChanges(storeDir: string, query?: ChangeQuery): Promise<ChangeRecord[]>;
|
|
12
|
+
export declare function sanitizeText(value: string, options?: {
|
|
13
|
+
preserveLineBreaks?: boolean;
|
|
14
|
+
}): string;
|
|
15
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EAEX,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EAGf,MAAM,YAAY,CAAC;AAOpB,qBAAa,iBAAkB,SAAQ,KAAK;gBAC9B,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAIjE;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI/D;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC,CAiBpG;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,GAAE,aAAkB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAYzG;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAiB9F;AAED,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,GAAE,WAAgB,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAWpG;AAoDD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CAYlG"}
|
package/dist/store.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { appendFile, mkdir, readFile } from 'node:fs/promises';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
const evidenceFile = 'evidence.jsonl';
|
|
5
|
+
const changesFile = 'changes.jsonl';
|
|
6
|
+
const maxScalarLength = 2048;
|
|
7
|
+
const maxTextLength = 16000;
|
|
8
|
+
export class CorruptStoreError extends Error {
|
|
9
|
+
constructor(fileName, lineNumber, detail) {
|
|
10
|
+
super(`Corrupt JSONL store ${fileName}:${lineNumber}: ${detail}`);
|
|
11
|
+
this.name = 'CorruptStoreError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class StoreWriteError extends Error {
|
|
15
|
+
constructor(storeDir, fileName, detail) {
|
|
16
|
+
super(`Failed to write JSONL store ${join(storeDir, fileName)}: ${detail}`);
|
|
17
|
+
this.name = 'StoreWriteError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export async function appendEvidence(storeDir, input) {
|
|
21
|
+
const recordInput = requireRecord(input, 'Evidence input');
|
|
22
|
+
const record = {
|
|
23
|
+
profile: sanitizeScalar(requireString(recordInput.profile, 'Evidence profile')),
|
|
24
|
+
source: sanitizeScalar(requireString(recordInput.source, 'Evidence source')),
|
|
25
|
+
intent: sanitizeScalar(requireString(recordInput.intent, 'Evidence intent')),
|
|
26
|
+
summary: sanitizeText(requireString(recordInput.summary, 'Evidence summary')),
|
|
27
|
+
trust: parseTrustLevel(recordInput.trust),
|
|
28
|
+
capturedAt: sanitizeScalar(requireString(recordInput.capturedAt, 'Evidence capturedAt')),
|
|
29
|
+
links: optionalStringArray(recordInput.links, 'Evidence links')?.map(sanitizeScalar),
|
|
30
|
+
tags: optionalStringArray(recordInput.tags, 'Evidence tags')?.map(sanitizeScalar),
|
|
31
|
+
id: `ev_${randomUUID()}`
|
|
32
|
+
};
|
|
33
|
+
await appendJsonLine(storeDir, evidenceFile, record);
|
|
34
|
+
return record;
|
|
35
|
+
}
|
|
36
|
+
export async function listEvidence(storeDir, query = {}) {
|
|
37
|
+
const normalizedQuery = normalizeEvidenceQuery(query);
|
|
38
|
+
const records = await readJsonLines(storeDir, evidenceFile);
|
|
39
|
+
return records.filter((record) => {
|
|
40
|
+
if (definedFilter(normalizedQuery.profile) && record.profile !== sanitizeScalar(normalizedQuery.profile))
|
|
41
|
+
return false;
|
|
42
|
+
if (definedFilter(normalizedQuery.source) && record.source !== sanitizeScalar(normalizedQuery.source))
|
|
43
|
+
return false;
|
|
44
|
+
if (definedFilter(normalizedQuery.intent) && record.intent !== sanitizeScalar(normalizedQuery.intent))
|
|
45
|
+
return false;
|
|
46
|
+
if (normalizedQuery.trust && record.trust !== normalizedQuery.trust)
|
|
47
|
+
return false;
|
|
48
|
+
if (definedFilter(normalizedQuery.tag) && !record.tags?.includes(sanitizeScalar(normalizedQuery.tag)))
|
|
49
|
+
return false;
|
|
50
|
+
return true;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export async function appendChange(storeDir, input) {
|
|
54
|
+
const recordInput = requireRecord(input, 'Change input');
|
|
55
|
+
const record = {
|
|
56
|
+
target: sanitizeScalar(requireString(recordInput.target, 'Change target')),
|
|
57
|
+
targetType: parseObjectKind(recordInput.targetType),
|
|
58
|
+
action: parseChangeAction(recordInput.action),
|
|
59
|
+
actor: sanitizeScalar(requireString(recordInput.actor, 'Change actor')),
|
|
60
|
+
reason: sanitizeText(requireString(recordInput.reason, 'Change reason')),
|
|
61
|
+
changedAt: sanitizeScalar(requireString(recordInput.changedAt, 'Change changedAt')),
|
|
62
|
+
before: sanitizeJsonValue(recordInput.before),
|
|
63
|
+
after: sanitizeJsonValue(recordInput.after),
|
|
64
|
+
id: `chg_${randomUUID()}`
|
|
65
|
+
};
|
|
66
|
+
await appendJsonLine(storeDir, changesFile, record);
|
|
67
|
+
return record;
|
|
68
|
+
}
|
|
69
|
+
export async function listChanges(storeDir, query = {}) {
|
|
70
|
+
const normalizedQuery = normalizeChangeQuery(query);
|
|
71
|
+
const records = await readJsonLines(storeDir, changesFile);
|
|
72
|
+
return records.filter((record) => {
|
|
73
|
+
if (definedFilter(normalizedQuery.target) && record.target !== sanitizeScalar(normalizedQuery.target))
|
|
74
|
+
return false;
|
|
75
|
+
if (normalizedQuery.targetType && record.targetType !== normalizedQuery.targetType)
|
|
76
|
+
return false;
|
|
77
|
+
if (definedFilter(normalizedQuery.actor) && record.actor !== sanitizeScalar(normalizedQuery.actor))
|
|
78
|
+
return false;
|
|
79
|
+
if (normalizedQuery.action && record.action !== normalizedQuery.action)
|
|
80
|
+
return false;
|
|
81
|
+
return true;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async function appendJsonLine(storeDir, fileName, record) {
|
|
85
|
+
try {
|
|
86
|
+
await mkdir(storeDir, { recursive: true });
|
|
87
|
+
await appendFile(join(storeDir, fileName), `${JSON.stringify(record)}\n`, 'utf8');
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
91
|
+
throw new StoreWriteError(storeDir, fileName, detail);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function readJsonLines(storeDir, fileName) {
|
|
95
|
+
const content = await readFileIfExists(join(storeDir, fileName));
|
|
96
|
+
if (!content.trim())
|
|
97
|
+
return [];
|
|
98
|
+
const records = [];
|
|
99
|
+
const lines = content.split(/\r?\n/);
|
|
100
|
+
for (const [index, rawLine] of lines.entries()) {
|
|
101
|
+
const line = rawLine.trim();
|
|
102
|
+
if (!line)
|
|
103
|
+
continue;
|
|
104
|
+
try {
|
|
105
|
+
const parsed = JSON.parse(line);
|
|
106
|
+
assertObjectRecord(parsed, fileName, index + 1);
|
|
107
|
+
records.push(parsed);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (error instanceof CorruptStoreError)
|
|
111
|
+
throw error;
|
|
112
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
113
|
+
throw new CorruptStoreError(fileName, index + 1, detail);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return records;
|
|
117
|
+
}
|
|
118
|
+
async function readFileIfExists(filePath) {
|
|
119
|
+
try {
|
|
120
|
+
return await readFile(filePath, 'utf8');
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
if (error && typeof error === 'object' && 'code' in error && error.code === 'ENOENT') {
|
|
124
|
+
return '';
|
|
125
|
+
}
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function sanitizeScalar(value) {
|
|
130
|
+
return sanitizeText(value).slice(0, maxScalarLength);
|
|
131
|
+
}
|
|
132
|
+
export function sanitizeText(value, options = {}) {
|
|
133
|
+
const controlCharacters = options.preserveLineBreaks
|
|
134
|
+
? /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u200B-\u200F\u202A-\u202E\u2060-\u206F]/g
|
|
135
|
+
: /[\u0000-\u001F\u007F-\u009F\u200B-\u200F\u202A-\u202E\u2060-\u206F]/g;
|
|
136
|
+
const sanitized = value
|
|
137
|
+
.normalize('NFKC')
|
|
138
|
+
.replace(/\r\n?/g, '\n')
|
|
139
|
+
.replace(controlCharacters, ' ')
|
|
140
|
+
.replace(/\b(SYSTEM|DEVELOPER|USER|ASSISTANT|TOOL)\s*:/gi, '[SANITIZED_INSTRUCTION]:')
|
|
141
|
+
.trim();
|
|
142
|
+
return (options.preserveLineBreaks ? sanitized : sanitized.replace(/\s+/g, ' ')).slice(0, maxTextLength);
|
|
143
|
+
}
|
|
144
|
+
function sanitizeJsonValue(value) {
|
|
145
|
+
if (typeof value === 'string')
|
|
146
|
+
return sanitizeText(value);
|
|
147
|
+
if (Array.isArray(value))
|
|
148
|
+
return value.map(sanitizeJsonValue);
|
|
149
|
+
if (value && typeof value === 'object') {
|
|
150
|
+
return Object.fromEntries(Object.entries(value).map(([key, nestedValue]) => [sanitizeScalar(key), sanitizeJsonValue(nestedValue)]));
|
|
151
|
+
}
|
|
152
|
+
return value;
|
|
153
|
+
}
|
|
154
|
+
function normalizeEvidenceQuery(query) {
|
|
155
|
+
const record = requireRecord(query, 'Evidence query');
|
|
156
|
+
return {
|
|
157
|
+
profile: optionalString(record.profile, 'Evidence query profile'),
|
|
158
|
+
source: optionalString(record.source, 'Evidence query source'),
|
|
159
|
+
intent: optionalString(record.intent, 'Evidence query intent'),
|
|
160
|
+
trust: record.trust === undefined ? undefined : parseTrustLevel(record.trust),
|
|
161
|
+
tag: optionalString(record.tag, 'Evidence query tag')
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function normalizeChangeQuery(query) {
|
|
165
|
+
const record = requireRecord(query, 'Change query');
|
|
166
|
+
return {
|
|
167
|
+
target: optionalString(record.target, 'Change query target'),
|
|
168
|
+
targetType: record.targetType === undefined ? undefined : parseObjectKind(record.targetType),
|
|
169
|
+
actor: optionalString(record.actor, 'Change query actor'),
|
|
170
|
+
action: record.action === undefined ? undefined : parseChangeAction(record.action)
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function parseTrustLevel(value) {
|
|
174
|
+
const values = ['high', 'medium', 'low'];
|
|
175
|
+
const trust = requireString(value, 'Evidence trust');
|
|
176
|
+
if (!values.includes(trust)) {
|
|
177
|
+
throw new Error(`Invalid trust level: ${trust}. Valid values: ${values.join(', ')}.`);
|
|
178
|
+
}
|
|
179
|
+
return trust;
|
|
180
|
+
}
|
|
181
|
+
function parseObjectKind(value) {
|
|
182
|
+
const values = ['profile', 'source', 'tool', 'job', 'memory', 'policy', 'workspace'];
|
|
183
|
+
const kind = requireString(value, 'Change targetType');
|
|
184
|
+
if (!values.includes(kind)) {
|
|
185
|
+
throw new Error(`Invalid object kind: ${kind}. Valid values: ${values.join(', ')}.`);
|
|
186
|
+
}
|
|
187
|
+
return kind;
|
|
188
|
+
}
|
|
189
|
+
function parseChangeAction(value) {
|
|
190
|
+
const values = ['create', 'update', 'pause', 'resume', 'delete', 'verify'];
|
|
191
|
+
const action = requireString(value, 'Change action');
|
|
192
|
+
if (!values.includes(action)) {
|
|
193
|
+
throw new Error(`Invalid change action: ${action}. Valid values: ${values.join(', ')}.`);
|
|
194
|
+
}
|
|
195
|
+
return action;
|
|
196
|
+
}
|
|
197
|
+
function optionalStringArray(value, label) {
|
|
198
|
+
if (value === undefined)
|
|
199
|
+
return undefined;
|
|
200
|
+
if (!Array.isArray(value)) {
|
|
201
|
+
throw new Error(`${label} must be an array of strings.`);
|
|
202
|
+
}
|
|
203
|
+
return value.map((item) => requireString(item, label));
|
|
204
|
+
}
|
|
205
|
+
function optionalString(value, label) {
|
|
206
|
+
if (value === undefined)
|
|
207
|
+
return undefined;
|
|
208
|
+
return requireString(value, label);
|
|
209
|
+
}
|
|
210
|
+
function requireString(value, label) {
|
|
211
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
212
|
+
throw new Error(`${label} must be a non-empty string.`);
|
|
213
|
+
}
|
|
214
|
+
return value;
|
|
215
|
+
}
|
|
216
|
+
function requireRecord(value, label) {
|
|
217
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
218
|
+
throw new Error(`${label} must be an object.`);
|
|
219
|
+
}
|
|
220
|
+
return value;
|
|
221
|
+
}
|
|
222
|
+
function assertObjectRecord(value, fileName, lineNumber) {
|
|
223
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
224
|
+
throw new CorruptStoreError(fileName, lineNumber, 'expected JSON object record');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
function definedFilter(value) {
|
|
228
|
+
return value !== undefined && value.trim().length > 0;
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAajC,MAAM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K,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,iBAAiB,CAAC,QAAQ,EAAE,UAAU,EAAE,6BAA6B,CAAC,CAAC;IACnF,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAyB;IAC9C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AACxD,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
export type PolicyEffect = 'allow' | 'deny' | 'approval_required';
|
|
2
|
+
export type ObjectKind = 'profile' | 'source' | 'tool' | 'job' | 'memory' | 'policy' | 'workspace';
|
|
3
|
+
export type ObjectStatus = 'active' | 'paused' | 'blocked' | 'planned';
|
|
4
|
+
export type TrustLevel = 'high' | 'medium' | 'low';
|
|
5
|
+
export type IssueSeverity = 'error' | 'warning';
|
|
6
|
+
export type ChangeAction = 'create' | 'update' | 'pause' | 'resume' | 'delete' | 'verify';
|
|
7
|
+
export type BrainEntityKind = 'person' | 'company' | 'topic' | 'tool' | 'project';
|
|
8
|
+
export interface SourceRef {
|
|
9
|
+
id: string;
|
|
10
|
+
label: string;
|
|
11
|
+
kind: 'memory' | 'tool' | 'oauth' | 'wiki' | 'web' | 'evidence';
|
|
12
|
+
readOnly: boolean;
|
|
13
|
+
notes?: string;
|
|
14
|
+
freshnessTtl?: string;
|
|
15
|
+
brainEntityId?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface SourceRoute {
|
|
18
|
+
intent: string;
|
|
19
|
+
sources: string[];
|
|
20
|
+
notes?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface AgentProfile {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
purpose: string;
|
|
26
|
+
guardrails: string[];
|
|
27
|
+
routes: SourceRoute[];
|
|
28
|
+
}
|
|
29
|
+
export interface CmdbObject {
|
|
30
|
+
id: string;
|
|
31
|
+
kind: ObjectKind;
|
|
32
|
+
label: string;
|
|
33
|
+
status: ObjectStatus;
|
|
34
|
+
profile?: string;
|
|
35
|
+
tags: string[];
|
|
36
|
+
dependsOn?: string[];
|
|
37
|
+
notes?: string;
|
|
38
|
+
}
|
|
39
|
+
export interface Relationship {
|
|
40
|
+
from: string;
|
|
41
|
+
to: string;
|
|
42
|
+
type: 'uses' | 'owns' | 'governed_by' | 'depends_on' | 'blocks' | 'writes_to';
|
|
43
|
+
notes?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface PolicyRule {
|
|
46
|
+
id: string;
|
|
47
|
+
effect: PolicyEffect;
|
|
48
|
+
actions: string[];
|
|
49
|
+
profiles?: string[];
|
|
50
|
+
tools?: string[];
|
|
51
|
+
reason: string;
|
|
52
|
+
code?: string;
|
|
53
|
+
canEscalate?: boolean;
|
|
54
|
+
suggestedAlternative?: string;
|
|
55
|
+
}
|
|
56
|
+
export interface ControlPlane {
|
|
57
|
+
version: string;
|
|
58
|
+
updatedAt: string;
|
|
59
|
+
sources: SourceRef[];
|
|
60
|
+
profiles: AgentProfile[];
|
|
61
|
+
policies: PolicyRule[];
|
|
62
|
+
objects: CmdbObject[];
|
|
63
|
+
relationships: Relationship[];
|
|
64
|
+
}
|
|
65
|
+
export interface PolicyRequest {
|
|
66
|
+
profile: string;
|
|
67
|
+
action: string;
|
|
68
|
+
tool?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface PolicyDecision {
|
|
71
|
+
effect: PolicyEffect;
|
|
72
|
+
ruleId: string;
|
|
73
|
+
code: string;
|
|
74
|
+
reason: string;
|
|
75
|
+
profile: string;
|
|
76
|
+
action: string;
|
|
77
|
+
tool?: string;
|
|
78
|
+
canEscalate: boolean;
|
|
79
|
+
suggestedAlternative?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface SourceRouteRequest {
|
|
82
|
+
profile: string;
|
|
83
|
+
intent: string;
|
|
84
|
+
freshness?: SourceFreshnessInput[];
|
|
85
|
+
now?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface SourceFreshnessInput {
|
|
88
|
+
sourceId: string;
|
|
89
|
+
lastUpdated: string;
|
|
90
|
+
}
|
|
91
|
+
export interface SourceFreshnessStatus {
|
|
92
|
+
sourceId: string;
|
|
93
|
+
ttl: string;
|
|
94
|
+
lastUpdated?: string;
|
|
95
|
+
ageMs?: number;
|
|
96
|
+
stale: boolean;
|
|
97
|
+
reason?: string;
|
|
98
|
+
}
|
|
99
|
+
export interface ResolvedSourceRoute {
|
|
100
|
+
profile: string;
|
|
101
|
+
intent: string;
|
|
102
|
+
sources: SourceRef[];
|
|
103
|
+
guardrails: string[];
|
|
104
|
+
notes?: string;
|
|
105
|
+
staleSourceIds: string[];
|
|
106
|
+
freshness: SourceFreshnessStatus[];
|
|
107
|
+
}
|
|
108
|
+
export interface ProfileInspection {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
purpose: string;
|
|
112
|
+
guardrails: string[];
|
|
113
|
+
routes: SourceRoute[];
|
|
114
|
+
}
|
|
115
|
+
export interface ObjectQuery {
|
|
116
|
+
profile?: string;
|
|
117
|
+
kind?: ObjectKind;
|
|
118
|
+
status?: ObjectStatus;
|
|
119
|
+
tag?: string;
|
|
120
|
+
}
|
|
121
|
+
export interface GraphNeighbor {
|
|
122
|
+
relationship: Relationship;
|
|
123
|
+
node: CmdbObject | SourceRef | AgentProfile | PolicyRule;
|
|
124
|
+
}
|
|
125
|
+
export interface GraphResult {
|
|
126
|
+
node: CmdbObject | SourceRef | AgentProfile | PolicyRule;
|
|
127
|
+
neighbors: GraphNeighbor[];
|
|
128
|
+
}
|
|
129
|
+
export interface ValidationIssue {
|
|
130
|
+
severity: IssueSeverity;
|
|
131
|
+
code: string;
|
|
132
|
+
message: string;
|
|
133
|
+
}
|
|
134
|
+
export interface PreflightRequest extends PolicyRequest {
|
|
135
|
+
intent?: string;
|
|
136
|
+
dryRun?: boolean;
|
|
137
|
+
freshness?: SourceFreshnessInput[];
|
|
138
|
+
now?: string;
|
|
139
|
+
}
|
|
140
|
+
export interface PreflightResult {
|
|
141
|
+
allowed: boolean;
|
|
142
|
+
approvalRequired: boolean;
|
|
143
|
+
decision: PolicyDecision;
|
|
144
|
+
route?: ResolvedSourceRoute;
|
|
145
|
+
routeExecutable: boolean;
|
|
146
|
+
guardrails: string[];
|
|
147
|
+
warnings: string[];
|
|
148
|
+
dryRun: boolean;
|
|
149
|
+
}
|
|
150
|
+
export interface AgentCmdbReport {
|
|
151
|
+
version: string;
|
|
152
|
+
updatedAt: string;
|
|
153
|
+
counts: {
|
|
154
|
+
profiles: number;
|
|
155
|
+
sources: number;
|
|
156
|
+
policies: number;
|
|
157
|
+
objects: number;
|
|
158
|
+
relationships: number;
|
|
159
|
+
};
|
|
160
|
+
guardrails: {
|
|
161
|
+
deniedActions: string[];
|
|
162
|
+
pausedObjects: string[];
|
|
163
|
+
blockedObjects: string[];
|
|
164
|
+
};
|
|
165
|
+
validation: {
|
|
166
|
+
errors: number;
|
|
167
|
+
warnings: number;
|
|
168
|
+
issues: ValidationIssue[];
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export interface EvidenceRecord {
|
|
172
|
+
id: string;
|
|
173
|
+
profile: string;
|
|
174
|
+
source: string;
|
|
175
|
+
intent: string;
|
|
176
|
+
summary: string;
|
|
177
|
+
trust: TrustLevel;
|
|
178
|
+
capturedAt: string;
|
|
179
|
+
links?: string[];
|
|
180
|
+
tags?: string[];
|
|
181
|
+
}
|
|
182
|
+
export type EvidenceInput = Omit<EvidenceRecord, 'id'>;
|
|
183
|
+
export interface EvidenceQuery {
|
|
184
|
+
profile?: string;
|
|
185
|
+
source?: string;
|
|
186
|
+
intent?: string;
|
|
187
|
+
trust?: TrustLevel;
|
|
188
|
+
tag?: string;
|
|
189
|
+
}
|
|
190
|
+
export interface ChangeRecord {
|
|
191
|
+
id: string;
|
|
192
|
+
target: string;
|
|
193
|
+
targetType: ObjectKind;
|
|
194
|
+
action: ChangeAction;
|
|
195
|
+
actor: string;
|
|
196
|
+
reason: string;
|
|
197
|
+
changedAt: string;
|
|
198
|
+
before?: unknown;
|
|
199
|
+
after?: unknown;
|
|
200
|
+
}
|
|
201
|
+
export type ChangeInput = Omit<ChangeRecord, 'id'>;
|
|
202
|
+
export interface ChangeQuery {
|
|
203
|
+
target?: string;
|
|
204
|
+
targetType?: ObjectKind;
|
|
205
|
+
actor?: string;
|
|
206
|
+
action?: ChangeAction;
|
|
207
|
+
}
|
|
208
|
+
export interface BrainEntity {
|
|
209
|
+
id: string;
|
|
210
|
+
kind: BrainEntityKind;
|
|
211
|
+
name: string;
|
|
212
|
+
filePath: string;
|
|
213
|
+
tags: string[];
|
|
214
|
+
trust: TrustLevel;
|
|
215
|
+
lastUpdated: string;
|
|
216
|
+
lastUpdatedBy: string;
|
|
217
|
+
summary: string;
|
|
218
|
+
relatedEntities?: string[];
|
|
219
|
+
}
|
|
220
|
+
export interface BrainIndex {
|
|
221
|
+
version: string;
|
|
222
|
+
updatedAt: string;
|
|
223
|
+
entities: BrainEntity[];
|
|
224
|
+
}
|
|
225
|
+
export interface BrainReadResult {
|
|
226
|
+
entity: BrainEntity;
|
|
227
|
+
content: string;
|
|
228
|
+
ageMs: number;
|
|
229
|
+
stale: boolean;
|
|
230
|
+
}
|
|
231
|
+
export interface BrainWriteInput {
|
|
232
|
+
entityId: string;
|
|
233
|
+
content: string;
|
|
234
|
+
actor: string;
|
|
235
|
+
reason: string;
|
|
236
|
+
appendOnly?: boolean;
|
|
237
|
+
}
|
|
238
|
+
export interface BrainSearchQuery {
|
|
239
|
+
kind?: BrainEntityKind;
|
|
240
|
+
tag?: string;
|
|
241
|
+
updatedAfter?: string;
|
|
242
|
+
updatedBefore?: string;
|
|
243
|
+
keyword?: string;
|
|
244
|
+
}
|
|
245
|
+
export interface DigestResult {
|
|
246
|
+
profile: string;
|
|
247
|
+
date: string;
|
|
248
|
+
evidenceCount: number;
|
|
249
|
+
changesCount: number;
|
|
250
|
+
entitiesUpdated: string[];
|
|
251
|
+
digestPath: string;
|
|
252
|
+
summary: string;
|
|
253
|
+
}
|
|
254
|
+
export interface DoctorReport {
|
|
255
|
+
ok: boolean;
|
|
256
|
+
checkedAt: string;
|
|
257
|
+
errors: string[];
|
|
258
|
+
warnings: string[];
|
|
259
|
+
controlPlane: {
|
|
260
|
+
errors: number;
|
|
261
|
+
warnings: number;
|
|
262
|
+
};
|
|
263
|
+
store: {
|
|
264
|
+
writable: boolean;
|
|
265
|
+
evidenceCount: number;
|
|
266
|
+
changesCount: number;
|
|
267
|
+
lastWriteAt?: string;
|
|
268
|
+
};
|
|
269
|
+
brain: {
|
|
270
|
+
configured: boolean;
|
|
271
|
+
indexReadable: boolean;
|
|
272
|
+
entityCount: number;
|
|
273
|
+
staleEntityCount: number;
|
|
274
|
+
orphanedFiles: string[];
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
//# sourceMappingURL=types.d.ts.map
|