channelstack 0.0.0-stage → 0.1.1

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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -2
  3. package/bin/channelstack.mjs +31 -0
  4. package/dist/integrations/checks/checks.test.d.ts +1 -0
  5. package/dist/integrations/checks/checks.test.js +31 -0
  6. package/dist/integrations/checks/index.d.ts +69 -0
  7. package/dist/integrations/checks/index.js +578 -0
  8. package/dist/integrations/matchers-core/index.d.ts +138 -0
  9. package/dist/integrations/matchers-core/index.js +458 -0
  10. package/dist/integrations/matchers-core/matchers.test.d.ts +1 -0
  11. package/dist/integrations/matchers-core/matchers.test.js +159 -0
  12. package/dist/integrations/vitest/global-setup.d.ts +3 -0
  13. package/dist/integrations/vitest/global-setup.js +19 -0
  14. package/dist/integrations/vitest/index.d.ts +80 -0
  15. package/dist/integrations/vitest/index.js +42 -0
  16. package/dist/integrations/vitest/plugin.test.d.ts +1 -0
  17. package/dist/integrations/vitest/plugin.test.js +19 -0
  18. package/dist/integrations/vitest/refused.d.ts +22 -0
  19. package/dist/integrations/vitest/refused.js +49 -0
  20. package/dist/integrations/vitest/setup.d.ts +1 -0
  21. package/dist/integrations/vitest/setup.js +109 -0
  22. package/dist/sdks/typescript/client.d.ts +13 -0
  23. package/dist/sdks/typescript/client.js +11 -0
  24. package/dist/sdks/typescript/generated/channels.d.ts +24 -0
  25. package/dist/sdks/typescript/generated/channels.js +2 -0
  26. package/dist/sdks/typescript/generated/index.d.ts +2747 -0
  27. package/dist/sdks/typescript/generated/index.js +3039 -0
  28. package/dist/sdks/typescript/runtime/client.d.ts +47 -0
  29. package/dist/sdks/typescript/runtime/client.js +69 -0
  30. package/dist/sdks/typescript/runtime/credentials.d.ts +7 -0
  31. package/dist/sdks/typescript/runtime/credentials.js +20 -0
  32. package/dist/sdks/typescript/runtime/duration.d.ts +4 -0
  33. package/dist/sdks/typescript/runtime/duration.js +13 -0
  34. package/dist/sdks/typescript/runtime/files.d.ts +32 -0
  35. package/dist/sdks/typescript/runtime/files.js +45 -0
  36. package/dist/sdks/typescript/runtime/launcher.d.ts +24 -0
  37. package/dist/sdks/typescript/runtime/launcher.js +121 -0
  38. package/dist/sdks/typescript/runtime/transport.d.ts +43 -0
  39. package/dist/sdks/typescript/runtime/transport.js +95 -0
  40. package/dist/sdks/typescript/runtime/wait.d.ts +82 -0
  41. package/dist/sdks/typescript/runtime/wait.js +136 -0
  42. package/dist/sdks/typescript/types.d.ts +72 -0
  43. package/dist/sdks/typescript/types.js +1 -0
  44. package/package.json +80 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Christian Bromann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # Temporary Holding Version
