runtime by assistant-ui/skills
npx skills add https://github.com/assistant-ui/skills --skill runtime请始终查阅 assistant-ui.com/llms.txt 以获取最新的 API 信息。
AssistantRuntime
├── ThreadListRuntime (thread management)
│ ├── ThreadListItemRuntime (per-thread item)
│ └── ...
└── ThreadRuntime (current thread)
├── ComposerRuntime (input state)
└── MessageRuntime[] (per-message)
└── MessagePartRuntime[] (per-content-part)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
import { useAui, useAuiState, useAuiEvent } from "@assistant-ui/react";
function ChatControls() {
const api = useAui();
const messages = useAuiState(s => s.thread.messages);
const isRunning = useAuiState(s => s.thread.isRunning);
useAuiEvent("composer.send", (e) => {
console.log("Sent in thread:", e.threadId);
});
return (
<div>
<button onClick={() => api.thread().append({
role: "user",
content: [{ type: "text", text: "Hello!" }],
})}>
Send
</button>
{isRunning && (
<button onClick={() => api.thread().cancelRun()}>Cancel</button>
)}
</div>
);
}
const api = useAui();
const thread = api.thread();
// 追加消息
thread.append({ role: "user", content: [{ type: "text", text: "Hello" }] });
// 取消生成
thread.cancelRun();
// 获取当前状态
const state = thread.getState(); // { messages, isRunning, ... }
const message = api.thread().message(0); // 通过索引
message.edit({ role: "user", content: [{ type: "text", text: "Updated" }] });
message.reload();
useAuiEvent("thread.runStart", () => {});
useAuiEvent("thread.runEnd", () => {});
useAuiEvent("composer.send", ({ threadId }) => {
console.log("Sent in thread:", threadId);
});
useAuiEvent("thread.modelContextUpdate", () => {});
const caps = useAuiState(s => s.thread.capabilities);
// { cancel, edit, reload, copy, speak, attachments }
// 获取消息
const messages = useAuiState(s => s.thread.messages);
// 检查运行状态
const isRunning = useAuiState(s => s.thread.isRunning);
// 追加消息
api.thread().append({ role: "user", content: [{ type: "text", text: "Hi" }] });
// 取消生成
api.thread().cancelRun();
// 编辑消息
api.thread().message(index).edit({ ... });
// 重新加载消息
api.thread().message(index).reload();
"无法读取未定义的属性"
AssistantRuntimeProvider 内部调用状态未更新
useAuiState 的选择器以防止不必要的重新渲染消息数组为空
每周安装量
483
代码仓库
GitHub 星标数
7
首次出现
2026年1月21日
安全审计
安装于
codex392
opencode383
gemini-cli375
github-copilot365
amp314
kimi-cli310
Always consultassistant-ui.com/llms.txt for latest API.
AssistantRuntime
├── ThreadListRuntime (thread management)
│ ├── ThreadListItemRuntime (per-thread item)
│ └── ...
└── ThreadRuntime (current thread)
├── ComposerRuntime (input state)
└── MessageRuntime[] (per-message)
└── MessagePartRuntime[] (per-content-part)
import { useAui, useAuiState, useAuiEvent } from "@assistant-ui/react";
function ChatControls() {
const api = useAui();
const messages = useAuiState(s => s.thread.messages);
const isRunning = useAuiState(s => s.thread.isRunning);
useAuiEvent("composer.send", (e) => {
console.log("Sent in thread:", e.threadId);
});
return (
<div>
<button onClick={() => api.thread().append({
role: "user",
content: [{ type: "text", text: "Hello!" }],
})}>
Send
</button>
{isRunning && (
<button onClick={() => api.thread().cancelRun()}>Cancel</button>
)}
</div>
);
}
const api = useAui();
const thread = api.thread();
// Append message
thread.append({ role: "user", content: [{ type: "text", text: "Hello" }] });
// Cancel generation
thread.cancelRun();
// Get current state
const state = thread.getState(); // { messages, isRunning, ... }
const message = api.thread().message(0); // By index
message.edit({ role: "user", content: [{ type: "text", text: "Updated" }] });
message.reload();
useAuiEvent("thread.runStart", () => {});
useAuiEvent("thread.runEnd", () => {});
useAuiEvent("composer.send", ({ threadId }) => {
console.log("Sent in thread:", threadId);
});
useAuiEvent("thread.modelContextUpdate", () => {});
const caps = useAuiState(s => s.thread.capabilities);
// { cancel, edit, reload, copy, speak, attachments }
// Get messages
const messages = useAuiState(s => s.thread.messages);
// Check running state
const isRunning = useAuiState(s => s.thread.isRunning);
// Append message
api.thread().append({ role: "user", content: [{ type: "text", text: "Hi" }] });
// Cancel generation
api.thread().cancelRun();
// Edit message
api.thread().message(index).edit({ ... });
// Reload message
api.thread().message(index).reload();
"Cannot read property of undefined"
AssistantRuntimeProviderState not updating
useAuiState to prevent unnecessary re-rendersMessages array empty
Weekly Installs
483
Repository
GitHub Stars
7
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex392
opencode383
gemini-cli375
github-copilot365
amp314
kimi-cli310
AI 代码实施计划编写技能 | 自动化开发任务分解与 TDD 流程规划工具
41,400 周安装