Agent Chat
同じエージェントとの会話をチャットとして表示:自分のメッセージはアクセントの吹き出し、エージェントはアバターの下、控えめなツール操作、作業中を示すライブステータス、入力欄。Terminal とパーツ単位で入れ替えられます。回答の行と数字キーを備えたエージェントの質問、折りたたまれた「N 秒間思考」の行も含みます。
Angular: 対応 Vue: 対応 React: 対応 React Native: 未対応
使い方
Exit code 1
✕ checkout › applies the discount once (2 of 20 runs)
expected 90, received 81
at discount.spec.ts:42:18Fixed: the discount was applied twice.
applyDiscount()ran in a promise nobody awaited, so a slow run applied it again.- It is awaited now, and
discount.spec.tscovers the slow path.
20 of 20 runs pass.
Fix the orders that already got the double discount, or ship the fix now?
The fix is right. Orders placed before today may already hold a second discount.
<sone-agent-chat style="height: 560px; width: 100%">
<sone-agent-chat-log>
<sone-agent-chat-divider [time]="at(0)">Run started · fix-flaky-tests</sone-agent-chat-divider>
<sone-agent-chat-message from="user" to="Lead" [time]="at(1)">
The checkout tests fail about once in ten runs. Find out why and fix it.
</sone-agent-chat-message>
<sone-agent-chat-message speaker="Lead" [hue]="3" [time]="at(2)">
On it. I'll rerun the suite to catch the failure first.
</sone-agent-chat-message>
<sone-agent-chat-message kind="activity" speaker="Lead" [hue]="3" glyph="$" tone="danger" [time]="at(3)">
Ran npm test -- checkout --repeat 20 --reporter=verbose --coverage=false --bail=false
<button soneBtn soneAgentChatMessageMeta type="button" variant="outline" size="icon-xs"
[attr.aria-expanded]="open()" [attr.aria-label]="open() ? 'Hide output' : 'Show output'"
(click)="open.set(!open())">{{ open() ? "−" : "+" }}</button>
@if (open()) {
<pre soneAgentChatMessageDetail>Exit code 1
✕ checkout › applies the discount once (2 of 20 runs)
expected 90, received 81
at discount.spec.ts:42:18</pre>
}
</sone-agent-chat-message>
<sone-agent-chat-message kind="activity" speaker="Explore" [hue]="5" [time]="at(4)">Read 2 files</sone-agent-chat-message>
<sone-agent-chat-message kind="activity" speaker="Lead" [hue]="3" [time]="at(5)">
Edited src/checkout/discount.ts
<span soneAgentChatMessageMeta><ins>+3</ins> <del>−1</del></span>
</sone-agent-chat-message>
<sone-agent-chat-message kind="activity" speaker="Lead" [hue]="3" glyph="$" [time]="at(6)">
Ran npm test -- checkout --repeat 20
<span soneAgentChatMessageMeta>ok · 41s</span>
</sone-agent-chat-message>
<sone-agent-chat-message speaker="Lead" [hue]="3" [time]="at(7)">
<sone-agent-chat-thought [seconds]="12">
Two of twenty runs failed with 81 instead of 90, so the discount ran twice. Only a slow
run does that, which points at a promise nobody awaits.
</sone-agent-chat-thought>
<p><strong>Fixed: the discount was applied twice.</strong></p>
<ul>
<li><code>applyDiscount()</code> ran in a promise nobody awaited, so a slow run applied it again.</li>
<li>It is awaited now, and <code>discount.spec.ts</code> covers the slow path.</li>
</ul>
<p>20 of 20 runs pass.</p>
</sone-agent-chat-message>
<sone-agent-chat-divider tone="success" [time]="at(8)">Done · 6 turns · 1m 12s</sone-agent-chat-divider>
@if (asking()) {
<sone-agent-chat-question who="Lead" [hue]="3" [time]="at(9)"
question="Fix the orders that already got the double discount, or ship the fix now?"
reason="The fix is right. Orders placed before today may already hold a second discount."
[options]="options" (answer)="reply($event)" />
}
@for (e of sent(); track e.id) {
<sone-agent-chat-message [from]="e.from" [kind]="e.kind" [glyph]="e.glyph ?? null"
[speaker]="e.from === 'user' ? null : 'Lead'" [to]="e.from === 'user' ? 'Lead' : null"
[hue]="3" [time]="at(10 + e.id)">
{{ e.text }}
@if (e.meta) { <span soneAgentChatMessageMeta>{{ e.meta }}</span> }
</sone-agent-chat-message>
}
</sone-agent-chat-log>
<sone-agent-chat-status [state]="state()" speaker="Lead" [hue]="3" [since]="since()">
{{ doing() }}
@if (state() === "working") {
<button soneBtn soneAgentChatStatusActions type="button" variant="outline" size="sm"
(click)="finish('idle')">Interrupt</button>
}
</sone-agent-chat-status>
<sone-agent-chat-composer (submitted)="send()">
<textarea soneAgentChatComposerInput placeholder="Message the lead…"
[value]="draft()" (input)="draft.set($any($event.target).value)"></textarea>
<button soneBtn soneAgentChatComposerActions type="submit" size="sm"
[disabled]="!draft().trim()">Send</button>
</sone-agent-chat-composer>
</sone-agent-chat>インポート
import {
SoneAgentChatComponent,
SoneAgentChatComposerActionsDirective,
SoneAgentChatComposerComponent,
SoneAgentChatComposerInputDirective,
SoneAgentChatDividerComponent,
SoneAgentChatLogComponent,
SoneAgentChatMessageAvatarDirective,
SoneAgentChatMessageComponent,
SoneAgentChatMessageDetailDirective,
SoneAgentChatMessageMetaDirective,
SoneAgentChatQuestionComponent,
SoneAgentChatStatusActionsDirective,
SoneAgentChatStatusComponent,
SoneAgentChatThoughtComponent,
} from "@surface-one/angular/agent-chat";API リファレンス
SoneAgentChatComponentコンポーネント
`<sone-agent-chat>` — the frame of an agent conversation shown as a chat: the thread (`<sone-agent-chat-log>`), the agent's live status (`<sone-agent-chat-status>`) and the composer (`<sone-agent-chat-composer>`). Every part takes the same inputs as its `<sone-terminal>` twin, so an app switches between the two views without touching its data.
SoneAgentChatComposerActionsDirectiveディレクティブ
Buttons and selects at the end of the composer (model, send).
SoneAgentChatComposerComponentコンポーネント
`<sone-agent-chat-composer>` — the message box around a `textarea[soneAgentChatComposerInput]`.
| 名前 | 型 |
|---|---|
submittedFires when the person sends (Enter, or a submit button inside). | void |
SoneAgentChatComposerInputDirectiveディレクティブ
The composer's field: Enter sends, Shift+Enter breaks the line.
| 名前 | 型 | デフォルト |
|---|---|---|
ariaLabelThe field's accessible name (it has no visible label). | string | null | $localize`:The prompt field of an agent conversation:Message` |
SoneAgentChatDividerComponentコンポーネント
`<sone-agent-chat-divider>` — a run boundary or a turn summary across the thread.
| 名前 | 型 | デフォルト |
|---|---|---|
time | AgentTime | null | null |
tone | AgentTone | "default" |
SoneAgentChatLogComponentコンポーネント
`<sone-agent-chat-log>` — the scrolling `role="log"`: follows the newest message, offers “Jump to newest”.
| 名前 | 型 | デフォルト |
|---|---|---|
labelThe log's accessible name. | string | null | null |
followStay pinned to the newest line while the reader is there. | boolean | true |
SoneAgentChatMessageAvatarDirectiveディレクティブ
What stands in a message's avatar instead of the speaker's initials, such as the mark of the app that spoke.
SoneAgentChatMessageComponentコンポーネント
`<sone-agent-chat-message>` — one entry. The person's messages are accent bubbles on the right; an agent's sit on the left under its avatar, name and time; `kind="activity"` is a quiet line of tool work with no bubble. `[soneAgentChatMessageMeta]` sits at the end of the bubble, `[soneAgentChatMessageDetail]` under it (an expanded body, a command's output), and `[soneAgentChatMessageAvatar]` replaces the initials in the avatar.
| 名前 | 型 | デフォルト |
|---|---|---|
fromWho wrote it: the person (`user`), an `agent`, or the `system`. | AgentFrom | "agent" |
kind`message` is something said; `activity` is a quiet line of tool work. | AgentEntryKind | "message" |
speakerThe speaker's name; the person's defaults to “You”. | string | null | null |
toWho the person (or an agent) spoke to: “You → Lead”. | string | null | null |
timeWhen it was said: a `Date`, epoch milliseconds or an ISO string. | AgentTime | null | null |
tone`danger` for a failed command, `success` / `warning` for an outcome. | AgentTone | "default" |
glyphThe mark in front of the text; `❯` for the person, `›` for activity. `""` hides it. | string | null | null |
hueA speaker colour, `1`–`8` (the chart hues), so each agent keeps its own. | number | null | null |
noteA quiet note about the entry, such as the model that wrote it: after the time in the chat, in front of the text in the terminal. | string | null | null |
SoneAgentChatMessageDetailDirectiveディレクティブ
Content under a message: its expanded body or a command's output.
SoneAgentChatMessageMetaDirectiveディレクティブ
Trailing content of a message: a metric, a badge, a “show more” toggle.
SoneAgentChatQuestionComponentコンポーネント
`<sone-agent-chat-question>` — a question an agent asks in the thread and waits on: who asks (`who`, `hue`, `time`) with a “Needs you” badge, the `question` with its one-line `reason`, the `options` as rows that say what each leads to, and a field for your own words. Keys `1`…`9` pick an answer while the field is empty; Enter in the field sends what you wrote. `answer` emits the chosen option's label or your trimmed text.
| 名前 | 型 | デフォルト |
|---|---|---|
whoWho asks: its name, shown with its initials. | string | null | null |
timeWhen it asked. | AgentTime | null | null |
questionThe question itself. | string | "" |
reasonWhy it asks, in one line. | string | null | null |
optionsThe answers to pick from (keys `1`…`9`). | readonly AgentQuestionOption[] | [] |
placeholderThe own-answer field's placeholder (“Or write your own answer…”). | string | null | null |
hueA speaker colour, `1`–`8` (the chart hues), as on `<sone-agent-chat-message>`. | number | null | null |
hintsThe key hints row under the field. | boolean | true |
| 名前 | 型 |
|---|---|
answerThe answer: the picked option's label, or the trimmed text written in the field. | string |
SoneAgentChatStatusActionsDirectiveディレクティブ
Actions next to the status (Interrupt, Stop).
SoneAgentChatStatusComponentコンポーネント
`<sone-agent-chat-status>` — what the agent is doing right now, under the thread: its avatar (ringed while busy), an animated mark, the sentence (“Lead is working”), the running time and a slot for actions (`[soneAgentChatStatusActions]`, e.g. Interrupt).
| 名前 | 型 | デフォルト |
|---|---|---|
state | AgentState | "idle" |
speakerWho it is about: “Lead is working”. | string | null | null |
sinceWhen the current state began; a running time is shown while the agent is active. | AgentTime | null | null |
labelReplaces the built-in sentence. | string | null | null |
hueThe speaker colour, `1`–`8`. | number | null | null |
SoneAgentChatThoughtComponentコンポーネント
`<sone-agent-chat-thought>` — an agent's reasoning, folded into a quiet row (“Thought for 12 seconds ›”) that opens a panel with a rule along its edge. Put it first in an agent's `<sone-agent-chat-message>`; the projected content is the reasoning. `open` is two-way.
| 名前 | 型 | デフォルト |
|---|---|---|
secondsHow long the agent thought, in whole seconds. | number | 0 |
open双方向The reasoning panel shows (two-way: `[(open)]`). | boolean | false |