Agent Chat

以聊天呈现的同一场智能体对话:你的消息位于强调色气泡中,智能体显示在各自头像下,工具活动低调呈现,附带实时工作状态和输入框。可与 Terminal 逐个部件互换。另有带答案行和数字快捷键的智能体提问,以及可折叠的“思考了 N 秒”行。

可用框架
  • Angular: 可用
  • Vue: 可用
  • React: 可用
  • React Native: 暂不可用

用法

Run started · fix-flaky-tests
Youto Lead
The checkout tests fail about once in ten runs. Find out why and fix it.
Lead
On it. I'll rerun the suite to catch the failure first.
Lead
Ran npm test -- checkout --repeat 20 --reporter=verbose --coverage=false --bail=false
Exit code 1
✕ checkout › applies the discount once (2 of 20 runs)
    expected 90, received 81
    at discount.spec.ts:42:18
Explore
Read 2 files
Lead
Edited src/checkout/discount.ts
+3−1
Lead
Ran npm test -- checkout --repeat 20
ok · 41s
Lead

Fixed: 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.ts covers the slow path.

20 of 20 runs pass.

Done · 6 turns · 1m 12s
LeadNeeds you

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.

12to answer/commands⌘Kanywhere

Lead is waiting for you

导入

ts
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.

选择器
sone-agent-chat

SoneAgentChatComposerActionsDirective指令

Buttons and selects at the end of the composer (model, send).

选择器
[soneAgentChatComposerActions]

SoneAgentChatComposerComponent组件

`<sone-agent-chat-composer>` — the message box around a `textarea[soneAgentChatComposerInput]`.

选择器
sone-agent-chat-composer
输出
名称类型
submitted

Fires when the person sends (Enter, or a submit button inside).

void

SoneAgentChatComposerInputDirective指令

The composer's field: Enter sends, Shift+Enter breaks the line.

选择器
textarea[soneAgentChatComposerInput]
输入
名称类型 默认值
ariaLabel

The 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.

选择器
sone-agent-chat-divider
输入
名称类型 默认值
timeAgentTime | nullnull
toneAgentTone"default"

SoneAgentChatLogComponent组件

`<sone-agent-chat-log>` — the scrolling `role="log"`: follows the newest message, offers “Jump to newest”.

选择器
sone-agent-chat-log
输入
名称类型 默认值
label

The log's accessible name.

string | nullnull
follow

Stay pinned to the newest line while the reader is there.

booleantrue

SoneAgentChatMessageAvatarDirective指令

What stands in a message's avatar instead of the speaker's initials, such as the mark of the app that spoke.

选择器
[soneAgentChatMessageAvatar]

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.

选择器
sone-agent-chat-message
输入
名称类型 默认值
from

Who 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"
speaker

The speaker's name; the person's defaults to “You”.

string | nullnull
to

Who the person (or an agent) spoke to: “You → Lead”.

string | nullnull
time

When it was said: a `Date`, epoch milliseconds or an ISO string.

AgentTime | nullnull
tone

`danger` for a failed command, `success` / `warning` for an outcome.

AgentTone"default"
glyph

The mark in front of the text; `❯` for the person, `›` for activity. `""` hides it.

string | nullnull
hue

A speaker colour, `1`–`8` (the chart hues), so each agent keeps its own.

number | nullnull
note

A 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 | nullnull

SoneAgentChatMessageDetailDirective指令

Content under a message: its expanded body or a command's output.

选择器
[soneAgentChatMessageDetail]

SoneAgentChatMessageMetaDirective指令

Trailing content of a message: a metric, a badge, a “show more” toggle.

选择器
[soneAgentChatMessageMeta]

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.

选择器
sone-agent-chat-question
输入
名称类型 默认值
who

Who asks: its name, shown with its initials.

string | nullnull
time

When it asked.

AgentTime | nullnull
question

The question itself.

string""
reason

Why it asks, in one line.

string | nullnull
options

The answers to pick from (keys `1`…`9`).

readonly AgentQuestionOption[][]
placeholder

The own-answer field's placeholder (“Or write your own answer…”).

string | nullnull
hue

A speaker colour, `1`–`8` (the chart hues), as on `<sone-agent-chat-message>`.

number | nullnull
hints

The key hints row under the field.

booleantrue
输出
名称类型
answer

The answer: the picked option's label, or the trimmed text written in the field.

string

SoneAgentChatStatusActionsDirective指令

Actions next to the status (Interrupt, Stop).

选择器
[soneAgentChatStatusActions]

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).

选择器
sone-agent-chat-status
输入
名称类型 默认值
stateAgentState"idle"
speaker

Who it is about: “Lead is working”.

string | nullnull
since

When the current state began; a running time is shown while the agent is active.

AgentTime | nullnull
label

Replaces the built-in sentence.

string | nullnull
hue

The speaker colour, `1`–`8`.

number | nullnull

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.

选择器
sone-agent-chat-thought
输入
名称类型 默认值
seconds

How long the agent thought, in whole seconds.

number0
open双向

The reasoning panel shows (two-way: `[(open)]`).

booleanfalse