@skillcdn/console 0.5.0 → 0.5.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 +87 -12
- package/SKILLCDN.md +3 -3
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +7 -6
- package/dist/agent-page.js.map +1 -1
- package/dist/api.d.ts +9 -7
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +8 -6
- 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 +58 -2
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +1742 -472
- 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 +70 -9
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +267 -40
- 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 +101 -58
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/machine-check.d.ts +36 -0
- package/dist/cli/machine-check.d.ts.map +1 -0
- package/dist/cli/machine-check.js +151 -0
- package/dist/cli/machine-check.js.map +1 -0
- 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/runner-host.d.ts +7 -0
- package/dist/cli/runner-host.d.ts.map +1 -1
- package/dist/cli/runner-host.js +2 -0
- package/dist/cli/runner-host.js.map +1 -1
- package/dist/cli/secret-notes.d.ts +8 -0
- package/dist/cli/secret-notes.d.ts.map +1 -0
- package/dist/cli/secret-notes.js +48 -0
- package/dist/cli/secret-notes.js.map +1 -0
- 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 +54 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +77 -80
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +164 -8
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +588 -151
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/agents.d.ts.map +1 -1
- package/dist/components/agents.js +1 -1
- package/dist/components/agents.js.map +1 -1
- package/dist/components/board.d.ts.map +1 -1
- package/dist/components/board.js +3 -2
- package/dist/components/board.js.map +1 -1
- package/dist/components/categories.js +1 -1
- package/dist/components/categories.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/decision-list.d.ts.map +1 -1
- package/dist/components/decision-list.js +1 -1
- package/dist/components/decision-list.js.map +1 -1
- 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 +7 -3
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/goals.d.ts +2 -0
- package/dist/components/goals.d.ts.map +1 -1
- package/dist/components/goals.js +1 -1
- package/dist/components/goals.js.map +1 -1
- package/dist/components/home.d.ts.map +1 -1
- package/dist/components/home.js +14 -6
- package/dist/components/home.js.map +1 -1
- package/dist/components/icon.d.ts +31 -0
- package/dist/components/icon.d.ts.map +1 -0
- package/dist/components/icon.js +169 -0
- package/dist/components/icon.js.map +1 -0
- package/dist/components/markdown.d.ts +6 -0
- package/dist/components/markdown.d.ts.map +1 -1
- package/dist/components/markdown.js +10 -2
- package/dist/components/markdown.js.map +1 -1
- package/dist/components/people.js +1 -1
- package/dist/components/people.js.map +1 -1
- package/dist/components/plugin-frame.d.ts.map +1 -1
- package/dist/components/plugin-frame.js +7 -0
- package/dist/components/plugin-frame.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 +17 -4
- package/dist/components/projects.d.ts.map +1 -1
- package/dist/components/projects.js +51 -12
- 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/sessions.d.ts.map +1 -1
- package/dist/components/sessions.js +3 -2
- package/dist/components/sessions.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 +12 -6
- package/dist/components/setup.js.map +1 -1
- package/dist/components/shell.d.ts.map +1 -1
- package/dist/components/shell.js +3 -2
- package/dist/components/shell.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 +5 -2
- package/dist/components/ui.d.ts.map +1 -1
- package/dist/components/ui.js +10 -7
- package/dist/components/ui.js.map +1 -1
- package/dist/connect-page.js +1 -1
- package/dist/connect-page.js.map +1 -1
- package/dist/console.css +1172 -106
- package/dist/console.d.ts +5 -0
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +52 -39
- 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 +19 -3
- package/dist/home-tiles.d.ts.map +1 -1
- package/dist/home-tiles.js +147 -42
- package/dist/home-tiles.js.map +1 -1
- package/dist/i18n/en.d.ts +228 -6
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +309 -9
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +366 -85
- package/dist/i18n/ko.js.map +1 -1
- package/dist/i18n/particles.d.ts +7 -0
- package/dist/i18n/particles.d.ts.map +1 -0
- package/dist/i18n/particles.js +72 -0
- package/dist/i18n/particles.js.map +1 -0
- package/dist/icons/glyphs.d.ts +605 -0
- package/dist/icons/glyphs.d.ts.map +1 -0
- package/dist/icons/glyphs.js +104 -0
- package/dist/icons/glyphs.js.map +1 -0
- package/dist/icons/index.d.ts +59 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/icons/index.js +157 -0
- package/dist/icons/index.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +20 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +20 -0
- package/dist/limits.js.map +1 -1
- package/dist/marks.d.ts +9 -0
- package/dist/marks.d.ts.map +1 -1
- package/dist/marks.js +9 -0
- package/dist/marks.js.map +1 -1
- package/dist/onboarding.d.ts +6 -0
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +5 -5
- 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/web.d.ts +3 -0
- package/dist/plugin/web.d.ts.map +1 -1
- package/dist/plugin/web.js +5 -1
- package/dist/plugin/web.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 +32 -21
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/awake.d.ts +35 -0
- package/dist/runner/awake.d.ts.map +1 -0
- package/dist/runner/awake.js +95 -0
- package/dist/runner/awake.js.map +1 -0
- package/dist/runner/claude.d.ts +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +100 -18
- 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 +20 -17
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/config.d.ts +5 -0
- package/dist/runner/config.d.ts.map +1 -1
- package/dist/runner/config.js +9 -0
- package/dist/runner/config.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 +168 -13
- 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 +28 -3
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +371 -54
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/slack.d.ts.map +1 -1
- package/dist/runner/slack.js +10 -4
- package/dist/runner/slack.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 +51 -1
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js +26 -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 +603 -6
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +156 -20
- 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 +41 -17
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +17 -4
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +48 -41
- package/dist/setup-guide.js.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +5 -1
- package/dist/tokens.js.map +1 -1
- package/dist/vocabulary.d.ts +21 -3
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +19 -3
- package/dist/vocabulary.js.map +1 -1
- package/docs/specs/cli.md +73 -44
- package/docs/specs/plugins.md +40 -22
- package/docs/specs/records.md +113 -0
- package/docs/specs/rest.md +30 -21
- package/docs/specs/runner.md +46 -22
- package/package.json +11 -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 +47 -56
- package/skills/working-the-board/SKILL.md +63 -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 +16 -2
- package/src/api.ts +109 -3
- package/src/charts.ts +250 -0
- package/src/cli/cli.ts +2226 -580
- 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 +332 -49
- package/src/cli/help.ts +113 -57
- package/src/cli/machine-check.ts +223 -0
- 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/runner-host.ts +8 -0
- package/src/cli/secret-notes.ts +63 -0
- package/src/cli/serve.ts +295 -2
- package/src/client.ts +215 -177
- package/src/components/agent-page.tsx +1044 -281
- package/src/components/agents.tsx +9 -5
- package/src/components/board.tsx +3 -15
- package/src/components/categories.tsx +2 -2
- package/src/components/charts.tsx +680 -0
- package/src/components/decision-list.tsx +11 -7
- package/src/components/desk-records.tsx +724 -0
- package/src/components/desk.tsx +471 -0
- package/src/components/event-feed.tsx +12 -3
- package/src/components/goals.tsx +33 -25
- package/src/components/home.tsx +42 -6
- package/src/components/icon.tsx +337 -0
- package/src/components/markdown.tsx +22 -2
- package/src/components/people.tsx +1 -1
- package/src/components/plugin-frame.tsx +7 -0
- package/src/components/plugin-settings.tsx +171 -12
- package/src/components/projects.tsx +68 -17
- package/src/components/rules.tsx +94 -34
- package/src/components/sessions.tsx +2 -13
- package/src/components/setup.tsx +20 -5
- package/src/components/shell.tsx +3 -20
- package/src/components/tokens.tsx +1 -1
- package/src/components/ui.tsx +16 -8
- package/src/connect-page.tsx +1 -1
- package/src/console.tsx +104 -62
- 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 +170 -46
- package/src/i18n/en.ts +323 -11
- package/src/i18n/ko.ts +378 -87
- package/src/i18n/particles.ts +79 -0
- package/src/icons/glyphs.ts +112 -0
- package/src/icons/index.ts +195 -0
- package/src/index.ts +125 -0
- package/src/limits.ts +20 -0
- package/src/marks.ts +12 -0
- package/src/onboarding.ts +14 -6
- 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/web.ts +9 -2
- 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 +49 -30
- package/src/runner/awake.ts +135 -0
- package/src/runner/claude.ts +131 -26
- package/src/runner/codex.ts +37 -26
- package/src/runner/config.ts +9 -0
- package/src/runner/desk.ts +200 -15
- package/src/runner/process.ts +11 -4
- package/src/runner/redact.ts +92 -6
- package/src/runner/runner.ts +457 -56
- package/src/runner/slack.ts +10 -4
- package/src/runner/task-scheduler.ts +36 -4
- package/src/runner/types.ts +67 -1
- package/src/runner.ts +27 -2
- package/src/schemas.ts +177 -18
- package/src/services.ts +55 -16
- package/src/setup-guide.ts +49 -40
- package/src/styles/README.md +16 -5
- package/src/styles/base.css +17 -0
- package/src/styles/console.css +10 -0
- package/src/styles/drawn-by-pages.json +1 -1
- package/src/styles/pages/agents.css +103 -1
- package/src/styles/pages/board.css +0 -10
- package/src/styles/pages/calendar.css +1 -1
- package/src/styles/pages/connect.css +0 -10
- package/src/styles/pages/decisions.css +3 -1
- package/src/styles/pages/desk.css +126 -0
- package/src/styles/pages/documents.css +5 -0
- package/src/styles/pages/feed.css +5 -2
- package/src/styles/pages/home.css +5 -0
- package/src/styles/pages/roadmap.css +2 -2
- package/src/styles/pages/settings.css +11 -0
- package/src/styles/pages/task.css +0 -20
- package/src/styles/pages/thread.css +1 -1
- package/src/styles/parts/bars.css +80 -0
- package/src/styles/parts/calendar.css +1 -1
- package/src/styles/parts/callout.css +1 -0
- package/src/styles/parts/chart.css +173 -0
- package/src/styles/parts/detail.css +22 -0
- package/src/styles/parts/empty.css +2 -0
- package/src/styles/parts/eyebrow.css +1 -1
- package/src/styles/parts/facts.css +1 -1
- package/src/styles/parts/figures.css +65 -0
- package/src/styles/parts/form.css +2 -1
- package/src/styles/parts/icon.css +191 -0
- package/src/styles/parts/input.css +14 -4
- package/src/styles/parts/legend.css +48 -0
- package/src/styles/parts/mark.css +36 -0
- package/src/styles/parts/menu.css +1 -7
- package/src/styles/parts/page.css +1 -1
- package/src/styles/parts/panel.css +10 -0
- package/src/styles/parts/person.css +5 -2
- package/src/styles/parts/progress.css +5 -2
- package/src/styles/parts/rows.css +1 -0
- package/src/styles/parts/series.css +32 -0
- package/src/styles/parts/settings.css +5 -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 +31 -10
- package/src/tokens.ts +5 -1
- package/src/vocabulary.ts +25 -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/dist/runner/runner.js
CHANGED
|
@@ -3,7 +3,7 @@ import { MAX_RUNNER_LINE_LENGTH, MAX_RUNNER_OFFERS, MAX_TRANSCRIPT_ATTACHMENTS,
|
|
|
3
3
|
import { RUNNER_CHOICE } from "../schemas.js";
|
|
4
4
|
import { hasForbiddenCodePoint } from "../text.js";
|
|
5
5
|
import { composeSignals, deskName, GROUP_WINDOW_MS, introOf, makeMark, } from "./message.js";
|
|
6
|
-
import { redactorOf } from "./redact.js";
|
|
6
|
+
import { cutShown, cutShownEnd, redactorOf } from "./redact.js";
|
|
7
7
|
// The runner (ADR-0085, docs/specs/runner.md): one process per agent account on its machine. It
|
|
8
8
|
// keeps one session of the agent's product at a time, feeds it what the console sends, reports
|
|
9
9
|
// what the product does, and says every thirty seconds that it is there. It restarts nothing by
|
|
@@ -26,6 +26,13 @@ export const MAX_COOL_DOWN_MS = 4 * 60 * 60_000;
|
|
|
26
26
|
export const RECONNECT_MS = 5000;
|
|
27
27
|
/** What an autosave's commit says: the runner's, and never the agent's own words. */
|
|
28
28
|
export const AUTOSAVE_MESSAGE = "Autosave at the end of a session";
|
|
29
|
+
/**
|
|
30
|
+
* How long the runner holds back what the console refused as more than an hour takes
|
|
31
|
+
* (ADR-0132), the events of a session and the wakes of its wake sources: a minute at first,
|
|
32
|
+
* twice as long after each refusal that follows, a quarter of an hour at most.
|
|
33
|
+
*/
|
|
34
|
+
export const HOLD_MS = 60_000;
|
|
35
|
+
export const MAX_HOLD_MS = 15 * 60_000;
|
|
29
36
|
/** The longest the runner waits before it starts a wake source again that keeps ending at once. */
|
|
30
37
|
export const MAX_SOURCE_PAUSE_MS = 5 * 60_000;
|
|
31
38
|
/** How long a wake source holds before the runner takes it to have worked. */
|
|
@@ -126,8 +133,12 @@ export function createRunner(options) {
|
|
|
126
133
|
coolDownMs: COOL_DOWN_MS,
|
|
127
134
|
maxCoolDownMs: MAX_COOL_DOWN_MS,
|
|
128
135
|
reconnectMs: RECONNECT_MS,
|
|
136
|
+
holdMs: HOLD_MS,
|
|
137
|
+
maxHoldMs: MAX_HOLD_MS,
|
|
129
138
|
...options.timing,
|
|
130
139
|
};
|
|
140
|
+
/** How long what an hour's bound refused is held back: the first time, and twice as long each time after. */
|
|
141
|
+
const heldFor = (before) => before === undefined ? timing.holdMs : Math.min(before.pause * 2, timing.maxHoldMs);
|
|
131
142
|
const bounds = { outboxBytes: MAX_OUTBOX_BYTES, ...options.bounds };
|
|
132
143
|
// What keeps failing is said once, and again when what is said of it changes, so that an hour
|
|
133
144
|
// without the console is a line and not thousands; that it is over is said once too.
|
|
@@ -173,7 +184,12 @@ export function createRunner(options) {
|
|
|
173
184
|
timers.add(timer);
|
|
174
185
|
};
|
|
175
186
|
// What the runner holds.
|
|
187
|
+
/** The number of the last signal delivered, every one before it too: what is kept and said to the console. */
|
|
176
188
|
let delivered = 0;
|
|
189
|
+
/** The signals handed to the product that it has not taken yet, by number: not delivered, and not sent twice. */
|
|
190
|
+
const owed = new Set();
|
|
191
|
+
/** The highest number of a signal the product took, or the record says was never read or let go. */
|
|
192
|
+
let settled = 0;
|
|
177
193
|
/** The number of the last signal the stream gave, and of the last one acted on: the second is behind the first while one waits in the queue. */
|
|
178
194
|
let received = 0;
|
|
179
195
|
let handled = 0;
|
|
@@ -204,8 +220,10 @@ export function createRunner(options) {
|
|
|
204
220
|
/** The values of the account's store, by what the store said of them last. */
|
|
205
221
|
let secretsStamp;
|
|
206
222
|
let secretValues = new Map();
|
|
207
|
-
let redact = (
|
|
223
|
+
let redact = redactorOf([]);
|
|
208
224
|
let tooOldSaid = false;
|
|
225
|
+
/** The console took as many wakes of this runner's as an hour takes: until when none is raised, and how long that was. */
|
|
226
|
+
let wakesHeld;
|
|
209
227
|
/**
|
|
210
228
|
* The package the runner runs from, where it is another version than the runner's: the one
|
|
211
229
|
* last seen, and the one seen twice running, which the runner ends for.
|
|
@@ -213,6 +231,17 @@ export function createRunner(options) {
|
|
|
213
231
|
let seenVersion;
|
|
214
232
|
let seenAt = 0;
|
|
215
233
|
let updatedTo;
|
|
234
|
+
/**
|
|
235
|
+
* The desk's `runner.json`, where it is another than the one the runner was started with:
|
|
236
|
+
* how it was last seen, a file that reads or what is wrong with one that does not, and since
|
|
237
|
+
* when it is seen so; whether the runner ends for it; and what is wrong with it that the
|
|
238
|
+
* agent was told of.
|
|
239
|
+
*/
|
|
240
|
+
let sighted;
|
|
241
|
+
let reconfigure = false;
|
|
242
|
+
let toldOf;
|
|
243
|
+
/** How each wake source stands, by its name: what the heartbeat says of them. */
|
|
244
|
+
const sources = new Map();
|
|
216
245
|
/**
|
|
217
246
|
* The signals a product was handed and never took, since it did not start or was not signed
|
|
218
247
|
* in, which are kept to be sent again; and, of those, the ones a reset gave one more try: a
|
|
@@ -328,11 +357,18 @@ export function createRunner(options) {
|
|
|
328
357
|
}
|
|
329
358
|
};
|
|
330
359
|
const codeOf = (error) => error instanceof ApiError ? error.code : error instanceof Error ? error.name : "error";
|
|
331
|
-
/**
|
|
332
|
-
|
|
360
|
+
/**
|
|
361
|
+
* Sends what the product did, a batch at a time, the pictures first. What the console has
|
|
362
|
+
* already is left there. Nothing is sent while the console holds the session to its hour
|
|
363
|
+
* (ADR-0132), but at the session's end, which is `last`.
|
|
364
|
+
*/
|
|
365
|
+
const flush = async (target, last = false) => {
|
|
333
366
|
if (flushing) {
|
|
334
367
|
return;
|
|
335
368
|
}
|
|
369
|
+
if (!last && target.hold !== undefined && options.now() < target.hold.until) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
336
372
|
flushing = true;
|
|
337
373
|
const about = `transcript ${target.id}`;
|
|
338
374
|
try {
|
|
@@ -383,6 +419,8 @@ export function createRunner(options) {
|
|
|
383
419
|
for (const event of target.outbox.splice(0, batch.length)) {
|
|
384
420
|
target.waiting -= event.held;
|
|
385
421
|
}
|
|
422
|
+
target.hold = undefined;
|
|
423
|
+
target.unsent = undefined;
|
|
386
424
|
sayOver(about, `the transcript of session ${target.id} is sent again`);
|
|
387
425
|
sayOver(`outbox ${target.id}`);
|
|
388
426
|
}
|
|
@@ -431,6 +469,19 @@ export function createRunner(options) {
|
|
|
431
469
|
target.waiting += only.held - before;
|
|
432
470
|
continue;
|
|
433
471
|
}
|
|
472
|
+
if (code === "transcript.too_many") {
|
|
473
|
+
// As many events as the console takes of a session within an hour: what waits is
|
|
474
|
+
// kept, within what the runner keeps, and sent again after a while, longer each
|
|
475
|
+
// time, so that the console is not asked every second for what it will refuse.
|
|
476
|
+
const pause = heldFor(target.hold);
|
|
477
|
+
target.hold = { until: options.now() + pause, pause };
|
|
478
|
+
target.unsent = code;
|
|
479
|
+
// Nothing is kept past the session's end: what is let go then is said there.
|
|
480
|
+
if (!last) {
|
|
481
|
+
sayOnce(about, `the console takes no more events of session ${target.id} within the hour (${code}); they are kept and sent again later`);
|
|
482
|
+
}
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
434
485
|
if (code === "transcript.session_over" ||
|
|
435
486
|
code === "transcript.session_not_found" ||
|
|
436
487
|
code === "transcript.away") {
|
|
@@ -445,8 +496,10 @@ export function createRunner(options) {
|
|
|
445
496
|
}
|
|
446
497
|
}
|
|
447
498
|
catch (error) {
|
|
448
|
-
// Kept, and sent with the next batch. Said once for as long as it lasts, and when it is
|
|
449
|
-
|
|
499
|
+
// Kept, and sent with the next batch. Said once for as long as it lasts, and when it is
|
|
500
|
+
// over; at the session's end there is no next batch, and what is let go is said there.
|
|
501
|
+
target.unsent = codeOf(error);
|
|
502
|
+
if (!stopped && !last) {
|
|
450
503
|
sayOnce(about, `the transcript of session ${target.id} waits to be sent (${codeOf(error)})`);
|
|
451
504
|
}
|
|
452
505
|
}
|
|
@@ -519,7 +572,10 @@ export function createRunner(options) {
|
|
|
519
572
|
});
|
|
520
573
|
}
|
|
521
574
|
catch (error) {
|
|
522
|
-
|
|
575
|
+
const code = codeOf(error);
|
|
576
|
+
log(code === "transcript.too_many_sessions"
|
|
577
|
+
? `the console begins no more sessions of this account within the hour (${code}); tried again after the cool-down`
|
|
578
|
+
: `a session could not be begun at the console (${code})`);
|
|
523
579
|
for (const path of handed.written) {
|
|
524
580
|
await options.files.remove(path).catch(() => undefined);
|
|
525
581
|
}
|
|
@@ -535,12 +591,18 @@ export function createRunner(options) {
|
|
|
535
591
|
effort: settings.effort,
|
|
536
592
|
resume,
|
|
537
593
|
permissions: config.permissions,
|
|
594
|
+
browser: config.browser,
|
|
595
|
+
// Whatever the driver shows a part of is cut once the secrets, as the store has them
|
|
596
|
+
// now, are out of it: no part of one stands where a text was cut.
|
|
597
|
+
cut: (text, most, more) => cutShown(redact, text, most, more),
|
|
598
|
+
cutEnd: (text, most, more) => cutShownEnd(redact, text, most, more),
|
|
538
599
|
}),
|
|
539
600
|
startedAt: options.now(),
|
|
540
601
|
first: true,
|
|
541
602
|
turn: false,
|
|
542
603
|
sent: [],
|
|
543
604
|
handed: [],
|
|
605
|
+
took: false,
|
|
544
606
|
n: 0,
|
|
545
607
|
outbox: [],
|
|
546
608
|
waiting: 0,
|
|
@@ -567,10 +629,24 @@ export function createRunner(options) {
|
|
|
567
629
|
await target.driver.stop().catch(() => undefined);
|
|
568
630
|
}
|
|
569
631
|
await target.pumped;
|
|
570
|
-
|
|
571
|
-
|
|
632
|
+
await hearLast(target);
|
|
633
|
+
// What the product was handed and never took is sent again, by the console where the
|
|
634
|
+
// runner itself ends and by the runner where the product had not started; else it is on
|
|
635
|
+
// the record as never read.
|
|
636
|
+
await leave(target, stopped ? "after" : already || target.took ? undefined : "next");
|
|
572
637
|
record(target, "status", `The session ended: ${how}.`, { ended: how });
|
|
573
|
-
await flush(target);
|
|
638
|
+
await flush(target, true);
|
|
639
|
+
// What the console did not take by now goes with the session: nothing of it is sent
|
|
640
|
+
// later, and the runner's line says how many, where an earlier one said they were kept.
|
|
641
|
+
const unsent = target.outbox.length;
|
|
642
|
+
if (unsent > 0) {
|
|
643
|
+
const one = unsent === 1;
|
|
644
|
+
log(`${unsent} ${one ? "event" : "events"} of session ${target.id} ${one ? "was" : "were"} let go unsent when it ended: ${target.unsent === "transcript.too_many"
|
|
645
|
+
? `the console takes no more of it within the hour (${target.unsent})`
|
|
646
|
+
: `the console did not take ${one ? "it" : "them"} (${target.unsent ?? "error"})`}`);
|
|
647
|
+
}
|
|
648
|
+
saidOf.delete(`transcript ${target.id}`);
|
|
649
|
+
saidOf.delete(`outbox ${target.id}`);
|
|
574
650
|
try {
|
|
575
651
|
await client.endAgentSession(target.id, { how });
|
|
576
652
|
}
|
|
@@ -763,25 +839,124 @@ export function createRunner(options) {
|
|
|
763
839
|
if (waited) {
|
|
764
840
|
write();
|
|
765
841
|
}
|
|
766
|
-
target.handed.push({ written: waited, write });
|
|
842
|
+
target.handed.push({ written: waited, write, signals: batch });
|
|
767
843
|
target.turn = true;
|
|
768
844
|
// Everything handed over since the agent was last done: what a product that took nothing is sent again.
|
|
769
845
|
target.sent = [...target.sent, ...batch];
|
|
770
|
-
|
|
771
|
-
|
|
846
|
+
// Handed over, and not delivered until the product says it took it: a product that did
|
|
847
|
+
// not start took nothing, and a runner that ends then is sent it again when it is back.
|
|
848
|
+
for (const signal of batch) {
|
|
849
|
+
owed.add(signal.number);
|
|
850
|
+
}
|
|
851
|
+
await account();
|
|
852
|
+
};
|
|
853
|
+
/** Counts signals as delivered: the product took them, or the record says what became of them. */
|
|
854
|
+
const count = async (signals) => {
|
|
855
|
+
for (const signal of signals) {
|
|
856
|
+
owed.delete(signal.number);
|
|
857
|
+
settled = Math.max(settled, signal.number);
|
|
858
|
+
}
|
|
772
859
|
await account();
|
|
773
860
|
};
|
|
774
861
|
/**
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
|
|
862
|
+
* The product took the oldest message it was handed: on the record now, where it was not
|
|
863
|
+
* written at once, and delivered.
|
|
864
|
+
*/
|
|
865
|
+
const take = async (target) => {
|
|
866
|
+
target.took = true;
|
|
867
|
+
const message = target.handed.shift();
|
|
868
|
+
if (message !== undefined) {
|
|
869
|
+
if (!message.written) {
|
|
870
|
+
message.write();
|
|
871
|
+
}
|
|
872
|
+
await count(message.signals);
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
/**
|
|
876
|
+
* The agent is done with what it was sent: what the product was handed and did not say it
|
|
877
|
+
* took is taken, on the record where the record does not hold it yet, and delivered.
|
|
778
878
|
*/
|
|
779
|
-
const settle = (target
|
|
879
|
+
const settle = async (target) => {
|
|
880
|
+
target.took = true;
|
|
881
|
+
const counted = [];
|
|
780
882
|
for (const message of target.handed.splice(0)) {
|
|
781
883
|
if (!message.written) {
|
|
782
|
-
message.write(
|
|
884
|
+
message.write();
|
|
885
|
+
}
|
|
886
|
+
counted.push(...message.signals);
|
|
887
|
+
}
|
|
888
|
+
await count(counted);
|
|
889
|
+
};
|
|
890
|
+
/**
|
|
891
|
+
* Hears what the product said as its session was ended. Its words wait in the queue behind
|
|
892
|
+
* whatever ended the session, and are let go there once the session is no longer the open
|
|
893
|
+
* one: a message it said it took then is taken, and not sent again, and the conversation it
|
|
894
|
+
* named is the one to go on with, where that message is.
|
|
895
|
+
*/
|
|
896
|
+
const hearLast = async (target) => {
|
|
897
|
+
let named = false;
|
|
898
|
+
for (const message of queue) {
|
|
899
|
+
if (message.t !== "driver" || message.session !== target) {
|
|
900
|
+
continue;
|
|
901
|
+
}
|
|
902
|
+
const { event } = message;
|
|
903
|
+
if (event.type === "conversation") {
|
|
904
|
+
conversation = event.id;
|
|
905
|
+
named = true;
|
|
906
|
+
}
|
|
907
|
+
else if (event.type === "taken") {
|
|
908
|
+
await take(target);
|
|
909
|
+
}
|
|
910
|
+
else if (event.type === "turn_completed") {
|
|
911
|
+
await settle(target);
|
|
912
|
+
record(target, "status", "The turn completed.", { turn: "completed" });
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
if (named) {
|
|
916
|
+
await persist();
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
/**
|
|
920
|
+
* What becomes of what the product was handed and never took, as its session ends
|
|
921
|
+
* (ADR-0131). Sent again, it is not delivered, and the record holds nothing more of it than
|
|
922
|
+
* a line that says so: by the console to the runner started `after` this one, where the
|
|
923
|
+
* runner itself ends; by this runner in the `next` session, where the product had taken
|
|
924
|
+
* nothing of this one, and so had not started. Else it is let go: on the record as never
|
|
925
|
+
* read, which delivers it; what the record holds since it was handed over, to a product that
|
|
926
|
+
* waited for a message, is said in a line not to have been taken.
|
|
927
|
+
*/
|
|
928
|
+
const leave = async (target, again) => {
|
|
929
|
+
const messages = target.handed.splice(0);
|
|
930
|
+
const signals = messages.flatMap((message) => message.signals);
|
|
931
|
+
if (signals.length === 0) {
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
const numbersOf = (some) => some.map((signal) => `#${signal.number}`).join(", ");
|
|
935
|
+
if (again !== undefined) {
|
|
936
|
+
const numbers = numbersOf(signals);
|
|
937
|
+
record(target, "status", `The session ended before the product took what it was sent: ${numbers}. It is sent again.`);
|
|
938
|
+
log(`${numbers} not taken when session ${target.id} ended: sent again`);
|
|
939
|
+
if (again === "next") {
|
|
940
|
+
for (const signal of signals) {
|
|
941
|
+
// Waits to be handed over again: owed no word of the product's, and not delivered.
|
|
942
|
+
owed.delete(signal.number);
|
|
943
|
+
sentBefore.add(signal.number);
|
|
944
|
+
}
|
|
945
|
+
pending = [...signals, ...pending];
|
|
946
|
+
}
|
|
947
|
+
return;
|
|
948
|
+
}
|
|
949
|
+
const written = messages.filter((message) => message.written).flatMap((one) => one.signals);
|
|
950
|
+
if (written.length > 0) {
|
|
951
|
+
record(target, "status", `The session ended before the product took what it was sent: ${numbersOf(written)}. Whoever sent it says it again where it still matters.`);
|
|
952
|
+
}
|
|
953
|
+
for (const message of messages) {
|
|
954
|
+
if (!message.written) {
|
|
955
|
+
message.write(true);
|
|
783
956
|
}
|
|
784
957
|
}
|
|
958
|
+
// On the record as never read: delivered.
|
|
959
|
+
await count(signals);
|
|
785
960
|
};
|
|
786
961
|
/**
|
|
787
962
|
* What the transcript says of a signal beside its words: its number and kind, where it came
|
|
@@ -803,13 +978,24 @@ export function createRunner(options) {
|
|
|
803
978
|
return { tries, until: options.now() + length };
|
|
804
979
|
};
|
|
805
980
|
/**
|
|
806
|
-
*
|
|
807
|
-
*
|
|
981
|
+
* Counts what is delivered: signals in order, up to the last one the product took, the record
|
|
982
|
+
* says was never read or let go, or the runner acted on itself, a stop or a choice of model
|
|
983
|
+
* say, and never past one that still waits to be handed to the product or that the product
|
|
984
|
+
* has not said it took.
|
|
808
985
|
*/
|
|
809
986
|
const account = async (signal) => {
|
|
810
987
|
acted = Math.max(acted, signal?.number ?? 0);
|
|
811
|
-
|
|
812
|
-
|
|
988
|
+
const most = Math.max(settled, acted);
|
|
989
|
+
let least = Number.POSITIVE_INFINITY;
|
|
990
|
+
for (const kept of pending) {
|
|
991
|
+
least = Math.min(least, kept.number);
|
|
992
|
+
}
|
|
993
|
+
for (const number of owed) {
|
|
994
|
+
least = Math.min(least, number);
|
|
995
|
+
}
|
|
996
|
+
const next = Math.min(most, least - 1);
|
|
997
|
+
if (next > delivered) {
|
|
998
|
+
delivered = next;
|
|
813
999
|
await persist();
|
|
814
1000
|
}
|
|
815
1001
|
};
|
|
@@ -821,7 +1007,9 @@ export function createRunner(options) {
|
|
|
821
1007
|
};
|
|
822
1008
|
const onSignal = async (signal) => {
|
|
823
1009
|
handled = Math.max(handled, signal.number);
|
|
824
|
-
if (signal.number <= delivered ||
|
|
1010
|
+
if (signal.number <= delivered ||
|
|
1011
|
+
owed.has(signal.number) ||
|
|
1012
|
+
pending.some((kept) => kept.number === signal.number)) {
|
|
825
1013
|
return;
|
|
826
1014
|
}
|
|
827
1015
|
const by = signal.by?.name ?? signal.by?.login ?? "a supervisor";
|
|
@@ -829,8 +1017,9 @@ export function createRunner(options) {
|
|
|
829
1017
|
case "stop": {
|
|
830
1018
|
held = true;
|
|
831
1019
|
if (session !== undefined) {
|
|
832
|
-
// What the product had not taken is on the record before the stop that leaves it
|
|
833
|
-
|
|
1020
|
+
// What the product had not taken is on the record before the stop that leaves it
|
|
1021
|
+
// unread; what a product that had not started was handed waits for the restart.
|
|
1022
|
+
await leave(session, session.took ? undefined : "next");
|
|
834
1023
|
record(session, "person", signal.text, signalData(signal));
|
|
835
1024
|
}
|
|
836
1025
|
await end("stopped");
|
|
@@ -956,16 +1145,12 @@ export function createRunner(options) {
|
|
|
956
1145
|
return;
|
|
957
1146
|
}
|
|
958
1147
|
case "taken": {
|
|
959
|
-
|
|
960
|
-
const message = target.handed.shift();
|
|
961
|
-
if (message !== undefined && !message.written) {
|
|
962
|
-
message.write();
|
|
963
|
-
}
|
|
1148
|
+
await take(target);
|
|
964
1149
|
return;
|
|
965
1150
|
}
|
|
966
1151
|
case "turn_completed": {
|
|
967
1152
|
// The agent is done with everything it was sent: what a product did not say it took is taken.
|
|
968
|
-
settle(target);
|
|
1153
|
+
await settle(target);
|
|
969
1154
|
// The record says where a turn ends, so that whoever reads it live knows the agent is done.
|
|
970
1155
|
record(target, "status", "The turn completed.", { turn: "completed" });
|
|
971
1156
|
target.turn = false;
|
|
@@ -1011,10 +1196,14 @@ export function createRunner(options) {
|
|
|
1011
1196
|
}
|
|
1012
1197
|
for (const signal of again) {
|
|
1013
1198
|
sentBefore.add(signal.number);
|
|
1199
|
+
// Waits to be handed over again: owed no word of the product's, and not delivered.
|
|
1200
|
+
owed.delete(signal.number);
|
|
1014
1201
|
}
|
|
1015
1202
|
pending = [...again, ...pending];
|
|
1016
1203
|
// Sent again, and on the record when it is taken then.
|
|
1017
1204
|
target.handed = [];
|
|
1205
|
+
// What was let go is on the record as that, and is delivered: it is sent no more.
|
|
1206
|
+
await count(gone);
|
|
1018
1207
|
}
|
|
1019
1208
|
target.sent = [];
|
|
1020
1209
|
waits = cooled(waits);
|
|
@@ -1052,6 +1241,50 @@ export function createRunner(options) {
|
|
|
1052
1241
|
images: driver.can.images,
|
|
1053
1242
|
resume: driver.can.resume,
|
|
1054
1243
|
});
|
|
1244
|
+
/**
|
|
1245
|
+
* Says something of the runner's own to the agent, in the open session, under a header that
|
|
1246
|
+
* carries the session's mark: read after the tool call under way. The agent has a turn's work
|
|
1247
|
+
* in it, so it is counted as a turn, and what the runner does between two turns, an update or
|
|
1248
|
+
* a `runner.json` taken, waits for that turn to end. What the product says it took then is
|
|
1249
|
+
* this message, which the record holds nothing of, and not the message of a signal that waits
|
|
1250
|
+
* behind it. Whether it was said.
|
|
1251
|
+
*/
|
|
1252
|
+
const sayToAgent = async (target, words) => {
|
|
1253
|
+
try {
|
|
1254
|
+
await target.driver.send({
|
|
1255
|
+
text: `[console ${target.mark} · runner]\n${words}`,
|
|
1256
|
+
images: [],
|
|
1257
|
+
priority: "next",
|
|
1258
|
+
});
|
|
1259
|
+
target.turn = true;
|
|
1260
|
+
target.handed.push({ written: true, write: () => undefined, signals: [] });
|
|
1261
|
+
return true;
|
|
1262
|
+
}
|
|
1263
|
+
catch {
|
|
1264
|
+
return false;
|
|
1265
|
+
}
|
|
1266
|
+
};
|
|
1267
|
+
/** The wake sources as the console is told of them: each by its name, how it stands, since when and why. */
|
|
1268
|
+
const sourcesOf = () => [...sources].map(([name, one]) => {
|
|
1269
|
+
const why = lineOf(one.why);
|
|
1270
|
+
return {
|
|
1271
|
+
name,
|
|
1272
|
+
state: one.state,
|
|
1273
|
+
since: new Date(one.since).toISOString(),
|
|
1274
|
+
...(why === null ? {} : { why }),
|
|
1275
|
+
};
|
|
1276
|
+
});
|
|
1277
|
+
/** Notes how a wake source stands, and has the console told at once where that is news. */
|
|
1278
|
+
const sourceStands = (name, state, why) => {
|
|
1279
|
+
const before = sources.get(name);
|
|
1280
|
+
if (before?.state === state && before.why === why) {
|
|
1281
|
+
return;
|
|
1282
|
+
}
|
|
1283
|
+
sources.set(name, { state, since: options.now(), why });
|
|
1284
|
+
if (!stopped) {
|
|
1285
|
+
push({ t: "heartbeat" });
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1055
1288
|
const beat = async () => {
|
|
1056
1289
|
const now = `${stands.state} ${stands.reason} ${session?.id ?? ""}`;
|
|
1057
1290
|
said = now;
|
|
@@ -1071,6 +1304,7 @@ export function createRunner(options) {
|
|
|
1071
1304
|
model: choiceOf(session?.running.model),
|
|
1072
1305
|
effort: choiceOf(session?.running.effort),
|
|
1073
1306
|
},
|
|
1307
|
+
sources: sourcesOf(),
|
|
1074
1308
|
});
|
|
1075
1309
|
settings = answer.settings;
|
|
1076
1310
|
tooOldSaid = false;
|
|
@@ -1100,22 +1334,9 @@ export function createRunner(options) {
|
|
|
1100
1334
|
const update = install === undefined
|
|
1101
1335
|
? ""
|
|
1102
1336
|
: ` Update it: ${install}\nThe runner sees the update and is started again with it by itself, once no turn is under way.`;
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
images: [],
|
|
1107
|
-
priority: "next",
|
|
1108
|
-
});
|
|
1109
|
-
// The agent has a turn's work in it, the install among it: counted as a turn, so
|
|
1110
|
-
// that the update it makes is taken when that turn ends and never inside it. What
|
|
1111
|
-
// the product says it took then is this message, which the record holds nothing
|
|
1112
|
-
// of, and not the message of a signal that waits behind it.
|
|
1113
|
-
target.turn = true;
|
|
1114
|
-
target.handed.push({ written: true, write: () => undefined });
|
|
1115
|
-
}
|
|
1116
|
-
catch {
|
|
1117
|
-
// Not told: the runner's own line above says it to whoever reads its output.
|
|
1118
|
-
}
|
|
1337
|
+
// Not told where it could not be: the runner's own line above says it to whoever
|
|
1338
|
+
// reads its output.
|
|
1339
|
+
await sayToAgent(target, `The console no longer takes this version of the command the runner runs from, and hears nothing of this session until it is updated.${update}\nWhere you cannot update it, say so to whom you report to.`);
|
|
1119
1340
|
}
|
|
1120
1341
|
}
|
|
1121
1342
|
return;
|
|
@@ -1151,6 +1372,61 @@ export function createRunner(options) {
|
|
|
1151
1372
|
updatedTo = now;
|
|
1152
1373
|
log(`the command the runner runs from is ${now} now, and was ${options.version} when the runner started: the runner ends once no turn is under way, to be started again`);
|
|
1153
1374
|
};
|
|
1375
|
+
/**
|
|
1376
|
+
* Looks whether the desk's `runner.json` is another than the one the runner was started with
|
|
1377
|
+
* (ADR-0144). How it stands is taken once it was seen the same way twice, a heartbeat's
|
|
1378
|
+
* interval apart, so that a file being written is not read halfway. One that reads has the
|
|
1379
|
+
* runner end between two turns, for whoever started it to start the next with the file as it
|
|
1380
|
+
* is; the look goes on until then, and a file put back, or one that stopped reading, ends
|
|
1381
|
+
* nothing. One that does not read changes nothing: the runner goes on with what it has, and
|
|
1382
|
+
* the agent, whose file it is, is told what is wrong with it, once for each thing that is,
|
|
1383
|
+
* in the session that is open or in the next one.
|
|
1384
|
+
*/
|
|
1385
|
+
const lookForChange = async () => {
|
|
1386
|
+
if (options.reconfigured === undefined) {
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
const now = await options.reconfigured().catch(() => "same");
|
|
1390
|
+
if (now === "same") {
|
|
1391
|
+
if (reconfigure) {
|
|
1392
|
+
log("runner.json is as the runner was started with it again: the runner goes on");
|
|
1393
|
+
}
|
|
1394
|
+
sighted = undefined;
|
|
1395
|
+
reconfigure = false;
|
|
1396
|
+
toldOf = undefined;
|
|
1397
|
+
sayOver("config", "runner.json is as the runner was started with it again");
|
|
1398
|
+
return;
|
|
1399
|
+
}
|
|
1400
|
+
const same = sighted !== undefined &&
|
|
1401
|
+
(now === "changed"
|
|
1402
|
+
? sighted.what === "changed"
|
|
1403
|
+
: sighted.what !== "changed" && sighted.what.problem === now.problem);
|
|
1404
|
+
if (!same) {
|
|
1405
|
+
// Another state than the one before: counted from now, and nothing ends for the old one.
|
|
1406
|
+
sighted = { what: now, at: options.now() };
|
|
1407
|
+
reconfigure = false;
|
|
1408
|
+
return;
|
|
1409
|
+
}
|
|
1410
|
+
const since = sighted?.at ?? options.now();
|
|
1411
|
+
if (options.now() - since < timing.heartbeatMs - Math.min(1000, timing.heartbeatMs / 2)) {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
if (now === "changed") {
|
|
1415
|
+
if (!reconfigure) {
|
|
1416
|
+
reconfigure = true;
|
|
1417
|
+
log("runner.json changed since the runner started: the runner ends once no turn is under way, and starts again with it");
|
|
1418
|
+
}
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
sayOnce("config", `${now.problem}: the runner goes on with the runner.json it was started with`);
|
|
1422
|
+
// Told once it can be: a session that opens later is told then.
|
|
1423
|
+
if (toldOf !== now.problem && session !== undefined && !session.first) {
|
|
1424
|
+
const told = await sayToAgent(session, `The desk's runner.json does not read: ${now.problem}. The runner goes on with the one it was started with. Put the file right, and the runner takes it by itself once your turn is over.`);
|
|
1425
|
+
if (told) {
|
|
1426
|
+
toldOf = now.problem;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
};
|
|
1154
1430
|
/** Waits so long, or until the runner stops. */
|
|
1155
1431
|
const pause = (ms, signal = abort.signal) => new Promise((resolve) => {
|
|
1156
1432
|
if (signal.aborted) {
|
|
@@ -1176,22 +1452,51 @@ export function createRunner(options) {
|
|
|
1176
1452
|
const host = {
|
|
1177
1453
|
secret: async (name) => secretValues.get(name),
|
|
1178
1454
|
raise: async (raised) => {
|
|
1179
|
-
|
|
1455
|
+
// The console takes so many wakes a runner raises itself within an hour (ADR-0132):
|
|
1456
|
+
// past that, what the sources raise is let go for a while, longer each time, and said
|
|
1457
|
+
// once, so that a source that repeats itself costs the console nothing more.
|
|
1458
|
+
if (wakesHeld !== undefined && options.now() < wakesHeld.until) {
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
try {
|
|
1462
|
+
await client.raiseWake({ source: "messenger", key: raised.key, text: raised.text });
|
|
1463
|
+
}
|
|
1464
|
+
catch (error) {
|
|
1465
|
+
if (codeOf(error) !== "signal.too_many") {
|
|
1466
|
+
throw error;
|
|
1467
|
+
}
|
|
1468
|
+
const pause = heldFor(wakesHeld);
|
|
1469
|
+
wakesHeld = { until: options.now() + pause, pause };
|
|
1470
|
+
sayOnce("wakes", "the console takes no more wakes of this runner's within the hour (signal.too_many); what its wake sources raise is let go for a while");
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
if (wakesHeld !== undefined) {
|
|
1474
|
+
wakesHeld = undefined;
|
|
1475
|
+
sayOver("wakes", "the console takes the wakes of this runner's wake sources again");
|
|
1476
|
+
}
|
|
1180
1477
|
},
|
|
1181
1478
|
log,
|
|
1479
|
+
stands: (state, why) => sourceStands(source.name, state, why),
|
|
1182
1480
|
fetch: wakes.fetch,
|
|
1183
1481
|
socket: wakes.socket,
|
|
1184
1482
|
wait: pause,
|
|
1185
1483
|
};
|
|
1484
|
+
sourceStands(source.name, "waiting");
|
|
1186
1485
|
let wait = timing.reconnectMs;
|
|
1187
1486
|
while (!stopped) {
|
|
1188
1487
|
const began = options.now();
|
|
1189
1488
|
try {
|
|
1190
1489
|
await source.run(host, abort.signal);
|
|
1490
|
+
// Ended with no error, a connection the other side closed say: it listens no more
|
|
1491
|
+
// until it says so again. What it said of why it waits stands.
|
|
1492
|
+
if (!stopped && sources.get(source.name)?.state === "connected") {
|
|
1493
|
+
sourceStands(source.name, "waiting");
|
|
1494
|
+
}
|
|
1191
1495
|
}
|
|
1192
1496
|
catch (error) {
|
|
1193
1497
|
if (!stopped) {
|
|
1194
1498
|
log(`the wake source ${source.name} ended (${codeOf(error)}); started again`);
|
|
1499
|
+
sourceStands(source.name, "failing", codeOf(error));
|
|
1195
1500
|
}
|
|
1196
1501
|
}
|
|
1197
1502
|
wait =
|
|
@@ -1283,14 +1588,21 @@ export function createRunner(options) {
|
|
|
1283
1588
|
const beating = setInterval(() => push({ t: "heartbeat" }), timing.heartbeatMs);
|
|
1284
1589
|
const batching = setInterval(() => push({ t: "flush" }), timing.batchMs);
|
|
1285
1590
|
log(`the runner is there: ${driver.product.name} ${probe.version ?? "of a version it did not say"}, signals after #${delivered}`);
|
|
1591
|
+
if (probe.version === undefined) {
|
|
1592
|
+
// Said before a session fails on it: asked for its version, the product's command did not answer.
|
|
1593
|
+
log(`the command of ${driver.product.name} did not answer when asked for its version: it is not installed where the runner looks for programs, or does not start there`);
|
|
1594
|
+
}
|
|
1286
1595
|
let how = "stopped";
|
|
1287
1596
|
try {
|
|
1288
1597
|
for (;;) {
|
|
1289
|
-
// An update is taken between two turns, and at once where none is under way
|
|
1290
|
-
|
|
1291
|
-
|
|
1598
|
+
// An update is taken between two turns, and at once where none is under way; so is
|
|
1599
|
+
// a runner.json that changed.
|
|
1600
|
+
if ((updatedTo !== undefined || reconfigure) && session?.turn !== true) {
|
|
1601
|
+
how = updatedTo !== undefined ? "updated" : "changed";
|
|
1292
1602
|
if (session !== undefined) {
|
|
1293
|
-
record(session, "status",
|
|
1603
|
+
record(session, "status", updatedTo !== undefined
|
|
1604
|
+
? `The command the runner runs from was updated, from ${options.version} to ${updatedTo}: the runner ends, to be started again with it.`
|
|
1605
|
+
: "The desk's runner.json changed: the runner ends, and starts again with it.");
|
|
1294
1606
|
}
|
|
1295
1607
|
break;
|
|
1296
1608
|
}
|
|
@@ -1318,6 +1630,7 @@ export function createRunner(options) {
|
|
|
1318
1630
|
}
|
|
1319
1631
|
else {
|
|
1320
1632
|
await lookForUpdate();
|
|
1633
|
+
await lookForChange();
|
|
1321
1634
|
// Said every thirty seconds, and at once when how the agent stands changed.
|
|
1322
1635
|
const changed = said !== `${stands.state} ${stands.reason} ${session?.id ?? ""}`;
|
|
1323
1636
|
if (changed || !queue.some((queued) => queued.t === "heartbeat")) {
|
|
@@ -1340,11 +1653,15 @@ export function createRunner(options) {
|
|
|
1340
1653
|
}
|
|
1341
1654
|
// A session ended for an update goes on, in the runner started after, as one a
|
|
1342
1655
|
// supervisor restarted does: with the same conversation.
|
|
1343
|
-
await end(how === "
|
|
1656
|
+
await end(how === "stopped" ? "exited" : "restarted");
|
|
1344
1657
|
abort.abort();
|
|
1345
1658
|
await listening;
|
|
1346
1659
|
await Promise.all(sourcing);
|
|
1347
|
-
log(how === "updated"
|
|
1660
|
+
log(how === "updated"
|
|
1661
|
+
? "the runner ended, for the update"
|
|
1662
|
+
: how === "changed"
|
|
1663
|
+
? "the runner ended, for its runner.json"
|
|
1664
|
+
: "the runner stopped");
|
|
1348
1665
|
}
|
|
1349
1666
|
return how;
|
|
1350
1667
|
},
|