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