
Channelstack发布本地测试工具,可在本机模拟Slack、GitHub等平台及OpenAI API
来源标题:Channelstack – Your app's whole world, on localhost
Channelstack 推出一款本地测试工具,能在开发者本机复刻 Slack、GitHub、Linear、Notion、Resend、Gmail 和 Discord,并模拟 OpenAI API,用于测试聊天机器人、集成和 AI 智能体。工具支持编写用户脚本和模型回复,让应用走真实代码路径运行,并校验用户可见结果,同时提供签名 webhook、真实负载结构和真实 ID,无需改动应用本身。已发布 npm、PyPI 和 crates.io 版本。
以下正文由 AI 翻译自 Hacker News 最新(原文版权归原站所有),可能存在偏差,重要内容请以原文为准。
为 Slack、GitHub、Linear、Notion、Resend、Gmail 和 Discord 应用以及其背后的模型提供的测试工具
channelstack 在你的机器上重建 Slack、GitHub、Linear、Notion、Resend、Gmail 和 Discord,供你在其上构建的机器人、集成和 AI agent 使用,同时还为你的 agent 模型伪造 OpenAI 的 API。你可以编写人物脚本和模型的回答,让你的应用通过其真实代码路径做出响应,并对用户会看到的内容进行断言。签名 webhook、真实 payload 结构和真实 id,且无需改动应用的任何工作方式。
为什么选择 channelstack?$ npm i -D channelstack npmchannelstack PyPIpytest-channelstack crates.iochannelstack
示例:每个平台一个测试 SlackGitHubLinearNotionResendGmailDiscordOpenAI
deploy.test.tsTypeScriptTSPythonPyRustRs
import { expect, test } from "vitest";test("ships a PR from a Slack DM", async ({ slack }) => { const ana = await slack.createUser({ name: "ana" }); const dm = { to: slack.app }; const msg = await ana.say("@my-agent ship #812 to staging", dm); await expect(msg.thread).toHaveStatusText(/checking CI/); const ask = await msg.thread.waitForReply({ from: "my-agent" }); await expect(ask).toHaveButton("Approve"); await ana.click("Approve", { message: ask }); await expect(msg.thread).toContainText(/Deployed/, { count: 1 }); await expect(msg.thread).not.toContainText("Thinking…");});
slack.localhostReplay
Rmy-agentAPP
Aana 10:42 AM Deploy #812 to staging? CI passed 4 minutes ago, 2 files changed. Deployed #812 to staging in 41s. ana approved it.
status reads “checking CI” the reply has an Approve button “Deployed” appears once, no leftover “Thinking…”
Slack:channelstack 处理的内容 向你的应用投递签名的 message.im 事件 当 Ana 点击 Approve 时发送 block_actions 按用户看到的方式渲染状态行和消息
issues.test.tsTypeScriptTSPythonPyRustRs
test("answers on the issue and ignores itself", async ({ github }) => { const mo = await github.createUser({ login: "mo" }); const repo = await github.createRepo({ collaborators: [mo], apps: [github.app], }); const issue = await mo.openIssue({ title: "500s on Safari" }, { repo }); const comment = await mo.comment("@my-agent take a look?", { issue }); await expect(issue).toHaveCommentFrom("my-agent", { text: /Safari/ }); // the same delivery again must not start a second run await comment.delivery!.redeliver(); await expect(issue).toHaveCommentsFrom("my-agent", { count: 1 });});
github.localhost
acme / webIssues
500s on Safari #1 Reproduced on Safari 17: the session cookie is dropped on the redirect. A fix is on the way.
issue_comment redelivered with the same GUID my-agent commented, mentioning Safari one comment from my-agent after the redelivery
GitHub:channelstack 处理的内容 仅在 apps 中列出的仓库上安装 App 使用 X-Hub-Signature-256 为每次投递签名 像 GitHub 一样,以相同 GUID 重新投递
sessions.test.tsTypeScriptTSPythonPyRustRs
test("Stop ends a working session", async ({ linear }) => { const kai = await linear.createUser({ name: "Kai" }); const team = await linear.createTeam({ key: "ENG", members: [kai] }); const issue = await kai.createIssue({ title: "Migrate cron" }, { team }); const session = await kai.delegate(linear.app, { issue }); await expect(session).toHaveActivity({ type: "thought" }); await kai.stop({ session }); await expect(session).toHaveSessionState("complete");});
linear.localhost
Engineering › ENG-1
Migrate cron Reading the cron definitions in billing/cron.ts…
the session shows a thought after Stop, the session is complete
Linear:channelstack 处理的内容 Linear 当前形态的 AgentSessionEvent 携带停止信号的 prompted 事件 每个 GraphQL 响应都按 Linear 的 schema 校验
comments.test.tsTypeScriptTSPythonPyRustRs
test("answers a mention in the same discussion", async ({ notion }) => { const ana = await notion.createUser({ name: "Ana" }); const page = await notion.createPage({ title: "Roadmap", content: "# Q1\n- ship search", connections: [notion.app], }); const comment = await ana.comment("@my-agent summarize", { page }); const thread = comment.discussion; await expect(thread).toHaveCommentFrom("my-agent", { text: /search/ }); await expect(thread).toHaveCommentsFrom("my-agent", { count: 1 });});
notion.localhost
RoadmapShare···
Roadmap
my-agent answered in the same discussion exactly one comment from my-agent
Notion:channelstack 处理的内容 像 Notion 一样处理连接及其继承关系 使用 X-Notion-Signature 签名的 webhook 按 Notion 的方式批量处理 page.content_updated
refund.test.tsTypeScriptTSPythonPyRustRs
test("answers once, even when Resend retries", async ({ resend }) => { const ana = await resend.createUser({ name: "Ana" }); const email = await ana.send({ to: [resend.app], subject: "Refund", text: "Where is my refund for #4411?", }); const answer = await email.thread.waitForReply({ from: "my-agent" }); expect(answer.text).toMatch(/refund/i); // Resend delivers the webhook again, with the same svix-id await email.delivery!.redeliver(); await expect(email.thread).toHaveRepliesFrom("my-agent", { count: 1 });});
resend.localhost
Refund
my-agent my-agent@acme.resend.app9:14 AM Your refund for #4411 went out on Monday. It reaches your card within 5 days.
Resend delivered email.received again, with the same svix-id my-agent answered about the refund, in Ana’s thread still one answer after Resend’s retry
Resend:channelstack 处理的内容 投递以 Svix 方式签名的 email.received 通过接收 API 将邮件返回 按 Resend 的调度重试,使用相同的 svix-id
invoice.test.tsTypeScriptTSPythonPyRustRs
(原文较长,此处译出前 6000 字,完整内容请点「打开原文」。)
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。
