@trama-dev/runtime 0.4.0 → 0.6.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.
Files changed (56) hide show
  1. package/README.md +4 -3
  2. package/dist/abort.d.ts +12 -0
  3. package/dist/abort.js +31 -0
  4. package/dist/agent-backend.d.ts +127 -7
  5. package/dist/agent-backend.js +38 -19
  6. package/dist/agent-host.d.ts +50 -0
  7. package/dist/agent-host.js +97 -0
  8. package/dist/agent-hosts.d.ts +14 -0
  9. package/dist/agent-hosts.js +321 -0
  10. package/dist/agent.d.ts +26 -3
  11. package/dist/agent.js +165 -43
  12. package/dist/bridge-client.d.ts +6 -0
  13. package/dist/bridge-client.js +69 -16
  14. package/dist/budget.d.ts +52 -0
  15. package/dist/budget.js +118 -0
  16. package/dist/child-process.d.ts +18 -0
  17. package/dist/child-process.js +38 -9
  18. package/dist/client.d.ts +2 -1
  19. package/dist/client.js +9 -19
  20. package/dist/context.d.ts +36 -7
  21. package/dist/context.js +83 -92
  22. package/dist/errors.d.ts +2 -0
  23. package/dist/errors.js +2 -0
  24. package/dist/index.d.ts +7 -2
  25. package/dist/index.js +254 -88
  26. package/dist/ipc-server.d.ts +14 -5
  27. package/dist/ipc-server.js +174 -144
  28. package/dist/journal-view.d.ts +2 -0
  29. package/dist/journal-view.js +52 -7
  30. package/dist/journal.d.ts +27 -9
  31. package/dist/journal.js +216 -79
  32. package/dist/meta.d.ts +18 -0
  33. package/dist/meta.js +29 -0
  34. package/dist/model-relay.d.ts +130 -0
  35. package/dist/model-relay.js +339 -0
  36. package/dist/path-guard.d.ts +128 -19
  37. package/dist/path-guard.js +384 -68
  38. package/dist/pi-adapter.d.ts +35 -9
  39. package/dist/pi-adapter.js +865 -66
  40. package/dist/replace-file.d.ts +31 -0
  41. package/dist/replace-file.js +75 -0
  42. package/dist/runner-types.d.ts +35 -0
  43. package/dist/runner.d.ts +202 -30
  44. package/dist/runner.js +949 -273
  45. package/dist/serializable.d.ts +10 -4
  46. package/dist/serializable.js +56 -31
  47. package/dist/stopping.d.ts +37 -3
  48. package/dist/stopping.js +167 -21
  49. package/dist/tools.d.ts +2 -1
  50. package/dist/tools.js +90 -21
  51. package/dist/tree.d.ts +241 -0
  52. package/dist/tree.js +1431 -0
  53. package/dist/types.d.ts +106 -15
  54. package/dist/workspace.d.ts +7 -0
  55. package/dist/workspace.js +93 -104
  56. package/package.json +1 -1