1
+ # channelstack
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A test harness for the apps and agents you build for Slack, GitHub, Linear, Notion, Resend and Gmail. channelstack runs fake versions of those platforms on your machine. Your tests script the people, your app answers through its real code path, and you check what a person would see.
4
+
5
+ This package has the `channelstack` CLI and server, the TypeScript SDK, the Vitest plugin (`channelstack/vitest`) and the standard behaviour checks (`channelstack/checks`). The server binary for your platform comes with it, as an optional dependency (`@channelstack/server-<platform>-<arch>`).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm i -D channelstack
11
+ ```
12
+
13
+ It needs Node 22 or later.
14
+
15
+ ## A first test
16
+
17
+ ```ts
18
+ import { expect, test } from "vitest";
19
+
20
+ test("a mention gets one reply, in the thread", async ({ slack }) => {
21
+ const ana = await slack.createUser({ name: "Ana" });
22
+ const channel = await slack.createChannel({ participants: [ana, slack.app] });
23
+
24
+ const msg = await ana.say("@my-agent summarize the incidents", { channel });
25
+
26
+ await expect(msg.thread).toHaveReplyFrom("my-agent", { text: /summarize the incidents/ });
27
+ await expect(msg.thread).toHaveRepliesFrom(slack.app, { count: 1 });
28
+ await expect(channel).not.toHaveChannelMessageFrom("my-agent");
29
+ });
30
+ ```
31
+
32
+ Start the server with `npx channelstack`, point your app at the fake platforms with `npx channelstack env`, and add the plugin to your Vitest config. [Getting started](https://channelstack.dev/docs/getting-started) walks through it.
33
+
34
+ ## Without a test framework
35
+
36
+ ```ts
37
+ import { connect } from "channelstack/client";
38
+
39
+ await using client = await connect({ mode: "auto" });
40
+ await using session = await client.openSession({ name: "example" });
41
+
42
+ const slack = await session.slack();
43
+ const ana = await slack.createUser({ name: "Ana" });
44
+ const channel = await slack.createChannel({ participants: [ana, slack.app] });
45
+
46
+ const msg = await ana.say("@my-agent hi", { channel });
47
+ const reply = await msg.thread.waitForReply({ from: "my-agent" });
48
+ console.log(reply.text);
49
+ ```
50
+
51
+ ## Links
52
+
53
+ - [Documentation](https://channelstack.dev/docs)
54
+ - [The SDKs](https://channelstack.dev/docs/reference/sdks), also for [Python](https://pypi.org/project/channelstack/) and [Rust](https://crates.io/crates/channelstack)
55
+ - [Source, issues and changelog](https://github.com/christian-bromann/channelstack)
56
+
57
+ MIT licensed.
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ // The `channelstack` command: runs the server binary installed for this platform, with the same arguments.
3
+ import { spawn } from "node:child_process";
4
+
5
+ import { resolveServerBinary } from "../dist/sdks/typescript/runtime/launcher.js";
6
+
7
+ let binary;
8
+ try {
9
+ binary = resolveServerBinary();
10
+ } catch (error) {
11
+ console.error(error instanceof Error ? error.message : error);
12
+ process.exit(1);
13
+ }
14
+
15
+ const child = spawn(binary, process.argv.slice(2), { stdio: "inherit" });
16
+
17
+ // Stopping this wrapper must stop the server, so it can remove its token file and its *.localhost names.
18
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
19
+ process.on(signal, () => child.kill(signal));
20
+ }
21
+
22
+ child.on("error", (error) => {
23
+ console.error(`channelstack: could not run ${binary}: ${error.message}`);
24
+ process.exit(1);
25
+ });
26
+ child.on("exit", (code, signal) => {
27
+ // End the way the server did, so a caller sees its exit code or the signal that stopped it.
28
+ if (!signal) process.exit(code ?? 1);
29
+ process.removeAllListeners(signal);
30
+ process.kill(process.pid, signal);
31
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,31 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { GITHUB_CHECKS, githubChecks, LINEAR_CHECKS, linearChecks, NOTION_CHECKS, notionChecks, SLACK_CHECKS, slackChecks, } from "./index.js";
3
+ // Registered and never run: the test below reads which checks each call put in its suite.
4
+ describe.skip("registered", () => {
5
+ slackChecks({ app: "my-agent" });
6
+ linearChecks({ app: "my-agent" });
7
+ notionChecks({ app: "my-agent" });
8
+ });
9
+ /** The ids in the names of the tests under a task. */
10
+ const idsUnder = (task) => "tasks" in task ? task.tasks.flatMap(idsUnder) : [/\[([a-z.-]+)\]$/.exec(task.name)?.[1] ?? ""];
11
+ describe("skipping a check", () => {
12
+ test("an id no check has is a mistake, and the message lists the ids there are", () => {
13
+ expect(() => githubChecks({ app: "my-agent", skip: ["github.nope"] })).toThrow(`No check is called "github.nope". The checks are: ${GITHUB_CHECKS.join(", ")}`);
14
+ expect(() => slackChecks({ app: "my-agent", skip: ["slack.nope", "slack.ack"] })).toThrow(`No check is called "slack.nope". The checks are: ${SLACK_CHECKS.join(", ")}`);
15
+ });
16
+ });
17
+ describe("what is registered", () => {
18
+ test("a check whose option isn't given is left out; every other check is there, once", ({ task }) => {
19
+ const registered = task.file.tasks.find((entry) => entry.name === "registered");
20
+ if (!registered)
21
+ throw new Error("The registered checks are missing");
22
+ const ids = idsUnder(registered);
23
+ // `streamPrompt` and `approval` weren't given: the four checks that need them aren't there.
24
+ const needOptions = ["slack.stream-stop", "slack.stop", "slack.click-unauthorized", "slack.double-click"];
25
+ expect(ids).toEqual([
26
+ ...SLACK_CHECKS.filter((id) => !needOptions.includes(id)),
27
+ ...LINEAR_CHECKS,
28
+ ...NOTION_CHECKS,
29
+ ]);
30
+ });
31
+ });
@@ -0,0 +1,69 @@
1
+ import type { Duration } from "../../sdks/typescript/client.ts";
2
+ export interface ChecksOptions {
3
+ /** The app's name, as people mention it. */
4
+ app: string;
5
+ /** Text that makes the agent reply. Default: `@<app> hello`. */
6
+ prompt?: string;
7
+ /**
8
+ * Text that makes the agent stream a longer answer, in a DM. Without it the stream and Stop
9
+ * checks are left out: not every agent streams.
10
+ */
11
+ streamPrompt?: string;
12
+ /**
13
+ * Text that makes the agent ask for an approval, and the label of the button it shows. A
14
+ * workspace admin may press it; anyone else may not. Without it the click checks are left out.
15
+ */
16
+ approval?: {
17
+ prompt: string;
18
+ button: string;
19
+ };
20
+ /** Leave out checks by id, e.g. `["slack.stream-stop"]`. */
21
+ skip?: string[];
22
+ /** How long each check waits for the agent. Default: the integration's timeout. */
23
+ timeout?: Duration;
24
+ }
25
+ /** The ids of the Slack checks, in the order they are registered. */
26
+ export declare const SLACK_CHECKS: readonly ["slack.dm-once", "slack.mention-once", "slack.in-thread", "slack.retry", "slack.redelivery", "slack.ignores-bots", "slack.bad-signature", "slack.ack", "slack.msg-too-long", "slack.stream-stop", "slack.stop", "slack.click-unauthorized", "slack.double-click"];
27
+ /** The ids of the GitHub checks, in the order they are registered. */
28
+ export declare const GITHUB_CHECKS: readonly ["github.ignores-own-comments", "github.one-comment", "github.review-thread", "github.redelivery", "github.check-run", "github.bad-signature"];
29
+ /** The ids of the Linear checks, in the order they are registered. */
30
+ export declare const LINEAR_CHECKS: readonly ["linear.first-activity", "linear.ends-turn", "linear.stop", "linear.redelivery", "linear.stale", "linear.bad-signature"];
31
+ /** The ids of the Notion checks, in the order they are registered. */
32
+ export declare const NOTION_CHECKS: readonly ["notion.reply-in-discussion", "notion.ignores-own-comments", "notion.redelivery", "notion.bad-signature"];
33
+ /** The ids of the Resend checks, in the order they are registered. */
34
+ export declare const RESEND_CHECKS: readonly ["resend.reply-in-thread", "resend.redelivery", "resend.bad-signature", "resend.stale"];
35
+ /** The ids of the Google checks, in the order they are registered. */
36
+ export declare const GOOGLE_CHECKS: readonly ["google.reply-in-thread", "google.history", "google.redelivery", "google.bad-signature", "google.wrong-audience", "google.stale"];
37
+ /**
38
+ * Registers: replies once to a DM · once to a mention · replies in the thread · survives Slack's
39
+ * 3 s retry · handles redelivery idempotently · ignores other bots' messages · rejects a bad
40
+ * signature · acks within 3 s · handles `msg_too_long` · a stream starts and stops · honours
41
+ * Stop · refuses clicks from people who may not act · a double click acts once.
42
+ */
43
+ export declare function slackChecks(options: ChecksOptions): void;
44
+ /**
45
+ * Registers: ignores its own comments · one comment per trigger · review-thread replies trigger
46
+ * it · redelivery doesn't duplicate · check runs reach a conclusion · rejects a bad webhook
47
+ * signature.
48
+ */
49
+ export declare function githubChecks(options: ChecksOptions): void;
50
+ /**
51
+ * The Linear checks: an agent delegated an issue. `prompt` is the issue's title (default "Look
52
+ * into this"); the agent should take the issue, work on it and end its turn.
53
+ */
54
+ export declare function linearChecks(options: ChecksOptions): void;
55
+ /**
56
+ * The Notion checks: an integration mentioned in a page comment. `prompt` is the comment (default
57
+ * `@<app> hello`); the agent should answer once, in that discussion.
58
+ */
59
+ export declare function notionChecks(options: ChecksOptions): void;
60
+ /**
61
+ * The Resend checks: a person emails the agent. `prompt` is the email's text (default `hello`); the
62
+ * agent should answer once, in the email's thread.
63
+ */
64
+ export declare function resendChecks(options: ChecksOptions): void;
65
+ /**
66
+ * The Google checks: a person emails the agent's Gmail address. `prompt` is the email's text
67
+ * (default `hello`); the agent should answer once, in the email's thread, whatever Gmail pushes.
68
+ */
69
+ export declare function googleChecks(options: ChecksOptions): void;