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