@@ -0,0 +1,31 @@
1
+ /** Whether a file name is that of a temp file made here — not content, though it sits among it for a moment. */
2
+ export declare const isStagedName: (name: string) => boolean;
3
+ /**
4
+ * A name beside a destination for what is to take its place. It is not made
5
+ * of the destination's own: a name near the longest a directory takes leaves
6
+ * no room to add to.
7
+ */
8
+ export declare const stagedNameFor: (destination: string) => string;
9
+ export interface StagedFile {
10
+ /** Where the content will be: the path given, with every link on the way followed. */
11
+ destination: string;
12
+ /** Move the content into place. If that cannot be done, nothing is left behind. */
13
+ commit(): void;
14
+ /** Call it off: the destination stays as it is. */
15
+ discard(): void;
16
+ }
17
+ /**
18
+ * Write `content` beside where `relativePath` under `rootDir` leads, ready to
19
+ * take its place.
20
+ *
21
+ * The destination is where the links on the way point, so a link is written
22
+ * through, not replaced. It must be a file's place: the root itself is
23
+ * refused, since "beside" it is outside it. Directories on the way are
24
+ * created. The temp file is created, never opened: a name that is already
25
+ * there — a link somebody planted, say — is not written through. A file that
26
+ * is being replaced hands on its permissions, as it would if it were written
27
+ * into — unless `mode` says what the new file's are. It is a new file all the
28
+ * same, so a second hard link to the old one, or its owner, are not carried
29
+ * over.
30
+ */
31
+ export declare function stageFile(rootDir: string, relativePath: string, content: string | Buffer, mode?: number): StagedFile;
@@ -0,0 +1,75 @@
1
+ // Putting a file in place in one move.
2
+ //
3
+ // The content is written to a temp file beside where it is going, and the
4
+ // temp file is then renamed over the destination. Whoever reads the path sees
5
+ // the old content or the new, never part of either — and between the two
6
+ // steps there is a moment to do something that must not be left half-done
7
+ // (see installValidatedProgram), or to call the whole thing off.
8
+ import { chmodSync, closeSync, fdatasyncSync, mkdirSync, openSync, renameSync, rmSync, statSync, writeFileSync } from "fs";
9
+ import { randomBytes } from "crypto";
10
+ import { dirname, join } from "path";
11
+ import { guardPath, realRootOf } from "./path-guard.js";
12
+ /** Whether a file name is that of a temp file made here — not content, though it sits among it for a moment. */
13
+ export const isStagedName = (name) => /\.trama-tmp-[0-9a-f]{12}$/.test(name);
14
+ /**
15
+ * A name beside a destination for what is to take its place. It is not made
16
+ * of the destination's own: a name near the longest a directory takes leaves
17
+ * no room to add to.
18
+ */
19
+ export const stagedNameFor = (destination) => join(dirname(destination), `.trama-tmp-${randomBytes(6).toString("hex")}`);
20
+ /**
21
+ * Write `content` beside where `relativePath` under `rootDir` leads, ready to
22
+ * take its place.
23
+ *
24
+ * The destination is where the links on the way point, so a link is written
25
+ * through, not replaced. It must be a file's place: the root itself is
26
+ * refused, since "beside" it is outside it. Directories on the way are
27
+ * created. The temp file is created, never opened: a name that is already
28
+ * there — a link somebody planted, say — is not written through. A file that
29
+ * is being replaced hands on its permissions, as it would if it were written
30
+ * into — unless `mode` says what the new file's are. It is a new file all the
31
+ * same, so a second hard link to the old one, or its owner, are not carried
32
+ * over.
33
+ */
34
+ export function stageFile(rootDir, relativePath, content, mode) {
35
+ const destination = guardPath(rootDir, relativePath);
36
+ if (destination === realRootOf(rootDir)) {
37
+ throw new Error(`Not a file path: "${relativePath}" is the directory itself`);
38
+ }
39
+ mkdirSync(dirname(destination), { recursive: true });
40
+ const staged = stagedNameFor(destination);
41
+ const discard = () => { try {
42
+ rmSync(staged, { force: true });
43
+ }
44
+ catch { /* best-effort */ } };
45
+ const fd = openSync(staged, "wx");
46
+ try {
47
+ try {
48
+ writeFileSync(fd, content);
49
+ fdatasyncSync(fd);
50
+ }
51
+ finally {
52
+ closeSync(fd);
53
+ }
54
+ const permissions = mode ?? statSync(destination, { throwIfNoEntry: false })?.mode;
55
+ if (permissions !== undefined)
56
+ chmodSync(staged, permissions & 0o777);
57
+ }
58
+ catch (err) {
59
+ discard();
60
+ throw err;
61
+ }
62
+ return {
63
+ destination,
64
+ discard,
65
+ commit() {
66
+ try {
67
+ renameSync(staged, destination);
68
+ }
69
+ catch (err) {
70
+ discard();
71
+ throw err;
72
+ }
73
+ },
74
+ };
75
+ }
@@ -1,3 +1,5 @@
1
+ import type { Budget } from "./budget.js";
2
+ export type { Budget };
1
3
  export interface ProgramResult {
2
4
  status: "done" | "yielded" | "failed";
3
5
  /** Yield reason, or error summary for failed. */
@@ -25,6 +27,25 @@ export interface RunOptions {
25
27
  workspaceDir?: string;
26
28
  /** A name for this run — a participant's, say. Its output is shown under it. */
27
29
  label?: string;
30
+ /**
31
+ * Variables for the run, over the runner's own: its program has them, and
32
+ * so do the shell commands it runs, its agents, and the runs it asks for,
33
+ * each of which may be given more. (An agent has them by being served in a
34
+ * process of its own, started with them: which pi it finds, and which key
35
+ * for a provider, are then the run's.) One given as undefined is one not
36
+ * given. The journal has their names, not what they hold.
37
+ */
38
+ env?: Record<string, string | undefined>;
39
+ /**
40
+ * What the run may use of a model, in all: its program's agent calls, the
41
+ * requests for a fix, and everything the runs it asks for use. Once it is
42
+ * spent, a call that asks a model is refused, one that is under way is
43
+ * stopped where it would ask its model again, and no repair is tried. A
44
+ * run a program asks for is held to the budget of the run that asked as
45
+ * well: it can be given less, never more. Without it, a run nobody's
46
+ * program asked for has the config's `budget`, if that has one.
47
+ */
48
+ budget?: Budget;
28
49
  /**
29
50
  * Stops the run: its program is stopped, no repair is attempted, and the
30
51
  * run ends as failed. A fix that was being tried leaves no trace.
@@ -39,4 +60,18 @@ export interface TramaConfig extends ModelConfig {
39
60
  defaultMaxIterations: number;
40
61
  /** How many runs of a project keep their journal. 0 records nothing. */
41
62
  journalRuns: number;
63
+ /**
64
+ * What becomes of what the agent that writes or fixes a program changes in
65
+ * the project beside the program — a package it installs, a file it puts
66
+ * right. "keep": it reaches the project with a program that then works,
67
+ * and only with one. "discard": none of it does; the program is all that
68
+ * is taken from the agent.
69
+ */
70
+ agentChanges: "keep" | "discard";
71
+ /**
72
+ * What a run may use of a model (see RunOptions) where it is not given a
73
+ * budget of its own — and what a `create` or an `update` may: writing the
74
+ * program and validating it, together. Without it, nothing is capped.
75
+ */
76
+ budget?: Budget;
42
77
  }
package/dist/runner.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { RunOptions, TramaConfig, ProgramResult } from "./runner-types.js";
2
- import { type AgentBackend } from "./agent-backend.js";
2
+ import type { AgentBackend, AgentUsage } from "./agent-backend.js";
3
+ import { type Budget, type Meter } from "./budget.js";
4
+ import { type Tree, type Unmerged } from "./tree.js";
3
5
  /**
4
6
  * Everything a project directory needs around program.ts before it can run:
5
7
  * history/ and logs/, an ESM package.json, .gitignore entries, and links to the
@@ -15,47 +17,118 @@ export declare function ensureProjectScaffold(projectDir: string): void;
15
17
  export declare const RUNTIME_TYPES: string;
16
18
  export declare function loadConfig(): TramaConfig;
17
19
  /** The global config, with the model/provider a project was created with taking precedence. */
18
- export declare function loadProjectConfig(projectDir: string): TramaConfig;
20
+ export declare function loadProjectConfig(projectDir: string, meta?: import("./meta.js").ProjectMeta): TramaConfig;
19
21
  /**
20
22
  * What does the LLM work for a project. The only place that picks a backend:
21
23
  * everything else is handed one and does not know which it is.
24
+ *
25
+ * It is also where what is asked of a model is counted, and held to a
26
+ * budget (`meter`): every call passes here, whoever makes it. A call that
27
+ * comes when the budget is spent is refused; one under way is stopped where
28
+ * its agent would ask the model again — what the model was asked before
29
+ * that is used, and what it was answering is let finish. `spent` is told
30
+ * why, the first time either happens.
31
+ */
32
+ export declare function createBackend(config: TramaConfig, meter?: Meter, spent?: (why: string) => void, env?: Record<string, string>): Backend;
33
+ /**
34
+ * Say that a budget is spent, once for the budget — whoever comes up against
35
+ * it first: the run's own backend, or the backend of a project being made
36
+ * for the run's program, of which there may be many.
22
37
  */
23
- export declare function createBackend(config: TramaConfig): AgentBackend;
38
+ export declare const saysOnce: (meter: Meter, say: (why: string) => void) => (why: string) => void;
39
+ /** A backend as the runner holds it: one whose cancelled calls are answered at once, and can be waited for apart. */
40
+ export interface Backend extends AgentBackend {
41
+ /** Why nothing more may be asked of it — the budget it counts in is spent — or nothing, while something may. */
42
+ spent?(): string | undefined;
43
+ /** Why a call of it was first refused or stopped for the budget, if one was — whatever the count has come to since. */
44
+ refused?(): string | undefined;
45
+ /** Whether what its calls use is held to anything: then what a call it cut off used is to be waited for, recorded or not. */
46
+ counts?(): boolean;
47
+ /**
48
+ * End what the backend kept to serve calls with — a process of its own for
49
+ * those that have extensions. Whatever it served is over: a run, a
50
+ * validation. (Asked again after this, it starts anew.)
51
+ */
52
+ close?(): Promise<void>;
53
+ /**
54
+ * Resolves when the backend has let go of the calls that were cancelled so
55
+ * far: whoever cancelled one went on at once, and the backend still had to
56
+ * stop what it was doing, and to say what the call had used. They are
57
+ * waited for no longer than anything asked to stop is.
58
+ */
59
+ letGo(): Promise<void>;
60
+ }
24
61
  export declare function loadState(projectDir: string): Record<string, unknown>;
62
+ /** Save the current program.ts as the next version of the project, and record why. */
63
+ export declare function copyToHistory(projectDir: string, reason: string, detail?: string): void;
64
+ /** Run fn in a temp directory, clean up afterwards regardless of outcome — including this process being stopped. */
65
+ export declare function withTempDir<T>(prefix: string, fn: (dir: string) => Promise<T>): Promise<T>;
25
66
  /**
26
- * Save the current program.ts as the next version: copy it to history/NNNN.ts
27
- * and record why in index.jsonl.
67
+ * Have what is beside a project be beside a copy of it: for each name in the
68
+ * directory the project is in, a link of that name, to it, in the directory
69
+ * the copy is in. So ".." leads from the copy to what it leads to from the
70
+ * project — a file beside it that its program reads, a module it imports
71
+ * from there, a project beside it that it runs.
72
+ *
73
+ * What is come to that way is the real thing, not a copy: what is done to it
74
+ * is done. (So is what it comes to in turn — and from a directory beside the
75
+ * project, ".." is the directory the project is in: by its name from there,
76
+ * the project itself, and not the copy.) One step up is all there is: what
77
+ * the directory the project is in is itself beside is not beside the copy.
78
+ * And it is as much as can be found out: a directory that may not be listed
79
+ * has nothing told of it, and a name the copy's own directory will not have
80
+ * beside the copy is left out — the project's own, which is the copy's
81
+ * there, before any.
28
82
  *
29
- * (See installValidatedProgram for how a create or update is recorded.)
83
+ * Returns the names put there, and the directory they are names in. A name
84
+ * is not the thing: one that is made beside the copy, or taken away there,
85
+ * is made or taken away in a directory that goes with the copy, and not
86
+ * beside the project (see strandedBeside).
30
87
  */
31
- export declare function copyToHistory(projectDir: string, reason: string, detail?: string): void;
32
- type DirSnapshot = Map<string, {
33
- size: number;
34
- mtimeMs: number;
35
- }>;
36
- /** Record all files in a directory with their size and mtime for change detection. */
37
- export declare function snapshotDir(dir: string, prefix?: string): DirSnapshot;
88
+ interface Beside {
89
+ among: string;
90
+ names: string[];
91
+ }
38
92
  /**
39
- * Merge what a run did to a staged copy back into the real directory, with a
40
- * three-way check so that nothing changed in the real directory meanwhile —
41
- * by the user, or by another run of the same project — is overwritten.
93
+ * Make, in `privateDir`, a copy of a project — to try a program in, or for an
94
+ * agent to look at and work in: what the project is and holds (see copyTree),
95
+ * with `program` as its program.ts where one is given. Returns where the
96
+ * copy is, what the project was when it was copied, and the names put beside
97
+ * the copy for what is beside the project.
98
+ *
99
+ * The copy allows what the project allows, to everybody: so it is made in a
100
+ * directory that is this runner's alone, and is nobody else's to come to. It
101
+ * has the project's name there, and what is beside the project beside it (see
102
+ * standAmong) — nothing else is to be in that directory. Where what is
103
+ * copied is itself a copy of a project — as where a candidate is validated
104
+ * in the project as an agent prepared it — `among` names the project: what
105
+ * is beside the copy is what is beside that, and nothing an agent made
106
+ * beside its own.
42
107
  *
43
- * @param stagedDir - the copy after the run (source of changes)
44
- * @param realDir - the real directory (destination)
45
- * @param stagedBefore - snapshot of the copy before the run (detects what the run changed)
46
- * @param realSeed - snapshot of the real directory when the copy was taken (detects concurrent changes)
108
+ * The project's journals are not carried over: they are the record of its
109
+ * runs, not part of what a run works on, and a copy is where a run is tried.
47
110
  *
48
- * For each file the run touched in the copy:
49
- * - Created: copied, unless that path has meanwhile appeared in the real directory.
50
- * - Modified: copied only if the real file still matches realSeed.
51
- * - Deleted: deleted only if the real file still matches realSeed.
52
- * Best-effort: anything that cannot be merged safely is skipped, never thrown.
111
+ * In everything else the copy is as the project is, so that what a program
112
+ * can do in the one it can do in the other: what a run did in a copy is
113
+ * merged back into the project, and must not have been possible only there.
114
+ * The one exception is the program: the one to be tried, in the place of
115
+ * the project's. It allows what the project's allows — and its owner to
116
+ * replace it — and is put there whatever the directory it goes in allows:
117
+ * a copy is where programs are tried and replaced, and whether the project's
118
+ * own may be is said of the project, where one is to take its place (see
119
+ * whyNotReplaceable). A project with a directory where its program should be
120
+ * has no place for one, and is not copied to try one in.
53
121
  */
54
- export declare function commitStagedChanges(stagedDir: string, realDir: string, stagedBefore: DirSnapshot, realSeed: DirSnapshot): void;
55
- /** Run fn in a temp directory, clean up afterwards regardless of outcome — including this process being stopped. */
56
- export declare function withTempDir<T>(prefix: string, fn: (dir: string) => Promise<T>): Promise<T>;
122
+ export declare function copyProjectWith(projectDir: string, privateDir: string, program?: string, among?: string): {
123
+ copy: string;
124
+ held: Tree;
125
+ beside: Beside;
126
+ };
127
+ /** A line as it is shown for a run: under the run's name, if it has one. */
128
+ export declare const tagged: (label: string | undefined, line: string) => string;
57
129
  /** The instructions a request for a fix is made under. (Exported so the tests' stand-in LLM can tell one from any other call.) */
58
130
  export declare const REPAIR_SYSTEM_PROMPT = "You are a TypeScript repair tool.";
131
+ export declare const shownPaths: (paths: string[]) => string;
59
132
  /**
60
133
  * Validate a candidate program.ts for a project without touching what the
61
134
  * project holds: run it (with repair) in a throwaway copy. The one thing left
@@ -63,20 +136,93 @@ export declare const REPAIR_SYSTEM_PROMPT = "You are a TypeScript repair tool.";
63
136
  * the candidate itself, or a repaired version of it, with the failure that was
64
137
  * repaired. Throws if it cannot be made to run.
65
138
  *
139
+ * `as` names a directory that is the project as it is to be once the
140
+ * program is in it — the copy the agent that wrote the program worked in,
141
+ * with what it made there (see Prepared). The copy the program is run in is
142
+ * then a copy of that, which is no more touched than the project is, and it
143
+ * stands among what the project stands among.
144
+ *
145
+ * A repair made here is of the program alone (see requestRepair): the copy a
146
+ * candidate runs in goes whole, with whatever was done in it.
147
+ *
148
+ * Where the agent left its copy so that no copy can be made of it — a file
149
+ * nobody may read, say — the candidate is validated in the project as it is,
150
+ * as it would be were nothing of the agent's kept: and `alone` says why,
151
+ * for then nothing of the agent's is to be kept. (A caller that knows of such
152
+ * a reason beforehand gives it as `alone`, with no `as`.) That is said when
153
+ * it is found, whatever then comes of the candidate.
154
+ *
66
155
  * Only the project's own files are shielded. What the program does beyond
67
156
  * them — network calls, shell commands, agent calls — is real. A run it asks
68
157
  * its runner for is not started: the validation ends where it asks for the
69
158
  * first.
70
159
  */
71
- export declare function validateProgram(projectDir: string, backend: AgentBackend, candidate: string, options: {
160
+ export declare function validateProgram(projectDir: string, backend: Backend, candidate: string, options: {
72
161
  timeout: number;
73
162
  maxRepairAttempts: number;
74
163
  maxIterations: number;
75
164
  journalRuns?: number;
165
+ signal?: AbortSignal;
166
+ as?: string;
167
+ alone?: string;
168
+ budget?: Budget;
169
+ wrote?: AgentUsage[];
170
+ /** Where a run's program asked for the project to be made or changed: the run's name and variables are the validation's, and the two journals point at each other. */
171
+ label?: string;
172
+ env?: Record<string, string>;
173
+ askedFor?: Pick<AskedFor, "parent" | "started">;
76
174
  }): Promise<{
77
175
  source: string;
78
176
  repairedError?: string;
177
+ alone?: string;
79
178
  }>;
179
+ /**
180
+ * A copy of a project for the agent that writes its program to work in: to
181
+ * look at what the program is to work with, and to make what the program
182
+ * needs beside it — a package installed, a module, a file. `keep` carries
183
+ * what the agent made there into the project, and returns what did not
184
+ * arrive, with the paths it made or changed: it is for when the program has
185
+ * been found to work in a copy of this one, and is in the project.
186
+ *
187
+ * The program is no part of that: it is what the agent answers with,
188
+ * validated and installed as that, and what the agent left at program.ts —
189
+ * the name, each link it led through, and the file it led to — stays in its
190
+ * copy. So that the answer is validated where it will be installed, `ready`
191
+ * has the name program.ts be, in the copy, what it was before the agent
192
+ * worked: a link the agent put there is taken away, and one it took away is
193
+ * put back. Where the way from the name is then still not what it was — a
194
+ * link further along made to lead elsewhere, a directory on it replaced —
195
+ * the copy is no place to validate the answer in, and `ready` says so.
196
+ */
197
+ export interface Prepared {
198
+ /** Where the copy is. */
199
+ copy: string;
200
+ /**
201
+ * Make the copy what a candidate can be validated in a copy of (see above).
202
+ * Throws if it cannot be: what is at the copy's path is no longer the copy
203
+ * (moved away, say, with a link left in its place), or program.ts does not
204
+ * lead there where it led.
205
+ */
206
+ ready(): void;
207
+ keep(): {
208
+ changed: string[];
209
+ unmerged: Unmerged[];
210
+ };
211
+ }
212
+ export declare function prepareProject(projectDir: string, privateDir: string): Prepared;
213
+ /**
214
+ * Why a project's program cannot be given a successor — or null if it can.
215
+ *
216
+ * A program is replaced by a new file taking its place, which the system
217
+ * allows whatever the old file's permissions say. So the old file is asked: a
218
+ * program its owner has made read-only is not replaced. A directory in its
219
+ * place is no program, and no file takes the place of one. And the new file
220
+ * has to be made beside it, in a directory that is there or can be made.
221
+ *
222
+ * This is the rule stageProgram enforces. It is also asked before work whose
223
+ * only use is a new program — an update, a repair — is begun.
224
+ */
225
+ export declare function whyNotReplaceable(projectDir: string): string | null;
80
226
  /**
81
227
  * Make a validated program the project's program.ts and record it as a new
82
228
  * version. A repair made while validating is not a version of its own — it is
@@ -86,6 +232,30 @@ export declare function installValidatedProgram(projectDir: string, validated: {
86
232
  source: string;
87
233
  repairedError?: string;
88
234
  }, reason: "create" | "update", prompt: string): void;
235
+ /** A project a program asks its runner to make, or to change (see createProject and updateProject). */
236
+ export interface MakeRequest {
237
+ kind: "create" | "update";
238
+ name: string;
239
+ prompt: string;
240
+ model?: string;
241
+ args?: Record<string, unknown>;
242
+ }
243
+ /**
244
+ * What a project is made or changed under where a run's program asked for
245
+ * it: that run's — stopped with it, counted in its budget, shown under its
246
+ * name, validated with its variables, and on record beside its journal.
247
+ */
248
+ export interface AskedToMake extends Pick<AskedFor, "parent" | "started" | "above"> {
249
+ signal: AbortSignal;
250
+ label?: string;
251
+ env?: Record<string, string>;
252
+ }
253
+ /**
254
+ * How a project is made or changed for a program that asks its runner to.
255
+ * The runner is handed it by what starts runs (the runner surface): it is
256
+ * that which knows how a program is written, and it stands on this.
257
+ */
258
+ export type Making = (request: MakeRequest, asked: AskedToMake) => Promise<void>;
89
259
  /** What a run is told when a program asked for it, rather than a person or a host. */
90
260
  interface AskedFor {
91
261
  /** How many runs deep it is: one more than the run that asked. */
@@ -98,6 +268,8 @@ interface AskedFor {
98
268
  };
99
269
  /** Called once this run has a journal of its own. */
100
270
  started(run: string, journal: string): void;
271
+ /** The count of what the run that asked uses of a model: what this one uses is counted there too, and held to it. */
272
+ above?: Meter;
101
273
  }
102
274
  /**
103
275
  * Run a project, in this process: this is what a runner does.
@@ -106,5 +278,5 @@ interface AskedFor {
106
278
  * call). One runner carries the whole tree of runs, so it is also where the
107
279
  * tree is kept from growing without bound.
108
280
  */
109
- export declare function runProgram(options: RunOptions, askedFor?: AskedFor): Promise<ProgramResult>;
281
+ export declare function runProgram(options: RunOptions, askedFor?: AskedFor, making?: Making): Promise<ProgramResult>;
110
282
  export {};