@parcha/agentrun-serve 0.0.0-bootstrap.0 → 0.1.0-beta.29
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/CHANGELOG.md +560 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +1724 -0
- package/dist/adapters.d.ts +205 -0
- package/dist/adapters.js +459 -0
- package/dist/agents.d.ts +124 -0
- package/dist/agents.js +302 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.js +324 -0
- package/dist/bound-files.d.ts +4 -0
- package/dist/bound-files.js +164 -0
- package/dist/box/record.d.ts +6 -0
- package/dist/box/record.js +41 -0
- package/dist/box/sweep.d.ts +53 -0
- package/dist/box/sweep.js +193 -0
- package/dist/box-image.d.ts +98 -0
- package/dist/box-image.js +283 -0
- package/dist/box-relay.d.ts +42 -0
- package/dist/box-relay.js +222 -0
- package/dist/boxes.d.ts +54 -0
- package/dist/boxes.js +182 -0
- package/dist/cap.d.ts +224 -0
- package/dist/cap.js +721 -0
- package/dist/catalog.d.ts +20 -0
- package/dist/catalog.js +53 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +167 -0
- package/dist/coding-tools.d.ts +31 -0
- package/dist/coding-tools.js +81 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +1141 -0
- package/dist/console/assets/index-BN7oVcO4.js +445 -0
- package/dist/console/assets/index-By-jkqki.css +1 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-CIEtRijs.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-BB5xRk30.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-EVf6-Yzo.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-BHyURHCj.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-C_uLvvQ5.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-Dj6eZy5f.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-DpeVePZf.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-greek-400-normal-CNojz0t3.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-600-normal-3KAm9r92.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-600-normal-H7WoG9Et.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-400-normal-B11XCQ5g.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-600-normal-DXv3JcnD.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-DHMOLxAi.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-DiQlUoE6.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-BeU3T8wf.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-ByoDsISC.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-CSpzN4cI.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-Dtizs43-.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-400-normal-Cph9ettZ.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-400-normal-DfGZKnlb.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-600-normal-BGBUNdzT.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-600-normal-COje25QW.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-4l4lq8zr.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-BGzXWJeR.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-8_E36CQj.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-C27an7Zc.woff +0 -0
- package/dist/console/index.html +15 -0
- package/dist/daytona-api.d.ts +21 -0
- package/dist/daytona-api.js +101 -0
- package/dist/decision-rows.d.ts +11 -0
- package/dist/decision-rows.js +116 -0
- package/dist/decisions.d.ts +94 -0
- package/dist/decisions.js +184 -0
- package/dist/effort-guidance.d.ts +5 -0
- package/dist/effort-guidance.js +14 -0
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +11 -0
- package/dist/errors.d.ts +72 -0
- package/dist/errors.js +66 -0
- package/dist/exa-keyless.d.ts +35 -0
- package/dist/exa-keyless.js +202 -0
- package/dist/fetch-page.d.ts +114 -0
- package/dist/fetch-page.js +182 -0
- package/dist/files.d.ts +60 -0
- package/dist/files.js +153 -0
- package/dist/grade.d.ts +96 -0
- package/dist/grade.js +348 -0
- package/dist/graph-view.d.ts +100 -0
- package/dist/graph-view.js +212 -0
- package/dist/harness-app.d.ts +38 -0
- package/dist/harness-app.js +626 -0
- package/dist/harness.d.ts +53 -0
- package/dist/harness.js +74 -0
- package/dist/home-path.d.ts +27 -0
- package/dist/home-path.js +78 -0
- package/dist/host-tools.d.ts +20 -0
- package/dist/host-tools.js +140 -0
- package/dist/host.d.ts +39 -0
- package/dist/host.js +81 -0
- package/dist/hosted-search.d.ts +27 -0
- package/dist/hosted-search.js +129 -0
- package/dist/import-sources.d.ts +104 -0
- package/dist/import-sources.js +629 -0
- package/dist/import-summary.d.ts +25 -0
- package/dist/import-summary.js +75 -0
- package/dist/import-worker.d.ts +26 -0
- package/dist/import-worker.js +41 -0
- package/dist/import.d.ts +145 -0
- package/dist/import.js +1221 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/key-check.d.ts +36 -0
- package/dist/key-check.js +108 -0
- package/dist/key-refusal.d.ts +51 -0
- package/dist/key-refusal.js +187 -0
- package/dist/learn/check.d.ts +99 -0
- package/dist/learn/check.js +259 -0
- package/dist/learn/grade.d.ts +79 -0
- package/dist/learn/grade.js +433 -0
- package/dist/learn/index.d.ts +7 -0
- package/dist/learn/index.js +11 -0
- package/dist/learn/invisible.d.ts +5 -0
- package/dist/learn/invisible.js +42 -0
- package/dist/learn/notes.d.ts +59 -0
- package/dist/learn/notes.js +146 -0
- package/dist/learn/reflect.d.ts +49 -0
- package/dist/learn/reflect.js +167 -0
- package/dist/learn/secrets.d.ts +18 -0
- package/dist/learn/secrets.js +111 -0
- package/dist/learn/skills.d.ts +84 -0
- package/dist/learn/skills.js +198 -0
- package/dist/learning-routes.d.ts +196 -0
- package/dist/learning-routes.js +609 -0
- package/dist/learning-run.d.ts +304 -0
- package/dist/learning-run.js +797 -0
- package/dist/learning-words.d.ts +73 -0
- package/dist/learning-words.js +171 -0
- package/dist/learning.d.ts +377 -0
- package/dist/learning.js +801 -0
- package/dist/llm.d.ts +40 -0
- package/dist/llm.js +37 -0
- package/dist/llms.txt +37 -0
- package/dist/mcp-servers.d.ts +115 -0
- package/dist/mcp-servers.js +445 -0
- package/dist/mcp.d.ts +51 -0
- package/dist/mcp.js +392 -0
- package/dist/model.d.ts +184 -0
- package/dist/model.js +484 -0
- package/dist/monid.d.ts +74 -0
- package/dist/monid.js +277 -0
- package/dist/openapi/agentrun-v2.openapi.json +4805 -0
- package/dist/openapi.d.ts +10 -0
- package/dist/openapi.js +1417 -0
- package/dist/owner.d.ts +55 -0
- package/dist/owner.js +222 -0
- package/dist/packs.d.ts +71 -0
- package/dist/packs.js +180 -0
- package/dist/page.d.ts +32 -0
- package/dist/page.js +133 -0
- package/dist/paid-calls.d.ts +46 -0
- package/dist/paid-calls.js +110 -0
- package/dist/pause.d.ts +68 -0
- package/dist/pause.js +97 -0
- package/dist/pdf-pages.d.ts +44 -0
- package/dist/pdf-pages.js +147 -0
- package/dist/place.d.ts +46 -0
- package/dist/place.js +105 -0
- package/dist/print.d.ts +20 -0
- package/dist/print.js +29 -0
- package/dist/propose.d.ts +38 -0
- package/dist/propose.js +82 -0
- package/dist/quiet-sqlite-warning.d.ts +1 -0
- package/dist/quiet-sqlite-warning.js +14 -0
- package/dist/request-start.d.ts +14 -0
- package/dist/request-start.js +226 -0
- package/dist/result.d.ts +3 -0
- package/dist/result.js +5 -0
- package/dist/rows.d.ts +46 -0
- package/dist/rows.js +121 -0
- package/dist/run-box.d.ts +134 -0
- package/dist/run-box.js +440 -0
- package/dist/run-manifest.d.ts +27 -0
- package/dist/run-manifest.js +60 -0
- package/dist/runnable.d.ts +80 -0
- package/dist/runnable.js +162 -0
- package/dist/runs.d.ts +840 -0
- package/dist/runs.js +2279 -0
- package/dist/secret-cut.d.ts +27 -0
- package/dist/secret-cut.js +109 -0
- package/dist/secrets.d.ts +50 -0
- package/dist/secrets.js +140 -0
- package/dist/server-lock.d.ts +44 -0
- package/dist/server-lock.js +140 -0
- package/dist/server.d.ts +626 -0
- package/dist/server.js +1756 -0
- package/dist/sessions.d.ts +4 -0
- package/dist/sessions.js +105 -0
- package/dist/skills.d.ts +31 -0
- package/dist/skills.js +68 -0
- package/dist/stats.d.ts +101 -0
- package/dist/stats.js +82 -0
- package/dist/tool-keys.d.ts +151 -0
- package/dist/tool-keys.js +273 -0
- package/dist/tool-plane.d.ts +143 -0
- package/dist/tool-plane.js +242 -0
- package/dist/tools.d.ts +147 -0
- package/dist/tools.js +253 -0
- package/dist/turn-end.d.ts +23 -0
- package/dist/turn-end.js +14 -0
- package/dist/turns.d.ts +34 -0
- package/dist/turns.js +202 -0
- package/dist/uploads.d.ts +104 -0
- package/dist/uploads.js +474 -0
- package/dist/usage.d.ts +29 -0
- package/dist/usage.js +58 -0
- package/dist/validate.d.ts +55 -0
- package/dist/validate.js +175 -0
- package/dist/web-fetch.d.ts +64 -0
- package/dist/web-fetch.js +262 -0
- package/dist/web-search.d.ts +54 -0
- package/dist/web-search.js +136 -0
- package/dist/webhooks.d.ts +182 -0
- package/dist/webhooks.js +487 -0
- package/dist/workspace-paths.d.ts +33 -0
- package/dist/workspace-paths.js +104 -0
- package/dist/workspace.d.ts +88 -0
- package/dist/workspace.js +369 -0
- package/launcher/agentrun-serve +109 -0
- package/package.json +96 -1
- package/skills/agentrun-serve/SKILL.md +128 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import type { AnalyticsFilter, Revision, RunRow, StartedRun } from "@parcha/pi-durable-agent";
|
|
2
|
+
import type { TimelineEvent } from "@parcha/pi-durable-agent/timeline";
|
|
3
|
+
import { type LearnedFile, type Learning, type LearningReason, type LearningState, type NoteLearned, type Shown } from "./learning.js";
|
|
4
|
+
import type { Run, RunsOptions, Status } from "./runs.js";
|
|
5
|
+
import { type Json } from "./validate.js";
|
|
6
|
+
/** A run's end-of-run turn: the job's outcome, the newest store entry before the turn and, once the run ended, the newest
|
|
7
|
+
* after it (its rows are those between), its deadline, and how it ended. */
|
|
8
|
+
export type Reflect = {
|
|
9
|
+
outcome: Status;
|
|
10
|
+
after: number;
|
|
11
|
+
until?: number;
|
|
12
|
+
deadline: string;
|
|
13
|
+
ended?: true;
|
|
14
|
+
timedOut?: true;
|
|
15
|
+
};
|
|
16
|
+
/** Who sent the end-of-run turn: the server, never a person, and no request field sets it. The one value it is sent
|
|
17
|
+
* with, at its one call (reflectTurn); the per-tool gate, once this server has one, takes it there. */
|
|
18
|
+
declare const REFLECT_ORIGIN = "reflect";
|
|
19
|
+
export type TurnOrigin = typeof REFLECT_ORIGIN;
|
|
20
|
+
/** The run asked its end-of-run turn and has not ended since. */
|
|
21
|
+
export declare const reflecting: (run: {
|
|
22
|
+
meta: {
|
|
23
|
+
reflect?: Reflect;
|
|
24
|
+
};
|
|
25
|
+
}) => boolean;
|
|
26
|
+
/** Whether entry `id` (a number), or the row `id`, is the end-of-run turn's. Before the run has ended every later entry
|
|
27
|
+
* is, and so is a live row. */
|
|
28
|
+
export declare function reflects(reflect: Reflect | undefined, id: string | number): boolean;
|
|
29
|
+
/** `rows` with the end-of-run turn's labelled: never the run's answer (meaningful skips the label), its answer shown as
|
|
30
|
+
* a text row, and its message as the host's, in a person's words (learning-words.ts): what the model is asked stays in
|
|
31
|
+
* the run's store, and no row shows it. */
|
|
32
|
+
export declare function labelled(reflect: Reflect | undefined, rows: TimelineEvent[]): TimelineEvent[];
|
|
33
|
+
/** The files of the run's copy of the folder its job read, in the order it first read them, each once: every `read`
|
|
34
|
+
* call whose result came back a success, matched to its call by id (claude-agent's rows can hold the result above the
|
|
35
|
+
* call), on any harness: pi's, claude-agent's (the host's `read`, served to its CLI as `mcp__hands__read`) and codex's
|
|
36
|
+
* (the same tool, as an app-server dynamic tool) rows all name it `read`, with the path as the model gave it. The
|
|
37
|
+
* end-of-run turn's reads are its own, not the job's, and are left out; so is a read that failed or never ended, and
|
|
38
|
+
* MEMORY.md, which is no note. Which of these files are notes the run started from is for its seed to say (noteUsed). */
|
|
39
|
+
export declare function notesRead(reflect: Reflect | undefined, rows: readonly TimelineEvent[]): string[];
|
|
40
|
+
/** The run's learning row, once its learning was proposed, merged or dropped (`seed_failed` included): its state, reason
|
|
41
|
+
* and detail, its summary the detail itself as the run's view says it (learning.ts detailShown: cut of the host's
|
|
42
|
+
* secrets now, `shown`, then cut short). One row, which says where the learning ended. */
|
|
43
|
+
export declare function withLearning(rows: readonly TimelineEvent[], learning: Learning | undefined, shown: Shown): TimelineEvent[];
|
|
44
|
+
/** How the runs that tried to learn fared, over the runs the analytics' `from`, `to` and `agent` pick (by when they
|
|
45
|
+
* started, unarchived): `runs` with a learning block, `merged`, `dropped` by reason, and `in_progress` (seeded,
|
|
46
|
+
* reflecting or proposed: a run this server holds). A run with learning off, a workflow's or an imported one, has
|
|
47
|
+
* none, and is not counted. */
|
|
48
|
+
export declare function learningStats(rows: readonly RunRow[], filter: AnalyticsFilter, learningOf: (row: RunRow) => {
|
|
49
|
+
state: string;
|
|
50
|
+
reason: string | null;
|
|
51
|
+
} | null): {
|
|
52
|
+
runs: number;
|
|
53
|
+
merged: number;
|
|
54
|
+
dropped: Record<string, number>;
|
|
55
|
+
in_progress: number;
|
|
56
|
+
};
|
|
57
|
+
/** One side of an agent's impact: how many runs, their median time to the answer, the median of their job's own cost
|
|
58
|
+
* over the `cost_runs` whose cost is known, and the median of what learning itself cost a run (its look-back and its
|
|
59
|
+
* grade), over the runs that learn whose learning cost is known. */
|
|
60
|
+
export type ImpactSide = {
|
|
61
|
+
runs: number;
|
|
62
|
+
median_duration_s: number;
|
|
63
|
+
median_cost_usd: number | null;
|
|
64
|
+
cost_runs: number;
|
|
65
|
+
median_learning_usd: number | null;
|
|
66
|
+
};
|
|
67
|
+
export type Impact = {
|
|
68
|
+
before: ImpactSide;
|
|
69
|
+
after: ImpactSide;
|
|
70
|
+
} | null;
|
|
71
|
+
/** What a run's learning tells its impact (learning-run.ts ofAgent), from memory or from its ledger line: how it
|
|
72
|
+
* ended and when, how many notes it started from, when its answer was final and its costs; `grade_usd` once it ended
|
|
73
|
+
* (0 when nothing was graded), and `look_back_usd` 0 for a run that never looked back. */
|
|
74
|
+
export type ImpactLearning = {
|
|
75
|
+
state: string;
|
|
76
|
+
reason: string | null;
|
|
77
|
+
at: string;
|
|
78
|
+
seed_notes?: number;
|
|
79
|
+
answered_at?: string;
|
|
80
|
+
job_cost_usd?: number | null;
|
|
81
|
+
look_back_usd?: number | null;
|
|
82
|
+
grade_usd?: number | null;
|
|
83
|
+
};
|
|
84
|
+
/** What learning changed for an agent, from its run rows (`rows`) and what its runs' learning says (`learningOf`),
|
|
85
|
+
* never a run's files. `after`: its completed agentic runs that started from at least one active note. `before`: its
|
|
86
|
+
* completed agentic runs that started before its first note, the earlier of its first merge's end and the start of its
|
|
87
|
+
* first run that started from a note (a person's note comes first that way); none of them could have. Each side's
|
|
88
|
+
* figures (sideOf, figuresOf): its time to the answer in seconds to a tenth, its job's own cost, what learning cost.
|
|
89
|
+
* An imported or archived run is on neither side, nor is a later one with learning off or seeded with no note (every
|
|
90
|
+
* note retired), nor one whose learning predates these figures. Null unless both sides hold 2 runs or more. */
|
|
91
|
+
export declare function learningImpact(rows: readonly RunRow[], learningOf: (row: RunRow) => ImpactLearning | null | undefined): Impact;
|
|
92
|
+
/** What learning needs of the server's options: the data directory and the agents, its tokens, the switch, and its bounds. */
|
|
93
|
+
export type LearningOptions = Pick<RunsOptions, "agents" | "token" | "doorToken" | "storedKeys" | "learning" | "learningBudget" | "reflectTimeoutMs" | "gradeTimeoutMs" | "gradeModel">;
|
|
94
|
+
/** What the kernel (runs.ts) hands learning: its runs, and the parts of a run's life learning moves. */
|
|
95
|
+
export type LearningKernel = {
|
|
96
|
+
/** Run `id` when the kernel holds it; read from the agent store the first time (`get`). */
|
|
97
|
+
held(id: string): Run | undefined;
|
|
98
|
+
get(id: string): Promise<Run | null>;
|
|
99
|
+
/** Whether the run's process lives. */
|
|
100
|
+
live(run: Run): boolean;
|
|
101
|
+
/** One request to a live run's door, never waking it, with who sent a turn it sends; one to its door, waking it. */
|
|
102
|
+
toLiveDoor(run: Run, path: string, body?: Json, turnOrigin?: TurnOrigin): Promise<Json | null>;
|
|
103
|
+
toDoor(run: Run, path: string, body: Json): Promise<unknown>;
|
|
104
|
+
/** The run's turn aborted; its process let go (SIGTERM). */
|
|
105
|
+
abortTurn(run: Run): Promise<void>;
|
|
106
|
+
terminate(run: Run): void;
|
|
107
|
+
/** Its status as one more change; its rows, as served, again. */
|
|
108
|
+
mark(run: Run): void;
|
|
109
|
+
show(run: Run): void;
|
|
110
|
+
/** Its serve.json written, in turn (onSaved follows). */
|
|
111
|
+
save(run: Run): Promise<void>;
|
|
112
|
+
/** A run's cost from its rows: null when unknown. */
|
|
113
|
+
costOf(rows: readonly TimelineEvent[]): number | null;
|
|
114
|
+
/** The test hooks startServe's options name, as a run's process gets them. */
|
|
115
|
+
fauxEnv(): NodeJS.ProcessEnv;
|
|
116
|
+
};
|
|
117
|
+
/** The learning of every run the kernel holds, from the end-of-run turn to the merge. */
|
|
118
|
+
export declare class LearningRuns {
|
|
119
|
+
private readonly options;
|
|
120
|
+
private readonly kernel;
|
|
121
|
+
/** Why this host keeps no learning folder, said once. */
|
|
122
|
+
private learningOff?;
|
|
123
|
+
/** The secrets each launch of a run that learns handed its process (runs.ts launch()), by run id, so a key a person
|
|
124
|
+
* replaced or deleted while the run lived is still refused in what its end-of-run turn wrote. In memory only, never on
|
|
125
|
+
* disk: a server that restarts loses them, and the run's next launch hands it the keys as they are then, which the
|
|
126
|
+
* check reads too. Dropped once the run's learning ends, and when the server closes. */
|
|
127
|
+
private readonly handed;
|
|
128
|
+
/** Aborted as the server closes: a grade's screen and grader stop, and leave the run's learning `proposed`. */
|
|
129
|
+
private readonly stopping;
|
|
130
|
+
/** The runs whose learning's end is in the learning ledger (usage.ts): read at the start, and each one written since. */
|
|
131
|
+
private readonly recorded;
|
|
132
|
+
/** By run: what its end-of-run turn wrote, being checked (proposeOnce), and its proposal, being graded (gradeOnce). */
|
|
133
|
+
private readonly proposing;
|
|
134
|
+
private readonly grading;
|
|
135
|
+
/** The host's secrets as shown() last cut them, by their values, and the saved keys it read. */
|
|
136
|
+
private cut?;
|
|
137
|
+
private saved?;
|
|
138
|
+
constructor(options: LearningOptions, kernel: LearningKernel);
|
|
139
|
+
private get closing();
|
|
140
|
+
/** A run of `revision` about to be made for agent `agentId`. It learns when the server's switch (`--learning`) is on and
|
|
141
|
+
* its agent's definition says `learning: true`; then its seed is read now, before the run is made, so the folder is
|
|
142
|
+
* read once whatever the run's setup does, and what comes back pins it in the run once it is made and its input
|
|
143
|
+
* saved (a server that goes down during the copy leaves no learning saved: onLoad), at `at`: its
|
|
144
|
+
* learning, `seeded`, or `dropped` as `seed_failed` (a learning fault never refuses a run). Undefined when it does
|
|
145
|
+
* not learn. What the run reads under `# Learned` is its notes within the server's learning budget, told of
|
|
146
|
+
* `.learning/` only when its agent has the read tool, and cut of the host's secrets as they are then. */
|
|
147
|
+
onStart(agentId: string, revision: Revision): Promise<((started: Pick<StartedRun, "runId" | "dir" | "workspace">, at: string) => Promise<Learning>) | undefined>;
|
|
148
|
+
/** The run's serve.json holds `learning` now: the learning ledger's line for the run (usage.ts), once, when that
|
|
149
|
+
* learning has ended. Never rejects: a line not written is written by the next save, or by the next start's pass. */
|
|
150
|
+
onSaved(run: Pick<Run, "id" | "agentId">, learning: Learning | null | undefined): Promise<void>;
|
|
151
|
+
/** The run's job ended with `end`. True when its end-of-run turn is asked first: the run is finishing with that
|
|
152
|
+
* outcome, and is let go once the turn ends. False when it is let go now, its learning dropped when it skips the turn. */
|
|
153
|
+
beforeFinish(run: Run, end: {
|
|
154
|
+
outcome: Status;
|
|
155
|
+
error?: Run["error"];
|
|
156
|
+
abort?: boolean;
|
|
157
|
+
}): boolean;
|
|
158
|
+
/** A run read at a start, before the kernel holds it, `save` writing its serve.json: one a server went down while it
|
|
159
|
+
* copied the run's seed (running, its input saved and no learning, and a pin or a `work/.learning/` there) has both
|
|
160
|
+
* taken back, so it starts again with nothing learned, and its learning dropped as `seed_failed`, saved before the
|
|
161
|
+
* ledger's line (onSaved). Called before anything reads the run: its relaunch, a settle, a follow-up. A seed_failed
|
|
162
|
+
* run asks no end-of-run turn (reflectSkip). A copy that never began leaves nothing, and the learning stays null. */
|
|
163
|
+
onLoad(row: Pick<RunRow, "id" | "agent" | "state">, dir: string, meta: Run["meta"], save: () => Promise<void>): Promise<void>;
|
|
164
|
+
/** A run's process launched, handed the secrets named `names`: what each held then, as handover read it, kept beside
|
|
165
|
+
* the run while its learning is under way (a key replaced since stays refused in its notes). */
|
|
166
|
+
onLaunch(run: Run, names: readonly string[]): void;
|
|
167
|
+
/** A running run read at a start, `live` when its process serves it still. One a server left while its end-of-run turn
|
|
168
|
+
* ran is finishing with its job's outcome, and nothing opens it again; when its process lives, the turn is asked again
|
|
169
|
+
* under the same request id, which it takes once, and waited for. */
|
|
170
|
+
onAdopt(run: Run, live: boolean): void;
|
|
171
|
+
/** The run's end being written: its end-of-run turn's rows closed, and its learning settled from how the turn went;
|
|
172
|
+
* then what the turn answered, and what the user said in the run, kept in its directory before the run reads ended,
|
|
173
|
+
* so a follow-up that opens it again never changes what is checked. */
|
|
174
|
+
beforeSettle(run: Run, outcome: Status): Promise<void>;
|
|
175
|
+
/** The run's end written, as it would be without learning: what its end-of-run turn wrote checked, then graded and
|
|
176
|
+
* merged. Called only then, so a slow or failing check never holds the job. A run already `proposed` is graded: one
|
|
177
|
+
* a follow-up opened again mid-grade, whose server went while it ran, which the next start passed over as running.
|
|
178
|
+
* gradeOnce does nothing for any other state, nor while a grade of the run is in flight here. */
|
|
179
|
+
afterSettle(run: Run): Promise<void>;
|
|
180
|
+
/** A run that learns, opened again for a follow-up, before its process starts: `work/.learning/` laid again from its
|
|
181
|
+
* seed where the run took it away, so the follow-up finds the notes its instructions name where they say, and the
|
|
182
|
+
* learned skills its pin names laid again, fresh, so its process reads each where it was. A fault leaves it without. */
|
|
183
|
+
onReopen(run: Run): Promise<void>;
|
|
184
|
+
/** Its process launched again for the follow-up: an end-of-run turn its process went in would resume with the run, so
|
|
185
|
+
* it is aborted before the follow-up is sent. One that cannot be aborted runs out ahead of it, and its rows are never
|
|
186
|
+
* the follow-up's answer, which comes after them. */
|
|
187
|
+
afterReopen(run: Run): Promise<void>;
|
|
188
|
+
/** The server's start: the learning ledger read from now, beside the running runs' pass, never before it (a line
|
|
189
|
+
* written twice meanwhile is read once). What comes back takes every run once that pass is done: each ended run whose
|
|
190
|
+
* learning a server left between steps, what its end-of-run turn wrote not checked yet, or its proposal not graded or
|
|
191
|
+
* merged, is checked or graded now, once; a learning end saved and not in the ledger (a server that went between the
|
|
192
|
+
* two) is written there. */
|
|
193
|
+
recover(): (rows: readonly RunRow[]) => Promise<void>;
|
|
194
|
+
/** The server closing: a grade's screen and grader stop, and leave the run's learning `proposed`; nothing new starts. */
|
|
195
|
+
close(): void;
|
|
196
|
+
/** Once every run has settled: each check in flight, then each grade, ended. */
|
|
197
|
+
idle(): Promise<void>;
|
|
198
|
+
/** A held run's learning, in short, from memory (null when it does not learn); undefined for a run the kernel does not
|
|
199
|
+
* hold. For a count, which reads the rest from the learning ledger and never a run's files. */
|
|
200
|
+
heldLearning(runId: string): {
|
|
201
|
+
state: LearningState;
|
|
202
|
+
reason: LearningReason | null;
|
|
203
|
+
} | null | undefined;
|
|
204
|
+
/** The host's secrets as they are now, as a reader cuts them (secretsShown): the ones this server holds, the keys
|
|
205
|
+
* saved on it, and its tokens, as the learning routes cut them. Built again only once they change. Every run's view
|
|
206
|
+
* and every row of a list asks it, so the saved keys, which are read from their file and opened one by one, are read
|
|
207
|
+
* once and kept until a person saves or deletes one (keysChanged). */
|
|
208
|
+
shown(): Shown;
|
|
209
|
+
/** A key was saved on this server or deleted from it: the next view reads them again. */
|
|
210
|
+
keysChanged(): void;
|
|
211
|
+
/** A run's learning as its view shows it (learning.ts learningView), cut of the host's secrets now; `settled`, once
|
|
212
|
+
* the run has ended and settled, shows the notes it read. */
|
|
213
|
+
view(learning: Learning | undefined, settled: boolean): {
|
|
214
|
+
used?: import("./learning.js").NoteUsed[];
|
|
215
|
+
learned?: NoteLearned[];
|
|
216
|
+
pending?: import("./learning.js").NoteUsed[];
|
|
217
|
+
skills?: LearnedFile[];
|
|
218
|
+
workflows?: LearnedFile[];
|
|
219
|
+
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
220
|
+
reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "no_write_tool" | "tool_denied" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "screen" | "screen_down" | "grader" | "grade_failed" | null;
|
|
221
|
+
detail: string | null;
|
|
222
|
+
at: string;
|
|
223
|
+
} | null;
|
|
224
|
+
/** A run's learning as a list shows it (learning.ts shortLearning): from serve.json for a run the kernel does not hold. */
|
|
225
|
+
short(learning: Learning | null, settled: boolean): ({
|
|
226
|
+
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
227
|
+
reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "no_write_tool" | "tool_denied" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "screen" | "screen_down" | "grader" | "grade_failed" | null;
|
|
228
|
+
detail: string | null;
|
|
229
|
+
} & Omit<{
|
|
230
|
+
used?: import("./learning.js").NoteUsed[];
|
|
231
|
+
learned?: NoteLearned[];
|
|
232
|
+
pending?: import("./learning.js").NoteUsed[];
|
|
233
|
+
skills?: LearnedFile[];
|
|
234
|
+
workflows?: LearnedFile[];
|
|
235
|
+
state: "proposed" | "merged" | "seeded" | "reflecting" | "dropped";
|
|
236
|
+
reason: "cancelled" | "empty" | "unparsed" | "seed_failed" | "no_budget" | "unknown_cost" | "no_write_tool" | "tool_denied" | "crashed" | "reflect_timeout" | "reflect_failed" | "propose_failed" | "checker" | "screen" | "screen_down" | "grader" | "grade_failed" | null;
|
|
237
|
+
detail: string | null;
|
|
238
|
+
at: string;
|
|
239
|
+
}, "at" | "reason" | "state" | "detail">) | null;
|
|
240
|
+
/** How the runs `rows` holds that tried to learn fared, over `filter` (learningStats): a held run's learning from
|
|
241
|
+
* memory, any other's end from the learning ledger, never a run's files. */
|
|
242
|
+
counts(rows: readonly RunRow[], filter: AnalyticsFilter): Promise<ReturnType<typeof learningStats>>;
|
|
243
|
+
/** Agent `agentId`'s runs (`rows`, its own) as its learning view counts them, the ledger read once: how they fared
|
|
244
|
+
* (counts, less `runs`), and what learning changed (learningImpact), each run's learning from memory when the kernel
|
|
245
|
+
* holds it, else its end from its ledger line; never a run's files. */
|
|
246
|
+
ofAgent(rows: readonly RunRow[], agentId: string): Promise<{
|
|
247
|
+
counts: Omit<ReturnType<typeof learningStats>, "runs">;
|
|
248
|
+
impact: Impact;
|
|
249
|
+
}>;
|
|
250
|
+
/** What a run of `agentId` starts from: its learning folder's main (learning.ts), the folder made first when it is
|
|
251
|
+
* absent; else why it starts with nothing learned. A learning fault never refuses a run: a host without the git
|
|
252
|
+
* learning needs is said once, and a folder that cannot be made or read once per run. */
|
|
253
|
+
private seedFor;
|
|
254
|
+
/** Moves the run's learning on, and shows its row. What it keeps whatever it does after (learning.ts KEPT_LEARNING:
|
|
255
|
+
* the notes the run read, how many it started from, its answer's time and costs) stays with it. Saved by the caller,
|
|
256
|
+
* or with the run's end. */
|
|
257
|
+
private setLearning;
|
|
258
|
+
/** As the run settles, before its end is written: the notes its job read from its copy of the folder (notesRead), by
|
|
259
|
+
* their names in its seed, kept with its learning (`used`), so a view or a list reads them from serve.json and never
|
|
260
|
+
* from its rows again. Only a note the run started from counts: MEMORY.md, a file the run wrote there, and a note
|
|
261
|
+
* not in its seed are not notes it used. Read again at each settle, a follow-up's reads with the rest. A seed that
|
|
262
|
+
* cannot be read leaves what was there, and says why. */
|
|
263
|
+
private noteUsed;
|
|
264
|
+
private dropLearning;
|
|
265
|
+
/** Why a run that just ended asks no end-of-run turn: a drop's reason and detail; null when it does not learn, or asked
|
|
266
|
+
* one already (one per run, ever); undefined when it asks one. The cap keeps no reserve: a run its cap stopped has no
|
|
267
|
+
* room left, and one whose spend is unknown cannot be kept within its cap. */
|
|
268
|
+
private reflectSkip;
|
|
269
|
+
/** The run answered or failed: it is finishing with that outcome, and its harness is asked one end-of-run turn first.
|
|
270
|
+
* The turn is saved before it is asked, so a restart asks it again under the same id, never twice. */
|
|
271
|
+
private reflect;
|
|
272
|
+
/** Asks the end-of-run turn through the run's door and waits for its end, its deadline (the turn is aborted) or the
|
|
273
|
+
* process to go; then lets the run go. The turn answers with its notes: it writes nothing, so nothing the run left in
|
|
274
|
+
* its copy of the folder counts. */
|
|
275
|
+
private reflectTurn;
|
|
276
|
+
/** How the end-of-run turn ends: `ended` once the run's door says it is idle (the turn was taken before the submit was
|
|
277
|
+
* answered, so idle is after it), `timeout` at `deadline`, `gone` when the process went or the run was cancelled. */
|
|
278
|
+
private reflectEnd;
|
|
279
|
+
/** At the run's end: the end-of-run turn's rows closed, and its learning settled from how the turn went. A run that
|
|
280
|
+
* never left `seeded` went before it could reflect. */
|
|
281
|
+
private closeLearning;
|
|
282
|
+
/** What the run's end-of-run turn wrote, checked and kept as its proposal or dropped (propose.ts), once at a time, after
|
|
283
|
+
* the run has ended. Never rejects: `proposed` or `dropped`, `propose_failed` for a fault. A server that goes
|
|
284
|
+
* meanwhile leaves it `reflecting` in serve.json, and the next start checks it again. */
|
|
285
|
+
private proposeOnce;
|
|
286
|
+
/** The tools a run's workflow draft may name: its revision's granted tools a workflow node runs here (tools.ts
|
|
287
|
+
* learnedWorkflowTools); none for a revision not found, so a draft that names one is refused. */
|
|
288
|
+
private draftTools;
|
|
289
|
+
private propose;
|
|
290
|
+
/** The run's proposal merged into main or dropped (grade.ts), one grade at a time per agent, after the checks and
|
|
291
|
+
* never in a run's way. The verdict and what the grade spent are kept in serve.json before the merge, so a restart
|
|
292
|
+
* never asks the grader again; what it spent is in the ledger with the run's end. A server that closes mid-grade leaves the
|
|
293
|
+
* learning `proposed`, and its next start grades it. */
|
|
294
|
+
private gradeOnce;
|
|
295
|
+
private grade;
|
|
296
|
+
/** What a run's learning refuses, and cuts from what it says: the secrets this server holds, wherever its launcher put
|
|
297
|
+
* them, the keys saved on it, what each launch handed the run, and its own tokens. */
|
|
298
|
+
private refused;
|
|
299
|
+
/** This server's environment for a call of its own (a grade's screen and grader): its secrets readable, never a
|
|
300
|
+
* child's, the keys saved on it with them (a Jev key saved through the settings API screens as one in the environment
|
|
301
|
+
* does), and the test hooks a run's process gets. */
|
|
302
|
+
private hostEnv;
|
|
303
|
+
}
|
|
304
|
+
export {};
|