@aid-framework/ir 0.0.0 → 0.1.39
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 +201 -0
- package/README.md +135 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/build.d.ts +74 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/build.js +1079 -0
- package/dist/build.js.map +1 -0
- package/dist/capabilities.d.ts +65 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +176 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/catalog/index.d.ts +36 -0
- package/dist/catalog/index.d.ts.map +1 -0
- package/dist/catalog/index.js +43 -0
- package/dist/catalog/index.js.map +1 -0
- package/dist/catalog/models.json +52 -0
- package/dist/diagnostics.d.ts +90 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +103 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/gates/agents.d.ts +34 -0
- package/dist/gates/agents.d.ts.map +1 -0
- package/dist/gates/agents.js +233 -0
- package/dist/gates/agents.js.map +1 -0
- package/dist/gates/capability.d.ts +15 -0
- package/dist/gates/capability.d.ts.map +1 -0
- package/dist/gates/capability.js +81 -0
- package/dist/gates/capability.js.map +1 -0
- package/dist/gates/contract.d.ts +35 -0
- package/dist/gates/contract.d.ts.map +1 -0
- package/dist/gates/contract.js +19 -0
- package/dist/gates/contract.js.map +1 -0
- package/dist/gates/cost.d.ts +40 -0
- package/dist/gates/cost.d.ts.map +1 -0
- package/dist/gates/cost.js +167 -0
- package/dist/gates/cost.js.map +1 -0
- package/dist/gates/deploy.d.ts +23 -0
- package/dist/gates/deploy.d.ts.map +1 -0
- package/dist/gates/deploy.js +44 -0
- package/dist/gates/deploy.js.map +1 -0
- package/dist/gates/eval-coverage.d.ts +11 -0
- package/dist/gates/eval-coverage.d.ts.map +1 -0
- package/dist/gates/eval-coverage.js +50 -0
- package/dist/gates/eval-coverage.js.map +1 -0
- package/dist/gates/guardrails.d.ts +24 -0
- package/dist/gates/guardrails.d.ts.map +1 -0
- package/dist/gates/guardrails.js +112 -0
- package/dist/gates/guardrails.js.map +1 -0
- package/dist/gates/hitl.d.ts +17 -0
- package/dist/gates/hitl.d.ts.map +1 -0
- package/dist/gates/hitl.js +40 -0
- package/dist/gates/hitl.js.map +1 -0
- package/dist/gates/index.d.ts +66 -0
- package/dist/gates/index.d.ts.map +1 -0
- package/dist/gates/index.js +77 -0
- package/dist/gates/index.js.map +1 -0
- package/dist/gates/memory.d.ts +13 -0
- package/dist/gates/memory.d.ts.map +1 -0
- package/dist/gates/memory.js +67 -0
- package/dist/gates/memory.js.map +1 -0
- package/dist/gates/normalize.d.ts +26 -0
- package/dist/gates/normalize.d.ts.map +1 -0
- package/dist/gates/normalize.js +228 -0
- package/dist/gates/normalize.js.map +1 -0
- package/dist/gates/orchestration.d.ts +17 -0
- package/dist/gates/orchestration.d.ts.map +1 -0
- package/dist/gates/orchestration.js +46 -0
- package/dist/gates/orchestration.js.map +1 -0
- package/dist/gates/referential.d.ts +12 -0
- package/dist/gates/referential.d.ts.map +1 -0
- package/dist/gates/referential.js +554 -0
- package/dist/gates/referential.js.map +1 -0
- package/dist/gates/security.d.ts +22 -0
- package/dist/gates/security.d.ts.map +1 -0
- package/dist/gates/security.js +225 -0
- package/dist/gates/security.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/policy/ast.d.ts +61 -0
- package/dist/policy/ast.d.ts.map +1 -0
- package/dist/policy/ast.js +48 -0
- package/dist/policy/ast.js.map +1 -0
- package/dist/policy/index.d.ts +7 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +4 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/policy/lexer.d.ts +27 -0
- package/dist/policy/lexer.d.ts.map +1 -0
- package/dist/policy/lexer.js +147 -0
- package/dist/policy/lexer.js.map +1 -0
- package/dist/policy/parser.d.ts +15 -0
- package/dist/policy/parser.d.ts.map +1 -0
- package/dist/policy/parser.js +202 -0
- package/dist/policy/parser.js.map +1 -0
- package/dist/predicate/ast.d.ts +125 -0
- package/dist/predicate/ast.d.ts.map +1 -0
- package/dist/predicate/ast.js +111 -0
- package/dist/predicate/ast.js.map +1 -0
- package/dist/predicate/index.d.ts +7 -0
- package/dist/predicate/index.d.ts.map +1 -0
- package/dist/predicate/index.js +4 -0
- package/dist/predicate/index.js.map +1 -0
- package/dist/predicate/lexer.d.ts +30 -0
- package/dist/predicate/lexer.d.ts.map +1 -0
- package/dist/predicate/lexer.js +176 -0
- package/dist/predicate/lexer.js.map +1 -0
- package/dist/predicate/parser.d.ts +16 -0
- package/dist/predicate/parser.d.ts.map +1 -0
- package/dist/predicate/parser.js +317 -0
- package/dist/predicate/parser.js.map +1 -0
- package/dist/schema/ir.schema.json +1144 -0
- package/dist/serialize.d.ts +15 -0
- package/dist/serialize.d.ts.map +1 -0
- package/dist/serialize.js +53 -0
- package/dist/serialize.js.map +1 -0
- package/dist/shapes.d.ts +671 -0
- package/dist/shapes.d.ts.map +1 -0
- package/dist/shapes.js +159 -0
- package/dist/shapes.js.map +1 -0
- package/package.json +44 -14
package/dist/shapes.d.ts
ADDED
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IR v0.1 shapes (`docs/design.md` §7.2).
|
|
3
|
+
*
|
|
4
|
+
* Every top-level collection in §7.2 is present in the IR, always. Phase 0 populates
|
|
5
|
+
* `types`, `models`, `prompts`, `tools`, `pipelines`, and `evals`; the retrieval
|
|
6
|
+
* surface adds `stores` and `retrievers` and derives `embeddings` from the models that
|
|
7
|
+
* declare the `embeddings` capability. The rest are **present and empty (`[]`)** by
|
|
8
|
+
* design, never omitted and never `undefined`: that stability is what lets a later
|
|
9
|
+
* phase fill them without a breaking reshape. They are empty for two different
|
|
10
|
+
* reasons, and the difference matters. `agents`, `guardrails`, `memory`, and
|
|
11
|
+
* `deployments` are spec sections the DSL defines but defers (`DEFERRED_SECTIONS`), so
|
|
12
|
+
* a spec cannot populate them yet. `embeddings` has no spec section at all: it is
|
|
13
|
+
* IR-only scaffolding, derived rather than declared, declared here so §7.2's shape is
|
|
14
|
+
* complete. `observability` and `runtime` are objects carrying defaults, not arrays.
|
|
15
|
+
*/
|
|
16
|
+
import type { ModelCapability, RequiredCapability } from './capabilities.js';
|
|
17
|
+
import type { PolicyExpr } from './policy/index.js';
|
|
18
|
+
import type { PredicateNode } from './predicate/index.js';
|
|
19
|
+
/** IR format version. Semver, independent of the spec's `specVersion`. */
|
|
20
|
+
export declare const IR_VERSION = "0.1.0";
|
|
21
|
+
export declare const PRIMITIVE_TYPES: readonly ['string', 'number', 'integer', 'boolean'];
|
|
22
|
+
export type PrimitiveType = (typeof PRIMITIVE_TYPES)[number];
|
|
23
|
+
/**
|
|
24
|
+
* A resolved type reference: `named` carries the declared type id and whether it
|
|
25
|
+
* resolved, so a generator never re-resolves the spec.
|
|
26
|
+
*/
|
|
27
|
+
export type TypeRef = {
|
|
28
|
+
kind: 'primitive';
|
|
29
|
+
name: PrimitiveType;
|
|
30
|
+
list: boolean;
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'named';
|
|
33
|
+
name: string;
|
|
34
|
+
list: boolean;
|
|
35
|
+
resolved: boolean;
|
|
36
|
+
};
|
|
37
|
+
export interface TypeField {
|
|
38
|
+
name: string;
|
|
39
|
+
type: TypeRef;
|
|
40
|
+
required: boolean;
|
|
41
|
+
description?: string;
|
|
42
|
+
enum?: (string | number | boolean)[];
|
|
43
|
+
minimum?: number;
|
|
44
|
+
maximum?: number;
|
|
45
|
+
/** Marks the field as sensitive; trace redaction must cover it. */
|
|
46
|
+
sensitive?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface TypeShape {
|
|
49
|
+
id: string;
|
|
50
|
+
kind: 'struct';
|
|
51
|
+
description?: string;
|
|
52
|
+
fields: TypeField[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The derived identity of an IR node (§5.2). Identities come from the declared
|
|
56
|
+
* id — and the prompt version — never from content or ordering, so an unrelated
|
|
57
|
+
* edit cannot churn an identity and therefore cannot churn a diff.
|
|
58
|
+
*/
|
|
59
|
+
export declare function modelIdentity(id: string): string;
|
|
60
|
+
export declare function promptIdentity(id: string, version: number): string;
|
|
61
|
+
export declare function toolIdentity(id: string): string;
|
|
62
|
+
export declare function pipelineIdentity(id: string): string;
|
|
63
|
+
/** Free-form, generator-specific annotation. Spec v0.1 declares `citations` only. */
|
|
64
|
+
export interface Trait {
|
|
65
|
+
name: string;
|
|
66
|
+
value?: unknown;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Traits a retriever can declare in spec v0.1. A generator may emit behavior only
|
|
70
|
+
* for a trait it recognizes, so an unrecognized one is dropped rather than kept
|
|
71
|
+
* and silently ignored.
|
|
72
|
+
*/
|
|
73
|
+
export declare const RETRIEVAL_TRAITS: readonly ['citations'];
|
|
74
|
+
/** §7.2's provider union plus the two Phase 0 spec spellings. */
|
|
75
|
+
export declare const PROVIDERS: readonly ['openai', 'openai-compatible', 'anthropic', 'azure', 'bedrock', 'google', 'ollama', 'vllm', 'fake', 'custom'];
|
|
76
|
+
export type Provider = (typeof PROVIDERS)[number];
|
|
77
|
+
export declare function isProvider(value: string): value is Provider;
|
|
78
|
+
export interface ModelParams {
|
|
79
|
+
temperature?: number;
|
|
80
|
+
topP?: number;
|
|
81
|
+
maxTokens?: number;
|
|
82
|
+
seed?: number;
|
|
83
|
+
stop?: string[];
|
|
84
|
+
}
|
|
85
|
+
export interface ModelLimits {
|
|
86
|
+
/** Context window. The spec spells this `limits.maxInputTokens`. */
|
|
87
|
+
contextTokens: number;
|
|
88
|
+
maxOutputTokens?: number;
|
|
89
|
+
rpm?: number;
|
|
90
|
+
tpm?: number;
|
|
91
|
+
}
|
|
92
|
+
/** Per-million-token prices. Resolved from `src/catalog/models.json`. */
|
|
93
|
+
export interface CostProfile {
|
|
94
|
+
inputPerMTok: number;
|
|
95
|
+
outputPerMTok: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The opt-in semantic cache: an explicit threshold and TTL, so no spec can enable
|
|
99
|
+
* semantic caching and inherit a silent default for either.
|
|
100
|
+
*/
|
|
101
|
+
export interface SemanticCacheShape {
|
|
102
|
+
/** Minimum cosine similarity (0..1) a new prompt must reach against a cached one. */
|
|
103
|
+
threshold: number;
|
|
104
|
+
/** How long (seconds) a cached response may be reused before it is invalidated. */
|
|
105
|
+
ttlSeconds: number;
|
|
106
|
+
}
|
|
107
|
+
export interface ModelShape {
|
|
108
|
+
id: string;
|
|
109
|
+
/** Stable identity `model:<id>`; derived from the id, never from content. */
|
|
110
|
+
identity: string;
|
|
111
|
+
provider: Provider;
|
|
112
|
+
modelId: string;
|
|
113
|
+
capabilities: ModelCapability[];
|
|
114
|
+
params: ModelParams;
|
|
115
|
+
limits: ModelLimits;
|
|
116
|
+
costProfile?: CostProfile;
|
|
117
|
+
/** Catalog key the cost came from, when one resolved. */
|
|
118
|
+
costProfileId?: string;
|
|
119
|
+
fallbacks: string[];
|
|
120
|
+
cache?: {
|
|
121
|
+
prompt?: boolean;
|
|
122
|
+
semantic?: SemanticCacheShape;
|
|
123
|
+
};
|
|
124
|
+
baseUrl?: string;
|
|
125
|
+
apiKeyEnv?: string;
|
|
126
|
+
description?: string;
|
|
127
|
+
traits: Trait[];
|
|
128
|
+
}
|
|
129
|
+
export interface PromptVariable {
|
|
130
|
+
name: string;
|
|
131
|
+
type: TypeRef;
|
|
132
|
+
required: boolean;
|
|
133
|
+
/** Any JSON value; the spec's `variables.<name>.default` is unconstrained. */
|
|
134
|
+
default?: unknown;
|
|
135
|
+
description?: string;
|
|
136
|
+
/** Marks the value as sensitive; trace redaction must cover it. */
|
|
137
|
+
sensitive?: boolean;
|
|
138
|
+
}
|
|
139
|
+
export interface PromptOutput {
|
|
140
|
+
kind: 'text' | 'json' | 'structured';
|
|
141
|
+
schema?: TypeRef;
|
|
142
|
+
}
|
|
143
|
+
export interface PromptShape {
|
|
144
|
+
id: string;
|
|
145
|
+
version: number;
|
|
146
|
+
/** Stable identity, `prompt:<id>@<version>`. */
|
|
147
|
+
identity: string;
|
|
148
|
+
model: string;
|
|
149
|
+
template: string;
|
|
150
|
+
variables: PromptVariable[];
|
|
151
|
+
output: PromptOutput;
|
|
152
|
+
params: ModelParams;
|
|
153
|
+
examples: unknown[];
|
|
154
|
+
guardrails: string[];
|
|
155
|
+
evals: string[];
|
|
156
|
+
traits: Trait[];
|
|
157
|
+
}
|
|
158
|
+
export type SideEffects = 'none' | 'read' | 'write' | 'destructive';
|
|
159
|
+
export type Idempotency = 'none' | 'key' | 'natural';
|
|
160
|
+
export interface ToolHandler {
|
|
161
|
+
kind: 'generated' | 'business' | 'mcp';
|
|
162
|
+
symbol?: string;
|
|
163
|
+
mcp?: {
|
|
164
|
+
server: string;
|
|
165
|
+
tool: string;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
export interface ToolShape {
|
|
169
|
+
id: string;
|
|
170
|
+
/** Stable identity `tool:<id>`; derived from the id, never from content. */
|
|
171
|
+
identity: string;
|
|
172
|
+
name: string;
|
|
173
|
+
description: string;
|
|
174
|
+
input: TypeRef;
|
|
175
|
+
output: TypeRef;
|
|
176
|
+
sideEffects: SideEffects;
|
|
177
|
+
requiresConfirmation: boolean;
|
|
178
|
+
/** Parsed policy, absent when the spec declared none or it failed to parse. */
|
|
179
|
+
auth?: PolicyExpr;
|
|
180
|
+
timeoutMs: number;
|
|
181
|
+
retries: number;
|
|
182
|
+
idempotency: Idempotency;
|
|
183
|
+
handler: ToolHandler;
|
|
184
|
+
traits: Trait[];
|
|
185
|
+
}
|
|
186
|
+
export type PipelineTrigger = {
|
|
187
|
+
kind: 'http';
|
|
188
|
+
method: string;
|
|
189
|
+
path: string;
|
|
190
|
+
} | {
|
|
191
|
+
kind: 'schedule';
|
|
192
|
+
schedule: string;
|
|
193
|
+
} | {
|
|
194
|
+
kind: 'event';
|
|
195
|
+
event: string;
|
|
196
|
+
} | {
|
|
197
|
+
kind: 'manual';
|
|
198
|
+
};
|
|
199
|
+
export type StepInputValue = {
|
|
200
|
+
kind: 'literal';
|
|
201
|
+
value: string | number | boolean | null;
|
|
202
|
+
} | {
|
|
203
|
+
kind: 'reference';
|
|
204
|
+
path: string[];
|
|
205
|
+
} | {
|
|
206
|
+
kind: 'template';
|
|
207
|
+
template: string;
|
|
208
|
+
};
|
|
209
|
+
export type StepInput = Record<string, StepInputValue>;
|
|
210
|
+
export interface GenerateStep {
|
|
211
|
+
kind: 'generate';
|
|
212
|
+
prompt: string;
|
|
213
|
+
/** Model alias the prompt resolves to, inlined so a runtime need not re-resolve. */
|
|
214
|
+
model: string;
|
|
215
|
+
input: StepInput;
|
|
216
|
+
as: string;
|
|
217
|
+
/**
|
|
218
|
+
* Binding whose retrieved items and citations are inlined into the prompt. The
|
|
219
|
+
* referential gate resolves the name against the bindings in scope.
|
|
220
|
+
*/
|
|
221
|
+
context?: string;
|
|
222
|
+
}
|
|
223
|
+
export interface ToolStep {
|
|
224
|
+
kind: 'tool';
|
|
225
|
+
tool: string;
|
|
226
|
+
input: StepInput;
|
|
227
|
+
as: string;
|
|
228
|
+
}
|
|
229
|
+
export interface EmitStep {
|
|
230
|
+
kind: 'emit';
|
|
231
|
+
event: string;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* A retrieval step. `query` stays the declared template text, because the runtime
|
|
235
|
+
* interpolates it per request; the referential gate reads its placeholders to
|
|
236
|
+
* reject a reference to a binding that does not exist yet.
|
|
237
|
+
*/
|
|
238
|
+
export interface RetrieveStep {
|
|
239
|
+
kind: 'retrieve';
|
|
240
|
+
retriever: string;
|
|
241
|
+
query: string;
|
|
242
|
+
as: string;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Authorization branching. `when` is evaluated against the caller's Principal and
|
|
246
|
+
* nothing else: the grammar has no operand for a context value, so a branch cannot
|
|
247
|
+
* read what an earlier step produced. Data-driven control flow is `map`/`reduce`.
|
|
248
|
+
*/
|
|
249
|
+
export interface BranchStep {
|
|
250
|
+
kind: 'branch';
|
|
251
|
+
when: PolicyExpr;
|
|
252
|
+
then: StepShape[];
|
|
253
|
+
/** Absent when the spec declared no alternative; then the branch binds nothing. */
|
|
254
|
+
else: StepShape[];
|
|
255
|
+
}
|
|
256
|
+
/** Each arm runs concurrently under the deployment's single concurrency cap. */
|
|
257
|
+
export interface ParallelStep {
|
|
258
|
+
kind: 'parallel';
|
|
259
|
+
branches: StepShape[][];
|
|
260
|
+
}
|
|
261
|
+
/** Applies `step` to every item of `over`, concurrently; binds the ordered results. */
|
|
262
|
+
export interface MapStep {
|
|
263
|
+
kind: 'map';
|
|
264
|
+
over: string;
|
|
265
|
+
as: string;
|
|
266
|
+
step: StepShape;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Applies `prompt` to every item of `over`, concurrently, and binds the ordered list of
|
|
270
|
+
* results. Combining them is a following `generate` step, so no merge strategy is
|
|
271
|
+
* invented here.
|
|
272
|
+
*/
|
|
273
|
+
export interface ReduceStep {
|
|
274
|
+
kind: 'reduce';
|
|
275
|
+
over: string;
|
|
276
|
+
prompt: string;
|
|
277
|
+
/** Model alias the prompt resolves to, inlined so a runtime need not re-resolve. */
|
|
278
|
+
model: string;
|
|
279
|
+
as: string;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Reorders the retrieved items bound by `over` against `query`.
|
|
283
|
+
*
|
|
284
|
+
* The runtime's `Reranker.rerank(query, items, *, top_n)` takes both a query and the
|
|
285
|
+
* items, so the step names both rather than carrying the design's single `input`: one
|
|
286
|
+
* field could not supply a query *and* say which binding is being reordered.
|
|
287
|
+
*/
|
|
288
|
+
export interface RerankStep {
|
|
289
|
+
kind: 'rerank';
|
|
290
|
+
/** Binding holding the retrieval result to reorder; the referential gate types it. */
|
|
291
|
+
over: string;
|
|
292
|
+
query: string;
|
|
293
|
+
/** Reranker alias, not a `models[]` id: only the lexical reranker exists today. */
|
|
294
|
+
model: string;
|
|
295
|
+
topN: number;
|
|
296
|
+
as: string;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Runs one declared guardrail against one payload at one stage.
|
|
300
|
+
*
|
|
301
|
+
* Binds nothing: a `flag` verdict is observability only, and the actions that could
|
|
302
|
+
* change the payload are refused when the pipeline is validated.
|
|
303
|
+
*/
|
|
304
|
+
export interface GuardStep {
|
|
305
|
+
kind: 'guard';
|
|
306
|
+
guardrail: string;
|
|
307
|
+
stage: 'input' | 'output' | 'retrieval' | 'tool-call';
|
|
308
|
+
/**
|
|
309
|
+
* Stage-discriminated. At `input`/`output` this is template text handed to the
|
|
310
|
+
* guardrail as the payload; at `retrieval` it is a single reference to a retrieval
|
|
311
|
+
* binding, whose chunk passages are what `check_retrieval` inspects.
|
|
312
|
+
*/
|
|
313
|
+
text: string;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Runs a declared agent to completion and binds its answer.
|
|
317
|
+
*
|
|
318
|
+
* The step owns a fresh run of the agent: it opens no thread and resumes nothing, so a
|
|
319
|
+
* target that can pause is refused where the pipeline is validated.
|
|
320
|
+
*/
|
|
321
|
+
export interface AgentStep {
|
|
322
|
+
kind: 'agent';
|
|
323
|
+
agent: string;
|
|
324
|
+
/** User turn for the run; the agent's own instructions stay with the agent. */
|
|
325
|
+
text: string;
|
|
326
|
+
as: string;
|
|
327
|
+
}
|
|
328
|
+
export type StepShape = GenerateStep | RetrieveStep | ToolStep | EmitStep | BranchStep | ParallelStep | MapStep | ReduceStep | RerankStep | GuardStep | AgentStep;
|
|
329
|
+
/** The composite kinds: the four that nest other steps and so can recurse. */
|
|
330
|
+
export declare const COMPOSITE_STEP_KINDS: readonly ['branch', 'parallel', 'map', 'reduce'];
|
|
331
|
+
/** The step kinds that contain other steps, so every walker has one guard to reach for. */
|
|
332
|
+
export type CompositeStep = BranchStep | ParallelStep | MapStep | ReduceStep;
|
|
333
|
+
export declare function isCompositeStep(step: {
|
|
334
|
+
kind: StepShape['kind'];
|
|
335
|
+
}): step is CompositeStep;
|
|
336
|
+
/**
|
|
337
|
+
* Deepest composite nesting a pipeline may declare. The spec layer owns the number and
|
|
338
|
+
* rejects a deeper pipeline before generation; the generator *emits* it into the
|
|
339
|
+
* generated package (`aid_runtime.control` keeps a default for hand-written use), so a
|
|
340
|
+
* drift between build and runtime fails a test instead of diverging silently.
|
|
341
|
+
*/
|
|
342
|
+
export { MAX_STEP_DEPTH } from '@aid-framework/spec';
|
|
343
|
+
export interface ErrorPolicy {
|
|
344
|
+
retries: number;
|
|
345
|
+
fallback?: string;
|
|
346
|
+
deadLetter?: string;
|
|
347
|
+
}
|
|
348
|
+
export interface ObservabilityShape {
|
|
349
|
+
trace: boolean;
|
|
350
|
+
redact: string[];
|
|
351
|
+
}
|
|
352
|
+
export interface PipelineShape {
|
|
353
|
+
id: string;
|
|
354
|
+
/** Stable identity `pipeline:<id>`; derived from the id, never from content. */
|
|
355
|
+
identity: string;
|
|
356
|
+
description?: string;
|
|
357
|
+
trigger: PipelineTrigger;
|
|
358
|
+
steps: StepShape[];
|
|
359
|
+
errorPolicy: ErrorPolicy;
|
|
360
|
+
/** Resolved from the top-level `observability` during normalization. */
|
|
361
|
+
observability: ObservabilityShape;
|
|
362
|
+
}
|
|
363
|
+
export declare const EVAL_TARGET_KINDS: readonly ['pipeline', 'prompt'];
|
|
364
|
+
export type EvalTargetKind = (typeof EVAL_TARGET_KINDS)[number];
|
|
365
|
+
export interface EvalTarget {
|
|
366
|
+
kind: EvalTargetKind;
|
|
367
|
+
id: string;
|
|
368
|
+
/** The `kind:id` form as declared. */
|
|
369
|
+
qualified: string;
|
|
370
|
+
/** False when `qualified` is not a `kind:id` pair with a known kind. */
|
|
371
|
+
valid: boolean;
|
|
372
|
+
}
|
|
373
|
+
export interface EvalDataset {
|
|
374
|
+
source: 'inline' | 'file' | 'synthetic';
|
|
375
|
+
uri?: string;
|
|
376
|
+
}
|
|
377
|
+
export type MetricShape = {
|
|
378
|
+
kind: 'exact';
|
|
379
|
+
field: string;
|
|
380
|
+
} | {
|
|
381
|
+
kind: 'contains';
|
|
382
|
+
field: string;
|
|
383
|
+
value?: string;
|
|
384
|
+
} | {
|
|
385
|
+
kind: 'json-schema';
|
|
386
|
+
schema: TypeRef;
|
|
387
|
+
} | {
|
|
388
|
+
kind: 'tool-trace';
|
|
389
|
+
expect: string[];
|
|
390
|
+
ordered: boolean;
|
|
391
|
+
} | {
|
|
392
|
+
kind: 'cost';
|
|
393
|
+
max: number;
|
|
394
|
+
} | {
|
|
395
|
+
kind: 'latency';
|
|
396
|
+
maxMs: number;
|
|
397
|
+
} | {
|
|
398
|
+
kind: 'llm-judge';
|
|
399
|
+
rubric: string;
|
|
400
|
+
field?: string;
|
|
401
|
+
model?: string;
|
|
402
|
+
threshold?: number;
|
|
403
|
+
} | {
|
|
404
|
+
kind: 'retrieval';
|
|
405
|
+
expectDocs: string[];
|
|
406
|
+
k: number;
|
|
407
|
+
} | {
|
|
408
|
+
kind: 'assert';
|
|
409
|
+
expr: PredicateNode;
|
|
410
|
+
message: string;
|
|
411
|
+
};
|
|
412
|
+
export interface EvalGate {
|
|
413
|
+
ci: boolean;
|
|
414
|
+
maxRegression: number;
|
|
415
|
+
samples: number;
|
|
416
|
+
/**
|
|
417
|
+
* Absolute floor on every metric's mean, checked before the maxRegression delta.
|
|
418
|
+
*
|
|
419
|
+
* Absent unless the spec declared it, so an eval that does not carry one serializes
|
|
420
|
+
* exactly as it did before this property existed.
|
|
421
|
+
*/
|
|
422
|
+
minMean?: number;
|
|
423
|
+
}
|
|
424
|
+
export interface EvalShape {
|
|
425
|
+
id: string;
|
|
426
|
+
description?: string;
|
|
427
|
+
target: EvalTarget;
|
|
428
|
+
dataset: EvalDataset;
|
|
429
|
+
metrics: MetricShape[];
|
|
430
|
+
gate: EvalGate;
|
|
431
|
+
/** Tightest `cost` metric `max`, in the run's currency. */
|
|
432
|
+
costBudget?: number;
|
|
433
|
+
latencyBudgetP95Ms?: number;
|
|
434
|
+
traits: Trait[];
|
|
435
|
+
}
|
|
436
|
+
export interface ProjectShape {
|
|
437
|
+
name: string;
|
|
438
|
+
namespace: string;
|
|
439
|
+
description?: string;
|
|
440
|
+
targets: string[];
|
|
441
|
+
}
|
|
442
|
+
export interface RuntimeShape {
|
|
443
|
+
/** Phase 0 executes generated pipelines as plain sequential async control flow. */
|
|
444
|
+
controlFlow: 'plain-async';
|
|
445
|
+
orchestration?: string;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Shaped per design §7.2. Populated from the `retrievers` spec section as of the
|
|
449
|
+
* retrieval surface; the collections that remain deferred (`agents`, `guardrails`,
|
|
450
|
+
* `memory`, `deployments`) are empty, since an empty array is otherwise
|
|
451
|
+
* indistinguishable from "not implemented".
|
|
452
|
+
*/
|
|
453
|
+
export interface RetrieverShape {
|
|
454
|
+
id: string;
|
|
455
|
+
source: {
|
|
456
|
+
kind: 'file' | 's3' | 'http' | 'db' | 'mcp';
|
|
457
|
+
uri: string;
|
|
458
|
+
glob?: string;
|
|
459
|
+
};
|
|
460
|
+
chunking: {
|
|
461
|
+
strategy: 'fixed' | 'recursive' | 'semantic' | 'code';
|
|
462
|
+
size: number;
|
|
463
|
+
overlap: number;
|
|
464
|
+
keepMetadata: string[];
|
|
465
|
+
};
|
|
466
|
+
embedModel: string;
|
|
467
|
+
/** Vector store id. */
|
|
468
|
+
store: string;
|
|
469
|
+
index: {
|
|
470
|
+
metric: IndexMetric;
|
|
471
|
+
hybrid: boolean;
|
|
472
|
+
params?: Record<string, unknown>;
|
|
473
|
+
};
|
|
474
|
+
topK: number;
|
|
475
|
+
/** A deterministic lexical reranker in Phase 1, named by a model alias. */
|
|
476
|
+
rerank?: {
|
|
477
|
+
model: string;
|
|
478
|
+
topN: number;
|
|
479
|
+
};
|
|
480
|
+
filters?: string[];
|
|
481
|
+
refresh: {
|
|
482
|
+
mode: 'full' | 'incremental';
|
|
483
|
+
schedule?: string;
|
|
484
|
+
};
|
|
485
|
+
traits: Trait[];
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* One per model that declares the `embeddings` capability, so a runtime can pick an
|
|
489
|
+
* embedder without re-reading `models`. Embeddings have no spec section of their
|
|
490
|
+
* own; the model alias is the id, which keeps `retriever.embedModel` resolvable.
|
|
491
|
+
*/
|
|
492
|
+
export interface EmbeddingShape {
|
|
493
|
+
id: string;
|
|
494
|
+
provider: Provider;
|
|
495
|
+
modelId: string;
|
|
496
|
+
dimensions?: number;
|
|
497
|
+
costProfile?: CostProfile;
|
|
498
|
+
traits: Trait[];
|
|
499
|
+
}
|
|
500
|
+
/** The vector-distance metrics the IR models. Spec v0.1 can declare any of them. */
|
|
501
|
+
export declare const INDEX_METRICS: readonly ['cosine', 'dot', 'l2'];
|
|
502
|
+
export type IndexMetric = (typeof INDEX_METRICS)[number];
|
|
503
|
+
export declare function isIndexMetric(value: string): value is IndexMetric;
|
|
504
|
+
/** Vector store kinds the IR models. Spec v0.1 can declare `memory` and `pgvector`. */
|
|
505
|
+
export declare const VECTOR_STORE_KINDS: readonly ['memory', 'pgvector', 'qdrant', 'pinecone', 'weaviate', 'custom'];
|
|
506
|
+
export type VectorStoreKind = (typeof VECTOR_STORE_KINDS)[number];
|
|
507
|
+
export declare function isVectorStoreKind(value: string): value is VectorStoreKind;
|
|
508
|
+
export interface VectorStoreShape {
|
|
509
|
+
id: string;
|
|
510
|
+
kind: VectorStoreKind;
|
|
511
|
+
/** `env:NAME` for a hosted store; absent for `memory`. */
|
|
512
|
+
uri?: string;
|
|
513
|
+
dimensions?: number;
|
|
514
|
+
traits: Trait[];
|
|
515
|
+
}
|
|
516
|
+
export interface MemoryShape {
|
|
517
|
+
id: string;
|
|
518
|
+
kind: 'buffer' | 'window' | 'summary' | 'semantic' | 'episodic' | 'vector';
|
|
519
|
+
scope: 'thread' | 'user' | 'global';
|
|
520
|
+
tokenBudget: number;
|
|
521
|
+
summarizeModel?: string;
|
|
522
|
+
store?: string;
|
|
523
|
+
/** A declared store id or `in-process`; resolved by the `memory/refs` gate. */
|
|
524
|
+
backend?: string;
|
|
525
|
+
ttl?: string;
|
|
526
|
+
redact: string[];
|
|
527
|
+
traits: Trait[];
|
|
528
|
+
}
|
|
529
|
+
/** Who owns the agent loop. `deepagents` requires a pinned `engineVersion`. */
|
|
530
|
+
export declare const AGENT_ENGINES: readonly ['native', 'deepagents'];
|
|
531
|
+
export type AgentEngine = (typeof AGENT_ENGINES)[number];
|
|
532
|
+
/** What happens when an agent's budget is exhausted. `fail` is the default. */
|
|
533
|
+
export declare const AGENT_ON_BUDGET_EXHAUSTED: readonly ['fail', 'degrade'];
|
|
534
|
+
export type AgentOnBudgetExhausted = (typeof AGENT_ON_BUDGET_EXHAUSTED)[number];
|
|
535
|
+
export interface AgentShape {
|
|
536
|
+
id: string;
|
|
537
|
+
name: string;
|
|
538
|
+
/** Prompt ref supplying the agent's instructions. */
|
|
539
|
+
instructions: string;
|
|
540
|
+
model: string;
|
|
541
|
+
tools: string[];
|
|
542
|
+
retrievers: string[];
|
|
543
|
+
memory: string[];
|
|
544
|
+
guardrails: string[];
|
|
545
|
+
structuredOutput?: TypeRef;
|
|
546
|
+
maxSteps: number;
|
|
547
|
+
maxTokensBudget?: number;
|
|
548
|
+
/** USD. */
|
|
549
|
+
maxCostBudget?: number;
|
|
550
|
+
/**
|
|
551
|
+
* `fail` (the default) makes a budget breach a hard failure. `degrade` steps
|
|
552
|
+
* once to the first cheaper fallback alias; the `agents/budget-degrade` gate
|
|
553
|
+
* rejects it without a cost ceiling and a strictly cheaper alias.
|
|
554
|
+
*/
|
|
555
|
+
onBudgetExhausted?: AgentOnBudgetExhausted;
|
|
556
|
+
/** Other agent ids this agent may transfer the conversation to. */
|
|
557
|
+
handoffs: string[];
|
|
558
|
+
/** Other agent ids this agent may delegate a sub-task to. */
|
|
559
|
+
delegates: string[];
|
|
560
|
+
engine: AgentEngine;
|
|
561
|
+
/** Pinned framework version; required when `engine` is `deepagents`. */
|
|
562
|
+
engineVersion?: string;
|
|
563
|
+
humanInTheLoop?: {
|
|
564
|
+
when: PolicyExpr;
|
|
565
|
+
channel: string;
|
|
566
|
+
};
|
|
567
|
+
traits: Trait[];
|
|
568
|
+
}
|
|
569
|
+
export interface GuardrailShape {
|
|
570
|
+
id: string;
|
|
571
|
+
stages: ('input' | 'output' | 'retrieval' | 'tool-call')[];
|
|
572
|
+
policies: GuardrailPolicyKind[];
|
|
573
|
+
action: 'block' | 'redact' | 'flag' | 'escalate';
|
|
574
|
+
/** Field names the `redact` action removes; required for that action. */
|
|
575
|
+
redact: string[];
|
|
576
|
+
/** Tools this guardrail covers; empty means every tool reaching the stage. */
|
|
577
|
+
tools: string[];
|
|
578
|
+
onFail: {
|
|
579
|
+
message: string;
|
|
580
|
+
fallbackPrompt?: string;
|
|
581
|
+
log: boolean;
|
|
582
|
+
};
|
|
583
|
+
traits: Trait[];
|
|
584
|
+
}
|
|
585
|
+
/**
|
|
586
|
+
* The closed vocabulary of policy checks a guardrail may name. This is the L1 answer
|
|
587
|
+
* to "no passthrough of unknown keys": a spec names one of these, the engine that
|
|
588
|
+
* evaluates them ships in the guardrails layer, and nothing in between accepts a name
|
|
589
|
+
* it does not know. Extending it is a deliberate edit here, not a spec-side string.
|
|
590
|
+
*/
|
|
591
|
+
export declare const GUARDRAIL_POLICY_KINDS: readonly ['pii-detect', 'pii-redact', 'prompt-injection', 'jailbreak', 'moderation', 'toxicity', 'secret-scan'];
|
|
592
|
+
export type GuardrailPolicyKind = (typeof GUARDRAIL_POLICY_KINDS)[number];
|
|
593
|
+
export declare function isGuardrailPolicyKind(value: string): value is GuardrailPolicyKind;
|
|
594
|
+
export interface DeploymentShape {
|
|
595
|
+
id: string;
|
|
596
|
+
target: 'serverless' | 'container' | 'batch' | 'edge';
|
|
597
|
+
streaming: boolean;
|
|
598
|
+
concurrency?: number;
|
|
599
|
+
autoscale?: {
|
|
600
|
+
min: number;
|
|
601
|
+
max: number;
|
|
602
|
+
metric: string;
|
|
603
|
+
};
|
|
604
|
+
secrets: string[];
|
|
605
|
+
env: {
|
|
606
|
+
name: string;
|
|
607
|
+
value?: string;
|
|
608
|
+
secret?: boolean;
|
|
609
|
+
}[];
|
|
610
|
+
traits: Trait[];
|
|
611
|
+
}
|
|
612
|
+
export interface IR {
|
|
613
|
+
/** Semver of the IR format itself; independent of `specVersion`. */
|
|
614
|
+
irVersion: string;
|
|
615
|
+
specVersion: string;
|
|
616
|
+
project: ProjectShape;
|
|
617
|
+
types: TypeShape[];
|
|
618
|
+
models: ModelShape[];
|
|
619
|
+
prompts: PromptShape[];
|
|
620
|
+
tools: ToolShape[];
|
|
621
|
+
retrievers: RetrieverShape[];
|
|
622
|
+
embeddings: EmbeddingShape[];
|
|
623
|
+
stores: VectorStoreShape[];
|
|
624
|
+
memory: MemoryShape[];
|
|
625
|
+
agents: AgentShape[];
|
|
626
|
+
pipelines: PipelineShape[];
|
|
627
|
+
evals: EvalShape[];
|
|
628
|
+
guardrails: GuardrailShape[];
|
|
629
|
+
deployments: DeploymentShape[];
|
|
630
|
+
observability: ObservabilityShape;
|
|
631
|
+
runtime: RuntimeShape;
|
|
632
|
+
/** Target capabilities the IR requires; derived from IR content by the gates. */
|
|
633
|
+
requiredCapabilities: RequiredCapability[];
|
|
634
|
+
}
|
|
635
|
+
/** The IR's collection keys, i.e. every top-level key whose value is an array. */
|
|
636
|
+
export declare const IR_COLLECTIONS: readonly ['types', 'models', 'prompts', 'tools', 'retrievers', 'embeddings', 'stores', 'memory', 'agents', 'pipelines', 'evals', 'guardrails', 'deployments'];
|
|
637
|
+
export type IrCollection = (typeof IR_COLLECTIONS)[number];
|
|
638
|
+
/** Spec section -> IR collection, for every section that populates one. */
|
|
639
|
+
export declare const POPULATED_COLLECTION_BY_SECTION: {
|
|
640
|
+
readonly types: 'types';
|
|
641
|
+
readonly models: 'models';
|
|
642
|
+
readonly prompts: 'prompts';
|
|
643
|
+
readonly tools: 'tools';
|
|
644
|
+
readonly stores: 'stores';
|
|
645
|
+
readonly retrievers: 'retrievers';
|
|
646
|
+
readonly memory: 'memory';
|
|
647
|
+
readonly agents: 'agents';
|
|
648
|
+
readonly guardrails: 'guardrails';
|
|
649
|
+
readonly deployments: 'deployments';
|
|
650
|
+
readonly evals: 'evals';
|
|
651
|
+
readonly pipelines: 'pipelines';
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* IR collections with no spec section: present and populated by derivation rather
|
|
655
|
+
* than declared. Embeddings come from the models that declare the `embeddings`
|
|
656
|
+
* capability, so a spec never names one.
|
|
657
|
+
*/
|
|
658
|
+
export declare const IR_ONLY_COLLECTIONS: readonly ['embeddings'];
|
|
659
|
+
/**
|
|
660
|
+
* Supported spec sections that map to an IR object rather than a collection.
|
|
661
|
+
* Together with `POPULATED_COLLECTION_BY_SECTION` these account for every
|
|
662
|
+
* `SUPPORTED_SECTIONS` entry exactly once.
|
|
663
|
+
*/
|
|
664
|
+
export declare const NON_COLLECTION_SECTIONS: readonly ['specVersion', 'project'];
|
|
665
|
+
/** Providers Phase 0 can actually serve. The IR's `Provider` union is wider. */
|
|
666
|
+
export declare const PHASE_0_PROVIDERS: readonly ['openai', 'openai-compatible', 'fake'];
|
|
667
|
+
/** Phase 0 defaults for the two IR objects that are not collections. */
|
|
668
|
+
export declare const DEFAULT_OBSERVABILITY: ObservabilityShape;
|
|
669
|
+
export declare const DEFAULT_RUNTIME: RuntimeShape;
|
|
670
|
+
export declare const DEFAULT_MAX_CONTEXT_TOKENS = 128000;
|
|
671
|
+
//# sourceMappingURL=shapes.d.ts.map
|