@orkestrel/study 0.0.0-stage → 0.0.1
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 +15 -2
- package/dist/bin/main.js +5408 -0
- package/dist/bin/main.js.map +1 -0
- package/dist/src/core/index.cjs +2066 -0
- package/dist/src/core/index.cjs.map +1 -0
- package/dist/src/core/index.d.cts +1319 -0
- package/dist/src/core/index.d.ts +1319 -0
- package/dist/src/core/index.js +2000 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/server/index.cjs +7408 -0
- package/dist/src/server/index.cjs.map +1 -0
- package/dist/src/server/index.d.cts +2635 -0
- package/dist/src/server/index.d.ts +2635 -0
- package/dist/src/server/index.js +7281 -0
- package/dist/src/server/index.js.map +1 -0
- package/package.json +120 -5
|
@@ -0,0 +1,2635 @@
|
|
|
1
|
+
import type { ChildProcess } from 'node:child_process';
|
|
2
|
+
import type { Dir } from 'node:fs';
|
|
3
|
+
import type { Dirent } from 'node:fs';
|
|
4
|
+
import type { estimateRequest } from '@orkestrel/agent';
|
|
5
|
+
import type { extractTiming } from '@orkestrel/ollama';
|
|
6
|
+
import type { FileHandle } from 'node:fs/promises';
|
|
7
|
+
import type { isAgentError } from '@orkestrel/agent';
|
|
8
|
+
import type { JSONValue } from '@orkestrel/contract';
|
|
9
|
+
import type { LedgerGauge } from '@orkestrel/agent';
|
|
10
|
+
import type { LoadFnOutput } from 'node:module';
|
|
11
|
+
import type { LoadHookContext } from 'node:module';
|
|
12
|
+
import type { LoadHookSync } from 'node:module';
|
|
13
|
+
import type { measureRequest } from '@orkestrel/agent';
|
|
14
|
+
import type { Message } from '@orkestrel/agent';
|
|
15
|
+
import type { OllamaOptions } from '@orkestrel/ollama';
|
|
16
|
+
import type { OllamaTiming } from '@orkestrel/ollama';
|
|
17
|
+
import type { ProviderDelta } from '@orkestrel/agent';
|
|
18
|
+
import type { ProviderInterface } from '@orkestrel/agent';
|
|
19
|
+
import type { ProviderRequest } from '@orkestrel/agent';
|
|
20
|
+
import type { ProviderResult } from '@orkestrel/agent';
|
|
21
|
+
import type { ResolveFnOutput } from 'node:module';
|
|
22
|
+
import type { ResolveHookContext } from 'node:module';
|
|
23
|
+
import type { ResolveHookSync } from 'node:module';
|
|
24
|
+
|
|
25
|
+
/** Bounds all captured input bytes to 128 MiB. */
|
|
26
|
+
export declare const ARTIFACT_BYTES: number;
|
|
27
|
+
|
|
28
|
+
/** Bounds directory nesting below each selected root. */
|
|
29
|
+
export declare const ARTIFACT_DEPTH = 64;
|
|
30
|
+
|
|
31
|
+
/** Bounds one captured input file to 16 MiB. */
|
|
32
|
+
export declare const ARTIFACT_FILE_BYTES: number;
|
|
33
|
+
|
|
34
|
+
/** Bounds admitted files before another capture is allocated. */
|
|
35
|
+
export declare const ARTIFACT_FILES = 8192;
|
|
36
|
+
|
|
37
|
+
/** Bounds selected package roots before traversal begins. */
|
|
38
|
+
export declare const ARTIFACT_ROOTS = 128;
|
|
39
|
+
|
|
40
|
+
/** Bounds all visited directory entries, including ignored assets. */
|
|
41
|
+
export declare const ARTIFACT_VISITS = 32768;
|
|
42
|
+
|
|
43
|
+
/** Reports an invalid or drifted artifact inventory. */
|
|
44
|
+
export declare class ArtifactError extends Error {
|
|
45
|
+
readonly code: "ARTIFACT";
|
|
46
|
+
/** Records the refused artifact boundary.
|
|
47
|
+
* @param message - The specific refusal.
|
|
48
|
+
*/
|
|
49
|
+
constructor(message: string);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Records the exact bytes admitted at one absolute file path. */
|
|
53
|
+
export declare interface ArtifactFile {
|
|
54
|
+
readonly path: string;
|
|
55
|
+
readonly digest: string;
|
|
56
|
+
readonly size: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Supplies the private namespace and separate source selection to resolution. */
|
|
60
|
+
export declare interface ArtifactHookInput {
|
|
61
|
+
readonly token: string;
|
|
62
|
+
readonly files: readonly ArtifactSource[];
|
|
63
|
+
readonly source?: ArtifactSourceOptions;
|
|
64
|
+
readonly instrument?: string;
|
|
65
|
+
readonly excluded?: readonly string[];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Records all admitted module bytes, selections, and native runtime identity. */
|
|
69
|
+
export declare interface ArtifactInventory {
|
|
70
|
+
readonly digest: string;
|
|
71
|
+
readonly node: string;
|
|
72
|
+
readonly runtime: ArtifactRuntime;
|
|
73
|
+
readonly entries: readonly string[];
|
|
74
|
+
readonly packages: readonly ArtifactPackage[];
|
|
75
|
+
readonly source?: ArtifactSourceOptions;
|
|
76
|
+
readonly instrument?: string;
|
|
77
|
+
readonly files: readonly ArtifactFile[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Captures built ESM and a separate strip-only consumer adapter in a fresh worker.
|
|
81
|
+
* @remarks
|
|
82
|
+
* Loads trusted code, not a hostile-code sandbox. Native process APIs, eval and external
|
|
83
|
+
* services are not replayed. One inventory may load per process; terminate it afterwards.
|
|
84
|
+
*/
|
|
85
|
+
export declare class ArtifactLoader {
|
|
86
|
+
#private;
|
|
87
|
+
/** Captures selections without reading or executing selected modules.
|
|
88
|
+
* @param options - Canonical built selections and optional consumer source selection.
|
|
89
|
+
*/
|
|
90
|
+
constructor(options: ArtifactLoaderOptions);
|
|
91
|
+
/** Reads and identifies admitted files without evaluating selected modules.
|
|
92
|
+
* @returns Frozen evidence identifying all captured bytes and the native runtime.
|
|
93
|
+
* @throws Thrown for invalid selections, unsupported TypeScript, limits, or drift.
|
|
94
|
+
*/
|
|
95
|
+
inspect(): ArtifactInventory;
|
|
96
|
+
/** Refuses byte and population drift since inspection.
|
|
97
|
+
* @throws Thrown when any admitted file or the admitted population changes.
|
|
98
|
+
*/
|
|
99
|
+
verify(): void;
|
|
100
|
+
/** Imports one selected entry through synchronous captured-byte hooks.
|
|
101
|
+
* @param entry - The exact canonical built entry or selected source adapter entry.
|
|
102
|
+
* @returns The actual module namespace for the caller to narrow.
|
|
103
|
+
* @throws Thrown for drift, unsupported edges, evaluation failures, or a reused worker.
|
|
104
|
+
*/
|
|
105
|
+
load(entry: string): Promise<unknown>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** Selects built packages and an optional separate consumer source graph. */
|
|
109
|
+
export declare interface ArtifactLoaderOptions {
|
|
110
|
+
readonly entries: readonly string[];
|
|
111
|
+
readonly roots: readonly string[];
|
|
112
|
+
readonly source?: ArtifactSourceOptions;
|
|
113
|
+
/** Selects one already admitted trusted instrument package permitted to import loader builtins. */
|
|
114
|
+
readonly instrument?: string;
|
|
115
|
+
/** Refuses these built files at every import edge; the inventory identity is unchanged. */
|
|
116
|
+
readonly excluded?: readonly string[];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Names Node's synchronous loading continuation. */
|
|
120
|
+
export declare type ArtifactLoadHandler = Parameters<LoadHookSync>[2];
|
|
121
|
+
|
|
122
|
+
/** Records the identity declared by an admitted package manifest. */
|
|
123
|
+
export declare interface ArtifactPackage {
|
|
124
|
+
readonly root: string;
|
|
125
|
+
readonly name: string;
|
|
126
|
+
readonly version: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Names Node's synchronous resolution continuation. */
|
|
130
|
+
export declare type ArtifactResolveHandler = Parameters<ResolveHookSync>[2];
|
|
131
|
+
|
|
132
|
+
/** Binds native conditions and host-sensitive builtin behavior to the inventory. */
|
|
133
|
+
export declare interface ArtifactRuntime {
|
|
134
|
+
readonly arguments: readonly string[];
|
|
135
|
+
readonly platform: string;
|
|
136
|
+
readonly architecture: string;
|
|
137
|
+
readonly options?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Retains captured bytes for the native loader. */
|
|
141
|
+
export declare interface ArtifactSource extends ArtifactFile {
|
|
142
|
+
readonly source: Uint8Array;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Selects a consumer-owned executable source directory and its exact adapter entry.
|
|
146
|
+
* @remarks Source JSON assets are not admitted; parsed fixtures and rubrics retain separate identities.
|
|
147
|
+
*/
|
|
148
|
+
export declare interface ArtifactSourceOptions {
|
|
149
|
+
readonly root: string;
|
|
150
|
+
readonly entry: string;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Counts the directory entries visited and the file bytes admitted so far in one capture. */
|
|
154
|
+
export declare interface ArtifactTally {
|
|
155
|
+
readonly visits: number;
|
|
156
|
+
readonly bytes: number;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Builds the JSON evidence form of a Ledger result's logical classifier readings.
|
|
161
|
+
* @param result - Value returned by the Ledger
|
|
162
|
+
* @returns Null when the result carries no readings array, else one entry per well-formed reading in asking order, each with its duration or null
|
|
163
|
+
*/
|
|
164
|
+
export declare function buildStudyAgentReadings(result: unknown): JSONValue;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Builds a request revision by hashing its canonical rendering exactly as rendered.
|
|
168
|
+
* @remarks
|
|
169
|
+
* The request is rendered once with key-sorted canonical JSON and hashed as rendered; no
|
|
170
|
+
* newline or JSON round trip is added. Any change to content, order, ids, tools, or options
|
|
171
|
+
* changes the revision.
|
|
172
|
+
* @param request - The exact pre-encoding request
|
|
173
|
+
* @returns The lowercase SHA-256 digest, or undefined when the request cannot be canonically rendered; a rendering failure never throws
|
|
174
|
+
*/
|
|
175
|
+
export declare function buildStudyAgentRevision(request: ProviderRequest): string | undefined;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Declares the pinned serving identities the Ollama transport verifies, keyed by the label their inventory evidence carries.
|
|
179
|
+
* @param provider - Declared serving identities
|
|
180
|
+
* @returns The model pin, plus the judge pin when the provider declares both the judge name and its digest
|
|
181
|
+
*/
|
|
182
|
+
export declare function buildStudyOllamaModels(provider: StudyProvider): StudyOllamaTransportOptions['models'];
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Builds the provider options one role's declared wire policy determines.
|
|
186
|
+
* @remarks
|
|
187
|
+
* The policy's `options` object keeps its identity and key order. A strict policy adds `truncate`
|
|
188
|
+
* and `shift` as `false`; any other policy omits both keys. The `length` allowance is read by the
|
|
189
|
+
* transport and projects nothing.
|
|
190
|
+
* @param policy - The role's declared wire policy
|
|
191
|
+
* @returns The model, think flag, options object, and the strict native fields when declared
|
|
192
|
+
*/
|
|
193
|
+
export declare function buildStudyOllamaOptions(policy: StudyOllamaPolicy): StudyOllamaOptions;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Builds a reading of the raw prompt text an encoded request body carries, as sent.
|
|
197
|
+
* @param body - The encoded request body
|
|
198
|
+
* @returns The prompt's UTF-16 code units and UTF-8 bytes, labeled with its encoding, or undefined when there is no string prompt; these are readings of the actual text, not token allocations
|
|
199
|
+
*/
|
|
200
|
+
export declare function buildStudyOllamaRaw(body: unknown): JSONValue | undefined;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Builds an owned snapshot of one outbound request before anything is awaited.
|
|
204
|
+
* @remarks
|
|
205
|
+
* The URL spelling, accepted settings, headers, and dispatch are copied at the call, each caller
|
|
206
|
+
* member read once; headers are cloned from the copied settings. The settings' `signal` keeps its
|
|
207
|
+
* live identity so caller cancellation still reaches the request.
|
|
208
|
+
* @param input - The requested URL
|
|
209
|
+
* @param init - The native fetch settings
|
|
210
|
+
* @param dispatch - The canonical dispatch the caller measured
|
|
211
|
+
* @returns The owned request facts
|
|
212
|
+
* @throws StudyError - Thrown with code `CONFIG` when the input is a `Request`
|
|
213
|
+
*/
|
|
214
|
+
export declare function buildStudyOllamaSnapshot(input: string | URL | Request, init: RequestInit | undefined, dispatch: StudyAgentDispatch | undefined): StudyOllamaSnapshot;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Builds the JSON evidence form of a timing observation with raw nanoseconds and counts.
|
|
218
|
+
* @param timing - The extracted timing
|
|
219
|
+
* @returns Null when no terminal timing was observed; otherwise every unreported member as null
|
|
220
|
+
*/
|
|
221
|
+
export declare function buildStudyOllamaTiming(timing: OllamaTiming | undefined): JSONValue;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Builds a frozen owned copy of transport configuration that later caller mutation cannot reach.
|
|
225
|
+
* @remarks
|
|
226
|
+
* Every caller member is read once, outer fields before nested data. Every nested data object is
|
|
227
|
+
* copied and frozen; the caller's objects are never frozen. The cancellation signal and timing
|
|
228
|
+
* extractor keep their live identity.
|
|
229
|
+
* @param options - The caller's transport configuration
|
|
230
|
+
* @returns The owned configuration, not yet validated
|
|
231
|
+
*/
|
|
232
|
+
export declare function buildStudyOllamaTransportOptions(options: StudyOllamaTransportOptions): StudyOllamaTransportOptions;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Builds deterministic public semantic inputs and a separately retained private map.
|
|
236
|
+
* @param result - The verified sealed execution
|
|
237
|
+
* @param rubric - The compatible semantic criterion declaration
|
|
238
|
+
* @param digest - The exact imported rubric-byte identity
|
|
239
|
+
* @returns The packet bundle, or undefined for a purely mechanical rubric
|
|
240
|
+
* @throws StudyError - Thrown when a semantic pair has no declared input or terminal record
|
|
241
|
+
* @example
|
|
242
|
+
* ```ts
|
|
243
|
+
* buildStudyPacket(result, rubric, rubricDigest)
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export declare function buildStudyPacket(result: StudySealedResult, rubric: StudyRubric, digest: string): StudyPacketBundle | undefined;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Builds neutral semantic identities for the complete eligible sealed horizon.
|
|
250
|
+
* @param result - The verified sealed execution
|
|
251
|
+
* @param rubric - The compatible independently held rubric
|
|
252
|
+
* @returns Deterministically sorted neutral mappings
|
|
253
|
+
* @example
|
|
254
|
+
* ```ts
|
|
255
|
+
* buildStudyPacketLinks(result, rubric)
|
|
256
|
+
* ```
|
|
257
|
+
*/
|
|
258
|
+
export declare function buildStudyPacketLinks(result: StudySealedResult, rubric: StudyRubric): readonly StudyPacketLink[];
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Renders a citation of one retained trial file or evidence row.
|
|
262
|
+
* @param target - The declared pair whose retained observations the citation must name
|
|
263
|
+
* @param reference - The attempt file, the evidence file, or one zero-based evidence row
|
|
264
|
+
* @returns The retained path, with a one-based row position for an evidence row
|
|
265
|
+
* @throws StudyError - Thrown when the trial was not retained, or the citation names a row that does not exist or a row of the attempt file
|
|
266
|
+
* @example Cite a retained evidence row
|
|
267
|
+
* ```ts
|
|
268
|
+
* import type { StudyGradeTarget } from '@orkestrel/study/server'
|
|
269
|
+
* import { buildStudyReference } from '@orkestrel/study/server'
|
|
270
|
+
*
|
|
271
|
+
* declare const target: StudyGradeTarget
|
|
272
|
+
*
|
|
273
|
+
* buildStudyReference(target, { file: 'evidence', row: 0 }) // 'trials/r1-s1-a1/evidence.jsonl#1'
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
export declare function buildStudyReference(target: StudyGradeTarget, reference: StudyReference): string;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Refuses symbolic links and non-directory ancestors before custody operations.
|
|
280
|
+
* @param directory - The absolute or relative directory
|
|
281
|
+
* @returns The resolved checked directory
|
|
282
|
+
* @throws StudyError - Thrown when any ancestor is linked or is not a directory
|
|
283
|
+
* @example
|
|
284
|
+
* ```ts
|
|
285
|
+
* await checkStudyDirectory(directory)
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
export declare function checkStudyDirectory(directory: string): Promise<string>;
|
|
289
|
+
|
|
290
|
+
/** Collects a directory and each of its ancestors up to the filesystem root, nearest first.
|
|
291
|
+
* @param directory - The absolute directory to start from.
|
|
292
|
+
* @returns The directory followed by every parent directory, ending at the root.
|
|
293
|
+
*/
|
|
294
|
+
export declare function collectStudyAncestors(directory: string): readonly string[];
|
|
295
|
+
|
|
296
|
+
/** Collects the executable entries a profile selects, each canonical path once.
|
|
297
|
+
* @param profile - The resolved execution profile.
|
|
298
|
+
* @returns The agent, subject, and provider entries without repeating a shared entry.
|
|
299
|
+
* @remarks The declared roles stay separate in the profile; only capture and loading deduplicate.
|
|
300
|
+
*/
|
|
301
|
+
export declare function collectStudyEntries(profile: StudyProfile): readonly string[];
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Reads sealed evidence bytes through custody checks without loading executable code.
|
|
305
|
+
* @param result - The independently verified sealed execution
|
|
306
|
+
* @returns Evidence records keyed by scheduled trial identity
|
|
307
|
+
* @throws StudyError - Thrown when evidence drifts, becomes partial, or fails validation
|
|
308
|
+
* @example
|
|
309
|
+
* ```ts
|
|
310
|
+
* await collectStudyEvidence(result)
|
|
311
|
+
* ```
|
|
312
|
+
*/
|
|
313
|
+
export declare function collectStudyEvidence(result: StudySealedResult): Promise<Readonly<Record<string, readonly StudyEvidence[]>>>;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* Groups failed records by cause, role, and layer, each group carrying its source readings.
|
|
317
|
+
* @remarks
|
|
318
|
+
* A group exists for each cause, role, and layer that holds at least one record. Groups follow
|
|
319
|
+
* `STUDY_CAUSES`, then `STUDY_ROLES` with an absent role last, then `STUDY_LAYERS` with an absent
|
|
320
|
+
* layer last. `role` and `layer` are null when absent. `executed` and `unexecuted` partition the
|
|
321
|
+
* group by each record's own execution fact. `readings` lists every record of the group that carries
|
|
322
|
+
* a stop, in source order, with `trial`, `goal` at the goal level only, `id`, `max`, and `consumed`
|
|
323
|
+
* (null when the source reported none). A failure sealed before the `stop` member existed groups with
|
|
324
|
+
* a null layer and no reading; the helper infers no layer from a message.
|
|
325
|
+
* @param sources - The failed records, in source order
|
|
326
|
+
* @returns The JSON groups
|
|
327
|
+
* @example
|
|
328
|
+
* ```ts
|
|
329
|
+
* computeStudyAttributions([{ trial: 'r1-s1-a1', goal: undefined, failure, executed: true }])
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
export declare function computeStudyAttributions(sources: readonly StudyAttributionSource[]): JSONValue;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Computes the native supervisor's exact validated execution fingerprint.
|
|
336
|
+
* @param identity - The reproducible executable identities
|
|
337
|
+
* @param bounds - The validated nested execution limits
|
|
338
|
+
* @param definition - The optional full declaration binding supervisor check to execute
|
|
339
|
+
* @returns The fingerprint that execute must compare before any writes or child work
|
|
340
|
+
* @example
|
|
341
|
+
* ```ts
|
|
342
|
+
* computeStudyCommandFingerprint(identity, bounds)
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
export declare function computeStudyCommandFingerprint(identity: StudyIdentity, bounds: StudyBounds, definition?: StudyDefinition): string;
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Computes public fixture identity from execution policy and exact scenario bytes.
|
|
349
|
+
* @param definition - The complete retained study declaration
|
|
350
|
+
* @param scenarios - The exact public scenario artifact identities
|
|
351
|
+
* @returns The digest shared by compatible capacity and memory executions
|
|
352
|
+
* @example
|
|
353
|
+
* ```ts
|
|
354
|
+
* computeStudyFixtureDigest(definition, scenarios)
|
|
355
|
+
* ```
|
|
356
|
+
*/
|
|
357
|
+
export declare function computeStudyFixtureDigest(definition: StudyDefinition, scenarios: readonly StudyCommandArtifact[]): string;
|
|
358
|
+
|
|
359
|
+
/** Computes the instrument identity binding trusted runtime bytes to the adapter inventory.
|
|
360
|
+
* @param entry - The SHA-256 identity of the trusted runtime entry bytes.
|
|
361
|
+
* @param inventory - The captured adapter inventory digest.
|
|
362
|
+
* @returns The identity that validation, grading, and trial children must share.
|
|
363
|
+
*/
|
|
364
|
+
export declare function computeStudyInstrumentDigest(entry: string, inventory: string): string;
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Computes a bundle identity binding exact public packet and private map bytes.
|
|
368
|
+
* @param packet - The immutable grading packet bundle
|
|
369
|
+
* @returns The exact bundle digest
|
|
370
|
+
* @example
|
|
371
|
+
* ```ts
|
|
372
|
+
* computeStudyPacketDigest(packet)
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
export declare function computeStudyPacketDigest(packet: StudyPacketBundle): string;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Partitions records by their explicit execution fact without inferring any.
|
|
379
|
+
* @param records - The attempts, observations, or attribution sources to partition
|
|
380
|
+
* @returns Counts of executed and unexecuted records, which sum to the record count
|
|
381
|
+
* @example
|
|
382
|
+
* ```ts
|
|
383
|
+
* computeStudyPartition(attempts) // { executed: 2, unexecuted: 1 }
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
386
|
+
export declare function computeStudyPartition(records: ReadonlyArray<StudyAttempt | StudyObservation | StudyAttributionSource>): Readonly<Record<'executed' | 'unexecuted', number>>;
|
|
387
|
+
|
|
388
|
+
/** Binds the canonical fully resolved execution profile carried over IPC.
|
|
389
|
+
* @param profile - The resolved execution settings, with optional absent leaves.
|
|
390
|
+
* @returns The SHA256 digest of the canonical JSON wire representation.
|
|
391
|
+
*/
|
|
392
|
+
export declare function computeStudyProfileDigest(profile: StudyProfile): string;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Computes whole-horizon results with operational costs and repetitions kept distinct.
|
|
396
|
+
* @param result - The verified complete execution
|
|
397
|
+
* @param rubric - The retained compatible rubric
|
|
398
|
+
* @param grading - The independently verified selected grading
|
|
399
|
+
* @returns The JSON report without pooling identities or inventing absent measurements
|
|
400
|
+
* @remarks
|
|
401
|
+
* Operations count affected trial and goal records, not independent failure events, and the
|
|
402
|
+
* trial and goal counts overlap and are never added. Completion is operational: a goal is
|
|
403
|
+
* completed when it holds a non-partial product and no failure, and a trial when it holds no
|
|
404
|
+
* failure and every goal completed. It is neither task success nor a qualification gate.
|
|
405
|
+
* @example
|
|
406
|
+
* ```ts
|
|
407
|
+
* computeStudyReport(result, rubric, grading)
|
|
408
|
+
* ```
|
|
409
|
+
*/
|
|
410
|
+
export declare function computeStudyReport(result: StudySealedResult, rubric: StudyRubric, grading: StudyGrading): JSONValue;
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Computes an execution seal identity from its exact sorted inventory.
|
|
414
|
+
* @param result - The manifest result identity
|
|
415
|
+
* @param files - The sorted inventory
|
|
416
|
+
* @returns The deterministic seal digest
|
|
417
|
+
* @example
|
|
418
|
+
* ```ts
|
|
419
|
+
* computeStudySealId('execution', files)
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
export declare function computeStudySealId(result: string, files: readonly StudyFile[]): string;
|
|
423
|
+
|
|
424
|
+
/** Checks strict lexical containment under a selected directory.
|
|
425
|
+
* @param root - The canonical directory.
|
|
426
|
+
* @param path - The candidate absolute file.
|
|
427
|
+
* @returns True if the file is below the directory; false otherwise.
|
|
428
|
+
*/
|
|
429
|
+
export declare function containsArtifact(root: string, path: string): boolean;
|
|
430
|
+
|
|
431
|
+
/** Creates attributable protocol infrastructure failure.
|
|
432
|
+
* @param message - The refused operation or broken boundary.
|
|
433
|
+
* @returns A domain failure that never awards task credit.
|
|
434
|
+
*/
|
|
435
|
+
export declare function createStudyProcessFailure(message: string): StudyFailure;
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Decodes strict UTF-8 custody bytes and parses their JSON text.
|
|
439
|
+
* @param bytes - The exact retained bytes
|
|
440
|
+
* @returns The parsed value, or undefined when the text is not JSON
|
|
441
|
+
* @throws TypeError - Thrown when the bytes are not valid UTF-8
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* decodeStudyJSON(new TextEncoder().encode('{"id":1}')) // { id: 1 }
|
|
445
|
+
* ```
|
|
446
|
+
*/
|
|
447
|
+
export declare function decodeStudyJSON(bytes: Uint8Array): unknown;
|
|
448
|
+
|
|
449
|
+
/** Releases inherited output handles a bounded time after native exit.
|
|
450
|
+
* @param child - A newly spawned child, subscribed before native exit.
|
|
451
|
+
* @remarks A descendant that outlives an exited root is outside discoverable-tree cleanup; this only stops the parent from waiting on its pipes.
|
|
452
|
+
*/
|
|
453
|
+
export declare function drainStudyChild(child: ChildProcess): void;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Encodes deterministic JSON bytes without synthesizing execution metadata.
|
|
457
|
+
* @param value - The validated record
|
|
458
|
+
* @returns The exact canonical UTF-8 bytes
|
|
459
|
+
* @throws StudyError - Thrown when the record cannot be serialized
|
|
460
|
+
* @example Encode custody bytes
|
|
461
|
+
* ```ts
|
|
462
|
+
* import { encodeStudyJSON } from '@orkestrel/study/server'
|
|
463
|
+
*
|
|
464
|
+
* encodeStudyJSON({ id: 1 })
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
export declare function encodeStudyJSON(value: unknown): Uint8Array;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Grades every declared trial and criterion pair through the consumer's predicate.
|
|
471
|
+
* @param input - The sealed declaration, retained attempts, retained evidence, and independent rubric
|
|
472
|
+
* @param grade - The consumer's domain predicate; it supplies each verdict, method, reason, and citation
|
|
473
|
+
* @returns One judgment for each declared pair, in schedule then rubric order, with one-based evidence references
|
|
474
|
+
* @remarks
|
|
475
|
+
* The traversal validates its input at this boundary, so a direct call retains the checks the
|
|
476
|
+
* host also makes. A trial without a retained attempt still receives a judgment: the predicate
|
|
477
|
+
* sees no attempt and no evidence, and missing evidence stays whatever verdict the consumer
|
|
478
|
+
* reads from it. The traversal never decides success, and it cites nothing the retained
|
|
479
|
+
* evidence cannot back.
|
|
480
|
+
* @throws StudyError - Thrown when the rubric, declaration, attempts, or evidence are invalid or foreign, when a criterion names an undeclared goal, or when a reading is not a valid judgment
|
|
481
|
+
* @example Grade retained evidence with a consumer predicate
|
|
482
|
+
* ```ts
|
|
483
|
+
* import type { StudyAdjudication, StudyGradeFunction } from '@orkestrel/study/server'
|
|
484
|
+
* import { gradeStudyEvidence } from '@orkestrel/study/server'
|
|
485
|
+
*
|
|
486
|
+
* declare const input: StudyAdjudication
|
|
487
|
+
* declare const grade: StudyGradeFunction
|
|
488
|
+
*
|
|
489
|
+
* gradeStudyEvidence(input, grade)
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
export declare function gradeStudyEvidence(input: StudyAdjudication, grade: StudyGradeFunction): readonly StudyJudgment[];
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Computes the lowercase SHA-256 identity of exact bytes or UTF-8 text.
|
|
496
|
+
* @param input - The retained bytes, or text identified by its UTF-8 bytes
|
|
497
|
+
* @returns The lowercase hexadecimal digest
|
|
498
|
+
* @example Identify captured bytes
|
|
499
|
+
* ```ts
|
|
500
|
+
* import { hashStudyBytes } from '@orkestrel/study/server'
|
|
501
|
+
*
|
|
502
|
+
* hashStudyBytes('retained evidence')
|
|
503
|
+
* ```
|
|
504
|
+
*/
|
|
505
|
+
export declare function hashStudyBytes(input: string | Uint8Array): string;
|
|
506
|
+
|
|
507
|
+
/** Narrows a caught value to an artifact refusal.
|
|
508
|
+
* @param value - The caught value.
|
|
509
|
+
* @returns True if the value is an artifact error; false otherwise.
|
|
510
|
+
*/
|
|
511
|
+
export declare function isArtifactError(value: unknown): value is ArtifactError;
|
|
512
|
+
|
|
513
|
+
/** Checks whether a factory returned the complete consumer adapter contract.
|
|
514
|
+
* @param value - The unknown factory result.
|
|
515
|
+
* @returns True if validation, construction, and grading are callable; false otherwise.
|
|
516
|
+
* @example Refuse an incomplete adapter
|
|
517
|
+
* ```ts
|
|
518
|
+
* import { isStudyAdapter } from '@orkestrel/study/server'
|
|
519
|
+
*
|
|
520
|
+
* isStudyAdapter({}) // false
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
export declare function isStudyAdapter(value: unknown): value is StudyAdapterInterface;
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Checks whether a scripted response has JSON calls and workload controls.
|
|
527
|
+
* @remarks
|
|
528
|
+
* The guard accepts exact own data keys: `content` and `calls` are required; `consume`, `abort`,
|
|
529
|
+
* `tokens`, `bytes` and `truncated` are optional. Each call must satisfy the Tool package's call
|
|
530
|
+
* guard and carry JSON arguments. The guard sets no size limit on content, calls or `consume`; a
|
|
531
|
+
* consumer composes its own workload bounds. A throwing accessor returns false.
|
|
532
|
+
* @param value - The candidate response
|
|
533
|
+
* @returns True if every declared response member is valid; false otherwise
|
|
534
|
+
* @example
|
|
535
|
+
* ```ts
|
|
536
|
+
* isStudyAgentResponse({ content: 'done', calls: [] }) // true
|
|
537
|
+
* ```
|
|
538
|
+
*/
|
|
539
|
+
export declare function isStudyAgentResponse(value: unknown): value is StudyAgentResponse;
|
|
540
|
+
|
|
541
|
+
/** Checks a request's declared role and finite cost ceilings.
|
|
542
|
+
* @param value - Decoded charge.
|
|
543
|
+
* @returns True if all charge leaves are valid; false otherwise.
|
|
544
|
+
*/
|
|
545
|
+
export declare function isStudyCharge(value: unknown): value is StudyCharge;
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* Checks whether an attempt terminally accounts for the exact scheduled goal horizon.
|
|
549
|
+
* @param value - The candidate attempt
|
|
550
|
+
* @param manifest - The authoritative declaration
|
|
551
|
+
* @returns True if the terminal record is compatible and its execution facts are consistent; false otherwise
|
|
552
|
+
* @remarks
|
|
553
|
+
* Executed goals form a prefix of the horizon and an executed goal with a failure ends it.
|
|
554
|
+
* An unexecuted attempt holds only unexecuted goals, and an attempt without a failure holds only
|
|
555
|
+
* executed goals that did not fail.
|
|
556
|
+
* @example
|
|
557
|
+
* ```ts
|
|
558
|
+
* isStudyCustodyAttempt({}, manifest) // false
|
|
559
|
+
* ```
|
|
560
|
+
*/
|
|
561
|
+
export declare function isStudyCustodyAttempt(value: unknown, manifest: StudyManifest): value is StudyAttempt;
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Checks whether evidence is exact JSON with a declared event and goal name.
|
|
565
|
+
* @param value - The candidate evidence
|
|
566
|
+
* @returns True if evidence is valid; false otherwise
|
|
567
|
+
* @example
|
|
568
|
+
* ```ts
|
|
569
|
+
* isStudyCustodyEvidence({ event: 'saved', goal: 'write', value: true }) // true
|
|
570
|
+
* ```
|
|
571
|
+
*/
|
|
572
|
+
export declare function isStudyCustodyEvidence(value: unknown): value is StudyEvidence;
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Checks whether a failure carries exact attributable operational fields.
|
|
576
|
+
* @remarks
|
|
577
|
+
* `role` and `stop` are optional keys. A `stop` is valid only on a `capacity` or `deadline` failure,
|
|
578
|
+
* and it must satisfy `isStudyStop`; a failure sealed before the `stop` member existed has no key.
|
|
579
|
+
* @param value - The candidate failure
|
|
580
|
+
* @returns True if the failure is valid; false otherwise
|
|
581
|
+
* @example
|
|
582
|
+
* ```ts
|
|
583
|
+
* isStudyCustodyFailure({}) // false
|
|
584
|
+
* ```
|
|
585
|
+
*/
|
|
586
|
+
export declare function isStudyCustodyFailure(value: unknown): value is StudyFailure;
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Checks whether an execution file inventory entry is path-safe and bounded.
|
|
590
|
+
* @param value - The candidate entry
|
|
591
|
+
* @returns True if the entry is valid; false otherwise
|
|
592
|
+
* @example
|
|
593
|
+
* ```ts
|
|
594
|
+
* isStudyCustodyFile({}) // false
|
|
595
|
+
* ```
|
|
596
|
+
*/
|
|
597
|
+
export declare function isStudyCustodyFile(value: unknown): value is StudyFile;
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Checks whether a manifest exactly binds its declared population and identities.
|
|
601
|
+
* @param value - The candidate manifest
|
|
602
|
+
* @returns True if the manifest is valid; false otherwise
|
|
603
|
+
* @example
|
|
604
|
+
* ```ts
|
|
605
|
+
* isStudyCustodyManifest({}) // false
|
|
606
|
+
* ```
|
|
607
|
+
*/
|
|
608
|
+
export declare function isStudyCustodyManifest(value: unknown): value is StudyManifest;
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Checks whether a trial name is portable on all supported hosts.
|
|
612
|
+
* @param value - The candidate name
|
|
613
|
+
* @returns True if the name is portable; false otherwise
|
|
614
|
+
* @example
|
|
615
|
+
* ```ts
|
|
616
|
+
* isStudyCustodyName('r1-s1-a1') // true
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
export declare function isStudyCustodyName(value: unknown): value is string;
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Checks whether an observation preserves output or an explicit unexecuted failure.
|
|
623
|
+
* @param value - The candidate observation
|
|
624
|
+
* @returns True if the observation is valid, with an executed fact or an unexecuted fact that holds a failure and no product, usage or duration; false otherwise
|
|
625
|
+
* @example
|
|
626
|
+
* ```ts
|
|
627
|
+
* isStudyCustodyObservation({}) // false
|
|
628
|
+
* ```
|
|
629
|
+
*/
|
|
630
|
+
export declare function isStudyCustodyObservation(value: unknown): value is StudyObservation;
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Checks whether a seal has an exact unique execution inventory.
|
|
634
|
+
* @param value - The candidate seal
|
|
635
|
+
* @returns True if the seal is structurally valid; false otherwise
|
|
636
|
+
* @example
|
|
637
|
+
* ```ts
|
|
638
|
+
* isStudyCustodySeal({}) // false
|
|
639
|
+
* ```
|
|
640
|
+
*/
|
|
641
|
+
export declare function isStudyCustodySeal(value: unknown): value is StudySeal;
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Checks whether a scheduled trial has exact valid identity fields.
|
|
645
|
+
* @param value - The candidate trial
|
|
646
|
+
* @returns True if its identity is valid; false otherwise
|
|
647
|
+
* @example
|
|
648
|
+
* ```ts
|
|
649
|
+
* isStudyCustodyTrial({}) // false
|
|
650
|
+
* ```
|
|
651
|
+
*/
|
|
652
|
+
export declare function isStudyCustodyTrial(value: unknown): value is StudyTrial;
|
|
653
|
+
|
|
654
|
+
/** Checks append-only public evidence.
|
|
655
|
+
* @param value - Decoded evidence.
|
|
656
|
+
* @returns True if event, goal and payload are valid; false otherwise.
|
|
657
|
+
*/
|
|
658
|
+
export declare function isStudyEvidence(value: unknown): value is StudyEvidence;
|
|
659
|
+
|
|
660
|
+
/** Checks the complete transport envelope before domain handling.
|
|
661
|
+
* @param value - Native IPC decoded value.
|
|
662
|
+
* @returns True if the envelope is bounded in shape and JSON-compatible; false otherwise.
|
|
663
|
+
*/
|
|
664
|
+
export declare function isStudyFrame(value: unknown): value is StudyFrame;
|
|
665
|
+
|
|
666
|
+
/** Checks the exact digest fields carried by the execution declaration.
|
|
667
|
+
* @param value - Decoded identity.
|
|
668
|
+
* @returns True if all required identities are digests; false otherwise.
|
|
669
|
+
*/
|
|
670
|
+
export declare function isStudyIdentity(value: unknown): value is StudyIdentity;
|
|
671
|
+
|
|
672
|
+
/** Checks operational failure attribution arriving over IPC.
|
|
673
|
+
* @param value - Decoded failure value.
|
|
674
|
+
* @returns True if the failure carries a known cause, an optional role, and an optional stop that satisfies `isStudyStop` on a `capacity` or `deadline` cause; false otherwise.
|
|
675
|
+
*/
|
|
676
|
+
export declare function isStudyProcessFailure(value: unknown): value is StudyFailure;
|
|
677
|
+
|
|
678
|
+
/** Checks a fresh trial's declared identifiers.
|
|
679
|
+
* @param value - Decoded trial.
|
|
680
|
+
* @returns True if every identifier and repetition is valid; false otherwise.
|
|
681
|
+
*/
|
|
682
|
+
export declare function isStudyTrial(value: unknown): value is StudyTrial;
|
|
683
|
+
|
|
684
|
+
/** Iterates the remaining entries of an open directory handle lazily, in read order.
|
|
685
|
+
* @param handle - The open synchronous directory handle; the caller owns it and closes it.
|
|
686
|
+
* @returns Each remaining entry until the handle reports the end. An entry is read only when the consumer asks for it, so a consumer that stops early leaves the rest unread.
|
|
687
|
+
*/
|
|
688
|
+
export declare function iterateArtifactEntries(handle: Dir): Generator<Dirent, void>;
|
|
689
|
+
|
|
690
|
+
/** Parses public command tokens with operation-specific grammar diagnostics.
|
|
691
|
+
* @param arguments_ - Exact command tokens, after the CLI help boundary.
|
|
692
|
+
* @returns The independent operation request.
|
|
693
|
+
* @throws StudyError when a token, required flag, or portable path is invalid.
|
|
694
|
+
* @example Parse a study command
|
|
695
|
+
* ```ts
|
|
696
|
+
* import { parseStudyArguments } from '@orkestrel/study/server'
|
|
697
|
+
*
|
|
698
|
+
* parseStudyArguments(['check', 'files', '--profile', 'local'])
|
|
699
|
+
* ```
|
|
700
|
+
*/
|
|
701
|
+
export declare function parseStudyArguments(arguments_: readonly string[]): StudyCommandRequest;
|
|
702
|
+
|
|
703
|
+
/** Reads a bounded regular file only through its canonical absolute path.
|
|
704
|
+
* @param path - The absolute path to inspect.
|
|
705
|
+
* @param maximum - The remaining capture budget; Default: 16 MiB.
|
|
706
|
+
* @returns Captured bytes with their identity.
|
|
707
|
+
* @throws Thrown when the path is linked, noncanonical, oversized, or changes while read.
|
|
708
|
+
*/
|
|
709
|
+
export declare function readArtifact(path: string, maximum?: number): ArtifactSource;
|
|
710
|
+
|
|
711
|
+
/** Fills a buffer from an open descriptor, one positioned read at a time.
|
|
712
|
+
* @param descriptor - The open file descriptor to read.
|
|
713
|
+
* @param target - The buffer to fill.
|
|
714
|
+
* @param offset - The position in the file and the buffer to continue from; Default: 0.
|
|
715
|
+
* @returns The bytes read, as the whole buffer when the file filled it or as its leading part when the file ended first.
|
|
716
|
+
*/
|
|
717
|
+
export declare function readArtifactBytes(descriptor: number, target: Buffer, offset?: number): Buffer;
|
|
718
|
+
|
|
719
|
+
/** Reads a complete adapter from an admitted module namespace.
|
|
720
|
+
* @param namespace - The captured consumer module.
|
|
721
|
+
* @returns The validated adapter instance.
|
|
722
|
+
*/
|
|
723
|
+
export declare function readStudyAdapter(namespace: unknown): StudyAdapterInterface;
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Projects foreign provider messages onto the exact fields the workload reads.
|
|
727
|
+
* @param value - The foreign provider message collection
|
|
728
|
+
* @returns Owned JSON message readings in original order
|
|
729
|
+
* @throws StudyError - Thrown when a dereferenced foreign member is malformed
|
|
730
|
+
* @example
|
|
731
|
+
* ```ts
|
|
732
|
+
* readStudyAgentMessages([{ id: 'm1', role: 'user', content: 'Hi' }]) // [{ role: 'user', content: 'Hi' }]
|
|
733
|
+
* ```
|
|
734
|
+
*/
|
|
735
|
+
export declare function readStudyAgentMessages(value: unknown): readonly JSONValue[];
|
|
736
|
+
|
|
737
|
+
/**
|
|
738
|
+
* Drains a scripted provider stream into its assembled result.
|
|
739
|
+
* @param stream - The provider stream to consume to its end
|
|
740
|
+
* @returns The result the stream returns after its last delta
|
|
741
|
+
*/
|
|
742
|
+
export declare function readStudyAgentResult(stream: AsyncGenerator<ProviderDelta, ProviderResult>): Promise<ProviderResult>;
|
|
743
|
+
|
|
744
|
+
/**
|
|
745
|
+
* Reads bounded regular-file bytes without following a symbolic link.
|
|
746
|
+
* @param path - The custody file path
|
|
747
|
+
* @param limit - The byte allowance
|
|
748
|
+
* @returns Exact retained bytes
|
|
749
|
+
* @throws StudyError - Thrown when the file is linked, oversized, changed, or not regular
|
|
750
|
+
* @example
|
|
751
|
+
* ```ts
|
|
752
|
+
* await readStudyBytes(path, 1024)
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
755
|
+
export declare function readStudyBytes(path: string, limit: number): Promise<Uint8Array>;
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Reads from an open file handle into a buffer until the buffer is full or the file ends.
|
|
759
|
+
* @param handle - The open file handle to read
|
|
760
|
+
* @param target - The buffer to fill from the start of the file
|
|
761
|
+
* @param offset - The position in the file and the buffer to continue from; Default: 0
|
|
762
|
+
* @returns The bytes read, as the whole buffer when the file filled it or as its leading part when the file ended first
|
|
763
|
+
*/
|
|
764
|
+
export declare function readStudyHandle(handle: FileHandle, target: Buffer, offset?: number): Promise<Buffer>;
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Reads the pinned serving digest of an admitted request's model.
|
|
768
|
+
* @param models - The pinned served identities
|
|
769
|
+
* @param request - The admitted dispatch
|
|
770
|
+
* @returns The pinned digest, or undefined for an inventory request or an unpinned model
|
|
771
|
+
*/
|
|
772
|
+
export declare function readStudyOllamaDigest(models: StudyOllamaTransportOptions['models'], request: StudyOllamaRequest): string | undefined;
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Reads a native Ollama error member as the attributable failure it names, without usage.
|
|
776
|
+
* @remarks
|
|
777
|
+
* No token usage is read from the member.
|
|
778
|
+
* The failure is `CAPACITY` when the member, a string or an object, names the exact structured
|
|
779
|
+
* type `exceed_context_size_error` with a finite positive integer `n_prompt_tokens` above `n_ctx`,
|
|
780
|
+
* a `code` of 400 if supplied, and a status of 400 if supplied. Every other member, a malformed
|
|
781
|
+
* one included, is `FAULT` with its readable reason.
|
|
782
|
+
* @param value - The parsed HTTP error body or wire row
|
|
783
|
+
* @param role - The responsibility whose request was dispatched; the failure retains it
|
|
784
|
+
* @param status - The HTTP status of the carrying response; undefined for a row of a stream that answered 200
|
|
785
|
+
* @returns Undefined when the value carries no `error` member; otherwise the attributable failure
|
|
786
|
+
*/
|
|
787
|
+
export declare function readStudyOllamaFailure(value: unknown, role: StudyRole, status?: number): StudyError | undefined;
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Reads exact outbound Ollama facts and refuses a request outside its declared policy.
|
|
791
|
+
* @remarks
|
|
792
|
+
* The refusal happens before admission, so a refused request is never accounted.
|
|
793
|
+
* @param options - The admitted origin, pinned inventory, and declared role policies
|
|
794
|
+
* @param role - The responsible request role
|
|
795
|
+
* @param input - The requested URL
|
|
796
|
+
* @param init - The native fetch settings
|
|
797
|
+
* @returns The validated dispatch facts
|
|
798
|
+
* @throws StudyError - Thrown with code `CONFIG` when the endpoint, model, options, flags, or strict fields differ from the declaration, or the role declares no policy
|
|
799
|
+
*/
|
|
800
|
+
export declare function readStudyOllamaRequest(options: Pick<StudyOllamaTransportOptions, 'url' | 'models' | 'roles'>, role: StudyRole, input: string | URL | Request, init?: RequestInit): StudyOllamaRequest;
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* Reads the declared model context ceiling without claiming daemon allocation.
|
|
804
|
+
* @param value - The parsed Ollama show response
|
|
805
|
+
* @param context - The requested total context
|
|
806
|
+
* @returns The unambiguous model context ceiling
|
|
807
|
+
* @throws StudyError - Thrown with code `FAULT` when context metadata is missing, or `CAPACITY` when it is ambiguous or below the requested context
|
|
808
|
+
*/
|
|
809
|
+
export declare function readStudyOllamaSupport(value: unknown, context: number): number;
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Reads one Ollama response row without inventing absent usage.
|
|
813
|
+
* @param value - The parsed wire row
|
|
814
|
+
* @param request - The admitted dispatch
|
|
815
|
+
* @returns The terminal facts, or undefined for a nonterminal row
|
|
816
|
+
* @throws StudyError - Thrown with the recognized provider failure when the row carries an `error` member, before any other row check; `FAULT` for a malformed row, model, message, finish reason, or usage
|
|
817
|
+
*/
|
|
818
|
+
export declare function readStudyOllamaTerminal(value: unknown, request: StudyOllamaRequest): StudyOllamaTerminal | undefined;
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Reads daemon timing from a terminal row without letting an observation fail the request.
|
|
822
|
+
* @param extract - The admitted extractor
|
|
823
|
+
* @param record - The validated terminal row
|
|
824
|
+
* @returns The raw timing, or undefined when absent or the extractor throws
|
|
825
|
+
*/
|
|
826
|
+
export declare function readStudyOllamaTiming(extract: StudyOllamaTransportOptions['timing'], record: Readonly<Record<string, unknown>>): OllamaTiming | undefined;
|
|
827
|
+
|
|
828
|
+
/**
|
|
829
|
+
* Inspects custody bytes offline and verifies complete execution before grading.
|
|
830
|
+
* @param directory - The result directory
|
|
831
|
+
* @returns A sealed result or explicitly interrupted safe metadata
|
|
832
|
+
* @throws StudyError - Thrown when existing custody bytes are invalid or tampered
|
|
833
|
+
* @example
|
|
834
|
+
* ```ts
|
|
835
|
+
* await readStudyResult(directory)
|
|
836
|
+
* ```
|
|
837
|
+
*/
|
|
838
|
+
export declare function readStudyResult(directory: string): Promise<StudyResultReading>;
|
|
839
|
+
|
|
840
|
+
/** Enforces captured inventory membership at every synchronous native import edge. */
|
|
841
|
+
export declare class Resolution {
|
|
842
|
+
#private;
|
|
843
|
+
/** Retains the trusted captured inventory and its private namespace.
|
|
844
|
+
* @param input - Captured built bytes and separate source selection.
|
|
845
|
+
*/
|
|
846
|
+
constructor(input: ArtifactHookInput);
|
|
847
|
+
/** Resolves native edges with source-local JavaScript-to-TypeScript substitution.
|
|
848
|
+
* @param specifier - The requested native specifier.
|
|
849
|
+
* @param context - Node's resolution context.
|
|
850
|
+
* @param next - The remaining native resolution chain.
|
|
851
|
+
* @returns An admitted URL in the captured namespace.
|
|
852
|
+
*/
|
|
853
|
+
resolve(specifier: string, context: ResolveHookContext, next: ArtifactResolveHandler): ResolveFnOutput;
|
|
854
|
+
/** Returns captured bytes after verifying their live disk identity.
|
|
855
|
+
* @param href - Node's resolved URL.
|
|
856
|
+
* @param context - Node's load context.
|
|
857
|
+
* @param next - The remaining native load chain.
|
|
858
|
+
* @returns Captured ESM, JSON, or native strip-only TypeScript output.
|
|
859
|
+
*/
|
|
860
|
+
load(href: string, context: LoadHookContext, next: ArtifactLoadHandler): LoadFnOutput;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Resolves the content a scripted response serves, from its declaration or from a prior tool message.
|
|
865
|
+
* @param request - The projected actual request messages
|
|
866
|
+
* @param response - The declared response being served
|
|
867
|
+
* @returns The declared content, or the content of the actual tool message the response consumes
|
|
868
|
+
* @throws StudyError - Thrown when a consuming response has no actual referenced tool result
|
|
869
|
+
*/
|
|
870
|
+
export declare function resolveStudyAgentContent(request: readonly JSONValue[], response: StudyAgentResponse): string;
|
|
871
|
+
|
|
872
|
+
/** Resolves the actual host package from its trusted executable entry.
|
|
873
|
+
* @param entry - The runtime's own executable, never a consumer-supplied module.
|
|
874
|
+
* @returns The canonical study package root.
|
|
875
|
+
*/
|
|
876
|
+
export declare function resolveStudyInstrument(entry: string): string;
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Resolves a portable relative artifact path strictly inside its selected directory.
|
|
880
|
+
* @param directory - The selected custody or study directory
|
|
881
|
+
* @param path - The slash-separated relative artifact path
|
|
882
|
+
* @returns The contained absolute host path
|
|
883
|
+
* @throws StudyError - Thrown when a path is malformed, reserved, absolute, or escaping
|
|
884
|
+
* @example
|
|
885
|
+
* ```ts
|
|
886
|
+
* resolveStudyPath(directory, 'profiles/local.json')
|
|
887
|
+
* ```
|
|
888
|
+
*/
|
|
889
|
+
export declare function resolveStudyPath(directory: string, path: string): string;
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Resolves the execution profile's caller-selected built artifact paths.
|
|
893
|
+
* @param root - The repository root
|
|
894
|
+
* @param profile - The validated source profile
|
|
895
|
+
* @returns The reproducible resolved execution profile
|
|
896
|
+
* @example
|
|
897
|
+
* ```ts
|
|
898
|
+
* resolveStudyProfile(root, profile)
|
|
899
|
+
* ```
|
|
900
|
+
*/
|
|
901
|
+
export declare function resolveStudyProfile(root: string, profile: StudyProfile): StudyProfile;
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Scans regular execution files while refusing unknown directories and linked paths.
|
|
905
|
+
* @param directory - The execution directory
|
|
906
|
+
* @param manifest - The authoritative population
|
|
907
|
+
* @returns Sorted exact inventory entries
|
|
908
|
+
* @throws StudyError - Thrown when inventory escapes its declared tree
|
|
909
|
+
* @example
|
|
910
|
+
* ```ts
|
|
911
|
+
* await scanStudyExecution(directory, manifest)
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
914
|
+
export declare function scanStudyExecution(directory: string, manifest: StudyManifest): Promise<readonly StudyFile[]>;
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Scans one execution directory and the subdirectories it admits, reading each admitted file under the series bytes that remain.
|
|
918
|
+
* @param directory - The execution directory
|
|
919
|
+
* @param prefix - The slash-separated path of the scanned directory; the empty string names the execution root
|
|
920
|
+
* @param known - The scheduled trial identities
|
|
921
|
+
* @param allowance - The series bytes that remain before this directory
|
|
922
|
+
* @returns The admitted files in read order: this directory's files, then each admitted subdirectory's, last listed first
|
|
923
|
+
* @throws StudyError - Thrown when the tree holds a link, an unknown directory or file, or a file beyond the remaining allowance
|
|
924
|
+
*/
|
|
925
|
+
export declare function scanStudyTree(directory: string, prefix: string, known: ReadonlySet<string>, allowance: number): Promise<readonly StudyFile[]>;
|
|
926
|
+
|
|
927
|
+
/** Caps declared execution duration at the native supervisor's host ceiling. */
|
|
928
|
+
export declare const STUDY_COMMAND_DURATION = 86400000;
|
|
929
|
+
|
|
930
|
+
/** Names the trusted command's independent offline predicate. */
|
|
931
|
+
export declare const STUDY_COMMAND_GRADER = "consumer-adapter";
|
|
932
|
+
|
|
933
|
+
/** Defines the complete public CLI reference shared by help and grammar diagnostics. */
|
|
934
|
+
export declare const STUDY_COMMAND_HELP = "study check <study> [--profile <name>]\nstudy execute <study> [--profile <name>] [--out <path>] [--expected <sha256>]\nstudy grade <result> --rubric <path>\nstudy label <result> --grading <sha256> --labels <path>\nstudy report <result> --grading <sha256>\nstudy --help\n\nProfiles default to local. Flags require values and may appear only once.\nResults default to tmp/studies/<result>; scratch also uses tmp/studies.\nA result is its id under tmp/studies, a root-relative path, or an absolute path.\nRelative paths, including --out, must stay inside the consumer working directory.\nOutput directories must be new; existing results are never overwritten.\n--expected pins the fingerprint returned by check. --grading selects an exact grading.\n--rubric selects independent criteria. --labels imports caller-supplied semantic labels.\nSuccess writes one JSON document; next contains suggested argv, never executed automatically.\ncheck, grade, label and report have a fixed allowance of 60 seconds.\nexecute checks first, then uses the declared series duration plus 15 seconds for cleanup.\nExit codes: 0 success, 64 invalid input, 124 deadline, 130 interruption, 1 operational failure.\n";
|
|
935
|
+
|
|
936
|
+
/** Names the command route beneath the native supervisor. */
|
|
937
|
+
export declare const STUDY_COMMAND_OPERATION = "study-command";
|
|
938
|
+
|
|
939
|
+
/** Limits untrusted metadata before JSON parsing or file allocation. */
|
|
940
|
+
export declare const STUDY_CUSTODY_BYTES: number;
|
|
941
|
+
|
|
942
|
+
/** Bounds how long inherited output handles stay open after native exit, in milliseconds. */
|
|
943
|
+
export declare const STUDY_DRAIN_DURATION = 1000;
|
|
944
|
+
|
|
945
|
+
/** Limits each serialized IPC envelope, including its JSON framing. */
|
|
946
|
+
export declare const STUDY_FRAME_BYTES: number;
|
|
947
|
+
|
|
948
|
+
/** Bounds combined supervised command output to 16 MiB before terminating the tree. */
|
|
949
|
+
export declare const STUDY_LAUNCH_BYTES: number;
|
|
950
|
+
|
|
951
|
+
/** Extends supervised execution beyond its declared series duration for cleanup. */
|
|
952
|
+
export declare const STUDY_LAUNCH_CLEANUP = 15000;
|
|
953
|
+
|
|
954
|
+
/** Bounds each supervised operation other than execution to 60 seconds. */
|
|
955
|
+
export declare const STUDY_LAUNCH_DURATION = 60000;
|
|
956
|
+
|
|
957
|
+
/** Limits combined worker stdout and stderr before termination. */
|
|
958
|
+
export declare const STUDY_LOG_BYTES: number;
|
|
959
|
+
|
|
960
|
+
/** Discloses the limits of neutral identifiers when public text remains visible. */
|
|
961
|
+
export declare const STUDY_PACKET_DISCLOSURE = "Identifiers omit treatment and model names. Input and product text may still reveal design details.";
|
|
962
|
+
|
|
963
|
+
/** Limits outstanding bidirectional protocol work per process. */
|
|
964
|
+
export declare const STUDY_PENDING_LIMIT = 64;
|
|
965
|
+
|
|
966
|
+
/** Attributes an expired process handshake or cleanup deadline. */
|
|
967
|
+
export declare const STUDY_PROCESS_LABEL = "Process lifecycle";
|
|
968
|
+
|
|
969
|
+
/** Rejects names that Windows reserves even on other hosts. */
|
|
970
|
+
export declare const STUDY_RESERVED_NAME: RegExp;
|
|
971
|
+
|
|
972
|
+
/** Caps pure domain work independently of its event loop. */
|
|
973
|
+
export declare const STUDY_TASK_DURATION = 60000;
|
|
974
|
+
|
|
975
|
+
/** Names the private bounded validation and grading route. */
|
|
976
|
+
export declare const STUDY_TASK_OPERATION = "study-adapter";
|
|
977
|
+
|
|
978
|
+
/** Names the worker operation routed by the built application entry. */
|
|
979
|
+
export declare const STUDY_WORKER_OPERATION = "study-worker";
|
|
980
|
+
|
|
981
|
+
/** Defines the consumer's domain checks, driver construction, and retained-evidence grading.
|
|
982
|
+
* @remarks
|
|
983
|
+
* An authored module exports a createStudyAdapter factory returning this interface.
|
|
984
|
+
* The host invokes adapter code in a bounded child. It passes criteria to validation
|
|
985
|
+
* and grading only; a trial receives the admitted modules and its public input.
|
|
986
|
+
* Adapter code is trusted instrumentation, not a security sandbox.
|
|
987
|
+
*/
|
|
988
|
+
export declare interface StudyAdapterInterface {
|
|
989
|
+
/** Checks domain declarations before loading a selected agent, subject or provider.
|
|
990
|
+
* @param input - The generic declarations already parsed by the host.
|
|
991
|
+
*/
|
|
992
|
+
validate(input: StudyValidation): void;
|
|
993
|
+
/** Constructs the consumer's driver over admitted module namespaces.
|
|
994
|
+
* @param options - Modules, runtime profile, and owned scratch parent.
|
|
995
|
+
* @returns The actual driver used for this isolated trial.
|
|
996
|
+
*/
|
|
997
|
+
driver(options: StudyDriverOptions): StudyDriverInterface;
|
|
998
|
+
/** Judges retained evidence without changing the executed trajectory.
|
|
999
|
+
* @param input - The sealed observations and independently selected rubric.
|
|
1000
|
+
* @returns Criterion readings; unavailable evidence remains unknown.
|
|
1001
|
+
*/
|
|
1002
|
+
grade(input: StudyAdjudication): readonly StudyJudgment[];
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/** Holds retained observations and independent criteria for a grading operation. */
|
|
1006
|
+
export declare interface StudyAdjudication {
|
|
1007
|
+
readonly manifest: StudyManifest;
|
|
1008
|
+
readonly rubric: StudyRubric;
|
|
1009
|
+
readonly attempts: readonly StudyAttempt[];
|
|
1010
|
+
readonly evidence: Readonly<Record<string, readonly StudyEvidence[]>>;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
/** Admits requests against enclosing limits before an adapter dispatches them. */
|
|
1014
|
+
declare interface StudyAdmissionInterface {
|
|
1015
|
+
readonly signal: AbortSignal;
|
|
1016
|
+
readonly usage: readonly StudyUsage[];
|
|
1017
|
+
/** Resolves admission before dispatch; local meters may return the ticket synchronously. */
|
|
1018
|
+
admit(charge: StudyCharge): StudyTicket | Promise<StudyTicket>;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
/** Holds the trial-local canonical dispatch identity a wire request joins to. */
|
|
1022
|
+
declare interface StudyAgentDispatch {
|
|
1023
|
+
readonly id: number;
|
|
1024
|
+
/** Holds the SHA-256 revision of the canonical request, or undefined when it could not be rendered. */
|
|
1025
|
+
readonly revision: string | undefined;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/** Joins each message of a measured request to its origin, one JSON entry per message in order. */
|
|
1029
|
+
export declare type StudyAgentOriginHandler = (messages: readonly Message[]) => JSONValue;
|
|
1030
|
+
|
|
1031
|
+
/** Holds one goal's scripted replies and the resources the provider charges and cancels through. */
|
|
1032
|
+
export declare interface StudyAgentPlan {
|
|
1033
|
+
readonly responses: readonly StudyAgentResponse[];
|
|
1034
|
+
readonly goal: string;
|
|
1035
|
+
readonly context: StudyContext;
|
|
1036
|
+
readonly workload: AbortController;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/** Holds one dispatched request's explicit size reading. */
|
|
1040
|
+
declare interface StudyAgentReading {
|
|
1041
|
+
/** Holds the runtime's estimate of the complete pre-encoding request. */
|
|
1042
|
+
readonly estimate: number;
|
|
1043
|
+
/** Holds the gauge projection of that estimate; undefined when no gauge applies. */
|
|
1044
|
+
readonly projected: number | undefined;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
/**
|
|
1048
|
+
* Declares one scripted reply.
|
|
1049
|
+
* @remarks
|
|
1050
|
+
* `content` and `calls` are the reply the provider returns. `consume` names the prior tool result
|
|
1051
|
+
* the reply consumes; undefined consumes none. `abort`: if `true`, the reply aborts the goal's
|
|
1052
|
+
* workload; if `false` or undefined, it does not. `tokens` and `bytes` override the admitted
|
|
1053
|
+
* token count and byte charge of the reply; undefined keeps the defaults. `truncated`: if `true`,
|
|
1054
|
+
* the reply reports that the model ended it at its own token limit, which the Agent reads as a
|
|
1055
|
+
* `model` stop; if `false` or undefined, it does not.
|
|
1056
|
+
*/
|
|
1057
|
+
export declare interface StudyAgentResponse {
|
|
1058
|
+
readonly content: string;
|
|
1059
|
+
readonly calls: NonNullable<ProviderResult['tools']>;
|
|
1060
|
+
readonly consume: string | undefined;
|
|
1061
|
+
readonly abort: boolean | undefined;
|
|
1062
|
+
readonly tokens: number | undefined;
|
|
1063
|
+
readonly bytes: number | undefined;
|
|
1064
|
+
readonly truncated: boolean | undefined;
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
/** Names the model responsibilities whose requests the trace and summary measure. */
|
|
1068
|
+
export declare type StudyAgentRole = Extract<StudyRole, 'agent' | 'summary'>;
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* Holds the admitted Agent namespace capabilities the shared instrumentation invokes.
|
|
1072
|
+
* @remarks
|
|
1073
|
+
* Each member has the exact signature of the export of the same name in the selected Agent
|
|
1074
|
+
* runtime. The consumer supplies the admitted namespace; the instrumentation never imports a
|
|
1075
|
+
* runtime value from an installed Agent copy. No Ledger capability is required.
|
|
1076
|
+
*/
|
|
1077
|
+
declare interface StudyAgentRuntime {
|
|
1078
|
+
readonly estimateRequest: typeof estimateRequest;
|
|
1079
|
+
readonly measureRequest: typeof measureRequest;
|
|
1080
|
+
readonly isAgentError: typeof isAgentError;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
/** Serves declared inert responses through the actual Agent provider boundary. */
|
|
1084
|
+
export declare class StudyAgentScript implements ProviderInterface {
|
|
1085
|
+
#private;
|
|
1086
|
+
readonly id: `${string}-${string}-${string}-${string}-${string}`;
|
|
1087
|
+
readonly name = "scripted-study";
|
|
1088
|
+
/**
|
|
1089
|
+
* Binds the encoded byte bound every served request and response must fit.
|
|
1090
|
+
* @param options - The explicit encoded bound; it is also each response's default admitted bytes
|
|
1091
|
+
* @throws StudyError - Thrown when the bound is not a nonnegative safe integer
|
|
1092
|
+
*/
|
|
1093
|
+
constructor(options: StudyAgentScriptOptions);
|
|
1094
|
+
/**
|
|
1095
|
+
* Prepares one goal's declared response sequence and metered operational boundary until `clear` ends the goal.
|
|
1096
|
+
* @param plan - The workload's responses and its operational context
|
|
1097
|
+
* @returns Nothing when the provider is ready
|
|
1098
|
+
* @throws StudyError - Thrown with code `CONFIG` when a response is still running, a goal is already prepared, or a declared response is invalid; a prepared goal stays prepared
|
|
1099
|
+
*/
|
|
1100
|
+
prepare(plan: StudyAgentPlan): void;
|
|
1101
|
+
/**
|
|
1102
|
+
* Ends the prepared goal so another goal can be prepared; a stream already running keeps serving its own goal.
|
|
1103
|
+
* @returns Nothing; a provider with no prepared goal stays unprepared
|
|
1104
|
+
*/
|
|
1105
|
+
clear(): void;
|
|
1106
|
+
/**
|
|
1107
|
+
* Consumes the same streaming response into its assembled provider result.
|
|
1108
|
+
* @param messages - The actual Agent conversation
|
|
1109
|
+
* @param signal - The enclosing Agent run signal
|
|
1110
|
+
* @returns The assembled declared response
|
|
1111
|
+
*/
|
|
1112
|
+
generate(messages: readonly Message[], signal: AbortSignal): Promise<ProviderResult>;
|
|
1113
|
+
/**
|
|
1114
|
+
* Streams a declared response after authoritative admission and retains actual request bytes.
|
|
1115
|
+
* @param messages - The actual Agent conversation
|
|
1116
|
+
* @param signal - The enclosing Agent run signal
|
|
1117
|
+
* @returns The declared response, optionally consuming an actual prior tool message
|
|
1118
|
+
* @remarks
|
|
1119
|
+
* A stream abandoned after admission accounts for an Agent budget cut without latching a failure.
|
|
1120
|
+
* Other abandoned streams fail the admitted request with the run signal's reason, or a `FAULT`
|
|
1121
|
+
* when the signal carries none.
|
|
1122
|
+
* @throws StudyError - Thrown with code `CONFIG` when no goal is prepared, another response is running, or the responses are exhausted; thrown with the meter's refusal when admission fails
|
|
1123
|
+
*/
|
|
1124
|
+
stream(messages: readonly Message[], signal: AbortSignal): AsyncGenerator<ProviderDelta, ProviderResult>;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
/** Holds the scripted provider's fixed byte bound; the admitted token count defaults to one. */
|
|
1128
|
+
export declare interface StudyAgentScriptOptions {
|
|
1129
|
+
readonly bytes: number;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
/**
|
|
1133
|
+
* Names where a measurement was taken.
|
|
1134
|
+
* @remarks
|
|
1135
|
+
* `admission` is a window or room check before a request is admitted; `dispatch` is the request
|
|
1136
|
+
* the provider sends.
|
|
1137
|
+
*/
|
|
1138
|
+
export declare type StudyAgentStage = 'admission' | 'dispatch';
|
|
1139
|
+
|
|
1140
|
+
/**
|
|
1141
|
+
* Holds the ordinal and revision one measurement received.
|
|
1142
|
+
* @remarks
|
|
1143
|
+
* `revision` is null, never omitted, when the request could not be canonically rendered; the
|
|
1144
|
+
* retained evidence format distinguishes the two.
|
|
1145
|
+
*/
|
|
1146
|
+
export declare interface StudyAgentStamp {
|
|
1147
|
+
readonly ordinal: number;
|
|
1148
|
+
readonly revision: string | null;
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/** Folds a conversation through the real provider under an explicit gauge and prompt limit. */
|
|
1152
|
+
export declare class StudyAgentSummary {
|
|
1153
|
+
#private;
|
|
1154
|
+
/** Binds the provider, the measuring trace, the gauge, the limit and the consumer's instruction.
|
|
1155
|
+
* @param options - Delegate, measurement seam, limits and cancellation.
|
|
1156
|
+
* @throws StudyError - Thrown with code `CONFIG` when the limit is not a positive safe integer, or the gauge scale is not finite and greater than 0 or its overhead is not finite and at least 0.
|
|
1157
|
+
*/
|
|
1158
|
+
constructor(options: StudyAgentSummaryOptions);
|
|
1159
|
+
/** Measures one canonical request, refuses it at the limit, and sends the very same array to the provider.
|
|
1160
|
+
* @param messages - The conversation to fold; the instruction follows as the final user turn.
|
|
1161
|
+
* @param signal - Bounds the request; the options' signal bounds it when omitted.
|
|
1162
|
+
* @returns The summary content, retained as evidence before a blank result is refused.
|
|
1163
|
+
* @throws StudyError - Thrown with code `CAPACITY` when the projection reaches the limit, and with code `FAULT` when usage is unusable, no goal is active, or the content is blank.
|
|
1164
|
+
*/
|
|
1165
|
+
summarize(messages: readonly Message[], signal: AbortSignal | undefined): Promise<string>;
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
/**
|
|
1169
|
+
* Holds the gauged summary's delegate, measurement seam, explicit limits and cancellation.
|
|
1170
|
+
* @remarks
|
|
1171
|
+
* `provider` receives the one canonical array the summary measured. `runtime` prices it. `trace`
|
|
1172
|
+
* retains the summary's measurement, refusal and evidence rows. `latch` refuses work after a
|
|
1173
|
+
* retained failure. `gauge` prices each request and `limit` is the prompt projection at which a
|
|
1174
|
+
* request is refused; it must be a positive safe integer, and `gauge.scale` must be finite and
|
|
1175
|
+
* greater than 0 and `gauge.overhead` finite and at least 0, or construction refuses with `CONFIG`.
|
|
1176
|
+
* The summary keeps its own copy of the gauge. `instruction` is the final user turn appended to the
|
|
1177
|
+
* folded messages. `signal` bounds work when the caller supplies none.
|
|
1178
|
+
*/
|
|
1179
|
+
export declare interface StudyAgentSummaryOptions {
|
|
1180
|
+
readonly provider: ProviderInterface;
|
|
1181
|
+
readonly runtime: Pick<StudyAgentRuntime, 'estimateRequest'>;
|
|
1182
|
+
readonly trace: StudyAgentTrace;
|
|
1183
|
+
readonly latch: StudyLatchInterface;
|
|
1184
|
+
readonly gauge: LedgerGauge;
|
|
1185
|
+
readonly limit: number;
|
|
1186
|
+
readonly instruction: Message;
|
|
1187
|
+
readonly signal: AbortSignal;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/** Correlates measured Agent requests and retains their evidence across a trial's goals. */
|
|
1191
|
+
export declare class StudyAgentTrace {
|
|
1192
|
+
#private;
|
|
1193
|
+
/** Binds the measuring runtime, the failure owner and the consumer origin join.
|
|
1194
|
+
* @param options - Runtime, latch, observation switch and origin handler.
|
|
1195
|
+
*/
|
|
1196
|
+
constructor(options: StudyAgentTraceOptions);
|
|
1197
|
+
/** Reports the active goal; undefined between goals. */
|
|
1198
|
+
get goal(): string | undefined;
|
|
1199
|
+
/** Begins a goal's rows. Ordinals, dispatch numbers and role identities continue from earlier goals.
|
|
1200
|
+
* @param goal - The goal whose rows follow.
|
|
1201
|
+
* @throws StudyError - Thrown with code `CONFIG` when a goal is already active; the active goal and its rows stay unchanged.
|
|
1202
|
+
*/
|
|
1203
|
+
start(goal: string): void;
|
|
1204
|
+
/** Retains one domain row for the active goal, whether or not observation is enabled; a row outside a goal is dropped.
|
|
1205
|
+
* @param event - The evidence event name.
|
|
1206
|
+
* @param value - The JSON evidence value.
|
|
1207
|
+
*/
|
|
1208
|
+
append(event: string, value: JSONValue): void;
|
|
1209
|
+
/** Appends the retained rows in order, including rows added during the flush, and ends the goal even when custody refuses a row.
|
|
1210
|
+
* @param evidence - The sink that takes custody of each row.
|
|
1211
|
+
* @returns Completion after every row is appended; immediately when no goal is active.
|
|
1212
|
+
* @throws StudyError - Thrown with code `CONFIG` when another flush is pending; the pending flush is untouched.
|
|
1213
|
+
*/
|
|
1214
|
+
flush(evidence: StudySinkInterface): Promise<void>;
|
|
1215
|
+
/** Prices a window measurement and, when observing, retains it as the goal's admission.
|
|
1216
|
+
* @param request - The measured request.
|
|
1217
|
+
* @param gauge - The explicit gauge pricing the estimate.
|
|
1218
|
+
* @returns The projected prompt tokens.
|
|
1219
|
+
*/
|
|
1220
|
+
admit(request: ProviderRequest, gauge: LedgerGauge): number;
|
|
1221
|
+
/** Retains a dispatching agent request's reading, names it for the wire request that follows, and records its estimate.
|
|
1222
|
+
* @param reading - The explicit size reading.
|
|
1223
|
+
* @param request - The exact pre-encoding request.
|
|
1224
|
+
*/
|
|
1225
|
+
record(reading: StudyAgentReading, request: ProviderRequest): void;
|
|
1226
|
+
/** Takes one synchronous measurement row; the goal's flush appends it, failure included.
|
|
1227
|
+
* @param stage - Where the measurement was taken.
|
|
1228
|
+
* @param role - The responsibility whose request was measured.
|
|
1229
|
+
* @param request - The exact pre-encoding request.
|
|
1230
|
+
* @param reading - The explicit size reading.
|
|
1231
|
+
* @param dispatch - The dispatch number the request received; undefined for an admission.
|
|
1232
|
+
* @returns The ordinal and revision; undefined when not observing.
|
|
1233
|
+
*/
|
|
1234
|
+
measure(stage: StudyAgentStage, role: StudyAgentRole, request: ProviderRequest, reading: StudyAgentReading, dispatch: number | undefined): StudyAgentStamp | undefined;
|
|
1235
|
+
/** Numbers a request about to be dispatched and retains it as its role's current dispatch; does nothing unless observing.
|
|
1236
|
+
* @param role - The responsibility dispatching.
|
|
1237
|
+
* @param request - The exact pre-encoding request.
|
|
1238
|
+
* @param reading - The explicit size reading.
|
|
1239
|
+
*/
|
|
1240
|
+
dispatch(role: StudyAgentRole, request: ProviderRequest, reading: StudyAgentReading): void;
|
|
1241
|
+
/** Reads the role's current dispatch identity for the wire request that follows it.
|
|
1242
|
+
* @param role - The responsibility dispatching.
|
|
1243
|
+
* @returns The dispatch id and revision; undefined before any observed dispatch of the role.
|
|
1244
|
+
*/
|
|
1245
|
+
canonical(role: StudyAgentRole): StudyAgentDispatch | undefined;
|
|
1246
|
+
/** Latches the study-level reading of a failure before an enclosing runtime can swallow it and retains one refusal row per refused identity in a goal.
|
|
1247
|
+
* @param error - The caught or reported value.
|
|
1248
|
+
* @returns The translated failure, or the same value when it is not an Agent window refusal.
|
|
1249
|
+
*/
|
|
1250
|
+
translate(error: unknown): unknown;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* Holds the trace's measuring runtime, failure owner and consumer origin join.
|
|
1255
|
+
* @remarks
|
|
1256
|
+
* `runtime` measures requests and recognizes the nominal Agent refusal. `latch` retains the first
|
|
1257
|
+
* operational failure. `observe`: if `true`, the trace retains measurement and refusal rows; if
|
|
1258
|
+
* `false`, it retains none, while domain rows still follow an active goal. `origins` supplies the
|
|
1259
|
+
* consumer's origin annotation for a measured request's messages.
|
|
1260
|
+
*/
|
|
1261
|
+
export declare interface StudyAgentTraceOptions {
|
|
1262
|
+
readonly runtime: StudyAgentRuntime;
|
|
1263
|
+
readonly latch: StudyLatchInterface;
|
|
1264
|
+
readonly observe: boolean;
|
|
1265
|
+
readonly origins: StudyAgentOriginHandler;
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
/** Holds the separately bound instrument and selected module inventory identities. */
|
|
1269
|
+
export declare interface StudyArtifactIdentity {
|
|
1270
|
+
readonly agent: string;
|
|
1271
|
+
readonly subject: string;
|
|
1272
|
+
readonly provider: string | undefined;
|
|
1273
|
+
readonly instrument: string;
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
/** Binds consumer instrumentation separately from selected executable identities. */
|
|
1277
|
+
export declare class StudyArtifactLoader {
|
|
1278
|
+
#private;
|
|
1279
|
+
/** Owns resolved built and consumer source selections.
|
|
1280
|
+
* @param options - The trusted host, adapter, and profile.
|
|
1281
|
+
*/
|
|
1282
|
+
constructor(options: StudyArtifactLoaderOptions);
|
|
1283
|
+
/** Inventories bytes without importing selected code.
|
|
1284
|
+
* @returns Bound executable and instrumentation identities.
|
|
1285
|
+
*/
|
|
1286
|
+
inspect(): Promise<StudyArtifactIdentity>;
|
|
1287
|
+
/** Loads the adapter from the trial inventory.
|
|
1288
|
+
* @returns The complete consumer adapter.
|
|
1289
|
+
*/
|
|
1290
|
+
adapter(): Promise<StudyAdapterInterface>;
|
|
1291
|
+
/** Loads admitted built namespaces inside the trial child.
|
|
1292
|
+
* @returns The agent, subject and optional provider; a shared entry loads once and keeps each role.
|
|
1293
|
+
*/
|
|
1294
|
+
load(): Promise<StudyArtifactModule>;
|
|
1295
|
+
/** Refuses instrument and inventory drift after inspection. */
|
|
1296
|
+
verify(): void;
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
/** Holds the trusted instrument and caller-selected built artifact locations. */
|
|
1300
|
+
export declare interface StudyArtifactLoaderOptions {
|
|
1301
|
+
readonly entry: string;
|
|
1302
|
+
readonly root: string;
|
|
1303
|
+
readonly profile: StudyProfile;
|
|
1304
|
+
readonly adapter: string;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
/** Holds actual namespaces loaded only during worker execution. */
|
|
1308
|
+
export declare interface StudyArtifactModule {
|
|
1309
|
+
readonly agent: unknown;
|
|
1310
|
+
readonly subject: unknown;
|
|
1311
|
+
readonly provider: unknown;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
/** Holds a terminal trial record, including goals never dispatched. */
|
|
1315
|
+
declare interface StudyAttempt {
|
|
1316
|
+
readonly trial: StudyTrial;
|
|
1317
|
+
readonly observations: readonly StudyObservation[];
|
|
1318
|
+
readonly failure: StudyFailure | undefined;
|
|
1319
|
+
readonly duration: number;
|
|
1320
|
+
/** Records whether the trial entered execution without an inherited terminal series failure, including failures before the driver opened; not a claim that the driver was opened. */
|
|
1321
|
+
readonly executed: boolean;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* Holds one failed record the report groups by cause, role, and layer.
|
|
1326
|
+
* @remarks
|
|
1327
|
+
* `trial` names the trial the failure belongs to. `goal` names the goal at the goal level and is
|
|
1328
|
+
* undefined at the trial level. `executed` is the record's own execution fact, never inferred.
|
|
1329
|
+
*/
|
|
1330
|
+
export declare interface StudyAttributionSource {
|
|
1331
|
+
readonly trial: string;
|
|
1332
|
+
readonly goal: string | undefined;
|
|
1333
|
+
readonly failure: StudyFailure;
|
|
1334
|
+
readonly executed: boolean;
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
/** Holds nested execution allowances; each request also has a deadline. */
|
|
1338
|
+
declare interface StudyBounds {
|
|
1339
|
+
readonly request: StudyLimit;
|
|
1340
|
+
readonly goal: StudyLimit;
|
|
1341
|
+
readonly trial: StudyLimit;
|
|
1342
|
+
readonly series: StudyLimit;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* Names an operational ending separately from task achievement.
|
|
1347
|
+
* @remarks
|
|
1348
|
+
* `content` means a request completed but its consumer refused the content as unusable. It
|
|
1349
|
+
* claims no model or decoder cause and grades no semantic quality.
|
|
1350
|
+
*/
|
|
1351
|
+
declare type StudyCause = 'capacity' | 'infrastructure' | 'deadline' | 'interrupted' | 'content';
|
|
1352
|
+
|
|
1353
|
+
/** Correlates bounded IPC work and rejects every outstanding request on transport failure. */
|
|
1354
|
+
export declare class StudyChannel {
|
|
1355
|
+
#private;
|
|
1356
|
+
/** Subscribes to one native IPC endpoint.
|
|
1357
|
+
* @param options - Native endpoint and owning domain handlers; the bag is snapshotted while selected collaborators keep their identity.
|
|
1358
|
+
*/
|
|
1359
|
+
constructor(options: StudyChannelOptions);
|
|
1360
|
+
get signal(): AbortSignal;
|
|
1361
|
+
/** Sends one correlated domain request.
|
|
1362
|
+
* @param operation - The domain operation expected by the peer.
|
|
1363
|
+
* @param value - Public JSON payload.
|
|
1364
|
+
* @returns The peer's acknowledged result.
|
|
1365
|
+
*/
|
|
1366
|
+
request(operation: StudyOperation, value: JSONValue): Promise<JSONValue>;
|
|
1367
|
+
/** Forwards cancellation without closing the cleanup transport.
|
|
1368
|
+
* @param value - Validated goal, trial or ticket cancellation attribution.
|
|
1369
|
+
*/
|
|
1370
|
+
abort(value: JSONValue): void;
|
|
1371
|
+
/** Removes endpoint handlers and rejects all unresolved calls.
|
|
1372
|
+
* @param error - The first transport or owning lifecycle failure.
|
|
1373
|
+
*/
|
|
1374
|
+
close(error?: unknown): void;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
/** Holds one native IPC endpoint and its domain handlers. */
|
|
1378
|
+
export declare interface StudyChannelOptions {
|
|
1379
|
+
readonly endpoint: ChildProcess | NodeJS.Process;
|
|
1380
|
+
readonly handle: StudyMessageHandler;
|
|
1381
|
+
readonly abort: (value: JSONValue) => void;
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1384
|
+
/** Holds a request's pre-dispatch upper bounds. */
|
|
1385
|
+
declare interface StudyCharge {
|
|
1386
|
+
readonly role: StudyRole;
|
|
1387
|
+
readonly tokens: number;
|
|
1388
|
+
readonly bytes: number;
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
/** Dispatches private child routes before the public native supervisor. */
|
|
1392
|
+
export declare class StudyCLI {
|
|
1393
|
+
#private;
|
|
1394
|
+
/** Owns the installed executable path and consumer working directory.
|
|
1395
|
+
* @param options - Exact runtime entry and consumer root, snapshotted at construction.
|
|
1396
|
+
*/
|
|
1397
|
+
constructor(options: StudyLaunchOptions);
|
|
1398
|
+
/** Executes one route with truthful public exit semantics.
|
|
1399
|
+
* @param arguments_ - Native command arguments.
|
|
1400
|
+
* @returns The command, deadline, interruption, or invalid-input exit code.
|
|
1401
|
+
*/
|
|
1402
|
+
execute(arguments_: readonly string[]): Promise<number>;
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
/** Executes validated study operations with execution and grading custody kept independent. */
|
|
1406
|
+
export declare class StudyCommand {
|
|
1407
|
+
#private;
|
|
1408
|
+
/**
|
|
1409
|
+
* Owns the trusted host entry and repository location without reading or writing files.
|
|
1410
|
+
* @param options - The repository root and built trusted application entry
|
|
1411
|
+
*/
|
|
1412
|
+
constructor(options: StudyCommandOptions);
|
|
1413
|
+
/**
|
|
1414
|
+
* Parses command tokens once and executes their independent operation.
|
|
1415
|
+
* @param arguments_ - The exact command tokens
|
|
1416
|
+
* @param signal - The caller's execution cancellation
|
|
1417
|
+
* @returns Truthful operation metadata or a verified whole-horizon report
|
|
1418
|
+
* @throws StudyError - Thrown when arguments, declarations, identities, or custody fail
|
|
1419
|
+
*/
|
|
1420
|
+
execute(arguments_: readonly string[], signal: AbortSignal): Promise<JSONValue>;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
/** Holds one bounded source artifact retained during offline validation. */
|
|
1424
|
+
export declare interface StudyCommandArtifact {
|
|
1425
|
+
readonly path: string;
|
|
1426
|
+
readonly digest: string;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
/** Holds the trusted application entry and repository location. */
|
|
1430
|
+
export declare interface StudyCommandOptions {
|
|
1431
|
+
readonly root: string;
|
|
1432
|
+
readonly entry: string;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
/** Names the independently dispatched study command operation. */
|
|
1436
|
+
export declare type StudyCommandRequest = StudyExecutionRequest | StudyGradeRequest | StudyLabelRequest | StudyReportRequest;
|
|
1437
|
+
|
|
1438
|
+
/** Holds the resources visible to one running goal. */
|
|
1439
|
+
declare interface StudyContext {
|
|
1440
|
+
readonly signal: AbortSignal;
|
|
1441
|
+
readonly meter: StudyAdmissionInterface;
|
|
1442
|
+
readonly evidence: StudySinkInterface;
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
/** Retains the first operational failure while bounding asynchronous waits. */
|
|
1446
|
+
declare class StudyControl implements StudyControlInterface {
|
|
1447
|
+
#private;
|
|
1448
|
+
/** Links cancellation to the caller without assigning it a task verdict.
|
|
1449
|
+
* @param signal - Optional parent cancellation.
|
|
1450
|
+
*/
|
|
1451
|
+
constructor(signal?: AbortSignal);
|
|
1452
|
+
get signal(): AbortSignal;
|
|
1453
|
+
get failure(): StudyFailure | undefined;
|
|
1454
|
+
/** Latches an operational failure and cancels all linked work.
|
|
1455
|
+
* @param failure - The first attribution to preserve.
|
|
1456
|
+
*/
|
|
1457
|
+
fail(failure: StudyFailure): void;
|
|
1458
|
+
/** Races work against cancellation and removes its listener after either ending.
|
|
1459
|
+
* @param work - Already-started work whose rejection remains observed after cancellation.
|
|
1460
|
+
* @returns The work's result if it settles before cancellation.
|
|
1461
|
+
* @throws Thrown with the retained operational attribution when cancelled.
|
|
1462
|
+
*/
|
|
1463
|
+
wait<T>(work: PromiseLike<T>): Promise<T>;
|
|
1464
|
+
/** Removes the lifecycle listener without changing the retained failure. */
|
|
1465
|
+
close(): void;
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
/** Owns the first operational failure and cancellation of enclosing work. */
|
|
1469
|
+
declare interface StudyControlInterface {
|
|
1470
|
+
readonly signal: AbortSignal;
|
|
1471
|
+
readonly failure: StudyFailure | undefined;
|
|
1472
|
+
/** Latches an operational failure and cancels all linked work.
|
|
1473
|
+
* @param failure - The first attribution to preserve.
|
|
1474
|
+
* @returns Nothing after failure propagation.
|
|
1475
|
+
*/
|
|
1476
|
+
fail(failure: StudyFailure): void;
|
|
1477
|
+
/** Races work against cancellation and removes its listener after either ending.
|
|
1478
|
+
* @param work - Work whose late rejection remains observed.
|
|
1479
|
+
* @returns The result when work settles before cancellation.
|
|
1480
|
+
*/
|
|
1481
|
+
wait<T>(work: PromiseLike<T>): Promise<T>;
|
|
1482
|
+
/** Removes the lifecycle listener without changing the retained failure.
|
|
1483
|
+
* @returns Nothing after listener release.
|
|
1484
|
+
*/
|
|
1485
|
+
close(): void;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
/** Holds a grader-owned criterion outside the driver's public input. */
|
|
1489
|
+
declare interface StudyCriterion {
|
|
1490
|
+
readonly id: string;
|
|
1491
|
+
readonly scenario: string;
|
|
1492
|
+
readonly goal: string;
|
|
1493
|
+
readonly method: 'state' | 'trace' | 'semantic';
|
|
1494
|
+
readonly critical: boolean;
|
|
1495
|
+
readonly assertion: JSONValue;
|
|
1496
|
+
}
|
|
1497
|
+
|
|
1498
|
+
/** Holds the evidence sink's shared admission budget. */
|
|
1499
|
+
export declare interface StudyCustodyBudget {
|
|
1500
|
+
readonly reserve: (bytes: number) => void;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
/** Names the execution custody lifecycle without inferring seal completeness. */
|
|
1504
|
+
export declare type StudyCustodyPhase = 'new' | 'creating' | 'ready' | 'sealing' | 'sealed' | 'failed';
|
|
1505
|
+
|
|
1506
|
+
/** Closes evidence admission and drains already admitted appends. */
|
|
1507
|
+
export declare interface StudyCustodySinkInterface extends StudySinkInterface {
|
|
1508
|
+
/** Closes admission immediately and synchronizes all previously admitted writes.
|
|
1509
|
+
* @returns A promise that resolves after the evidence descriptor closes.
|
|
1510
|
+
*/
|
|
1511
|
+
close(): Promise<void>;
|
|
1512
|
+
}
|
|
1513
|
+
|
|
1514
|
+
/** Holds the frozen study question, population and explicit repetition orders. */
|
|
1515
|
+
declare interface StudyDefinition {
|
|
1516
|
+
readonly name: string;
|
|
1517
|
+
readonly version: string;
|
|
1518
|
+
readonly question: string;
|
|
1519
|
+
readonly purpose: StudyPurpose;
|
|
1520
|
+
readonly driver: string;
|
|
1521
|
+
readonly arms: readonly string[];
|
|
1522
|
+
readonly scenarios: readonly string[];
|
|
1523
|
+
readonly order: ReadonlyArray<readonly string[]>;
|
|
1524
|
+
readonly retries: 0;
|
|
1525
|
+
readonly rubric: string;
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
/** Creates isolated domain state through a concrete package consumer. */
|
|
1529
|
+
declare interface StudyDriverInterface {
|
|
1530
|
+
/** Creates fresh domain state for one scheduled trial.
|
|
1531
|
+
* @param trial - The scheduled scenario, arm, and repetition.
|
|
1532
|
+
* @param signal - The caller's cancellation.
|
|
1533
|
+
* @returns The isolated session for this trial.
|
|
1534
|
+
*/
|
|
1535
|
+
open(trial: StudyTrial, signal: AbortSignal): Promise<StudySessionInterface>;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
/** Supplies admitted modules and an exclusive scratch parent without grader truth. */
|
|
1539
|
+
export declare interface StudyDriverOptions {
|
|
1540
|
+
readonly agent: unknown;
|
|
1541
|
+
readonly subject: unknown;
|
|
1542
|
+
readonly provider: unknown;
|
|
1543
|
+
readonly profile: StudyProfile;
|
|
1544
|
+
readonly directory: string;
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
/** Reports a study contract or operational failure with a stable code. */
|
|
1548
|
+
declare class StudyError extends Error {
|
|
1549
|
+
readonly code: StudyErrorCode;
|
|
1550
|
+
readonly failure: StudyFailure | undefined;
|
|
1551
|
+
/**
|
|
1552
|
+
* Records the failing boundary and optional operational attribution.
|
|
1553
|
+
* @param code - The machine-readable boundary
|
|
1554
|
+
* @param message - The specific failure
|
|
1555
|
+
* @param failure - The optional operational reading
|
|
1556
|
+
*/
|
|
1557
|
+
constructor(code: StudyErrorCode, message: string, failure?: StudyFailure);
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
/** Names malformed configuration, evidence, custody and operational failures. */
|
|
1561
|
+
declare type StudyErrorCode = 'CONFIG' | 'EVIDENCE' | 'CUSTODY' | 'CAPACITY' | 'FAULT' | 'DEADLINE';
|
|
1562
|
+
|
|
1563
|
+
/** Holds append-only domain evidence in a JSON-compatible form. */
|
|
1564
|
+
declare interface StudyEvidence {
|
|
1565
|
+
readonly event: string;
|
|
1566
|
+
readonly goal: string;
|
|
1567
|
+
readonly value: JSONValue;
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
/** Retains admitted evidence in order and closes admission before terminal records. */
|
|
1571
|
+
export declare class StudyEvidenceSink implements StudyCustodySinkInterface {
|
|
1572
|
+
#private;
|
|
1573
|
+
/**
|
|
1574
|
+
* Owns the descriptor selection and constraints while retaining the live file and budget.
|
|
1575
|
+
* @param options - The owned descriptor, goal names, and byte admission bounds
|
|
1576
|
+
*/
|
|
1577
|
+
constructor(options: StudyEvidenceSinkOptions);
|
|
1578
|
+
/**
|
|
1579
|
+
* Admits exact encoded bytes before queuing an append in call order.
|
|
1580
|
+
* @param evidence - The validated domain record
|
|
1581
|
+
* @returns Nothing after the admitted append completes
|
|
1582
|
+
* @throws StudyError - Thrown when admission is closed or a byte limit is exceeded
|
|
1583
|
+
*/
|
|
1584
|
+
append(evidence: StudyEvidence): Promise<void>;
|
|
1585
|
+
/**
|
|
1586
|
+
* Closes admission immediately and synchronizes all previously admitted writes.
|
|
1587
|
+
* @returns Nothing when the evidence descriptor has closed
|
|
1588
|
+
*/
|
|
1589
|
+
close(): Promise<void>;
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
/** Holds the owned evidence descriptor and byte admission constraints. */
|
|
1593
|
+
export declare interface StudyEvidenceSinkOptions {
|
|
1594
|
+
readonly file: FileHandle;
|
|
1595
|
+
readonly goals: readonly string[];
|
|
1596
|
+
readonly goal: number;
|
|
1597
|
+
readonly trial: number;
|
|
1598
|
+
readonly budget: StudyCustodyBudget;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
/** Holds a checked execution selection with optional output custody. */
|
|
1602
|
+
export declare interface StudyExecutionRequest {
|
|
1603
|
+
readonly command: 'check' | 'execute';
|
|
1604
|
+
readonly target: string;
|
|
1605
|
+
readonly profile: string;
|
|
1606
|
+
/** Selects an absolute output or a portable path contained by the consumer root. */
|
|
1607
|
+
readonly out: string | undefined;
|
|
1608
|
+
readonly expected: string | undefined;
|
|
1609
|
+
}
|
|
1610
|
+
|
|
1611
|
+
/** Holds an attributable operational fault without awarding a task verdict. */
|
|
1612
|
+
declare interface StudyFailure {
|
|
1613
|
+
readonly cause: StudyCause;
|
|
1614
|
+
readonly message: string;
|
|
1615
|
+
readonly role: StudyRole | undefined;
|
|
1616
|
+
/** Names the ceiling that stopped the run; undefined for a failure no ceiling caused, and for a record sealed before this member existed. */
|
|
1617
|
+
readonly stop: StudyStop | undefined;
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
/** Holds the exact byte identity of one execution file. */
|
|
1621
|
+
export declare interface StudyFile {
|
|
1622
|
+
readonly path: string;
|
|
1623
|
+
readonly bytes: number;
|
|
1624
|
+
readonly digest: string;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
/** Holds a correlated JSON request, reply or cancellation notification. */
|
|
1628
|
+
export declare interface StudyFrame {
|
|
1629
|
+
readonly id: number;
|
|
1630
|
+
readonly operation: StudyOperation | 'reply' | 'error' | 'abort';
|
|
1631
|
+
readonly value: JSONValue;
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
/** Holds a declared goal's public input without its grading truth. */
|
|
1635
|
+
declare interface StudyGoal {
|
|
1636
|
+
readonly id: string;
|
|
1637
|
+
readonly input: JSONValue;
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
/** Reads one declared target against the consumer's domain predicate. */
|
|
1641
|
+
export declare type StudyGradeFunction = (target: StudyGradeTarget) => StudyGradeReading;
|
|
1642
|
+
|
|
1643
|
+
/** Holds a consumer predicate's reading of one target, citing only retained files and rows. */
|
|
1644
|
+
export declare interface StudyGradeReading {
|
|
1645
|
+
readonly verdict: StudyJudgment['verdict'];
|
|
1646
|
+
readonly method: StudyJudgment['method'];
|
|
1647
|
+
readonly reason: string;
|
|
1648
|
+
readonly references: readonly StudyReference[];
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
/** Holds an offline predicate grading request. */
|
|
1652
|
+
export declare interface StudyGradeRequest {
|
|
1653
|
+
readonly command: 'grade';
|
|
1654
|
+
readonly target: string;
|
|
1655
|
+
readonly rubric: string;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
/** Holds one declared trial and criterion pair with its retained observations. */
|
|
1659
|
+
export declare interface StudyGradeTarget {
|
|
1660
|
+
readonly trial: StudyTrial;
|
|
1661
|
+
readonly criterion: StudyCriterion;
|
|
1662
|
+
/** Holds the retained terminal record, or undefined when the trial was never retained. */
|
|
1663
|
+
readonly attempt: StudyAttempt | undefined;
|
|
1664
|
+
/** Holds the trial's retained evidence rows in append order; empty when the trial was never retained. */
|
|
1665
|
+
readonly evidence: readonly StudyEvidence[];
|
|
1666
|
+
}
|
|
1667
|
+
|
|
1668
|
+
/** Holds a grading identity that cannot replace or mutate execution bytes. */
|
|
1669
|
+
declare interface StudyGrading {
|
|
1670
|
+
readonly result: string;
|
|
1671
|
+
readonly rubric: string;
|
|
1672
|
+
readonly grader: string;
|
|
1673
|
+
readonly instrument: string;
|
|
1674
|
+
readonly attempts: readonly string[];
|
|
1675
|
+
readonly labels: string | undefined;
|
|
1676
|
+
/** Binds the retained public packet and private mapping when semantic criteria exist. */
|
|
1677
|
+
readonly packet?: string;
|
|
1678
|
+
readonly judgments: readonly StudyJudgment[];
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
/** Holds artifacts already verified inside a selected immutable grading directory. */
|
|
1682
|
+
export declare interface StudyGradingContext {
|
|
1683
|
+
readonly grading: StudyGrading;
|
|
1684
|
+
readonly rubric: StudyRubric;
|
|
1685
|
+
readonly bytes: Uint8Array;
|
|
1686
|
+
readonly packet: StudyPacketBundle | undefined;
|
|
1687
|
+
readonly labels: Uint8Array | undefined;
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
/** Retains immutable deterministic grading versions independently of execution bytes. */
|
|
1691
|
+
export declare class StudyGradingStore {
|
|
1692
|
+
#private;
|
|
1693
|
+
/**
|
|
1694
|
+
* Owns exact imported grading bytes without writing any custody files.
|
|
1695
|
+
* @param options - The verified execution and exact rubric and optional labels bytes
|
|
1696
|
+
* @throws StudyError - Thrown when imported bytes exceed bounds or fail validation
|
|
1697
|
+
*/
|
|
1698
|
+
constructor(options: StudyGradingStoreOptions);
|
|
1699
|
+
/**
|
|
1700
|
+
* Retains a deterministic grading version or verifies identical existing bytes.
|
|
1701
|
+
* @param grading - The complete evidence-backed judgments and artifact bindings
|
|
1702
|
+
* @returns The exact grading-byte SHA-256 identity
|
|
1703
|
+
* @throws StudyError - Thrown when coverage, bindings, or existing bytes are invalid
|
|
1704
|
+
*/
|
|
1705
|
+
write(grading: StudyGrading): Promise<string>;
|
|
1706
|
+
/**
|
|
1707
|
+
* Reads an immutable grading version and verifies every bound artifact byte.
|
|
1708
|
+
* @param id - The grading-byte SHA-256 identity
|
|
1709
|
+
* @returns The verified grading, or undefined when the version does not exist
|
|
1710
|
+
* @throws StudyError - Thrown when an existing version is partial or tampered
|
|
1711
|
+
*/
|
|
1712
|
+
read(id: string): Promise<StudyGrading | undefined>;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
/** Holds imported grading artifacts independently of execution. */
|
|
1716
|
+
export declare interface StudyGradingStoreOptions {
|
|
1717
|
+
readonly result: StudySealedResult;
|
|
1718
|
+
readonly rubric: Uint8Array;
|
|
1719
|
+
readonly labels?: Uint8Array;
|
|
1720
|
+
readonly packet?: StudyPacketBundle;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
/** Holds byte identities that qualification and comparisons must agree on. */
|
|
1724
|
+
declare interface StudyIdentity {
|
|
1725
|
+
readonly agent: string;
|
|
1726
|
+
readonly subject: string;
|
|
1727
|
+
readonly provider: string | undefined;
|
|
1728
|
+
readonly instrument: string;
|
|
1729
|
+
readonly fixtures: string;
|
|
1730
|
+
readonly profile: string;
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1733
|
+
/** Holds inspected execution metadata that is never gradeable before sealing. */
|
|
1734
|
+
export declare interface StudyInterruptedResult {
|
|
1735
|
+
readonly status: 'interrupted';
|
|
1736
|
+
readonly directory: string;
|
|
1737
|
+
readonly manifest: StudyManifest | undefined;
|
|
1738
|
+
readonly attempts: readonly StudyAttempt[];
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
/** Holds an evidence-backed verdict; missing evidence stays unknown. */
|
|
1742
|
+
declare interface StudyJudgment {
|
|
1743
|
+
readonly trial: string;
|
|
1744
|
+
readonly criterion: string;
|
|
1745
|
+
readonly verdict: 'achieved' | 'unsuccessful' | 'unknown';
|
|
1746
|
+
readonly method: 'state' | 'trace' | 'human' | 'model';
|
|
1747
|
+
readonly reason: string;
|
|
1748
|
+
readonly references: readonly string[];
|
|
1749
|
+
}
|
|
1750
|
+
|
|
1751
|
+
/** Holds imported semantic judgments and their accountable origin. */
|
|
1752
|
+
declare interface StudyLabeling {
|
|
1753
|
+
readonly packet: string;
|
|
1754
|
+
readonly labeler: string;
|
|
1755
|
+
readonly version: string;
|
|
1756
|
+
readonly created: string;
|
|
1757
|
+
readonly usage: readonly StudyUsage[];
|
|
1758
|
+
readonly judgments: readonly StudyJudgment[];
|
|
1759
|
+
}
|
|
1760
|
+
|
|
1761
|
+
/** Holds an imported-label grading request. */
|
|
1762
|
+
export declare interface StudyLabelRequest {
|
|
1763
|
+
readonly command: 'label';
|
|
1764
|
+
readonly target: string;
|
|
1765
|
+
readonly grading: string;
|
|
1766
|
+
readonly labels: string;
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
/** Retains the first operational failure of instrumented work and refuses work after it. */
|
|
1770
|
+
declare interface StudyLatchInterface {
|
|
1771
|
+
/** Refuses work after a retained failure or cancellation.
|
|
1772
|
+
* @returns Nothing when work may continue.
|
|
1773
|
+
*/
|
|
1774
|
+
check(): void;
|
|
1775
|
+
/** Retains an operational failure even when an enclosing runtime catches it.
|
|
1776
|
+
* @param error - The observed failure; an earlier retained failure keeps its identity, and a branded `BudgetError` can retain nothing because Agent reports that stop in its own result.
|
|
1777
|
+
* @returns Nothing after retention.
|
|
1778
|
+
*/
|
|
1779
|
+
fail(error: unknown): void;
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
/** Supervises finite command trees and binds offline check to execution. */
|
|
1783
|
+
export declare class StudyLauncher {
|
|
1784
|
+
#private;
|
|
1785
|
+
/** Owns the trusted runtime entry and caller working directory.
|
|
1786
|
+
* @param options - Native entry and consumer root.
|
|
1787
|
+
*/
|
|
1788
|
+
constructor(options: StudyLaunchOptions);
|
|
1789
|
+
/** Checks and supervises the requested command under its finite native allowance.
|
|
1790
|
+
* @param arguments_ - Public command tokens.
|
|
1791
|
+
* @returns The exact operational or supervisor exit code.
|
|
1792
|
+
*/
|
|
1793
|
+
execute(arguments_: readonly string[]): Promise<number>;
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
/** Selects the native command entry and the caller's consumer root. */
|
|
1797
|
+
export declare interface StudyLaunchOptions {
|
|
1798
|
+
readonly root: string;
|
|
1799
|
+
readonly entry: string;
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
/** Retains the bounded command exit and captured output. */
|
|
1803
|
+
export declare interface StudyLaunchResult {
|
|
1804
|
+
readonly code: number;
|
|
1805
|
+
readonly output: string;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1808
|
+
/**
|
|
1809
|
+
* Names the ceiling that stopped a run.
|
|
1810
|
+
* @remarks
|
|
1811
|
+
* `scope` is a limit Study declares: the calls, tokens, bytes, or duration of a request, goal,
|
|
1812
|
+
* trial, series, or operation, the product output allowance, and a provider's declared byte bound.
|
|
1813
|
+
* `window` is a prompt room. `custody` is an evidence allowance. `meter`, `budget`, and `model`
|
|
1814
|
+
* mirror the `layer` of the `AgentStop` type from `@orkestrel/agent`: the run's estimate allowance,
|
|
1815
|
+
* any other budget, and the model's own token limit, which also names the daemon's context and
|
|
1816
|
+
* output caps.
|
|
1817
|
+
*/
|
|
1818
|
+
declare type StudyLayer = 'scope' | 'window' | 'custody' | 'meter' | 'budget' | 'model';
|
|
1819
|
+
|
|
1820
|
+
/** Holds finite allowances in milliseconds, calls, tokens and bytes. */
|
|
1821
|
+
declare interface StudyLimit {
|
|
1822
|
+
readonly duration: number;
|
|
1823
|
+
readonly calls: number;
|
|
1824
|
+
readonly tokens: number;
|
|
1825
|
+
readonly bytes: number;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
/** Holds the execution declaration sealed before any trial begins. */
|
|
1829
|
+
declare interface StudyManifest {
|
|
1830
|
+
readonly id: string;
|
|
1831
|
+
readonly created: string;
|
|
1832
|
+
readonly definition: StudyDefinition;
|
|
1833
|
+
readonly scenarios: readonly StudyScenario[];
|
|
1834
|
+
readonly identity: StudyIdentity;
|
|
1835
|
+
readonly schedule: readonly StudyTrial[];
|
|
1836
|
+
readonly bounds: StudyBounds;
|
|
1837
|
+
readonly qualification: string | undefined;
|
|
1838
|
+
readonly host: Readonly<Record<string, string>>;
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
/** Handles validated transport requests at their owning domain boundary. */
|
|
1842
|
+
export declare type StudyMessageHandler = (operation: StudyOperation, value: JSONValue) => Promise<JSONValue>;
|
|
1843
|
+
|
|
1844
|
+
/** Holds the retained outcome of a scheduled goal. */
|
|
1845
|
+
declare interface StudyObservation {
|
|
1846
|
+
readonly goal: string;
|
|
1847
|
+
readonly product: StudyProduct | undefined;
|
|
1848
|
+
readonly failure: StudyFailure | undefined;
|
|
1849
|
+
readonly usage: readonly StudyUsage[];
|
|
1850
|
+
readonly duration: number;
|
|
1851
|
+
/** Records whether the engine dispatched the goal to the session; never inferred from product, usage, duration or failure. */
|
|
1852
|
+
readonly executed: boolean;
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
/** Holds one active goal's accounting and attribution. */
|
|
1856
|
+
export declare interface StudyOllamaActivity {
|
|
1857
|
+
readonly goal: string;
|
|
1858
|
+
readonly context: StudyContext;
|
|
1859
|
+
/** Holds the owned public view retained with the goal's first model dispatch; undefined retains neither it nor request bodies. */
|
|
1860
|
+
readonly checkpoint: JSONValue | undefined;
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
/** Pins one served model identity the inventory verifies. */
|
|
1864
|
+
export declare interface StudyOllamaModel {
|
|
1865
|
+
readonly name: string;
|
|
1866
|
+
readonly digest: string;
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
/**
|
|
1870
|
+
* Holds the Ollama provider options one role's declared policy determines.
|
|
1871
|
+
* @remarks
|
|
1872
|
+
* `truncate` and `shift` are present, and `false`, only when the policy is strict; the policy's
|
|
1873
|
+
* `length` allowance is transport-only and projects nothing.
|
|
1874
|
+
*/
|
|
1875
|
+
export declare type StudyOllamaOptions = Pick<OllamaOptions, 'model' | 'think' | 'options' | 'truncate' | 'shift'>;
|
|
1876
|
+
|
|
1877
|
+
/**
|
|
1878
|
+
* Declares one model role's exact wire policy.
|
|
1879
|
+
* @remarks
|
|
1880
|
+
* `model` names the served model the role dispatches to; the inventory must pin it. `options`
|
|
1881
|
+
* mirrors the Ollama `options` object the role must send exactly, and its `num_predict` member
|
|
1882
|
+
* is the role's output allowance. `think`: if `true`, a chat request may enable `think`; if
|
|
1883
|
+
* `false`, it must send `think: false`. `strict`: if `true`, a chat request must carry the Ollama
|
|
1884
|
+
* `truncate` and `shift` fields as `false`; if `false`, neither field is read. `length`: if
|
|
1885
|
+
* `true`, a `length` finish is the declared completion and generation may reach its allowance;
|
|
1886
|
+
* if `false`, either is a capacity refusal. The `judge` role dispatches the raw generate wire,
|
|
1887
|
+
* which carries no strict fields.
|
|
1888
|
+
*/
|
|
1889
|
+
export declare interface StudyOllamaPolicy {
|
|
1890
|
+
readonly model: string;
|
|
1891
|
+
readonly options: Readonly<Record<string, number>>;
|
|
1892
|
+
readonly think: boolean;
|
|
1893
|
+
readonly strict: boolean;
|
|
1894
|
+
readonly length: boolean;
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
/** Holds validated wire dispatch facts without retaining payload text. */
|
|
1898
|
+
export declare interface StudyOllamaRequest {
|
|
1899
|
+
readonly role: StudyRole;
|
|
1900
|
+
readonly path: string;
|
|
1901
|
+
readonly model: string | undefined;
|
|
1902
|
+
readonly output: number;
|
|
1903
|
+
readonly bytes: number;
|
|
1904
|
+
readonly options: Readonly<Record<string, number>>;
|
|
1905
|
+
/** Reports whether the request's native `truncate` and `shift` fields were verified false. */
|
|
1906
|
+
readonly strict: boolean;
|
|
1907
|
+
/** Reports whether the declared policy admits a `length` finish. */
|
|
1908
|
+
readonly length: boolean;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
/**
|
|
1912
|
+
* Names the model roles an Ollama study transport dispatches under a declared policy.
|
|
1913
|
+
* @remarks
|
|
1914
|
+
* Inventory and metadata reads use the `metadata` role and need no policy.
|
|
1915
|
+
*/
|
|
1916
|
+
export declare type StudyOllamaRole = Extract<StudyRole, 'agent' | 'summary' | 'judge'>;
|
|
1917
|
+
|
|
1918
|
+
/**
|
|
1919
|
+
* Holds one outbound request's facts as owned at admission.
|
|
1920
|
+
* @remarks
|
|
1921
|
+
* `url` is the caller's URL spelling and `init` carries a copy of the caller's accepted settings
|
|
1922
|
+
* with owned headers; the caller's `signal` keeps its live identity. `dispatch` is a copy of the
|
|
1923
|
+
* caller's canonical dispatch. Later caller mutation changes none of them.
|
|
1924
|
+
*/
|
|
1925
|
+
export declare interface StudyOllamaSnapshot {
|
|
1926
|
+
readonly url: string;
|
|
1927
|
+
readonly init: RequestInit | undefined;
|
|
1928
|
+
readonly dispatch: StudyAgentDispatch | undefined;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
/** Holds a validated terminal's finish reason and actual usage, unknown when unreported. */
|
|
1932
|
+
export declare interface StudyOllamaTerminal {
|
|
1933
|
+
readonly prompt: number | undefined;
|
|
1934
|
+
readonly completion: number | undefined;
|
|
1935
|
+
readonly reason: string;
|
|
1936
|
+
}
|
|
1937
|
+
|
|
1938
|
+
/** Admits and accounts Ollama wire requests under declared policies and latches failure. */
|
|
1939
|
+
export declare class StudyOllamaTransport implements StudyLatchInterface {
|
|
1940
|
+
#private;
|
|
1941
|
+
/** Records immutable transport bounds and refuses a role policy the inventory cannot serve.
|
|
1942
|
+
* @param options - Origin, room, request limit, pinned inventory, role policies, and cancellation.
|
|
1943
|
+
*/
|
|
1944
|
+
constructor(options: StudyOllamaTransportOptions);
|
|
1945
|
+
/** Binds subsequent wire requests to one live goal until `clear` or `close` ends it.
|
|
1946
|
+
* @param activity - The goal's accounting boundary.
|
|
1947
|
+
* @throws StudyError - Thrown with code `FAULT` when a model response is still open or a goal is still bound; the bound goal stays bound.
|
|
1948
|
+
* @throws unknown - Thrown with the retained failure or the cancellation reason, as `check` throws it.
|
|
1949
|
+
*/
|
|
1950
|
+
prepare(activity: StudyOllamaActivity): void;
|
|
1951
|
+
/** Ends the bound goal so another goal can be prepared; a request already admitted keeps its own goal.
|
|
1952
|
+
* @returns Nothing; a transport with no bound goal stays unbound, and a closed transport stays closed.
|
|
1953
|
+
*/
|
|
1954
|
+
clear(): void;
|
|
1955
|
+
/** Refuses work after any retained failure or cancellation.
|
|
1956
|
+
* @returns Nothing when work may continue.
|
|
1957
|
+
*/
|
|
1958
|
+
check(): void;
|
|
1959
|
+
/** Retains an operational failure even when an inner runtime catches it.
|
|
1960
|
+
* @param error - The observed failure; the first retained failure keeps its identity, and a branded `BudgetError` retains nothing because Agent reports that stop in its own result.
|
|
1961
|
+
*/
|
|
1962
|
+
fail(error: unknown): void;
|
|
1963
|
+
/** Checks every pinned serving identity through admitted inventory and metadata requests.
|
|
1964
|
+
* @returns Completion after inventory validation and support evidence.
|
|
1965
|
+
* @throws StudyError - Thrown with code `FAULT` when no goal is bound; the transport retains this refusal as its failure, as it retains every verification failure.
|
|
1966
|
+
*/
|
|
1967
|
+
verify(): Promise<void>;
|
|
1968
|
+
/** Dispatches exactly one admitted request with bounded streaming reads.
|
|
1969
|
+
* @param role - The accountable responsibility.
|
|
1970
|
+
* @param input - The exact configured URL.
|
|
1971
|
+
* @param init - The native fetch settings.
|
|
1972
|
+
* @param original - The immutable canonical dispatch the caller measured for this request; it joins the observation rows and never changes the request.
|
|
1973
|
+
* @returns A validated streaming response.
|
|
1974
|
+
* @throws StudyError - Thrown with code `FAULT` when no goal is bound, before admission and without retaining a failure.
|
|
1975
|
+
* @throws StudyError - Thrown with the recognized provider failure or a role-attributed `FAULT` for a non-2xx response, after its bounded body was read and its request accounted once.
|
|
1976
|
+
*/
|
|
1977
|
+
fetch(role: StudyRole, input: string | URL | Request, init?: RequestInit, original?: StudyAgentDispatch): Promise<Response>;
|
|
1978
|
+
/** Cancels every outstanding native reader and permanently closes the transport.
|
|
1979
|
+
* @returns Completion after finite native cancellation.
|
|
1980
|
+
*/
|
|
1981
|
+
close(): Promise<void>;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
/**
|
|
1985
|
+
* Holds the Ollama study transport's immutable configuration.
|
|
1986
|
+
* @remarks
|
|
1987
|
+
* `url` is the admitted daemon origin. `room` supplies the context the transport reserves and the
|
|
1988
|
+
* safety margin it keeps. `limit` bounds each request's duration and encoded bytes. `models` pins
|
|
1989
|
+
* the served identities, keyed by the label their inventory evidence carries. `roles` declares the
|
|
1990
|
+
* wire policy of every model role the consumer dispatches; an undeclared role is refused.
|
|
1991
|
+
* `signal` cancels all work. `observe`: if `true`, existing evidence rows gain passive timing and
|
|
1992
|
+
* correlation fields; if `false`, they carry none. `timing` extracts daemon timing; the selected Ollama runtime supplies the extractor and the transport imports none.
|
|
1993
|
+
*/
|
|
1994
|
+
export declare interface StudyOllamaTransportOptions {
|
|
1995
|
+
readonly url: string;
|
|
1996
|
+
readonly room: Pick<StudyRoom, 'context' | 'safety'>;
|
|
1997
|
+
readonly limit: Pick<StudyLimit, 'duration' | 'bytes'>;
|
|
1998
|
+
readonly models: Readonly<Record<string, StudyOllamaModel>>;
|
|
1999
|
+
readonly roles: Readonly<Partial<Record<StudyOllamaRole, StudyOllamaPolicy>>>;
|
|
2000
|
+
readonly signal: AbortSignal;
|
|
2001
|
+
readonly observe: boolean;
|
|
2002
|
+
readonly timing: typeof extractTiming;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
/** Tracks one owned HTTP response until its end or cancellation. */
|
|
2006
|
+
export declare interface StudyOllamaWire {
|
|
2007
|
+
readonly activity: StudyOllamaActivity;
|
|
2008
|
+
readonly request: StudyOllamaRequest;
|
|
2009
|
+
readonly ticket: StudyTicket;
|
|
2010
|
+
readonly signal: AbortSignal;
|
|
2011
|
+
readonly reader: ReadableStreamDefaultReader<Uint8Array>;
|
|
2012
|
+
readonly decoder: TextDecoder;
|
|
2013
|
+
/** Holds the HTTP status the daemon answered with. */
|
|
2014
|
+
readonly status: number;
|
|
2015
|
+
readonly started: number;
|
|
2016
|
+
/** Holds the trial-local request id. */
|
|
2017
|
+
readonly id: number;
|
|
2018
|
+
/** Holds the monotonic millisecond reading taken immediately before native fetch. */
|
|
2019
|
+
readonly sent: number;
|
|
2020
|
+
/** Holds the canonical dispatch this wire request was made for, when the caller measured one. */
|
|
2021
|
+
readonly dispatch: StudyAgentDispatch | undefined;
|
|
2022
|
+
/** Holds the encoded request bytes plus every response byte counted so far. */
|
|
2023
|
+
readonly bytes: number;
|
|
2024
|
+
/** Holds the decoded response text not yet consumed as complete rows. */
|
|
2025
|
+
readonly text: string;
|
|
2026
|
+
readonly terminal: StudyOllamaTerminal | undefined;
|
|
2027
|
+
/** Holds the daemon timing of the terminal row once observed. */
|
|
2028
|
+
readonly timing: OllamaTiming | undefined;
|
|
2029
|
+
/** Reports whether the request was accounted, finished or failed. */
|
|
2030
|
+
readonly settled: boolean;
|
|
2031
|
+
}
|
|
2032
|
+
|
|
2033
|
+
/** Names the bounded transport's domain operations. */
|
|
2034
|
+
export declare type StudyOperation = 'open' | 'goal' | 'close' | 'admit' | 'finish' | 'fail' | 'evidence';
|
|
2035
|
+
|
|
2036
|
+
/** Holds exact neutral public packet bytes and private mapping bytes. */
|
|
2037
|
+
export declare interface StudyPacketBundle {
|
|
2038
|
+
readonly content: Uint8Array;
|
|
2039
|
+
readonly mapping: Uint8Array;
|
|
2040
|
+
}
|
|
2041
|
+
|
|
2042
|
+
/** Holds one neutral semantic grading input without treatment or model identifiers. */
|
|
2043
|
+
export declare interface StudyPacketEntry {
|
|
2044
|
+
readonly trial: string;
|
|
2045
|
+
readonly criterion: string;
|
|
2046
|
+
readonly input: JSONValue;
|
|
2047
|
+
readonly product: StudyProduct | undefined;
|
|
2048
|
+
readonly assertion: JSONValue;
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
/** Holds the neutral identity mapping to a sealed semantic trial-criterion pair. */
|
|
2052
|
+
export declare interface StudyPacketLink {
|
|
2053
|
+
readonly trial: string;
|
|
2054
|
+
readonly criterion: string;
|
|
2055
|
+
readonly source: {
|
|
2056
|
+
readonly trial: string;
|
|
2057
|
+
readonly criterion: string;
|
|
2058
|
+
};
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
/** Holds an authoritative parent ticket and its transport listener lifetime. */
|
|
2062
|
+
export declare interface StudyParentTicket {
|
|
2063
|
+
readonly ticket: StudyTicket;
|
|
2064
|
+
readonly listeners: AbortController;
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
/** Holds checked public declarations and reproducible executable identities. */
|
|
2068
|
+
export declare interface StudyPreparation {
|
|
2069
|
+
readonly directory: string;
|
|
2070
|
+
readonly definition: StudyDefinition;
|
|
2071
|
+
readonly scenarios: readonly StudyScenario[];
|
|
2072
|
+
readonly rubric: StudyRubric;
|
|
2073
|
+
readonly profile: StudyProfile;
|
|
2074
|
+
readonly identity: StudyIdentity;
|
|
2075
|
+
readonly artifacts: StudyArtifactLoader;
|
|
2076
|
+
readonly source: string;
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
/** Opens one fresh native child for each scheduled trial. */
|
|
2080
|
+
export declare class StudyProcessDriver implements StudyDriverInterface {
|
|
2081
|
+
#private;
|
|
2082
|
+
/** Owns immutable resolved launch settings.
|
|
2083
|
+
* @param options - Built entry, admitted identities and exclusive scratch parent.
|
|
2084
|
+
*/
|
|
2085
|
+
constructor(options: StudyProcessOptions);
|
|
2086
|
+
/** Opens isolated child state and waits for its verified readiness.
|
|
2087
|
+
* @param trial - The public scheduled trial.
|
|
2088
|
+
* @param signal - Authoritative parent cancellation.
|
|
2089
|
+
* @returns A ready process-backed session.
|
|
2090
|
+
*/
|
|
2091
|
+
open(trial: StudyTrial, signal: AbortSignal): Promise<StudySessionInterface>;
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
/** Holds one goal's parent context and the worker admission sequence it issues while the goal runs.
|
|
2095
|
+
* @example Issue worker admissions in sequence
|
|
2096
|
+
* ```ts
|
|
2097
|
+
* import type { StudyContext } from '@orkestrel/study'
|
|
2098
|
+
* import { StudyProcessGoal } from '@orkestrel/study/server'
|
|
2099
|
+
*
|
|
2100
|
+
* declare const context: StudyContext
|
|
2101
|
+
*
|
|
2102
|
+
* const goal = new StudyProcessGoal(context)
|
|
2103
|
+
* goal.issue(2) // undefined
|
|
2104
|
+
* goal.issue(1) // 1
|
|
2105
|
+
* goal.issue(1) // undefined
|
|
2106
|
+
* goal.issue(2) // 2
|
|
2107
|
+
* ```
|
|
2108
|
+
*/
|
|
2109
|
+
export declare class StudyProcessGoal {
|
|
2110
|
+
#private;
|
|
2111
|
+
/** Binds one goal to the parent meter and evidence sink it runs under.
|
|
2112
|
+
* @param context - The actual parent meter, evidence sink and cancellation of the goal.
|
|
2113
|
+
*/
|
|
2114
|
+
constructor(context: StudyContext);
|
|
2115
|
+
/** Reports the parent meter and evidence sink the goal runs under. */
|
|
2116
|
+
get context(): StudyContext;
|
|
2117
|
+
/** Issues the identifier of the next worker admission when the worker asked for exactly that one.
|
|
2118
|
+
* @param requested - The identifier the worker supplied.
|
|
2119
|
+
* @returns The issued identifier, or undefined when the requested one is not the next in sequence.
|
|
2120
|
+
*/
|
|
2121
|
+
issue(requested: unknown): number | undefined;
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
/** Holds the parent-owned fresh trial process configuration. */
|
|
2125
|
+
export declare interface StudyProcessOptions extends StudyArtifactLoaderOptions {
|
|
2126
|
+
readonly identity: StudyIdentity;
|
|
2127
|
+
readonly driver: string;
|
|
2128
|
+
readonly directory: string;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
/** Keeps admission and evidence custody in the parent of one fresh trial process. */
|
|
2132
|
+
export declare class StudyProcessSession implements StudySessionInterface {
|
|
2133
|
+
#private;
|
|
2134
|
+
/** Owns one trial's process lifecycle without starting host work.
|
|
2135
|
+
* @param options - Public trial and process configuration; the configuration is snapshotted while the borrowed signal keeps its identity.
|
|
2136
|
+
*/
|
|
2137
|
+
constructor(options: StudyProcessSessionOptions);
|
|
2138
|
+
/** Starts the child and verifies its artifact-bound readiness. */
|
|
2139
|
+
start(): Promise<void>;
|
|
2140
|
+
/** Runs one ordered goal through parent-authorized requests and acknowledged evidence.
|
|
2141
|
+
* @param goal - Public goal without grading truth.
|
|
2142
|
+
* @param context - Actual parent meter and evidence sink.
|
|
2143
|
+
* @returns The retained child product after every admitted operation settles.
|
|
2144
|
+
*/
|
|
2145
|
+
execute(goal: StudyGoal, context: StudyContext): Promise<StudyProduct>;
|
|
2146
|
+
/** Requests verified cleanup, then terminates only this recorded process tree. */
|
|
2147
|
+
close(): Promise<void>;
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
/** Holds one fresh child trial's launch parameters and cancellation. */
|
|
2151
|
+
export declare interface StudyProcessSessionOptions extends StudyProcessOptions {
|
|
2152
|
+
readonly trial: StudyTrial;
|
|
2153
|
+
readonly signal: AbortSignal;
|
|
2154
|
+
}
|
|
2155
|
+
|
|
2156
|
+
/** Holds observed output and partial completion, never self-awarded success. */
|
|
2157
|
+
declare interface StudyProduct {
|
|
2158
|
+
readonly value: JSONValue;
|
|
2159
|
+
readonly partial: boolean;
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
/** Holds execution settings independently of scenario and grading declarations. */
|
|
2163
|
+
declare interface StudyProfile {
|
|
2164
|
+
readonly name: string;
|
|
2165
|
+
/** Selects the Agent runtime entry, independently of the package under study. */
|
|
2166
|
+
readonly agent: string;
|
|
2167
|
+
/** Selects the entry of the package under study; it can equal the Agent entry. */
|
|
2168
|
+
readonly subject: string;
|
|
2169
|
+
readonly roots: readonly string[];
|
|
2170
|
+
readonly bounds: StudyBounds;
|
|
2171
|
+
readonly room: StudyRoom;
|
|
2172
|
+
readonly provider: StudyProvider | undefined;
|
|
2173
|
+
readonly qualification: string | undefined;
|
|
2174
|
+
/** Holds driver-owned JSON; the driver owns its interpretation and Study only validates and owns the object. */
|
|
2175
|
+
readonly settings: Readonly<Record<string, JSONValue>> | undefined;
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
/** Holds caller-selected provider artifacts and model identities. */
|
|
2179
|
+
declare interface StudyProvider {
|
|
2180
|
+
readonly entry: string;
|
|
2181
|
+
readonly url: string;
|
|
2182
|
+
readonly model: string;
|
|
2183
|
+
/** Names the judge model; declared together with its digest or both absent. */
|
|
2184
|
+
readonly judge: string | undefined;
|
|
2185
|
+
/** Pins the serving inventory independently of mutable model names. */
|
|
2186
|
+
readonly digest: {
|
|
2187
|
+
readonly model: string;
|
|
2188
|
+
/** Pins the judge model; declared together with its name or both absent. */
|
|
2189
|
+
readonly judge: string | undefined;
|
|
2190
|
+
};
|
|
2191
|
+
}
|
|
2192
|
+
|
|
2193
|
+
/** Names the evidence a study can establish. */
|
|
2194
|
+
declare type StudyPurpose = 'mechanism' | 'quality' | 'capacity';
|
|
2195
|
+
|
|
2196
|
+
/** Cites a retained trial file, or one evidence row of it by its zero-based position. */
|
|
2197
|
+
export declare interface StudyReference {
|
|
2198
|
+
readonly file: StudyReferenceFile;
|
|
2199
|
+
/** Selects one retained evidence row; the cited string carries its one-based position. Valid only for the evidence file. */
|
|
2200
|
+
readonly row?: number;
|
|
2201
|
+
}
|
|
2202
|
+
|
|
2203
|
+
/** Names a retained file of one trial that a judgment cites. */
|
|
2204
|
+
export declare type StudyReferenceFile = 'attempt' | 'evidence';
|
|
2205
|
+
|
|
2206
|
+
/** Waits for authoritative parent admission and drains acknowledged settlements. */
|
|
2207
|
+
export declare class StudyRemoteMeter implements StudyRemoteMeterInterface {
|
|
2208
|
+
#private;
|
|
2209
|
+
/** Owns one goal's transported tickets without local budget decisions.
|
|
2210
|
+
* @param options - Parent transport and shared worker failure control, snapshotted at construction.
|
|
2211
|
+
*/
|
|
2212
|
+
constructor(options: StudyRemoteMeterOptions);
|
|
2213
|
+
get signal(): AbortSignal;
|
|
2214
|
+
get usage(): readonly StudyUsage[];
|
|
2215
|
+
/** Requests and awaits the parent's dispatch grant.
|
|
2216
|
+
* @param charge - Upper bounds that the parent reserves before replying.
|
|
2217
|
+
* @returns A ticket only after authoritative admission succeeds.
|
|
2218
|
+
*/
|
|
2219
|
+
admit(charge: StudyCharge): Promise<StudyTicket>;
|
|
2220
|
+
/** Propagates the parent's ticket cancellation without changing its cause.
|
|
2221
|
+
* @param id - Parent-issued ticket identity.
|
|
2222
|
+
* @param failure - Authoritative parent attribution.
|
|
2223
|
+
*/
|
|
2224
|
+
abort(id: number, failure: StudyFailure): void;
|
|
2225
|
+
/** Closes admission and requires every ticket and acknowledgment to finish. */
|
|
2226
|
+
close(): Promise<void>;
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
/** Owns transported admission, parent cancellation, and settlement drainage. */
|
|
2230
|
+
export declare interface StudyRemoteMeterInterface extends StudyAdmissionInterface {
|
|
2231
|
+
/** Propagates the parent's ticket cancellation without changing its cause.
|
|
2232
|
+
* @param id - The parent-issued ticket identity.
|
|
2233
|
+
* @param failure - The authoritative parent attribution.
|
|
2234
|
+
* @returns Nothing after cancellation propagation.
|
|
2235
|
+
*/
|
|
2236
|
+
abort(id: number, failure: StudyFailure): void;
|
|
2237
|
+
/** Closes admission and requires every ticket and acknowledgment to finish.
|
|
2238
|
+
* @returns A promise that resolves after acknowledged settlements drain.
|
|
2239
|
+
*/
|
|
2240
|
+
close(): Promise<void>;
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
/** Holds the worker meter's parent-authorized transport and failure latch. */
|
|
2244
|
+
export declare interface StudyRemoteMeterOptions {
|
|
2245
|
+
readonly channel: StudyChannel;
|
|
2246
|
+
readonly control: StudyControl;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
/** Transmits one settlement without inventing local admission authority. */
|
|
2250
|
+
export declare class StudyRemoteTicket implements StudyTicket {
|
|
2251
|
+
#private;
|
|
2252
|
+
/** Owns the parent's ticket identity and composed cancellation.
|
|
2253
|
+
* @param options - Transported ticket state and settlement callback, snapshotted at construction.
|
|
2254
|
+
*/
|
|
2255
|
+
constructor(options: StudyRemoteTicketOptions);
|
|
2256
|
+
get signal(): AbortSignal;
|
|
2257
|
+
get settled(): boolean;
|
|
2258
|
+
/** Sends actual usage for authoritative parent settlement.
|
|
2259
|
+
* @param usage - Actual measured request usage.
|
|
2260
|
+
*/
|
|
2261
|
+
finish(usage: StudyUsage): void;
|
|
2262
|
+
/** Sends operational failure while preserving unknown actual cost.
|
|
2263
|
+
* @param failure - The first observed request failure.
|
|
2264
|
+
*/
|
|
2265
|
+
fail(failure: StudyFailure): void;
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2268
|
+
/** Holds one transported ticket's identity and settlement owner. */
|
|
2269
|
+
export declare interface StudyRemoteTicketOptions {
|
|
2270
|
+
readonly id: number;
|
|
2271
|
+
readonly signal: AbortSignal;
|
|
2272
|
+
readonly settle: (operation: 'finish' | 'fail', value: StudyUsage | StudyFailure) => void;
|
|
2273
|
+
}
|
|
2274
|
+
|
|
2275
|
+
/** Holds a selected immutable report request. */
|
|
2276
|
+
export declare interface StudyReportRequest {
|
|
2277
|
+
readonly command: 'report';
|
|
2278
|
+
readonly target: string;
|
|
2279
|
+
readonly grading: string;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
/** Holds an outstanding bounded IPC response. */
|
|
2283
|
+
export declare interface StudyResponse {
|
|
2284
|
+
readonly resolve: (value: JSONValue) => void;
|
|
2285
|
+
readonly reject: (error: unknown) => void;
|
|
2286
|
+
}
|
|
2287
|
+
|
|
2288
|
+
/** Holds an offline execution reading discriminated by custody completeness. */
|
|
2289
|
+
export declare type StudyResultReading = StudyInterruptedResult | StudySealedResult;
|
|
2290
|
+
|
|
2291
|
+
/** Owns append-only execution bytes and seals only a complete terminal population. */
|
|
2292
|
+
export declare class StudyResultStore implements StudyResultStoreInterface {
|
|
2293
|
+
#private;
|
|
2294
|
+
/**
|
|
2295
|
+
* Owns a validated manifest snapshot without creating any files.
|
|
2296
|
+
* @param options - The new result directory and execution declaration
|
|
2297
|
+
* @throws StudyError - Thrown when the manifest is invalid
|
|
2298
|
+
*/
|
|
2299
|
+
constructor(options: StudyResultStoreOptions);
|
|
2300
|
+
/**
|
|
2301
|
+
* Exclusively creates the result directory and initial manifest bytes.
|
|
2302
|
+
* @returns Nothing after the manifest is synchronized
|
|
2303
|
+
* @throws StudyError - Thrown when creation repeats or custody bounds are exceeded
|
|
2304
|
+
*/
|
|
2305
|
+
create(): Promise<void>;
|
|
2306
|
+
/**
|
|
2307
|
+
* Exclusively creates the evidence sink for an exact scheduled trial.
|
|
2308
|
+
* @param trial - The scheduled trajectory
|
|
2309
|
+
* @returns The bounded append-only sink
|
|
2310
|
+
* @throws StudyError - Thrown when the trial is foreign, repeated, or late
|
|
2311
|
+
*/
|
|
2312
|
+
start(trial: StudyTrial): Promise<StudySinkInterface>;
|
|
2313
|
+
/**
|
|
2314
|
+
* Closes evidence admission, drains admitted appends, and writes a terminal record.
|
|
2315
|
+
* @param attempt - The complete scheduled goal horizon
|
|
2316
|
+
* @returns Nothing after the terminal record is synchronized
|
|
2317
|
+
* @throws StudyError - Thrown when the terminal record is invalid, repeated, or late
|
|
2318
|
+
*/
|
|
2319
|
+
finish(attempt: StudyAttempt): Promise<void>;
|
|
2320
|
+
/**
|
|
2321
|
+
* Seals exact execution inventory after every scheduled trial has terminated.
|
|
2322
|
+
* @returns The immutable deterministic execution seal
|
|
2323
|
+
* @throws StudyError - Thrown when custody is incomplete, invalid, or already sealed
|
|
2324
|
+
*/
|
|
2325
|
+
seal(): Promise<StudySeal>;
|
|
2326
|
+
}
|
|
2327
|
+
|
|
2328
|
+
/** Owns execution custody from exclusive creation through complete sealing. */
|
|
2329
|
+
export declare interface StudyResultStoreInterface extends StudyStoreInterface {
|
|
2330
|
+
/** Exclusively creates the result directory and initial manifest bytes.
|
|
2331
|
+
* @returns A promise that resolves after the manifest is synchronized.
|
|
2332
|
+
*/
|
|
2333
|
+
create(): Promise<void>;
|
|
2334
|
+
/** Seals a complete terminal population with its exact execution-byte inventory.
|
|
2335
|
+
* @returns The synchronized execution seal.
|
|
2336
|
+
*/
|
|
2337
|
+
seal(): Promise<StudySeal>;
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
/** Holds the inert execution store configuration. */
|
|
2341
|
+
export declare interface StudyResultStoreOptions {
|
|
2342
|
+
readonly directory: string;
|
|
2343
|
+
readonly manifest: StudyManifest;
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
/** Names a request's measured responsibility. */
|
|
2347
|
+
declare type StudyRole = 'agent' | 'judge' | 'summary' | 'metadata' | 'tool';
|
|
2348
|
+
|
|
2349
|
+
/** Holds the model context and generation allowance as separate measurements. */
|
|
2350
|
+
declare interface StudyRoom {
|
|
2351
|
+
readonly context: number;
|
|
2352
|
+
readonly output: number;
|
|
2353
|
+
readonly safety: number;
|
|
2354
|
+
/** Declares the recap allowance; absent when the workflow produces no recap. */
|
|
2355
|
+
readonly recap: number | undefined;
|
|
2356
|
+
readonly think: boolean;
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
/** Holds a versioned grading declaration independently of execution. */
|
|
2360
|
+
declare interface StudyRubric {
|
|
2361
|
+
readonly version: string;
|
|
2362
|
+
readonly criteria: readonly StudyCriterion[];
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
/** Holds ordered goals sharing state within an isolated trial. */
|
|
2366
|
+
declare interface StudyScenario {
|
|
2367
|
+
readonly id: string;
|
|
2368
|
+
readonly goals: readonly StudyGoal[];
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
/** Holds a complete execution inventory and its deterministic identity. */
|
|
2372
|
+
export declare interface StudySeal {
|
|
2373
|
+
readonly result: string;
|
|
2374
|
+
readonly id: string;
|
|
2375
|
+
readonly files: readonly StudyFile[];
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
/** Holds independently verified sealed execution bytes. */
|
|
2379
|
+
export declare interface StudySealedResult {
|
|
2380
|
+
readonly status: 'sealed';
|
|
2381
|
+
readonly directory: string;
|
|
2382
|
+
readonly manifest: StudyManifest;
|
|
2383
|
+
readonly attempts: readonly StudyAttempt[];
|
|
2384
|
+
readonly seal: StudySeal;
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2387
|
+
/** Owns domain state across a trial and releases it before the next trial. */
|
|
2388
|
+
declare interface StudySessionInterface {
|
|
2389
|
+
/** Executes one public goal against the trial's retained domain state.
|
|
2390
|
+
* @param goal - The declared public input.
|
|
2391
|
+
* @param context - Cancellation, borrowed admission, and evidence custody.
|
|
2392
|
+
* @returns The observed product without a task verdict.
|
|
2393
|
+
*/
|
|
2394
|
+
execute(goal: StudyGoal, context: StudyContext): Promise<StudyProduct>;
|
|
2395
|
+
/** Releases the trial's domain resources.
|
|
2396
|
+
* @returns A promise that resolves after release.
|
|
2397
|
+
*/
|
|
2398
|
+
close(): Promise<void>;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
/** Holds an evidence sink whose implementation owns byte limits and custody. */
|
|
2402
|
+
declare interface StudySinkInterface {
|
|
2403
|
+
/** Appends bounded domain evidence to the owned execution record.
|
|
2404
|
+
* @param evidence - The public evidence for a declared goal.
|
|
2405
|
+
* @returns A promise that resolves when custody accepts the bytes.
|
|
2406
|
+
*/
|
|
2407
|
+
append(evidence: StudyEvidence): Promise<void>;
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
/**
|
|
2411
|
+
* Holds the ceiling that stopped a run and the readings it crossed.
|
|
2412
|
+
* @remarks
|
|
2413
|
+
* `id` names the ceiling: a Study label and quantity such as `Goal tokens`, an Agent budget's trace
|
|
2414
|
+
* id, or the provider option that capped the model such as `num_predict`. `max` is the ceiling and
|
|
2415
|
+
* `consumed` the tally at the crossing, the refused charge included; each is undefined when its
|
|
2416
|
+
* source reports none. On the `model` layer `max` is the cap and `consumed` the completion or prompt.
|
|
2417
|
+
* Finite foreign readings retain their source values, including negative and fractional values.
|
|
2418
|
+
*/
|
|
2419
|
+
declare interface StudyStop {
|
|
2420
|
+
readonly layer: StudyLayer;
|
|
2421
|
+
readonly id: string;
|
|
2422
|
+
readonly max: number | undefined;
|
|
2423
|
+
readonly consumed: number | undefined;
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
/** Appends terminal records without overwriting a prior attempt. */
|
|
2427
|
+
declare interface StudyStoreInterface {
|
|
2428
|
+
/** Opens append-only evidence custody for one scheduled trial.
|
|
2429
|
+
* @param trial - The exact scheduled trial.
|
|
2430
|
+
* @returns The borrowed evidence sink.
|
|
2431
|
+
*/
|
|
2432
|
+
start(trial: StudyTrial): Promise<StudySinkInterface>;
|
|
2433
|
+
/** Retains the terminal record for one scheduled trial.
|
|
2434
|
+
* @param attempt - The complete scheduled goal horizon.
|
|
2435
|
+
* @returns A promise that resolves after custody retains the record.
|
|
2436
|
+
*/
|
|
2437
|
+
finish(attempt: StudyAttempt): Promise<void>;
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
/** Bounds adapter evaluation by an independent native parent timer. */
|
|
2441
|
+
export declare class StudyTask {
|
|
2442
|
+
#private;
|
|
2443
|
+
/** Owns the built child route and captured source selection.
|
|
2444
|
+
* @param options - Consumer root, runtime entry, adapter, and admitted dependencies.
|
|
2445
|
+
*/
|
|
2446
|
+
constructor(options: StudyTaskOptions);
|
|
2447
|
+
/** Executes one validation or grading operation in a fresh child.
|
|
2448
|
+
* @param request - Declarations or retained evidence, never a trial payload.
|
|
2449
|
+
* @param signal - Caller cancellation.
|
|
2450
|
+
* @returns Verified adapter output and active instrumentation identity.
|
|
2451
|
+
*/
|
|
2452
|
+
execute(request: StudyTaskRequest, signal: AbortSignal): Promise<StudyTaskResult>;
|
|
2453
|
+
}
|
|
2454
|
+
|
|
2455
|
+
/** Holds a bounded adapter-only native operation. */
|
|
2456
|
+
export declare interface StudyTaskOptions {
|
|
2457
|
+
readonly entry: string;
|
|
2458
|
+
readonly root: string;
|
|
2459
|
+
readonly adapter: string;
|
|
2460
|
+
readonly roots: readonly string[];
|
|
2461
|
+
readonly duration?: number;
|
|
2462
|
+
}
|
|
2463
|
+
|
|
2464
|
+
/** Carries only declarations or sealed evidence to an adapter child. */
|
|
2465
|
+
export declare type StudyTaskRequest = {
|
|
2466
|
+
readonly operation: 'validate';
|
|
2467
|
+
readonly input: StudyValidation;
|
|
2468
|
+
} | {
|
|
2469
|
+
readonly operation: 'grade';
|
|
2470
|
+
readonly input: StudyAdjudication;
|
|
2471
|
+
};
|
|
2472
|
+
|
|
2473
|
+
/** Returns adapter output with the exact active instrumentation digest. */
|
|
2474
|
+
export declare interface StudyTaskResult {
|
|
2475
|
+
readonly instrument: string;
|
|
2476
|
+
readonly value: JSONValue;
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
/** Evaluates only admitted instrumentation in a disposable native child. */
|
|
2480
|
+
export declare class StudyTaskWorker {
|
|
2481
|
+
#private;
|
|
2482
|
+
/** Processes exactly one inherited request and returns a bounded response. */
|
|
2483
|
+
execute(): Promise<void>;
|
|
2484
|
+
}
|
|
2485
|
+
|
|
2486
|
+
/** Holds one admitted request until its actual charge is recorded. */
|
|
2487
|
+
declare interface StudyTicket {
|
|
2488
|
+
readonly signal: AbortSignal;
|
|
2489
|
+
/** Reports whether this ticket already recorded its own settlement; an aborted signal does not establish it. */
|
|
2490
|
+
readonly settled: boolean;
|
|
2491
|
+
/** Records actual measurements for one admitted request.
|
|
2492
|
+
* @param usage - The request's measured charges.
|
|
2493
|
+
* @returns Nothing after settlement.
|
|
2494
|
+
*/
|
|
2495
|
+
finish(usage: StudyUsage): void;
|
|
2496
|
+
/** Records an attributable failure for one admitted request.
|
|
2497
|
+
* @param failure - The retained operational attribution.
|
|
2498
|
+
* @returns Nothing after failure propagation.
|
|
2499
|
+
*/
|
|
2500
|
+
fail(failure: StudyFailure): void;
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
/** Holds a scheduled trajectory, with a fresh state for each repetition and arm. */
|
|
2504
|
+
declare interface StudyTrial {
|
|
2505
|
+
readonly id: string;
|
|
2506
|
+
readonly scenario: string;
|
|
2507
|
+
readonly arm: string;
|
|
2508
|
+
readonly repetition: number;
|
|
2509
|
+
}
|
|
2510
|
+
|
|
2511
|
+
/** Holds the trial sink's admitted writes and terminal lifecycle. */
|
|
2512
|
+
export declare interface StudyTrialCustody {
|
|
2513
|
+
readonly sink: StudyCustodySinkInterface;
|
|
2514
|
+
readonly terminal: Promise<void> | undefined;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
/** Holds actual request measurements; absent token usage remains unknown. */
|
|
2518
|
+
declare interface StudyUsage {
|
|
2519
|
+
readonly role: StudyRole;
|
|
2520
|
+
readonly calls: number;
|
|
2521
|
+
readonly tokens: number | undefined;
|
|
2522
|
+
readonly bytes: number | undefined;
|
|
2523
|
+
readonly duration: number;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
/** Holds declarations for domain validation before agent, subject or provider execution. */
|
|
2527
|
+
export declare interface StudyValidation {
|
|
2528
|
+
readonly definition: StudyDefinition;
|
|
2529
|
+
readonly scenarios: readonly StudyScenario[];
|
|
2530
|
+
readonly rubric: StudyRubric;
|
|
2531
|
+
readonly profile: StudyProfile;
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
/** Executes one verified trial behind parent-authorized admission and custody. */
|
|
2535
|
+
export declare class StudyWorker {
|
|
2536
|
+
#private;
|
|
2537
|
+
/** Serves the inherited IPC channel until its parent disconnects.
|
|
2538
|
+
* @returns Completion after channel and acquired session cleanup.
|
|
2539
|
+
*/
|
|
2540
|
+
execute(): Promise<void>;
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2543
|
+
/** Terminates the recorded native process tree under a finite cleanup allowance.
|
|
2544
|
+
* @param child - The exclusively owned child process.
|
|
2545
|
+
*/
|
|
2546
|
+
export declare function terminateStudyChild(child: ChildProcess): void;
|
|
2547
|
+
|
|
2548
|
+
/**
|
|
2549
|
+
* Translates bound neutral imported labels through the sealed semantic horizon.
|
|
2550
|
+
* @param result - The verified sealed execution
|
|
2551
|
+
* @param rubric - The retained rubric
|
|
2552
|
+
* @param digest - The exact retained rubric-byte identity
|
|
2553
|
+
* @param labels - The original imported neutral labels
|
|
2554
|
+
* @returns Judgments translated to scheduled trial and criterion identities
|
|
2555
|
+
* @throws StudyError - Thrown when the packet or a label identity is foreign
|
|
2556
|
+
* @example
|
|
2557
|
+
* ```ts
|
|
2558
|
+
* translateStudyPacketLabeling(result, rubric, rubricDigest, labels)
|
|
2559
|
+
* ```
|
|
2560
|
+
*/
|
|
2561
|
+
export declare function translateStudyPacketLabeling(result: StudySealedResult, rubric: StudyRubric, digest: string, labels: StudyLabeling): readonly StudyJudgment[];
|
|
2562
|
+
|
|
2563
|
+
/**
|
|
2564
|
+
* Validates complete evidence lines and per-goal encoded evidence bounds.
|
|
2565
|
+
* @param bytes - The exact JSONL file
|
|
2566
|
+
* @param manifest - The bounds and scenario declarations
|
|
2567
|
+
* @param trial - The scheduled trial identity
|
|
2568
|
+
* @returns Nothing when evidence satisfies its custody contract
|
|
2569
|
+
* @throws StudyError - Thrown when evidence is partial, invalid, foreign, or oversized
|
|
2570
|
+
* @example
|
|
2571
|
+
* ```ts
|
|
2572
|
+
* validateStudyEvidenceBytes(bytes, manifest, trial)
|
|
2573
|
+
* ```
|
|
2574
|
+
*/
|
|
2575
|
+
export declare function validateStudyEvidenceBytes(bytes: Uint8Array, manifest: StudyManifest, trial: string): void;
|
|
2576
|
+
|
|
2577
|
+
/**
|
|
2578
|
+
* Checks terminal policy after the actual wire cost has been retained.
|
|
2579
|
+
* @param terminal - The valid terminal facts
|
|
2580
|
+
* @param room - The reserved context and safety margin
|
|
2581
|
+
* @param request - The admitted dispatch and its declared finish policy; every refusal retains its role
|
|
2582
|
+
* @returns Nothing when the completion satisfies the declared policy
|
|
2583
|
+
* @throws StudyError - Thrown with code `CAPACITY` when the actual prompt exceeds its room, generation exceeds its allowance, or an undeclared `length` finish or capped generation occurs; `FAULT` for another unsupported finish reason
|
|
2584
|
+
*/
|
|
2585
|
+
export declare function validateStudyOllamaCompletion(terminal: StudyOllamaTerminal, room: Pick<StudyRoom, 'context' | 'safety'>, request: StudyOllamaRequest): void;
|
|
2586
|
+
|
|
2587
|
+
/**
|
|
2588
|
+
* Verifies that each pinned name resolves to one inventory entry with its pinned digest.
|
|
2589
|
+
* @param value - The parsed inventory response
|
|
2590
|
+
* @param models - The pinned served identities
|
|
2591
|
+
* @returns Nothing for a matching inventory
|
|
2592
|
+
* @throws StudyError - Thrown with code `FAULT` when the inventory is unsupported or a pinned identity does not match
|
|
2593
|
+
*/
|
|
2594
|
+
export declare function validateStudyOllamaInventory(value: unknown, models: StudyOllamaTransportOptions['models']): void;
|
|
2595
|
+
|
|
2596
|
+
/**
|
|
2597
|
+
* Validates declared role policies against the pinned inventory before any dispatch.
|
|
2598
|
+
* @param roles - The declared wire policy of each model role
|
|
2599
|
+
* @param models - The pinned served identities
|
|
2600
|
+
* @returns Nothing when every policy names a pinned model and a positive output allowance
|
|
2601
|
+
* @throws StudyError - Thrown with code `CONFIG` when a policy names an unpinned model, declares no positive safe-integer `num_predict`, or makes the raw judge wire strict
|
|
2602
|
+
*/
|
|
2603
|
+
export declare function validateStudyOllamaRoles(roles: StudyOllamaTransportOptions['roles'], models: StudyOllamaTransportOptions['models']): void;
|
|
2604
|
+
|
|
2605
|
+
/** Refuses a profile that omits the actual host runtime's declared dependency bytes.
|
|
2606
|
+
* @param instrument - The canonical package owning the trusted runtime entry.
|
|
2607
|
+
* @param roots - Explicitly admitted package roots, including the instrument.
|
|
2608
|
+
*/
|
|
2609
|
+
export declare function validateStudyRuntime(instrument: string, roots: readonly string[]): void;
|
|
2610
|
+
|
|
2611
|
+
/** Projects optional domain fields into the JSON wire representation.
|
|
2612
|
+
* @param value - An owned domain value with optional undefined fields.
|
|
2613
|
+
* @returns A JSON-compatible snapshot.
|
|
2614
|
+
* @example Project a wire value
|
|
2615
|
+
* ```ts
|
|
2616
|
+
* import { valueToWire } from '@orkestrel/study/server'
|
|
2617
|
+
*
|
|
2618
|
+
* valueToWire({ state: 'ready', failure: undefined }) // { state: 'ready' }
|
|
2619
|
+
* ```
|
|
2620
|
+
*/
|
|
2621
|
+
export declare function valueToWire(value: unknown): JSONValue;
|
|
2622
|
+
|
|
2623
|
+
/**
|
|
2624
|
+
* Writes an exclusive regular record and synchronizes it before reporting success.
|
|
2625
|
+
* @param path - The new custody path
|
|
2626
|
+
* @param bytes - The exact encoded record
|
|
2627
|
+
* @returns Nothing after the record is synchronized
|
|
2628
|
+
* @example
|
|
2629
|
+
* ```ts
|
|
2630
|
+
* await writeStudyBytes(path, bytes)
|
|
2631
|
+
* ```
|
|
2632
|
+
*/
|
|
2633
|
+
export declare function writeStudyBytes(path: string, bytes: Uint8Array): Promise<void>;
|
|
2634
|
+
|
|
2635
|
+
export { }
|