@notation/factory 0.2.2 → 0.5.1
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/contracts/runner.ts +32 -1
- package/deployer/sdk.gen.ts +1 -1
- package/index.ts +1 -1
- package/package.json +1 -1
- package/resources/random-key.ts +43 -0
- package/resources/router-sync.ts +27 -11
- package/router/admin.ts +100 -0
- package/router/channel.ts +65 -11
- package/router/deliveries.ts +126 -0
- package/router/handle.test.ts +613 -18
- package/router/handle.ts +538 -112
- package/router/index.ts +24 -38
- package/router/run.ts +45 -5
- package/router/sync.ts +22 -0
- package/runner/index.ts +369 -80
- package/runner/runner.test.ts +485 -78
package/contracts/runner.ts
CHANGED
|
@@ -11,10 +11,18 @@ import type { Run } from "../router/run.ts";
|
|
|
11
11
|
export type RunContext = {
|
|
12
12
|
/** The run's worktree. */
|
|
13
13
|
cwd: string;
|
|
14
|
+
/**
|
|
15
|
+
* The conversation's messages that the agent hasn't seen, which the
|
|
16
|
+
* runner reads when the run starts. The runner writes it to the CLI's
|
|
17
|
+
* stdin, since a whole thread can be longer than one argument may be.
|
|
18
|
+
*/
|
|
19
|
+
prompt: string;
|
|
14
20
|
/** The runner's system prompt, followed by the agent's own. */
|
|
15
21
|
systemPrompt: string;
|
|
16
22
|
/** The runner's state directory, `/data`. */
|
|
17
23
|
dataDir: string;
|
|
24
|
+
/** The agent's config directory, which the CLI reads in place of `~/<configDir>`. */
|
|
25
|
+
configDir: string;
|
|
18
26
|
};
|
|
19
27
|
|
|
20
28
|
/** What a runtime's CLI said at the end of a run. */
|
|
@@ -26,14 +34,37 @@ export type RuntimeRunner = {
|
|
|
26
34
|
command: string;
|
|
27
35
|
/** The CLI's name, for errors. */
|
|
28
36
|
name: string;
|
|
29
|
-
/**
|
|
37
|
+
/** The CLI's config directory, relative to the home, such as `.claude`. */
|
|
38
|
+
configDir: string;
|
|
39
|
+
/**
|
|
40
|
+
* The environment that has the CLI read `dir` as its config directory.
|
|
41
|
+
* The runner gives each agent a directory of its own. Without it, the
|
|
42
|
+
* agents of the runtime share `~/<configDir>`.
|
|
43
|
+
*/
|
|
44
|
+
configEnv?(dir: string): Record<string, string>;
|
|
45
|
+
/**
|
|
46
|
+
* Files that the CLI reads from the home, but from its config directory
|
|
47
|
+
* once `configEnv` moves it, such as Claude Code's `.claude.json`. The
|
|
48
|
+
* runner writes `~/<file>` to the agent's config directory.
|
|
49
|
+
*/
|
|
50
|
+
homeFiles?: string[];
|
|
51
|
+
/** Where the CLI keeps its sessions' transcripts, relative to its config directory, in a directory per working directory. */
|
|
30
52
|
transcripts: string;
|
|
31
53
|
/** The CLI's arguments for a run. */
|
|
32
54
|
args(run: Run, context: RunContext): Promise<string[]>;
|
|
55
|
+
/** What the runner writes to the CLI's stdin. Without it, the runner writes the prompt. */
|
|
56
|
+
input?(context: RunContext): string;
|
|
33
57
|
/** The arguments that resume a session. */
|
|
34
58
|
resume(sessionId: string): string[];
|
|
35
59
|
/** Reads the CLI's output. Returns undefined if it isn't the CLI's output. */
|
|
36
60
|
parse(stdout: string): RuntimeOutput | undefined;
|
|
61
|
+
/**
|
|
62
|
+
* Reads one line of the CLI's output while it runs, and returns the text
|
|
63
|
+
* of the agent's message on that line, if it has one. The runner posts
|
|
64
|
+
* each message in place of the last, until the final reply replaces
|
|
65
|
+
* them. Without it, the runner posts only the final reply.
|
|
66
|
+
*/
|
|
67
|
+
message?(line: string): string | undefined;
|
|
37
68
|
/** Extra environment for the CLI. */
|
|
38
69
|
env?: Record<string, string>;
|
|
39
70
|
};
|