@inflexa-ai/harness 0.19.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/conversation-agent.d.ts +26 -14
- package/dist/agents/conversation-agent.js +12 -23
- package/dist/agents/report-session-agent.d.ts +31 -5
- package/dist/agents/report-session-agent.js +31 -6
- package/dist/app/chat-turn.js +3 -1
- package/dist/app/message-assembly.d.ts +15 -1
- package/dist/app/message-assembly.js +22 -8
- package/dist/app/report-session-runtime.d.ts +21 -4
- package/dist/app/report-session-runtime.js +53 -6
- package/dist/app/spawn-report-session.d.ts +174 -17
- package/dist/app/spawn-report-session.js +233 -21
- package/dist/contracts/chat-events.d.ts +7 -2
- package/dist/contracts/message.d.ts +10 -0
- package/dist/contracts/report-blocks.d.ts +743 -19
- package/dist/contracts/report-blocks.js +186 -11
- package/dist/contracts/report-reference.d.ts +88 -0
- package/dist/contracts/report-reference.js +48 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +20 -0
- package/dist/lib/chrome.d.ts +26 -6
- package/dist/lib/chrome.js +99 -32
- package/dist/lib/eyes.d.ts +57 -0
- package/dist/lib/eyes.js +45 -0
- package/dist/lib/page-capture.d.ts +14 -0
- package/dist/lib/page-capture.js +56 -2
- package/dist/literature/sources/pubmed.js +2 -1
- package/dist/loop/run-agent.js +58 -23
- package/dist/loop/tool-detail.d.ts +19 -2
- package/dist/loop/tool-detail.js +35 -2
- package/dist/memory/content-to-cortex.d.ts +3 -2
- package/dist/memory/content-to-cortex.js +21 -12
- package/dist/memory/conversation-display-replay.js +14 -7
- package/dist/memory/thread-history.d.ts +60 -3
- package/dist/memory/thread-history.js +55 -16
- package/dist/memory/thread-store.d.ts +11 -1
- package/dist/memory/thread-store.js +12 -2
- package/dist/prompts/conversation.d.ts +1 -1
- package/dist/prompts/conversation.js +23 -6
- package/dist/prompts/report-session.d.ts +1 -1
- package/dist/prompts/report-session.js +183 -9
- package/dist/report-model/authoring-grammar.d.ts +463 -0
- package/dist/report-model/authoring-grammar.js +77 -0
- package/dist/report-model/block-walk.d.ts +57 -14
- package/dist/report-model/block-walk.js +116 -11
- package/dist/report-model/draft-finish.d.ts +22 -4
- package/dist/report-model/draft-finish.js +39 -7
- package/dist/report-model/draft-operations.d.ts +3 -0
- package/dist/report-model/draft-operations.js +19 -5
- package/dist/report-model/draft-read.d.ts +8 -5
- package/dist/report-model/draft-read.js +21 -5
- package/dist/report-model/fixture-resolver.js +15 -4
- package/dist/report-model/pin-snapshot.d.ts +24 -6
- package/dist/report-model/pin-snapshot.js +204 -6
- package/dist/report-model/production-resolver.js +15 -4
- package/dist/report-model/reference-resolver.d.ts +50 -1
- package/dist/report-model/reference-resolver.js +94 -1
- package/dist/report-model/reference-stamp.d.ts +45 -0
- package/dist/report-model/reference-stamp.js +173 -0
- package/dist/report-model/structural-validation.d.ts +4 -1
- package/dist/report-model/structural-validation.js +48 -3
- package/dist/report-model/validate.d.ts +1 -1
- package/dist/report-model/validate.js +1 -1
- package/dist/report-render/asset-lookup.d.ts +19 -0
- package/dist/report-render/asset-lookup.js +37 -0
- package/dist/report-render/assets.d.ts +45 -1
- package/dist/report-render/assets.js +65 -6
- package/dist/report-render/chart-presets.d.ts +102 -0
- package/dist/report-render/chart-presets.js +205 -0
- package/dist/report-render/chart.d.ts +112 -10
- package/dist/report-render/chart.js +1164 -41
- package/dist/report-render/design.d.ts +99 -0
- package/dist/report-render/design.js +289 -107
- package/dist/report-render/number-format.d.ts +117 -0
- package/dist/report-render/number-format.js +479 -0
- package/dist/report-render/page.d.ts +121 -5
- package/dist/report-render/page.js +689 -7
- package/dist/report-render/references.d.ts +70 -16
- package/dist/report-render/references.js +54 -22
- package/dist/report-render/render.d.ts +23 -5
- package/dist/report-render/render.js +81 -22
- package/dist/report-render/table-data.d.ts +92 -0
- package/dist/report-render/table-data.js +129 -0
- package/dist/report-render/types.d.ts +15 -0
- package/dist/report-render/value-bridge.js +6 -2
- package/dist/report-render/views/chart-view.d.ts +12 -5
- package/dist/report-render/views/chart-view.js +14 -8
- package/dist/report-render/views/page-view.d.ts +36 -15
- package/dist/report-render/views/page-view.js +45 -23
- package/dist/report-render/views/prose.d.ts +12 -2
- package/dist/report-render/views/prose.js +29 -7
- package/dist/report-render/views/references-view.d.ts +22 -8
- package/dist/report-render/views/references-view.js +101 -13
- package/dist/report-render/views/values.d.ts +128 -13
- package/dist/report-render/views/values.js +199 -18
- package/dist/runtime/assemble.d.ts +39 -5
- package/dist/runtime/assemble.js +47 -6
- package/dist/sandbox/client.d.ts +10 -1
- package/dist/sandbox/create-sandbox.d.ts +9 -4
- package/dist/sandbox/create-sandbox.js +22 -16
- package/dist/sandbox/docker-client.js +10 -7
- package/dist/sandbox/k8s-client.js +11 -18
- package/dist/sandbox/mount-plan.d.ts +45 -7
- package/dist/sandbox/mount-plan.js +43 -5
- package/dist/sandbox/types.d.ts +10 -6
- package/dist/state/init.js +38 -9
- package/dist/state/report-session-state.d.ts +42 -1
- package/dist/state/report-session-state.js +70 -2
- package/dist/state/report-versions.d.ts +22 -17
- package/dist/state/report-versions.js +48 -35
- package/dist/state/snapshot-parse.js +16 -1
- package/dist/tasks/data-profile.d.ts +7 -4
- package/dist/tasks/data-profile.js +9 -9
- package/dist/tools/define-tool.d.ts +32 -0
- package/dist/tools/define-tool.js +4 -0
- package/dist/tools/detail-resolver.d.ts +7 -2
- package/dist/tools/detail-resolver.js +7 -2
- package/dist/tools/iterate-report.d.ts +1 -1
- package/dist/tools/report/preview-snapshot.js +1 -0
- package/dist/tools/report-authoring/authoring-tools.d.ts +15 -6
- package/dist/tools/report-authoring/authoring-tools.js +99 -18
- package/dist/tools/report-session/derive-table.d.ts +162 -0
- package/dist/tools/report-session/derive-table.js +459 -0
- package/dist/tools/report-session/examine-page.d.ts +48 -18
- package/dist/tools/report-session/examine-page.js +204 -24
- package/dist/tools/report-session/index.d.ts +2 -0
- package/dist/tools/report-session/index.js +2 -0
- package/dist/tools/report-session/list-artifacts.d.ts +97 -0
- package/dist/tools/report-session/list-artifacts.js +197 -0
- package/dist/tools/report-session/preview-report.d.ts +6 -0
- package/dist/tools/report-session/preview-report.js +180 -28
- package/dist/tools/report-session/record-version.d.ts +22 -10
- package/dist/tools/report-session/record-version.js +99 -14
- package/dist/tools/start-report-session.d.ts +115 -0
- package/dist/tools/start-report-session.js +179 -0
- package/dist/workflows/sandbox-step.d.ts +7 -4
- package/dist/workflows/sandbox-step.js +10 -12
- package/dist/workspace/paths.d.ts +50 -0
- package/dist/workspace/paths.js +63 -0
- package/package.json +2 -1
|
@@ -17,27 +17,33 @@
|
|
|
17
17
|
* nested union. A conflict between the flat fields refuses before the core runs.
|
|
18
18
|
*/
|
|
19
19
|
import { err, ok } from "neverthrow";
|
|
20
|
+
import { basename } from "node:path";
|
|
20
21
|
import { z } from "zod";
|
|
22
|
+
import { capCodePoints, DETAIL_NEEDLE_MAX_LENGTH } from "../../loop/tool-detail.js";
|
|
21
23
|
import { isSafeId } from "../../workspace/paths.js";
|
|
22
24
|
import { addBlock, changeBlock, locate, moveBlock, removeBlock, setTitle, } from "../../report-model/draft-operations.js";
|
|
23
25
|
import { buildOutline, childOutline, readBlock } from "../../report-model/draft-read.js";
|
|
24
26
|
import { finishDraft } from "../../report-model/draft-finish.js";
|
|
25
|
-
import {
|
|
27
|
+
import { AuthoringBlockSchema } from "../../report-model/authoring-grammar.js";
|
|
26
28
|
import { defineTool } from "../define-tool.js";
|
|
27
29
|
/**
|
|
28
30
|
* The block payload.
|
|
29
31
|
*
|
|
30
|
-
* The published JSON Schema carries the whole
|
|
31
|
-
* time and the schema is the only place where the model learns the shape of the eight block kinds.
|
|
32
|
-
* `z.unknown()` emits the empty schema, which tells the model nothing and leaves it to discover each
|
|
32
|
+
* The published JSON Schema carries the whole authoring grammar, because a tool is self-describing at
|
|
33
|
+
* attach time and the schema is the only place where the model learns the shape of the eight block kinds.
|
|
34
|
+
* A bare `z.unknown()` emits the empty schema, which tells the model nothing and leaves it to discover each
|
|
33
35
|
* required field through one refusal at a time.
|
|
34
36
|
*
|
|
37
|
+
* The grammar is the authoring one, thus no artifact reference of the published schema carries a hash. The
|
|
38
|
+
* pinned snapshot owns that value, and the land path stamps it from the path.
|
|
39
|
+
*
|
|
35
40
|
* The `z.unknown()` member keeps the runtime parse permissive. Thus a malformed payload still reaches the
|
|
36
|
-
* core, which parses it with the
|
|
41
|
+
* core, which parses it with the draft grammar and refuses `malformed-block` as typed data in the ok
|
|
37
42
|
* channel. A strict input schema would turn that designed refusal into a hard input-validation error from
|
|
38
|
-
* the loop.
|
|
43
|
+
* the loop. A payload that carries a hash rides the same arm, and the stamp drops the value before the
|
|
44
|
+
* parse.
|
|
39
45
|
*/
|
|
40
|
-
const blockPayload = z.union([
|
|
46
|
+
const blockPayload = z.union([AuthoringBlockSchema, z.unknown()]);
|
|
41
47
|
/**
|
|
42
48
|
* A flat field that the model can leave out.
|
|
43
49
|
*
|
|
@@ -119,7 +125,14 @@ export async function openReportThread(gateway, scope) {
|
|
|
119
125
|
detail: `the scope names the analysis ${analysisId}, but the thread ${threadId} belongs to the analysis ${loaded.analysisId}`,
|
|
120
126
|
});
|
|
121
127
|
}
|
|
122
|
-
return ok({
|
|
128
|
+
return ok({
|
|
129
|
+
threadId,
|
|
130
|
+
analysisId,
|
|
131
|
+
state: loaded.state,
|
|
132
|
+
token: loaded.token,
|
|
133
|
+
seenDocumentHash: loaded.seenDocumentHash,
|
|
134
|
+
derivations: loaded.derivations,
|
|
135
|
+
});
|
|
123
136
|
}
|
|
124
137
|
/** Read an absentable field. An explicit `null` and an omitted key both mean that the model gave no value. */
|
|
125
138
|
function given(value) {
|
|
@@ -208,15 +221,75 @@ function readKind(block) {
|
|
|
208
221
|
function readId(block) {
|
|
209
222
|
return readStringField(block, "id");
|
|
210
223
|
}
|
|
224
|
+
/** Read one field of an untyped payload, or `undefined` when the payload is not an object. */
|
|
225
|
+
function fieldOf(value, field) {
|
|
226
|
+
return value !== null && typeof value === "object" ? value[field] : undefined;
|
|
227
|
+
}
|
|
211
228
|
function readStringField(block, field) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
229
|
+
const value = fieldOf(block, field);
|
|
230
|
+
return typeof value === "string" ? value : undefined;
|
|
231
|
+
}
|
|
232
|
+
/** The pinned path of an untyped reference payload, or `undefined` when it names none. */
|
|
233
|
+
function referencePath(reference) {
|
|
234
|
+
const path = readStringField(reference, "path");
|
|
235
|
+
return path === undefined || path.length === 0 ? undefined : path;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* The artifact path that an untyped block payload binds, or `undefined` when the kind binds no path.
|
|
239
|
+
*
|
|
240
|
+
* Where a reference sits differs per kind, thus the walk reads the one field of each kind and never
|
|
241
|
+
* searches the payload. A claim can hold a citation first, which names no path, thus the walk takes the
|
|
242
|
+
* first binding that names one. A metric holds a scalar reference, and a derivation holds its own two
|
|
243
|
+
* inputs, thus the first input names the derived value. A text block, a citation block, and a section
|
|
244
|
+
* bind no artifact at all.
|
|
245
|
+
*
|
|
246
|
+
* The payload is model-authored and unvalidated here, thus each read is a guarded read and a wrong shape
|
|
247
|
+
* gives `undefined`.
|
|
248
|
+
*/
|
|
249
|
+
function boundArtifactPath(kind, block) {
|
|
250
|
+
if (kind === "table" || kind === "chart" || kind === "figure") {
|
|
251
|
+
return referencePath(fieldOf(block, "binding"));
|
|
252
|
+
}
|
|
253
|
+
if (kind === "claim") {
|
|
254
|
+
const bindings = fieldOf(block, "bindings");
|
|
255
|
+
if (!Array.isArray(bindings)) {
|
|
256
|
+
return undefined;
|
|
216
257
|
}
|
|
258
|
+
for (const binding of bindings) {
|
|
259
|
+
const path = referencePath(binding);
|
|
260
|
+
if (path !== undefined) {
|
|
261
|
+
return path;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
if (kind === "metric") {
|
|
267
|
+
const value = fieldOf(block, "value");
|
|
268
|
+
const direct = referencePath(value);
|
|
269
|
+
if (direct !== undefined) {
|
|
270
|
+
return direct;
|
|
271
|
+
}
|
|
272
|
+
const inputs = fieldOf(value, "inputs");
|
|
273
|
+
return Array.isArray(inputs) ? referencePath(inputs[0]) : undefined;
|
|
217
274
|
}
|
|
218
275
|
return undefined;
|
|
219
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* The subject that names one added block: the title of a section in quotes, or the file name of the
|
|
279
|
+
* artifact that the block binds. A block that names neither gives no subject, and the kind stands alone.
|
|
280
|
+
*
|
|
281
|
+
* The title is model-authored text of no fixed length, thus the needle bound cuts it before the emit-site
|
|
282
|
+
* cap can cut the quote that closes it. The file name is the base name alone, because the directory
|
|
283
|
+
* segments of an analysis path repeat across every block and the file name is what tells two apart.
|
|
284
|
+
*/
|
|
285
|
+
function addedSubject(kind, block) {
|
|
286
|
+
if (kind === "section") {
|
|
287
|
+
const title = readStringField(block, "title");
|
|
288
|
+
return title === undefined || title.length === 0 ? undefined : `"${capCodePoints(title, DETAIL_NEEDLE_MAX_LENGTH)}"`;
|
|
289
|
+
}
|
|
290
|
+
const path = boundArtifactPath(kind, block);
|
|
291
|
+
return path === undefined ? undefined : basename(path);
|
|
292
|
+
}
|
|
220
293
|
/**
|
|
221
294
|
* The id of the section that holds a block, or `undefined` when the block sits at the root.
|
|
222
295
|
*
|
|
@@ -299,12 +372,18 @@ export function createReportAuthoringTools(gateway) {
|
|
|
299
372
|
description: "Add one block to the draft. The `block` schema gives the eight kinds and the fields of each one. " +
|
|
300
373
|
"You choose the `id` of the block, and it must be unique in the draft. " +
|
|
301
374
|
"Name the destination with `parentId` and one of `place`, `before`, or `after`. " +
|
|
302
|
-
"The root admits a section only, and an atom needs a section as its parent."
|
|
375
|
+
"The root admits a section only, and an atom needs a section as its parent. " +
|
|
376
|
+
"A reference names the path of a pinned artifact, and the session stamps the hash from the pinned evidence.",
|
|
303
377
|
inputSchema: addBlockInput,
|
|
304
378
|
executionMode: AUTHORING_EXECUTION_MODE,
|
|
305
379
|
describeCall: (input) => {
|
|
306
|
-
const
|
|
307
|
-
|
|
380
|
+
const block = decodeBlockPayload(input.block);
|
|
381
|
+
const kind = readKind(block);
|
|
382
|
+
if (kind === undefined) {
|
|
383
|
+
return "add a block";
|
|
384
|
+
}
|
|
385
|
+
const subject = addedSubject(kind, block);
|
|
386
|
+
return subject === undefined ? `add ${kind}` : `add ${kind} ${subject}`;
|
|
308
387
|
},
|
|
309
388
|
execute: async (input, ctx) => {
|
|
310
389
|
const opened = await openThread(ctx);
|
|
@@ -324,7 +403,8 @@ export function createReportAuthoringTools(gateway) {
|
|
|
324
403
|
const change_block = defineTool({
|
|
325
404
|
id: "change_block",
|
|
326
405
|
description: "Change one block by its id. Give a `title` to retitle a section, or a `block` to replace an atom, and never both. " +
|
|
327
|
-
"The change keeps the id of the target, thus the `id` of the payload does not matter. A kind change is permitted."
|
|
406
|
+
"The change keeps the id of the target, thus the `id` of the payload does not matter. A kind change is permitted. " +
|
|
407
|
+
"A reference names the path of a pinned artifact, and the session stamps the hash from the pinned evidence.",
|
|
328
408
|
inputSchema: changeBlockInput,
|
|
329
409
|
executionMode: AUTHORING_EXECUTION_MODE,
|
|
330
410
|
describeCall: (input) => `change ${input.targetId}`,
|
|
@@ -416,7 +496,8 @@ export function createReportAuthoringTools(gateway) {
|
|
|
416
496
|
});
|
|
417
497
|
const read_block = defineTool({
|
|
418
498
|
id: "read_block",
|
|
419
|
-
description: "Read one block by its id. An atom gives the full block with its bindings. A
|
|
499
|
+
description: "Read one block by its id. An atom gives the full block with its bindings. A binding gives its path and no hash, " +
|
|
500
|
+
"because the session owns the hash. A section gives its title and the id of each child, " +
|
|
420
501
|
"because the outline already names every block under it. Use it when the outline label is not enough.",
|
|
421
502
|
inputSchema: readBlockInput,
|
|
422
503
|
executionMode: AUTHORING_EXECUTION_MODE,
|
|
@@ -444,7 +525,7 @@ export function createReportAuthoringTools(gateway) {
|
|
|
444
525
|
if (opened.isErr()) {
|
|
445
526
|
return ok({ refused: opened.error });
|
|
446
527
|
}
|
|
447
|
-
return ok(finishDraft(opened.value.state.document, opened.value.state.snapshot));
|
|
528
|
+
return ok(finishDraft(opened.value.state.document, opened.value.state.snapshot, opened.value.derivations));
|
|
448
529
|
},
|
|
449
530
|
});
|
|
450
531
|
return {
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The derivation tool of a report session.
|
|
3
|
+
*
|
|
4
|
+
* A run writes statistical tables, and not plot-ready ones. This tool reshapes the pinned evidence into one
|
|
5
|
+
* table that a block can bind: a join, a pivot, or an aggregate. The agent writes the script, and the record
|
|
6
|
+
* chains the derived table back to the evidence that made it.
|
|
7
|
+
*
|
|
8
|
+
* A session derivation is not an analysis run. It mints no run id, it registers no artifact, and it writes
|
|
9
|
+
* under the session directory alone. The rails are the rails of the value tier (`tasks/extract-values.ts`):
|
|
10
|
+
* the sandbox client, the identity mint, and the authorizer on every terminal path. The container is
|
|
11
|
+
* ephemeral, and it goes away with the work.
|
|
12
|
+
*
|
|
13
|
+
* The container mounts the analysis tree read-only, and one write mount covers the `derived/` directory of
|
|
14
|
+
* the session alone. The script writes its table into that mount directly, thus a large table makes no
|
|
15
|
+
* roundtrip and no write of the script can reach the workspace tree. The working directory of the exec is
|
|
16
|
+
* that same mount, and the standard output carries the logs of the script alone.
|
|
17
|
+
*
|
|
18
|
+
* The host then reads the file that the container wrote. A path inside the mount is still untrusted bytes: a
|
|
19
|
+
* script can leave a symbolic link in place of its output. Thus the host classifies the file against the
|
|
20
|
+
* workspace root before it hashes one byte, and an escape refuses as typed data.
|
|
21
|
+
*
|
|
22
|
+
* Each declared input must sit in the served membership, and its hash comes from there. The declaration is
|
|
23
|
+
* what the record pins, thus a derived cell traces to a pinned artifact and to the script that read it.
|
|
24
|
+
*
|
|
25
|
+
* The tool refuses an output name that the membership already holds. A record is immutable, and a second
|
|
26
|
+
* derivation of one table takes a new name.
|
|
27
|
+
*
|
|
28
|
+
* A composition with no sandbox client and no run authorizer cannot derive at all. The tool reports that
|
|
29
|
+
* condition one time, up front, the same discipline as the eyes. A per-attempt failure would instead read as
|
|
30
|
+
* a transient fault, and it would invite a repeat of a call that can never pass.
|
|
31
|
+
*
|
|
32
|
+
* The transport of the client is the second such bound. A derivation runs inside one live turn and not
|
|
33
|
+
* inside a workflow body. The poll transport awaits with plain steps and a plain sleep, thus it settles
|
|
34
|
+
* there. The callback transport awaits through `DBOS.recv`, which a workflow body alone can call, thus this
|
|
35
|
+
* tool refuses up front under it rather than start a container that nothing can await.
|
|
36
|
+
*/
|
|
37
|
+
import { z } from "zod";
|
|
38
|
+
import type { RunAuthorizer } from "../../execution/run-authorizer.js";
|
|
39
|
+
import { type Logger } from "../../lib/logger.js";
|
|
40
|
+
import type { SandboxClient } from "../../sandbox/client.js";
|
|
41
|
+
import type { ExecResult, SubmitExecBody } from "../../sandbox/types.js";
|
|
42
|
+
import type { DerivationSource, ReportSessionStateStore } from "../../state/report-session-state.js";
|
|
43
|
+
import { type ResolveWorkspaceRoot } from "../../workspace/paths.js";
|
|
44
|
+
import { type Tool } from "../define-tool.js";
|
|
45
|
+
import { type ReportSessionStateGateway, type SessionRefusal } from "../report-authoring/authoring-tools.js";
|
|
46
|
+
/** The input of one derivation: the script, the declared pinned inputs, and the name of the output file. */
|
|
47
|
+
declare const deriveTableInput: z.ZodObject<{
|
|
48
|
+
script: z.ZodString;
|
|
49
|
+
inputs: z.ZodArray<z.ZodString>;
|
|
50
|
+
output: z.ZodString;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export type DeriveTableInput = z.infer<typeof deriveTableInput>;
|
|
53
|
+
/**
|
|
54
|
+
* The typed outcome of the derivation tool. Each arm is ok-channel data, thus the tool never throws for one
|
|
55
|
+
* of them.
|
|
56
|
+
*
|
|
57
|
+
* `derived` carries the workspace-relative path of the derived table, its content hash, the hash of the
|
|
58
|
+
* script, the sources that the record pins, and the header columns of the output. Each other arm names a
|
|
59
|
+
* condition that the agent repairs: a call that is out of bounds, an input that the membership does not
|
|
60
|
+
* hold, a name that a record already holds, a script that failed in the container, and a green script that
|
|
61
|
+
* left no file at the output name.
|
|
62
|
+
*/
|
|
63
|
+
export type DeriveTableResult = {
|
|
64
|
+
outcome: "refused";
|
|
65
|
+
refusal: SessionRefusal;
|
|
66
|
+
} | {
|
|
67
|
+
outcome: "unavailable";
|
|
68
|
+
detail: string;
|
|
69
|
+
} | {
|
|
70
|
+
outcome: "script-too-large";
|
|
71
|
+
bytes: number;
|
|
72
|
+
cap: number;
|
|
73
|
+
detail: string;
|
|
74
|
+
} | {
|
|
75
|
+
outcome: "too-many-inputs";
|
|
76
|
+
count: number;
|
|
77
|
+
cap: number;
|
|
78
|
+
detail: string;
|
|
79
|
+
} | {
|
|
80
|
+
outcome: "unsafe-name";
|
|
81
|
+
detail: string;
|
|
82
|
+
} | {
|
|
83
|
+
outcome: "absent-input";
|
|
84
|
+
path: string;
|
|
85
|
+
detail: string;
|
|
86
|
+
} | {
|
|
87
|
+
outcome: "repeated-name";
|
|
88
|
+
outputPath: string;
|
|
89
|
+
detail: string;
|
|
90
|
+
} | {
|
|
91
|
+
outcome: "exec-failed";
|
|
92
|
+
detail: string;
|
|
93
|
+
} | {
|
|
94
|
+
outcome: "no-output";
|
|
95
|
+
detail: string;
|
|
96
|
+
} | {
|
|
97
|
+
outcome: "derived";
|
|
98
|
+
path: string;
|
|
99
|
+
hash: string;
|
|
100
|
+
scriptHash: string;
|
|
101
|
+
sources: DerivationSource[];
|
|
102
|
+
columns?: string[];
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* The construction deps of the derivation tool.
|
|
106
|
+
*
|
|
107
|
+
* `derivations` is the append side of the durable session state, thus the record lands beside the document
|
|
108
|
+
* and the pin. `sandboxClient` and `runAuthorizer` are the two rails of the exec, and a composition that
|
|
109
|
+
* binds neither leaves the session with no derivation at all. `resolveWorkspaceRoot` maps the analysis of
|
|
110
|
+
* the call onto its workspace root, thus one singleton tool serves every analysis.
|
|
111
|
+
*/
|
|
112
|
+
export interface DeriveTableToolDeps {
|
|
113
|
+
readonly gateway: ReportSessionStateGateway;
|
|
114
|
+
readonly resolveWorkspaceRoot: ResolveWorkspaceRoot;
|
|
115
|
+
readonly derivations: Pick<ReportSessionStateStore, "appendDerivation">;
|
|
116
|
+
readonly sandboxClient?: SandboxClient;
|
|
117
|
+
readonly runAuthorizer?: RunAuthorizer;
|
|
118
|
+
readonly logger?: Logger;
|
|
119
|
+
}
|
|
120
|
+
/** The environment variable that carries the declared inputs into the container. */
|
|
121
|
+
export declare const DERIVE_INPUT_ENV = "DERIVE_INPUTS";
|
|
122
|
+
/** The environment variable that carries the container path of the output file into the container. */
|
|
123
|
+
export declare const DERIVE_OUTPUT_ENV = "DERIVE_OUTPUT";
|
|
124
|
+
/** One declared input, as the container reads it: the mounted path of the file, and its pinned hash. */
|
|
125
|
+
export interface DerivationInputMount {
|
|
126
|
+
readonly path: string;
|
|
127
|
+
readonly hash: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Build the sandbox exec of one derivation. The command runs the script of the agent through `python3 -c`.
|
|
131
|
+
*
|
|
132
|
+
* The working directory is the write mount, thus the script writes its table beside where it stands. Each
|
|
133
|
+
* declared input rides as its mounted path, thus the script opens the file wherever it works from. The
|
|
134
|
+
* output path rides too, thus the script names no directory of its own.
|
|
135
|
+
*
|
|
136
|
+
* The function is pure, thus a test asserts the command shape without a sandbox.
|
|
137
|
+
*/
|
|
138
|
+
export declare function buildDerivationExec(args: {
|
|
139
|
+
readonly script: string;
|
|
140
|
+
readonly execId: string;
|
|
141
|
+
readonly workingDir: string;
|
|
142
|
+
readonly inputs: readonly DerivationInputMount[];
|
|
143
|
+
readonly output: string;
|
|
144
|
+
}): SubmitExecBody;
|
|
145
|
+
/**
|
|
146
|
+
* Give the failure of an exec result, or `undefined` when the script ran to a clean exit.
|
|
147
|
+
*
|
|
148
|
+
* A synthetic failure, a timeout, and a non-zero exit each mean that no table came back. The detail of a
|
|
149
|
+
* non-zero exit carries the tail of the standard error, thus the agent repairs the script from what the
|
|
150
|
+
* container reported.
|
|
151
|
+
*
|
|
152
|
+
* The function is pure, thus a test asserts the mapping without a sandbox.
|
|
153
|
+
*/
|
|
154
|
+
export declare function describeExecFailure(result: ExecResult): string | undefined;
|
|
155
|
+
/**
|
|
156
|
+
* Make the derivation tool over the session-state gateway, the derivation ledger, and the sandbox rails.
|
|
157
|
+
*
|
|
158
|
+
* The tool reads the thread id from the scope of the call, and it loads the membership through the gateway.
|
|
159
|
+
* Thus one factory serves every thread, and the tool holds no per-session value.
|
|
160
|
+
*/
|
|
161
|
+
export declare function createDeriveTableTool(deps: DeriveTableToolDeps): Tool<DeriveTableInput, DeriveTableResult>;
|
|
162
|
+
export {};
|