@trama-dev/runtime 0.6.1 → 0.8.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/agent-backend.d.ts +100 -0
- package/dist/agent-backend.js +4 -0
- package/dist/agent-host.d.ts +46 -7
- package/dist/agent-host.js +59 -19
- package/dist/agent-hosts.d.ts +8 -0
- package/dist/agent-hosts.js +123 -56
- package/dist/agent.d.ts +18 -5
- package/dist/agent.js +23 -64
- package/dist/bridge-client.d.ts +6 -2
- package/dist/bridge-client.js +7 -1
- package/dist/budget.d.ts +6 -0
- package/dist/budget.js +1 -0
- package/dist/client.d.ts +3 -2
- package/dist/client.js +146 -2
- package/dist/context.js +3 -2
- package/dist/history.d.ts +9 -0
- package/dist/history.js +98 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +73 -41
- package/dist/ipc-server.d.ts +2 -3
- package/dist/ipc-server.js +99 -38
- package/dist/journal-view.d.ts +8 -0
- package/dist/journal-view.js +63 -11
- package/dist/journal.d.ts +10 -4
- package/dist/journal.js +73 -7
- package/dist/merge-deeds.d.ts +22 -0
- package/dist/merge-deeds.js +201 -0
- package/dist/merge-doing.d.ts +9 -0
- package/dist/merge-doing.js +410 -0
- package/dist/merge-settle.d.ts +14 -0
- package/dist/merge-settle.js +166 -0
- package/dist/merge-shared.d.ts +64 -0
- package/dist/merge-shared.js +159 -0
- package/dist/merge.d.ts +150 -0
- package/dist/merge.js +209 -0
- package/dist/model-relay.d.ts +19 -0
- package/dist/model-relay.js +91 -9
- package/dist/model-request.d.ts +9 -0
- package/dist/model-request.js +185 -0
- package/dist/own-tools.d.ts +60 -0
- package/dist/own-tools.js +209 -0
- package/dist/path-guard.js +8 -6
- package/dist/pi-adapter.d.ts +32 -9
- package/dist/pi-adapter.js +198 -51
- package/dist/project.d.ts +39 -0
- package/dist/project.js +270 -0
- package/dist/replace-file.d.ts +13 -2
- package/dist/replace-file.js +23 -6
- package/dist/runner-backend.d.ts +43 -0
- package/dist/runner-backend.js +149 -0
- package/dist/runner-types.d.ts +26 -0
- package/dist/runner.d.ts +10 -125
- package/dist/runner.js +148 -461
- package/dist/schema.d.ts +45 -0
- package/dist/schema.js +113 -0
- package/dist/stopping.js +2 -3
- package/dist/tools.d.ts +8 -1
- package/dist/tools.js +36 -10
- package/dist/tree.d.ts +33 -149
- package/dist/tree.js +43 -1077
- package/dist/types.d.ts +182 -2
- package/dist/workspace.d.ts +28 -1
- package/dist/workspace.js +88 -13
- package/package.json +2 -2
package/dist/runner.d.ts
CHANGED
|
@@ -1,129 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { MakeRequest, RunOptions, ProgramResult } from "./runner-types.js";
|
|
2
|
+
import type { AgentUsage } from "./agent-backend.js";
|
|
3
3
|
import { type Budget, type Meter } from "./budget.js";
|
|
4
|
-
import { type
|
|
5
|
-
|
|
6
|
-
* Everything a project directory needs around program.ts before it can run:
|
|
7
|
-
* history/ and logs/, an ESM package.json, .gitignore entries, and links to the
|
|
8
|
-
* @trama-dev packages it can import.
|
|
9
|
-
* Idempotent — called before every run, so a freshly cloned project just works.
|
|
10
|
-
*/
|
|
11
|
-
export declare function ensureProjectScaffold(projectDir: string): void;
|
|
4
|
+
import { type Unmerged } from "./merge.js";
|
|
5
|
+
import { type Backend } from "./runner-backend.js";
|
|
12
6
|
/**
|
|
13
7
|
* The program-facing API, as shown to the LLM when it writes or repairs a
|
|
14
8
|
* program. This is the declaration file generated from types.ts, so the prompt
|
|
15
9
|
* cannot drift from the real API — doc comments included.
|
|
16
10
|
*/
|
|
17
11
|
export declare const RUNTIME_TYPES: string;
|
|
18
|
-
export declare function loadConfig(): TramaConfig;
|
|
19
|
-
/** The global config, with the model/provider a project was created with taking precedence. */
|
|
20
|
-
export declare function loadProjectConfig(projectDir: string, meta?: import("./meta.js").ProjectMeta): TramaConfig;
|
|
21
|
-
/**
|
|
22
|
-
* What does the LLM work for a project. The only place that picks a backend:
|
|
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.
|
|
37
|
-
*/
|
|
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
|
-
}
|
|
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
12
|
/** Run fn in a temp directory, clean up afterwards regardless of outcome — including this process being stopped. */
|
|
65
13
|
export declare function withTempDir<T>(prefix: string, fn: (dir: string) => Promise<T>): Promise<T>;
|
|
66
14
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
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.
|
|
82
|
-
*
|
|
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).
|
|
15
|
+
* How a run that failed is said to whoever asked for it: as a program's
|
|
16
|
+
* failure — which the reasons that begin so say for themselves, and is not
|
|
17
|
+
* said of them twice.
|
|
87
18
|
*/
|
|
88
|
-
|
|
89
|
-
among: string;
|
|
90
|
-
names: string[];
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
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.
|
|
107
|
-
*
|
|
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.
|
|
110
|
-
*
|
|
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.
|
|
121
|
-
*/
|
|
122
|
-
export declare function copyProjectWith(projectDir: string, privateDir: string, program?: string, among?: string): {
|
|
123
|
-
copy: string;
|
|
124
|
-
held: Tree;
|
|
125
|
-
beside: Beside;
|
|
126
|
-
};
|
|
19
|
+
export declare const failureOf: (reason: string | undefined) => string;
|
|
127
20
|
/** A line as it is shown for a run: under the run's name, if it has one. */
|
|
128
21
|
export declare const tagged: (label: string | undefined, line: string) => string;
|
|
129
22
|
/** The instructions a request for a fix is made under. (Exported so the tests' stand-in LLM can tell one from any other call.) */
|
|
@@ -232,14 +125,6 @@ export declare function installValidatedProgram(projectDir: string, validated: {
|
|
|
232
125
|
source: string;
|
|
233
126
|
repairedError?: string;
|
|
234
127
|
}, 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
128
|
/**
|
|
244
129
|
* What a project is made or changed under where a run's program asked for
|
|
245
130
|
* it: that run's — stopped with it, counted in its budget, shown under its
|
|
@@ -260,11 +145,11 @@ export type Making = (request: MakeRequest, asked: AskedToMake) => Promise<void>
|
|
|
260
145
|
interface AskedFor {
|
|
261
146
|
/** How many runs deep it is: one more than the run that asked. */
|
|
262
147
|
depth: number;
|
|
263
|
-
/** The call that asked for it: which run's, and which of that run's calls. */
|
|
148
|
+
/** The call that asked for it: which run's, and which of that run's calls — or none of them, where the run itself asked: for a fix. */
|
|
264
149
|
parent: {
|
|
265
150
|
run: string;
|
|
266
151
|
journal: string;
|
|
267
|
-
seq
|
|
152
|
+
seq?: number;
|
|
268
153
|
};
|
|
269
154
|
/** Called once this run has a journal of its own. */
|
|
270
155
|
started(run: string, journal: string): void;
|