@lightdash-tools/common 0.5.0 → 0.7.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/agentops/extract-yaml-project.d.ts +7 -0
- package/dist/agentops/extract-yaml-project.js +42 -0
- package/dist/agentops/formatters.d.ts +5 -0
- package/dist/agentops/formatters.js +47 -0
- package/dist/agentops/snapshots.d.ts +32 -0
- package/dist/agentops/snapshots.js +34 -0
- package/dist/agentops/types.d.ts +224 -0
- package/dist/agentops/types.js +430 -0
- package/dist/argument-validation.d.ts +25 -0
- package/dist/argument-validation.js +199 -0
- package/dist/argument-validation.test.d.ts +1 -0
- package/dist/argument-validation.test.js +183 -0
- package/dist/audit.d.ts +9 -2
- package/dist/audit.js +17 -2
- package/dist/audit.test.d.ts +1 -0
- package/dist/audit.test.js +73 -0
- package/dist/env.d.ts +8 -0
- package/dist/env.js +9 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +14 -0
- package/dist/input-validation.d.ts +35 -0
- package/dist/input-validation.js +87 -0
- package/dist/input-validation.test.js +93 -0
- package/dist/operations/agent-safe.d.ts +7 -0
- package/dist/operations/agent-safe.js +16 -0
- package/dist/operations/ai-agents.d.ts +6 -0
- package/dist/operations/ai-agents.js +411 -0
- package/dist/operations/index.d.ts +5 -0
- package/dist/operations/index.js +16 -0
- package/dist/operations/parity.test.d.ts +1 -0
- package/dist/operations/parity.test.js +28 -0
- package/dist/operations/registry.d.ts +10 -0
- package/dist/operations/registry.js +35 -0
- package/dist/operations/registry.test.d.ts +1 -0
- package/dist/operations/registry.test.js +196 -0
- package/dist/operations/types.d.ts +69 -0
- package/dist/operations/types.js +70 -0
- package/dist/operations/types.test.d.ts +1 -0
- package/dist/operations/types.test.js +104 -0
- package/dist/operations/users.d.ts +6 -0
- package/dist/operations/users.js +60 -0
- package/dist/safety.d.ts +27 -2
- package/dist/safety.js +52 -5
- package/dist/safety.test.js +217 -4
- package/dist/types/generated/openapi-types.d.ts +35895 -10622
- package/dist/types/generated/openapi-types.js +0 -1
- package/dist/types/lightdash-api.d.ts +1 -1
- package/dist/types/v1/ai-agents.d.ts +112 -3
- package/dist/types/v1/charts.d.ts +5 -3
- package/dist/types/v1/dashboards.d.ts +13 -0
- package/dist/types/v1/index.d.ts +45 -8
- package/dist/types/v1/index.js +1 -1
- package/dist/types/v1/lightdash-api.d.ts +107 -16
- package/dist/types/v1/users.d.ts +4 -0
- package/dist/types/v2/content.d.ts +2 -0
- package/dist/types/v2/content.js +8 -0
- package/dist/types/v2/index.d.ts +11 -9
- package/dist/types/v2/index.js +1 -1
- package/package.json +16 -3
- package/src/agentops/extract-yaml-project.ts +42 -0
- package/src/agentops/formatters.ts +52 -0
- package/src/agentops/snapshots.ts +56 -0
- package/src/agentops/types.ts +599 -0
- package/src/argument-validation.test.ts +270 -0
- package/src/argument-validation.ts +240 -0
- package/src/audit.test.ts +87 -0
- package/src/audit.ts +21 -3
- package/src/env.ts +9 -0
- package/src/index.test.ts +1 -0
- package/src/index.ts +16 -1
- package/src/input-validation.test.ts +157 -1
- package/src/input-validation.ts +95 -0
- package/src/operations/agent-safe.ts +18 -0
- package/src/operations/ai-agents.ts +451 -0
- package/src/operations/index.ts +19 -0
- package/src/operations/parity.test.ts +35 -0
- package/src/operations/registry.test.ts +219 -0
- package/src/operations/registry.ts +44 -0
- package/src/operations/types.test.ts +148 -0
- package/src/operations/types.ts +168 -0
- package/src/operations/users.ts +67 -0
- package/src/safety.test.ts +276 -4
- package/src/safety.ts +72 -4
- package/src/types/generated/openapi-types.ts +37017 -11241
- package/src/types/lightdash-api.ts +39 -0
- package/src/types/v1/ai-agents.ts +133 -3
- package/src/types/v1/charts.ts +5 -3
- package/src/types/v1/dashboards.ts +19 -0
- package/src/types/v1/index.ts +51 -8
- package/src/types/v1/lightdash-api.ts +129 -20
- package/src/types/v1/users.ts +4 -0
- package/src/types/v2/content.ts +8 -0
- package/src/types/v2/index.ts +11 -9
- package/tsconfig.json +1 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** True when MCP tool args carry AgentOps YAML documents that imply a project scope. */
|
|
2
|
+
export declare function hasYamlProjectDocumentArgs(args: unknown): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Extracts project UUIDs from MCP tool args, including YAML document fields
|
|
5
|
+
* (`bundleYaml`, `gateYaml`) used by AgentOps composite tools.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractProjectUuidsFromToolArgs(args: unknown): string[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hasYamlProjectDocumentArgs = hasYamlProjectDocumentArgs;
|
|
4
|
+
exports.extractProjectUuidsFromToolArgs = extractProjectUuidsFromToolArgs;
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
/** True when MCP tool args carry AgentOps YAML documents that imply a project scope. */
|
|
7
|
+
function hasYamlProjectDocumentArgs(args) {
|
|
8
|
+
if (typeof args !== 'object' || args === null || Array.isArray(args)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const record = args;
|
|
12
|
+
return typeof record.bundleYaml === 'string' || typeof record.gateYaml === 'string';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Extracts project UUIDs from MCP tool args, including YAML document fields
|
|
16
|
+
* (`bundleYaml`, `gateYaml`) used by AgentOps composite tools.
|
|
17
|
+
*/
|
|
18
|
+
function extractProjectUuidsFromToolArgs(args) {
|
|
19
|
+
const uuids = [];
|
|
20
|
+
if (typeof args === 'object' && args !== null && !Array.isArray(args)) {
|
|
21
|
+
const record = args;
|
|
22
|
+
if (typeof record.bundleYaml === 'string') {
|
|
23
|
+
try {
|
|
24
|
+
const bundle = (0, types_1.parseLightdashAiAgentBundle)(record.bundleYaml);
|
|
25
|
+
uuids.push(bundle.spec.projectUuid);
|
|
26
|
+
}
|
|
27
|
+
catch (_a) {
|
|
28
|
+
// Handler validates YAML; allowlist runs before handler may see invalid YAML.
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (typeof record.gateYaml === 'string') {
|
|
32
|
+
try {
|
|
33
|
+
const gate = (0, types_1.parseLightdashAiEvaluationGate)(record.gateYaml);
|
|
34
|
+
uuids.push(gate.spec.projectUuid);
|
|
35
|
+
}
|
|
36
|
+
catch (_b) {
|
|
37
|
+
// Same as bundleYaml — parse errors surface in the handler.
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return uuids;
|
|
42
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GatePolicyEvaluation, LightdashAiEvaluationGate } from './types';
|
|
2
|
+
export declare function formatGateJUnit(gate: LightdashAiEvaluationGate, evaluation: GatePolicyEvaluation): string;
|
|
3
|
+
export declare function formatGateTimeoutJUnit(gate: LightdashAiEvaluationGate): string;
|
|
4
|
+
export declare function formatGateTimeoutMarkdown(gate: LightdashAiEvaluationGate): string;
|
|
5
|
+
export declare function formatGateMarkdown(gate: LightdashAiEvaluationGate, evaluation: GatePolicyEvaluation): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatGateJUnit = formatGateJUnit;
|
|
4
|
+
exports.formatGateTimeoutJUnit = formatGateTimeoutJUnit;
|
|
5
|
+
exports.formatGateTimeoutMarkdown = formatGateTimeoutMarkdown;
|
|
6
|
+
exports.formatGateMarkdown = formatGateMarkdown;
|
|
7
|
+
function escapeXml(text) {
|
|
8
|
+
return text
|
|
9
|
+
.replace(/&/g, '&')
|
|
10
|
+
.replace(/</g, '<')
|
|
11
|
+
.replace(/>/g, '>')
|
|
12
|
+
.replace(/"/g, '"')
|
|
13
|
+
.replace(/'/g, ''');
|
|
14
|
+
}
|
|
15
|
+
function formatGateJUnit(gate, evaluation) {
|
|
16
|
+
const name = escapeXml(gate.metadata.name);
|
|
17
|
+
const failures = evaluation.passed
|
|
18
|
+
? ''
|
|
19
|
+
: ` <failure message="${escapeXml(evaluation.reasons.join('; '))}">Gate policy failed</failure>\n`;
|
|
20
|
+
return `<?xml version="1.0" encoding="UTF-8"?>\n<testsuite name="${name}" tests="1" failures="${evaluation.passed ? 0 : 1}">\n <testcase name="${name}" classname="agentops.evaluate-gate">\n${failures} </testcase>\n</testsuite>\n`;
|
|
21
|
+
}
|
|
22
|
+
function formatGateTimeoutJUnit(gate) {
|
|
23
|
+
const name = escapeXml(gate.metadata.name);
|
|
24
|
+
return `<?xml version="1.0" encoding="UTF-8"?>\n<testsuite name="${name}" tests="1" failures="1">\n <testcase name="timeout"><failure>Timed out</failure></testcase>\n</testsuite>\n`;
|
|
25
|
+
}
|
|
26
|
+
function formatGateTimeoutMarkdown(gate) {
|
|
27
|
+
return `# Evaluation Gate: ${gate.metadata.name}\n\n**Result:** TIMEOUT\n`;
|
|
28
|
+
}
|
|
29
|
+
function formatGateMarkdown(gate, evaluation) {
|
|
30
|
+
var _a;
|
|
31
|
+
const lines = [
|
|
32
|
+
`# Evaluation Gate: ${gate.metadata.name}`,
|
|
33
|
+
'',
|
|
34
|
+
`**Result:** ${evaluation.passed ? 'PASSED' : 'FAILED'} (exit ${evaluation.exitCode})`,
|
|
35
|
+
'',
|
|
36
|
+
'## Metrics',
|
|
37
|
+
`- Run status: ${evaluation.metrics.runStatus}`,
|
|
38
|
+
`- Passed assessments: ${evaluation.metrics.passedAssessments}`,
|
|
39
|
+
`- Failed assessments: ${evaluation.metrics.failedAssessments}`,
|
|
40
|
+
`- Pass rate: ${(_a = evaluation.metrics.passRate) !== null && _a !== void 0 ? _a : 'n/a'}`,
|
|
41
|
+
'',
|
|
42
|
+
];
|
|
43
|
+
if (evaluation.reasons.length > 0) {
|
|
44
|
+
lines.push('## Reasons', ...evaluation.reasons.map((r) => `- ${r}`), '');
|
|
45
|
+
}
|
|
46
|
+
return lines.join('\n');
|
|
47
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AgentStateSnapshot, EvaluationStateSnapshot, GateRunSnapshot } from './types';
|
|
2
|
+
export declare function toGateRunSnapshot(run: {
|
|
3
|
+
runUuid: string;
|
|
4
|
+
status: GateRunSnapshot['status'];
|
|
5
|
+
passedAssessments: number;
|
|
6
|
+
failedAssessments: number;
|
|
7
|
+
completedAt: string | null;
|
|
8
|
+
}): GateRunSnapshot;
|
|
9
|
+
export declare function toAgentSnapshot(agent: {
|
|
10
|
+
uuid: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string | null;
|
|
13
|
+
instruction: string | null;
|
|
14
|
+
tags: string[] | null;
|
|
15
|
+
enableDataAccess?: boolean;
|
|
16
|
+
enableSelfImprovement?: boolean;
|
|
17
|
+
}): AgentStateSnapshot;
|
|
18
|
+
export declare function toEvaluationSnapshot(evaluation: {
|
|
19
|
+
evalUuid: string;
|
|
20
|
+
title: string;
|
|
21
|
+
description: string | null;
|
|
22
|
+
prompts: Array<{
|
|
23
|
+
type?: 'string';
|
|
24
|
+
prompt: string;
|
|
25
|
+
expectedResponse: string | null;
|
|
26
|
+
} | {
|
|
27
|
+
type?: 'thread';
|
|
28
|
+
threadUuid: string;
|
|
29
|
+
promptUuid: string;
|
|
30
|
+
expectedResponse: string | null;
|
|
31
|
+
}>;
|
|
32
|
+
}): EvaluationStateSnapshot;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toGateRunSnapshot = toGateRunSnapshot;
|
|
4
|
+
exports.toAgentSnapshot = toAgentSnapshot;
|
|
5
|
+
exports.toEvaluationSnapshot = toEvaluationSnapshot;
|
|
6
|
+
const types_1 = require("./types");
|
|
7
|
+
function toGateRunSnapshot(run) {
|
|
8
|
+
return {
|
|
9
|
+
runUuid: run.runUuid,
|
|
10
|
+
status: run.status,
|
|
11
|
+
passedAssessments: run.passedAssessments,
|
|
12
|
+
failedAssessments: run.failedAssessments,
|
|
13
|
+
completedAt: run.completedAt,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function toAgentSnapshot(agent) {
|
|
17
|
+
return {
|
|
18
|
+
uuid: agent.uuid,
|
|
19
|
+
name: agent.name,
|
|
20
|
+
description: agent.description,
|
|
21
|
+
instruction: agent.instruction,
|
|
22
|
+
tags: agent.tags,
|
|
23
|
+
enableDataAccess: agent.enableDataAccess,
|
|
24
|
+
enableSelfImprovement: agent.enableSelfImprovement,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function toEvaluationSnapshot(evaluation) {
|
|
28
|
+
return {
|
|
29
|
+
evalUuid: evaluation.evalUuid,
|
|
30
|
+
title: evaluation.title,
|
|
31
|
+
description: evaluation.description,
|
|
32
|
+
prompts: evaluation.prompts.map((p) => (0, types_1.normalizeEvaluationPrompt)(p)),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentOps bundle and evaluation gate YAML types (RFC Phase 2).
|
|
3
|
+
* Kubernetes-style documents with apiVersion, kind, metadata, and spec.
|
|
4
|
+
*/
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
declare const bundleEvaluationSchema: z.ZodObject<{
|
|
7
|
+
key: z.ZodString;
|
|
8
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
9
|
+
title: z.ZodString;
|
|
10
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
|
+
prompts: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
12
|
+
prompt: z.ZodString;
|
|
13
|
+
expectedResponse: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
14
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
15
|
+
threadUuid: z.ZodString;
|
|
16
|
+
promptUuid: z.ZodString;
|
|
17
|
+
expectedResponse: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
18
|
+
}, z.core.$strip>]>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
declare const bundleAgentSchema: z.ZodObject<{
|
|
21
|
+
key: z.ZodString;
|
|
22
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
25
|
+
instruction: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
26
|
+
tags: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
27
|
+
enableDataAccess: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
enableSelfImprovement: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
evaluations: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
30
|
+
key: z.ZodString;
|
|
31
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
32
|
+
title: z.ZodString;
|
|
33
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
34
|
+
prompts: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
35
|
+
prompt: z.ZodString;
|
|
36
|
+
expectedResponse: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
37
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
38
|
+
threadUuid: z.ZodString;
|
|
39
|
+
promptUuid: z.ZodString;
|
|
40
|
+
expectedResponse: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
}, z.core.$strip>]>>;
|
|
42
|
+
}, z.core.$strip>>>>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export declare const lightdashAiAgentBundleSchema: z.ZodObject<{
|
|
45
|
+
apiVersion: z.ZodLiteral<"lightdash.ai/v1alpha1">;
|
|
46
|
+
kind: z.ZodLiteral<"LightdashAiAgentBundle">;
|
|
47
|
+
metadata: z.ZodObject<{
|
|
48
|
+
name: z.ZodString;
|
|
49
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
50
|
+
annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
spec: z.ZodObject<{
|
|
53
|
+
projectUuid: z.ZodString;
|
|
54
|
+
agents: z.ZodArray<z.ZodObject<{
|
|
55
|
+
key: z.ZodString;
|
|
56
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
57
|
+
name: z.ZodString;
|
|
58
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
instruction: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
60
|
+
tags: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
61
|
+
enableDataAccess: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
enableSelfImprovement: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
evaluations: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
64
|
+
key: z.ZodString;
|
|
65
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
66
|
+
title: z.ZodString;
|
|
67
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
68
|
+
prompts: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
69
|
+
prompt: z.ZodString;
|
|
70
|
+
expectedResponse: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
72
|
+
threadUuid: z.ZodString;
|
|
73
|
+
promptUuid: z.ZodString;
|
|
74
|
+
expectedResponse: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
75
|
+
}, z.core.$strip>]>>;
|
|
76
|
+
}, z.core.$strip>>>>;
|
|
77
|
+
}, z.core.$strip>>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
export type LightdashAiAgentBundle = z.infer<typeof lightdashAiAgentBundleSchema>;
|
|
81
|
+
export type BundleAgentSpec = z.infer<typeof bundleAgentSchema>;
|
|
82
|
+
export type BundleEvaluationSpec = z.infer<typeof bundleEvaluationSchema>;
|
|
83
|
+
export declare const gatePolicySchema: z.ZodObject<{
|
|
84
|
+
minPassRate: z.ZodOptional<z.ZodNumber>;
|
|
85
|
+
maxFailedAssessments: z.ZodOptional<z.ZodNumber>;
|
|
86
|
+
minPassedAssessments: z.ZodOptional<z.ZodNumber>;
|
|
87
|
+
requireAllPassed: z.ZodOptional<z.ZodBoolean>;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
export declare const lightdashAiEvaluationGateSchema: z.ZodObject<{
|
|
90
|
+
apiVersion: z.ZodLiteral<"lightdash.ai/v1alpha1">;
|
|
91
|
+
kind: z.ZodLiteral<"LightdashAiEvaluationGate">;
|
|
92
|
+
metadata: z.ZodObject<{
|
|
93
|
+
name: z.ZodString;
|
|
94
|
+
labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
95
|
+
annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
spec: z.ZodObject<{
|
|
98
|
+
projectUuid: z.ZodString;
|
|
99
|
+
agentUuid: z.ZodString;
|
|
100
|
+
evaluationUuid: z.ZodString;
|
|
101
|
+
policy: z.ZodObject<{
|
|
102
|
+
minPassRate: z.ZodOptional<z.ZodNumber>;
|
|
103
|
+
maxFailedAssessments: z.ZodOptional<z.ZodNumber>;
|
|
104
|
+
minPassedAssessments: z.ZodOptional<z.ZodNumber>;
|
|
105
|
+
requireAllPassed: z.ZodOptional<z.ZodBoolean>;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
runUuid: z.ZodOptional<z.ZodString>;
|
|
108
|
+
triggerRun: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
export type LightdashAiEvaluationGate = z.infer<typeof lightdashAiEvaluationGateSchema>;
|
|
112
|
+
export type GatePolicy = z.infer<typeof gatePolicySchema>;
|
|
113
|
+
export declare const GateExitCode: {
|
|
114
|
+
readonly PASSED: 0;
|
|
115
|
+
readonly ERROR: 1;
|
|
116
|
+
readonly INVALID: 2;
|
|
117
|
+
readonly POLICY_FAILED: 3;
|
|
118
|
+
readonly TIMEOUT: 4;
|
|
119
|
+
readonly RUN_FAILED: 5;
|
|
120
|
+
readonly RUN_IN_PROGRESS: 6;
|
|
121
|
+
};
|
|
122
|
+
export type GateExitCodeValue = (typeof GateExitCode)[keyof typeof GateExitCode];
|
|
123
|
+
export type DiffOperation = 'create' | 'delete' | 'noop' | 'update';
|
|
124
|
+
export type BundleResourceType = 'agent' | 'evaluation';
|
|
125
|
+
export interface BundleDiffChange {
|
|
126
|
+
resourceType: BundleResourceType;
|
|
127
|
+
operation: DiffOperation;
|
|
128
|
+
key: string;
|
|
129
|
+
/** Logical agent key from the bundle spec. */
|
|
130
|
+
agentKey?: string;
|
|
131
|
+
/** Resolved agent UUID when known (required for evaluation API calls). */
|
|
132
|
+
agentUuid?: string;
|
|
133
|
+
/** Resolved evaluation UUID when known (required for title-matched evaluation updates). */
|
|
134
|
+
evaluationUuid?: string;
|
|
135
|
+
path: string;
|
|
136
|
+
fields?: Record<string, {
|
|
137
|
+
from: unknown;
|
|
138
|
+
to: unknown;
|
|
139
|
+
}>;
|
|
140
|
+
}
|
|
141
|
+
export interface BundleDiffResult {
|
|
142
|
+
bundleName: string;
|
|
143
|
+
projectUuid: string;
|
|
144
|
+
changes: BundleDiffChange[];
|
|
145
|
+
hasDrift: boolean;
|
|
146
|
+
summary: {
|
|
147
|
+
creates: number;
|
|
148
|
+
updates: number;
|
|
149
|
+
deletes: number;
|
|
150
|
+
noops: number;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/** Minimal agent shape for diffing (from API or desired state). */
|
|
154
|
+
export interface AgentStateSnapshot {
|
|
155
|
+
uuid: string;
|
|
156
|
+
name: string;
|
|
157
|
+
description: string | null;
|
|
158
|
+
instruction: string | null;
|
|
159
|
+
tags: string[] | null;
|
|
160
|
+
enableDataAccess?: boolean;
|
|
161
|
+
enableSelfImprovement?: boolean;
|
|
162
|
+
}
|
|
163
|
+
/** Minimal evaluation shape for diffing. */
|
|
164
|
+
export interface EvaluationStateSnapshot {
|
|
165
|
+
evalUuid: string;
|
|
166
|
+
title: string;
|
|
167
|
+
description: string | null;
|
|
168
|
+
prompts: Array<{
|
|
169
|
+
type: 'string';
|
|
170
|
+
prompt: string;
|
|
171
|
+
expectedResponse: string | null;
|
|
172
|
+
} | {
|
|
173
|
+
type: 'thread';
|
|
174
|
+
threadUuid: string;
|
|
175
|
+
promptUuid: string;
|
|
176
|
+
expectedResponse: string | null;
|
|
177
|
+
}>;
|
|
178
|
+
}
|
|
179
|
+
export interface BundleCurrentState {
|
|
180
|
+
projectUuid: string;
|
|
181
|
+
agents: Array<{
|
|
182
|
+
agent: AgentStateSnapshot;
|
|
183
|
+
evaluations: EvaluationStateSnapshot[];
|
|
184
|
+
}>;
|
|
185
|
+
}
|
|
186
|
+
export interface GateRunSnapshot {
|
|
187
|
+
runUuid: string;
|
|
188
|
+
status: 'completed' | 'failed' | 'pending' | 'running';
|
|
189
|
+
passedAssessments: number;
|
|
190
|
+
failedAssessments: number;
|
|
191
|
+
completedAt: string | null;
|
|
192
|
+
}
|
|
193
|
+
export interface GatePolicyEvaluation {
|
|
194
|
+
exitCode: GateExitCodeValue;
|
|
195
|
+
passed: boolean;
|
|
196
|
+
reasons: string[];
|
|
197
|
+
metrics: {
|
|
198
|
+
passedAssessments: number;
|
|
199
|
+
failedAssessments: number;
|
|
200
|
+
totalAssessments: number;
|
|
201
|
+
passRate: number | null;
|
|
202
|
+
runStatus: GateRunSnapshot['status'];
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
export declare function parseDocumentYaml(content: string): unknown;
|
|
206
|
+
export declare function parseLightdashAiAgentBundle(content: string): LightdashAiAgentBundle;
|
|
207
|
+
export declare function parseLightdashAiEvaluationGate(content: string): LightdashAiEvaluationGate;
|
|
208
|
+
export declare function normalizeEvaluationPrompt(prompt: {
|
|
209
|
+
prompt: string;
|
|
210
|
+
expectedResponse?: string | null;
|
|
211
|
+
} | {
|
|
212
|
+
threadUuid: string;
|
|
213
|
+
promptUuid: string;
|
|
214
|
+
expectedResponse?: string | null;
|
|
215
|
+
}): EvaluationStateSnapshot['prompts'][number];
|
|
216
|
+
export declare function computeBundleDiff(bundle: LightdashAiAgentBundle, current: BundleCurrentState): BundleDiffResult;
|
|
217
|
+
export declare function detectBundleDrift(bundle: LightdashAiAgentBundle, current: BundleCurrentState): {
|
|
218
|
+
hasDrift: boolean;
|
|
219
|
+
diff: BundleDiffResult;
|
|
220
|
+
};
|
|
221
|
+
export declare function getLightdashAiAgentBundleJsonSchema(): Record<string, unknown>;
|
|
222
|
+
export declare function getLightdashAiEvaluationGateJsonSchema(): Record<string, unknown>;
|
|
223
|
+
export declare function evaluateGatePolicy(policy: GatePolicy, run: GateRunSnapshot): GatePolicyEvaluation;
|
|
224
|
+
export {};
|