@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/src/runner/runner.ts
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
introOf,
|
|
23
23
|
makeMark,
|
|
24
24
|
} from "./message.js";
|
|
25
|
-
import { redactorOf } from "./redact.js";
|
|
25
|
+
import { cutShown, cutShownEnd, type Redactor, redactorOf } from "./redact.js";
|
|
26
26
|
import type {
|
|
27
27
|
Driver,
|
|
28
28
|
DriverEvent,
|
|
@@ -57,6 +57,13 @@ export const MAX_COOL_DOWN_MS = 4 * 60 * 60_000;
|
|
|
57
57
|
export const RECONNECT_MS = 5000;
|
|
58
58
|
/** What an autosave's commit says: the runner's, and never the agent's own words. */
|
|
59
59
|
export const AUTOSAVE_MESSAGE = "Autosave at the end of a session";
|
|
60
|
+
/**
|
|
61
|
+
* How long the runner holds back what the console refused as more than an hour takes
|
|
62
|
+
* (ADR-0132), the events of a session and the wakes of its wake sources: a minute at first,
|
|
63
|
+
* twice as long after each refusal that follows, a quarter of an hour at most.
|
|
64
|
+
*/
|
|
65
|
+
export const HOLD_MS = 60_000;
|
|
66
|
+
export const MAX_HOLD_MS = 15 * 60_000;
|
|
60
67
|
/** The longest the runner waits before it starts a wake source again that keeps ending at once. */
|
|
61
68
|
export const MAX_SOURCE_PAUSE_MS = 5 * 60_000;
|
|
62
69
|
/** How long a wake source holds before the runner takes it to have worked. */
|
|
@@ -103,7 +110,12 @@ export type RunnerClient = Pick<
|
|
|
103
110
|
|
|
104
111
|
/** What the runner keeps between its own restarts. No secret is in it. */
|
|
105
112
|
export interface RunnerState {
|
|
106
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* The number of the last signal that is delivered, every one before it too (ADR-0131): the
|
|
115
|
+
* product said it took it, or the record says it was never read or was let go, or the runner
|
|
116
|
+
* acted on it itself. One handed to a product that has not said so is not delivered yet, and
|
|
117
|
+
* is sent again to a runner started after.
|
|
118
|
+
*/
|
|
107
119
|
readonly delivered: number;
|
|
108
120
|
/** The conversation the next session goes on with, where the product resumes one. */
|
|
109
121
|
readonly conversation: string | undefined;
|
|
@@ -174,6 +186,14 @@ export interface RunnerOptions {
|
|
|
174
186
|
readonly socket: WakeHost["socket"];
|
|
175
187
|
}
|
|
176
188
|
| undefined;
|
|
189
|
+
/**
|
|
190
|
+
* How the desk's `runner.json` stands against the one this runner was started with (ADR-0144):
|
|
191
|
+
* the same, another that reads, or one that does not read, with what is wrong with it in a few
|
|
192
|
+
* words. Left out, the runner never ends for its file.
|
|
193
|
+
*/
|
|
194
|
+
readonly reconfigured?:
|
|
195
|
+
| (() => Promise<"same" | "changed" | { readonly problem: string }>)
|
|
196
|
+
| undefined;
|
|
177
197
|
/** The durations, for a test to shorten. */
|
|
178
198
|
readonly timing?: Partial<{
|
|
179
199
|
heartbeatMs: number;
|
|
@@ -182,13 +202,18 @@ export interface RunnerOptions {
|
|
|
182
202
|
coolDownMs: number;
|
|
183
203
|
maxCoolDownMs: number;
|
|
184
204
|
reconnectMs: number;
|
|
205
|
+
holdMs: number;
|
|
206
|
+
maxHoldMs: number;
|
|
185
207
|
}>;
|
|
186
208
|
/** The bounds, for a test to lower. */
|
|
187
209
|
readonly bounds?: Partial<{ outboxBytes: number }>;
|
|
188
210
|
}
|
|
189
211
|
|
|
190
|
-
/**
|
|
191
|
-
|
|
212
|
+
/**
|
|
213
|
+
* How a runner ended: stopped by whoever runs it, by itself for an update of the command it runs
|
|
214
|
+
* from, or by itself for a `runner.json` that changed, which the next runner is started with.
|
|
215
|
+
*/
|
|
216
|
+
export type RunnerEnd = "stopped" | "updated" | "changed";
|
|
192
217
|
|
|
193
218
|
export interface Runner {
|
|
194
219
|
/** Runs until it ends: resolves, with how, when the open session is ended and nothing is left to send. */
|
|
@@ -252,7 +277,14 @@ interface OpenSession {
|
|
|
252
277
|
written: boolean;
|
|
253
278
|
/** Writes its signals on the record, as never read where so, and only those asked for where some are. */
|
|
254
279
|
readonly write: (unread?: boolean, only?: (signal: RestSignal) => boolean) => void;
|
|
280
|
+
/** Its signals: counted as delivered once the product took the message. */
|
|
281
|
+
readonly signals: readonly RestSignal[];
|
|
255
282
|
}[];
|
|
283
|
+
/**
|
|
284
|
+
* Whether the product took a message of this session, or completed a turn of it. One that
|
|
285
|
+
* has not is still starting, for all the runner knows: it took nothing it was handed.
|
|
286
|
+
*/
|
|
287
|
+
took: boolean;
|
|
256
288
|
/** The number of the last event of it. */
|
|
257
289
|
n: number;
|
|
258
290
|
/** What the product did and the console has not been sent yet, and what that holds of memory. */
|
|
@@ -260,6 +292,10 @@ interface OpenSession {
|
|
|
260
292
|
waiting: number;
|
|
261
293
|
/** Whether the console takes nothing more of it: over there, or its month away. */
|
|
262
294
|
refused: boolean;
|
|
295
|
+
/** The console took as many of its events as an hour takes: until when nothing is sent, and how long that was. */
|
|
296
|
+
hold?: { readonly until: number; readonly pause: number } | undefined;
|
|
297
|
+
/** Why the console did not take what waits, in its code: said where the session ends with it unsent. */
|
|
298
|
+
unsent?: string | undefined;
|
|
263
299
|
running: { model: string | null; effort: string | null };
|
|
264
300
|
/** The files written for it, to remove at its end. */
|
|
265
301
|
readonly written: string[];
|
|
@@ -345,8 +381,13 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
345
381
|
coolDownMs: COOL_DOWN_MS,
|
|
346
382
|
maxCoolDownMs: MAX_COOL_DOWN_MS,
|
|
347
383
|
reconnectMs: RECONNECT_MS,
|
|
384
|
+
holdMs: HOLD_MS,
|
|
385
|
+
maxHoldMs: MAX_HOLD_MS,
|
|
348
386
|
...options.timing,
|
|
349
387
|
};
|
|
388
|
+
/** How long what an hour's bound refused is held back: the first time, and twice as long each time after. */
|
|
389
|
+
const heldFor = (before: { readonly pause: number } | undefined): number =>
|
|
390
|
+
before === undefined ? timing.holdMs : Math.min(before.pause * 2, timing.maxHoldMs);
|
|
350
391
|
const bounds = { outboxBytes: MAX_OUTBOX_BYTES, ...options.bounds };
|
|
351
392
|
|
|
352
393
|
// What keeps failing is said once, and again when what is said of it changes, so that an hour
|
|
@@ -396,7 +437,12 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
396
437
|
};
|
|
397
438
|
|
|
398
439
|
// What the runner holds.
|
|
440
|
+
/** The number of the last signal delivered, every one before it too: what is kept and said to the console. */
|
|
399
441
|
let delivered = 0;
|
|
442
|
+
/** The signals handed to the product that it has not taken yet, by number: not delivered, and not sent twice. */
|
|
443
|
+
const owed = new Set<number>();
|
|
444
|
+
/** The highest number of a signal the product took, or the record says was never read or let go. */
|
|
445
|
+
let settled = 0;
|
|
400
446
|
/** 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. */
|
|
401
447
|
let received = 0;
|
|
402
448
|
let handled = 0;
|
|
@@ -427,8 +473,10 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
427
473
|
/** The values of the account's store, by what the store said of them last. */
|
|
428
474
|
let secretsStamp: string | undefined;
|
|
429
475
|
let secretValues = new Map<string, string>();
|
|
430
|
-
let redact:
|
|
476
|
+
let redact: Redactor = redactorOf([]);
|
|
431
477
|
let tooOldSaid = false;
|
|
478
|
+
/** The console took as many wakes of this runner's as an hour takes: until when none is raised, and how long that was. */
|
|
479
|
+
let wakesHeld: { readonly until: number; readonly pause: number } | undefined;
|
|
432
480
|
/**
|
|
433
481
|
* The package the runner runs from, where it is another version than the runner's: the one
|
|
434
482
|
* last seen, and the one seen twice running, which the runner ends for.
|
|
@@ -436,6 +484,22 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
436
484
|
let seenVersion: string | undefined;
|
|
437
485
|
let seenAt = 0;
|
|
438
486
|
let updatedTo: string | undefined;
|
|
487
|
+
/**
|
|
488
|
+
* The desk's `runner.json`, where it is another than the one the runner was started with:
|
|
489
|
+
* how it was last seen, a file that reads or what is wrong with one that does not, and since
|
|
490
|
+
* when it is seen so; whether the runner ends for it; and what is wrong with it that the
|
|
491
|
+
* agent was told of.
|
|
492
|
+
*/
|
|
493
|
+
let sighted:
|
|
494
|
+
| { readonly what: "changed" | { readonly problem: string }; readonly at: number }
|
|
495
|
+
| undefined;
|
|
496
|
+
let reconfigure = false;
|
|
497
|
+
let toldOf: string | undefined;
|
|
498
|
+
/** How each wake source stands, by its name: what the heartbeat says of them. */
|
|
499
|
+
const sources = new Map<
|
|
500
|
+
string,
|
|
501
|
+
{ state: "connected" | "waiting" | "failing"; since: number; why: string | undefined }
|
|
502
|
+
>();
|
|
439
503
|
/**
|
|
440
504
|
* The signals a product was handed and never took, since it did not start or was not signed
|
|
441
505
|
* in, which are kept to be sent again; and, of those, the ones a reset gave one more try: a
|
|
@@ -569,11 +633,18 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
569
633
|
const codeOf = (error: unknown): string =>
|
|
570
634
|
error instanceof ApiError ? error.code : error instanceof Error ? error.name : "error";
|
|
571
635
|
|
|
572
|
-
/**
|
|
573
|
-
|
|
636
|
+
/**
|
|
637
|
+
* Sends what the product did, a batch at a time, the pictures first. What the console has
|
|
638
|
+
* already is left there. Nothing is sent while the console holds the session to its hour
|
|
639
|
+
* (ADR-0132), but at the session's end, which is `last`.
|
|
640
|
+
*/
|
|
641
|
+
const flush = async (target: OpenSession, last = false): Promise<void> => {
|
|
574
642
|
if (flushing) {
|
|
575
643
|
return;
|
|
576
644
|
}
|
|
645
|
+
if (!last && target.hold !== undefined && options.now() < target.hold.until) {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
577
648
|
flushing = true;
|
|
578
649
|
const about = `transcript ${target.id}`;
|
|
579
650
|
try {
|
|
@@ -623,6 +694,8 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
623
694
|
for (const event of target.outbox.splice(0, batch.length)) {
|
|
624
695
|
target.waiting -= event.held;
|
|
625
696
|
}
|
|
697
|
+
target.hold = undefined;
|
|
698
|
+
target.unsent = undefined;
|
|
626
699
|
sayOver(about, `the transcript of session ${target.id} is sent again`);
|
|
627
700
|
sayOver(`outbox ${target.id}`);
|
|
628
701
|
} catch (error) {
|
|
@@ -670,6 +743,22 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
670
743
|
target.waiting += only.held - before;
|
|
671
744
|
continue;
|
|
672
745
|
}
|
|
746
|
+
if (code === "transcript.too_many") {
|
|
747
|
+
// As many events as the console takes of a session within an hour: what waits is
|
|
748
|
+
// kept, within what the runner keeps, and sent again after a while, longer each
|
|
749
|
+
// time, so that the console is not asked every second for what it will refuse.
|
|
750
|
+
const pause = heldFor(target.hold);
|
|
751
|
+
target.hold = { until: options.now() + pause, pause };
|
|
752
|
+
target.unsent = code;
|
|
753
|
+
// Nothing is kept past the session's end: what is let go then is said there.
|
|
754
|
+
if (!last) {
|
|
755
|
+
sayOnce(
|
|
756
|
+
about,
|
|
757
|
+
`the console takes no more events of session ${target.id} within the hour (${code}); they are kept and sent again later`,
|
|
758
|
+
);
|
|
759
|
+
}
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
673
762
|
if (
|
|
674
763
|
code === "transcript.session_over" ||
|
|
675
764
|
code === "transcript.session_not_found" ||
|
|
@@ -685,8 +774,10 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
685
774
|
}
|
|
686
775
|
}
|
|
687
776
|
} catch (error) {
|
|
688
|
-
// Kept, and sent with the next batch. Said once for as long as it lasts, and when it is
|
|
689
|
-
|
|
777
|
+
// Kept, and sent with the next batch. Said once for as long as it lasts, and when it is
|
|
778
|
+
// over; at the session's end there is no next batch, and what is let go is said there.
|
|
779
|
+
target.unsent = codeOf(error);
|
|
780
|
+
if (!stopped && !last) {
|
|
690
781
|
sayOnce(
|
|
691
782
|
about,
|
|
692
783
|
`the transcript of session ${target.id} waits to be sent (${codeOf(error)})`,
|
|
@@ -759,7 +850,12 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
759
850
|
machine: options.machine,
|
|
760
851
|
});
|
|
761
852
|
} catch (error) {
|
|
762
|
-
|
|
853
|
+
const code = codeOf(error);
|
|
854
|
+
log(
|
|
855
|
+
code === "transcript.too_many_sessions"
|
|
856
|
+
? `the console begins no more sessions of this account within the hour (${code}); tried again after the cool-down`
|
|
857
|
+
: `a session could not be begun at the console (${code})`,
|
|
858
|
+
);
|
|
763
859
|
for (const path of handed.written) {
|
|
764
860
|
await options.files.remove(path).catch(() => undefined);
|
|
765
861
|
}
|
|
@@ -775,12 +871,18 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
775
871
|
effort: settings.effort,
|
|
776
872
|
resume,
|
|
777
873
|
permissions: config.permissions,
|
|
874
|
+
browser: config.browser,
|
|
875
|
+
// Whatever the driver shows a part of is cut once the secrets, as the store has them
|
|
876
|
+
// now, are out of it: no part of one stands where a text was cut.
|
|
877
|
+
cut: (text, most, more) => cutShown(redact, text, most, more),
|
|
878
|
+
cutEnd: (text, most, more) => cutShownEnd(redact, text, most, more),
|
|
778
879
|
}),
|
|
779
880
|
startedAt: options.now(),
|
|
780
881
|
first: true,
|
|
781
882
|
turn: false,
|
|
782
883
|
sent: [],
|
|
783
884
|
handed: [],
|
|
885
|
+
took: false,
|
|
784
886
|
n: 0,
|
|
785
887
|
outbox: [],
|
|
786
888
|
waiting: 0,
|
|
@@ -813,10 +915,28 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
813
915
|
await target.driver.stop().catch(() => undefined);
|
|
814
916
|
}
|
|
815
917
|
await target.pumped;
|
|
816
|
-
|
|
817
|
-
|
|
918
|
+
await hearLast(target);
|
|
919
|
+
// What the product was handed and never took is sent again, by the console where the
|
|
920
|
+
// runner itself ends and by the runner where the product had not started; else it is on
|
|
921
|
+
// the record as never read.
|
|
922
|
+
await leave(target, stopped ? "after" : already || target.took ? undefined : "next");
|
|
818
923
|
record(target, "status", `The session ended: ${how}.`, { ended: how });
|
|
819
|
-
await flush(target);
|
|
924
|
+
await flush(target, true);
|
|
925
|
+
// What the console did not take by now goes with the session: nothing of it is sent
|
|
926
|
+
// later, and the runner's line says how many, where an earlier one said they were kept.
|
|
927
|
+
const unsent = target.outbox.length;
|
|
928
|
+
if (unsent > 0) {
|
|
929
|
+
const one = unsent === 1;
|
|
930
|
+
log(
|
|
931
|
+
`${unsent} ${one ? "event" : "events"} of session ${target.id} ${one ? "was" : "were"} let go unsent when it ended: ${
|
|
932
|
+
target.unsent === "transcript.too_many"
|
|
933
|
+
? `the console takes no more of it within the hour (${target.unsent})`
|
|
934
|
+
: `the console did not take ${one ? "it" : "them"} (${target.unsent ?? "error"})`
|
|
935
|
+
}`,
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
saidOf.delete(`transcript ${target.id}`);
|
|
939
|
+
saidOf.delete(`outbox ${target.id}`);
|
|
820
940
|
try {
|
|
821
941
|
await client.endAgentSession(target.id, { how });
|
|
822
942
|
} catch (error) {
|
|
@@ -1018,26 +1138,136 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1018
1138
|
if (waited) {
|
|
1019
1139
|
write();
|
|
1020
1140
|
}
|
|
1021
|
-
target.handed.push({ written: waited, write });
|
|
1141
|
+
target.handed.push({ written: waited, write, signals: batch });
|
|
1022
1142
|
target.turn = true;
|
|
1023
1143
|
// Everything handed over since the agent was last done: what a product that took nothing is sent again.
|
|
1024
1144
|
target.sent = [...target.sent, ...batch];
|
|
1025
|
-
|
|
1026
|
-
|
|
1145
|
+
// Handed over, and not delivered until the product says it took it: a product that did
|
|
1146
|
+
// not start took nothing, and a runner that ends then is sent it again when it is back.
|
|
1147
|
+
for (const signal of batch) {
|
|
1148
|
+
owed.add(signal.number);
|
|
1149
|
+
}
|
|
1150
|
+
await account();
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
/** Counts signals as delivered: the product took them, or the record says what became of them. */
|
|
1154
|
+
const count = async (signals: readonly RestSignal[]): Promise<void> => {
|
|
1155
|
+
for (const signal of signals) {
|
|
1156
|
+
owed.delete(signal.number);
|
|
1157
|
+
settled = Math.max(settled, signal.number);
|
|
1158
|
+
}
|
|
1027
1159
|
await account();
|
|
1028
1160
|
};
|
|
1029
1161
|
|
|
1030
1162
|
/**
|
|
1031
|
-
*
|
|
1032
|
-
*
|
|
1033
|
-
* over or the agent cannot go on.
|
|
1163
|
+
* The product took the oldest message it was handed: on the record now, where it was not
|
|
1164
|
+
* written at once, and delivered.
|
|
1034
1165
|
*/
|
|
1035
|
-
const
|
|
1166
|
+
const take = async (target: OpenSession): Promise<void> => {
|
|
1167
|
+
target.took = true;
|
|
1168
|
+
const message = target.handed.shift();
|
|
1169
|
+
if (message !== undefined) {
|
|
1170
|
+
if (!message.written) {
|
|
1171
|
+
message.write();
|
|
1172
|
+
}
|
|
1173
|
+
await count(message.signals);
|
|
1174
|
+
}
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* The agent is done with what it was sent: what the product was handed and did not say it
|
|
1179
|
+
* took is taken, on the record where the record does not hold it yet, and delivered.
|
|
1180
|
+
*/
|
|
1181
|
+
const settle = async (target: OpenSession): Promise<void> => {
|
|
1182
|
+
target.took = true;
|
|
1183
|
+
const counted: RestSignal[] = [];
|
|
1036
1184
|
for (const message of target.handed.splice(0)) {
|
|
1037
1185
|
if (!message.written) {
|
|
1038
|
-
message.write(
|
|
1186
|
+
message.write();
|
|
1039
1187
|
}
|
|
1188
|
+
counted.push(...message.signals);
|
|
1040
1189
|
}
|
|
1190
|
+
await count(counted);
|
|
1191
|
+
};
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Hears what the product said as its session was ended. Its words wait in the queue behind
|
|
1195
|
+
* whatever ended the session, and are let go there once the session is no longer the open
|
|
1196
|
+
* one: a message it said it took then is taken, and not sent again, and the conversation it
|
|
1197
|
+
* named is the one to go on with, where that message is.
|
|
1198
|
+
*/
|
|
1199
|
+
const hearLast = async (target: OpenSession): Promise<void> => {
|
|
1200
|
+
let named = false;
|
|
1201
|
+
for (const message of queue) {
|
|
1202
|
+
if (message.t !== "driver" || message.session !== target) {
|
|
1203
|
+
continue;
|
|
1204
|
+
}
|
|
1205
|
+
const { event } = message;
|
|
1206
|
+
if (event.type === "conversation") {
|
|
1207
|
+
conversation = event.id;
|
|
1208
|
+
named = true;
|
|
1209
|
+
} else if (event.type === "taken") {
|
|
1210
|
+
await take(target);
|
|
1211
|
+
} else if (event.type === "turn_completed") {
|
|
1212
|
+
await settle(target);
|
|
1213
|
+
record(target, "status", "The turn completed.", { turn: "completed" });
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
if (named) {
|
|
1217
|
+
await persist();
|
|
1218
|
+
}
|
|
1219
|
+
};
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* What becomes of what the product was handed and never took, as its session ends
|
|
1223
|
+
* (ADR-0131). Sent again, it is not delivered, and the record holds nothing more of it than
|
|
1224
|
+
* a line that says so: by the console to the runner started `after` this one, where the
|
|
1225
|
+
* runner itself ends; by this runner in the `next` session, where the product had taken
|
|
1226
|
+
* nothing of this one, and so had not started. Else it is let go: on the record as never
|
|
1227
|
+
* read, which delivers it; what the record holds since it was handed over, to a product that
|
|
1228
|
+
* waited for a message, is said in a line not to have been taken.
|
|
1229
|
+
*/
|
|
1230
|
+
const leave = async (target: OpenSession, again?: "after" | "next"): Promise<void> => {
|
|
1231
|
+
const messages = target.handed.splice(0);
|
|
1232
|
+
const signals = messages.flatMap((message) => message.signals);
|
|
1233
|
+
if (signals.length === 0) {
|
|
1234
|
+
return;
|
|
1235
|
+
}
|
|
1236
|
+
const numbersOf = (some: readonly RestSignal[]): string =>
|
|
1237
|
+
some.map((signal) => `#${signal.number}`).join(", ");
|
|
1238
|
+
if (again !== undefined) {
|
|
1239
|
+
const numbers = numbersOf(signals);
|
|
1240
|
+
record(
|
|
1241
|
+
target,
|
|
1242
|
+
"status",
|
|
1243
|
+
`The session ended before the product took what it was sent: ${numbers}. It is sent again.`,
|
|
1244
|
+
);
|
|
1245
|
+
log(`${numbers} not taken when session ${target.id} ended: sent again`);
|
|
1246
|
+
if (again === "next") {
|
|
1247
|
+
for (const signal of signals) {
|
|
1248
|
+
// Waits to be handed over again: owed no word of the product's, and not delivered.
|
|
1249
|
+
owed.delete(signal.number);
|
|
1250
|
+
sentBefore.add(signal.number);
|
|
1251
|
+
}
|
|
1252
|
+
pending = [...signals, ...pending];
|
|
1253
|
+
}
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
const written = messages.filter((message) => message.written).flatMap((one) => one.signals);
|
|
1257
|
+
if (written.length > 0) {
|
|
1258
|
+
record(
|
|
1259
|
+
target,
|
|
1260
|
+
"status",
|
|
1261
|
+
`The session ended before the product took what it was sent: ${numbersOf(written)}. Whoever sent it says it again where it still matters.`,
|
|
1262
|
+
);
|
|
1263
|
+
}
|
|
1264
|
+
for (const message of messages) {
|
|
1265
|
+
if (!message.written) {
|
|
1266
|
+
message.write(true);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
// On the record as never read: delivered.
|
|
1270
|
+
await count(signals);
|
|
1041
1271
|
};
|
|
1042
1272
|
|
|
1043
1273
|
/**
|
|
@@ -1062,13 +1292,24 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1062
1292
|
};
|
|
1063
1293
|
|
|
1064
1294
|
/**
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1295
|
+
* Counts what is delivered: signals in order, up to the last one the product took, the record
|
|
1296
|
+
* says was never read or let go, or the runner acted on itself, a stop or a choice of model
|
|
1297
|
+
* say, and never past one that still waits to be handed to the product or that the product
|
|
1298
|
+
* has not said it took.
|
|
1067
1299
|
*/
|
|
1068
1300
|
const account = async (signal?: RestSignal): Promise<void> => {
|
|
1069
1301
|
acted = Math.max(acted, signal?.number ?? 0);
|
|
1070
|
-
|
|
1071
|
-
|
|
1302
|
+
const most = Math.max(settled, acted);
|
|
1303
|
+
let least = Number.POSITIVE_INFINITY;
|
|
1304
|
+
for (const kept of pending) {
|
|
1305
|
+
least = Math.min(least, kept.number);
|
|
1306
|
+
}
|
|
1307
|
+
for (const number of owed) {
|
|
1308
|
+
least = Math.min(least, number);
|
|
1309
|
+
}
|
|
1310
|
+
const next = Math.min(most, least - 1);
|
|
1311
|
+
if (next > delivered) {
|
|
1312
|
+
delivered = next;
|
|
1072
1313
|
await persist();
|
|
1073
1314
|
}
|
|
1074
1315
|
};
|
|
@@ -1082,7 +1323,11 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1082
1323
|
|
|
1083
1324
|
const onSignal = async (signal: RestSignal): Promise<void> => {
|
|
1084
1325
|
handled = Math.max(handled, signal.number);
|
|
1085
|
-
if (
|
|
1326
|
+
if (
|
|
1327
|
+
signal.number <= delivered ||
|
|
1328
|
+
owed.has(signal.number) ||
|
|
1329
|
+
pending.some((kept) => kept.number === signal.number)
|
|
1330
|
+
) {
|
|
1086
1331
|
return;
|
|
1087
1332
|
}
|
|
1088
1333
|
const by = signal.by?.name ?? signal.by?.login ?? "a supervisor";
|
|
@@ -1090,8 +1335,9 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1090
1335
|
case "stop": {
|
|
1091
1336
|
held = true;
|
|
1092
1337
|
if (session !== undefined) {
|
|
1093
|
-
// What the product had not taken is on the record before the stop that leaves it
|
|
1094
|
-
|
|
1338
|
+
// What the product had not taken is on the record before the stop that leaves it
|
|
1339
|
+
// unread; what a product that had not started was handed waits for the restart.
|
|
1340
|
+
await leave(session, session.took ? undefined : "next");
|
|
1095
1341
|
record(session, "person", signal.text, signalData(signal));
|
|
1096
1342
|
}
|
|
1097
1343
|
await end("stopped");
|
|
@@ -1212,16 +1458,12 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1212
1458
|
return;
|
|
1213
1459
|
}
|
|
1214
1460
|
case "taken": {
|
|
1215
|
-
|
|
1216
|
-
const message = target.handed.shift();
|
|
1217
|
-
if (message !== undefined && !message.written) {
|
|
1218
|
-
message.write();
|
|
1219
|
-
}
|
|
1461
|
+
await take(target);
|
|
1220
1462
|
return;
|
|
1221
1463
|
}
|
|
1222
1464
|
case "turn_completed": {
|
|
1223
1465
|
// The agent is done with everything it was sent: what a product did not say it took is taken.
|
|
1224
|
-
settle(target);
|
|
1466
|
+
await settle(target);
|
|
1225
1467
|
// The record says where a turn ends, so that whoever reads it live knows the agent is done.
|
|
1226
1468
|
record(target, "status", "The turn completed.", { turn: "completed" });
|
|
1227
1469
|
target.turn = false;
|
|
@@ -1274,10 +1516,14 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1274
1516
|
}
|
|
1275
1517
|
for (const signal of again) {
|
|
1276
1518
|
sentBefore.add(signal.number);
|
|
1519
|
+
// Waits to be handed over again: owed no word of the product's, and not delivered.
|
|
1520
|
+
owed.delete(signal.number);
|
|
1277
1521
|
}
|
|
1278
1522
|
pending = [...again, ...pending];
|
|
1279
1523
|
// Sent again, and on the record when it is taken then.
|
|
1280
1524
|
target.handed = [];
|
|
1525
|
+
// What was let go is on the record as that, and is delivered: it is sent no more.
|
|
1526
|
+
await count(gone);
|
|
1281
1527
|
}
|
|
1282
1528
|
target.sent = [];
|
|
1283
1529
|
waits = cooled(waits);
|
|
@@ -1318,6 +1564,57 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1318
1564
|
resume: driver.can.resume,
|
|
1319
1565
|
});
|
|
1320
1566
|
|
|
1567
|
+
/**
|
|
1568
|
+
* Says something of the runner's own to the agent, in the open session, under a header that
|
|
1569
|
+
* carries the session's mark: read after the tool call under way. The agent has a turn's work
|
|
1570
|
+
* in it, so it is counted as a turn, and what the runner does between two turns, an update or
|
|
1571
|
+
* a `runner.json` taken, waits for that turn to end. What the product says it took then is
|
|
1572
|
+
* this message, which the record holds nothing of, and not the message of a signal that waits
|
|
1573
|
+
* behind it. Whether it was said.
|
|
1574
|
+
*/
|
|
1575
|
+
const sayToAgent = async (target: OpenSession, words: string): Promise<boolean> => {
|
|
1576
|
+
try {
|
|
1577
|
+
await target.driver.send({
|
|
1578
|
+
text: `[console ${target.mark} · runner]\n${words}`,
|
|
1579
|
+
images: [],
|
|
1580
|
+
priority: "next",
|
|
1581
|
+
});
|
|
1582
|
+
target.turn = true;
|
|
1583
|
+
target.handed.push({ written: true, write: () => undefined, signals: [] });
|
|
1584
|
+
return true;
|
|
1585
|
+
} catch {
|
|
1586
|
+
return false;
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
|
|
1590
|
+
/** The wake sources as the console is told of them: each by its name, how it stands, since when and why. */
|
|
1591
|
+
const sourcesOf = () =>
|
|
1592
|
+
[...sources].map(([name, one]) => {
|
|
1593
|
+
const why = lineOf(one.why);
|
|
1594
|
+
return {
|
|
1595
|
+
name,
|
|
1596
|
+
state: one.state,
|
|
1597
|
+
since: new Date(one.since).toISOString(),
|
|
1598
|
+
...(why === null ? {} : { why }),
|
|
1599
|
+
};
|
|
1600
|
+
});
|
|
1601
|
+
|
|
1602
|
+
/** Notes how a wake source stands, and has the console told at once where that is news. */
|
|
1603
|
+
const sourceStands = (
|
|
1604
|
+
name: string,
|
|
1605
|
+
state: "connected" | "waiting" | "failing",
|
|
1606
|
+
why?: string,
|
|
1607
|
+
): void => {
|
|
1608
|
+
const before = sources.get(name);
|
|
1609
|
+
if (before?.state === state && before.why === why) {
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
sources.set(name, { state, since: options.now(), why });
|
|
1613
|
+
if (!stopped) {
|
|
1614
|
+
push({ t: "heartbeat" });
|
|
1615
|
+
}
|
|
1616
|
+
};
|
|
1617
|
+
|
|
1321
1618
|
const beat = async (): Promise<void> => {
|
|
1322
1619
|
const now = `${stands.state} ${stands.reason} ${session?.id ?? ""}`;
|
|
1323
1620
|
said = now;
|
|
@@ -1337,6 +1634,7 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1337
1634
|
model: choiceOf(session?.running.model),
|
|
1338
1635
|
effort: choiceOf(session?.running.effort),
|
|
1339
1636
|
},
|
|
1637
|
+
sources: sourcesOf(),
|
|
1340
1638
|
});
|
|
1341
1639
|
settings = answer.settings;
|
|
1342
1640
|
tooOldSaid = false;
|
|
@@ -1368,21 +1666,12 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1368
1666
|
install === undefined
|
|
1369
1667
|
? ""
|
|
1370
1668
|
: ` Update it: ${install}\nThe runner sees the update and is started again with it by itself, once no turn is under way.`;
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
// The agent has a turn's work in it, the install among it: counted as a turn, so
|
|
1378
|
-
// that the update it makes is taken when that turn ends and never inside it. What
|
|
1379
|
-
// the product says it took then is this message, which the record holds nothing
|
|
1380
|
-
// of, and not the message of a signal that waits behind it.
|
|
1381
|
-
target.turn = true;
|
|
1382
|
-
target.handed.push({ written: true, write: () => undefined });
|
|
1383
|
-
} catch {
|
|
1384
|
-
// Not told: the runner's own line above says it to whoever reads its output.
|
|
1385
|
-
}
|
|
1669
|
+
// Not told where it could not be: the runner's own line above says it to whoever
|
|
1670
|
+
// reads its output.
|
|
1671
|
+
await sayToAgent(
|
|
1672
|
+
target,
|
|
1673
|
+
`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.`,
|
|
1674
|
+
);
|
|
1386
1675
|
}
|
|
1387
1676
|
}
|
|
1388
1677
|
return;
|
|
@@ -1422,6 +1711,71 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1422
1711
|
);
|
|
1423
1712
|
};
|
|
1424
1713
|
|
|
1714
|
+
/**
|
|
1715
|
+
* Looks whether the desk's `runner.json` is another than the one the runner was started with
|
|
1716
|
+
* (ADR-0144). How it stands is taken once it was seen the same way twice, a heartbeat's
|
|
1717
|
+
* interval apart, so that a file being written is not read halfway. One that reads has the
|
|
1718
|
+
* runner end between two turns, for whoever started it to start the next with the file as it
|
|
1719
|
+
* is; the look goes on until then, and a file put back, or one that stopped reading, ends
|
|
1720
|
+
* nothing. One that does not read changes nothing: the runner goes on with what it has, and
|
|
1721
|
+
* the agent, whose file it is, is told what is wrong with it, once for each thing that is,
|
|
1722
|
+
* in the session that is open or in the next one.
|
|
1723
|
+
*/
|
|
1724
|
+
const lookForChange = async (): Promise<void> => {
|
|
1725
|
+
if (options.reconfigured === undefined) {
|
|
1726
|
+
return;
|
|
1727
|
+
}
|
|
1728
|
+
const now = await options.reconfigured().catch(() => "same" as const);
|
|
1729
|
+
if (now === "same") {
|
|
1730
|
+
if (reconfigure) {
|
|
1731
|
+
log("runner.json is as the runner was started with it again: the runner goes on");
|
|
1732
|
+
}
|
|
1733
|
+
sighted = undefined;
|
|
1734
|
+
reconfigure = false;
|
|
1735
|
+
toldOf = undefined;
|
|
1736
|
+
sayOver("config", "runner.json is as the runner was started with it again");
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
const same =
|
|
1740
|
+
sighted !== undefined &&
|
|
1741
|
+
(now === "changed"
|
|
1742
|
+
? sighted.what === "changed"
|
|
1743
|
+
: sighted.what !== "changed" && sighted.what.problem === now.problem);
|
|
1744
|
+
if (!same) {
|
|
1745
|
+
// Another state than the one before: counted from now, and nothing ends for the old one.
|
|
1746
|
+
sighted = { what: now, at: options.now() };
|
|
1747
|
+
reconfigure = false;
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
const since = sighted?.at ?? options.now();
|
|
1751
|
+
if (options.now() - since < timing.heartbeatMs - Math.min(1000, timing.heartbeatMs / 2)) {
|
|
1752
|
+
return;
|
|
1753
|
+
}
|
|
1754
|
+
if (now === "changed") {
|
|
1755
|
+
if (!reconfigure) {
|
|
1756
|
+
reconfigure = true;
|
|
1757
|
+
log(
|
|
1758
|
+
"runner.json changed since the runner started: the runner ends once no turn is under way, and starts again with it",
|
|
1759
|
+
);
|
|
1760
|
+
}
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
sayOnce(
|
|
1764
|
+
"config",
|
|
1765
|
+
`${now.problem}: the runner goes on with the runner.json it was started with`,
|
|
1766
|
+
);
|
|
1767
|
+
// Told once it can be: a session that opens later is told then.
|
|
1768
|
+
if (toldOf !== now.problem && session !== undefined && !session.first) {
|
|
1769
|
+
const told = await sayToAgent(
|
|
1770
|
+
session,
|
|
1771
|
+
`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.`,
|
|
1772
|
+
);
|
|
1773
|
+
if (told) {
|
|
1774
|
+
toldOf = now.problem;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1425
1779
|
/** Waits so long, or until the runner stops. */
|
|
1426
1780
|
const pause = (ms: number, signal: AbortSignal = abort.signal): Promise<void> =>
|
|
1427
1781
|
new Promise<void>((resolve) => {
|
|
@@ -1453,21 +1807,52 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1453
1807
|
const host: WakeHost = {
|
|
1454
1808
|
secret: async (name) => secretValues.get(name),
|
|
1455
1809
|
raise: async (raised) => {
|
|
1456
|
-
|
|
1810
|
+
// The console takes so many wakes a runner raises itself within an hour (ADR-0132):
|
|
1811
|
+
// past that, what the sources raise is let go for a while, longer each time, and said
|
|
1812
|
+
// once, so that a source that repeats itself costs the console nothing more.
|
|
1813
|
+
if (wakesHeld !== undefined && options.now() < wakesHeld.until) {
|
|
1814
|
+
return;
|
|
1815
|
+
}
|
|
1816
|
+
try {
|
|
1817
|
+
await client.raiseWake({ source: "messenger", key: raised.key, text: raised.text });
|
|
1818
|
+
} catch (error) {
|
|
1819
|
+
if (codeOf(error) !== "signal.too_many") {
|
|
1820
|
+
throw error;
|
|
1821
|
+
}
|
|
1822
|
+
const pause = heldFor(wakesHeld);
|
|
1823
|
+
wakesHeld = { until: options.now() + pause, pause };
|
|
1824
|
+
sayOnce(
|
|
1825
|
+
"wakes",
|
|
1826
|
+
"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",
|
|
1827
|
+
);
|
|
1828
|
+
return;
|
|
1829
|
+
}
|
|
1830
|
+
if (wakesHeld !== undefined) {
|
|
1831
|
+
wakesHeld = undefined;
|
|
1832
|
+
sayOver("wakes", "the console takes the wakes of this runner's wake sources again");
|
|
1833
|
+
}
|
|
1457
1834
|
},
|
|
1458
1835
|
log,
|
|
1836
|
+
stands: (state, why) => sourceStands(source.name, state, why),
|
|
1459
1837
|
fetch: wakes.fetch,
|
|
1460
1838
|
socket: wakes.socket,
|
|
1461
1839
|
wait: pause,
|
|
1462
1840
|
};
|
|
1841
|
+
sourceStands(source.name, "waiting");
|
|
1463
1842
|
let wait = timing.reconnectMs;
|
|
1464
1843
|
while (!stopped) {
|
|
1465
1844
|
const began = options.now();
|
|
1466
1845
|
try {
|
|
1467
1846
|
await source.run(host, abort.signal);
|
|
1847
|
+
// Ended with no error, a connection the other side closed say: it listens no more
|
|
1848
|
+
// until it says so again. What it said of why it waits stands.
|
|
1849
|
+
if (!stopped && sources.get(source.name)?.state === "connected") {
|
|
1850
|
+
sourceStands(source.name, "waiting");
|
|
1851
|
+
}
|
|
1468
1852
|
} catch (error) {
|
|
1469
1853
|
if (!stopped) {
|
|
1470
1854
|
log(`the wake source ${source.name} ended (${codeOf(error)}); started again`);
|
|
1855
|
+
sourceStands(source.name, "failing", codeOf(error));
|
|
1471
1856
|
}
|
|
1472
1857
|
}
|
|
1473
1858
|
wait =
|
|
@@ -1571,17 +1956,26 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1571
1956
|
log(
|
|
1572
1957
|
`the runner is there: ${driver.product.name} ${probe.version ?? "of a version it did not say"}, signals after #${delivered}`,
|
|
1573
1958
|
);
|
|
1959
|
+
if (probe.version === undefined) {
|
|
1960
|
+
// Said before a session fails on it: asked for its version, the product's command did not answer.
|
|
1961
|
+
log(
|
|
1962
|
+
`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`,
|
|
1963
|
+
);
|
|
1964
|
+
}
|
|
1574
1965
|
let how: RunnerEnd = "stopped";
|
|
1575
1966
|
try {
|
|
1576
1967
|
for (;;) {
|
|
1577
|
-
// An update is taken between two turns, and at once where none is under way
|
|
1578
|
-
|
|
1579
|
-
|
|
1968
|
+
// An update is taken between two turns, and at once where none is under way; so is
|
|
1969
|
+
// a runner.json that changed.
|
|
1970
|
+
if ((updatedTo !== undefined || reconfigure) && session?.turn !== true) {
|
|
1971
|
+
how = updatedTo !== undefined ? "updated" : "changed";
|
|
1580
1972
|
if (session !== undefined) {
|
|
1581
1973
|
record(
|
|
1582
1974
|
session,
|
|
1583
1975
|
"status",
|
|
1584
|
-
|
|
1976
|
+
updatedTo !== undefined
|
|
1977
|
+
? `The command the runner runs from was updated, from ${options.version} to ${updatedTo}: the runner ends, to be started again with it.`
|
|
1978
|
+
: "The desk's runner.json changed: the runner ends, and starts again with it.",
|
|
1585
1979
|
);
|
|
1586
1980
|
}
|
|
1587
1981
|
break;
|
|
@@ -1606,6 +2000,7 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1606
2000
|
}
|
|
1607
2001
|
} else {
|
|
1608
2002
|
await lookForUpdate();
|
|
2003
|
+
await lookForChange();
|
|
1609
2004
|
// Said every thirty seconds, and at once when how the agent stands changed.
|
|
1610
2005
|
const changed = said !== `${stands.state} ${stands.reason} ${session?.id ?? ""}`;
|
|
1611
2006
|
if (changed || !queue.some((queued) => queued.t === "heartbeat")) {
|
|
@@ -1626,11 +2021,17 @@ export function createRunner(options: RunnerOptions): Runner {
|
|
|
1626
2021
|
}
|
|
1627
2022
|
// A session ended for an update goes on, in the runner started after, as one a
|
|
1628
2023
|
// supervisor restarted does: with the same conversation.
|
|
1629
|
-
await end(how === "
|
|
2024
|
+
await end(how === "stopped" ? "exited" : "restarted");
|
|
1630
2025
|
abort.abort();
|
|
1631
2026
|
await listening;
|
|
1632
2027
|
await Promise.all(sourcing);
|
|
1633
|
-
log(
|
|
2028
|
+
log(
|
|
2029
|
+
how === "updated"
|
|
2030
|
+
? "the runner ended, for the update"
|
|
2031
|
+
: how === "changed"
|
|
2032
|
+
? "the runner ended, for its runner.json"
|
|
2033
|
+
: "the runner stopped",
|
|
2034
|
+
);
|
|
1634
2035
|
}
|
|
1635
2036
|
return how;
|
|
1636
2037
|
},
|