@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,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type FormEvent,
|
|
3
|
+
memo,
|
|
4
|
+
type NamedExoticComponent,
|
|
5
|
+
type ReactNode,
|
|
6
|
+
useCallback,
|
|
7
|
+
useEffect,
|
|
8
|
+
useMemo,
|
|
9
|
+
useRef,
|
|
10
|
+
useState,
|
|
11
|
+
} from "react";
|
|
2
12
|
import {
|
|
3
13
|
type AgentState,
|
|
4
14
|
type FileUpload,
|
|
@@ -13,17 +23,22 @@ import {
|
|
|
13
23
|
type RestSignal,
|
|
14
24
|
type RestTranscriptEvent,
|
|
15
25
|
} from "../api.js";
|
|
26
|
+
import { today } from "../dates.js";
|
|
16
27
|
import { useWords } from "../i18n/index.js";
|
|
17
28
|
import { isPicture } from "./files.js";
|
|
18
|
-
import {
|
|
29
|
+
import { Markdown } from "./markdown.js";
|
|
30
|
+
import { Lightbox, type PictureState, PictureThumb, usePicture } from "./pictures.js";
|
|
19
31
|
import { Avatar, Badge, Button, Callout, cx, formatBytes, personName, Time } from "./ui.js";
|
|
20
32
|
|
|
21
33
|
// The parts of an agent account's page (ADR-0085, ADR-0086): how it stands, what it is doing as
|
|
22
34
|
// it happens, read as a conversation in a pane that follows its end, what a supervisor says to
|
|
23
35
|
// it, shown as waiting until the agent takes it, what changes how it stands, its sessions, and
|
|
24
|
-
// what its runner said of itself.
|
|
25
|
-
//
|
|
26
|
-
//
|
|
36
|
+
// what its runner said of itself. What the agent said is read as Markdown, rendered to elements
|
|
37
|
+
// and never to HTML, with no picture fetched from elsewhere; everything else its product printed,
|
|
38
|
+
// a thought, a tool's call and its answer, a note, is shown as text, in a block that keeps its
|
|
39
|
+
// spaces and its lines (ADR-0141). What a sub-agent did is read under the call that started it.
|
|
40
|
+
// A picture of the session is shown by its address at the console, and any other file is offered
|
|
41
|
+
// to save.
|
|
27
42
|
|
|
28
43
|
/** How an agent stands, in a word, with the tone of it. */
|
|
29
44
|
const STATE_TONES: Readonly<Record<AgentState, "success" | "neutral" | "warning" | "danger">> = {
|
|
@@ -102,6 +117,11 @@ export interface TranscriptViewProps {
|
|
|
102
117
|
readonly onReadWhole?: ((n: number) => Promise<string>) | undefined;
|
|
103
118
|
/** The account whose session this is: its picture stands beside what it said. */
|
|
104
119
|
readonly agent?: RestPerson | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* Whether the session is one whose agent is at work: a sub-agent the record neither answers
|
|
122
|
+
* nor ends is then running, and its row counts its time. Left out, no sub-agent is.
|
|
123
|
+
*/
|
|
124
|
+
readonly live?: boolean | undefined;
|
|
105
125
|
/**
|
|
106
126
|
* The files that came with a signal, by its number, where the page has read the account's
|
|
107
127
|
* record: what a supervisor sent that is no picture is offered to save from there.
|
|
@@ -131,7 +151,8 @@ const TOOL = "tool";
|
|
|
131
151
|
/**
|
|
132
152
|
* One thing of a session as a person reads it: what the agent was told, what woke it, what it
|
|
133
153
|
* said and thought, a tool's call with what it answered and what was asked of it, and a note for
|
|
134
|
-
* everything else, a status, an error, an event that was sealed.
|
|
154
|
+
* everything else, a status, an error, an event that was sealed. A call that started a sub-agent
|
|
155
|
+
* holds what that sub-agent did, as things of its own (ADR-0141).
|
|
135
156
|
*/
|
|
136
157
|
export type TalkItem =
|
|
137
158
|
| {
|
|
@@ -144,119 +165,378 @@ export type TalkItem =
|
|
|
144
165
|
readonly call: RestTranscriptEvent | undefined;
|
|
145
166
|
readonly result: RestTranscriptEvent | undefined;
|
|
146
167
|
readonly permission: RestTranscriptEvent | undefined;
|
|
168
|
+
/**
|
|
169
|
+
* What the sub-agent this call started did, in order: the events that name the call as
|
|
170
|
+
* their parent, read as a conversation of their own. Nothing for a call that started none.
|
|
171
|
+
*/
|
|
172
|
+
readonly steps?: readonly TalkItem[] | undefined;
|
|
173
|
+
/** When the turn or the session it ran in ended, where that came before its answer. */
|
|
174
|
+
readonly endedAt?: string | undefined;
|
|
147
175
|
};
|
|
148
176
|
|
|
177
|
+
/** The most characters of a sub-agent's name that a label shows. */
|
|
178
|
+
const MAX_SUBAGENT_LABEL = 40;
|
|
179
|
+
/** The most characters of a sub-agent's name that its own row shows: what a runner writes of one. */
|
|
180
|
+
const MAX_SUBAGENT_NAME = 80;
|
|
181
|
+
|
|
182
|
+
/** The call an event names as the one that started the sub-agent it is of, or nothing. */
|
|
183
|
+
const parentOf = (event: RestTranscriptEvent | undefined): string | undefined => {
|
|
184
|
+
const parent = event?.data.parent;
|
|
185
|
+
return typeof parent === "string" && parent.length > 0 ? parent : undefined;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Whose an event is, where a sub-agent made it (ADR-0131): what the call that started the
|
|
190
|
+
* sub-agent called it, an empty name where the runner knew only that call, and nothing for an
|
|
191
|
+
* event of the session's own, which is every event of a runner that does not say.
|
|
192
|
+
*/
|
|
193
|
+
export function subagentOf(event: RestTranscriptEvent | undefined): string | undefined {
|
|
194
|
+
if (parentOf(event) === undefined) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
const name = event?.data.subagent;
|
|
198
|
+
return typeof name === "string" ? name.trim().slice(0, MAX_SUBAGENT_LABEL) : "";
|
|
199
|
+
}
|
|
200
|
+
|
|
149
201
|
const idOf = (event: RestTranscriptEvent): string | undefined => {
|
|
150
202
|
const id = event.data.id;
|
|
151
203
|
return typeof id === "string" && id.length > 0 ? id : undefined;
|
|
152
204
|
};
|
|
153
205
|
|
|
206
|
+
/** Whether an event is where a turn ended, or the session did: the record's own word for it. */
|
|
207
|
+
const endsTurn = (event: RestTranscriptEvent): boolean =>
|
|
208
|
+
event.kind === "status" &&
|
|
209
|
+
event.sealed === null &&
|
|
210
|
+
(event.data.turn === "completed" || typeof event.data.ended === "string");
|
|
211
|
+
|
|
212
|
+
type ToolItem = Extract<TalkItem, { type: "tool" }>;
|
|
213
|
+
|
|
214
|
+
/** Things in the order they are read: the session's own, or one sub-agent's. */
|
|
215
|
+
type TalkLineOf = TalkItem[];
|
|
216
|
+
|
|
217
|
+
/** Where a tool thing stands: the line it is in, and its place there. */
|
|
218
|
+
interface TalkPlace {
|
|
219
|
+
readonly line: TalkLineOf;
|
|
220
|
+
readonly at: number;
|
|
221
|
+
}
|
|
222
|
+
|
|
154
223
|
/**
|
|
155
224
|
* The events of a session as the things a person reads, in order. A tool's call, what it
|
|
156
225
|
* answered and what was asked before it ran are one thing, joined by the id the product gave
|
|
157
226
|
* them; a call under an id whose call is done is another call, as an agent that numbers its
|
|
158
227
|
* calls anew at every turn has it. What carries no id joins the call before it that waits.
|
|
228
|
+
*
|
|
229
|
+
* What a sub-agent did is read under the call that started it (ADR-0141): an event that names a
|
|
230
|
+
* call the session holds as its parent is a step of that call, in a line of the call's own, and
|
|
231
|
+
* not a thing of the line the call stands in. A call that says it starts a sub-agent (`starts`)
|
|
232
|
+
* has such a line from the first, empty; one a runner of before wrote has it from the first
|
|
233
|
+
* event that names it. An event that names a call the events do not hold stays where it stood.
|
|
234
|
+
* A turn or a session that ended ends every sub-agent still open in it.
|
|
159
235
|
*/
|
|
160
236
|
export function talkOf(events: readonly RestTranscriptEvent[]): TalkItem[] {
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const
|
|
166
|
-
|
|
237
|
+
const top: TalkLineOf = [];
|
|
238
|
+
/** The tool things that still wait for something, by the id they are open under. */
|
|
239
|
+
const open = new Map<string, TalkPlace>();
|
|
240
|
+
/** The last call under each id, done or not: what a sub-agent's event names as its parent. */
|
|
241
|
+
const calls = new Map<string, TalkPlace>();
|
|
242
|
+
/** The line of each sub-agent, by the id of the call that started it. */
|
|
243
|
+
const lines = new Map<string, TalkLineOf>();
|
|
244
|
+
/** The calls that started a sub-agent and were not answered, as far as the events read say. */
|
|
245
|
+
let running: TalkPlace[] = [];
|
|
246
|
+
const toolAt = (place: TalkPlace | undefined): ToolItem | undefined => {
|
|
247
|
+
const item = place === undefined ? undefined : place.line[place.at];
|
|
167
248
|
return item !== undefined && item.type === "tool" ? item : undefined;
|
|
168
249
|
};
|
|
169
|
-
/** The last tool thing that still waits for
|
|
170
|
-
const waiting = (
|
|
171
|
-
for (let at =
|
|
172
|
-
const item =
|
|
250
|
+
/** The last tool thing of a line that still waits for an answer, where nothing names an id. */
|
|
251
|
+
const waiting = (line: TalkLineOf): TalkPlace | undefined => {
|
|
252
|
+
for (let at = line.length - 1; at >= 0; at -= 1) {
|
|
253
|
+
const item = line[at];
|
|
173
254
|
if (item === undefined || item.type !== "tool") {
|
|
174
255
|
return undefined;
|
|
175
256
|
}
|
|
176
|
-
if (item
|
|
177
|
-
return at;
|
|
257
|
+
if (item.result === undefined) {
|
|
258
|
+
return { line, at };
|
|
178
259
|
}
|
|
179
260
|
}
|
|
180
261
|
return undefined;
|
|
181
262
|
};
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
263
|
+
const set = (place: TalkPlace, tool: ToolItem): void => {
|
|
264
|
+
place.line[place.at] = tool;
|
|
265
|
+
};
|
|
266
|
+
const push = (line: TalkLineOf, tool: ToolItem): TalkPlace => {
|
|
267
|
+
line.push(tool);
|
|
268
|
+
return { line, at: line.length - 1 };
|
|
269
|
+
};
|
|
270
|
+
/** The line of the sub-agent a call started, begun where it has none yet. */
|
|
271
|
+
const lineOf = (id: string, place: TalkPlace): TalkLineOf => {
|
|
272
|
+
const begun = lines.get(id);
|
|
273
|
+
if (begun !== undefined) {
|
|
274
|
+
return begun;
|
|
190
275
|
}
|
|
276
|
+
const line: TalkLineOf = [];
|
|
277
|
+
lines.set(id, line);
|
|
278
|
+
const tool = toolAt(place);
|
|
279
|
+
if (tool !== undefined) {
|
|
280
|
+
set(place, { ...tool, steps: line });
|
|
281
|
+
running.push(place);
|
|
282
|
+
}
|
|
283
|
+
return line;
|
|
191
284
|
};
|
|
192
285
|
for (const event of events) {
|
|
286
|
+
// Whose line the event is of: the sub-agent's whose call it names, where the session holds
|
|
287
|
+
// that call, and the session's own otherwise.
|
|
288
|
+
const parent = parentOf(event);
|
|
289
|
+
const starter = parent === undefined ? undefined : calls.get(parent);
|
|
290
|
+
const line = parent === undefined || starter === undefined ? top : lineOf(parent, starter);
|
|
193
291
|
// A sealed event says who sealed it and why, wherever it stood.
|
|
194
292
|
if (event.sealed !== null) {
|
|
195
|
-
|
|
293
|
+
line.push({ type: "note", event });
|
|
196
294
|
continue;
|
|
197
295
|
}
|
|
198
296
|
if (event.kind === "person") {
|
|
199
|
-
|
|
297
|
+
line.push({ type: "told", event });
|
|
200
298
|
} else if (event.kind === "wake") {
|
|
201
|
-
|
|
299
|
+
line.push({ type: "wake", event });
|
|
202
300
|
} else if (event.kind === "assistant") {
|
|
203
|
-
|
|
301
|
+
line.push({ type: "said", event });
|
|
204
302
|
} else if (event.kind === "thinking") {
|
|
205
|
-
|
|
303
|
+
line.push({ type: "thought", event });
|
|
206
304
|
} else if (event.kind === "tool_call") {
|
|
207
305
|
const id = idOf(event);
|
|
208
|
-
const
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
|
|
306
|
+
const held = id === undefined ? undefined : open.get(id);
|
|
307
|
+
const asked = toolAt(held);
|
|
308
|
+
let place: TalkPlace;
|
|
309
|
+
if (held !== undefined && asked !== undefined && asked.call === undefined) {
|
|
310
|
+
set(held, { ...asked, call: event });
|
|
311
|
+
place = held;
|
|
212
312
|
} else {
|
|
213
|
-
|
|
313
|
+
place = push(line, { type: "tool", call: event, result: undefined, permission: undefined });
|
|
314
|
+
if (id !== undefined) {
|
|
315
|
+
open.set(id, place);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (id !== undefined) {
|
|
319
|
+
// Another call under the id is another call, with a sub-agent of its own or none.
|
|
320
|
+
calls.set(id, place);
|
|
321
|
+
lines.delete(id);
|
|
322
|
+
if (typeof event.data.starts === "string") {
|
|
323
|
+
lineOf(id, place);
|
|
324
|
+
}
|
|
214
325
|
}
|
|
215
326
|
} else if (event.kind === "tool_result") {
|
|
216
327
|
const id = idOf(event);
|
|
217
|
-
const
|
|
218
|
-
const
|
|
219
|
-
if (held !== undefined &&
|
|
220
|
-
|
|
328
|
+
const held = id === undefined ? waiting(line) : open.get(id);
|
|
329
|
+
const called = toolAt(held);
|
|
330
|
+
if (held !== undefined && called !== undefined && called.result === undefined) {
|
|
331
|
+
set(held, { ...called, result: event });
|
|
221
332
|
if (id !== undefined) {
|
|
222
333
|
open.delete(id);
|
|
223
334
|
}
|
|
224
335
|
} else {
|
|
225
|
-
|
|
336
|
+
line.push({ type: "tool", call: undefined, result: event, permission: undefined });
|
|
226
337
|
}
|
|
227
338
|
} else if (event.kind === "permission") {
|
|
228
339
|
const id = idOf(event);
|
|
229
|
-
const
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
232
|
-
|
|
340
|
+
const held = id === undefined ? undefined : open.get(id);
|
|
341
|
+
const called = toolAt(held);
|
|
342
|
+
if (
|
|
343
|
+
held !== undefined &&
|
|
344
|
+
called !== undefined &&
|
|
345
|
+
called.permission === undefined &&
|
|
346
|
+
called.result === undefined
|
|
347
|
+
) {
|
|
348
|
+
set(held, { ...called, permission: event });
|
|
233
349
|
} else {
|
|
234
|
-
|
|
350
|
+
const place = push(line, {
|
|
351
|
+
type: "tool",
|
|
352
|
+
call: undefined,
|
|
353
|
+
result: undefined,
|
|
354
|
+
permission: event,
|
|
355
|
+
});
|
|
356
|
+
if (id !== undefined) {
|
|
357
|
+
open.set(id, place);
|
|
358
|
+
}
|
|
235
359
|
}
|
|
236
360
|
} else {
|
|
237
|
-
|
|
361
|
+
line.push({ type: "note", event });
|
|
362
|
+
// Where the session's own line says a turn ended, or the session did, nothing started in
|
|
363
|
+
// it goes on: a sub-agent that was not answered by then is ended there.
|
|
364
|
+
if (parent === undefined && endsTurn(event)) {
|
|
365
|
+
for (const place of running) {
|
|
366
|
+
const tool = toolAt(place);
|
|
367
|
+
if (tool !== undefined && tool.result === undefined && tool.endedAt === undefined) {
|
|
368
|
+
set(place, { ...tool, endedAt: event.at });
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
running = [];
|
|
372
|
+
}
|
|
238
373
|
}
|
|
239
374
|
}
|
|
240
|
-
return
|
|
375
|
+
return top;
|
|
241
376
|
}
|
|
242
377
|
|
|
243
|
-
/**
|
|
378
|
+
/**
|
|
379
|
+
* What the agent is at while a turn is under way: thinking, at a tool, or at work between the two.
|
|
380
|
+
*/
|
|
244
381
|
export type Working =
|
|
245
382
|
| { readonly at: "thinking" | "working" }
|
|
246
383
|
| { readonly at: "tool"; readonly tool: string | undefined };
|
|
247
384
|
|
|
385
|
+
/** How a sub-agent stands: at work, done, failed, or ended with the turn or the session it ran in. */
|
|
386
|
+
export type SubAgentState = "running" | "done" | "failed" | "ended";
|
|
387
|
+
|
|
388
|
+
/** A sub-agent as the record alone says it (ADR-0141). */
|
|
389
|
+
export interface SubAgent {
|
|
390
|
+
/** The number of the event that began it: what it is told apart by. */
|
|
391
|
+
readonly n: number;
|
|
392
|
+
/** What the call that started it calls it; empty where nothing says. */
|
|
393
|
+
readonly name: string;
|
|
394
|
+
readonly startedAt: string;
|
|
395
|
+
readonly state: SubAgentState;
|
|
396
|
+
/** How long it ran, or has run so far, in whole seconds. */
|
|
397
|
+
readonly seconds: number;
|
|
398
|
+
/** How many tools it called. */
|
|
399
|
+
readonly calls: number;
|
|
400
|
+
/** What it is at, while it runs. */
|
|
401
|
+
readonly at: Working | undefined;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/** The first event of a thing: what it is numbered and timed by. */
|
|
405
|
+
const firstOf = (item: TalkItem): RestTranscriptEvent | undefined =>
|
|
406
|
+
item.type === "tool" ? (item.call ?? item.permission ?? item.result) : item.event;
|
|
407
|
+
|
|
408
|
+
/** The moments a thing holds, as numbers; none for one that reads as no moment. */
|
|
409
|
+
const momentsOf = (item: TalkItem): number[] =>
|
|
410
|
+
(item.type === "tool" ? [item.call, item.permission, item.result] : [item.event]).flatMap(
|
|
411
|
+
(event) => {
|
|
412
|
+
const at = event === undefined ? Number.NaN : Date.parse(event.at);
|
|
413
|
+
return Number.isFinite(at) ? [at] : [];
|
|
414
|
+
},
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
/** Whether what was asked of a call was answered with anything but leave to run. */
|
|
418
|
+
const refusedOf = (item: ToolItem): boolean => {
|
|
419
|
+
const answer = item.permission?.data.answer;
|
|
420
|
+
return typeof answer === "string" && answer.length > 0 && answer !== "allowed";
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
/** What a sub-agent is at, by its steps: its last tool that was not answered, a thought, or the work between. */
|
|
424
|
+
function atOf(steps: readonly TalkItem[]): Working {
|
|
425
|
+
for (let at = steps.length - 1; at >= 0; at -= 1) {
|
|
426
|
+
const step = steps[at];
|
|
427
|
+
if (
|
|
428
|
+
step !== undefined &&
|
|
429
|
+
step.type === "tool" &&
|
|
430
|
+
step.call !== undefined &&
|
|
431
|
+
step.result === undefined &&
|
|
432
|
+
!refusedOf(step)
|
|
433
|
+
) {
|
|
434
|
+
const tool = step.call.data[TOOL];
|
|
435
|
+
return { at: "tool", tool: typeof tool === "string" && tool.length > 0 ? tool : undefined };
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
return steps[steps.length - 1]?.type === "thought" ? { at: "thinking" } : { at: "working" };
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* The sub-agent a call started, read off the record alone (ADR-0141): what the call calls it, or
|
|
443
|
+
* what its events do where a runner of before wrote them; when it started; how it stands, done
|
|
444
|
+
* or failed by the call's answer, ended where its turn or its session ended first, and at work
|
|
445
|
+
* otherwise, which only an open session's is (`live`); how long it ran, to its answer, to where
|
|
446
|
+
* it was ended or to the last thing it did, and to `now` while it runs; how many tools it
|
|
447
|
+
* called; and what it is at. Nothing for a thing that is no call that started a sub-agent.
|
|
448
|
+
*/
|
|
449
|
+
export function subAgentOf(
|
|
450
|
+
item: TalkItem,
|
|
451
|
+
input: { readonly now: number; readonly live: boolean },
|
|
452
|
+
): SubAgent | undefined {
|
|
453
|
+
if (item.type !== "tool" || item.steps === undefined) {
|
|
454
|
+
return undefined;
|
|
455
|
+
}
|
|
456
|
+
const first = firstOf(item);
|
|
457
|
+
if (first === undefined) {
|
|
458
|
+
return undefined;
|
|
459
|
+
}
|
|
460
|
+
const steps = item.steps;
|
|
461
|
+
const said = item.call?.data.starts;
|
|
462
|
+
const named = typeof said === "string" ? said : steps.map(firstOf).find(Boolean)?.data.subagent;
|
|
463
|
+
const name = typeof named === "string" ? named.trim().slice(0, MAX_SUBAGENT_NAME) : "";
|
|
464
|
+
const started = Date.parse(first.at);
|
|
465
|
+
const answered = item.result === undefined ? Number.NaN : Date.parse(item.result.at);
|
|
466
|
+
const cut = item.endedAt === undefined ? Number.NaN : Date.parse(item.endedAt);
|
|
467
|
+
const state: SubAgentState =
|
|
468
|
+
item.result !== undefined
|
|
469
|
+
? item.result.data.error === true
|
|
470
|
+
? "failed"
|
|
471
|
+
: "done"
|
|
472
|
+
: item.endedAt !== undefined || refusedOf(item) || !input.live
|
|
473
|
+
? "ended"
|
|
474
|
+
: "running";
|
|
475
|
+
const until =
|
|
476
|
+
state === "running"
|
|
477
|
+
? input.now
|
|
478
|
+
: item.result !== undefined
|
|
479
|
+
? answered
|
|
480
|
+
: item.endedAt !== undefined
|
|
481
|
+
? cut
|
|
482
|
+
: Math.max(started, ...steps.flatMap(momentsOf));
|
|
483
|
+
const seconds = Math.floor((until - started) / 1000);
|
|
484
|
+
return {
|
|
485
|
+
n: first.n,
|
|
486
|
+
name,
|
|
487
|
+
startedAt: first.at,
|
|
488
|
+
state,
|
|
489
|
+
seconds: Number.isFinite(seconds) && seconds > 0 ? seconds : 0,
|
|
490
|
+
calls: steps.filter((step) => step.type === "tool" && step.call !== undefined).length,
|
|
491
|
+
at: state === "running" ? atOf(steps) : undefined,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/** The sub-agents among things and under them, in the order they were started. */
|
|
496
|
+
function subAgentsIn(
|
|
497
|
+
items: readonly TalkItem[],
|
|
498
|
+
input: { readonly now: number; readonly live: boolean },
|
|
499
|
+
): SubAgent[] {
|
|
500
|
+
return items.flatMap((item) => {
|
|
501
|
+
const one = subAgentOf(item, input);
|
|
502
|
+
return one === undefined || item.type !== "tool"
|
|
503
|
+
? []
|
|
504
|
+
: [one, ...subAgentsIn(item.steps ?? [], input)];
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* The sub-agents at work in the turn under way, read off a session's events alone, in the order
|
|
510
|
+
* they were started: those a call of this turn started that was not answered yet. None where the
|
|
511
|
+
* session has no event, or its last turn is over.
|
|
512
|
+
*/
|
|
513
|
+
export function atWorkOf(events: readonly RestTranscriptEvent[], now: number): readonly SubAgent[] {
|
|
514
|
+
let from = 0;
|
|
515
|
+
for (let at = events.length - 1; at >= 0; at -= 1) {
|
|
516
|
+
const event = events[at];
|
|
517
|
+
if (event !== undefined && parentOf(event) === undefined && endsTurn(event)) {
|
|
518
|
+
from = at + 1;
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return subAgentsIn(talkOf(events.slice(from)), { now, live: true }).filter(
|
|
523
|
+
(one) => one.state === "running",
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
|
|
248
527
|
/**
|
|
249
528
|
* Whether a turn is under way, and what the agent is at, read off a session's events alone:
|
|
250
529
|
* the record says where a turn ends (`turn: "completed"` on a status) and where the session
|
|
251
530
|
* does, so whatever follows the last of those is a turn that is not done. Nothing where the
|
|
252
|
-
* session has no event yet, or its last turn is over.
|
|
531
|
+
* session has no event yet, or its last turn is over. What a sub-agent does says nothing of
|
|
532
|
+
* what the agent itself is at, which is the call that started it: its events are passed over.
|
|
253
533
|
*/
|
|
254
534
|
export function workingOf(events: readonly RestTranscriptEvent[]): Working | undefined {
|
|
255
535
|
/** The calls that were answered, by the id the product gave them. */
|
|
256
536
|
const answered = new Set<string>();
|
|
257
537
|
for (let at = events.length - 1; at >= 0; at -= 1) {
|
|
258
538
|
const event = events[at];
|
|
259
|
-
if (event === undefined || event.sealed !== null) {
|
|
539
|
+
if (event === undefined || event.sealed !== null || parentOf(event) !== undefined) {
|
|
260
540
|
continue;
|
|
261
541
|
}
|
|
262
542
|
if (event.kind === "status") {
|
|
@@ -412,6 +692,21 @@ function firstLine(text: string, most = 160): string {
|
|
|
412
692
|
return line.length > most ? `${line.slice(0, most)}…` : line;
|
|
413
693
|
}
|
|
414
694
|
|
|
695
|
+
/**
|
|
696
|
+
* The first line of what was said, for a row that shows one: without the marks its Markdown
|
|
697
|
+
* begins a heading, a quotation or an item of a list with, and those it sets code and weight
|
|
698
|
+
* off by, which a line alone would show bare.
|
|
699
|
+
*/
|
|
700
|
+
export function saidLine(text: string): string {
|
|
701
|
+
const line = text.split("\n").find((one) => one.trim().length > 0) ?? "";
|
|
702
|
+
return firstLine(
|
|
703
|
+
line
|
|
704
|
+
.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d{1,9}[.)]\s+)/, "")
|
|
705
|
+
.replaceAll("**", "")
|
|
706
|
+
.replaceAll("`", ""),
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
|
|
415
710
|
/** A fact of an event as a word, or nothing where it is none. */
|
|
416
711
|
const word = (value: unknown): string | undefined =>
|
|
417
712
|
typeof value === "string" && value.length > 0 ? value : undefined;
|
|
@@ -426,88 +721,306 @@ export function wordOf(words: Readonly<Record<string, string>>, name: string): s
|
|
|
426
721
|
return Object.hasOwn(words, name) ? (words[name] ?? name) : name;
|
|
427
722
|
}
|
|
428
723
|
|
|
724
|
+
/** A length of time as a clock says it, from whole seconds: `0:07`, `12:40`, `1:02:05`. */
|
|
725
|
+
export function clockOf(seconds: number): string {
|
|
726
|
+
const whole = Number.isFinite(seconds) && seconds > 0 ? Math.floor(seconds) : 0;
|
|
727
|
+
const two = (value: number): string => String(value).padStart(2, "0");
|
|
728
|
+
const hours = Math.floor(whole / 3600);
|
|
729
|
+
const minutes = Math.floor((whole % 3600) / 60);
|
|
730
|
+
return hours > 0
|
|
731
|
+
? `${hours}:${two(minutes)}:${two(whole % 60)}`
|
|
732
|
+
: `${minutes}:${two(whole % 60)}`;
|
|
733
|
+
}
|
|
734
|
+
|
|
429
735
|
/**
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
* thoughts folded; a tool's call and what it answered as one row that opens, the steps of a turn
|
|
433
|
-
* close together; a wake, a status and an error as notes between, and a line where a turn
|
|
434
|
-
* ended, with how long it took. A picture opens large over the page. Everything an agent's
|
|
435
|
-
* product printed is text, never markup.
|
|
736
|
+
* How long something has run since a moment, as a clock that ticks by itself: the page counts
|
|
737
|
+
* the seconds, and the record is not read again for them.
|
|
436
738
|
*/
|
|
437
|
-
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
739
|
+
function RunningFor(props: { readonly since: string }) {
|
|
740
|
+
const [now, setNow] = useState(() => Date.now());
|
|
741
|
+
useEffect(() => {
|
|
742
|
+
const timer = setInterval(() => setNow(Date.now()), 1000);
|
|
743
|
+
return () => clearInterval(timer);
|
|
744
|
+
}, []);
|
|
745
|
+
return <>{clockOf((now - Date.parse(props.since)) / 1000)}</>;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/** 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. */
|
|
749
|
+
function workingWord(
|
|
750
|
+
words: {
|
|
751
|
+
readonly thinking: string;
|
|
752
|
+
readonly working: string;
|
|
753
|
+
readonly tool: (name: string) => string;
|
|
754
|
+
},
|
|
755
|
+
working: Working | undefined,
|
|
756
|
+
): string {
|
|
757
|
+
if (working === undefined) {
|
|
758
|
+
return words.working;
|
|
759
|
+
}
|
|
760
|
+
if (working.at === "tool") {
|
|
761
|
+
return working.tool === undefined ? words.working : words.tool(working.tool);
|
|
762
|
+
}
|
|
763
|
+
return words[working.at];
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* What every line of a conversation is handed, the same from one render of the view to the
|
|
768
|
+
* next, so that a line is drawn again only when what it shows changed.
|
|
769
|
+
*/
|
|
770
|
+
export interface TalkHands {
|
|
771
|
+
/** Where the bytes of a picture of the session are read. */
|
|
772
|
+
readonly fileHref: (fileId: string) => string;
|
|
773
|
+
/** Where the bytes of a file of a signal are read, where the view was told. */
|
|
774
|
+
readonly signalFileHref: ((number: number, fileId: string) => string) | undefined;
|
|
775
|
+
/** Reads the whole text of an event, where the view can. */
|
|
776
|
+
readonly readWhole: ((n: number) => void) | undefined;
|
|
777
|
+
readonly openPicture: PictureState["open"];
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
export interface TalkLineProps {
|
|
781
|
+
readonly one: TalkItem;
|
|
782
|
+
readonly hands: TalkHands;
|
|
783
|
+
/** The account's picture, beside what it said. */
|
|
784
|
+
readonly agent: RestPerson | undefined;
|
|
785
|
+
/** When the turn the line ends began, for a line that ends one. */
|
|
786
|
+
readonly began: string | undefined;
|
|
787
|
+
/** The files that came with what the agent was told, as the account's record names them. */
|
|
788
|
+
readonly files: readonly SignalFile[] | undefined;
|
|
789
|
+
/** The line's text read whole: its own, or its call's for a tool. */
|
|
790
|
+
readonly whole: string | undefined;
|
|
791
|
+
/** A tool's answer read whole. */
|
|
792
|
+
readonly wholeAnswer: string | undefined;
|
|
793
|
+
/** The event of the line whose whole text is being read, by its number. */
|
|
794
|
+
readonly reading: number | undefined;
|
|
795
|
+
/** The day it is: a moment of today is said by its hour alone, so a new day draws the lines again. */
|
|
796
|
+
readonly today: string;
|
|
797
|
+
/**
|
|
798
|
+
* When the line before this one was: a line of the same day says its hour alone, and the day
|
|
799
|
+
* is said once, on the first line of it. The first line is read against today.
|
|
800
|
+
*/
|
|
801
|
+
readonly after: string | undefined;
|
|
802
|
+
/**
|
|
803
|
+
* What the sub-agent the line's call started did, a line each, for a call that started one
|
|
804
|
+
* (ADR-0141): drawn inside the line, each again only when it changed.
|
|
805
|
+
*/
|
|
806
|
+
readonly steps?: readonly TalkStep[] | undefined;
|
|
807
|
+
/**
|
|
808
|
+
* For a call that started a sub-agent: whether the session is one whose agent is at work, so
|
|
809
|
+
* that a sub-agent the record does not end is running. Said on no other line.
|
|
810
|
+
*/
|
|
811
|
+
readonly live?: boolean | undefined;
|
|
812
|
+
/** Whether the line stands under the sub-agent that made it: whose it is, is then not said again. */
|
|
813
|
+
readonly inside?: boolean | undefined;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/** A line of a conversation with the number it is told apart by. */
|
|
817
|
+
export type TalkStep = TalkLineProps & { readonly key: number };
|
|
818
|
+
|
|
819
|
+
/** Whether two things of a session are the same events: a thing is made anew each time the events are read through. */
|
|
820
|
+
function sameItem(a: TalkItem, b: TalkItem): boolean {
|
|
821
|
+
if (a.type === "tool" || b.type === "tool") {
|
|
822
|
+
// What a sub-agent did is compared as the lines it is drawn in, and not here.
|
|
451
823
|
return (
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
)}
|
|
459
|
-
</>
|
|
824
|
+
a.type === "tool" &&
|
|
825
|
+
b.type === "tool" &&
|
|
826
|
+
a.call === b.call &&
|
|
827
|
+
a.result === b.result &&
|
|
828
|
+
a.permission === b.permission &&
|
|
829
|
+
a.endedAt === b.endedAt
|
|
460
830
|
);
|
|
461
831
|
}
|
|
462
|
-
|
|
463
|
-
|
|
832
|
+
return a.type === b.type && a.event === b.event;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/** Whether two lists of a signal's files name the same files: the record is read again every few seconds. */
|
|
836
|
+
function sameFiles(
|
|
837
|
+
a: readonly SignalFile[] | undefined,
|
|
838
|
+
b: readonly SignalFile[] | undefined,
|
|
839
|
+
): boolean {
|
|
840
|
+
if (a === b) {
|
|
841
|
+
return true;
|
|
842
|
+
}
|
|
843
|
+
return (
|
|
844
|
+
a !== undefined &&
|
|
845
|
+
b !== undefined &&
|
|
846
|
+
a.length === b.length &&
|
|
847
|
+
a.every((file, index) => {
|
|
848
|
+
const other = b[index];
|
|
849
|
+
return (
|
|
850
|
+
other !== undefined &&
|
|
851
|
+
file.id === other.id &&
|
|
852
|
+
file.name === other.name &&
|
|
853
|
+
file.size === other.size &&
|
|
854
|
+
file.contentType === other.contentType
|
|
855
|
+
);
|
|
856
|
+
})
|
|
857
|
+
);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/** Whether the lines of two sub-agents would be drawn the same: as many, each the same line. */
|
|
861
|
+
function sameSteps(
|
|
862
|
+
a: readonly TalkStep[] | undefined,
|
|
863
|
+
b: readonly TalkStep[] | undefined,
|
|
864
|
+
): boolean {
|
|
865
|
+
if (a === undefined || b === undefined) {
|
|
866
|
+
return a === b;
|
|
867
|
+
}
|
|
868
|
+
return (
|
|
869
|
+
a.length === b.length &&
|
|
870
|
+
a.every((line, index) => {
|
|
871
|
+
const other = b[index];
|
|
872
|
+
return other !== undefined && line.key === other.key && sameLine(line, other);
|
|
873
|
+
})
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
/** Whether a line would be drawn the same: then it is not drawn again. */
|
|
878
|
+
export function sameLine(a: TalkLineProps, b: TalkLineProps): boolean {
|
|
879
|
+
return (
|
|
880
|
+
sameItem(a.one, b.one) &&
|
|
881
|
+
a.hands === b.hands &&
|
|
882
|
+
a.agent === b.agent &&
|
|
883
|
+
a.began === b.began &&
|
|
884
|
+
sameFiles(a.files, b.files) &&
|
|
885
|
+
a.whole === b.whole &&
|
|
886
|
+
a.wholeAnswer === b.wholeAnswer &&
|
|
887
|
+
a.reading === b.reading &&
|
|
888
|
+
a.today === b.today &&
|
|
889
|
+
a.after === b.after &&
|
|
890
|
+
a.live === b.live &&
|
|
891
|
+
a.inside === b.inside &&
|
|
892
|
+
sameSteps(a.steps, b.steps)
|
|
893
|
+
);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/** When the turn an event ends began, by the event's number: the first thing the agent was sent after the turn before. */
|
|
897
|
+
export function turnStarts(events: readonly RestTranscriptEvent[]): ReadonlyMap<number, string> {
|
|
898
|
+
const starts = new Map<number, string>();
|
|
464
899
|
let since: string | undefined;
|
|
465
|
-
for (const event of
|
|
900
|
+
for (const event of events) {
|
|
466
901
|
if (event.kind === "status" && event.data.turn === "completed") {
|
|
467
902
|
if (since !== undefined) {
|
|
468
|
-
|
|
903
|
+
starts.set(event.n, since);
|
|
469
904
|
}
|
|
470
905
|
since = undefined;
|
|
471
906
|
} else if ((event.kind === "person" || event.kind === "wake") && since === undefined) {
|
|
472
907
|
since = event.at;
|
|
473
908
|
}
|
|
474
909
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
910
|
+
return starts;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* What each line of a conversation is given, in order, with the number it is told apart by:
|
|
915
|
+
* its own events, and of everything the view holds only what the line itself shows, so that a
|
|
916
|
+
* line's props say the same until the line would be drawn otherwise. A call that started a
|
|
917
|
+
* sub-agent is given the lines of what that sub-agent did, made the same way.
|
|
918
|
+
*/
|
|
919
|
+
export function talkLinesOf(input: {
|
|
920
|
+
readonly items: readonly TalkItem[];
|
|
921
|
+
readonly hands: TalkHands;
|
|
922
|
+
readonly agent: RestPerson | undefined;
|
|
923
|
+
readonly began: ReadonlyMap<number, string>;
|
|
924
|
+
readonly signalFiles: TranscriptViewProps["signalFiles"];
|
|
925
|
+
readonly whole: WholeTexts;
|
|
926
|
+
/** The session the events are of. */
|
|
927
|
+
readonly of: string | undefined;
|
|
928
|
+
/** The event whose whole text is being read, by its number. */
|
|
929
|
+
readonly reading: number | undefined;
|
|
930
|
+
readonly today: string;
|
|
931
|
+
/** Whether the session is one whose agent is at work: left out, it is not. */
|
|
932
|
+
readonly live?: boolean | undefined;
|
|
933
|
+
}): readonly TalkStep[] {
|
|
934
|
+
const { whole, of, reading } = input;
|
|
935
|
+
const linesOf = (
|
|
936
|
+
items: readonly TalkItem[],
|
|
937
|
+
inside: boolean,
|
|
938
|
+
from: string | undefined,
|
|
939
|
+
): TalkStep[] => {
|
|
940
|
+
let before = from;
|
|
941
|
+
return items.flatMap((one) => {
|
|
942
|
+
const main = one.type === "tool" ? one.call : one.event;
|
|
943
|
+
const answer = one.type === "tool" ? one.result : undefined;
|
|
944
|
+
const first = firstOf(one);
|
|
945
|
+
if (first === undefined) {
|
|
946
|
+
return [];
|
|
947
|
+
}
|
|
948
|
+
const signal = one.type === "told" ? one.event.data.signal : undefined;
|
|
949
|
+
const after = before;
|
|
950
|
+
before = first.at;
|
|
951
|
+
const steps =
|
|
952
|
+
one.type === "tool" && one.steps !== undefined
|
|
953
|
+
? { steps: linesOf(one.steps, true, first.at), live: input.live === true }
|
|
954
|
+
: {};
|
|
955
|
+
return [
|
|
956
|
+
{
|
|
957
|
+
key: first.n,
|
|
958
|
+
one,
|
|
959
|
+
hands: input.hands,
|
|
960
|
+
// The account's picture stands beside what it said, and nowhere else: what a
|
|
961
|
+
// sub-agent said is a step, with no picture, and is not drawn again for one.
|
|
962
|
+
agent:
|
|
963
|
+
one.type === "said" && subagentOf(one.event) === undefined ? input.agent : undefined,
|
|
964
|
+
began: one.type === "tool" ? undefined : input.began.get(one.event.n),
|
|
965
|
+
files: typeof signal === "number" ? input.signalFiles?.(signal) : undefined,
|
|
966
|
+
whole: main === undefined ? undefined : wholeOf(whole, of, main.n),
|
|
967
|
+
wholeAnswer: answer === undefined ? undefined : wholeOf(whole, of, answer.n),
|
|
968
|
+
reading:
|
|
969
|
+
reading !== undefined && (reading === main?.n || reading === answer?.n)
|
|
970
|
+
? reading
|
|
971
|
+
: undefined,
|
|
972
|
+
today: input.today,
|
|
973
|
+
after,
|
|
974
|
+
...steps,
|
|
975
|
+
...(inside ? { inside: true } : {}),
|
|
976
|
+
},
|
|
977
|
+
];
|
|
978
|
+
});
|
|
495
979
|
};
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
980
|
+
return linesOf(input.items, false, undefined);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* One line of a conversation. It is drawn again only when its own events, its own texts read
|
|
985
|
+
* whole or what it is handed changed: a session of thousands of events draws one line for an
|
|
986
|
+
* event that arrives, not all of them.
|
|
987
|
+
*/
|
|
988
|
+
const TalkLine: NamedExoticComponent<TalkLineProps> = memo(function Line(
|
|
989
|
+
props: TalkLineProps,
|
|
990
|
+
): ReactNode {
|
|
991
|
+
const all = useWords();
|
|
992
|
+
const words = all.agents.page.live;
|
|
993
|
+
const { one, hands } = props;
|
|
994
|
+
const kinds: Readonly<Record<string, string>> = words.kinds;
|
|
995
|
+
/**
|
|
996
|
+
* The words of an event, whole where they were read whole, with the way to read the rest: as
|
|
997
|
+
* text that keeps its spaces and its lines, or, for what the agent said (`said`), as Markdown
|
|
998
|
+
* rendered to elements, with no picture fetched (ADR-0141).
|
|
999
|
+
*/
|
|
1000
|
+
const text = (
|
|
1001
|
+
event: RestTranscriptEvent,
|
|
1002
|
+
className: string,
|
|
1003
|
+
read: string | undefined,
|
|
1004
|
+
said = false,
|
|
1005
|
+
): ReactNode => {
|
|
499
1006
|
const shown = read ?? event.text;
|
|
1007
|
+
const readWhole = hands.readWhole;
|
|
500
1008
|
return (
|
|
501
1009
|
<>
|
|
502
|
-
{shown.length > 0 &&
|
|
1010
|
+
{shown.length > 0 &&
|
|
1011
|
+
(said ? (
|
|
1012
|
+
<Markdown source={shown} picturesAsLinks />
|
|
1013
|
+
) : (
|
|
1014
|
+
<pre className={className}>{shown}</pre>
|
|
1015
|
+
))}
|
|
503
1016
|
{event.whole !== null && read === undefined && (
|
|
504
1017
|
<p className="sc-talk-cut">
|
|
505
1018
|
{words.cutAt(formatBytes(event.whole))}{" "}
|
|
506
|
-
{
|
|
1019
|
+
{readWhole !== undefined && (
|
|
507
1020
|
<Button
|
|
508
1021
|
variant="ghost"
|
|
509
1022
|
size="sm"
|
|
510
|
-
disabled={
|
|
1023
|
+
disabled={props.reading === event.n}
|
|
511
1024
|
onClick={() => readWhole(event.n)}
|
|
512
1025
|
>
|
|
513
1026
|
{words.whole}
|
|
@@ -525,50 +1038,82 @@ export function TranscriptView(props: TranscriptViewProps) {
|
|
|
525
1038
|
<li key={file.id}>
|
|
526
1039
|
<PictureThumb
|
|
527
1040
|
picture={{
|
|
528
|
-
src:
|
|
1041
|
+
src: hands.fileHref(file.id),
|
|
529
1042
|
alt: file.name,
|
|
530
1043
|
name: file.name,
|
|
531
1044
|
size: file.size,
|
|
532
1045
|
}}
|
|
533
|
-
onOpen={
|
|
1046
|
+
onOpen={hands.openPicture}
|
|
534
1047
|
/>
|
|
535
1048
|
</li>
|
|
536
1049
|
))}
|
|
537
1050
|
</ul>
|
|
538
1051
|
);
|
|
539
|
-
const when = (event: RestTranscriptEvent): ReactNode =>
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
1052
|
+
const when = (event: RestTranscriptEvent): ReactNode => (
|
|
1053
|
+
<Time iso={event.at} precision="clock" against={props.after} />
|
|
1054
|
+
);
|
|
1055
|
+
if (one.type === "tool") {
|
|
1056
|
+
const first = one.call ?? one.permission ?? one.result;
|
|
1057
|
+
if (first === undefined) {
|
|
1058
|
+
return null;
|
|
1059
|
+
}
|
|
1060
|
+
const name = word(one.call?.data[TOOL]) ?? word(one.permission?.data[TOOL]);
|
|
1061
|
+
const failed = one.result?.data.error === true;
|
|
1062
|
+
const answer = word(one.permission?.data.answer);
|
|
1063
|
+
const refused = answer !== undefined && answer !== "allowed";
|
|
1064
|
+
const line = firstLine(one.call?.text ?? one.permission?.text ?? one.result?.text ?? "");
|
|
1065
|
+
// Whose the call is, where a sub-agent made it: read off the line's own events, as
|
|
1066
|
+
// everything a line shows is, so that it is drawn again only when they are others. Under
|
|
1067
|
+
// the sub-agent that made it, it is not said again.
|
|
1068
|
+
const sub = props.inside === true ? undefined : subagentOf(first);
|
|
1069
|
+
// A call that started a sub-agent is that sub-agent's row: what it is called, how much it
|
|
1070
|
+
// did and how it stands; opened, what it was started with, what it did, a line each, and
|
|
1071
|
+
// what it answered.
|
|
1072
|
+
const started = subAgentOf(one, { now: 0, live: props.live === true });
|
|
1073
|
+
if (started !== undefined) {
|
|
1074
|
+
const steps = props.steps ?? [];
|
|
1075
|
+
const calls = words.agent.calls(started.calls);
|
|
1076
|
+
// What it is called: by the call, by its events, or as the tool that started it is.
|
|
1077
|
+
const called = started.name.length === 0 ? (name ?? kinds.tool_call) : started.name;
|
|
551
1078
|
return (
|
|
552
1079
|
<li
|
|
553
|
-
key={first.n}
|
|
554
1080
|
className={cx(
|
|
555
1081
|
"sc-talk-item",
|
|
556
1082
|
"sc-talk-step",
|
|
557
1083
|
"sc-talk-tool",
|
|
558
|
-
(failed || refused) && "sc-talk-tool-failed",
|
|
1084
|
+
(started.state === "failed" || refused) && "sc-talk-tool-failed",
|
|
559
1085
|
)}
|
|
560
1086
|
data-n={first.n}
|
|
561
1087
|
>
|
|
562
1088
|
<details className="sc-talk-tool-fold">
|
|
563
|
-
<summary className="sc-talk-tool-head">
|
|
564
|
-
<
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
{
|
|
568
|
-
{
|
|
569
|
-
<
|
|
1089
|
+
<summary className="sc-talk-tool-head sc-talk-agent-head">
|
|
1090
|
+
<span className="sc-talk-who sc-talk-agent-name" title={called}>
|
|
1091
|
+
{called}
|
|
1092
|
+
</span>
|
|
1093
|
+
{sub !== undefined && <Badge>{words.subagent(sub)}</Badge>}
|
|
1094
|
+
{refused ? (
|
|
1095
|
+
<Badge tone="warning">{words.toolRefused}</Badge>
|
|
1096
|
+
) : started.state === "running" ? (
|
|
1097
|
+
<Badge tone="success" kind="state" live>
|
|
1098
|
+
{words.agent.states.running}
|
|
1099
|
+
</Badge>
|
|
1100
|
+
) : started.state === "failed" ? (
|
|
1101
|
+
<Badge tone="danger">{words.agent.states.failed}</Badge>
|
|
1102
|
+
) : (
|
|
1103
|
+
<Badge>{words.agent.states[started.state]}</Badge>
|
|
570
1104
|
)}
|
|
571
1105
|
{when(first)}
|
|
1106
|
+
<span className="sc-muted sc-talk-agent-facts">
|
|
1107
|
+
<span className="sc-talk-kind">{words.agent.label}</span>
|
|
1108
|
+
{started.state === "running" ? (
|
|
1109
|
+
<>
|
|
1110
|
+
{workingWord(words.working, started.at)} · {calls} ·{" "}
|
|
1111
|
+
<RunningFor since={started.startedAt} />
|
|
1112
|
+
</>
|
|
1113
|
+
) : (
|
|
1114
|
+
`${calls} · ${clockOf(started.seconds)}`
|
|
1115
|
+
)}
|
|
1116
|
+
</span>
|
|
572
1117
|
</summary>
|
|
573
1118
|
<div className="sc-talk-tool-body">
|
|
574
1119
|
{one.permission !== undefined && (
|
|
@@ -578,178 +1123,345 @@ export function TranscriptView(props: TranscriptViewProps) {
|
|
|
578
1123
|
{one.permission.text.length > 0 && ` · ${one.permission.text}`}
|
|
579
1124
|
</p>
|
|
580
1125
|
)}
|
|
581
|
-
{one.call !== undefined && text(one.call, "sc-talk-code")}
|
|
582
|
-
{
|
|
1126
|
+
{one.call !== undefined && text(one.call, "sc-talk-code", props.whole)}
|
|
1127
|
+
{steps.length > 0 && (
|
|
1128
|
+
<ol className="sc-talk sc-talk-steps" aria-label={words.agent.steps}>
|
|
1129
|
+
{steps.map(({ key, ...step }) => (
|
|
1130
|
+
<TalkLine key={key} {...step} />
|
|
1131
|
+
))}
|
|
1132
|
+
</ol>
|
|
1133
|
+
)}
|
|
1134
|
+
{one.result !== undefined &&
|
|
1135
|
+
text(one.result, "sc-talk-code sc-talk-code-answer", props.wholeAnswer)}
|
|
583
1136
|
</div>
|
|
584
1137
|
</details>
|
|
585
1138
|
{pictures(one.result)}
|
|
586
1139
|
</li>
|
|
587
1140
|
);
|
|
588
1141
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
const others = word(event.data.files);
|
|
609
|
-
const listed =
|
|
610
|
-
number === undefined
|
|
611
|
-
? undefined
|
|
612
|
-
: props.signalFiles?.(number)?.filter((file) => !isPicture(file.contentType));
|
|
613
|
-
const who = word(event.data.by) ?? words.kinds.person;
|
|
614
|
-
// An interrupt with no words of its own stopped the turn so that what waited is read: a
|
|
615
|
-
// note of who did, and no message.
|
|
616
|
-
if (
|
|
617
|
-
kind === "interrupt" &&
|
|
618
|
-
event.text.length === 0 &&
|
|
619
|
-
event.files.length === 0 &&
|
|
620
|
-
others === undefined
|
|
621
|
-
) {
|
|
622
|
-
return (
|
|
623
|
-
<li key={event.n} className="sc-talk-item sc-talk-note" data-n={event.n}>
|
|
624
|
-
<span className="sc-talk-note-line">
|
|
625
|
-
{words.interrupted(who)}
|
|
626
|
-
{when(event)}
|
|
627
|
-
</span>
|
|
628
|
-
</li>
|
|
629
|
-
);
|
|
630
|
-
}
|
|
631
|
-
return (
|
|
632
|
-
<li key={event.n} className="sc-talk-item sc-talk-told" data-n={event.n}>
|
|
633
|
-
<div className="sc-talk-bubble">
|
|
634
|
-
{text(event, "sc-talk-text")}
|
|
635
|
-
{pictures(event)}
|
|
636
|
-
{listed !== undefined && listed.length > 0 ? (
|
|
637
|
-
<ul className="sc-chosen-files" aria-label={words.files}>
|
|
638
|
-
{listed.map((file) => (
|
|
639
|
-
<li key={file.id} className="sc-chosen-file">
|
|
640
|
-
{props.signalFileHref === undefined || number === undefined ? (
|
|
641
|
-
<span>{file.name}</span>
|
|
642
|
-
) : (
|
|
643
|
-
<a href={props.signalFileHref(number, file.id)} download={file.name}>
|
|
644
|
-
{file.name}
|
|
645
|
-
</a>
|
|
646
|
-
)}{" "}
|
|
647
|
-
<span className="sc-muted">{formatBytes(file.size)}</span>
|
|
648
|
-
</li>
|
|
649
|
-
))}
|
|
650
|
-
</ul>
|
|
651
|
-
) : (
|
|
652
|
-
others !== undefined && (
|
|
653
|
-
<p className="sc-talk-note-line">
|
|
654
|
-
{words.files}: {others}
|
|
655
|
-
</p>
|
|
656
|
-
)
|
|
657
|
-
)}
|
|
658
|
-
{unseen !== undefined && (
|
|
659
|
-
<p className="sc-talk-note-line sc-talk-unseen">{words.unseen(unseen)}</p>
|
|
1142
|
+
return (
|
|
1143
|
+
<li
|
|
1144
|
+
className={cx(
|
|
1145
|
+
"sc-talk-item",
|
|
1146
|
+
"sc-talk-step",
|
|
1147
|
+
"sc-talk-tool",
|
|
1148
|
+
(failed || refused) && "sc-talk-tool-failed",
|
|
1149
|
+
)}
|
|
1150
|
+
data-n={first.n}
|
|
1151
|
+
>
|
|
1152
|
+
<details className="sc-talk-tool-fold">
|
|
1153
|
+
<summary className="sc-talk-tool-head">
|
|
1154
|
+
<code className="sc-talk-tool-name">{name ?? kinds.tool_call}</code>
|
|
1155
|
+
<span className="sc-talk-tool-line">{line}</span>
|
|
1156
|
+
{sub !== undefined && <Badge>{words.subagent(sub)}</Badge>}
|
|
1157
|
+
{failed && <Badge tone="danger">{words.toolFailed}</Badge>}
|
|
1158
|
+
{refused && <Badge tone="warning">{words.toolRefused}</Badge>}
|
|
1159
|
+
{one.result === undefined && one.call !== undefined && !refused && (
|
|
1160
|
+
<span className="sc-muted">{words.toolRunning}</span>
|
|
660
1161
|
)}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
{
|
|
665
|
-
|
|
666
|
-
|
|
1162
|
+
{when(first)}
|
|
1163
|
+
</summary>
|
|
1164
|
+
<div className="sc-talk-tool-body">
|
|
1165
|
+
{one.permission !== undefined && (
|
|
1166
|
+
<p className="sc-talk-note-line">
|
|
1167
|
+
{kinds.permission}
|
|
1168
|
+
{answer === undefined ? "" : ` · ${wordOf(words.answers, answer)}`}
|
|
1169
|
+
{one.permission.text.length > 0 && ` · ${one.permission.text}`}
|
|
1170
|
+
</p>
|
|
667
1171
|
)}
|
|
668
|
-
{
|
|
1172
|
+
{one.call !== undefined && text(one.call, "sc-talk-code", props.whole)}
|
|
1173
|
+
{one.result !== undefined &&
|
|
1174
|
+
text(one.result, "sc-talk-code sc-talk-code-answer", props.wholeAnswer)}
|
|
669
1175
|
</div>
|
|
670
|
-
|
|
671
|
-
|
|
1176
|
+
</details>
|
|
1177
|
+
{pictures(one.result)}
|
|
1178
|
+
</li>
|
|
1179
|
+
);
|
|
1180
|
+
}
|
|
1181
|
+
const { event } = one;
|
|
1182
|
+
if (event.sealed !== null) {
|
|
1183
|
+
return (
|
|
1184
|
+
<li className="sc-talk-item sc-talk-note" data-n={event.n}>
|
|
1185
|
+
<span className="sc-talk-note-line">
|
|
1186
|
+
{words.sealed(
|
|
1187
|
+
event.sealed.by === null ? "?" : (event.sealed.by.name ?? event.sealed.by.login),
|
|
1188
|
+
event.sealed.reason,
|
|
672
1189
|
)}
|
|
673
|
-
</
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
1190
|
+
</span>
|
|
1191
|
+
{when(event)}
|
|
1192
|
+
</li>
|
|
1193
|
+
);
|
|
1194
|
+
}
|
|
1195
|
+
if (one.type === "told") {
|
|
1196
|
+
const number = typeof event.data.signal === "number" ? event.data.signal : undefined;
|
|
1197
|
+
const kind = word(event.data.kind);
|
|
1198
|
+
const through = word(event.data.agent);
|
|
1199
|
+
const unseen = word(event.data.unseen);
|
|
1200
|
+
const others = word(event.data.files);
|
|
1201
|
+
const listed =
|
|
1202
|
+
number === undefined
|
|
1203
|
+
? undefined
|
|
1204
|
+
: props.files?.filter((file) => !isPicture(file.contentType));
|
|
1205
|
+
const who = word(event.data.by) ?? words.kinds.person;
|
|
1206
|
+
// An interrupt with no words of its own stopped the turn so that what waited is read: a
|
|
1207
|
+
// note of who did, and no message.
|
|
1208
|
+
if (
|
|
1209
|
+
kind === "interrupt" &&
|
|
1210
|
+
event.text.length === 0 &&
|
|
1211
|
+
event.files.length === 0 &&
|
|
1212
|
+
others === undefined
|
|
1213
|
+
) {
|
|
677
1214
|
return (
|
|
678
|
-
<li
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
{
|
|
682
|
-
|
|
683
|
-
</div>
|
|
684
|
-
{when(event)}
|
|
1215
|
+
<li className="sc-talk-item sc-talk-note" data-n={event.n}>
|
|
1216
|
+
<span className="sc-talk-note-line">
|
|
1217
|
+
{words.interrupted(who)}
|
|
1218
|
+
{when(event)}
|
|
1219
|
+
</span>
|
|
685
1220
|
</li>
|
|
686
1221
|
);
|
|
687
1222
|
}
|
|
688
|
-
|
|
1223
|
+
const signalFileHref = hands.signalFileHref;
|
|
1224
|
+
return (
|
|
1225
|
+
<li className="sc-talk-item sc-talk-told" data-n={event.n}>
|
|
1226
|
+
<div className="sc-talk-bubble">
|
|
1227
|
+
{text(event, "sc-talk-text", props.whole)}
|
|
1228
|
+
{pictures(event)}
|
|
1229
|
+
{listed !== undefined && listed.length > 0 ? (
|
|
1230
|
+
<ul className="sc-chosen-files" aria-label={words.files}>
|
|
1231
|
+
{listed.map((file) => (
|
|
1232
|
+
<li key={file.id} className="sc-chosen-file">
|
|
1233
|
+
{signalFileHref === undefined || number === undefined ? (
|
|
1234
|
+
<span>{file.name}</span>
|
|
1235
|
+
) : (
|
|
1236
|
+
<a href={signalFileHref(number, file.id)} download={file.name}>
|
|
1237
|
+
{file.name}
|
|
1238
|
+
</a>
|
|
1239
|
+
)}{" "}
|
|
1240
|
+
<span className="sc-muted">{formatBytes(file.size)}</span>
|
|
1241
|
+
</li>
|
|
1242
|
+
))}
|
|
1243
|
+
</ul>
|
|
1244
|
+
) : (
|
|
1245
|
+
others !== undefined && (
|
|
1246
|
+
<p className="sc-talk-note-line">
|
|
1247
|
+
{words.files}: {others}
|
|
1248
|
+
</p>
|
|
1249
|
+
)
|
|
1250
|
+
)}
|
|
1251
|
+
{unseen !== undefined && (
|
|
1252
|
+
<p className="sc-talk-note-line sc-talk-unseen">{words.unseen(unseen)}</p>
|
|
1253
|
+
)}
|
|
1254
|
+
</div>
|
|
1255
|
+
<div className="sc-talk-meta">
|
|
1256
|
+
<span className="sc-talk-who">{who}</span>
|
|
1257
|
+
{through !== undefined && <span>{words.through(through)}</span>}
|
|
1258
|
+
{kind !== undefined && kind !== "tell" && (
|
|
1259
|
+
<Badge>{wordOf(words.signalKinds, kind)}</Badge>
|
|
1260
|
+
)}
|
|
1261
|
+
{when(event)}
|
|
1262
|
+
</div>
|
|
1263
|
+
{event.data.unread === true && (
|
|
1264
|
+
<p className="sc-talk-note-line sc-talk-unread">{words.unread}</p>
|
|
1265
|
+
)}
|
|
1266
|
+
</li>
|
|
1267
|
+
);
|
|
1268
|
+
}
|
|
1269
|
+
if (one.type === "said") {
|
|
1270
|
+
const sub = subagentOf(event);
|
|
1271
|
+
// What a sub-agent said is a step of the work, and not the agent's word to whoever reads:
|
|
1272
|
+
// folded as a thought is, under the sub-agent's name where it stands apart from its row.
|
|
1273
|
+
if (sub !== undefined) {
|
|
689
1274
|
return (
|
|
690
|
-
<li
|
|
1275
|
+
<li className="sc-talk-item sc-talk-step sc-talk-thought" data-n={event.n}>
|
|
691
1276
|
<details className="sc-talk-tool-fold">
|
|
692
1277
|
<summary className="sc-talk-tool-head">
|
|
693
|
-
<span className="sc-talk-kind">{kinds.
|
|
694
|
-
<span className="sc-talk-tool-line">{
|
|
1278
|
+
<span className="sc-talk-kind">{kinds.assistant}</span>
|
|
1279
|
+
<span className="sc-talk-tool-line">{saidLine(event.text)}</span>
|
|
1280
|
+
{props.inside !== true && <Badge>{words.subagent(sub)}</Badge>}
|
|
695
1281
|
{when(event)}
|
|
696
1282
|
</summary>
|
|
697
|
-
<div className="sc-talk-tool-body">
|
|
1283
|
+
<div className="sc-talk-tool-body">
|
|
1284
|
+
{text(event, "sc-talk-text", props.whole, true)}
|
|
1285
|
+
{pictures(event)}
|
|
1286
|
+
</div>
|
|
698
1287
|
</details>
|
|
699
1288
|
</li>
|
|
700
1289
|
);
|
|
701
1290
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
1291
|
+
return (
|
|
1292
|
+
<li className="sc-talk-item sc-talk-said" data-n={event.n}>
|
|
1293
|
+
{props.agent !== undefined && <Avatar person={props.agent} size="sm" />}
|
|
1294
|
+
<div className="sc-talk-prose">
|
|
1295
|
+
{text(event, "sc-talk-text", props.whole, true)}
|
|
1296
|
+
{pictures(event)}
|
|
1297
|
+
</div>
|
|
1298
|
+
{when(event)}
|
|
1299
|
+
</li>
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
if (one.type === "thought") {
|
|
1303
|
+
const sub = props.inside === true ? undefined : subagentOf(event);
|
|
1304
|
+
return (
|
|
1305
|
+
<li className="sc-talk-item sc-talk-step sc-talk-thought" data-n={event.n}>
|
|
1306
|
+
<details className="sc-talk-tool-fold">
|
|
1307
|
+
<summary className="sc-talk-tool-head">
|
|
1308
|
+
<span className="sc-talk-kind">{kinds.thinking}</span>
|
|
1309
|
+
<span className="sc-talk-tool-line">{firstLine(event.text)}</span>
|
|
1310
|
+
{sub !== undefined && <Badge>{words.subagent(sub)}</Badge>}
|
|
713
1311
|
{when(event)}
|
|
714
|
-
</
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
// A wake, a status, an error, and whatever a newer runner calls otherwise: a note between.
|
|
719
|
-
// What the note's own words say already, how a session ended, is not said twice as a fact.
|
|
720
|
-
const facts = Object.entries(event.data).filter(
|
|
721
|
-
([name, fact]) => fact !== null && name !== "signal" && name !== "kind" && name !== "ended",
|
|
1312
|
+
</summary>
|
|
1313
|
+
<div className="sc-talk-tool-body">{text(event, "sc-talk-text", props.whole)}</div>
|
|
1314
|
+
</details>
|
|
1315
|
+
</li>
|
|
722
1316
|
);
|
|
723
|
-
|
|
1317
|
+
}
|
|
1318
|
+
// Where a turn ended: a line, with how long the agent was at it where the record says when it began.
|
|
1319
|
+
if (event.kind === "status" && event.data.turn === "completed") {
|
|
1320
|
+
const from = props.began;
|
|
1321
|
+
const seconds =
|
|
1322
|
+
from === undefined
|
|
1323
|
+
? undefined
|
|
1324
|
+
: Math.max(0, Math.round((Date.parse(event.at) - Date.parse(from)) / 1000));
|
|
724
1325
|
return (
|
|
725
|
-
<li
|
|
726
|
-
key={event.n}
|
|
727
|
-
className={cx(
|
|
728
|
-
"sc-talk-item",
|
|
729
|
-
"sc-talk-note",
|
|
730
|
-
event.kind === "error" && "sc-talk-note-error",
|
|
731
|
-
)}
|
|
732
|
-
data-n={event.n}
|
|
733
|
-
>
|
|
1326
|
+
<li className="sc-talk-item sc-talk-turn" data-n={event.n}>
|
|
734
1327
|
<span className="sc-talk-note-line">
|
|
735
|
-
|
|
736
|
-
{facts.map(([name, fact]) => (
|
|
737
|
-
<span key={name} className="sc-talk-fact">
|
|
738
|
-
{wordOf(words.facts, name)} {String(fact)}
|
|
739
|
-
</span>
|
|
740
|
-
))}
|
|
741
|
-
{lines.length === 1 && <span>{lines[0]}</span>}
|
|
1328
|
+
{words.turnDone(Number.isFinite(seconds) ? seconds : undefined)}
|
|
742
1329
|
{when(event)}
|
|
743
1330
|
</span>
|
|
744
|
-
{lines.length > 1 && text(event, "sc-talk-text sc-talk-text-note")}
|
|
745
|
-
{pictures(event)}
|
|
746
1331
|
</li>
|
|
747
1332
|
);
|
|
748
|
-
}
|
|
1333
|
+
}
|
|
1334
|
+
// A wake, a status, an error, and whatever a newer runner calls otherwise: a note between.
|
|
1335
|
+
// What the note's own words say already, how a session ended, is not said twice as a fact.
|
|
1336
|
+
// The id of the call that started a sub-agent is for joining, and says nothing to a reader;
|
|
1337
|
+
// whose a note is, is not said again under the sub-agent that made it.
|
|
1338
|
+
const facts = Object.entries(event.data).filter(
|
|
1339
|
+
([name, fact]) =>
|
|
1340
|
+
fact !== null &&
|
|
1341
|
+
name !== "signal" &&
|
|
1342
|
+
name !== "kind" &&
|
|
1343
|
+
name !== "ended" &&
|
|
1344
|
+
name !== "parent" &&
|
|
1345
|
+
!(name === "subagent" && props.inside === true),
|
|
1346
|
+
);
|
|
1347
|
+
const lines = event.text.split("\n").filter((line) => line.trim().length > 0);
|
|
1348
|
+
return (
|
|
1349
|
+
<li
|
|
1350
|
+
className={cx("sc-talk-item", "sc-talk-note", event.kind === "error" && "sc-talk-note-error")}
|
|
1351
|
+
data-n={event.n}
|
|
1352
|
+
>
|
|
1353
|
+
<span className="sc-talk-note-line">
|
|
1354
|
+
<span className="sc-talk-kind">{kinds[event.kind] ?? event.kind}</span>
|
|
1355
|
+
{facts.map(([name, fact]) => (
|
|
1356
|
+
<span key={name} className="sc-talk-fact">
|
|
1357
|
+
{wordOf(words.facts, name)} {String(fact)}
|
|
1358
|
+
</span>
|
|
1359
|
+
))}
|
|
1360
|
+
{lines.length === 1 && <span>{lines[0]}</span>}
|
|
1361
|
+
{when(event)}
|
|
1362
|
+
</span>
|
|
1363
|
+
{lines.length > 1 && text(event, "sc-talk-text sc-talk-text-note", props.whole)}
|
|
1364
|
+
{pictures(event)}
|
|
1365
|
+
</li>
|
|
1366
|
+
);
|
|
1367
|
+
}, sameLine);
|
|
1368
|
+
|
|
1369
|
+
/**
|
|
1370
|
+
* A session as a conversation: what the agent was told at the right, as whoever said it wrote
|
|
1371
|
+
* it, with the files that came with it; what the agent said at the left, beside its picture; its
|
|
1372
|
+
* thoughts folded; a tool's call and what it answered as one row that opens, the steps of a turn
|
|
1373
|
+
* close together; a sub-agent as one row that opens on what it did; a wake, a status and an
|
|
1374
|
+
* error as notes between, and a line where a turn ended, with how long it took. A picture opens
|
|
1375
|
+
* large over the page. What the agent said is Markdown rendered to elements; everything else its
|
|
1376
|
+
* product printed is text, and nothing of either is ever HTML (ADR-0141). Each line is drawn
|
|
1377
|
+
* once and again only when it changed, however long the session is.
|
|
1378
|
+
*/
|
|
1379
|
+
export function TranscriptView(props: TranscriptViewProps) {
|
|
1380
|
+
const words = useWords().agents.page.live;
|
|
1381
|
+
const shown = usePicture();
|
|
1382
|
+
// What was read whole belongs to the session it was read in: the events of another carry the
|
|
1383
|
+
// same numbers, and a view that goes on to show them must show none of this.
|
|
1384
|
+
const [whole, setWhole] = useState<WholeTexts>(NO_WHOLE);
|
|
1385
|
+
const [reading, setReading] = useState<
|
|
1386
|
+
{ readonly of: string | undefined; readonly n: number } | undefined
|
|
1387
|
+
>(undefined);
|
|
1388
|
+
const of = props.of;
|
|
1389
|
+
const showing = useRef(of);
|
|
1390
|
+
showing.current = of;
|
|
1391
|
+
// What the view is given may be made anew by whoever renders it; the lines are handed the
|
|
1392
|
+
// same hands each time, which reach for what was given last.
|
|
1393
|
+
const given = useRef(props);
|
|
1394
|
+
given.current = props;
|
|
1395
|
+
const readWhole = useCallback(
|
|
1396
|
+
(n: number) => {
|
|
1397
|
+
const load = given.current.onReadWhole;
|
|
1398
|
+
if (load === undefined) {
|
|
1399
|
+
return;
|
|
1400
|
+
}
|
|
1401
|
+
setReading({ of, n });
|
|
1402
|
+
void load(n)
|
|
1403
|
+
.then((text) => {
|
|
1404
|
+
// An answer that arrives once another session is shown is that session's no more.
|
|
1405
|
+
if (showing.current === of) {
|
|
1406
|
+
setWhole((current) => withWhole(current, of, n, text));
|
|
1407
|
+
}
|
|
1408
|
+
})
|
|
1409
|
+
.catch(() => undefined)
|
|
1410
|
+
.finally(() =>
|
|
1411
|
+
setReading((current) =>
|
|
1412
|
+
current !== undefined && current.of === of && current.n === n ? undefined : current,
|
|
1413
|
+
),
|
|
1414
|
+
);
|
|
1415
|
+
},
|
|
1416
|
+
[of],
|
|
1417
|
+
);
|
|
1418
|
+
const reads = props.onReadWhole !== undefined;
|
|
1419
|
+
const hasSignalFiles = props.signalFileHref !== undefined;
|
|
1420
|
+
const openPicture = shown.open;
|
|
1421
|
+
const hands = useMemo<TalkHands>(
|
|
1422
|
+
() => ({
|
|
1423
|
+
fileHref: (fileId) => given.current.fileHref(fileId),
|
|
1424
|
+
signalFileHref: hasSignalFiles
|
|
1425
|
+
? (number, fileId) => given.current.signalFileHref?.(number, fileId) ?? ""
|
|
1426
|
+
: undefined,
|
|
1427
|
+
readWhole: reads ? readWhole : undefined,
|
|
1428
|
+
openPicture,
|
|
1429
|
+
}),
|
|
1430
|
+
[hasSignalFiles, reads, readWhole, openPicture],
|
|
1431
|
+
);
|
|
1432
|
+
const events = props.events;
|
|
1433
|
+
const items = useMemo(() => talkOf(events), [events]);
|
|
1434
|
+
const began = useMemo(() => turnStarts(events), [events]);
|
|
1435
|
+
if (events.length === 0) {
|
|
1436
|
+
return (
|
|
1437
|
+
<>
|
|
1438
|
+
{props.empty ?? null}
|
|
1439
|
+
{props.foot !== undefined && props.foot !== null && (
|
|
1440
|
+
<ol className="sc-talk" aria-label={words.transcript}>
|
|
1441
|
+
{props.foot}
|
|
1442
|
+
</ol>
|
|
1443
|
+
)}
|
|
1444
|
+
</>
|
|
1445
|
+
);
|
|
1446
|
+
}
|
|
1447
|
+
const lines = talkLinesOf({
|
|
1448
|
+
items,
|
|
1449
|
+
hands,
|
|
1450
|
+
agent: props.agent,
|
|
1451
|
+
began,
|
|
1452
|
+
signalFiles: props.signalFiles,
|
|
1453
|
+
whole,
|
|
1454
|
+
of,
|
|
1455
|
+
reading: reading !== undefined && reading.of === of ? reading.n : undefined,
|
|
1456
|
+
today: today(),
|
|
1457
|
+
live: props.live,
|
|
1458
|
+
});
|
|
749
1459
|
return (
|
|
750
1460
|
<>
|
|
751
1461
|
<ol className="sc-talk" aria-label={words.transcript}>
|
|
752
|
-
{
|
|
1462
|
+
{lines.map(({ key, ...line }) => (
|
|
1463
|
+
<TalkLine key={key} {...line} />
|
|
1464
|
+
))}
|
|
753
1465
|
{props.foot}
|
|
754
1466
|
</ol>
|
|
755
1467
|
<Lightbox picture={shown.shown} onClose={shown.close} />
|
|
@@ -857,33 +1569,56 @@ export function TalkWaiting(props: TalkWaitingProps) {
|
|
|
857
1569
|
|
|
858
1570
|
/**
|
|
859
1571
|
* The sign that the agent is at work while a turn is under way: its picture, three dots, and
|
|
860
|
-
* what it is at, a thought, a tool by its name, or the work between.
|
|
861
|
-
*
|
|
1572
|
+
* what it is at, a thought, a tool by its name, or the work between. Where sub-agents run, it
|
|
1573
|
+
* says how many, with each under it: its name, what it is at, how many tools it called and how
|
|
1574
|
+
* long it has run, which the page counts by itself (ADR-0141). A row of the conversation's list;
|
|
1575
|
+
* nothing where no turn is under way.
|
|
862
1576
|
*/
|
|
863
1577
|
export function TalkWorking(props: {
|
|
864
1578
|
readonly working: Working | undefined;
|
|
865
1579
|
readonly agent?: RestPerson | undefined;
|
|
1580
|
+
/** The sub-agents at work in the turn under way: `atWorkOf` says which. */
|
|
1581
|
+
readonly agents?: readonly SubAgent[] | undefined;
|
|
866
1582
|
}) {
|
|
867
|
-
const
|
|
1583
|
+
const live = useWords().agents.page.live;
|
|
1584
|
+
const words = live.working;
|
|
868
1585
|
const { working } = props;
|
|
869
1586
|
if (working === undefined) {
|
|
870
1587
|
return null;
|
|
871
1588
|
}
|
|
1589
|
+
const agents = props.agents ?? [];
|
|
872
1590
|
return (
|
|
873
|
-
<li
|
|
1591
|
+
<li
|
|
1592
|
+
className={cx(
|
|
1593
|
+
"sc-talk-item",
|
|
1594
|
+
"sc-talk-working",
|
|
1595
|
+
agents.length > 0 && "sc-talk-working-agents",
|
|
1596
|
+
)}
|
|
1597
|
+
role="status"
|
|
1598
|
+
>
|
|
874
1599
|
{props.agent !== undefined && <Avatar person={props.agent} size="sm" />}
|
|
875
1600
|
<span className="sc-talk-dots" aria-hidden="true">
|
|
876
1601
|
<span />
|
|
877
1602
|
<span />
|
|
878
1603
|
<span />
|
|
879
1604
|
</span>
|
|
880
|
-
<span>
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
1605
|
+
<span>{agents.length > 0 ? words.agents(agents.length) : workingWord(words, working)}</span>
|
|
1606
|
+
{agents.length > 0 && (
|
|
1607
|
+
// A clock that ticks is not read out at every second.
|
|
1608
|
+
<ul className="sc-talk-agents" aria-live="off">
|
|
1609
|
+
{agents.map((one) => (
|
|
1610
|
+
<li key={one.n} className="sc-talk-agents-row">
|
|
1611
|
+
<span className="sc-talk-who sc-talk-agent-name">
|
|
1612
|
+
{one.name.length === 0 ? live.agent.label : one.name}
|
|
1613
|
+
</span>
|
|
1614
|
+
<span className="sc-talk-agents-facts">
|
|
1615
|
+
{workingWord(words, one.at)} · {live.agent.calls(one.calls)} ·{" "}
|
|
1616
|
+
<RunningFor since={one.startedAt} />
|
|
1617
|
+
</span>
|
|
1618
|
+
</li>
|
|
1619
|
+
))}
|
|
1620
|
+
</ul>
|
|
1621
|
+
)}
|
|
887
1622
|
</li>
|
|
888
1623
|
);
|
|
889
1624
|
}
|
|
@@ -1582,6 +2317,34 @@ export function AgentRunnerFacts(props: { readonly runner: RestAgentRunner | nul
|
|
|
1582
2317
|
],
|
|
1583
2318
|
] as [string, ReactNode][])),
|
|
1584
2319
|
[words.signals, words.delivered(runner.delivered, runner.latest)],
|
|
2320
|
+
// The wake sources its runner keeps beside the console's own, as it last said (ADR-0144):
|
|
2321
|
+
// each by its module's name, with how it stands and why where it does not listen.
|
|
2322
|
+
...(runner.sources === undefined || runner.sources.length === 0
|
|
2323
|
+
? []
|
|
2324
|
+
: ([
|
|
2325
|
+
[
|
|
2326
|
+
words.sources,
|
|
2327
|
+
<span key="sources" className="sc-agent-product">
|
|
2328
|
+
{runner.sources.map((source) => (
|
|
2329
|
+
<span key={source.name} className="sc-agent-product">
|
|
2330
|
+
{source.name}
|
|
2331
|
+
<Badge
|
|
2332
|
+
tone={
|
|
2333
|
+
source.state === "connected"
|
|
2334
|
+
? "success"
|
|
2335
|
+
: source.state === "failing"
|
|
2336
|
+
? "danger"
|
|
2337
|
+
: "warning"
|
|
2338
|
+
}
|
|
2339
|
+
>
|
|
2340
|
+
{wordOf(words.sourceStates, source.state)}
|
|
2341
|
+
</Badge>
|
|
2342
|
+
{source.why !== undefined && <span className="sc-muted">{source.why}</span>}
|
|
2343
|
+
</span>
|
|
2344
|
+
))}
|
|
2345
|
+
</span>,
|
|
2346
|
+
],
|
|
2347
|
+
] as [string, ReactNode][])),
|
|
1585
2348
|
];
|
|
1586
2349
|
return (
|
|
1587
2350
|
<dl className="sc-person-facts sc-agent-runner-facts">
|