@kindgi/api 0.1.3 → 0.1.4-rc.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/agent-binding.d.ts +18 -4
- package/dist/agent-binding.d.ts.map +1 -1
- package/dist/agent-pins.d.ts +48 -0
- package/dist/agent-pins.d.ts.map +1 -0
- package/dist/agent-pins.js +102 -0
- package/dist/agent-pins.js.map +1 -0
- package/dist/app.d.ts +22 -0
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +20 -2
- package/dist/app.js.map +1 -1
- package/dist/block-binding.d.ts +132 -0
- package/dist/block-binding.d.ts.map +1 -0
- package/dist/block-binding.js +4 -0
- package/dist/block-binding.js.map +1 -0
- package/dist/block-pins.d.ts +22 -0
- package/dist/block-pins.d.ts.map +1 -0
- package/dist/block-pins.js +112 -0
- package/dist/block-pins.js.map +1 -0
- package/dist/cost-binding.d.ts +20 -1
- package/dist/cost-binding.d.ts.map +1 -1
- package/dist/cost-binding.js +4 -0
- package/dist/cost-binding.js.map +1 -1
- package/dist/deploy-versions.d.ts +58 -0
- package/dist/deploy-versions.d.ts.map +1 -0
- package/dist/deploy-versions.js +91 -0
- package/dist/deploy-versions.js.map +1 -0
- package/dist/deployment-binding.d.ts +24 -3
- package/dist/deployment-binding.d.ts.map +1 -1
- package/dist/derive-agent-version.d.ts +69 -0
- package/dist/derive-agent-version.d.ts.map +1 -0
- package/dist/derive-agent-version.js +139 -0
- package/dist/derive-agent-version.js.map +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +17 -0
- package/dist/errors.js.map +1 -1
- package/dist/eval-case-binding.d.ts +65 -0
- package/dist/eval-case-binding.d.ts.map +1 -0
- package/dist/eval-case-binding.js +4 -0
- package/dist/eval-case-binding.js.map +1 -0
- package/dist/eval-run-binding.d.ts +30 -0
- package/dist/eval-run-binding.d.ts.map +1 -1
- package/dist/eval-run-dispatcher.d.ts +38 -3
- package/dist/eval-run-dispatcher.d.ts.map +1 -1
- package/dist/eval-run-dispatcher.js +21 -15
- package/dist/eval-run-dispatcher.js.map +1 -1
- package/dist/eval-suite-binding.d.ts +1 -1
- package/dist/eval-suite-binding.d.ts.map +1 -1
- package/dist/eval-suite-binding.js +2 -0
- package/dist/eval-suite-binding.js.map +1 -1
- package/dist/flow-binding.d.ts +10 -4
- package/dist/flow-binding.d.ts.map +1 -1
- package/dist/flow-pins.d.ts +36 -0
- package/dist/flow-pins.d.ts.map +1 -0
- package/dist/flow-pins.js +81 -0
- package/dist/flow-pins.js.map +1 -0
- package/dist/index.d.ts +17 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/judged-dispatcher.d.ts +134 -0
- package/dist/judged-dispatcher.d.ts.map +1 -0
- package/dist/judged-dispatcher.js +297 -0
- package/dist/judged-dispatcher.js.map +1 -0
- package/dist/judged-items.d.ts +86 -0
- package/dist/judged-items.d.ts.map +1 -0
- package/dist/judged-items.js +184 -0
- package/dist/judged-items.js.map +1 -0
- package/dist/judgment-binding.d.ts +316 -0
- package/dist/judgment-binding.d.ts.map +1 -0
- package/dist/judgment-binding.js +19 -0
- package/dist/judgment-binding.js.map +1 -0
- package/dist/openapi/generate.d.ts.map +1 -1
- package/dist/openapi/generate.js +4 -1
- package/dist/openapi/generate.js.map +1 -1
- package/dist/openapi/operations.d.ts.map +1 -1
- package/dist/openapi/operations.js +461 -7
- package/dist/openapi/operations.js.map +1 -1
- package/dist/openapi/schemas.d.ts +40 -0
- package/dist/openapi/schemas.d.ts.map +1 -1
- package/dist/openapi/schemas.js +843 -7
- package/dist/openapi/schemas.js.map +1 -1
- package/dist/provider-binding.d.ts +12 -7
- package/dist/provider-binding.d.ts.map +1 -1
- package/dist/routes/agents.d.ts +9 -1
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +175 -11
- package/dist/routes/agents.js.map +1 -1
- package/dist/routes/blocks.d.ts +19 -0
- package/dist/routes/blocks.d.ts.map +1 -0
- package/dist/routes/blocks.js +281 -0
- package/dist/routes/blocks.js.map +1 -0
- package/dist/routes/cost.d.ts.map +1 -1
- package/dist/routes/cost.js +47 -2
- package/dist/routes/cost.js.map +1 -1
- package/dist/routes/deployments.d.ts +3 -0
- package/dist/routes/deployments.d.ts.map +1 -1
- package/dist/routes/deployments.js +208 -55
- package/dist/routes/deployments.js.map +1 -1
- package/dist/routes/eval-comparison.d.ts +14 -0
- package/dist/routes/eval-comparison.d.ts.map +1 -0
- package/dist/routes/eval-comparison.js +87 -0
- package/dist/routes/eval-comparison.js.map +1 -0
- package/dist/routes/eval-runs.d.ts.map +1 -1
- package/dist/routes/eval-runs.js +8 -0
- package/dist/routes/eval-runs.js.map +1 -1
- package/dist/routes/flows.d.ts +13 -1
- package/dist/routes/flows.d.ts.map +1 -1
- package/dist/routes/flows.js +44 -3
- package/dist/routes/flows.js.map +1 -1
- package/dist/routes/hierarchy-errors.d.ts +35 -0
- package/dist/routes/hierarchy-errors.d.ts.map +1 -0
- package/dist/routes/hierarchy-errors.js +39 -0
- package/dist/routes/hierarchy-errors.js.map +1 -0
- package/dist/routes/judged-suites.d.ts +20 -0
- package/dist/routes/judged-suites.d.ts.map +1 -0
- package/dist/routes/judged-suites.js +272 -0
- package/dist/routes/judged-suites.js.map +1 -0
- package/dist/routes/judgment-context.d.ts +22 -0
- package/dist/routes/judgment-context.d.ts.map +1 -0
- package/dist/routes/judgment-context.js +88 -0
- package/dist/routes/judgment-context.js.map +1 -0
- package/dist/routes/judgment-flow-context.d.ts +32 -0
- package/dist/routes/judgment-flow-context.d.ts.map +1 -0
- package/dist/routes/judgment-flow-context.js +195 -0
- package/dist/routes/judgment-flow-context.js.map +1 -0
- package/dist/routes/judgments.d.ts +41 -0
- package/dist/routes/judgments.d.ts.map +1 -0
- package/dist/routes/judgments.js +566 -0
- package/dist/routes/judgments.js.map +1 -0
- package/dist/routes/orgs.d.ts +5 -2
- package/dist/routes/orgs.d.ts.map +1 -1
- package/dist/routes/orgs.js +38 -22
- package/dist/routes/orgs.js.map +1 -1
- package/dist/routes/policies.d.ts.map +1 -1
- package/dist/routes/policies.js +12 -1
- package/dist/routes/policies.js.map +1 -1
- package/dist/routes/projects.d.ts +10 -2
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +87 -79
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/providers.d.ts.map +1 -1
- package/dist/routes/providers.js +6 -1
- package/dist/routes/providers.js.map +1 -1
- package/dist/routes/runs.js +24 -3
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/teams.d.ts +6 -2
- package/dist/routes/teams.d.ts.map +1 -1
- package/dist/routes/teams.js +77 -73
- package/dist/routes/teams.js.map +1 -1
- package/openapi.json +13545 -10103
- package/package.json +21 -21
- package/src/agent-binding.ts +19 -4
- package/src/agent-pins.ts +147 -0
- package/src/app.ts +71 -2
- package/src/block-binding.ts +137 -0
- package/src/block-pins.ts +148 -0
- package/src/cost-binding.ts +21 -1
- package/src/deploy-versions.ts +157 -0
- package/src/deployment-binding.ts +27 -3
- package/src/derive-agent-version.ts +206 -0
- package/src/errors.ts +17 -0
- package/src/eval-case-binding.ts +71 -0
- package/src/eval-run-binding.ts +33 -0
- package/src/eval-run-dispatcher.ts +57 -16
- package/src/eval-suite-binding.ts +2 -0
- package/src/flow-binding.ts +11 -4
- package/src/flow-pins.ts +113 -0
- package/src/index.ts +85 -2
- package/src/judged-dispatcher.ts +507 -0
- package/src/judged-items.ts +263 -0
- package/src/judgment-binding.ts +349 -0
- package/src/openapi/generate.ts +7 -1
- package/src/openapi/operations.ts +523 -7
- package/src/openapi/schemas.ts +1009 -88
- package/src/provider-binding.ts +12 -7
- package/src/routes/agents.ts +243 -19
- package/src/routes/blocks.ts +362 -0
- package/src/routes/cost.ts +55 -1
- package/src/routes/deployments.ts +266 -56
- package/src/routes/eval-comparison.ts +101 -0
- package/src/routes/eval-runs.ts +11 -0
- package/src/routes/flows.ts +63 -5
- package/src/routes/hierarchy-errors.ts +51 -0
- package/src/routes/judged-suites.ts +363 -0
- package/src/routes/judgment-context.ts +128 -0
- package/src/routes/judgment-flow-context.ts +245 -0
- package/src/routes/judgments.ts +743 -0
- package/src/routes/orgs.ts +44 -27
- package/src/routes/policies.ts +19 -0
- package/src/routes/projects.ts +106 -95
- package/src/routes/providers.ts +5 -0
- package/src/routes/runs.ts +28 -3
- package/src/routes/teams.ts +96 -90
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import { randomUUID } from 'node:crypto';
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type { ReplayTurnReport } from '@kindgi/agents';
|
|
7
|
+
import type { RunReplayRef } from '@kindgi/runtime';
|
|
8
|
+
import type { ProjectId, RunId, TenantId, Timestamp } from '@kindgi/types';
|
|
7
9
|
|
|
8
10
|
import type {
|
|
9
11
|
AgentRef,
|
|
12
|
+
EvalComparison,
|
|
10
13
|
EvalRun,
|
|
11
14
|
EvalRunBinding,
|
|
12
15
|
EvalRunCancelInput,
|
|
@@ -50,6 +53,16 @@ export interface EvalRunSubjectInvokeInput {
|
|
|
50
53
|
readonly input: unknown;
|
|
51
54
|
readonly dryRun: boolean;
|
|
52
55
|
readonly abortSignal: AbortSignal;
|
|
56
|
+
/** The eval run's project: where the subject runs. */
|
|
57
|
+
readonly projectId?: ProjectId;
|
|
58
|
+
/**
|
|
59
|
+
* Set when the subject re-runs a past run (a comparison eval run): the
|
|
60
|
+
* run is a replay of `of` for the eval run, under the replay rules
|
|
61
|
+
* (`InvokeAgentInput.replay`).
|
|
62
|
+
*/
|
|
63
|
+
readonly replay?: RunReplayRef;
|
|
64
|
+
/** The conversation before the past turn, oldest first: a replayed turn starts from it. */
|
|
65
|
+
readonly history?: readonly unknown[];
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
export interface EvalRunSubjectInvokeOutcome {
|
|
@@ -57,6 +70,22 @@ export interface EvalRunSubjectInvokeOutcome {
|
|
|
57
70
|
readonly error?: string;
|
|
58
71
|
readonly costUsd?: number;
|
|
59
72
|
readonly durationMs?: number;
|
|
73
|
+
/** The run the subject ran in. */
|
|
74
|
+
readonly runId?: RunId;
|
|
75
|
+
/** A replay's report: each tool call and what happened to it (`AgentTurnResult.replay`). */
|
|
76
|
+
readonly replay?: ReplayTurnReport;
|
|
77
|
+
/** The provider and model that answered. */
|
|
78
|
+
readonly provider?: { readonly id: string; readonly model: string };
|
|
79
|
+
/**
|
|
80
|
+
* Set when a replayed flow stopped at a tool call the replay refused (a
|
|
81
|
+
* write the past run didn't make): no output, and what it would have
|
|
82
|
+
* done. Not an error: the replay did what it's meant to.
|
|
83
|
+
*/
|
|
84
|
+
readonly stopped?: {
|
|
85
|
+
readonly toolId: string;
|
|
86
|
+
readonly arguments: unknown;
|
|
87
|
+
readonly reason?: string;
|
|
88
|
+
};
|
|
60
89
|
}
|
|
61
90
|
|
|
62
91
|
/**
|
|
@@ -100,6 +129,10 @@ export interface DispatchContext {
|
|
|
100
129
|
readonly dryRun: boolean;
|
|
101
130
|
readonly abortSignal: AbortSignal;
|
|
102
131
|
readonly subject: EvalSubjectInvoker;
|
|
132
|
+
/** The eval run's project. */
|
|
133
|
+
readonly projectId?: ProjectId;
|
|
134
|
+
/** A comparison eval run's baseline, reads and repetitions. */
|
|
135
|
+
readonly comparison?: EvalComparison;
|
|
103
136
|
onProgress(perCase: Readonly<Record<string, unknown>>): void;
|
|
104
137
|
}
|
|
105
138
|
|
|
@@ -113,6 +146,7 @@ export interface EvalRunDispatcher {
|
|
|
113
146
|
validate?(
|
|
114
147
|
suite: EvalSuite,
|
|
115
148
|
target: AgentRef | FlowRef,
|
|
149
|
+
comparison?: EvalComparison,
|
|
116
150
|
): { kind: 'ok' } | { kind: 'err'; message: string };
|
|
117
151
|
dispatch(ctx: DispatchContext): Promise<DispatchResult>;
|
|
118
152
|
}
|
|
@@ -311,26 +345,13 @@ export function createInProcessEvalRunBinding(
|
|
|
311
345
|
};
|
|
312
346
|
}
|
|
313
347
|
if (dispatcher.validate !== undefined) {
|
|
314
|
-
const v = dispatcher.validate(suite, target);
|
|
348
|
+
const v = dispatcher.validate(suite, target, input.comparison);
|
|
315
349
|
if (v.kind === 'err') {
|
|
316
350
|
return { kind: 'dispatcher-input-invalid', message: v.message };
|
|
317
351
|
}
|
|
318
352
|
}
|
|
319
353
|
const runId = randomUUID() as unknown as RunId;
|
|
320
|
-
const
|
|
321
|
-
const record: EvalRun = {
|
|
322
|
-
runId,
|
|
323
|
-
tenantId: input.tenantId,
|
|
324
|
-
suiteId: suite.id,
|
|
325
|
-
suiteVersion: suite.version,
|
|
326
|
-
kind: suite.kind,
|
|
327
|
-
...(input.agentRef !== undefined && { agentRef: input.agentRef }),
|
|
328
|
-
...(input.flowRef !== undefined && { flowRef: input.flowRef }),
|
|
329
|
-
status: 'running' as EvalRunStatus,
|
|
330
|
-
dryRun: input.dryRun === true,
|
|
331
|
-
startedAt,
|
|
332
|
-
...(input.correlationId !== undefined && { correlationId: input.correlationId }),
|
|
333
|
-
};
|
|
354
|
+
const record = newRunRecord(input, suite, runId, now());
|
|
334
355
|
setRun(record);
|
|
335
356
|
const controller = new AbortController();
|
|
336
357
|
controllers.set(runId as unknown as string, controller);
|
|
@@ -349,6 +370,8 @@ export function createInProcessEvalRunBinding(
|
|
|
349
370
|
dryRun: input.dryRun === true,
|
|
350
371
|
abortSignal: controller.signal,
|
|
351
372
|
subject: options.subject,
|
|
373
|
+
projectId: input.projectId,
|
|
374
|
+
...(input.comparison !== undefined && { comparison: input.comparison }),
|
|
352
375
|
onProgress: (perCaseEntry: Readonly<Record<string, unknown>>) => {
|
|
353
376
|
const current = runs.get(runId as unknown as string);
|
|
354
377
|
if (current === undefined) return;
|
|
@@ -489,6 +512,24 @@ export function createInProcessEvalRunBinding(
|
|
|
489
512
|
};
|
|
490
513
|
}
|
|
491
514
|
|
|
515
|
+
/** A started run's row: `running`, with what it runs and how. */
|
|
516
|
+
function newRunRecord(input: EvalRunStartInput, suite: EvalSuite, runId: RunId, at: Date): EvalRun {
|
|
517
|
+
return {
|
|
518
|
+
runId,
|
|
519
|
+
tenantId: input.tenantId,
|
|
520
|
+
suiteId: suite.id,
|
|
521
|
+
suiteVersion: suite.version,
|
|
522
|
+
kind: suite.kind,
|
|
523
|
+
...(input.agentRef !== undefined && { agentRef: input.agentRef }),
|
|
524
|
+
...(input.flowRef !== undefined && { flowRef: input.flowRef }),
|
|
525
|
+
status: 'running',
|
|
526
|
+
dryRun: input.dryRun === true,
|
|
527
|
+
startedAt: at.toISOString() as unknown as Timestamp,
|
|
528
|
+
...(input.correlationId !== undefined && { correlationId: input.correlationId }),
|
|
529
|
+
...(input.comparison !== undefined && { comparison: input.comparison }),
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
|
|
492
533
|
function isTerminal(status: EvalRunStatus): boolean {
|
|
493
534
|
return status === 'completed' || status === 'failed' || status === 'cancelled';
|
|
494
535
|
}
|
|
@@ -100,6 +100,8 @@ export const EVAL_KINDS = [
|
|
|
100
100
|
'human-review',
|
|
101
101
|
'benchmark',
|
|
102
102
|
'custom',
|
|
103
|
+
/** Built from judgments of past runs: cases are copies of judged runs (`EvalCaseStoreBinding`). */
|
|
104
|
+
'judged',
|
|
103
105
|
] as const;
|
|
104
106
|
export type EvalKind = (typeof EVAL_KINDS)[number];
|
|
105
107
|
|
package/src/flow-binding.ts
CHANGED
|
@@ -39,11 +39,12 @@ export interface FlowRegistryBinding {
|
|
|
39
39
|
*/
|
|
40
40
|
get(input: FlowGetInput): Promise<Flow | null>;
|
|
41
41
|
/**
|
|
42
|
-
* Specific `(flowId, version)` lookup, or `null` if unknown.
|
|
43
|
-
*
|
|
44
|
-
*
|
|
42
|
+
* Specific `(flowId, version)` lookup, or `null` if unknown. Returns
|
|
43
|
+
* unregistered (tombstoned) versions too, with `unregisteredAt` set:
|
|
44
|
+
* a resumed run and provenance read them, while a new run that names
|
|
45
|
+
* one is refused.
|
|
45
46
|
*/
|
|
46
|
-
getVersion(input: FlowGetVersionInput): Promise<
|
|
47
|
+
getVersion(input: FlowGetVersionInput): Promise<FlowVersionRecord | null>;
|
|
47
48
|
/**
|
|
48
49
|
* Head-row existence check. Lets `GET /v1/flows/{id}` distinguish
|
|
49
50
|
* `410 gone` (identity exists, no active version) from `404 not-
|
|
@@ -79,6 +80,12 @@ export interface FlowRegistryBinding {
|
|
|
79
80
|
reinstateVersion(input: FlowReinstateVersionInput): Promise<FlowReinstateVersionOutcome>;
|
|
80
81
|
}
|
|
81
82
|
|
|
83
|
+
/** A flow version as `getVersion` reads it: `unregisteredAt` is set when it's unregistered. */
|
|
84
|
+
export type FlowVersionRecord = Flow & {
|
|
85
|
+
/** ISO-8601; present only on an unregistered version. */
|
|
86
|
+
readonly unregisteredAt?: string;
|
|
87
|
+
};
|
|
88
|
+
|
|
82
89
|
export interface FlowListInput {
|
|
83
90
|
readonly tenantId: TenantId;
|
|
84
91
|
readonly limit: number;
|
package/src/flow-pins.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import type { AgentId } from '@kindgi/agents';
|
|
5
|
+
import type { TupleEnqueueHook } from '@kindgi/authz';
|
|
6
|
+
import { type Flow, type FlowPins, flowPinsDigest, flowRefs } from '@kindgi/flow';
|
|
7
|
+
import { latestVersion } from '@kindgi/tools';
|
|
8
|
+
import type { Cursor, FlowId, ProjectId, TenantId, ToolId } from '@kindgi/types';
|
|
9
|
+
|
|
10
|
+
import type { AgentRegistryBinding } from './agent-binding.js';
|
|
11
|
+
import { type UnpinnableRef, activeToolVersions } from './agent-pins.js';
|
|
12
|
+
import { type DeployedVersionOutcome, deployVersion } from './deploy-versions.js';
|
|
13
|
+
import type { FlowRegistryBinding } from './flow-binding.js';
|
|
14
|
+
import type { ToolRegistryBinding } from './tool-binding.js';
|
|
15
|
+
|
|
16
|
+
export type FlowPinsOutcome =
|
|
17
|
+
| { readonly kind: 'ok'; readonly pins: FlowPins }
|
|
18
|
+
| { readonly kind: 'unpinnable'; readonly issues: readonly UnpinnableRef[] };
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Pin a flow version when it's published: each tool it runs, and each
|
|
22
|
+
* agent it runs at no named version, to its latest active version now
|
|
23
|
+
* (what a run would have bound), so every run of the version uses those.
|
|
24
|
+
* A tool or agent with no published version makes the flow unpinnable:
|
|
25
|
+
* the caller refuses the publish, naming each, rather than store a
|
|
26
|
+
* partly pinned version.
|
|
27
|
+
*/
|
|
28
|
+
export async function resolveFlowPins(
|
|
29
|
+
tools: ToolRegistryBinding,
|
|
30
|
+
agents: AgentRegistryBinding,
|
|
31
|
+
tenantId: TenantId,
|
|
32
|
+
flow: Flow,
|
|
33
|
+
): Promise<FlowPinsOutcome> {
|
|
34
|
+
const refs = flowRefs(flow);
|
|
35
|
+
const pinned: { tools: Record<string, string>; agents: Record<string, string> } = {
|
|
36
|
+
tools: {},
|
|
37
|
+
agents: {},
|
|
38
|
+
};
|
|
39
|
+
const issues: UnpinnableRef[] = [];
|
|
40
|
+
for (const id of refs.tools) {
|
|
41
|
+
const latest = latestVersion(await activeToolVersions(tools, tenantId, id as ToolId));
|
|
42
|
+
if (latest !== undefined) pinned.tools[id] = latest;
|
|
43
|
+
else
|
|
44
|
+
issues.push({
|
|
45
|
+
path: '/nodes',
|
|
46
|
+
message: `tool "${id}" has no published version; publish the tool first`,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
for (const id of refs.agents) {
|
|
50
|
+
const latest = await agents.get({ tenantId, agentId: id as AgentId });
|
|
51
|
+
if (latest !== null) pinned.agents[id] = latest.version as unknown as string;
|
|
52
|
+
else
|
|
53
|
+
issues.push({
|
|
54
|
+
path: '/nodes',
|
|
55
|
+
message: `agent "${id}" has no published version; publish the agent first`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (issues.length > 0) return { kind: 'unpinnable', issues };
|
|
59
|
+
return { kind: 'ok', pins: pinned };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface PublishDeployedFlowInput {
|
|
63
|
+
readonly flows: FlowRegistryBinding;
|
|
64
|
+
readonly tenantId: TenantId;
|
|
65
|
+
readonly projectId: ProjectId;
|
|
66
|
+
/** The flow as the pack defines it, with no pins. */
|
|
67
|
+
readonly flow: Flow;
|
|
68
|
+
readonly pins: FlowPins;
|
|
69
|
+
readonly enqueueTuples: TupleEnqueueHook;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Register a deployed flow with its pins, by the deploy rule (`deployVersion`). */
|
|
73
|
+
export async function publishDeployedFlow(
|
|
74
|
+
input: PublishDeployedFlowInput,
|
|
75
|
+
): Promise<DeployedVersionOutcome> {
|
|
76
|
+
const { flows, tenantId, projectId, flow, pins, enqueueTuples } = input;
|
|
77
|
+
return deployVersion<Flow>({
|
|
78
|
+
label: `flow "${flow.id as unknown as string}"`,
|
|
79
|
+
definition: flow,
|
|
80
|
+
pins,
|
|
81
|
+
pinsDigest: flowPinsDigest(pins),
|
|
82
|
+
existing: await allFlowVersions(flows, tenantId, flow.id),
|
|
83
|
+
publish: async (version) => {
|
|
84
|
+
const outcome = await flows.publish({ tenantId, projectId, flow: version, enqueueTuples });
|
|
85
|
+
if (outcome.kind === 'ok') return 'ok';
|
|
86
|
+
return outcome.kind === 'project-not-found' ? 'skipped' : 'taken';
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Page size for reading a flow's versions. */
|
|
92
|
+
const VERSIONS_PAGE = 200;
|
|
93
|
+
|
|
94
|
+
/** Every active version of a flow. */
|
|
95
|
+
async function allFlowVersions(
|
|
96
|
+
flows: FlowRegistryBinding,
|
|
97
|
+
tenantId: TenantId,
|
|
98
|
+
flowId: FlowId,
|
|
99
|
+
): Promise<readonly Flow[]> {
|
|
100
|
+
const versions: Flow[] = [];
|
|
101
|
+
let cursor: Cursor | undefined;
|
|
102
|
+
do {
|
|
103
|
+
const page = await flows.listVersions({
|
|
104
|
+
tenantId,
|
|
105
|
+
flowId,
|
|
106
|
+
limit: VERSIONS_PAGE,
|
|
107
|
+
...(cursor !== undefined && { cursor }),
|
|
108
|
+
});
|
|
109
|
+
versions.push(...page.data);
|
|
110
|
+
cursor = page.nextCursor;
|
|
111
|
+
} while (cursor !== undefined);
|
|
112
|
+
return versions;
|
|
113
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -233,6 +233,7 @@ export type {
|
|
|
233
233
|
AgentPublishInput,
|
|
234
234
|
AgentPublishOutcome,
|
|
235
235
|
AgentRegistryBinding,
|
|
236
|
+
AgentVersionRecord,
|
|
236
237
|
AgentReinstateVersionInput,
|
|
237
238
|
AgentReinstateVersionOutcome,
|
|
238
239
|
AgentUnregisterInput,
|
|
@@ -247,6 +248,7 @@ export type {
|
|
|
247
248
|
FlowPublishInput,
|
|
248
249
|
FlowPublishOutcome,
|
|
249
250
|
FlowRegistryBinding,
|
|
251
|
+
FlowVersionRecord,
|
|
250
252
|
FlowReinstateVersionInput,
|
|
251
253
|
FlowReinstateVersionOutcome,
|
|
252
254
|
FlowUnregisterInput,
|
|
@@ -309,7 +311,7 @@ export {
|
|
|
309
311
|
stdioRefusal,
|
|
310
312
|
} from './tenant-host-access.js';
|
|
311
313
|
export type { HostReach, TenantHostAccess } from './tenant-host-access.js';
|
|
312
|
-
export { POLICY_KINDS } from '@kindgi/policy-contract';
|
|
314
|
+
export { APPLIED_POLICY_KINDS, POLICY_KINDS } from '@kindgi/policy-contract';
|
|
313
315
|
export type {
|
|
314
316
|
Policy,
|
|
315
317
|
PolicyGetInput,
|
|
@@ -328,6 +330,61 @@ export type {
|
|
|
328
330
|
PolicyVersionPage,
|
|
329
331
|
PolicyVersionRow,
|
|
330
332
|
} from '@kindgi/policy-contract';
|
|
333
|
+
export { JUDGE_CLASS_SCOPE_KINDS, VERDICTS, judgeClassApplies } from './judgment-binding.js';
|
|
334
|
+
export type {
|
|
335
|
+
EvalCaseListInput,
|
|
336
|
+
EvalCasePage,
|
|
337
|
+
EvalCasePutInput,
|
|
338
|
+
EvalCaseStoreBinding,
|
|
339
|
+
JudgedEvalCase,
|
|
340
|
+
JudgedItemSummary,
|
|
341
|
+
} from './eval-case-binding.js';
|
|
342
|
+
export { MAX_JUDGED_CASES } from './routes/judged-suites.js';
|
|
343
|
+
export { MAX_JUDGED_HISTORY } from './routes/judgment-context.js';
|
|
344
|
+
export type {
|
|
345
|
+
JudgeClass,
|
|
346
|
+
JudgeClassCreateInput,
|
|
347
|
+
JudgeClassCreateOutcome,
|
|
348
|
+
JudgeClassGetInput,
|
|
349
|
+
JudgeClassListInput,
|
|
350
|
+
JudgeClassPage,
|
|
351
|
+
JudgeClassScope,
|
|
352
|
+
JudgeClassScopeKind,
|
|
353
|
+
JudgeClassUpdateInput,
|
|
354
|
+
JudgedItem,
|
|
355
|
+
JudgedFlowContext,
|
|
356
|
+
JudgedFlowStep,
|
|
357
|
+
JudgedRunContext,
|
|
358
|
+
JudgedToolCall,
|
|
359
|
+
JudgedRunCopy,
|
|
360
|
+
JudgedRunListInput,
|
|
361
|
+
JudgedRunPage,
|
|
362
|
+
JudgedRunWithJudgments,
|
|
363
|
+
JudgedSubject,
|
|
364
|
+
Judgment,
|
|
365
|
+
JudgmentAssertedBy,
|
|
366
|
+
JudgmentGetInput,
|
|
367
|
+
JudgmentListInput,
|
|
368
|
+
JudgmentPage,
|
|
369
|
+
JudgmentRecordInput,
|
|
370
|
+
JudgmentRegistryBinding,
|
|
371
|
+
JudgmentWithCopies,
|
|
372
|
+
Verdict,
|
|
373
|
+
} from './judgment-binding.js';
|
|
374
|
+
export { resolvePointer } from './routes/judgments.js';
|
|
375
|
+
export type {
|
|
376
|
+
BlockGetInput,
|
|
377
|
+
BlockGetVersionInput,
|
|
378
|
+
BlockListInput,
|
|
379
|
+
BlockListVersionsInput,
|
|
380
|
+
BlockPage,
|
|
381
|
+
BlockPublishInput,
|
|
382
|
+
BlockPublishOutcome,
|
|
383
|
+
BlockRecord,
|
|
384
|
+
BlockRegistryBinding,
|
|
385
|
+
BlockReinstateOutcome,
|
|
386
|
+
BlockVersionInput,
|
|
387
|
+
} from './block-binding.js';
|
|
331
388
|
export { EVAL_KINDS } from './eval-suite-binding.js';
|
|
332
389
|
export type {
|
|
333
390
|
EvalKind,
|
|
@@ -348,6 +405,9 @@ export type {
|
|
|
348
405
|
export { EVAL_RUN_STATUSES } from './eval-run-binding.js';
|
|
349
406
|
export type {
|
|
350
407
|
AgentRef,
|
|
408
|
+
EvalBaseline,
|
|
409
|
+
EvalComparison,
|
|
410
|
+
EvalReads,
|
|
351
411
|
EvalRun,
|
|
352
412
|
EvalRunBinding,
|
|
353
413
|
EvalRunCancelInput,
|
|
@@ -379,7 +439,27 @@ export type {
|
|
|
379
439
|
EvalSubjectInvoker,
|
|
380
440
|
InProcessEvalRunBindingOptions,
|
|
381
441
|
} from './eval-run-dispatcher.js';
|
|
382
|
-
export {
|
|
442
|
+
export { DEFAULT_COMPARISON, createJudgedDispatcher } from './judged-dispatcher.js';
|
|
443
|
+
export type {
|
|
444
|
+
ComparisonBaselineSummary,
|
|
445
|
+
ComparisonMetric,
|
|
446
|
+
JudgedCaseResult,
|
|
447
|
+
JudgedComparisonSummary,
|
|
448
|
+
JudgedDispatcherOptions,
|
|
449
|
+
} from './judged-dispatcher.js';
|
|
450
|
+
export { itemChanges, matchJudged, outputItems, scoreItems, valueAt } from './judged-items.js';
|
|
451
|
+
export type {
|
|
452
|
+
ItemChanges,
|
|
453
|
+
ItemJudgments,
|
|
454
|
+
MatchedItem,
|
|
455
|
+
OutputItem,
|
|
456
|
+
OutputScore,
|
|
457
|
+
} from './judged-items.js';
|
|
458
|
+
export {
|
|
459
|
+
COST_AGGREGATE_DEFAULT_LIMIT,
|
|
460
|
+
COST_AGGREGATE_MAX_LIMIT,
|
|
461
|
+
COST_GROUP_DIMENSIONS,
|
|
462
|
+
} from './cost-binding.js';
|
|
383
463
|
export type {
|
|
384
464
|
CostAggregateGroup,
|
|
385
465
|
CostAggregateInput,
|
|
@@ -477,7 +557,10 @@ export type {
|
|
|
477
557
|
DeploymentGetInput,
|
|
478
558
|
DeploymentListInput,
|
|
479
559
|
DeploymentPage,
|
|
560
|
+
DeployedAgent,
|
|
561
|
+
DeployedFlow,
|
|
480
562
|
DeployedPrimitive,
|
|
563
|
+
DeployedVersion,
|
|
481
564
|
DeploymentContents,
|
|
482
565
|
DeploymentPrimitiveCounts,
|
|
483
566
|
DeploymentRegisterInput,
|