@skillcdn/console 0.5.0 → 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/README.md +68 -11
- package/SKILLCDN.md +3 -3
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +3 -2
- package/dist/agent-page.js.map +1 -1
- package/dist/api.d.ts +7 -6
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +6 -5
- package/dist/api.js.map +1 -1
- package/dist/charts.d.ts +103 -0
- package/dist/charts.d.ts.map +1 -0
- package/dist/charts.js +182 -0
- package/dist/charts.js.map +1 -0
- package/dist/cli/cli.d.ts +26 -2
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +1304 -383
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/command-words.d.ts +20 -0
- package/dist/cli/command-words.d.ts.map +1 -0
- package/dist/cli/command-words.js +51 -0
- package/dist/cli/command-words.js.map +1 -0
- package/dist/cli/credentials.d.ts +54 -5
- package/dist/cli/credentials.d.ts.map +1 -1
- package/dist/cli/credentials.js +126 -20
- package/dist/cli/credentials.js.map +1 -1
- package/dist/cli/directory.d.ts +19 -4
- package/dist/cli/directory.d.ts.map +1 -1
- package/dist/cli/directory.js +16 -8
- package/dist/cli/directory.js.map +1 -1
- package/dist/cli/format.d.ts +65 -8
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +242 -37
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts +13 -4
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +92 -54
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/main.js +76 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/pack.d.ts +69 -60
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +241 -270
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/plugin-check.d.ts +42 -0
- package/dist/cli/plugin-check.d.ts.map +1 -1
- package/dist/cli/plugin-check.js +221 -36
- package/dist/cli/plugin-check.js.map +1 -1
- package/dist/cli/plugin-cli.d.ts +6 -1
- package/dist/cli/plugin-cli.d.ts.map +1 -1
- package/dist/cli/plugin-cli.js +21 -4
- package/dist/cli/plugin-cli.js.map +1 -1
- package/dist/cli/plugin-main.js +1 -0
- package/dist/cli/plugin-main.js.map +1 -1
- package/dist/cli/serve.d.ts +33 -1
- package/dist/cli/serve.d.ts.map +1 -1
- package/dist/cli/serve.js +252 -3
- package/dist/cli/serve.js.map +1 -1
- package/dist/client.d.ts +48 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +72 -80
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +64 -1
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +244 -96
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/charts.d.ts +157 -0
- package/dist/components/charts.d.ts.map +1 -0
- package/dist/components/charts.js +182 -0
- package/dist/components/charts.js.map +1 -0
- package/dist/components/desk-records.d.ts +102 -0
- package/dist/components/desk-records.d.ts.map +1 -0
- package/dist/components/desk-records.js +221 -0
- package/dist/components/desk-records.js.map +1 -0
- package/dist/components/desk.d.ts +85 -0
- package/dist/components/desk.d.ts.map +1 -0
- package/dist/components/desk.js +135 -0
- package/dist/components/desk.js.map +1 -0
- package/dist/components/event-feed.d.ts.map +1 -1
- package/dist/components/event-feed.js +4 -1
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/home.d.ts.map +1 -1
- package/dist/components/home.js +4 -2
- package/dist/components/home.js.map +1 -1
- package/dist/components/plugin-settings.d.ts.map +1 -1
- package/dist/components/plugin-settings.js +54 -3
- package/dist/components/plugin-settings.js.map +1 -1
- package/dist/components/projects.d.ts.map +1 -1
- package/dist/components/projects.js +27 -7
- package/dist/components/projects.js.map +1 -1
- package/dist/components/rules.d.ts +8 -10
- package/dist/components/rules.d.ts.map +1 -1
- package/dist/components/rules.js +35 -13
- package/dist/components/rules.js.map +1 -1
- package/dist/components/setup.d.ts +9 -3
- package/dist/components/setup.d.ts.map +1 -1
- package/dist/components/setup.js +10 -4
- package/dist/components/setup.js.map +1 -1
- package/dist/console.css +677 -7
- package/dist/console.d.ts +5 -0
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +14 -8
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +32 -33
- package/dist/data.js.map +1 -1
- package/dist/desk-page.d.ts +38 -0
- package/dist/desk-page.d.ts.map +1 -0
- package/dist/desk-page.js +184 -0
- package/dist/desk-page.js.map +1 -0
- package/dist/desk-records-page.d.ts +18 -0
- package/dist/desk-records-page.d.ts.map +1 -0
- package/dist/desk-records-page.js +130 -0
- package/dist/desk-records-page.js.map +1 -0
- package/dist/desk-records.d.ts +247 -0
- package/dist/desk-records.d.ts.map +1 -0
- package/dist/desk-records.js +543 -0
- package/dist/desk-records.js.map +1 -0
- package/dist/desk.d.ts +122 -0
- package/dist/desk.d.ts.map +1 -0
- package/dist/desk.js +211 -0
- package/dist/desk.js.map +1 -0
- package/dist/feed-stream.d.ts +39 -0
- package/dist/feed-stream.d.ts.map +1 -0
- package/dist/feed-stream.js +117 -0
- package/dist/feed-stream.js.map +1 -0
- package/dist/home-tiles.d.ts +10 -3
- package/dist/home-tiles.d.ts.map +1 -1
- package/dist/home-tiles.js +54 -31
- package/dist/home-tiles.js.map +1 -1
- package/dist/i18n/en.d.ts +180 -5
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +184 -7
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +169 -6
- package/dist/i18n/ko.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +11 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +11 -0
- package/dist/limits.js.map +1 -1
- package/dist/onboarding.d.ts +6 -0
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +3 -3
- package/dist/onboarding.js.map +1 -1
- package/dist/plugin/context.d.ts +42 -11
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/limits.d.ts +2 -0
- package/dist/plugin/limits.d.ts.map +1 -1
- package/dist/plugin/limits.js +2 -0
- package/dist/plugin/limits.js.map +1 -1
- package/dist/plugin/manifest.d.ts +13 -0
- package/dist/plugin/manifest.d.ts.map +1 -1
- package/dist/plugin/manifest.js +30 -3
- package/dist/plugin/manifest.js.map +1 -1
- package/dist/plugin/rest-schemas.d.ts +55 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -1
- package/dist/plugin/rest-schemas.js +37 -0
- package/dist/plugin/rest-schemas.js.map +1 -1
- package/dist/plugin/sandbox.d.ts.map +1 -1
- package/dist/plugin/sandbox.js +4 -1
- package/dist/plugin/sandbox.js.map +1 -1
- package/dist/plugin/testing.d.ts +6 -2
- package/dist/plugin/testing.d.ts.map +1 -1
- package/dist/plugin/testing.js +52 -10
- package/dist/plugin/testing.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/records.d.ts +283 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +543 -0
- package/dist/records.js.map +1 -0
- package/dist/routes.d.ts +3 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +3 -1
- package/dist/routes.js.map +1 -1
- package/dist/rules.d.ts +30 -11
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +98 -45
- package/dist/rules.js.map +1 -1
- package/dist/runner/acp.d.ts +1 -1
- package/dist/runner/acp.d.ts.map +1 -1
- package/dist/runner/acp.js +31 -20
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/claude.d.ts +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +85 -15
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +19 -16
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/desk.d.ts +43 -2
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +166 -10
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/process.d.ts.map +1 -1
- package/dist/runner/process.js +11 -4
- package/dist/runner/process.js.map +1 -1
- package/dist/runner/redact.d.ts +39 -4
- package/dist/runner/redact.d.ts.map +1 -1
- package/dist/runner/redact.js +81 -5
- package/dist/runner/redact.js.map +1 -1
- package/dist/runner/runner.d.ts +15 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +231 -33
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/task-scheduler.d.ts +20 -0
- package/dist/runner/task-scheduler.d.ts.map +1 -1
- package/dist/runner/task-scheduler.js +34 -4
- package/dist/runner/task-scheduler.js.map +1 -1
- package/dist/runner/types.d.ts +36 -1
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js +17 -0
- package/dist/runner/types.js.map +1 -1
- package/dist/runner.d.ts +6 -6
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +5 -5
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +509 -5
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +76 -16
- package/dist/schemas.js.map +1 -1
- package/dist/services.d.ts +22 -5
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +35 -15
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +3 -1
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +7 -4
- package/dist/setup-guide.js.map +1 -1
- package/dist/vocabulary.d.ts +14 -3
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +13 -3
- package/dist/vocabulary.js.map +1 -1
- package/docs/specs/cli.md +64 -38
- package/docs/specs/plugins.md +27 -20
- package/docs/specs/records.md +113 -0
- package/docs/specs/rest.md +20 -13
- package/docs/specs/runner.md +23 -17
- package/package.json +7 -2
- package/skills/building-a-console/SKILL.md +4 -4
- package/skills/building-a-plugin/SKILL.md +6 -6
- package/skills/deploying-a-console/SKILL.md +4 -4
- package/skills/deploying-a-console/references/resources.md +41 -4
- package/skills/deploying-a-console/references/running-it-again.md +3 -2
- package/skills/keeping-a-desk/SKILL.md +133 -0
- package/skills/keeping-a-desk/collections.md +96 -0
- package/skills/planning-the-board/SKILL.md +14 -18
- package/skills/planning-the-board/references/a-task.md +2 -2
- package/skills/planning-the-board/references/project-rules.md +13 -14
- package/skills/planning-the-board/references/setting-up.md +15 -13
- package/skills/running-an-agent/SKILL.md +10 -9
- package/skills/working-the-board/SKILL.md +62 -44
- package/skills/working-the-board/references/terms.md +9 -5
- package/skills/working-the-board/references/the-pack.md +12 -10
- package/skills/working-the-board/references/the-sentence.md +2 -2
- package/src/agent-page.tsx +3 -1
- package/src/api.ts +77 -2
- package/src/charts.ts +250 -0
- package/src/cli/cli.ts +1698 -476
- package/src/cli/command-words.ts +56 -0
- package/src/cli/credentials.ts +181 -20
- package/src/cli/directory.ts +28 -10
- package/src/cli/format.ts +301 -46
- package/src/cli/help.ts +102 -54
- package/src/cli/main.ts +72 -2
- package/src/cli/pack.ts +333 -372
- package/src/cli/plugin-check.ts +275 -34
- package/src/cli/plugin-cli.ts +28 -4
- package/src/cli/plugin-main.ts +1 -0
- package/src/cli/serve.ts +295 -2
- package/src/client.ts +192 -177
- package/src/components/agent-page.tsx +489 -243
- package/src/components/charts.tsx +680 -0
- package/src/components/desk-records.tsx +724 -0
- package/src/components/desk.tsx +471 -0
- package/src/components/event-feed.tsx +5 -1
- package/src/components/home.tsx +12 -0
- package/src/components/plugin-settings.tsx +171 -12
- package/src/components/projects.tsx +29 -12
- package/src/components/rules.tsx +94 -34
- package/src/components/setup.tsx +18 -3
- package/src/console.tsx +17 -9
- package/src/data.ts +37 -34
- package/src/desk-page.tsx +332 -0
- package/src/desk-records-page.tsx +256 -0
- package/src/desk-records.ts +808 -0
- package/src/desk.ts +329 -0
- package/src/feed-stream.ts +144 -0
- package/src/home-tiles.ts +55 -35
- package/src/i18n/en.ts +196 -9
- package/src/i18n/ko.ts +178 -8
- package/src/index.ts +118 -0
- package/src/limits.ts +11 -0
- package/src/onboarding.ts +12 -4
- package/src/plugin/context.ts +55 -12
- package/src/plugin/limits.ts +2 -0
- package/src/plugin/manifest.ts +38 -2
- package/src/plugin/rest-schemas.ts +41 -0
- package/src/plugin/sandbox.ts +4 -1
- package/src/plugin/testing.ts +63 -12
- package/src/plugin.ts +2 -0
- package/src/records.ts +702 -0
- package/src/routes.ts +3 -1
- package/src/rules.ts +108 -47
- package/src/runner/acp.ts +47 -29
- package/src/runner/claude.ts +113 -23
- package/src/runner/codex.ts +35 -25
- package/src/runner/desk.ts +198 -12
- package/src/runner/process.ts +11 -4
- package/src/runner/redact.ts +92 -6
- package/src/runner/runner.ts +275 -34
- package/src/runner/task-scheduler.ts +36 -4
- package/src/runner/types.ts +47 -1
- package/src/runner.ts +27 -2
- package/src/schemas.ts +83 -15
- package/src/services.ts +49 -14
- package/src/setup-guide.ts +6 -2
- package/src/styles/README.md +11 -1
- package/src/styles/console.css +9 -0
- package/src/styles/pages/desk.css +126 -0
- package/src/styles/pages/documents.css +5 -0
- package/src/styles/parts/bars.css +80 -0
- package/src/styles/parts/chart.css +173 -0
- package/src/styles/parts/figures.css +65 -0
- package/src/styles/parts/legend.css +48 -0
- package/src/styles/parts/series.css +32 -0
- package/src/styles/parts/share.css +25 -0
- package/src/styles/parts/spark.css +23 -0
- package/src/styles/parts/stat.css +69 -0
- package/src/styles/tokens.css +13 -7
- package/src/vocabulary.ts +16 -3
- package/template/desk-web/README.md +8 -0
- package/template/desk-web/index.html +13 -0
- package/template/desk-web/package.json +25 -0
- package/template/desk-web/src/main.tsx +24 -0
- package/template/desk-web/src/page.tsx +51 -0
- package/template/desk-web/tsconfig.json +16 -0
- package/template/desk-web/vite.config.ts +15 -0
package/src/runner/claude.ts
CHANGED
|
@@ -2,15 +2,19 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { MAX_FILE_BYTES } from "../limits.js";
|
|
3
3
|
import { TRANSCRIPT_PICTURE_TYPES } from "../vocabulary.js";
|
|
4
4
|
import type { DriverHost } from "./registry.js";
|
|
5
|
-
import
|
|
6
|
-
Child,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import {
|
|
6
|
+
type Child,
|
|
7
|
+
type Cut,
|
|
8
|
+
type Driver,
|
|
9
|
+
type DriverEvent,
|
|
10
|
+
type DriverMessage,
|
|
11
|
+
type DriverSession,
|
|
12
|
+
errorsShown,
|
|
13
|
+
type Fact,
|
|
14
|
+
type Picture,
|
|
15
|
+
plainCut,
|
|
16
|
+
plainCutEnd,
|
|
17
|
+
type StartOptions,
|
|
14
18
|
} from "./types.js";
|
|
15
19
|
|
|
16
20
|
// The `claude` driver (docs/specs/runner.md): the Claude Code binary, unmodified, over its
|
|
@@ -65,7 +69,7 @@ function lineOf(line: string): Json | undefined {
|
|
|
65
69
|
}
|
|
66
70
|
|
|
67
71
|
/** A tool's input as a person reads it: the command of a shell, the path of a file, or the input whole and bounded. */
|
|
68
|
-
function inputOf(input: unknown): string {
|
|
72
|
+
function inputOf(input: unknown, cut: Cut): string {
|
|
69
73
|
if (isObject(input)) {
|
|
70
74
|
const line = textOf(input.command) ?? textOf(input.file_path) ?? textOf(input.path);
|
|
71
75
|
if (line !== undefined && Object.keys(input).length <= 3) {
|
|
@@ -78,7 +82,38 @@ function inputOf(input: unknown): string {
|
|
|
78
82
|
} catch {
|
|
79
83
|
whole = "";
|
|
80
84
|
}
|
|
81
|
-
return whole
|
|
85
|
+
return cut(whole, MAX_INPUT_LENGTH);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The most characters of what a sub-agent is called that an event carries. */
|
|
89
|
+
const MAX_SUBAGENT_LENGTH = 80;
|
|
90
|
+
/** How many calls that started a sub-agent are remembered by their ids: the oldest is let go past it. */
|
|
91
|
+
const MAX_SUBAGENTS = 500;
|
|
92
|
+
/** The product's tools that start a sub-agent, as it has called them: one whose input names a kind of sub-agent is one too. */
|
|
93
|
+
const SUBAGENT_TOOLS: ReadonlySet<string> = new Set(["Agent", "Task"]);
|
|
94
|
+
|
|
95
|
+
/** A word of a call's input, trimmed, or nothing where it holds none. */
|
|
96
|
+
const wordOf = (input: unknown, name: string): string | undefined => {
|
|
97
|
+
const word = isObject(input) ? textOf(input[name])?.trim() : undefined;
|
|
98
|
+
return word === undefined || word.length === 0 ? undefined : word;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* What a call that starts a sub-agent calls it: the kind of sub-agent its input names and what
|
|
103
|
+
* its input says it is for, the kind first (`Explore: Read src/ of acme/web`), so that two of
|
|
104
|
+
* one kind at once are told apart; the one of the two the input names alone; the tool where
|
|
105
|
+
* it names neither; nothing for a call that starts none. Within the bound, mark and all, cut
|
|
106
|
+
* after the secrets are out of it, as everything a driver shows a part of is.
|
|
107
|
+
*/
|
|
108
|
+
function subagentOf(tool: string, input: unknown, cut: Cut): string | undefined {
|
|
109
|
+
const kind = wordOf(input, "subagent_type");
|
|
110
|
+
if (kind === undefined && !SUBAGENT_TOOLS.has(tool)) {
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
const about = wordOf(input, "description");
|
|
114
|
+
const name =
|
|
115
|
+
kind !== undefined && about !== undefined ? `${kind}: ${about}` : (kind ?? about ?? tool);
|
|
116
|
+
return cut(name, MAX_SUBAGENT_LENGTH - 1);
|
|
82
117
|
}
|
|
83
118
|
|
|
84
119
|
/** The pictures and the text of what a tool returned: a string, or blocks of text and pictures. */
|
|
@@ -124,7 +159,7 @@ function resultOf(
|
|
|
124
159
|
}
|
|
125
160
|
|
|
126
161
|
/** What a denial says of the tool it denied. */
|
|
127
|
-
function denialOf(denial: unknown): DriverEvent | undefined {
|
|
162
|
+
function denialOf(denial: unknown, cut: Cut): DriverEvent | undefined {
|
|
128
163
|
if (!isObject(denial)) {
|
|
129
164
|
return undefined;
|
|
130
165
|
}
|
|
@@ -137,7 +172,7 @@ function denialOf(denial: unknown): DriverEvent | undefined {
|
|
|
137
172
|
return {
|
|
138
173
|
type: "event",
|
|
139
174
|
kind: "permission",
|
|
140
|
-
text: `Denied, with nobody at the terminal to ask: ${tool} ${inputOf(denial.tool_input)}`.trim(),
|
|
175
|
+
text: `Denied, with nobody at the terminal to ask: ${tool} ${inputOf(denial.tool_input, cut)}`.trim(),
|
|
141
176
|
data,
|
|
142
177
|
};
|
|
143
178
|
}
|
|
@@ -159,6 +194,25 @@ interface Read {
|
|
|
159
194
|
acknowledges: boolean;
|
|
160
195
|
/** The tool calls of the turn it said were denied, which the turn's result says again. */
|
|
161
196
|
readonly denied: Set<string>;
|
|
197
|
+
/** The calls that started a sub-agent, by their ids, with what each calls it. */
|
|
198
|
+
readonly subagents: Map<string, string>;
|
|
199
|
+
/** What cuts a text to what is shown of it. */
|
|
200
|
+
readonly cut: Cut;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Whose a line of the product is, as facts of its events (ADR-0131): a line a sub-agent wrote
|
|
205
|
+
* names the call that started that sub-agent, by the id the product gave the call, as the
|
|
206
|
+
* product's documentation has it (`parent_tool_use_id`), and what that call called it, where
|
|
207
|
+
* the call was read. Nothing for a line of the session's own.
|
|
208
|
+
*/
|
|
209
|
+
function whoseOf(line: Json, state: Read): Record<string, Fact> {
|
|
210
|
+
const parent = textOf(line.parent_tool_use_id);
|
|
211
|
+
if (parent === undefined || parent.length === 0) {
|
|
212
|
+
return {};
|
|
213
|
+
}
|
|
214
|
+
const subagent = state.subagents.get(parent);
|
|
215
|
+
return subagent === undefined ? { parent } : { parent, subagent };
|
|
162
216
|
}
|
|
163
217
|
|
|
164
218
|
/** The product's permission modes, as its documentation and its own help name them. */
|
|
@@ -262,7 +316,7 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
|
|
|
262
316
|
});
|
|
263
317
|
} else if (line.subtype === "permission_denied") {
|
|
264
318
|
// Said when it happens, and again in the turn's result, which is then not said twice.
|
|
265
|
-
const denied = denialOf(line);
|
|
319
|
+
const denied = denialOf(line, state.cut);
|
|
266
320
|
if (denied !== undefined) {
|
|
267
321
|
events.push(denied);
|
|
268
322
|
const id = textOf(line.tool_use_id);
|
|
@@ -274,21 +328,40 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
|
|
|
274
328
|
return events;
|
|
275
329
|
}
|
|
276
330
|
case "assistant": {
|
|
331
|
+
const whose = whoseOf(line, state);
|
|
332
|
+
// A fact is said only where there is one: a line of the session's own carries none.
|
|
333
|
+
const said = Object.keys(whose).length === 0 ? {} : { data: whose };
|
|
277
334
|
for (const block of blocks) {
|
|
278
335
|
if (!isObject(block)) {
|
|
279
336
|
continue;
|
|
280
337
|
}
|
|
281
338
|
if (block.type === "text" && typeof block.text === "string") {
|
|
282
|
-
events.push({ type: "event", kind: "assistant", text: block.text });
|
|
339
|
+
events.push({ type: "event", kind: "assistant", text: block.text, ...said });
|
|
283
340
|
} else if (block.type === "thinking" && typeof block.thinking === "string") {
|
|
284
|
-
|
|
341
|
+
// A thought the product sends with no words, its signature alone, is no event: it
|
|
342
|
+
// would show nothing, and count against what an hour of a session takes.
|
|
343
|
+
if (block.thinking.trim().length > 0) {
|
|
344
|
+
events.push({ type: "event", kind: "thinking", text: block.thinking, ...said });
|
|
345
|
+
}
|
|
285
346
|
} else if (block.type === "tool_use") {
|
|
286
347
|
const tool = textOf(block.name) ?? "a tool";
|
|
348
|
+
const id = textOf(block.id);
|
|
349
|
+
const subagent = subagentOf(tool, block.input, state.cut);
|
|
350
|
+
if (id !== undefined && subagent !== undefined) {
|
|
351
|
+
// What the sub-agent this call starts does names the call: remembered by its id.
|
|
352
|
+
if (state.subagents.size >= MAX_SUBAGENTS) {
|
|
353
|
+
const oldest = state.subagents.keys().next().value;
|
|
354
|
+
if (oldest !== undefined) {
|
|
355
|
+
state.subagents.delete(oldest);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
state.subagents.set(id, subagent);
|
|
359
|
+
}
|
|
287
360
|
events.push({
|
|
288
361
|
type: "event",
|
|
289
362
|
kind: "tool_call",
|
|
290
|
-
text: inputOf(block.input),
|
|
291
|
-
data: { tool, id:
|
|
363
|
+
text: inputOf(block.input, state.cut),
|
|
364
|
+
data: { tool, id: id ?? null, ...whose },
|
|
292
365
|
});
|
|
293
366
|
}
|
|
294
367
|
}
|
|
@@ -305,7 +378,8 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
|
|
|
305
378
|
}
|
|
306
379
|
return events;
|
|
307
380
|
}
|
|
308
|
-
// What came back from a tool is recorded here.
|
|
381
|
+
// What came back from a tool is recorded here, a sub-agent's tool as the session's own.
|
|
382
|
+
const whose = whoseOf(line, state);
|
|
309
383
|
for (const block of blocks) {
|
|
310
384
|
if (!isObject(block) || block.type !== "tool_result") {
|
|
311
385
|
continue;
|
|
@@ -316,7 +390,11 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
|
|
|
316
390
|
type: "event",
|
|
317
391
|
kind: "tool_result",
|
|
318
392
|
text: result.text,
|
|
319
|
-
data: {
|
|
393
|
+
data: {
|
|
394
|
+
id: textOf(block.tool_use_id) ?? null,
|
|
395
|
+
error: block.is_error === true,
|
|
396
|
+
...whose,
|
|
397
|
+
},
|
|
320
398
|
pictures: result.pictures,
|
|
321
399
|
});
|
|
322
400
|
}
|
|
@@ -324,7 +402,7 @@ function eventsOf(line: Json, state: Read): DriverEvent[] {
|
|
|
324
402
|
}
|
|
325
403
|
case "result": {
|
|
326
404
|
for (const denial of Array.isArray(line.permission_denials) ? line.permission_denials : []) {
|
|
327
|
-
const denied = denialOf(denial);
|
|
405
|
+
const denied = denialOf(denial, state.cut);
|
|
328
406
|
const id = isObject(denial) ? textOf(denial.tool_use_id) : undefined;
|
|
329
407
|
if (denied !== undefined && (id === undefined || !state.denied.has(id))) {
|
|
330
408
|
events.push(denied);
|
|
@@ -448,7 +526,13 @@ const wait = (ms: number): Promise<"timeout"> =>
|
|
|
448
526
|
setTimeout(() => resolve("timeout"), ms).unref?.();
|
|
449
527
|
});
|
|
450
528
|
|
|
451
|
-
function sessionOf(
|
|
529
|
+
function sessionOf(
|
|
530
|
+
child: Child,
|
|
531
|
+
asked: string,
|
|
532
|
+
uuid: () => string,
|
|
533
|
+
cut: Cut,
|
|
534
|
+
cutEnd: Cut,
|
|
535
|
+
): DriverSession {
|
|
452
536
|
let stopping = false;
|
|
453
537
|
const state: Read = {
|
|
454
538
|
began: false,
|
|
@@ -459,6 +543,8 @@ function sessionOf(child: Child, asked: string, uuid: () => string): DriverSessi
|
|
|
459
543
|
waiting: new Set(),
|
|
460
544
|
denied: new Set(),
|
|
461
545
|
acknowledges: false,
|
|
546
|
+
subagents: new Map(),
|
|
547
|
+
cut,
|
|
462
548
|
};
|
|
463
549
|
|
|
464
550
|
async function* events(): AsyncGenerator<DriverEvent> {
|
|
@@ -478,10 +564,12 @@ function sessionOf(child: Child, asked: string, uuid: () => string): DriverSessi
|
|
|
478
564
|
const clean = stopping || (exit.code === 0 && exit.signal === null && exit.error === undefined);
|
|
479
565
|
if (!clean && !waits) {
|
|
480
566
|
const said = child.errors().trim();
|
|
567
|
+
// Its end, cut after the secrets are out, so that none stands at the cut.
|
|
568
|
+
const shown = errorsShown(said, cutEnd);
|
|
481
569
|
const text =
|
|
482
570
|
exit.error !== undefined
|
|
483
571
|
? `The product could not be started: ${exit.error}`
|
|
484
|
-
: `The product's process ended${exit.signal === null ? ` with code ${exit.code}` : ` on ${exit.signal}`}.${
|
|
572
|
+
: `The product's process ended${exit.signal === null ? ` with code ${exit.code}` : ` on ${exit.signal}`}.${shown.length === 0 ? "" : `\n${shown}`}`;
|
|
485
573
|
yield { type: "event", kind: "error", text };
|
|
486
574
|
yield {
|
|
487
575
|
type: "cannot_go_on",
|
|
@@ -599,6 +687,8 @@ export function createClaudeDriver(host: DriverHost): Driver {
|
|
|
599
687
|
host.spawn(command, claudeArguments(options), { cwd: options.cwd, env: options.env }),
|
|
600
688
|
claudeMode(options.permissions),
|
|
601
689
|
uuid,
|
|
690
|
+
options.cut ?? plainCut,
|
|
691
|
+
options.cutEnd ?? plainCutEnd,
|
|
602
692
|
);
|
|
603
693
|
},
|
|
604
694
|
};
|
package/src/runner/codex.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { DriverHost } from "./registry.js";
|
|
2
|
-
import
|
|
3
|
-
Child,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import {
|
|
3
|
+
type Child,
|
|
4
|
+
type Cut,
|
|
5
|
+
type Driver,
|
|
6
|
+
type DriverEvent,
|
|
7
|
+
type DriverMessage,
|
|
8
|
+
type DriverSession,
|
|
9
|
+
errorsShown,
|
|
10
|
+
type Fact,
|
|
11
|
+
plainCut,
|
|
12
|
+
plainCutEnd,
|
|
13
|
+
type StartOptions,
|
|
10
14
|
} from "./types.js";
|
|
11
15
|
|
|
12
16
|
// The `codex` driver (docs/specs/runner.md): the Codex binary, unmodified, run with nobody at
|
|
@@ -151,16 +155,13 @@ function lineOf(line: string): Json | undefined {
|
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
157
|
|
|
154
|
-
const bounded = (text: string): string =>
|
|
155
|
-
text.length > MAX_INPUT_LENGTH ? `${text.slice(0, MAX_INPUT_LENGTH)}…` : text;
|
|
156
|
-
|
|
157
158
|
/** Anything as a line of text a person reads, bounded. */
|
|
158
|
-
function shown(value: unknown): string {
|
|
159
|
+
function shown(value: unknown, cut: Cut): string {
|
|
159
160
|
if (typeof value === "string") {
|
|
160
|
-
return
|
|
161
|
+
return cut(value, MAX_INPUT_LENGTH);
|
|
161
162
|
}
|
|
162
163
|
try {
|
|
163
|
-
return
|
|
164
|
+
return cut(JSON.stringify(value) ?? "", MAX_INPUT_LENGTH);
|
|
164
165
|
} catch {
|
|
165
166
|
return "";
|
|
166
167
|
}
|
|
@@ -201,6 +202,8 @@ interface Read {
|
|
|
201
202
|
turned: boolean;
|
|
202
203
|
/** How many messages the turn under way was started with. */
|
|
203
204
|
messages: number;
|
|
205
|
+
/** What cuts a text to what is shown of it. */
|
|
206
|
+
readonly cut: Cut;
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
/** What a turn runs with, as the session's first event and the heartbeat say it. */
|
|
@@ -211,19 +214,23 @@ interface Runs {
|
|
|
211
214
|
}
|
|
212
215
|
|
|
213
216
|
/** A tool call of the product, by the kind of item it writes for one: its name and its input as a line. */
|
|
214
|
-
function callOf(
|
|
217
|
+
function callOf(
|
|
218
|
+
item: Json,
|
|
219
|
+
cut: Cut,
|
|
220
|
+
): { readonly tool: string; readonly text: string } | undefined {
|
|
215
221
|
switch (item.type) {
|
|
216
222
|
case "command_execution":
|
|
217
|
-
return { tool: "command_execution", text: shown(item.command ?? "") };
|
|
223
|
+
return { tool: "command_execution", text: shown(item.command ?? "", cut) };
|
|
218
224
|
case "file_change": {
|
|
219
225
|
const changes = Array.isArray(item.changes) ? item.changes : [];
|
|
220
226
|
return {
|
|
221
227
|
tool: "file_change",
|
|
222
|
-
text:
|
|
228
|
+
text: cut(
|
|
223
229
|
changes
|
|
224
230
|
.filter(isObject)
|
|
225
231
|
.map((change) => `${textOf(change.kind) ?? "change"} ${textOf(change.path) ?? ""}`)
|
|
226
232
|
.join("\n"),
|
|
233
|
+
MAX_INPUT_LENGTH,
|
|
227
234
|
),
|
|
228
235
|
};
|
|
229
236
|
}
|
|
@@ -231,17 +238,17 @@ function callOf(item: Json): { readonly tool: string; readonly text: string } |
|
|
|
231
238
|
case "mcp_tool_call":
|
|
232
239
|
return {
|
|
233
240
|
tool: `${textOf(item.server) ?? "mcp"}.${textOf(item.tool) ?? "tool"}`,
|
|
234
|
-
text: item.arguments === undefined ? "" : shown(item.arguments),
|
|
241
|
+
text: item.arguments === undefined ? "" : shown(item.arguments, cut),
|
|
235
242
|
};
|
|
236
243
|
case "web_search":
|
|
237
|
-
return { tool: "web_search", text: shown(item.query ?? "") };
|
|
244
|
+
return { tool: "web_search", text: shown(item.query ?? "", cut) };
|
|
238
245
|
default:
|
|
239
246
|
return undefined;
|
|
240
247
|
}
|
|
241
248
|
}
|
|
242
249
|
|
|
243
250
|
/** What came back from a tool call, where the product says: a command's output, or what a tool answered. */
|
|
244
|
-
function resultOf(item: Json): string {
|
|
251
|
+
function resultOf(item: Json, cut: Cut): string {
|
|
245
252
|
if (item.type === "command_execution") {
|
|
246
253
|
return textOf(item.aggregated_output) ?? "";
|
|
247
254
|
}
|
|
@@ -249,7 +256,7 @@ function resultOf(item: Json): string {
|
|
|
249
256
|
if (isObject(item.error) && typeof item.error.message === "string") {
|
|
250
257
|
return item.error.message;
|
|
251
258
|
}
|
|
252
|
-
return item.result === undefined || item.result === null ? "" : shown(item.result);
|
|
259
|
+
return item.result === undefined || item.result === null ? "" : shown(item.result, cut);
|
|
253
260
|
}
|
|
254
261
|
return "";
|
|
255
262
|
}
|
|
@@ -284,7 +291,7 @@ function eventsOf(line: Json, read: Read, runs: Runs): DriverEvent[] {
|
|
|
284
291
|
return events;
|
|
285
292
|
}
|
|
286
293
|
case "item.started": {
|
|
287
|
-
const call = item === undefined ? undefined : callOf(item);
|
|
294
|
+
const call = item === undefined ? undefined : callOf(item, read.cut);
|
|
288
295
|
const id = textOf(item?.id);
|
|
289
296
|
if (call !== undefined) {
|
|
290
297
|
events.push({
|
|
@@ -313,7 +320,7 @@ function eventsOf(line: Json, read: Read, runs: Runs): DriverEvent[] {
|
|
|
313
320
|
// A word of warning inside a turn: the turn goes on.
|
|
314
321
|
events.push({ type: "event", kind: "error", text: errorOf(item.message) });
|
|
315
322
|
} else {
|
|
316
|
-
const call = callOf(item);
|
|
323
|
+
const call = callOf(item, read.cut);
|
|
317
324
|
if (call === undefined) {
|
|
318
325
|
return events;
|
|
319
326
|
}
|
|
@@ -340,7 +347,7 @@ function eventsOf(line: Json, read: Read, runs: Runs): DriverEvent[] {
|
|
|
340
347
|
events.push({
|
|
341
348
|
type: "event",
|
|
342
349
|
kind: "tool_result",
|
|
343
|
-
text: resultOf(item),
|
|
350
|
+
text: resultOf(item, read.cut),
|
|
344
351
|
data,
|
|
345
352
|
pictures: [],
|
|
346
353
|
});
|
|
@@ -434,6 +441,7 @@ function sessionOf(
|
|
|
434
441
|
failed: undefined,
|
|
435
442
|
turned: false,
|
|
436
443
|
messages: 0,
|
|
444
|
+
cut: options.cut ?? plainCut,
|
|
437
445
|
};
|
|
438
446
|
const mode = codexMode(options.permissions);
|
|
439
447
|
let conversation = word(options.resume);
|
|
@@ -521,10 +529,12 @@ function sessionOf(
|
|
|
521
529
|
} else if (!read.completed) {
|
|
522
530
|
const errors = child.errors().trim();
|
|
523
531
|
if (read.failed === undefined) {
|
|
532
|
+
// Its end, cut after the secrets are out, so that none stands at the cut.
|
|
533
|
+
const shown = errorsShown(errors, options.cutEnd ?? plainCutEnd);
|
|
524
534
|
emit({
|
|
525
535
|
type: "event",
|
|
526
536
|
kind: "error",
|
|
527
|
-
text: `The product's process ended${exit.signal === null ? ` with code ${exit.code}` : ` on ${exit.signal}`} before the turn did.${
|
|
537
|
+
text: `The product's process ended${exit.signal === null ? ` with code ${exit.code}` : ` on ${exit.signal}`} before the turn did.${shown.length === 0 ? "" : `\n${shown}`}`,
|
|
528
538
|
});
|
|
529
539
|
}
|
|
530
540
|
if (SIGN_IN.test(`${read.failed ?? ""}\n${errors}`)) {
|