@skillcdn/console 0.5.0 → 0.5.1
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 +68 -11
- package/SKILLCDN.md +3 -3
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +3 -2
- package/dist/agent-page.js.map +1 -1
- package/dist/api.d.ts +7 -6
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +6 -5
- 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 +26 -2
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +1304 -383
- 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 +65 -8
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +242 -37
- 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 +92 -54
- package/dist/cli/help.js.map +1 -1
- 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/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 +48 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +72 -80
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +64 -1
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +244 -96
- package/dist/components/agent-page.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/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 +4 -1
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/home.d.ts.map +1 -1
- package/dist/components/home.js +4 -2
- package/dist/components/home.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.map +1 -1
- package/dist/components/projects.js +27 -7
- 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/setup.d.ts +9 -3
- package/dist/components/setup.d.ts.map +1 -1
- package/dist/components/setup.js +10 -4
- package/dist/components/setup.js.map +1 -1
- package/dist/console.css +677 -7
- package/dist/console.d.ts +5 -0
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +14 -8
- 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 +10 -3
- package/dist/home-tiles.d.ts.map +1 -1
- package/dist/home-tiles.js +54 -31
- package/dist/home-tiles.js.map +1 -1
- package/dist/i18n/en.d.ts +180 -5
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +184 -7
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +169 -6
- package/dist/i18n/ko.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +11 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +11 -0
- package/dist/limits.js.map +1 -1
- package/dist/onboarding.d.ts +6 -0
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +3 -3
- 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.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 +31 -20
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/claude.d.ts +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +85 -15
- 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 +19 -16
- package/dist/runner/codex.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 +166 -10
- 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 +15 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +231 -33
- package/dist/runner/runner.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 +36 -1
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js +17 -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 +509 -5
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +76 -16
- 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 +35 -15
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +3 -1
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +7 -4
- package/dist/setup-guide.js.map +1 -1
- package/dist/vocabulary.d.ts +14 -3
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +13 -3
- package/dist/vocabulary.js.map +1 -1
- package/docs/specs/cli.md +64 -38
- package/docs/specs/plugins.md +27 -20
- package/docs/specs/records.md +113 -0
- package/docs/specs/rest.md +20 -13
- package/docs/specs/runner.md +23 -17
- package/package.json +7 -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 +10 -9
- package/skills/working-the-board/SKILL.md +62 -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 +3 -1
- package/src/api.ts +77 -2
- package/src/charts.ts +250 -0
- package/src/cli/cli.ts +1698 -476
- 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 +301 -46
- package/src/cli/help.ts +102 -54
- 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/serve.ts +295 -2
- package/src/client.ts +192 -177
- package/src/components/agent-page.tsx +489 -243
- package/src/components/charts.tsx +680 -0
- package/src/components/desk-records.tsx +724 -0
- package/src/components/desk.tsx +471 -0
- package/src/components/event-feed.tsx +5 -1
- package/src/components/home.tsx +12 -0
- package/src/components/plugin-settings.tsx +171 -12
- package/src/components/projects.tsx +29 -12
- package/src/components/rules.tsx +94 -34
- package/src/components/setup.tsx +18 -3
- package/src/console.tsx +17 -9
- 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 +55 -35
- package/src/i18n/en.ts +196 -9
- package/src/i18n/ko.ts +178 -8
- package/src/index.ts +118 -0
- package/src/limits.ts +11 -0
- package/src/onboarding.ts +12 -4
- 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.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 +47 -29
- package/src/runner/claude.ts +113 -23
- package/src/runner/codex.ts +35 -25
- package/src/runner/desk.ts +198 -12
- package/src/runner/process.ts +11 -4
- package/src/runner/redact.ts +92 -6
- package/src/runner/runner.ts +275 -34
- package/src/runner/task-scheduler.ts +36 -4
- package/src/runner/types.ts +47 -1
- package/src/runner.ts +27 -2
- package/src/schemas.ts +83 -15
- package/src/services.ts +49 -14
- package/src/setup-guide.ts +6 -2
- package/src/styles/README.md +11 -1
- package/src/styles/console.css +9 -0
- package/src/styles/pages/desk.css +126 -0
- package/src/styles/pages/documents.css +5 -0
- package/src/styles/parts/bars.css +80 -0
- package/src/styles/parts/chart.css +173 -0
- package/src/styles/parts/figures.css +65 -0
- package/src/styles/parts/legend.css +48 -0
- package/src/styles/parts/series.css +32 -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 +13 -7
- package/src/vocabulary.ts +16 -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,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type FormEvent,
|
|
3
|
+
memo,
|
|
4
|
+
type ReactNode,
|
|
5
|
+
useCallback,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from "react";
|
|
2
11
|
import {
|
|
3
12
|
type AgentState,
|
|
4
13
|
type FileUpload,
|
|
@@ -13,9 +22,10 @@ import {
|
|
|
13
22
|
type RestSignal,
|
|
14
23
|
type RestTranscriptEvent,
|
|
15
24
|
} from "../api.js";
|
|
25
|
+
import { today } from "../dates.js";
|
|
16
26
|
import { useWords } from "../i18n/index.js";
|
|
17
27
|
import { isPicture } from "./files.js";
|
|
18
|
-
import { Lightbox, PictureThumb, usePicture } from "./pictures.js";
|
|
28
|
+
import { Lightbox, type PictureState, PictureThumb, usePicture } from "./pictures.js";
|
|
19
29
|
import { Avatar, Badge, Button, Callout, cx, formatBytes, personName, Time } from "./ui.js";
|
|
20
30
|
|
|
21
31
|
// The parts of an agent account's page (ADR-0085, ADR-0086): how it stands, what it is doing as
|
|
@@ -146,6 +156,23 @@ export type TalkItem =
|
|
|
146
156
|
readonly permission: RestTranscriptEvent | undefined;
|
|
147
157
|
};
|
|
148
158
|
|
|
159
|
+
/** The most characters of a sub-agent's name that a label shows. */
|
|
160
|
+
const MAX_SUBAGENT_LABEL = 40;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Whose an event is, where a sub-agent made it (ADR-0131): what the call that started the
|
|
164
|
+
* sub-agent called it, an empty name where the runner knew only that call, and nothing for an
|
|
165
|
+
* event of the session's own, which is every event of a runner that does not say.
|
|
166
|
+
*/
|
|
167
|
+
export function subagentOf(event: RestTranscriptEvent | undefined): string | undefined {
|
|
168
|
+
const parent = event?.data.parent;
|
|
169
|
+
if (typeof parent !== "string" || parent.length === 0) {
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
const name = event?.data.subagent;
|
|
173
|
+
return typeof name === "string" ? name.trim().slice(0, MAX_SUBAGENT_LABEL) : "";
|
|
174
|
+
}
|
|
175
|
+
|
|
149
176
|
const idOf = (event: RestTranscriptEvent): string | undefined => {
|
|
150
177
|
const id = event.data.id;
|
|
151
178
|
return typeof id === "string" && id.length > 0 ? id : undefined;
|
|
@@ -427,87 +454,187 @@ export function wordOf(words: Readonly<Record<string, string>>, name: string): s
|
|
|
427
454
|
}
|
|
428
455
|
|
|
429
456
|
/**
|
|
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.
|
|
457
|
+
* What every line of a conversation is handed, the same from one render of the view to the
|
|
458
|
+
* next, so that a line is drawn again only when what it shows changed.
|
|
436
459
|
*/
|
|
437
|
-
export
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
460
|
+
export interface TalkHands {
|
|
461
|
+
/** Where the bytes of a picture of the session are read. */
|
|
462
|
+
readonly fileHref: (fileId: string) => string;
|
|
463
|
+
/** Where the bytes of a file of a signal are read, where the view was told. */
|
|
464
|
+
readonly signalFileHref: ((number: number, fileId: string) => string) | undefined;
|
|
465
|
+
/** Reads the whole text of an event, where the view can. */
|
|
466
|
+
readonly readWhole: ((n: number) => void) | undefined;
|
|
467
|
+
readonly openPicture: PictureState["open"];
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export interface TalkLineProps {
|
|
471
|
+
readonly one: TalkItem;
|
|
472
|
+
readonly hands: TalkHands;
|
|
473
|
+
/** The account's picture, beside what it said. */
|
|
474
|
+
readonly agent: RestPerson | undefined;
|
|
475
|
+
/** When the turn the line ends began, for a line that ends one. */
|
|
476
|
+
readonly began: string | undefined;
|
|
477
|
+
/** The files that came with what the agent was told, as the account's record names them. */
|
|
478
|
+
readonly files: readonly SignalFile[] | undefined;
|
|
479
|
+
/** The line's text read whole: its own, or its call's for a tool. */
|
|
480
|
+
readonly whole: string | undefined;
|
|
481
|
+
/** A tool's answer read whole. */
|
|
482
|
+
readonly wholeAnswer: string | undefined;
|
|
483
|
+
/** The event of the line whose whole text is being read, by its number. */
|
|
484
|
+
readonly reading: number | undefined;
|
|
485
|
+
/** The day it is: a moment of today is said by its hour alone, so a new day draws the lines again. */
|
|
486
|
+
readonly today: string;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/** Whether two things of a session are the same events: a thing is made anew each time the events are read through. */
|
|
490
|
+
function sameItem(a: TalkItem, b: TalkItem): boolean {
|
|
491
|
+
if (a.type === "tool" || b.type === "tool") {
|
|
451
492
|
return (
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
</ol>
|
|
458
|
-
)}
|
|
459
|
-
</>
|
|
493
|
+
a.type === "tool" &&
|
|
494
|
+
b.type === "tool" &&
|
|
495
|
+
a.call === b.call &&
|
|
496
|
+
a.result === b.result &&
|
|
497
|
+
a.permission === b.permission
|
|
460
498
|
);
|
|
461
499
|
}
|
|
462
|
-
|
|
463
|
-
|
|
500
|
+
return a.type === b.type && a.event === b.event;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** Whether two lists of a signal's files name the same files: the record is read again every few seconds. */
|
|
504
|
+
function sameFiles(
|
|
505
|
+
a: readonly SignalFile[] | undefined,
|
|
506
|
+
b: readonly SignalFile[] | undefined,
|
|
507
|
+
): boolean {
|
|
508
|
+
if (a === b) {
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
return (
|
|
512
|
+
a !== undefined &&
|
|
513
|
+
b !== undefined &&
|
|
514
|
+
a.length === b.length &&
|
|
515
|
+
a.every((file, index) => {
|
|
516
|
+
const other = b[index];
|
|
517
|
+
return (
|
|
518
|
+
other !== undefined &&
|
|
519
|
+
file.id === other.id &&
|
|
520
|
+
file.name === other.name &&
|
|
521
|
+
file.size === other.size &&
|
|
522
|
+
file.contentType === other.contentType
|
|
523
|
+
);
|
|
524
|
+
})
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/** Whether a line would be drawn the same: then it is not drawn again. */
|
|
529
|
+
export function sameLine(a: TalkLineProps, b: TalkLineProps): boolean {
|
|
530
|
+
return (
|
|
531
|
+
sameItem(a.one, b.one) &&
|
|
532
|
+
a.hands === b.hands &&
|
|
533
|
+
a.agent === b.agent &&
|
|
534
|
+
a.began === b.began &&
|
|
535
|
+
sameFiles(a.files, b.files) &&
|
|
536
|
+
a.whole === b.whole &&
|
|
537
|
+
a.wholeAnswer === b.wholeAnswer &&
|
|
538
|
+
a.reading === b.reading &&
|
|
539
|
+
a.today === b.today
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/** When the turn an event ends began, by the event's number: the first thing the agent was sent after the turn before. */
|
|
544
|
+
export function turnStarts(events: readonly RestTranscriptEvent[]): ReadonlyMap<number, string> {
|
|
545
|
+
const starts = new Map<number, string>();
|
|
464
546
|
let since: string | undefined;
|
|
465
|
-
for (const event of
|
|
547
|
+
for (const event of events) {
|
|
466
548
|
if (event.kind === "status" && event.data.turn === "completed") {
|
|
467
549
|
if (since !== undefined) {
|
|
468
|
-
|
|
550
|
+
starts.set(event.n, since);
|
|
469
551
|
}
|
|
470
552
|
since = undefined;
|
|
471
553
|
} else if ((event.kind === "person" || event.kind === "wake") && since === undefined) {
|
|
472
554
|
since = event.at;
|
|
473
555
|
}
|
|
474
556
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
557
|
+
return starts;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* What each line of a conversation is given, in order, with the number it is told apart by:
|
|
562
|
+
* its own events, and of everything the view holds only what the line itself shows, so that a
|
|
563
|
+
* line's props say the same until the line would be drawn otherwise.
|
|
564
|
+
*/
|
|
565
|
+
export function talkLinesOf(input: {
|
|
566
|
+
readonly items: readonly TalkItem[];
|
|
567
|
+
readonly hands: TalkHands;
|
|
568
|
+
readonly agent: RestPerson | undefined;
|
|
569
|
+
readonly began: ReadonlyMap<number, string>;
|
|
570
|
+
readonly signalFiles: TranscriptViewProps["signalFiles"];
|
|
571
|
+
readonly whole: WholeTexts;
|
|
572
|
+
/** The session the events are of. */
|
|
573
|
+
readonly of: string | undefined;
|
|
574
|
+
/** The event whose whole text is being read, by its number. */
|
|
575
|
+
readonly reading: number | undefined;
|
|
576
|
+
readonly today: string;
|
|
577
|
+
}): readonly (TalkLineProps & { readonly key: number })[] {
|
|
578
|
+
const { whole, of, reading } = input;
|
|
579
|
+
return input.items.flatMap((one) => {
|
|
580
|
+
const main = one.type === "tool" ? one.call : one.event;
|
|
581
|
+
const answer = one.type === "tool" ? one.result : undefined;
|
|
582
|
+
const first = one.type === "tool" ? (main ?? one.permission ?? answer) : one.event;
|
|
583
|
+
if (first === undefined) {
|
|
584
|
+
return [];
|
|
480
585
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
),
|
|
494
|
-
|
|
495
|
-
|
|
586
|
+
const signal = one.type === "told" ? one.event.data.signal : undefined;
|
|
587
|
+
return [
|
|
588
|
+
{
|
|
589
|
+
key: first.n,
|
|
590
|
+
one,
|
|
591
|
+
hands: input.hands,
|
|
592
|
+
// The account's picture stands beside what it said, and nowhere else: what a
|
|
593
|
+
// sub-agent said is a step, with no picture, and is not drawn again for one.
|
|
594
|
+
agent: one.type === "said" && subagentOf(one.event) === undefined ? input.agent : undefined,
|
|
595
|
+
began: one.type === "tool" ? undefined : input.began.get(one.event.n),
|
|
596
|
+
files: typeof signal === "number" ? input.signalFiles?.(signal) : undefined,
|
|
597
|
+
whole: main === undefined ? undefined : wholeOf(whole, of, main.n),
|
|
598
|
+
wholeAnswer: answer === undefined ? undefined : wholeOf(whole, of, answer.n),
|
|
599
|
+
reading:
|
|
600
|
+
reading !== undefined && (reading === main?.n || reading === answer?.n)
|
|
601
|
+
? reading
|
|
602
|
+
: undefined,
|
|
603
|
+
today: input.today,
|
|
604
|
+
},
|
|
605
|
+
];
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* One line of a conversation. It is drawn again only when its own events, its own texts read
|
|
611
|
+
* whole or what it is handed changed: a session of thousands of events draws one line for an
|
|
612
|
+
* event that arrives, not all of them.
|
|
613
|
+
*/
|
|
614
|
+
const TalkLine = memo(function TalkLine(props: TalkLineProps): ReactNode {
|
|
615
|
+
const all = useWords();
|
|
616
|
+
const words = all.agents.page.live;
|
|
617
|
+
const { one, hands } = props;
|
|
618
|
+
const kinds: Readonly<Record<string, string>> = words.kinds;
|
|
496
619
|
/** The words of an event, whole where they were read whole, with the way to read the rest. */
|
|
497
|
-
const text = (
|
|
498
|
-
|
|
620
|
+
const text = (
|
|
621
|
+
event: RestTranscriptEvent,
|
|
622
|
+
className: string,
|
|
623
|
+
read: string | undefined,
|
|
624
|
+
): ReactNode => {
|
|
499
625
|
const shown = read ?? event.text;
|
|
626
|
+
const readWhole = hands.readWhole;
|
|
500
627
|
return (
|
|
501
628
|
<>
|
|
502
629
|
{shown.length > 0 && <pre className={className}>{shown}</pre>}
|
|
503
630
|
{event.whole !== null && read === undefined && (
|
|
504
631
|
<p className="sc-talk-cut">
|
|
505
632
|
{words.cutAt(formatBytes(event.whole))}{" "}
|
|
506
|
-
{
|
|
633
|
+
{readWhole !== undefined && (
|
|
507
634
|
<Button
|
|
508
635
|
variant="ghost"
|
|
509
636
|
size="sm"
|
|
510
|
-
disabled={
|
|
637
|
+
disabled={props.reading === event.n}
|
|
511
638
|
onClick={() => readWhole(event.n)}
|
|
512
639
|
>
|
|
513
640
|
{words.whole}
|
|
@@ -525,231 +652,350 @@ export function TranscriptView(props: TranscriptViewProps) {
|
|
|
525
652
|
<li key={file.id}>
|
|
526
653
|
<PictureThumb
|
|
527
654
|
picture={{
|
|
528
|
-
src:
|
|
655
|
+
src: hands.fileHref(file.id),
|
|
529
656
|
alt: file.name,
|
|
530
657
|
name: file.name,
|
|
531
658
|
size: file.size,
|
|
532
659
|
}}
|
|
533
|
-
onOpen={
|
|
660
|
+
onOpen={hands.openPicture}
|
|
534
661
|
/>
|
|
535
662
|
</li>
|
|
536
663
|
))}
|
|
537
664
|
</ul>
|
|
538
665
|
);
|
|
539
666
|
const when = (event: RestTranscriptEvent): ReactNode => <Time iso={event.at} precision="clock" />;
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
return null;
|
|
545
|
-
}
|
|
546
|
-
const name = word(one.call?.data[TOOL]) ?? word(one.permission?.data[TOOL]);
|
|
547
|
-
const failed = one.result?.data.error === true;
|
|
548
|
-
const answer = word(one.permission?.data.answer);
|
|
549
|
-
const refused = answer !== undefined && answer !== "allowed";
|
|
550
|
-
const line = firstLine(one.call?.text ?? one.permission?.text ?? one.result?.text ?? "");
|
|
551
|
-
return (
|
|
552
|
-
<li
|
|
553
|
-
key={first.n}
|
|
554
|
-
className={cx(
|
|
555
|
-
"sc-talk-item",
|
|
556
|
-
"sc-talk-step",
|
|
557
|
-
"sc-talk-tool",
|
|
558
|
-
(failed || refused) && "sc-talk-tool-failed",
|
|
559
|
-
)}
|
|
560
|
-
data-n={first.n}
|
|
561
|
-
>
|
|
562
|
-
<details className="sc-talk-tool-fold">
|
|
563
|
-
<summary className="sc-talk-tool-head">
|
|
564
|
-
<code className="sc-talk-tool-name">{name ?? kinds.tool_call}</code>
|
|
565
|
-
<span className="sc-talk-tool-line">{line}</span>
|
|
566
|
-
{failed && <Badge tone="danger">{words.toolFailed}</Badge>}
|
|
567
|
-
{refused && <Badge tone="warning">{words.toolRefused}</Badge>}
|
|
568
|
-
{one.result === undefined && one.call !== undefined && !refused && (
|
|
569
|
-
<span className="sc-muted">{words.toolRunning}</span>
|
|
570
|
-
)}
|
|
571
|
-
{when(first)}
|
|
572
|
-
</summary>
|
|
573
|
-
<div className="sc-talk-tool-body">
|
|
574
|
-
{one.permission !== undefined && (
|
|
575
|
-
<p className="sc-talk-note-line">
|
|
576
|
-
{kinds.permission}
|
|
577
|
-
{answer === undefined ? "" : ` · ${wordOf(words.answers, answer)}`}
|
|
578
|
-
{one.permission.text.length > 0 && ` · ${one.permission.text}`}
|
|
579
|
-
</p>
|
|
580
|
-
)}
|
|
581
|
-
{one.call !== undefined && text(one.call, "sc-talk-code")}
|
|
582
|
-
{one.result !== undefined && text(one.result, "sc-talk-code sc-talk-code-answer")}
|
|
583
|
-
</div>
|
|
584
|
-
</details>
|
|
585
|
-
{pictures(one.result)}
|
|
586
|
-
</li>
|
|
587
|
-
);
|
|
588
|
-
}
|
|
589
|
-
const { event } = one;
|
|
590
|
-
if (event.sealed !== null) {
|
|
591
|
-
return (
|
|
592
|
-
<li key={event.n} className="sc-talk-item sc-talk-note" data-n={event.n}>
|
|
593
|
-
<span className="sc-talk-note-line">
|
|
594
|
-
{words.sealed(
|
|
595
|
-
event.sealed.by === null ? "?" : (event.sealed.by.name ?? event.sealed.by.login),
|
|
596
|
-
event.sealed.reason,
|
|
597
|
-
)}
|
|
598
|
-
</span>
|
|
599
|
-
{when(event)}
|
|
600
|
-
</li>
|
|
601
|
-
);
|
|
667
|
+
if (one.type === "tool") {
|
|
668
|
+
const first = one.call ?? one.permission ?? one.result;
|
|
669
|
+
if (first === undefined) {
|
|
670
|
+
return null;
|
|
602
671
|
}
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
<span className="sc-talk-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
</
|
|
628
|
-
|
|
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>
|
|
672
|
+
const name = word(one.call?.data[TOOL]) ?? word(one.permission?.data[TOOL]);
|
|
673
|
+
const failed = one.result?.data.error === true;
|
|
674
|
+
const answer = word(one.permission?.data.answer);
|
|
675
|
+
const refused = answer !== undefined && answer !== "allowed";
|
|
676
|
+
const line = firstLine(one.call?.text ?? one.permission?.text ?? one.result?.text ?? "");
|
|
677
|
+
// Whose the call is, where a sub-agent made it: read off the line's own events, as
|
|
678
|
+
// everything a line shows is, so that it is drawn again only when they are others.
|
|
679
|
+
const sub = subagentOf(first);
|
|
680
|
+
return (
|
|
681
|
+
<li
|
|
682
|
+
className={cx(
|
|
683
|
+
"sc-talk-item",
|
|
684
|
+
"sc-talk-step",
|
|
685
|
+
"sc-talk-tool",
|
|
686
|
+
(failed || refused) && "sc-talk-tool-failed",
|
|
687
|
+
)}
|
|
688
|
+
data-n={first.n}
|
|
689
|
+
>
|
|
690
|
+
<details className="sc-talk-tool-fold">
|
|
691
|
+
<summary className="sc-talk-tool-head">
|
|
692
|
+
<code className="sc-talk-tool-name">{name ?? kinds.tool_call}</code>
|
|
693
|
+
<span className="sc-talk-tool-line">{line}</span>
|
|
694
|
+
{sub !== undefined && <Badge>{words.subagent(sub)}</Badge>}
|
|
695
|
+
{failed && <Badge tone="danger">{words.toolFailed}</Badge>}
|
|
696
|
+
{refused && <Badge tone="warning">{words.toolRefused}</Badge>}
|
|
697
|
+
{one.result === undefined && one.call !== undefined && !refused && (
|
|
698
|
+
<span className="sc-muted">{words.toolRunning}</span>
|
|
660
699
|
)}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
{
|
|
665
|
-
|
|
666
|
-
|
|
700
|
+
{when(first)}
|
|
701
|
+
</summary>
|
|
702
|
+
<div className="sc-talk-tool-body">
|
|
703
|
+
{one.permission !== undefined && (
|
|
704
|
+
<p className="sc-talk-note-line">
|
|
705
|
+
{kinds.permission}
|
|
706
|
+
{answer === undefined ? "" : ` · ${wordOf(words.answers, answer)}`}
|
|
707
|
+
{one.permission.text.length > 0 && ` · ${one.permission.text}`}
|
|
708
|
+
</p>
|
|
667
709
|
)}
|
|
668
|
-
{
|
|
710
|
+
{one.call !== undefined && text(one.call, "sc-talk-code", props.whole)}
|
|
711
|
+
{one.result !== undefined &&
|
|
712
|
+
text(one.result, "sc-talk-code sc-talk-code-answer", props.wholeAnswer)}
|
|
669
713
|
</div>
|
|
670
|
-
|
|
671
|
-
|
|
714
|
+
</details>
|
|
715
|
+
{pictures(one.result)}
|
|
716
|
+
</li>
|
|
717
|
+
);
|
|
718
|
+
}
|
|
719
|
+
const { event } = one;
|
|
720
|
+
if (event.sealed !== null) {
|
|
721
|
+
return (
|
|
722
|
+
<li className="sc-talk-item sc-talk-note" data-n={event.n}>
|
|
723
|
+
<span className="sc-talk-note-line">
|
|
724
|
+
{words.sealed(
|
|
725
|
+
event.sealed.by === null ? "?" : (event.sealed.by.name ?? event.sealed.by.login),
|
|
726
|
+
event.sealed.reason,
|
|
672
727
|
)}
|
|
673
|
-
</
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
728
|
+
</span>
|
|
729
|
+
{when(event)}
|
|
730
|
+
</li>
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
if (one.type === "told") {
|
|
734
|
+
const number = typeof event.data.signal === "number" ? event.data.signal : undefined;
|
|
735
|
+
const kind = word(event.data.kind);
|
|
736
|
+
const through = word(event.data.agent);
|
|
737
|
+
const unseen = word(event.data.unseen);
|
|
738
|
+
const others = word(event.data.files);
|
|
739
|
+
const listed =
|
|
740
|
+
number === undefined
|
|
741
|
+
? undefined
|
|
742
|
+
: props.files?.filter((file) => !isPicture(file.contentType));
|
|
743
|
+
const who = word(event.data.by) ?? words.kinds.person;
|
|
744
|
+
// An interrupt with no words of its own stopped the turn so that what waited is read: a
|
|
745
|
+
// note of who did, and no message.
|
|
746
|
+
if (
|
|
747
|
+
kind === "interrupt" &&
|
|
748
|
+
event.text.length === 0 &&
|
|
749
|
+
event.files.length === 0 &&
|
|
750
|
+
others === undefined
|
|
751
|
+
) {
|
|
677
752
|
return (
|
|
678
|
-
<li
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
{
|
|
682
|
-
|
|
683
|
-
</div>
|
|
684
|
-
{when(event)}
|
|
753
|
+
<li className="sc-talk-item sc-talk-note" data-n={event.n}>
|
|
754
|
+
<span className="sc-talk-note-line">
|
|
755
|
+
{words.interrupted(who)}
|
|
756
|
+
{when(event)}
|
|
757
|
+
</span>
|
|
685
758
|
</li>
|
|
686
759
|
);
|
|
687
760
|
}
|
|
688
|
-
|
|
761
|
+
const signalFileHref = hands.signalFileHref;
|
|
762
|
+
return (
|
|
763
|
+
<li className="sc-talk-item sc-talk-told" data-n={event.n}>
|
|
764
|
+
<div className="sc-talk-bubble">
|
|
765
|
+
{text(event, "sc-talk-text", props.whole)}
|
|
766
|
+
{pictures(event)}
|
|
767
|
+
{listed !== undefined && listed.length > 0 ? (
|
|
768
|
+
<ul className="sc-chosen-files" aria-label={words.files}>
|
|
769
|
+
{listed.map((file) => (
|
|
770
|
+
<li key={file.id} className="sc-chosen-file">
|
|
771
|
+
{signalFileHref === undefined || number === undefined ? (
|
|
772
|
+
<span>{file.name}</span>
|
|
773
|
+
) : (
|
|
774
|
+
<a href={signalFileHref(number, file.id)} download={file.name}>
|
|
775
|
+
{file.name}
|
|
776
|
+
</a>
|
|
777
|
+
)}{" "}
|
|
778
|
+
<span className="sc-muted">{formatBytes(file.size)}</span>
|
|
779
|
+
</li>
|
|
780
|
+
))}
|
|
781
|
+
</ul>
|
|
782
|
+
) : (
|
|
783
|
+
others !== undefined && (
|
|
784
|
+
<p className="sc-talk-note-line">
|
|
785
|
+
{words.files}: {others}
|
|
786
|
+
</p>
|
|
787
|
+
)
|
|
788
|
+
)}
|
|
789
|
+
{unseen !== undefined && (
|
|
790
|
+
<p className="sc-talk-note-line sc-talk-unseen">{words.unseen(unseen)}</p>
|
|
791
|
+
)}
|
|
792
|
+
</div>
|
|
793
|
+
<div className="sc-talk-meta">
|
|
794
|
+
<span className="sc-talk-who">{who}</span>
|
|
795
|
+
{through !== undefined && <span>{words.through(through)}</span>}
|
|
796
|
+
{kind !== undefined && kind !== "tell" && (
|
|
797
|
+
<Badge>{wordOf(words.signalKinds, kind)}</Badge>
|
|
798
|
+
)}
|
|
799
|
+
{when(event)}
|
|
800
|
+
</div>
|
|
801
|
+
{event.data.unread === true && (
|
|
802
|
+
<p className="sc-talk-note-line sc-talk-unread">{words.unread}</p>
|
|
803
|
+
)}
|
|
804
|
+
</li>
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
if (one.type === "said") {
|
|
808
|
+
const sub = subagentOf(event);
|
|
809
|
+
// What a sub-agent said is a step of the work, and not the agent's word to whoever reads:
|
|
810
|
+
// folded as a thought is, under the sub-agent's name.
|
|
811
|
+
if (sub !== undefined) {
|
|
689
812
|
return (
|
|
690
|
-
<li
|
|
813
|
+
<li className="sc-talk-item sc-talk-step sc-talk-thought" data-n={event.n}>
|
|
691
814
|
<details className="sc-talk-tool-fold">
|
|
692
815
|
<summary className="sc-talk-tool-head">
|
|
693
|
-
<span className="sc-talk-kind">{kinds.
|
|
816
|
+
<span className="sc-talk-kind">{kinds.assistant}</span>
|
|
694
817
|
<span className="sc-talk-tool-line">{firstLine(event.text)}</span>
|
|
818
|
+
<Badge>{words.subagent(sub)}</Badge>
|
|
695
819
|
{when(event)}
|
|
696
820
|
</summary>
|
|
697
|
-
<div className="sc-talk-tool-body">
|
|
821
|
+
<div className="sc-talk-tool-body">
|
|
822
|
+
{text(event, "sc-talk-text", props.whole)}
|
|
823
|
+
{pictures(event)}
|
|
824
|
+
</div>
|
|
698
825
|
</details>
|
|
699
826
|
</li>
|
|
700
827
|
);
|
|
701
828
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
829
|
+
return (
|
|
830
|
+
<li className="sc-talk-item sc-talk-said" data-n={event.n}>
|
|
831
|
+
{props.agent !== undefined && <Avatar person={props.agent} size="sm" />}
|
|
832
|
+
<div className="sc-talk-prose">
|
|
833
|
+
{text(event, "sc-talk-text", props.whole)}
|
|
834
|
+
{pictures(event)}
|
|
835
|
+
</div>
|
|
836
|
+
{when(event)}
|
|
837
|
+
</li>
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
if (one.type === "thought") {
|
|
841
|
+
const sub = subagentOf(event);
|
|
842
|
+
return (
|
|
843
|
+
<li className="sc-talk-item sc-talk-step sc-talk-thought" data-n={event.n}>
|
|
844
|
+
<details className="sc-talk-tool-fold">
|
|
845
|
+
<summary className="sc-talk-tool-head">
|
|
846
|
+
<span className="sc-talk-kind">{kinds.thinking}</span>
|
|
847
|
+
<span className="sc-talk-tool-line">{firstLine(event.text)}</span>
|
|
848
|
+
{sub !== undefined && <Badge>{words.subagent(sub)}</Badge>}
|
|
713
849
|
{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",
|
|
850
|
+
</summary>
|
|
851
|
+
<div className="sc-talk-tool-body">{text(event, "sc-talk-text", props.whole)}</div>
|
|
852
|
+
</details>
|
|
853
|
+
</li>
|
|
722
854
|
);
|
|
723
|
-
|
|
855
|
+
}
|
|
856
|
+
// Where a turn ended: a line, with how long the agent was at it where the record says when it began.
|
|
857
|
+
if (event.kind === "status" && event.data.turn === "completed") {
|
|
858
|
+
const from = props.began;
|
|
859
|
+
const seconds =
|
|
860
|
+
from === undefined
|
|
861
|
+
? undefined
|
|
862
|
+
: Math.max(0, Math.round((Date.parse(event.at) - Date.parse(from)) / 1000));
|
|
724
863
|
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
|
-
>
|
|
864
|
+
<li className="sc-talk-item sc-talk-turn" data-n={event.n}>
|
|
734
865
|
<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>}
|
|
866
|
+
{words.turnDone(Number.isFinite(seconds) ? seconds : undefined)}
|
|
742
867
|
{when(event)}
|
|
743
868
|
</span>
|
|
744
|
-
{lines.length > 1 && text(event, "sc-talk-text sc-talk-text-note")}
|
|
745
|
-
{pictures(event)}
|
|
746
869
|
</li>
|
|
747
870
|
);
|
|
748
|
-
}
|
|
871
|
+
}
|
|
872
|
+
// A wake, a status, an error, and whatever a newer runner calls otherwise: a note between.
|
|
873
|
+
// What the note's own words say already, how a session ended, is not said twice as a fact.
|
|
874
|
+
// The id of the call that started a sub-agent is for joining, and says nothing to a reader.
|
|
875
|
+
const facts = Object.entries(event.data).filter(
|
|
876
|
+
([name, fact]) =>
|
|
877
|
+
fact !== null &&
|
|
878
|
+
name !== "signal" &&
|
|
879
|
+
name !== "kind" &&
|
|
880
|
+
name !== "ended" &&
|
|
881
|
+
name !== "parent",
|
|
882
|
+
);
|
|
883
|
+
const lines = event.text.split("\n").filter((line) => line.trim().length > 0);
|
|
884
|
+
return (
|
|
885
|
+
<li
|
|
886
|
+
className={cx("sc-talk-item", "sc-talk-note", event.kind === "error" && "sc-talk-note-error")}
|
|
887
|
+
data-n={event.n}
|
|
888
|
+
>
|
|
889
|
+
<span className="sc-talk-note-line">
|
|
890
|
+
<span className="sc-talk-kind">{kinds[event.kind] ?? event.kind}</span>
|
|
891
|
+
{facts.map(([name, fact]) => (
|
|
892
|
+
<span key={name} className="sc-talk-fact">
|
|
893
|
+
{wordOf(words.facts, name)} {String(fact)}
|
|
894
|
+
</span>
|
|
895
|
+
))}
|
|
896
|
+
{lines.length === 1 && <span>{lines[0]}</span>}
|
|
897
|
+
{when(event)}
|
|
898
|
+
</span>
|
|
899
|
+
{lines.length > 1 && text(event, "sc-talk-text sc-talk-text-note", props.whole)}
|
|
900
|
+
{pictures(event)}
|
|
901
|
+
</li>
|
|
902
|
+
);
|
|
903
|
+
}, sameLine);
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* A session as a conversation: what the agent was told at the right, as whoever said it wrote
|
|
907
|
+
* it, with the files that came with it; what the agent said at the left, beside its picture; its
|
|
908
|
+
* thoughts folded; a tool's call and what it answered as one row that opens, the steps of a turn
|
|
909
|
+
* close together; a wake, a status and an error as notes between, and a line where a turn
|
|
910
|
+
* ended, with how long it took. A picture opens large over the page. Everything an agent's
|
|
911
|
+
* product printed is text, never markup. Each line is drawn once and again only when it
|
|
912
|
+
* changed, however long the session is.
|
|
913
|
+
*/
|
|
914
|
+
export function TranscriptView(props: TranscriptViewProps) {
|
|
915
|
+
const words = useWords().agents.page.live;
|
|
916
|
+
const shown = usePicture();
|
|
917
|
+
// What was read whole belongs to the session it was read in: the events of another carry the
|
|
918
|
+
// same numbers, and a view that goes on to show them must show none of this.
|
|
919
|
+
const [whole, setWhole] = useState<WholeTexts>(NO_WHOLE);
|
|
920
|
+
const [reading, setReading] = useState<
|
|
921
|
+
{ readonly of: string | undefined; readonly n: number } | undefined
|
|
922
|
+
>(undefined);
|
|
923
|
+
const of = props.of;
|
|
924
|
+
const showing = useRef(of);
|
|
925
|
+
showing.current = of;
|
|
926
|
+
// What the view is given may be made anew by whoever renders it; the lines are handed the
|
|
927
|
+
// same hands each time, which reach for what was given last.
|
|
928
|
+
const given = useRef(props);
|
|
929
|
+
given.current = props;
|
|
930
|
+
const readWhole = useCallback(
|
|
931
|
+
(n: number) => {
|
|
932
|
+
const load = given.current.onReadWhole;
|
|
933
|
+
if (load === undefined) {
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
setReading({ of, n });
|
|
937
|
+
void load(n)
|
|
938
|
+
.then((text) => {
|
|
939
|
+
// An answer that arrives once another session is shown is that session's no more.
|
|
940
|
+
if (showing.current === of) {
|
|
941
|
+
setWhole((current) => withWhole(current, of, n, text));
|
|
942
|
+
}
|
|
943
|
+
})
|
|
944
|
+
.catch(() => undefined)
|
|
945
|
+
.finally(() =>
|
|
946
|
+
setReading((current) =>
|
|
947
|
+
current !== undefined && current.of === of && current.n === n ? undefined : current,
|
|
948
|
+
),
|
|
949
|
+
);
|
|
950
|
+
},
|
|
951
|
+
[of],
|
|
952
|
+
);
|
|
953
|
+
const reads = props.onReadWhole !== undefined;
|
|
954
|
+
const hasSignalFiles = props.signalFileHref !== undefined;
|
|
955
|
+
const openPicture = shown.open;
|
|
956
|
+
const hands = useMemo<TalkHands>(
|
|
957
|
+
() => ({
|
|
958
|
+
fileHref: (fileId) => given.current.fileHref(fileId),
|
|
959
|
+
signalFileHref: hasSignalFiles
|
|
960
|
+
? (number, fileId) => given.current.signalFileHref?.(number, fileId) ?? ""
|
|
961
|
+
: undefined,
|
|
962
|
+
readWhole: reads ? readWhole : undefined,
|
|
963
|
+
openPicture,
|
|
964
|
+
}),
|
|
965
|
+
[hasSignalFiles, reads, readWhole, openPicture],
|
|
966
|
+
);
|
|
967
|
+
const events = props.events;
|
|
968
|
+
const items = useMemo(() => talkOf(events), [events]);
|
|
969
|
+
const began = useMemo(() => turnStarts(events), [events]);
|
|
970
|
+
if (events.length === 0) {
|
|
971
|
+
return (
|
|
972
|
+
<>
|
|
973
|
+
{props.empty ?? null}
|
|
974
|
+
{props.foot !== undefined && props.foot !== null && (
|
|
975
|
+
<ol className="sc-talk" aria-label={words.transcript}>
|
|
976
|
+
{props.foot}
|
|
977
|
+
</ol>
|
|
978
|
+
)}
|
|
979
|
+
</>
|
|
980
|
+
);
|
|
981
|
+
}
|
|
982
|
+
const lines = talkLinesOf({
|
|
983
|
+
items,
|
|
984
|
+
hands,
|
|
985
|
+
agent: props.agent,
|
|
986
|
+
began,
|
|
987
|
+
signalFiles: props.signalFiles,
|
|
988
|
+
whole,
|
|
989
|
+
of,
|
|
990
|
+
reading: reading !== undefined && reading.of === of ? reading.n : undefined,
|
|
991
|
+
today: today(),
|
|
992
|
+
});
|
|
749
993
|
return (
|
|
750
994
|
<>
|
|
751
995
|
<ol className="sc-talk" aria-label={words.transcript}>
|
|
752
|
-
{
|
|
996
|
+
{lines.map(({ key, ...line }) => (
|
|
997
|
+
<TalkLine key={key} {...line} />
|
|
998
|
+
))}
|
|
753
999
|
{props.foot}
|
|
754
1000
|
</ol>
|
|
755
1001
|
<Lightbox picture={shown.shown} onClose={shown.close} />
|