@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
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState, } from "react";
|
|
3
3
|
import { MAX_FILE_BYTES, MAX_SIGNAL_ATTACHMENTS, MAX_SIGNAL_LENGTH, } from "../api.js";
|
|
4
|
+
import { today } from "../dates.js";
|
|
4
5
|
import { useWords } from "../i18n/index.js";
|
|
5
6
|
import { isPicture } from "./files.js";
|
|
7
|
+
import { Markdown } from "./markdown.js";
|
|
6
8
|
import { Lightbox, PictureThumb, usePicture } from "./pictures.js";
|
|
7
9
|
import { Avatar, Badge, Button, Callout, cx, formatBytes, personName, Time } from "./ui.js";
|
|
8
10
|
// The parts of an agent account's page (ADR-0085, ADR-0086): how it stands, what it is doing as
|
|
9
11
|
// it happens, read as a conversation in a pane that follows its end, what a supervisor says to
|
|
10
12
|
// it, shown as waiting until the agent takes it, what changes how it stands, its sessions, and
|
|
11
|
-
// what its runner said of itself.
|
|
12
|
-
//
|
|
13
|
-
//
|
|
13
|
+
// what its runner said of itself. What the agent said is read as Markdown, rendered to elements
|
|
14
|
+
// and never to HTML, with no picture fetched from elsewhere; everything else its product printed,
|
|
15
|
+
// a thought, a tool's call and its answer, a note, is shown as text, in a block that keeps its
|
|
16
|
+
// spaces and its lines (ADR-0141). What a sub-agent did is read under the call that started it.
|
|
17
|
+
// A picture of the session is shown by its address at the console, and any other file is offered
|
|
18
|
+
// to save.
|
|
14
19
|
/** How an agent stands, in a word, with the tone of it. */
|
|
15
20
|
const STATE_TONES = {
|
|
16
21
|
running: "success",
|
|
@@ -38,120 +43,310 @@ export function AgentStateBadge(props) {
|
|
|
38
43
|
}
|
|
39
44
|
/** What a runner says of an event that is said apart from the rest: the tool it names. */
|
|
40
45
|
const TOOL = "tool";
|
|
46
|
+
/** The most characters of a sub-agent's name that a label shows. */
|
|
47
|
+
const MAX_SUBAGENT_LABEL = 40;
|
|
48
|
+
/** The most characters of a sub-agent's name that its own row shows: what a runner writes of one. */
|
|
49
|
+
const MAX_SUBAGENT_NAME = 80;
|
|
50
|
+
/** The call an event names as the one that started the sub-agent it is of, or nothing. */
|
|
51
|
+
const parentOf = (event) => {
|
|
52
|
+
const parent = event?.data.parent;
|
|
53
|
+
return typeof parent === "string" && parent.length > 0 ? parent : undefined;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Whose an event is, where a sub-agent made it (ADR-0131): what the call that started the
|
|
57
|
+
* sub-agent called it, an empty name where the runner knew only that call, and nothing for an
|
|
58
|
+
* event of the session's own, which is every event of a runner that does not say.
|
|
59
|
+
*/
|
|
60
|
+
export function subagentOf(event) {
|
|
61
|
+
if (parentOf(event) === undefined) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const name = event?.data.subagent;
|
|
65
|
+
return typeof name === "string" ? name.trim().slice(0, MAX_SUBAGENT_LABEL) : "";
|
|
66
|
+
}
|
|
41
67
|
const idOf = (event) => {
|
|
42
68
|
const id = event.data.id;
|
|
43
69
|
return typeof id === "string" && id.length > 0 ? id : undefined;
|
|
44
70
|
};
|
|
71
|
+
/** Whether an event is where a turn ended, or the session did: the record's own word for it. */
|
|
72
|
+
const endsTurn = (event) => event.kind === "status" &&
|
|
73
|
+
event.sealed === null &&
|
|
74
|
+
(event.data.turn === "completed" || typeof event.data.ended === "string");
|
|
45
75
|
/**
|
|
46
76
|
* The events of a session as the things a person reads, in order. A tool's call, what it
|
|
47
77
|
* answered and what was asked before it ran are one thing, joined by the id the product gave
|
|
48
78
|
* them; a call under an id whose call is done is another call, as an agent that numbers its
|
|
49
79
|
* calls anew at every turn has it. What carries no id joins the call before it that waits.
|
|
80
|
+
*
|
|
81
|
+
* What a sub-agent did is read under the call that started it (ADR-0141): an event that names a
|
|
82
|
+
* call the session holds as its parent is a step of that call, in a line of the call's own, and
|
|
83
|
+
* not a thing of the line the call stands in. A call that says it starts a sub-agent (`starts`)
|
|
84
|
+
* has such a line from the first, empty; one a runner of before wrote has it from the first
|
|
85
|
+
* event that names it. An event that names a call the events do not hold stays where it stood.
|
|
86
|
+
* A turn or a session that ended ends every sub-agent still open in it.
|
|
50
87
|
*/
|
|
51
88
|
export function talkOf(events) {
|
|
52
|
-
const
|
|
53
|
-
/** The tool things by the id they are open under
|
|
89
|
+
const top = [];
|
|
90
|
+
/** The tool things that still wait for something, by the id they are open under. */
|
|
54
91
|
const open = new Map();
|
|
55
|
-
|
|
56
|
-
|
|
92
|
+
/** The last call under each id, done or not: what a sub-agent's event names as its parent. */
|
|
93
|
+
const calls = new Map();
|
|
94
|
+
/** The line of each sub-agent, by the id of the call that started it. */
|
|
95
|
+
const lines = new Map();
|
|
96
|
+
/** The calls that started a sub-agent and were not answered, as far as the events read say. */
|
|
97
|
+
let running = [];
|
|
98
|
+
const toolAt = (place) => {
|
|
99
|
+
const item = place === undefined ? undefined : place.line[place.at];
|
|
57
100
|
return item !== undefined && item.type === "tool" ? item : undefined;
|
|
58
101
|
};
|
|
59
|
-
/** The last tool thing that still waits for
|
|
60
|
-
const waiting = (
|
|
61
|
-
for (let at =
|
|
62
|
-
const item =
|
|
102
|
+
/** The last tool thing of a line that still waits for an answer, where nothing names an id. */
|
|
103
|
+
const waiting = (line) => {
|
|
104
|
+
for (let at = line.length - 1; at >= 0; at -= 1) {
|
|
105
|
+
const item = line[at];
|
|
63
106
|
if (item === undefined || item.type !== "tool") {
|
|
64
107
|
return undefined;
|
|
65
108
|
}
|
|
66
|
-
if (item
|
|
67
|
-
return at;
|
|
109
|
+
if (item.result === undefined) {
|
|
110
|
+
return { line, at };
|
|
68
111
|
}
|
|
69
112
|
}
|
|
70
113
|
return undefined;
|
|
71
114
|
};
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
115
|
+
const set = (place, tool) => {
|
|
116
|
+
place.line[place.at] = tool;
|
|
117
|
+
};
|
|
118
|
+
const push = (line, tool) => {
|
|
119
|
+
line.push(tool);
|
|
120
|
+
return { line, at: line.length - 1 };
|
|
121
|
+
};
|
|
122
|
+
/** The line of the sub-agent a call started, begun where it has none yet. */
|
|
123
|
+
const lineOf = (id, place) => {
|
|
124
|
+
const begun = lines.get(id);
|
|
125
|
+
if (begun !== undefined) {
|
|
126
|
+
return begun;
|
|
78
127
|
}
|
|
79
|
-
|
|
80
|
-
|
|
128
|
+
const line = [];
|
|
129
|
+
lines.set(id, line);
|
|
130
|
+
const tool = toolAt(place);
|
|
131
|
+
if (tool !== undefined) {
|
|
132
|
+
set(place, { ...tool, steps: line });
|
|
133
|
+
running.push(place);
|
|
81
134
|
}
|
|
135
|
+
return line;
|
|
82
136
|
};
|
|
83
137
|
for (const event of events) {
|
|
138
|
+
// Whose line the event is of: the sub-agent's whose call it names, where the session holds
|
|
139
|
+
// that call, and the session's own otherwise.
|
|
140
|
+
const parent = parentOf(event);
|
|
141
|
+
const starter = parent === undefined ? undefined : calls.get(parent);
|
|
142
|
+
const line = parent === undefined || starter === undefined ? top : lineOf(parent, starter);
|
|
84
143
|
// A sealed event says who sealed it and why, wherever it stood.
|
|
85
144
|
if (event.sealed !== null) {
|
|
86
|
-
|
|
145
|
+
line.push({ type: "note", event });
|
|
87
146
|
continue;
|
|
88
147
|
}
|
|
89
148
|
if (event.kind === "person") {
|
|
90
|
-
|
|
149
|
+
line.push({ type: "told", event });
|
|
91
150
|
}
|
|
92
151
|
else if (event.kind === "wake") {
|
|
93
|
-
|
|
152
|
+
line.push({ type: "wake", event });
|
|
94
153
|
}
|
|
95
154
|
else if (event.kind === "assistant") {
|
|
96
|
-
|
|
155
|
+
line.push({ type: "said", event });
|
|
97
156
|
}
|
|
98
157
|
else if (event.kind === "thinking") {
|
|
99
|
-
|
|
158
|
+
line.push({ type: "thought", event });
|
|
100
159
|
}
|
|
101
160
|
else if (event.kind === "tool_call") {
|
|
102
161
|
const id = idOf(event);
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
162
|
+
const held = id === undefined ? undefined : open.get(id);
|
|
163
|
+
const asked = toolAt(held);
|
|
164
|
+
let place;
|
|
165
|
+
if (held !== undefined && asked !== undefined && asked.call === undefined) {
|
|
166
|
+
set(held, { ...asked, call: event });
|
|
167
|
+
place = held;
|
|
107
168
|
}
|
|
108
169
|
else {
|
|
109
|
-
|
|
170
|
+
place = push(line, { type: "tool", call: event, result: undefined, permission: undefined });
|
|
171
|
+
if (id !== undefined) {
|
|
172
|
+
open.set(id, place);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (id !== undefined) {
|
|
176
|
+
// Another call under the id is another call, with a sub-agent of its own or none.
|
|
177
|
+
calls.set(id, place);
|
|
178
|
+
lines.delete(id);
|
|
179
|
+
if (typeof event.data.starts === "string") {
|
|
180
|
+
lineOf(id, place);
|
|
181
|
+
}
|
|
110
182
|
}
|
|
111
183
|
}
|
|
112
184
|
else if (event.kind === "tool_result") {
|
|
113
185
|
const id = idOf(event);
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
if (held !== undefined &&
|
|
117
|
-
|
|
186
|
+
const held = id === undefined ? waiting(line) : open.get(id);
|
|
187
|
+
const called = toolAt(held);
|
|
188
|
+
if (held !== undefined && called !== undefined && called.result === undefined) {
|
|
189
|
+
set(held, { ...called, result: event });
|
|
118
190
|
if (id !== undefined) {
|
|
119
191
|
open.delete(id);
|
|
120
192
|
}
|
|
121
193
|
}
|
|
122
194
|
else {
|
|
123
|
-
|
|
195
|
+
line.push({ type: "tool", call: undefined, result: event, permission: undefined });
|
|
124
196
|
}
|
|
125
197
|
}
|
|
126
198
|
else if (event.kind === "permission") {
|
|
127
199
|
const id = idOf(event);
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
if (held !== undefined &&
|
|
131
|
-
|
|
200
|
+
const held = id === undefined ? undefined : open.get(id);
|
|
201
|
+
const called = toolAt(held);
|
|
202
|
+
if (held !== undefined &&
|
|
203
|
+
called !== undefined &&
|
|
204
|
+
called.permission === undefined &&
|
|
205
|
+
called.result === undefined) {
|
|
206
|
+
set(held, { ...called, permission: event });
|
|
132
207
|
}
|
|
133
208
|
else {
|
|
134
|
-
|
|
209
|
+
const place = push(line, {
|
|
210
|
+
type: "tool",
|
|
211
|
+
call: undefined,
|
|
212
|
+
result: undefined,
|
|
213
|
+
permission: event,
|
|
214
|
+
});
|
|
215
|
+
if (id !== undefined) {
|
|
216
|
+
open.set(id, place);
|
|
217
|
+
}
|
|
135
218
|
}
|
|
136
219
|
}
|
|
137
220
|
else {
|
|
138
|
-
|
|
221
|
+
line.push({ type: "note", event });
|
|
222
|
+
// Where the session's own line says a turn ended, or the session did, nothing started in
|
|
223
|
+
// it goes on: a sub-agent that was not answered by then is ended there.
|
|
224
|
+
if (parent === undefined && endsTurn(event)) {
|
|
225
|
+
for (const place of running) {
|
|
226
|
+
const tool = toolAt(place);
|
|
227
|
+
if (tool !== undefined && tool.result === undefined && tool.endedAt === undefined) {
|
|
228
|
+
set(place, { ...tool, endedAt: event.at });
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
running = [];
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return top;
|
|
236
|
+
}
|
|
237
|
+
/** The first event of a thing: what it is numbered and timed by. */
|
|
238
|
+
const firstOf = (item) => item.type === "tool" ? (item.call ?? item.permission ?? item.result) : item.event;
|
|
239
|
+
/** The moments a thing holds, as numbers; none for one that reads as no moment. */
|
|
240
|
+
const momentsOf = (item) => (item.type === "tool" ? [item.call, item.permission, item.result] : [item.event]).flatMap((event) => {
|
|
241
|
+
const at = event === undefined ? Number.NaN : Date.parse(event.at);
|
|
242
|
+
return Number.isFinite(at) ? [at] : [];
|
|
243
|
+
});
|
|
244
|
+
/** Whether what was asked of a call was answered with anything but leave to run. */
|
|
245
|
+
const refusedOf = (item) => {
|
|
246
|
+
const answer = item.permission?.data.answer;
|
|
247
|
+
return typeof answer === "string" && answer.length > 0 && answer !== "allowed";
|
|
248
|
+
};
|
|
249
|
+
/** What a sub-agent is at, by its steps: its last tool that was not answered, a thought, or the work between. */
|
|
250
|
+
function atOf(steps) {
|
|
251
|
+
for (let at = steps.length - 1; at >= 0; at -= 1) {
|
|
252
|
+
const step = steps[at];
|
|
253
|
+
if (step !== undefined &&
|
|
254
|
+
step.type === "tool" &&
|
|
255
|
+
step.call !== undefined &&
|
|
256
|
+
step.result === undefined &&
|
|
257
|
+
!refusedOf(step)) {
|
|
258
|
+
const tool = step.call.data[TOOL];
|
|
259
|
+
return { at: "tool", tool: typeof tool === "string" && tool.length > 0 ? tool : undefined };
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return steps[steps.length - 1]?.type === "thought" ? { at: "thinking" } : { at: "working" };
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* The sub-agent a call started, read off the record alone (ADR-0141): what the call calls it, or
|
|
266
|
+
* what its events do where a runner of before wrote them; when it started; how it stands, done
|
|
267
|
+
* or failed by the call's answer, ended where its turn or its session ended first, and at work
|
|
268
|
+
* otherwise, which only an open session's is (`live`); how long it ran, to its answer, to where
|
|
269
|
+
* it was ended or to the last thing it did, and to `now` while it runs; how many tools it
|
|
270
|
+
* called; and what it is at. Nothing for a thing that is no call that started a sub-agent.
|
|
271
|
+
*/
|
|
272
|
+
export function subAgentOf(item, input) {
|
|
273
|
+
if (item.type !== "tool" || item.steps === undefined) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
const first = firstOf(item);
|
|
277
|
+
if (first === undefined) {
|
|
278
|
+
return undefined;
|
|
279
|
+
}
|
|
280
|
+
const steps = item.steps;
|
|
281
|
+
const said = item.call?.data.starts;
|
|
282
|
+
const named = typeof said === "string" ? said : steps.map(firstOf).find(Boolean)?.data.subagent;
|
|
283
|
+
const name = typeof named === "string" ? named.trim().slice(0, MAX_SUBAGENT_NAME) : "";
|
|
284
|
+
const started = Date.parse(first.at);
|
|
285
|
+
const answered = item.result === undefined ? Number.NaN : Date.parse(item.result.at);
|
|
286
|
+
const cut = item.endedAt === undefined ? Number.NaN : Date.parse(item.endedAt);
|
|
287
|
+
const state = item.result !== undefined
|
|
288
|
+
? item.result.data.error === true
|
|
289
|
+
? "failed"
|
|
290
|
+
: "done"
|
|
291
|
+
: item.endedAt !== undefined || refusedOf(item) || !input.live
|
|
292
|
+
? "ended"
|
|
293
|
+
: "running";
|
|
294
|
+
const until = state === "running"
|
|
295
|
+
? input.now
|
|
296
|
+
: item.result !== undefined
|
|
297
|
+
? answered
|
|
298
|
+
: item.endedAt !== undefined
|
|
299
|
+
? cut
|
|
300
|
+
: Math.max(started, ...steps.flatMap(momentsOf));
|
|
301
|
+
const seconds = Math.floor((until - started) / 1000);
|
|
302
|
+
return {
|
|
303
|
+
n: first.n,
|
|
304
|
+
name,
|
|
305
|
+
startedAt: first.at,
|
|
306
|
+
state,
|
|
307
|
+
seconds: Number.isFinite(seconds) && seconds > 0 ? seconds : 0,
|
|
308
|
+
calls: steps.filter((step) => step.type === "tool" && step.call !== undefined).length,
|
|
309
|
+
at: state === "running" ? atOf(steps) : undefined,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/** The sub-agents among things and under them, in the order they were started. */
|
|
313
|
+
function subAgentsIn(items, input) {
|
|
314
|
+
return items.flatMap((item) => {
|
|
315
|
+
const one = subAgentOf(item, input);
|
|
316
|
+
return one === undefined || item.type !== "tool"
|
|
317
|
+
? []
|
|
318
|
+
: [one, ...subAgentsIn(item.steps ?? [], input)];
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* The sub-agents at work in the turn under way, read off a session's events alone, in the order
|
|
323
|
+
* they were started: those a call of this turn started that was not answered yet. None where the
|
|
324
|
+
* session has no event, or its last turn is over.
|
|
325
|
+
*/
|
|
326
|
+
export function atWorkOf(events, now) {
|
|
327
|
+
let from = 0;
|
|
328
|
+
for (let at = events.length - 1; at >= 0; at -= 1) {
|
|
329
|
+
const event = events[at];
|
|
330
|
+
if (event !== undefined && parentOf(event) === undefined && endsTurn(event)) {
|
|
331
|
+
from = at + 1;
|
|
332
|
+
break;
|
|
139
333
|
}
|
|
140
334
|
}
|
|
141
|
-
return
|
|
335
|
+
return subAgentsIn(talkOf(events.slice(from)), { now, live: true }).filter((one) => one.state === "running");
|
|
142
336
|
}
|
|
143
337
|
/**
|
|
144
338
|
* Whether a turn is under way, and what the agent is at, read off a session's events alone:
|
|
145
339
|
* the record says where a turn ends (`turn: "completed"` on a status) and where the session
|
|
146
340
|
* does, so whatever follows the last of those is a turn that is not done. Nothing where the
|
|
147
|
-
* session has no event yet, or its last turn is over.
|
|
341
|
+
* session has no event yet, or its last turn is over. What a sub-agent does says nothing of
|
|
342
|
+
* what the agent itself is at, which is the call that started it: its events are passed over.
|
|
148
343
|
*/
|
|
149
344
|
export function workingOf(events) {
|
|
150
345
|
/** The calls that were answered, by the id the product gave them. */
|
|
151
346
|
const answered = new Set();
|
|
152
347
|
for (let at = events.length - 1; at >= 0; at -= 1) {
|
|
153
348
|
const event = events[at];
|
|
154
|
-
if (event === undefined || event.sealed !== null) {
|
|
349
|
+
if (event === undefined || event.sealed !== null || parentOf(event) !== undefined) {
|
|
155
350
|
continue;
|
|
156
351
|
}
|
|
157
352
|
if (event.kind === "status") {
|
|
@@ -263,6 +458,18 @@ function firstLine(text, most = 160) {
|
|
|
263
458
|
const line = text.split("\n").find((one) => one.trim().length > 0) ?? "";
|
|
264
459
|
return line.length > most ? `${line.slice(0, most)}…` : line;
|
|
265
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* The first line of what was said, for a row that shows one: without the marks its Markdown
|
|
463
|
+
* begins a heading, a quotation or an item of a list with, and those it sets code and weight
|
|
464
|
+
* off by, which a line alone would show bare.
|
|
465
|
+
*/
|
|
466
|
+
export function saidLine(text) {
|
|
467
|
+
const line = text.split("\n").find((one) => one.trim().length > 0) ?? "";
|
|
468
|
+
return firstLine(line
|
|
469
|
+
.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d{1,9}[.)]\s+)/, "")
|
|
470
|
+
.replaceAll("**", "")
|
|
471
|
+
.replaceAll("`", ""));
|
|
472
|
+
}
|
|
266
473
|
/** A fact of an event as a word, or nothing where it is none. */
|
|
267
474
|
const word = (value) => typeof value === "string" && value.length > 0 ? value : undefined;
|
|
268
475
|
/**
|
|
@@ -274,35 +481,103 @@ const word = (value) => typeof value === "string" && value.length > 0 ? value :
|
|
|
274
481
|
export function wordOf(words, name) {
|
|
275
482
|
return Object.hasOwn(words, name) ? (words[name] ?? name) : name;
|
|
276
483
|
}
|
|
484
|
+
/** A length of time as a clock says it, from whole seconds: `0:07`, `12:40`, `1:02:05`. */
|
|
485
|
+
export function clockOf(seconds) {
|
|
486
|
+
const whole = Number.isFinite(seconds) && seconds > 0 ? Math.floor(seconds) : 0;
|
|
487
|
+
const two = (value) => String(value).padStart(2, "0");
|
|
488
|
+
const hours = Math.floor(whole / 3600);
|
|
489
|
+
const minutes = Math.floor((whole % 3600) / 60);
|
|
490
|
+
return hours > 0
|
|
491
|
+
? `${hours}:${two(minutes)}:${two(whole % 60)}`
|
|
492
|
+
: `${minutes}:${two(whole % 60)}`;
|
|
493
|
+
}
|
|
277
494
|
/**
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
* thoughts folded; a tool's call and what it answered as one row that opens, the steps of a turn
|
|
281
|
-
* close together; a wake, a status and an error as notes between, and a line where a turn
|
|
282
|
-
* ended, with how long it took. A picture opens large over the page. Everything an agent's
|
|
283
|
-
* product printed is text, never markup.
|
|
495
|
+
* How long something has run since a moment, as a clock that ticks by itself: the page counts
|
|
496
|
+
* the seconds, and the record is not read again for them.
|
|
284
497
|
*/
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
498
|
+
function RunningFor(props) {
|
|
499
|
+
const [now, setNow] = useState(() => Date.now());
|
|
500
|
+
useEffect(() => {
|
|
501
|
+
const timer = setInterval(() => setNow(Date.now()), 1000);
|
|
502
|
+
return () => clearInterval(timer);
|
|
503
|
+
}, []);
|
|
504
|
+
return _jsx(_Fragment, { children: clockOf((now - Date.parse(props.since)) / 1000) });
|
|
505
|
+
}
|
|
506
|
+
/** What an agent or a sub-agent is at, in the page's words: a thought, a tool by its name, or the work between. */
|
|
507
|
+
function workingWord(words, working) {
|
|
508
|
+
if (working === undefined) {
|
|
509
|
+
return words.working;
|
|
510
|
+
}
|
|
511
|
+
if (working.at === "tool") {
|
|
512
|
+
return working.tool === undefined ? words.working : words.tool(working.tool);
|
|
513
|
+
}
|
|
514
|
+
return words[working.at];
|
|
515
|
+
}
|
|
516
|
+
/** Whether two things of a session are the same events: a thing is made anew each time the events are read through. */
|
|
517
|
+
function sameItem(a, b) {
|
|
518
|
+
if (a.type === "tool" || b.type === "tool") {
|
|
519
|
+
// What a sub-agent did is compared as the lines it is drawn in, and not here.
|
|
520
|
+
return (a.type === "tool" &&
|
|
521
|
+
b.type === "tool" &&
|
|
522
|
+
a.call === b.call &&
|
|
523
|
+
a.result === b.result &&
|
|
524
|
+
a.permission === b.permission &&
|
|
525
|
+
a.endedAt === b.endedAt);
|
|
526
|
+
}
|
|
527
|
+
return a.type === b.type && a.event === b.event;
|
|
528
|
+
}
|
|
529
|
+
/** Whether two lists of a signal's files name the same files: the record is read again every few seconds. */
|
|
530
|
+
function sameFiles(a, b) {
|
|
531
|
+
if (a === b) {
|
|
532
|
+
return true;
|
|
298
533
|
}
|
|
299
|
-
|
|
300
|
-
|
|
534
|
+
return (a !== undefined &&
|
|
535
|
+
b !== undefined &&
|
|
536
|
+
a.length === b.length &&
|
|
537
|
+
a.every((file, index) => {
|
|
538
|
+
const other = b[index];
|
|
539
|
+
return (other !== undefined &&
|
|
540
|
+
file.id === other.id &&
|
|
541
|
+
file.name === other.name &&
|
|
542
|
+
file.size === other.size &&
|
|
543
|
+
file.contentType === other.contentType);
|
|
544
|
+
}));
|
|
545
|
+
}
|
|
546
|
+
/** Whether the lines of two sub-agents would be drawn the same: as many, each the same line. */
|
|
547
|
+
function sameSteps(a, b) {
|
|
548
|
+
if (a === undefined || b === undefined) {
|
|
549
|
+
return a === b;
|
|
550
|
+
}
|
|
551
|
+
return (a.length === b.length &&
|
|
552
|
+
a.every((line, index) => {
|
|
553
|
+
const other = b[index];
|
|
554
|
+
return other !== undefined && line.key === other.key && sameLine(line, other);
|
|
555
|
+
}));
|
|
556
|
+
}
|
|
557
|
+
/** Whether a line would be drawn the same: then it is not drawn again. */
|
|
558
|
+
export function sameLine(a, b) {
|
|
559
|
+
return (sameItem(a.one, b.one) &&
|
|
560
|
+
a.hands === b.hands &&
|
|
561
|
+
a.agent === b.agent &&
|
|
562
|
+
a.began === b.began &&
|
|
563
|
+
sameFiles(a.files, b.files) &&
|
|
564
|
+
a.whole === b.whole &&
|
|
565
|
+
a.wholeAnswer === b.wholeAnswer &&
|
|
566
|
+
a.reading === b.reading &&
|
|
567
|
+
a.today === b.today &&
|
|
568
|
+
a.after === b.after &&
|
|
569
|
+
a.live === b.live &&
|
|
570
|
+
a.inside === b.inside &&
|
|
571
|
+
sameSteps(a.steps, b.steps));
|
|
572
|
+
}
|
|
573
|
+
/** When the turn an event ends began, by the event's number: the first thing the agent was sent after the turn before. */
|
|
574
|
+
export function turnStarts(events) {
|
|
575
|
+
const starts = new Map();
|
|
301
576
|
let since;
|
|
302
|
-
for (const event of
|
|
577
|
+
for (const event of events) {
|
|
303
578
|
if (event.kind === "status" && event.data.turn === "completed") {
|
|
304
579
|
if (since !== undefined) {
|
|
305
|
-
|
|
580
|
+
starts.set(event.n, since);
|
|
306
581
|
}
|
|
307
582
|
since = undefined;
|
|
308
583
|
}
|
|
@@ -310,9 +585,198 @@ export function TranscriptView(props) {
|
|
|
310
585
|
since = event.at;
|
|
311
586
|
}
|
|
312
587
|
}
|
|
588
|
+
return starts;
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* What each line of a conversation is given, in order, with the number it is told apart by:
|
|
592
|
+
* its own events, and of everything the view holds only what the line itself shows, so that a
|
|
593
|
+
* line's props say the same until the line would be drawn otherwise. A call that started a
|
|
594
|
+
* sub-agent is given the lines of what that sub-agent did, made the same way.
|
|
595
|
+
*/
|
|
596
|
+
export function talkLinesOf(input) {
|
|
597
|
+
const { whole, of, reading } = input;
|
|
598
|
+
const linesOf = (items, inside, from) => {
|
|
599
|
+
let before = from;
|
|
600
|
+
return items.flatMap((one) => {
|
|
601
|
+
const main = one.type === "tool" ? one.call : one.event;
|
|
602
|
+
const answer = one.type === "tool" ? one.result : undefined;
|
|
603
|
+
const first = firstOf(one);
|
|
604
|
+
if (first === undefined) {
|
|
605
|
+
return [];
|
|
606
|
+
}
|
|
607
|
+
const signal = one.type === "told" ? one.event.data.signal : undefined;
|
|
608
|
+
const after = before;
|
|
609
|
+
before = first.at;
|
|
610
|
+
const steps = one.type === "tool" && one.steps !== undefined
|
|
611
|
+
? { steps: linesOf(one.steps, true, first.at), live: input.live === true }
|
|
612
|
+
: {};
|
|
613
|
+
return [
|
|
614
|
+
{
|
|
615
|
+
key: first.n,
|
|
616
|
+
one,
|
|
617
|
+
hands: input.hands,
|
|
618
|
+
// The account's picture stands beside what it said, and nowhere else: what a
|
|
619
|
+
// sub-agent said is a step, with no picture, and is not drawn again for one.
|
|
620
|
+
agent: one.type === "said" && subagentOf(one.event) === undefined ? input.agent : undefined,
|
|
621
|
+
began: one.type === "tool" ? undefined : input.began.get(one.event.n),
|
|
622
|
+
files: typeof signal === "number" ? input.signalFiles?.(signal) : undefined,
|
|
623
|
+
whole: main === undefined ? undefined : wholeOf(whole, of, main.n),
|
|
624
|
+
wholeAnswer: answer === undefined ? undefined : wholeOf(whole, of, answer.n),
|
|
625
|
+
reading: reading !== undefined && (reading === main?.n || reading === answer?.n)
|
|
626
|
+
? reading
|
|
627
|
+
: undefined,
|
|
628
|
+
today: input.today,
|
|
629
|
+
after,
|
|
630
|
+
...steps,
|
|
631
|
+
...(inside ? { inside: true } : {}),
|
|
632
|
+
},
|
|
633
|
+
];
|
|
634
|
+
});
|
|
635
|
+
};
|
|
636
|
+
return linesOf(input.items, false, undefined);
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* One line of a conversation. It is drawn again only when its own events, its own texts read
|
|
640
|
+
* whole or what it is handed changed: a session of thousands of events draws one line for an
|
|
641
|
+
* event that arrives, not all of them.
|
|
642
|
+
*/
|
|
643
|
+
const TalkLine = memo(function Line(props) {
|
|
644
|
+
const all = useWords();
|
|
645
|
+
const words = all.agents.page.live;
|
|
646
|
+
const { one, hands } = props;
|
|
313
647
|
const kinds = words.kinds;
|
|
314
|
-
|
|
315
|
-
|
|
648
|
+
/**
|
|
649
|
+
* The words of an event, whole where they were read whole, with the way to read the rest: as
|
|
650
|
+
* text that keeps its spaces and its lines, or, for what the agent said (`said`), as Markdown
|
|
651
|
+
* rendered to elements, with no picture fetched (ADR-0141).
|
|
652
|
+
*/
|
|
653
|
+
const text = (event, className, read, said = false) => {
|
|
654
|
+
const shown = read ?? event.text;
|
|
655
|
+
const readWhole = hands.readWhole;
|
|
656
|
+
return (_jsxs(_Fragment, { children: [shown.length > 0 &&
|
|
657
|
+
(said ? (_jsx(Markdown, { source: shown, picturesAsLinks: true })) : (_jsx("pre", { className: className, children: shown }))), event.whole !== null && read === undefined && (_jsxs("p", { className: "sc-talk-cut", children: [words.cutAt(formatBytes(event.whole)), " ", readWhole !== undefined && (_jsx(Button, { variant: "ghost", size: "sm", disabled: props.reading === event.n, onClick: () => readWhole(event.n), children: words.whole }))] }))] }));
|
|
658
|
+
};
|
|
659
|
+
const pictures = (event) => event === undefined || event.files.length === 0 ? null : (_jsx("ul", { className: "sc-talk-pictures", children: event.files.map((file) => (_jsx("li", { children: _jsx(PictureThumb, { picture: {
|
|
660
|
+
src: hands.fileHref(file.id),
|
|
661
|
+
alt: file.name,
|
|
662
|
+
name: file.name,
|
|
663
|
+
size: file.size,
|
|
664
|
+
}, onOpen: hands.openPicture }) }, file.id))) }));
|
|
665
|
+
const when = (event) => (_jsx(Time, { iso: event.at, precision: "clock", against: props.after }));
|
|
666
|
+
if (one.type === "tool") {
|
|
667
|
+
const first = one.call ?? one.permission ?? one.result;
|
|
668
|
+
if (first === undefined) {
|
|
669
|
+
return null;
|
|
670
|
+
}
|
|
671
|
+
const name = word(one.call?.data[TOOL]) ?? word(one.permission?.data[TOOL]);
|
|
672
|
+
const failed = one.result?.data.error === true;
|
|
673
|
+
const answer = word(one.permission?.data.answer);
|
|
674
|
+
const refused = answer !== undefined && answer !== "allowed";
|
|
675
|
+
const line = firstLine(one.call?.text ?? one.permission?.text ?? one.result?.text ?? "");
|
|
676
|
+
// Whose the call is, where a sub-agent made it: read off the line's own events, as
|
|
677
|
+
// everything a line shows is, so that it is drawn again only when they are others. Under
|
|
678
|
+
// the sub-agent that made it, it is not said again.
|
|
679
|
+
const sub = props.inside === true ? undefined : subagentOf(first);
|
|
680
|
+
// A call that started a sub-agent is that sub-agent's row: what it is called, how much it
|
|
681
|
+
// did and how it stands; opened, what it was started with, what it did, a line each, and
|
|
682
|
+
// what it answered.
|
|
683
|
+
const started = subAgentOf(one, { now: 0, live: props.live === true });
|
|
684
|
+
if (started !== undefined) {
|
|
685
|
+
const steps = props.steps ?? [];
|
|
686
|
+
const calls = words.agent.calls(started.calls);
|
|
687
|
+
// What it is called: by the call, by its events, or as the tool that started it is.
|
|
688
|
+
const called = started.name.length === 0 ? (name ?? kinds.tool_call) : started.name;
|
|
689
|
+
return (_jsxs("li", { className: cx("sc-talk-item", "sc-talk-step", "sc-talk-tool", (started.state === "failed" || refused) && "sc-talk-tool-failed"), "data-n": first.n, children: [_jsxs("details", { className: "sc-talk-tool-fold", children: [_jsxs("summary", { className: "sc-talk-tool-head sc-talk-agent-head", children: [_jsx("span", { className: "sc-talk-who sc-talk-agent-name", title: called, children: called }), sub !== undefined && _jsx(Badge, { children: words.subagent(sub) }), refused ? (_jsx(Badge, { tone: "warning", children: words.toolRefused })) : started.state === "running" ? (_jsx(Badge, { tone: "success", kind: "state", live: true, children: words.agent.states.running })) : started.state === "failed" ? (_jsx(Badge, { tone: "danger", children: words.agent.states.failed })) : (_jsx(Badge, { children: words.agent.states[started.state] })), when(first), _jsxs("span", { className: "sc-muted sc-talk-agent-facts", children: [_jsx("span", { className: "sc-talk-kind", children: words.agent.label }), started.state === "running" ? (_jsxs(_Fragment, { children: [workingWord(words.working, started.at), " \u00B7 ", calls, " \u00B7", " ", _jsx(RunningFor, { since: started.startedAt })] })) : (`${calls} · ${clockOf(started.seconds)}`)] })] }), _jsxs("div", { className: "sc-talk-tool-body", children: [one.permission !== undefined && (_jsxs("p", { className: "sc-talk-note-line", children: [kinds.permission, answer === undefined ? "" : ` · ${wordOf(words.answers, answer)}`, one.permission.text.length > 0 && ` · ${one.permission.text}`] })), one.call !== undefined && text(one.call, "sc-talk-code", props.whole), steps.length > 0 && (_jsx("ol", { className: "sc-talk sc-talk-steps", "aria-label": words.agent.steps, children: steps.map(({ key, ...step }) => (_jsx(TalkLine, { ...step }, key))) })), one.result !== undefined &&
|
|
690
|
+
text(one.result, "sc-talk-code sc-talk-code-answer", props.wholeAnswer)] })] }), pictures(one.result)] }));
|
|
691
|
+
}
|
|
692
|
+
return (_jsxs("li", { className: cx("sc-talk-item", "sc-talk-step", "sc-talk-tool", (failed || refused) && "sc-talk-tool-failed"), "data-n": first.n, children: [_jsxs("details", { className: "sc-talk-tool-fold", children: [_jsxs("summary", { className: "sc-talk-tool-head", children: [_jsx("code", { className: "sc-talk-tool-name", children: name ?? kinds.tool_call }), _jsx("span", { className: "sc-talk-tool-line", children: line }), sub !== undefined && _jsx(Badge, { children: words.subagent(sub) }), failed && _jsx(Badge, { tone: "danger", children: words.toolFailed }), refused && _jsx(Badge, { tone: "warning", children: words.toolRefused }), one.result === undefined && one.call !== undefined && !refused && (_jsx("span", { className: "sc-muted", children: words.toolRunning })), when(first)] }), _jsxs("div", { className: "sc-talk-tool-body", children: [one.permission !== undefined && (_jsxs("p", { className: "sc-talk-note-line", children: [kinds.permission, answer === undefined ? "" : ` · ${wordOf(words.answers, answer)}`, one.permission.text.length > 0 && ` · ${one.permission.text}`] })), one.call !== undefined && text(one.call, "sc-talk-code", props.whole), one.result !== undefined &&
|
|
693
|
+
text(one.result, "sc-talk-code sc-talk-code-answer", props.wholeAnswer)] })] }), pictures(one.result)] }));
|
|
694
|
+
}
|
|
695
|
+
const { event } = one;
|
|
696
|
+
if (event.sealed !== null) {
|
|
697
|
+
return (_jsxs("li", { className: "sc-talk-item sc-talk-note", "data-n": event.n, children: [_jsx("span", { className: "sc-talk-note-line", children: words.sealed(event.sealed.by === null ? "?" : (event.sealed.by.name ?? event.sealed.by.login), event.sealed.reason) }), when(event)] }));
|
|
698
|
+
}
|
|
699
|
+
if (one.type === "told") {
|
|
700
|
+
const number = typeof event.data.signal === "number" ? event.data.signal : undefined;
|
|
701
|
+
const kind = word(event.data.kind);
|
|
702
|
+
const through = word(event.data.agent);
|
|
703
|
+
const unseen = word(event.data.unseen);
|
|
704
|
+
const others = word(event.data.files);
|
|
705
|
+
const listed = number === undefined
|
|
706
|
+
? undefined
|
|
707
|
+
: props.files?.filter((file) => !isPicture(file.contentType));
|
|
708
|
+
const who = word(event.data.by) ?? words.kinds.person;
|
|
709
|
+
// An interrupt with no words of its own stopped the turn so that what waited is read: a
|
|
710
|
+
// note of who did, and no message.
|
|
711
|
+
if (kind === "interrupt" &&
|
|
712
|
+
event.text.length === 0 &&
|
|
713
|
+
event.files.length === 0 &&
|
|
714
|
+
others === undefined) {
|
|
715
|
+
return (_jsx("li", { className: "sc-talk-item sc-talk-note", "data-n": event.n, children: _jsxs("span", { className: "sc-talk-note-line", children: [words.interrupted(who), when(event)] }) }));
|
|
716
|
+
}
|
|
717
|
+
const signalFileHref = hands.signalFileHref;
|
|
718
|
+
return (_jsxs("li", { className: "sc-talk-item sc-talk-told", "data-n": event.n, children: [_jsxs("div", { className: "sc-talk-bubble", children: [text(event, "sc-talk-text", props.whole), pictures(event), listed !== undefined && listed.length > 0 ? (_jsx("ul", { className: "sc-chosen-files", "aria-label": words.files, children: listed.map((file) => (_jsxs("li", { className: "sc-chosen-file", children: [signalFileHref === undefined || number === undefined ? (_jsx("span", { children: file.name })) : (_jsx("a", { href: signalFileHref(number, file.id), download: file.name, children: file.name })), " ", _jsx("span", { className: "sc-muted", children: formatBytes(file.size) })] }, file.id))) })) : (others !== undefined && (_jsxs("p", { className: "sc-talk-note-line", children: [words.files, ": ", others] }))), unseen !== undefined && (_jsx("p", { className: "sc-talk-note-line sc-talk-unseen", children: words.unseen(unseen) }))] }), _jsxs("div", { className: "sc-talk-meta", children: [_jsx("span", { className: "sc-talk-who", children: who }), through !== undefined && _jsx("span", { children: words.through(through) }), kind !== undefined && kind !== "tell" && (_jsx(Badge, { children: wordOf(words.signalKinds, kind) })), when(event)] }), event.data.unread === true && (_jsx("p", { className: "sc-talk-note-line sc-talk-unread", children: words.unread }))] }));
|
|
719
|
+
}
|
|
720
|
+
if (one.type === "said") {
|
|
721
|
+
const sub = subagentOf(event);
|
|
722
|
+
// What a sub-agent said is a step of the work, and not the agent's word to whoever reads:
|
|
723
|
+
// folded as a thought is, under the sub-agent's name where it stands apart from its row.
|
|
724
|
+
if (sub !== undefined) {
|
|
725
|
+
return (_jsx("li", { className: "sc-talk-item sc-talk-step sc-talk-thought", "data-n": event.n, children: _jsxs("details", { className: "sc-talk-tool-fold", children: [_jsxs("summary", { className: "sc-talk-tool-head", children: [_jsx("span", { className: "sc-talk-kind", children: kinds.assistant }), _jsx("span", { className: "sc-talk-tool-line", children: saidLine(event.text) }), props.inside !== true && _jsx(Badge, { children: words.subagent(sub) }), when(event)] }), _jsxs("div", { className: "sc-talk-tool-body", children: [text(event, "sc-talk-text", props.whole, true), pictures(event)] })] }) }));
|
|
726
|
+
}
|
|
727
|
+
return (_jsxs("li", { className: "sc-talk-item sc-talk-said", "data-n": event.n, children: [props.agent !== undefined && _jsx(Avatar, { person: props.agent, size: "sm" }), _jsxs("div", { className: "sc-talk-prose", children: [text(event, "sc-talk-text", props.whole, true), pictures(event)] }), when(event)] }));
|
|
728
|
+
}
|
|
729
|
+
if (one.type === "thought") {
|
|
730
|
+
const sub = props.inside === true ? undefined : subagentOf(event);
|
|
731
|
+
return (_jsx("li", { className: "sc-talk-item sc-talk-step sc-talk-thought", "data-n": event.n, children: _jsxs("details", { className: "sc-talk-tool-fold", children: [_jsxs("summary", { className: "sc-talk-tool-head", children: [_jsx("span", { className: "sc-talk-kind", children: kinds.thinking }), _jsx("span", { className: "sc-talk-tool-line", children: firstLine(event.text) }), sub !== undefined && _jsx(Badge, { children: words.subagent(sub) }), when(event)] }), _jsx("div", { className: "sc-talk-tool-body", children: text(event, "sc-talk-text", props.whole) })] }) }));
|
|
732
|
+
}
|
|
733
|
+
// Where a turn ended: a line, with how long the agent was at it where the record says when it began.
|
|
734
|
+
if (event.kind === "status" && event.data.turn === "completed") {
|
|
735
|
+
const from = props.began;
|
|
736
|
+
const seconds = from === undefined
|
|
737
|
+
? undefined
|
|
738
|
+
: Math.max(0, Math.round((Date.parse(event.at) - Date.parse(from)) / 1000));
|
|
739
|
+
return (_jsx("li", { className: "sc-talk-item sc-talk-turn", "data-n": event.n, children: _jsxs("span", { className: "sc-talk-note-line", children: [words.turnDone(Number.isFinite(seconds) ? seconds : undefined), when(event)] }) }));
|
|
740
|
+
}
|
|
741
|
+
// A wake, a status, an error, and whatever a newer runner calls otherwise: a note between.
|
|
742
|
+
// What the note's own words say already, how a session ended, is not said twice as a fact.
|
|
743
|
+
// The id of the call that started a sub-agent is for joining, and says nothing to a reader;
|
|
744
|
+
// whose a note is, is not said again under the sub-agent that made it.
|
|
745
|
+
const facts = Object.entries(event.data).filter(([name, fact]) => fact !== null &&
|
|
746
|
+
name !== "signal" &&
|
|
747
|
+
name !== "kind" &&
|
|
748
|
+
name !== "ended" &&
|
|
749
|
+
name !== "parent" &&
|
|
750
|
+
!(name === "subagent" && props.inside === true));
|
|
751
|
+
const lines = event.text.split("\n").filter((line) => line.trim().length > 0);
|
|
752
|
+
return (_jsxs("li", { className: cx("sc-talk-item", "sc-talk-note", event.kind === "error" && "sc-talk-note-error"), "data-n": event.n, children: [_jsxs("span", { className: "sc-talk-note-line", children: [_jsx("span", { className: "sc-talk-kind", children: kinds[event.kind] ?? event.kind }), facts.map(([name, fact]) => (_jsxs("span", { className: "sc-talk-fact", children: [wordOf(words.facts, name), " ", String(fact)] }, name))), lines.length === 1 && _jsx("span", { children: lines[0] }), when(event)] }), lines.length > 1 && text(event, "sc-talk-text sc-talk-text-note", props.whole), pictures(event)] }));
|
|
753
|
+
}, sameLine);
|
|
754
|
+
/**
|
|
755
|
+
* A session as a conversation: what the agent was told at the right, as whoever said it wrote
|
|
756
|
+
* it, with the files that came with it; what the agent said at the left, beside its picture; its
|
|
757
|
+
* thoughts folded; a tool's call and what it answered as one row that opens, the steps of a turn
|
|
758
|
+
* close together; a sub-agent as one row that opens on what it did; a wake, a status and an
|
|
759
|
+
* error as notes between, and a line where a turn ended, with how long it took. A picture opens
|
|
760
|
+
* large over the page. What the agent said is Markdown rendered to elements; everything else its
|
|
761
|
+
* product printed is text, and nothing of either is ever HTML (ADR-0141). Each line is drawn
|
|
762
|
+
* once and again only when it changed, however long the session is.
|
|
763
|
+
*/
|
|
764
|
+
export function TranscriptView(props) {
|
|
765
|
+
const words = useWords().agents.page.live;
|
|
766
|
+
const shown = usePicture();
|
|
767
|
+
// What was read whole belongs to the session it was read in: the events of another carry the
|
|
768
|
+
// same numbers, and a view that goes on to show them must show none of this.
|
|
769
|
+
const [whole, setWhole] = useState(NO_WHOLE);
|
|
770
|
+
const [reading, setReading] = useState(undefined);
|
|
771
|
+
const of = props.of;
|
|
772
|
+
const showing = useRef(of);
|
|
773
|
+
showing.current = of;
|
|
774
|
+
// What the view is given may be made anew by whoever renders it; the lines are handed the
|
|
775
|
+
// same hands each time, which reach for what was given last.
|
|
776
|
+
const given = useRef(props);
|
|
777
|
+
given.current = props;
|
|
778
|
+
const readWhole = useCallback((n) => {
|
|
779
|
+
const load = given.current.onReadWhole;
|
|
316
780
|
if (load === undefined) {
|
|
317
781
|
return;
|
|
318
782
|
}
|
|
@@ -326,78 +790,37 @@ export function TranscriptView(props) {
|
|
|
326
790
|
})
|
|
327
791
|
.catch(() => undefined)
|
|
328
792
|
.finally(() => setReading((current) => current !== undefined && current.of === of && current.n === n ? undefined : current));
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
const
|
|
343
|
-
const
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
if (one.type === "told") {
|
|
361
|
-
const number = typeof event.data.signal === "number" ? event.data.signal : undefined;
|
|
362
|
-
const kind = word(event.data.kind);
|
|
363
|
-
const through = word(event.data.agent);
|
|
364
|
-
const unseen = word(event.data.unseen);
|
|
365
|
-
const others = word(event.data.files);
|
|
366
|
-
const listed = number === undefined
|
|
367
|
-
? undefined
|
|
368
|
-
: props.signalFiles?.(number)?.filter((file) => !isPicture(file.contentType));
|
|
369
|
-
const who = word(event.data.by) ?? words.kinds.person;
|
|
370
|
-
// An interrupt with no words of its own stopped the turn so that what waited is read: a
|
|
371
|
-
// note of who did, and no message.
|
|
372
|
-
if (kind === "interrupt" &&
|
|
373
|
-
event.text.length === 0 &&
|
|
374
|
-
event.files.length === 0 &&
|
|
375
|
-
others === undefined) {
|
|
376
|
-
return (_jsx("li", { className: "sc-talk-item sc-talk-note", "data-n": event.n, children: _jsxs("span", { className: "sc-talk-note-line", children: [words.interrupted(who), when(event)] }) }, event.n));
|
|
377
|
-
}
|
|
378
|
-
return (_jsxs("li", { className: "sc-talk-item sc-talk-told", "data-n": event.n, children: [_jsxs("div", { className: "sc-talk-bubble", children: [text(event, "sc-talk-text"), pictures(event), listed !== undefined && listed.length > 0 ? (_jsx("ul", { className: "sc-chosen-files", "aria-label": words.files, children: listed.map((file) => (_jsxs("li", { className: "sc-chosen-file", children: [props.signalFileHref === undefined || number === undefined ? (_jsx("span", { children: file.name })) : (_jsx("a", { href: props.signalFileHref(number, file.id), download: file.name, children: file.name })), " ", _jsx("span", { className: "sc-muted", children: formatBytes(file.size) })] }, file.id))) })) : (others !== undefined && (_jsxs("p", { className: "sc-talk-note-line", children: [words.files, ": ", others] }))), unseen !== undefined && (_jsx("p", { className: "sc-talk-note-line sc-talk-unseen", children: words.unseen(unseen) }))] }), _jsxs("div", { className: "sc-talk-meta", children: [_jsx("span", { className: "sc-talk-who", children: who }), through !== undefined && _jsx("span", { children: words.through(through) }), kind !== undefined && kind !== "tell" && (_jsx(Badge, { children: wordOf(words.signalKinds, kind) })), when(event)] }), event.data.unread === true && (_jsx("p", { className: "sc-talk-note-line sc-talk-unread", children: words.unread }))] }, event.n));
|
|
379
|
-
}
|
|
380
|
-
if (one.type === "said") {
|
|
381
|
-
return (_jsxs("li", { className: "sc-talk-item sc-talk-said", "data-n": event.n, children: [props.agent !== undefined && _jsx(Avatar, { person: props.agent, size: "sm" }), _jsxs("div", { className: "sc-talk-prose", children: [text(event, "sc-talk-text"), pictures(event)] }), when(event)] }, event.n));
|
|
382
|
-
}
|
|
383
|
-
if (one.type === "thought") {
|
|
384
|
-
return (_jsx("li", { className: "sc-talk-item sc-talk-step sc-talk-thought", "data-n": event.n, children: _jsxs("details", { className: "sc-talk-tool-fold", children: [_jsxs("summary", { className: "sc-talk-tool-head", children: [_jsx("span", { className: "sc-talk-kind", children: kinds.thinking }), _jsx("span", { className: "sc-talk-tool-line", children: firstLine(event.text) }), when(event)] }), _jsx("div", { className: "sc-talk-tool-body", children: text(event, "sc-talk-text") })] }) }, event.n));
|
|
385
|
-
}
|
|
386
|
-
// Where a turn ended: a line, with how long the agent was at it where the record says when it began.
|
|
387
|
-
if (event.kind === "status" && event.data.turn === "completed") {
|
|
388
|
-
const from = began.get(event.n);
|
|
389
|
-
const seconds = from === undefined
|
|
390
|
-
? undefined
|
|
391
|
-
: Math.max(0, Math.round((Date.parse(event.at) - Date.parse(from)) / 1000));
|
|
392
|
-
return (_jsx("li", { className: "sc-talk-item sc-talk-turn", "data-n": event.n, children: _jsxs("span", { className: "sc-talk-note-line", children: [words.turnDone(Number.isFinite(seconds) ? seconds : undefined), when(event)] }) }, event.n));
|
|
393
|
-
}
|
|
394
|
-
// A wake, a status, an error, and whatever a newer runner calls otherwise: a note between.
|
|
395
|
-
// What the note's own words say already, how a session ended, is not said twice as a fact.
|
|
396
|
-
const facts = Object.entries(event.data).filter(([name, fact]) => fact !== null && name !== "signal" && name !== "kind" && name !== "ended");
|
|
397
|
-
const lines = event.text.split("\n").filter((line) => line.trim().length > 0);
|
|
398
|
-
return (_jsxs("li", { className: cx("sc-talk-item", "sc-talk-note", event.kind === "error" && "sc-talk-note-error"), "data-n": event.n, children: [_jsxs("span", { className: "sc-talk-note-line", children: [_jsx("span", { className: "sc-talk-kind", children: kinds[event.kind] ?? event.kind }), facts.map(([name, fact]) => (_jsxs("span", { className: "sc-talk-fact", children: [wordOf(words.facts, name), " ", String(fact)] }, name))), lines.length === 1 && _jsx("span", { children: lines[0] }), when(event)] }), lines.length > 1 && text(event, "sc-talk-text sc-talk-text-note"), pictures(event)] }, event.n));
|
|
399
|
-
};
|
|
400
|
-
return (_jsxs(_Fragment, { children: [_jsxs("ol", { className: "sc-talk", "aria-label": words.transcript, children: [talkOf(props.events).map(item), props.foot] }), _jsx(Lightbox, { picture: shown.shown, onClose: shown.close })] }));
|
|
793
|
+
}, [of]);
|
|
794
|
+
const reads = props.onReadWhole !== undefined;
|
|
795
|
+
const hasSignalFiles = props.signalFileHref !== undefined;
|
|
796
|
+
const openPicture = shown.open;
|
|
797
|
+
const hands = useMemo(() => ({
|
|
798
|
+
fileHref: (fileId) => given.current.fileHref(fileId),
|
|
799
|
+
signalFileHref: hasSignalFiles
|
|
800
|
+
? (number, fileId) => given.current.signalFileHref?.(number, fileId) ?? ""
|
|
801
|
+
: undefined,
|
|
802
|
+
readWhole: reads ? readWhole : undefined,
|
|
803
|
+
openPicture,
|
|
804
|
+
}), [hasSignalFiles, reads, readWhole, openPicture]);
|
|
805
|
+
const events = props.events;
|
|
806
|
+
const items = useMemo(() => talkOf(events), [events]);
|
|
807
|
+
const began = useMemo(() => turnStarts(events), [events]);
|
|
808
|
+
if (events.length === 0) {
|
|
809
|
+
return (_jsxs(_Fragment, { children: [props.empty ?? null, props.foot !== undefined && props.foot !== null && (_jsx("ol", { className: "sc-talk", "aria-label": words.transcript, children: props.foot }))] }));
|
|
810
|
+
}
|
|
811
|
+
const lines = talkLinesOf({
|
|
812
|
+
items,
|
|
813
|
+
hands,
|
|
814
|
+
agent: props.agent,
|
|
815
|
+
began,
|
|
816
|
+
signalFiles: props.signalFiles,
|
|
817
|
+
whole,
|
|
818
|
+
of,
|
|
819
|
+
reading: reading !== undefined && reading.of === of ? reading.n : undefined,
|
|
820
|
+
today: today(),
|
|
821
|
+
live: props.live,
|
|
822
|
+
});
|
|
823
|
+
return (_jsxs(_Fragment, { children: [_jsxs("ol", { className: "sc-talk", "aria-label": words.transcript, children: [lines.map(({ key, ...line }) => (_jsx(TalkLine, { ...line }, key))), props.foot] }), _jsx(Lightbox, { picture: shown.shown, onClose: shown.close })] }));
|
|
401
824
|
}
|
|
402
825
|
/**
|
|
403
826
|
* What supervisors said and the agent has not taken yet, at the foot of the conversation: each
|
|
@@ -420,20 +843,20 @@ export function TalkWaiting(props) {
|
|
|
420
843
|
}
|
|
421
844
|
/**
|
|
422
845
|
* The sign that the agent is at work while a turn is under way: its picture, three dots, and
|
|
423
|
-
* what it is at, a thought, a tool by its name, or the work between.
|
|
424
|
-
*
|
|
846
|
+
* what it is at, a thought, a tool by its name, or the work between. Where sub-agents run, it
|
|
847
|
+
* says how many, with each under it: its name, what it is at, how many tools it called and how
|
|
848
|
+
* long it has run, which the page counts by itself (ADR-0141). A row of the conversation's list;
|
|
849
|
+
* nothing where no turn is under way.
|
|
425
850
|
*/
|
|
426
851
|
export function TalkWorking(props) {
|
|
427
|
-
const
|
|
852
|
+
const live = useWords().agents.page.live;
|
|
853
|
+
const words = live.working;
|
|
428
854
|
const { working } = props;
|
|
429
855
|
if (working === undefined) {
|
|
430
856
|
return null;
|
|
431
857
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
? words.working
|
|
435
|
-
: words.tool(working.tool)
|
|
436
|
-
: words[working.at] })] }));
|
|
858
|
+
const agents = props.agents ?? [];
|
|
859
|
+
return (_jsxs("li", { className: cx("sc-talk-item", "sc-talk-working", agents.length > 0 && "sc-talk-working-agents"), role: "status", children: [props.agent !== undefined && _jsx(Avatar, { person: props.agent, size: "sm" }), _jsxs("span", { className: "sc-talk-dots", "aria-hidden": "true", children: [_jsx("span", {}), _jsx("span", {}), _jsx("span", {})] }), _jsx("span", { children: agents.length > 0 ? words.agents(agents.length) : workingWord(words, working) }), agents.length > 0 && (_jsx("ul", { className: "sc-talk-agents", "aria-live": "off", children: agents.map((one) => (_jsxs("li", { className: "sc-talk-agents-row", children: [_jsx("span", { className: "sc-talk-who sc-talk-agent-name", children: one.name.length === 0 ? live.agent.label : one.name }), _jsxs("span", { className: "sc-talk-agents-facts", children: [workingWord(words, one.at), " \u00B7 ", live.agent.calls(one.calls), " \u00B7", " ", _jsx(RunningFor, { since: one.startedAt })] })] }, one.n))) }))] }));
|
|
437
860
|
}
|
|
438
861
|
/**
|
|
439
862
|
* A conversation in a pane of its own, as a chat is read: it scrolls within the pane, with the
|
|
@@ -805,6 +1228,20 @@ export function AgentRunnerFacts(props) {
|
|
|
805
1228
|
],
|
|
806
1229
|
]),
|
|
807
1230
|
[words.signals, words.delivered(runner.delivered, runner.latest)],
|
|
1231
|
+
// The wake sources its runner keeps beside the console's own, as it last said (ADR-0144):
|
|
1232
|
+
// each by its module's name, with how it stands and why where it does not listen.
|
|
1233
|
+
...(runner.sources === undefined || runner.sources.length === 0
|
|
1234
|
+
? []
|
|
1235
|
+
: [
|
|
1236
|
+
[
|
|
1237
|
+
words.sources,
|
|
1238
|
+
_jsx("span", { className: "sc-agent-product", children: runner.sources.map((source) => (_jsxs("span", { className: "sc-agent-product", children: [source.name, _jsx(Badge, { tone: source.state === "connected"
|
|
1239
|
+
? "success"
|
|
1240
|
+
: source.state === "failing"
|
|
1241
|
+
? "danger"
|
|
1242
|
+
: "warning", children: wordOf(words.sourceStates, source.state) }), source.why !== undefined && _jsx("span", { className: "sc-muted", children: source.why })] }, source.name))) }, "sources"),
|
|
1243
|
+
],
|
|
1244
|
+
]),
|
|
808
1245
|
];
|
|
809
1246
|
return (_jsx("dl", { className: "sc-person-facts sc-agent-runner-facts", children: facts.map(([name, value]) => (_jsxs("div", { className: "sc-person-fact", children: [_jsx("dt", { children: name }), _jsx("dd", { children: value })] }, name))) }));
|
|
810
1247
|
}
|