@skillcdn/console 0.6.0 → 0.6.2
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 +7 -7
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +58 -35
- package/dist/agent-page.js.map +1 -1
- package/dist/agent-usage.d.ts +51 -0
- package/dist/agent-usage.d.ts.map +1 -0
- package/dist/agent-usage.js +77 -0
- package/dist/agent-usage.js.map +1 -0
- package/dist/api.d.ts +4 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +4 -2
- package/dist/api.js.map +1 -1
- package/dist/cli/cli.d.ts +9 -2
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +491 -125
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/format.d.ts +46 -4
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +163 -45
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +62 -13
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/machine-check.d.ts +24 -5
- package/dist/cli/machine-check.d.ts.map +1 -1
- package/dist/cli/machine-check.js +128 -16
- package/dist/cli/machine-check.js.map +1 -1
- package/dist/cli/pack.d.ts +11 -8
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +63 -28
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/runner-host.d.ts +2 -0
- package/dist/cli/runner-host.d.ts.map +1 -1
- package/dist/cli/runner-host.js +1 -0
- package/dist/cli/runner-host.js.map +1 -1
- package/dist/cli/secret-notes.d.ts.map +1 -1
- package/dist/cli/secret-notes.js +9 -1
- package/dist/cli/secret-notes.js.map +1 -1
- package/dist/cli/terminal.d.ts +10 -2
- package/dist/cli/terminal.d.ts.map +1 -1
- package/dist/cli/terminal.js +16 -4
- package/dist/cli/terminal.js.map +1 -1
- package/dist/client.d.ts +30 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +13 -1
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +76 -18
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +183 -53
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/agents.d.ts +2 -0
- package/dist/components/agents.d.ts.map +1 -1
- package/dist/components/agents.js +6 -5
- package/dist/components/agents.js.map +1 -1
- package/dist/components/calendar.d.ts +24 -4
- package/dist/components/calendar.d.ts.map +1 -1
- package/dist/components/calendar.js +79 -36
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/categories.js +2 -2
- package/dist/components/categories.js.map +1 -1
- package/dist/components/comments.js +2 -2
- package/dist/components/comments.js.map +1 -1
- package/dist/components/decision-list.d.ts.map +1 -1
- package/dist/components/decision-list.js +5 -5
- package/dist/components/decision-list.js.map +1 -1
- package/dist/components/documents.d.ts.map +1 -1
- package/dist/components/documents.js +4 -4
- package/dist/components/documents.js.map +1 -1
- package/dist/components/event-feed.d.ts +2 -3
- package/dist/components/event-feed.d.ts.map +1 -1
- package/dist/components/event-feed.js +4 -184
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/goals.d.ts.map +1 -1
- package/dist/components/goals.js +3 -3
- package/dist/components/goals.js.map +1 -1
- package/dist/components/home.js +9 -9
- package/dist/components/home.js.map +1 -1
- package/dist/components/icon.d.ts.map +1 -1
- package/dist/components/icon.js +11 -2
- package/dist/components/icon.js.map +1 -1
- package/dist/components/notifications.d.ts +65 -0
- package/dist/components/notifications.d.ts.map +1 -0
- package/dist/components/notifications.js +162 -0
- package/dist/components/notifications.js.map +1 -0
- package/dist/components/pack-connect.js +1 -1
- package/dist/components/pack-connect.js.map +1 -1
- package/dist/components/pack-token.js +1 -1
- package/dist/components/pack-token.js.map +1 -1
- package/dist/components/people.js +2 -2
- package/dist/components/people.js.map +1 -1
- package/dist/components/pictures.js +1 -1
- package/dist/components/pictures.js.map +1 -1
- package/dist/components/plugin-settings.d.ts +22 -1
- package/dist/components/plugin-settings.d.ts.map +1 -1
- package/dist/components/plugin-settings.js +63 -11
- package/dist/components/plugin-settings.js.map +1 -1
- package/dist/components/projects.js +1 -1
- package/dist/components/projects.js.map +1 -1
- package/dist/components/roadmap.js +2 -2
- package/dist/components/roadmap.js.map +1 -1
- package/dist/components/rules.js +2 -2
- package/dist/components/rules.js.map +1 -1
- package/dist/components/runs.d.ts.map +1 -1
- package/dist/components/runs.js +1 -1
- package/dist/components/runs.js.map +1 -1
- package/dist/components/sessions.js +1 -1
- package/dist/components/sessions.js.map +1 -1
- package/dist/components/shell.d.ts +2 -0
- package/dist/components/shell.d.ts.map +1 -1
- package/dist/components/shell.js +1 -1
- package/dist/components/shell.js.map +1 -1
- package/dist/components/sign-in.js +2 -2
- package/dist/components/sign-in.js.map +1 -1
- package/dist/components/skills.d.ts.map +1 -1
- package/dist/components/skills.js +1 -1
- package/dist/components/skills.js.map +1 -1
- package/dist/components/task-view.d.ts +6 -0
- package/dist/components/task-view.d.ts.map +1 -1
- package/dist/components/task-view.js +3 -2
- package/dist/components/task-view.js.map +1 -1
- package/dist/components/tokens.js +1 -1
- package/dist/components/tokens.js.map +1 -1
- package/dist/components/ui.d.ts +21 -2
- package/dist/components/ui.d.ts.map +1 -1
- package/dist/components/ui.js +24 -3
- package/dist/components/ui.js.map +1 -1
- package/dist/components/work.js +1 -1
- package/dist/components/work.js.map +1 -1
- package/dist/console.css +506 -289
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +193 -16
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts +17 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +31 -0
- package/dist/data.js.map +1 -1
- package/dist/desk-page.js +5 -5
- package/dist/desk-page.js.map +1 -1
- package/dist/feed-words.d.ts +5 -0
- package/dist/feed-words.d.ts.map +1 -0
- package/dist/feed-words.js +193 -0
- package/dist/feed-words.js.map +1 -0
- package/dist/i18n/en.d.ts +93 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +103 -15
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +105 -22
- package/dist/i18n/ko.js.map +1 -1
- package/dist/icons/glyphs.d.ts +370 -104
- package/dist/icons/glyphs.d.ts.map +1 -1
- package/dist/icons/glyphs.js +72 -66
- package/dist/icons/glyphs.js.map +1 -1
- package/dist/icons/index.d.ts.map +1 -1
- package/dist/icons/index.js +9 -1
- package/dist/icons/index.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +7 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +7 -0
- package/dist/limits.js.map +1 -1
- package/dist/notifications.d.ts +124 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/notifications.js +147 -0
- package/dist/notifications.js.map +1 -0
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +7 -12
- package/dist/onboarding.js.map +1 -1
- package/dist/plugin/capabilities.d.ts +1 -1
- package/dist/plugin/capabilities.d.ts.map +1 -1
- package/dist/plugin/capabilities.js +10 -0
- package/dist/plugin/capabilities.js.map +1 -1
- package/dist/plugin/context.d.ts +85 -1
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/limits.d.ts +7 -0
- package/dist/plugin/limits.d.ts.map +1 -1
- package/dist/plugin/limits.js +7 -0
- package/dist/plugin/limits.js.map +1 -1
- package/dist/plugin/manifest.d.ts +8 -0
- package/dist/plugin/manifest.d.ts.map +1 -1
- package/dist/plugin/manifest.js +13 -0
- package/dist/plugin/manifest.js.map +1 -1
- package/dist/plugin/rest-schemas.d.ts +22 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -1
- package/dist/plugin/rest-schemas.js +19 -3
- package/dist/plugin/rest-schemas.js.map +1 -1
- package/dist/plugin/testing.d.ts +2 -0
- package/dist/plugin/testing.d.ts.map +1 -1
- package/dist/plugin/testing.js +2 -0
- 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/router.d.ts +6 -0
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +5 -0
- package/dist/router.js.map +1 -1
- package/dist/routes.d.ts +2 -0
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +2 -0
- package/dist/routes.js.map +1 -1
- package/dist/rules.js +1 -1
- package/dist/rules.js.map +1 -1
- package/dist/runner/acp.d.ts.map +1 -1
- package/dist/runner/acp.js +12 -97
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/browser.d.ts +50 -0
- package/dist/runner/browser.d.ts.map +1 -0
- package/dist/runner/browser.js +104 -0
- package/dist/runner/browser.js.map +1 -0
- package/dist/runner/claude.d.ts +1 -2
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +352 -13
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts +9 -10
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +809 -346
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/config.d.ts +14 -3
- package/dist/runner/config.d.ts.map +1 -1
- package/dist/runner/config.js +27 -7
- package/dist/runner/config.js.map +1 -1
- package/dist/runner/desk.d.ts +3 -1
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +17 -5
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/message.d.ts +53 -3
- package/dist/runner/message.d.ts.map +1 -1
- package/dist/runner/message.js +201 -20
- package/dist/runner/message.js.map +1 -1
- package/dist/runner/registry.d.ts +6 -0
- package/dist/runner/registry.d.ts.map +1 -1
- package/dist/runner/registry.js.map +1 -1
- package/dist/runner/rpc.d.ts +31 -0
- package/dist/runner/rpc.d.ts.map +1 -0
- package/dist/runner/rpc.js +102 -0
- package/dist/runner/rpc.js.map +1 -0
- package/dist/runner/runner.d.ts +41 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +695 -52
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/slack.d.ts +17 -8
- package/dist/runner/slack.d.ts.map +1 -1
- package/dist/runner/slack.js +1250 -78
- package/dist/runner/slack.js.map +1 -1
- package/dist/runner/types.d.ts +160 -8
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js.map +1 -1
- package/dist/runner/usage.d.ts +105 -0
- package/dist/runner/usage.d.ts.map +1 -0
- package/dist/runner/usage.js +218 -0
- package/dist/runner/usage.js.map +1 -0
- package/dist/runner.d.ts +4 -4
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +3 -3
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +673 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +205 -1
- package/dist/schemas.js.map +1 -1
- package/dist/services.js +3 -3
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +4 -3
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +11 -13
- package/dist/setup-guide.js.map +1 -1
- package/dist/text.d.ts +7 -0
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +18 -0
- package/dist/text.js.map +1 -1
- package/dist/vocabulary.d.ts +4 -2
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +4 -1
- package/dist/vocabulary.js.map +1 -1
- package/docs/specs/cli.md +26 -19
- package/docs/specs/plugins.md +16 -10
- package/docs/specs/rest.md +28 -10
- package/docs/specs/runner.md +132 -44
- package/package.json +4 -4
- package/skills/building-a-console/SKILL.md +2 -2
- package/skills/building-a-console/references/configuring.md +1 -1
- package/skills/building-a-plugin/SKILL.md +4 -4
- package/skills/planning-the-board/SKILL.md +1 -1
- package/skills/planning-the-board/references/setting-up.md +2 -2
- package/skills/running-an-agent/SKILL.md +15 -64
- package/skills/running-an-agent/references/preparing-the-machine.md +17 -0
- package/skills/running-an-agent/references/several-tasks.md +37 -0
- package/skills/running-an-agent/references/slack-app.md +70 -13
- package/skills/running-an-agent/references/the-account-and-the-invitation.md +5 -0
- package/skills/running-an-agent/references/what-was-not-seen-run-yet.md +3 -0
- package/skills/running-an-agent/references/when-the-agent-could-not-go-on.md +16 -0
- package/skills/running-an-agent/references/your-first-task.md +14 -0
- package/skills/working-the-board/SKILL.md +9 -12
- package/skills/working-the-board/references/a-pack-skills-questions.md +3 -0
- package/skills/working-the-board/references/a-plugins-commands.md +3 -0
- package/skills/working-the-board/references/a-review.md +3 -0
- package/skills/working-the-board/references/an-open-run.md +3 -0
- package/skills/working-the-board/references/requirements.md +7 -0
- package/skills/working-the-board/references/the-pack.md +2 -2
- package/skills/working-the-board/references/what-they-were-told.md +3 -0
- package/skills/working-the-board/references/work-given-in-chat.md +5 -0
- package/src/agent-page.tsx +76 -47
- package/src/agent-usage.ts +113 -0
- package/src/api.ts +62 -0
- package/src/cli/cli.ts +634 -162
- package/src/cli/format.ts +190 -47
- package/src/cli/help.ts +77 -12
- package/src/cli/machine-check.ts +182 -29
- package/src/cli/pack.ts +81 -40
- package/src/cli/runner-host.ts +3 -0
- package/src/cli/secret-notes.ts +9 -1
- package/src/cli/terminal.ts +20 -4
- package/src/client.ts +94 -6
- package/src/components/agent-page.tsx +280 -63
- package/src/components/agents.tsx +23 -3
- package/src/components/calendar.tsx +93 -37
- package/src/components/categories.tsx +2 -2
- package/src/components/comments.tsx +5 -5
- package/src/components/decision-list.tsx +13 -10
- package/src/components/documents.tsx +13 -8
- package/src/components/event-feed.tsx +4 -203
- package/src/components/goals.tsx +6 -4
- package/src/components/home.tsx +12 -12
- package/src/components/icon.tsx +16 -3
- package/src/components/notifications.tsx +419 -0
- package/src/components/pack-connect.tsx +1 -1
- package/src/components/pack-token.tsx +5 -5
- package/src/components/people.tsx +3 -3
- package/src/components/pictures.tsx +1 -1
- package/src/components/plugin-settings.tsx +128 -23
- package/src/components/projects.tsx +1 -1
- package/src/components/roadmap.tsx +2 -2
- package/src/components/rules.tsx +2 -2
- package/src/components/runs.tsx +6 -3
- package/src/components/sessions.tsx +2 -2
- package/src/components/shell.tsx +3 -0
- package/src/components/sign-in.tsx +3 -3
- package/src/components/skills.tsx +5 -3
- package/src/components/task-view.tsx +18 -7
- package/src/components/tokens.tsx +2 -2
- package/src/components/ui.tsx +70 -5
- package/src/components/work.tsx +2 -2
- package/src/console.tsx +269 -12
- package/src/data.ts +54 -0
- package/src/desk-page.tsx +5 -5
- package/src/feed-words.ts +214 -0
- package/src/i18n/en.ts +114 -15
- package/src/i18n/ko.ts +115 -22
- package/src/icons/glyphs.ts +74 -68
- package/src/icons/index.ts +9 -1
- package/src/index.ts +11 -0
- package/src/limits.ts +7 -0
- package/src/notifications.ts +205 -0
- package/src/onboarding.ts +10 -14
- package/src/plugin/capabilities.ts +13 -0
- package/src/plugin/context.ts +87 -0
- package/src/plugin/limits.ts +7 -0
- package/src/plugin/manifest.ts +14 -0
- package/src/plugin/rest-schemas.ts +27 -3
- package/src/plugin/testing.ts +4 -0
- package/src/plugin.ts +2 -0
- package/src/router.ts +7 -0
- package/src/routes.ts +2 -0
- package/src/rules.ts +1 -1
- package/src/runner/acp.ts +12 -118
- package/src/runner/browser.ts +128 -0
- package/src/runner/claude.ts +399 -12
- package/src/runner/codex.ts +904 -400
- package/src/runner/config.ts +30 -7
- package/src/runner/desk.ts +22 -6
- package/src/runner/message.ts +251 -21
- package/src/runner/registry.ts +6 -0
- package/src/runner/rpc.ts +140 -0
- package/src/runner/runner.ts +863 -53
- package/src/runner/slack.ts +1535 -85
- package/src/runner/types.ts +150 -5
- package/src/runner/usage.ts +299 -0
- package/src/runner.ts +16 -1
- package/src/schemas.ts +249 -0
- package/src/services.ts +3 -3
- package/src/setup-guide.ts +12 -14
- package/src/styles/README.md +11 -7
- package/src/styles/console.css +2 -0
- package/src/styles/drawn-by-pages.json +7 -82
- package/src/styles/pages/agents.css +46 -35
- package/src/styles/pages/calendar.css +0 -1
- package/src/styles/pages/connect.css +0 -14
- package/src/styles/pages/decisions.css +2 -43
- package/src/styles/pages/documents.css +0 -29
- package/src/styles/pages/home.css +4 -16
- package/src/styles/pages/people.css +2 -17
- package/src/styles/pages/plugins.css +9 -12
- package/src/styles/pages/roadmap.css +0 -16
- package/src/styles/pages/settings.css +0 -28
- package/src/styles/pages/sign-in.css +2 -17
- package/src/styles/pages/thread.css +4 -50
- package/src/styles/pages/work.css +0 -5
- package/src/styles/parts/button.css +31 -0
- package/src/styles/parts/count.css +10 -0
- package/src/styles/parts/divider.css +17 -0
- package/src/styles/parts/frame.css +12 -0
- package/src/styles/parts/icon.css +39 -0
- package/src/styles/parts/menu.css +184 -0
- package/src/styles/parts/panel.css +7 -0
- package/src/styles/parts/progress.css +63 -0
- package/src/styles/parts/settings.css +2 -0
- package/src/styles/parts/sheet.css +28 -0
- package/src/styles/parts/text.css +34 -0
- package/src/text.ts +19 -0
- package/src/vocabulary.ts +4 -1
- package/template/plugin/package.json +1 -1
package/src/runner/acp.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MAX_FILE_BYTES } from "../limits.js";
|
|
2
2
|
import { TRANSCRIPT_PICTURE_TYPES } from "../vocabulary.js";
|
|
3
3
|
import type { DriverHost } from "./registry.js";
|
|
4
|
+
import { connectionOf, METHOD_NOT_FOUND, RpcError } from "./rpc.js";
|
|
4
5
|
import {
|
|
5
6
|
type Child,
|
|
6
7
|
type Cut,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
plainCutEnd,
|
|
18
19
|
type StartOptions,
|
|
19
20
|
} from "./types.js";
|
|
21
|
+
import { saysUsageLimit } from "./usage.js";
|
|
20
22
|
|
|
21
23
|
// The driver for any product that speaks the Agent Client Protocol (ADR-0085): the product's
|
|
22
24
|
// command, which `runner.json` names, started once for a session and spoken to over its standard
|
|
@@ -52,12 +54,8 @@ const MAX_PRINTED_LENGTH = 200_000;
|
|
|
52
54
|
* was kept. More than the longest form a secret is looked for in.
|
|
53
55
|
*/
|
|
54
56
|
const PRINTED_BEYOND = 64 * 1024;
|
|
55
|
-
/** The most that is shown of what an error carries beside its message. */
|
|
56
|
-
const MAX_DETAIL_LENGTH = 1000;
|
|
57
57
|
/** The protocol's code for a request the agent takes only once the product is signed in. */
|
|
58
58
|
const AUTH_REQUIRED = -32000;
|
|
59
|
-
/** The answer to a request for a method this client does not offer. */
|
|
60
|
-
const METHOD_NOT_FOUND = -32601;
|
|
61
59
|
|
|
62
60
|
/**
|
|
63
61
|
* What an error says when the product is not signed in. The products' words for it are their
|
|
@@ -129,119 +127,6 @@ const wait = (ms: number): Promise<"timeout"> =>
|
|
|
129
127
|
setTimeout(() => resolve("timeout"), ms).unref?.();
|
|
130
128
|
});
|
|
131
129
|
|
|
132
|
-
/**
|
|
133
|
-
* What an error carries beside its message, as words: an agent may say "Internal error" and put
|
|
134
|
-
* why under `data`, as text or as an object with a message of its own.
|
|
135
|
-
*/
|
|
136
|
-
function detailOf(data: unknown, cut: Cut): string | undefined {
|
|
137
|
-
const words = isObject(data)
|
|
138
|
-
? (textOf(data.message) ?? textOf(data.details) ?? textOf(data.error))
|
|
139
|
-
: textOf(data);
|
|
140
|
-
const detail = words?.trim();
|
|
141
|
-
return detail === undefined || detail.length === 0 ? undefined : cut(detail, MAX_DETAIL_LENGTH);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** What a request was refused with, as the protocol says it: the message, with what it carries beside it. */
|
|
145
|
-
class RpcError extends Error {
|
|
146
|
-
readonly code: number;
|
|
147
|
-
constructor(code: number, message: string, data?: unknown, cut: Cut = plainCut) {
|
|
148
|
-
const detail = detailOf(data, cut);
|
|
149
|
-
super(detail === undefined || message.includes(detail) ? message : `${message}: ${detail}`);
|
|
150
|
-
this.code = code;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/** The two ends of the protocol on one process: requests with their answers, and what arrives unasked. */
|
|
155
|
-
interface Connection {
|
|
156
|
-
request(method: string, params: Json): Promise<unknown>;
|
|
157
|
-
notify(method: string, params: Json): Promise<void>;
|
|
158
|
-
/** Answers a request of the agent's. */
|
|
159
|
-
answer(id: unknown, result: Json): Promise<void>;
|
|
160
|
-
refuse(id: unknown, code: number, message: string): Promise<void>;
|
|
161
|
-
/** Reads the process to its end, handing over what the agent says and asks. */
|
|
162
|
-
read(on: {
|
|
163
|
-
notification(method: string, params: Json): void;
|
|
164
|
-
request(id: unknown, method: string, params: Json): void;
|
|
165
|
-
}): Promise<void>;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function connectionOf(child: Child, cut: Cut = plainCut): Connection {
|
|
169
|
-
let next = 0;
|
|
170
|
-
const pending = new Map<number, { resolve(value: unknown): void; reject(error: Error): void }>();
|
|
171
|
-
const write = (message: Json): Promise<void> =>
|
|
172
|
-
child.write(JSON.stringify({ jsonrpc: "2.0", ...message }));
|
|
173
|
-
return {
|
|
174
|
-
request(method, params) {
|
|
175
|
-
const id = next;
|
|
176
|
-
next += 1;
|
|
177
|
-
return new Promise((resolve, reject) => {
|
|
178
|
-
pending.set(id, { resolve, reject });
|
|
179
|
-
write({ id, method, params }).catch((error: unknown) => {
|
|
180
|
-
pending.delete(id);
|
|
181
|
-
reject(error instanceof Error ? error : new Error(String(error)));
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
},
|
|
185
|
-
notify: (method, params) => write({ method, params }),
|
|
186
|
-
answer: (id, result) => write({ id, result }),
|
|
187
|
-
refuse: (id, code, message) => write({ id, error: { code, message } }),
|
|
188
|
-
async read(on) {
|
|
189
|
-
try {
|
|
190
|
-
for await (const text of child.lines) {
|
|
191
|
-
if (text.trim().length === 0) {
|
|
192
|
-
continue;
|
|
193
|
-
}
|
|
194
|
-
let line: unknown;
|
|
195
|
-
try {
|
|
196
|
-
line = JSON.parse(text);
|
|
197
|
-
} catch {
|
|
198
|
-
// What is no message of the protocol is none of the runner's: a line a product
|
|
199
|
-
// printed beside it, say.
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
if (!isObject(line)) {
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
const method = textOf(line.method);
|
|
206
|
-
if (method !== undefined) {
|
|
207
|
-
const params = isObject(line.params) ? line.params : {};
|
|
208
|
-
if (line.id === undefined || line.id === null) {
|
|
209
|
-
on.notification(method, params);
|
|
210
|
-
} else {
|
|
211
|
-
on.request(line.id, method, params);
|
|
212
|
-
}
|
|
213
|
-
continue;
|
|
214
|
-
}
|
|
215
|
-
const waiting = typeof line.id === "number" ? pending.get(line.id) : undefined;
|
|
216
|
-
if (waiting === undefined || typeof line.id !== "number") {
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
pending.delete(line.id);
|
|
220
|
-
if (isObject(line.error)) {
|
|
221
|
-
waiting.reject(
|
|
222
|
-
new RpcError(
|
|
223
|
-
typeof line.error.code === "number" ? line.error.code : 0,
|
|
224
|
-
textOf(line.error.message) ?? "the request was refused",
|
|
225
|
-
line.error.data,
|
|
226
|
-
cut,
|
|
227
|
-
),
|
|
228
|
-
);
|
|
229
|
-
} else {
|
|
230
|
-
waiting.resolve(line.result);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
} catch {
|
|
234
|
-
// The output closed in the middle of a line: how the process ended says the rest.
|
|
235
|
-
}
|
|
236
|
-
// Nothing answers what was asked of a process that is gone.
|
|
237
|
-
for (const waiting of pending.values()) {
|
|
238
|
-
waiting.reject(new Error("the product's process ended"));
|
|
239
|
-
}
|
|
240
|
-
pending.clear();
|
|
241
|
-
},
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
|
|
245
130
|
/** What one of the product's choices is, as the protocol lists it: its id, what it stands at, and what it may be set to. */
|
|
246
131
|
interface Choice {
|
|
247
132
|
readonly id: string;
|
|
@@ -446,7 +331,7 @@ function sessionOf(
|
|
|
446
331
|
): DriverSession {
|
|
447
332
|
/** What cuts a text to what is shown of it: the runner's, which takes the account's secrets out first. */
|
|
448
333
|
const cut = options.cut ?? plainCut;
|
|
449
|
-
const connection = connectionOf(child, cut);
|
|
334
|
+
const connection = connectionOf(child, { cut });
|
|
450
335
|
/** How what the agent asks leave for is answered: settled once the session says its modes. */
|
|
451
336
|
let mode = acpMode(options.permissions);
|
|
452
337
|
|
|
@@ -917,6 +802,15 @@ function sessionOf(
|
|
|
917
802
|
emit({ type: "cannot_go_on", state: "failed", reason: "sign_in" });
|
|
918
803
|
return;
|
|
919
804
|
}
|
|
805
|
+
// A turn refused on the product's usage limit: nothing goes better before a window
|
|
806
|
+
// resets, and the protocol has no word for when that is. The session stays open; the
|
|
807
|
+
// runner waits, tries again by itself, and hands over again what was not answered.
|
|
808
|
+
// Read by pattern, of the agent's own error alone: not seen with an agent yet.
|
|
809
|
+
if (saysUsageLimit(words)) {
|
|
810
|
+
waiting = [];
|
|
811
|
+
emit({ type: "cannot_go_on", state: "failed", reason: "usage_limit" });
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
920
814
|
// A turn the agent itself said failed is a turn that ended: it takes the next message.
|
|
921
815
|
} else {
|
|
922
816
|
// The process is gone: how it ended is said where its output ends.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// The browser of an agent that is no tool of its product's own (ADR-0151): a Google Chrome
|
|
2
|
+
// driven by a program that the product starts beside itself, as a server of the Model Context
|
|
3
|
+
// Protocol. With no window it needs no screen, no extension and no sign-in of its own, and it
|
|
4
|
+
// keeps a profile of its own in the OS account's home, so that what the agent signed in at
|
|
5
|
+
// stays signed in from one session to the next, with a window or without. The program is
|
|
6
|
+
// looked for by the setup (`cli/machine-check.ts`) and named to the product by its driver; the
|
|
7
|
+
// package neither carries it nor fetches it.
|
|
8
|
+
|
|
9
|
+
/** The program that drives the browser: Chrome DevTools for agents, as npm installs it. */
|
|
10
|
+
export const HEADLESS_TOOL = {
|
|
11
|
+
/** What a product calls the server, and so its tools: `mcp__chrome-devtools__<tool>` in Claude Code. */
|
|
12
|
+
server: "chrome-devtools",
|
|
13
|
+
command: "chrome-devtools-mcp",
|
|
14
|
+
/**
|
|
15
|
+
* With the tag written out. Asked for by its name alone, npm on a Node.js older than the
|
|
16
|
+
* program needs installs the last version that named no Node.js at all, 0.2.6, without a
|
|
17
|
+
* word: one that answers, knows none of the words below and looks for Chrome in one place
|
|
18
|
+
* (seen on Windows with Node.js 22.11). Asked for by the tag, npm installs the latest, which
|
|
19
|
+
* says what it needs when it is started.
|
|
20
|
+
*/
|
|
21
|
+
install: "npm install -g chrome-devtools-mcp@latest",
|
|
22
|
+
/** What the program runs on: under an older Node.js it ends before it reads a word. */
|
|
23
|
+
needs: "Node.js 20.19, 22.12 or later",
|
|
24
|
+
/** The first version that knows every word it is started with. */
|
|
25
|
+
least: "0.23.0",
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Whether a version the program answered is one that knows the words it is started with. An
|
|
30
|
+
* answer that names no version says nothing against it: the session says so where the program
|
|
31
|
+
* does not start.
|
|
32
|
+
*/
|
|
33
|
+
export function headlessToolKnowsWords(answered: string): boolean {
|
|
34
|
+
const numbers = (version: string): number[] | undefined => {
|
|
35
|
+
const read = /^v?(\d{1,6})\.(\d{1,6})\.(\d{1,6})/.exec(version.trim());
|
|
36
|
+
return read === null ? undefined : read.slice(1).map(Number);
|
|
37
|
+
};
|
|
38
|
+
const has = numbers(answered);
|
|
39
|
+
const least = numbers(HEADLESS_TOOL.least) ?? [];
|
|
40
|
+
if (has === undefined) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
for (const [index, number] of has.entries()) {
|
|
44
|
+
const floor = least[index] ?? 0;
|
|
45
|
+
if (number !== floor) {
|
|
46
|
+
return number > floor;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The words the program is started with for a session, whatever its browser shows: nothing
|
|
54
|
+
* said of the agent's work to the program's maker, who is sent how its tools are used and the
|
|
55
|
+
* addresses a measurement of a page's speed read unless it is started with these; and the
|
|
56
|
+
* headers a sign-in is carried in left out of what its tools answer of a request, since what a
|
|
57
|
+
* tool answers is in the session's record. A profile is named by no word: the program keeps its
|
|
58
|
+
* own, the same one every time.
|
|
59
|
+
*/
|
|
60
|
+
const TOOL_WORDS = [
|
|
61
|
+
"--no-usage-statistics",
|
|
62
|
+
"--no-performance-crux",
|
|
63
|
+
"--redact-network-headers",
|
|
64
|
+
] as const;
|
|
65
|
+
|
|
66
|
+
/** The words for a browser with no window, which is what a desk has where it names none. */
|
|
67
|
+
export const HEADLESS_WORDS = ["--headless", ...TOOL_WORDS] as const;
|
|
68
|
+
|
|
69
|
+
/** The words for the same browser with its window, on the desktop the OS account is logged in at. */
|
|
70
|
+
export const WINDOW_WORDS = [...TOOL_WORDS] as const;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* How the program is started with some words, as the system the runner is on starts it. npm
|
|
74
|
+
* installs a program as a script, which on Windows is a `.cmd` file that only the system's own
|
|
75
|
+
* interpreter starts: there the program is started through it, with words that are the
|
|
76
|
+
* package's own and never anyone else's.
|
|
77
|
+
*/
|
|
78
|
+
export function headlessToolCommand(
|
|
79
|
+
platform: string | undefined,
|
|
80
|
+
words: readonly string[],
|
|
81
|
+
): { readonly command: string; readonly args: readonly string[] } {
|
|
82
|
+
return platform === "win32"
|
|
83
|
+
? { command: "cmd", args: ["/c", HEADLESS_TOOL.command, ...words] }
|
|
84
|
+
: { command: HEADLESS_TOOL.command, args: [...words] };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* What the program is started with beside its words: no look at a registry for a newer version
|
|
89
|
+
* of itself, so that a session asks nothing of one; and on Windows, the system's interpreter
|
|
90
|
+
* told to look for the program where programs are installed and never in the directory it is
|
|
91
|
+
* started in first, which is the agent's desk, where a file of the program's name would
|
|
92
|
+
* otherwise be what starts.
|
|
93
|
+
*/
|
|
94
|
+
function toolEnvironment(platform: string | undefined): Readonly<Record<string, string>> {
|
|
95
|
+
return {
|
|
96
|
+
CHROME_DEVTOOLS_MCP_NO_UPDATE_CHECKS: "1",
|
|
97
|
+
...(platform === "win32" ? { NoDefaultCurrentDirectoryInExePath: "1" } : {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The server a product is started with for the browser, in the shape a product reads its
|
|
103
|
+
* servers in: with no window, or with one where `window` says so.
|
|
104
|
+
*/
|
|
105
|
+
export function headlessServers(
|
|
106
|
+
platform: string | undefined,
|
|
107
|
+
window = false,
|
|
108
|
+
): {
|
|
109
|
+
readonly mcpServers: Readonly<
|
|
110
|
+
Record<
|
|
111
|
+
string,
|
|
112
|
+
{
|
|
113
|
+
readonly command: string;
|
|
114
|
+
readonly args: readonly string[];
|
|
115
|
+
readonly env: Readonly<Record<string, string>>;
|
|
116
|
+
}
|
|
117
|
+
>
|
|
118
|
+
>;
|
|
119
|
+
} {
|
|
120
|
+
return {
|
|
121
|
+
mcpServers: {
|
|
122
|
+
[HEADLESS_TOOL.server]: {
|
|
123
|
+
...headlessToolCommand(platform, window ? WINDOW_WORDS : HEADLESS_WORDS),
|
|
124
|
+
env: toolEnvironment(platform),
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|