channelstack 0.0.0-stage → 0.2.0

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 (48) 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 +102 -0
  7. package/dist/integrations/checks/index.js +1034 -0
  8. package/dist/integrations/matchers-core/index.d.ts +217 -0
  9. package/dist/integrations/matchers-core/index.js +799 -0
  10. package/dist/integrations/matchers-core/matchers.test.d.ts +1 -0
  11. package/dist/integrations/matchers-core/matchers.test.js +407 -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 +82 -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 +139 -0
  22. package/dist/sdks/typescript/client.d.ts +14 -0
  23. package/dist/sdks/typescript/client.js +11 -0
  24. package/dist/sdks/typescript/generated/channels.d.ts +32 -0
  25. package/dist/sdks/typescript/generated/channels.js +4 -0
  26. package/dist/sdks/typescript/generated/index.d.ts +4178 -0
  27. package/dist/sdks/typescript/generated/index.js +4608 -0
  28. package/dist/sdks/typescript/generated/normalisation.d.ts +18 -0
  29. package/dist/sdks/typescript/generated/normalisation.js +14 -0
  30. package/dist/sdks/typescript/runtime/client.d.ts +56 -0
  31. package/dist/sdks/typescript/runtime/client.js +74 -0
  32. package/dist/sdks/typescript/runtime/credentials.d.ts +7 -0
  33. package/dist/sdks/typescript/runtime/credentials.js +20 -0
  34. package/dist/sdks/typescript/runtime/duration.d.ts +4 -0
  35. package/dist/sdks/typescript/runtime/duration.js +13 -0
  36. package/dist/sdks/typescript/runtime/files.d.ts +47 -0
  37. package/dist/sdks/typescript/runtime/files.js +53 -0
  38. package/dist/sdks/typescript/runtime/launcher.d.ts +27 -0
  39. package/dist/sdks/typescript/runtime/launcher.js +124 -0
  40. package/dist/sdks/typescript/runtime/responder.d.ts +26 -0
  41. package/dist/sdks/typescript/runtime/responder.js +42 -0
  42. package/dist/sdks/typescript/runtime/transport.d.ts +43 -0
  43. package/dist/sdks/typescript/runtime/transport.js +95 -0
  44. package/dist/sdks/typescript/runtime/wait.d.ts +96 -0
  45. package/dist/sdks/typescript/runtime/wait.js +159 -0
  46. package/dist/sdks/typescript/types.d.ts +82 -0
  47. package/dist/sdks/typescript/types.js +1 -0
  48. package/package.json +82 -4
@@ -0,0 +1,95 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ /** An error from the control API. `code` is the protocol's stable error code. */
3
+ export class ChannelstackError extends Error {
4
+ code;
5
+ status;
6
+ data;
7
+ constructor(code, status, message, data = {}) {
8
+ super(message);
9
+ this.name = new.target.name;
10
+ this.code = code;
11
+ this.status = status;
12
+ this.data = data;
13
+ }
14
+ }
15
+ let refusalHandler;
16
+ /** Set (or, with `undefined`, clear) what sees every refusal before it is thrown. */
17
+ export function onRefusal(handler) {
18
+ refusalHandler = handler;
19
+ }
20
+ /** Reads whose refusals go to their caller only: scoped to their own async context, so others' still do. */
21
+ const unreported = new AsyncLocalStorage();
22
+ /**
23
+ * Run a read whose refusals go only to its caller, not to the refusal handler: for what is only
24
+ * nice to have, like the open work a failure message adds. A refused read then can't turn a
25
+ * failing test into a skipped one.
26
+ */
27
+ export function unreportedRefusals(read) {
28
+ return unreported.run(true, read);
29
+ }
30
+ /** How long to keep retrying a connection that is refused, while the server starts. */
31
+ const CONNECT_RETRY_MS = 5000;
32
+ const CONNECT_RETRY_INTERVAL_MS = 100;
33
+ /** Node reports a refused connection as `cause.code === "ECONNREFUSED"`, Bun as `code === "ConnectionRefused"`. */
34
+ function isConnectionRefused(error) {
35
+ const codes = [error.code, error.cause?.code];
36
+ return codes.includes("ECONNREFUSED") || codes.includes("ConnectionRefused");
37
+ }
38
+ /** One path segment, escaped. */
39
+ export function segment(value) {
40
+ return encodeURIComponent(value);
41
+ }
42
+ /** The HTTP client every generated method goes through: bearer token, retries while the server starts, typed errors. */
43
+ export class Transport {
44
+ #options;
45
+ constructor(options) {
46
+ this.#options = options;
47
+ }
48
+ async request(method, path, options = {}) {
49
+ const url = new URL(`${this.#options.basePath}${path}`, this.#options.url);
50
+ for (const [name, value] of Object.entries(options.query ?? {})) {
51
+ if (value !== undefined)
52
+ url.searchParams.set(name, String(value));
53
+ }
54
+ const response = await this.#send(url, {
55
+ method,
56
+ headers: {
57
+ authorization: `Bearer ${this.#options.token}`,
58
+ ...(options.body === undefined ? {} : { "content-type": "application/json" }),
59
+ },
60
+ ...(options.body === undefined ? {} : { body: JSON.stringify(options.body) }),
61
+ });
62
+ const text = await response.text();
63
+ let payload;
64
+ try {
65
+ payload = text === "" ? undefined : JSON.parse(text);
66
+ }
67
+ catch {
68
+ // Not the control API talking: a proxy's error page, for example.
69
+ throw new ChannelstackError("internal", response.status, `HTTP ${response.status}: the response is not JSON`);
70
+ }
71
+ if (response.ok)
72
+ return payload;
73
+ const { error = "internal", message = `HTTP ${response.status}`, data = {}, } = (typeof payload === "object" && payload !== null ? payload : {});
74
+ const ErrorClass = this.#options.errors[error] ?? ChannelstackError;
75
+ const refusal = new ErrorClass(error, response.status, message, data);
76
+ if (!unreported.getStore())
77
+ refusalHandler?.(refusal, path);
78
+ throw refusal;
79
+ }
80
+ async #send(url, init) {
81
+ const deadline = Date.now() + CONNECT_RETRY_MS;
82
+ for (;;) {
83
+ try {
84
+ return await fetch(url, init);
85
+ }
86
+ catch (error) {
87
+ // Only a refused connection is retried: the server isn't listening yet, so nothing was sent.
88
+ // Any other failure may have happened after the request went out, and a POST must not run twice.
89
+ if (!isConnectionRefused(error) || Date.now() > deadline)
90
+ throw error;
91
+ await new Promise((resolve) => setTimeout(resolve, CONNECT_RETRY_INTERVAL_MS));
92
+ }
93
+ }
94
+ }
95
+ }
@@ -0,0 +1,96 @@
1
+ import { type Duration } from "./duration.ts";
2
+ export interface WaitOptions {
3
+ /** Give up after this long. Default: 10s, or what `setWaitDefaults` set. */
4
+ timeout?: Duration;
5
+ /** How often to read. Default: 50ms. */
6
+ interval?: Duration;
7
+ }
8
+ /** What every wait uses when it isn't given a `timeout` or `quietFor`. */
9
+ export interface WaitDefaults {
10
+ timeout: Duration;
11
+ quietFor: Duration;
12
+ }
13
+ /**
14
+ * Change the default `timeout` and `quietFor` of every wait: `waitFor…`, `latest…`, the reads that
15
+ * wait for quiet, and calls repeated while refused. The Vitest plugin sets them from its `timeout`
16
+ * and `quietFor` options. What isn't given stays as it is.
17
+ */
18
+ export declare function setWaitDefaults(options: Partial<WaitDefaults>): void;
19
+ /** The defaults every wait uses now (a copy). */
20
+ export declare function waitDefaults(): WaitDefaults;
21
+ export declare class WaitTimeoutError extends Error {
22
+ constructor(what: string, timeoutMs: number);
23
+ }
24
+ /**
25
+ * The one polling loop: read until `read` returns something other than undefined, or the
26
+ * timeout passes. Every `waitFor…`, `latest…` and matcher is built on it; tests never sleep.
27
+ */
28
+ export declare function waitFor<T>(what: string | (() => string), read: () => Promise<T | undefined>, options?: WaitOptions): Promise<T>;
29
+ /**
30
+ * Repeat a call while it is refused with one of these error codes, the way a person waits for a
31
+ * button to appear before clicking it. When the time is up, the last refusal is the error.
32
+ */
33
+ export declare function retryWhile<T>(codes: readonly string[], call: () => Promise<T>, options?: WaitOptions): Promise<T>;
34
+ export interface QuietOptions extends WaitOptions {
35
+ /**
36
+ * How long the agent must be quiet (no call in flight, no delivery in flight or about to be retried, no open stream)
37
+ * before the result is read. Default: 750ms, or what `setWaitDefaults` set.
38
+ */
39
+ quietFor?: Duration;
40
+ }
41
+ /** What the server says about the agent's activity in a session (`GET /sessions/{sid}/quiet`). */
42
+ export interface QuietState {
43
+ busy: boolean;
44
+ quietForMs: number;
45
+ /** What is still open, in words: a delivery in flight or about to be retried, a stream the agent never stopped. */
46
+ open: string[];
47
+ /** What should fail a test at once: a model call no script answered (decision 0029). */
48
+ problems?: string[];
49
+ /** The bot loops the fake stopped in the session (decision 0027), when there are any. */
50
+ loops?: string[];
51
+ }
52
+ /** A wait that stopped because the session's model calls went wrong: no script answered one, a script ran out. */
53
+ export declare class ModelProblemError extends Error {
54
+ readonly problems: readonly string[];
55
+ constructor(problems: readonly string[]);
56
+ }
57
+ /** Anyone who can author something: a handle with an id and a name. */
58
+ interface Author {
59
+ readonly id: string;
60
+ readonly name: string;
61
+ }
62
+ /** Does an item's author match a `from` filter: a handle, a name, or nothing (anyone)? */
63
+ export declare function fromMatches(author: Author, from: Author | string | undefined): boolean;
64
+ /** Does a text match what was asked for: a string it contains, a pattern, or nothing (any text)? */
65
+ export declare function textMatches(text: string, expected: string | RegExp | undefined): boolean;
66
+ /**
67
+ * Text as the server compares it for attribution, by the rules the spec publishes
68
+ * (`TEXT_NORMALISATION`, generated): what `toHaveSent` compares.
69
+ */
70
+ export declare function normalisedText(text: string): string;
71
+ /** Text to find as it goes to the server: a string as it is, a `RegExp` as its source and flags. */
72
+ export declare function patternOnWire(pattern: string | RegExp): string | {
73
+ source: string;
74
+ flags: string;
75
+ };
76
+ /** "a reply" → "a reply from my-agent", for timeout messages. */
77
+ export declare function describeWait(what: string, from: Author | string | undefined): string;
78
+ /**
79
+ * Wait for the next new item of a list that matches, after the last one this handle returned.
80
+ * `seen` belongs to the handle and remembers, per wait, how far it has looked. With `startsTurn`,
81
+ * the wait also looks only after the newest item that starts a turn (a person's prompt).
82
+ */
83
+ export declare function waitForNext<T>(seen: Map<string, number>, key: string, read: () => Promise<readonly T[]>, matches: (item: T) => boolean, what: string, options?: WaitOptions, startsTurn?: (item: T) => boolean): Promise<T>;
84
+ /**
85
+ * Resolve once the agent has been quiet for `quietFor`. Negative and exact-count checks read after this.
86
+ *
87
+ * With `watching`, the quiet time counts from now at the earliest: the caller wants to have looked
88
+ * for the whole window. An agent that is thinking makes no sound, so a session that went quiet a
89
+ * while ago says nothing about what arrives next.
90
+ */
91
+ export declare function untilQuiet(quiet: () => Promise<QuietState>, options?: QuietOptions & {
92
+ watching?: boolean;
93
+ }): Promise<void>;
94
+ /** The last item of a list that matches, read once the agent is quiet. Waits for at least one first. */
95
+ export declare function latestOnceQuiet<T>(read: () => Promise<readonly T[]>, matches: (item: T) => boolean, quiet: () => Promise<QuietState>, what: string, options?: QuietOptions): Promise<T>;
96
+ export {};
@@ -0,0 +1,159 @@
1
+ import { TEXT_NORMALISATION } from "../generated/normalisation.js";
2
+ import { parseDuration } from "./duration.js";
3
+ const defaults = { timeout: "10s", quietFor: "750ms" };
4
+ /**
5
+ * Change the default `timeout` and `quietFor` of every wait: `waitFor…`, `latest…`, the reads that
6
+ * wait for quiet, and calls repeated while refused. The Vitest plugin sets them from its `timeout`
7
+ * and `quietFor` options. What isn't given stays as it is.
8
+ */
9
+ export function setWaitDefaults(options) {
10
+ for (const key of ["timeout", "quietFor"]) {
11
+ const value = options[key];
12
+ if (value === undefined)
13
+ continue;
14
+ parseDuration(value);
15
+ defaults[key] = value;
16
+ }
17
+ }
18
+ /** The defaults every wait uses now (a copy). */
19
+ export function waitDefaults() {
20
+ return { ...defaults };
21
+ }
22
+ export class WaitTimeoutError extends Error {
23
+ constructor(what, timeoutMs) {
24
+ super(`Timed out after ${timeoutMs}ms waiting for ${what}`);
25
+ this.name = "WaitTimeoutError";
26
+ }
27
+ }
28
+ /**
29
+ * The one polling loop: read until `read` returns something other than undefined, or the
30
+ * timeout passes. Every `waitFor…`, `latest…` and matcher is built on it; tests never sleep.
31
+ */
32
+ export async function waitFor(what, read, options = {}) {
33
+ const timeout = parseDuration(options.timeout ?? defaults.timeout);
34
+ const interval = parseDuration(options.interval ?? "50ms");
35
+ const deadline = Date.now() + timeout;
36
+ for (;;) {
37
+ const value = await read();
38
+ if (value !== undefined)
39
+ return value;
40
+ if (Date.now() + interval > deadline)
41
+ throw new WaitTimeoutError(typeof what === "string" ? what : what(), timeout);
42
+ await new Promise((resolve) => setTimeout(resolve, interval));
43
+ }
44
+ }
45
+ /**
46
+ * Repeat a call while it is refused with one of these error codes, the way a person waits for a
47
+ * button to appear before clicking it. When the time is up, the last refusal is the error.
48
+ */
49
+ export async function retryWhile(codes, call, options = {}) {
50
+ let refusal;
51
+ try {
52
+ return await waitFor("the call to be accepted", async () => {
53
+ try {
54
+ return { value: await call() };
55
+ }
56
+ catch (error) {
57
+ if (!codes.includes(String(error?.code)))
58
+ throw error;
59
+ refusal = error;
60
+ return undefined;
61
+ }
62
+ }, options).then(({ value }) => value);
63
+ }
64
+ catch (error) {
65
+ throw error instanceof WaitTimeoutError && refusal !== undefined ? refusal : error;
66
+ }
67
+ }
68
+ /** A wait that stopped because the session's model calls went wrong: no script answered one, a script ran out. */
69
+ export class ModelProblemError extends Error {
70
+ problems;
71
+ constructor(problems) {
72
+ super(`The model calls of this test went wrong:\n${problems.map((problem) => ` ${problem}`).join("\n")}`);
73
+ this.name = "ModelProblemError";
74
+ this.problems = problems;
75
+ }
76
+ }
77
+ /** Does an item's author match a `from` filter: a handle, a name, or nothing (anyone)? */
78
+ export function fromMatches(author, from) {
79
+ if (from === undefined)
80
+ return true;
81
+ return typeof from === "string" ? author.name === from || author.id === from : author.id === from.id;
82
+ }
83
+ /** Does a text match what was asked for: a string it contains, a pattern, or nothing (any text)? */
84
+ export function textMatches(text, expected) {
85
+ if (expected === undefined)
86
+ return true;
87
+ if (typeof expected === "string")
88
+ return text.includes(expected);
89
+ // A pattern with the `g` or `y` flag remembers where it stopped; every test starts afresh.
90
+ expected.lastIndex = 0;
91
+ return expected.test(text);
92
+ }
93
+ const NORMALISATION_RULES = TEXT_NORMALISATION.rules.map(({ pattern, replacement }) => [new RegExp(pattern, "g"), replacement]);
94
+ /**
95
+ * Text as the server compares it for attribution, by the rules the spec publishes
96
+ * (`TEXT_NORMALISATION`, generated): what `toHaveSent` compares.
97
+ */
98
+ export function normalisedText(text) {
99
+ let normalised = NORMALISATION_RULES.reduce((current, [pattern, replacement]) => current.replace(pattern, replacement), text);
100
+ if (TEXT_NORMALISATION.collapseWhitespace)
101
+ normalised = normalised.replace(/\s+/g, " ").trim();
102
+ return TEXT_NORMALISATION.lowercase ? normalised.toLowerCase() : normalised;
103
+ }
104
+ /** Text to find as it goes to the server: a string as it is, a `RegExp` as its source and flags. */
105
+ export function patternOnWire(pattern) {
106
+ return typeof pattern === "string" ? pattern : { source: pattern.source, flags: pattern.flags };
107
+ }
108
+ /** "a reply" → "a reply from my-agent", for timeout messages. */
109
+ export function describeWait(what, from) {
110
+ return from === undefined ? what : `${what} from ${typeof from === "string" ? from : from.name}`;
111
+ }
112
+ /**
113
+ * Wait for the next new item of a list that matches, after the last one this handle returned.
114
+ * `seen` belongs to the handle and remembers, per wait, how far it has looked. With `startsTurn`,
115
+ * the wait also looks only after the newest item that starts a turn (a person's prompt).
116
+ */
117
+ export function waitForNext(seen, key, read, matches, what, options = {}, startsTurn) {
118
+ return waitFor(what, async () => {
119
+ const items = await read();
120
+ const turn = startsTurn ? items.findLastIndex(startsTurn) + 1 : 0;
121
+ const from = Math.max(seen.get(key) ?? 0, turn);
122
+ const index = items.findIndex((item, position) => position >= from && matches(item));
123
+ if (index === -1)
124
+ return undefined;
125
+ seen.set(key, index + 1);
126
+ return items[index];
127
+ }, options);
128
+ }
129
+ /**
130
+ * Resolve once the agent has been quiet for `quietFor`. Negative and exact-count checks read after this.
131
+ *
132
+ * With `watching`, the quiet time counts from now at the earliest: the caller wants to have looked
133
+ * for the whole window. An agent that is thinking makes no sound, so a session that went quiet a
134
+ * while ago says nothing about what arrives next.
135
+ */
136
+ export async function untilQuiet(quiet, options = {}) {
137
+ const quietFor = parseDuration(options.quietFor ?? defaults.quietFor);
138
+ const started = Date.now();
139
+ let open = [];
140
+ await waitFor(
141
+ // A wait that gives up says what the agent left open: that is usually the bug.
142
+ () => `the agent to be quiet for ${quietFor}ms${open.length > 0 ? `. Still open: ${open.join("; ")}` : ""}`, async () => {
143
+ const state = await quiet();
144
+ open = state.open;
145
+ if (state.problems !== undefined && state.problems.length > 0)
146
+ throw new ModelProblemError(state.problems);
147
+ if (options.watching && Date.now() - started < quietFor)
148
+ return undefined;
149
+ return !state.busy && state.quietForMs >= quietFor ? true : undefined;
150
+ }, options);
151
+ }
152
+ /** The last item of a list that matches, read once the agent is quiet. Waits for at least one first. */
153
+ export async function latestOnceQuiet(read, matches, quiet, what, options = {}) {
154
+ const latest = async () => (await read()).filter(matches).at(-1);
155
+ await waitFor(what, latest, options);
156
+ await untilQuiet(quiet, options);
157
+ // The agent may have said more while it was settling: the answer is what is there now.
158
+ return waitFor(what, latest, options);
159
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The type names tests import that the generated SDK has no type of its own for: unions of its
3
+ * handles, the option bags of its methods, and the values of its fields. Each one is read from the
4
+ * generated code, so it can't drift from it. With them, `import type { AuthorRef } from
5
+ * "channelstack"` works.
6
+ *
7
+ * Not here: the test framework's own types (`ChannelstackFixture`, `ChannelstackIntegrationOptions`,
8
+ * `ChannelstackMatchers`, `TextOptions`, in `channelstack/vitest`), and `SlackInjectedFault`, which
9
+ * the SDK calls `SlackFault` (#37).
10
+ */
11
+ import type { AnyDelivery, App, Transcript, User } from "./generated/channels.ts";
12
+ import type * as G from "./generated/index.ts";
13
+ export type { ApiCall, App, ChannelKind, DeliveryFilter, ProviderKind, Inspectable, Resource, Transcript, User, } from "./generated/channels.ts";
14
+ type Option<Method extends (...args: never[]) => unknown> = NonNullable<Parameters<Method>[0]>;
15
+ /** Text that may contain `@name` mentions. */
16
+ export type RichText = string;
17
+ /** ISO 8601 timestamp string. */
18
+ export type Timestamp = string;
19
+ export type SlackParticipant = G.SlackUser | G.SlackApp;
20
+ export type GitHubAuthor = G.GitHubUser | G.GitHubApp;
21
+ export type LinearAuthor = G.LinearUser | G.LinearApp;
22
+ export type NotionAuthor = G.NotionUser | G.NotionIntegration;
23
+ export type Principal = User | App;
24
+ /** Anything that can be named as an author in a matcher: a handle or its `name`. */
25
+ export type AuthorRef = Principal | string;
26
+ /** A delivery of any channel, narrowed by its `type` and `payload` as `Delivery<TType, TPayload>`. */
27
+ export type Delivery<TType extends string = string, TPayload = unknown> = AnyDelivery & {
28
+ readonly type: TType;
29
+ readonly payload: TPayload;
30
+ };
31
+ export type DeliveryStatus = Delivery["status"];
32
+ export type DeliveryTransport = G.DeliveryAttempt["transport"];
33
+ export type SlackDeliveryType = G.SlackDelivery["type"];
34
+ export type DeliveryResendOptions = Option<G.GitHubDelivery["resend"]>;
35
+ export type SlackDeliveryResendOptions = Option<G.SlackDelivery["resend"]>;
36
+ export type LinearDeliveryResendOptions = Option<G.LinearDelivery["resend"]>;
37
+ export type ApiCallFilter = Option<G.SlackFixture["calls"]>;
38
+ export type TranscriptEntry = Transcript["entries"][number];
39
+ export type HasTranscript = {
40
+ transcript(): Promise<Transcript>;
41
+ };
42
+ export type SlackHasTranscript = {
43
+ transcript(options?: {
44
+ as?: SlackParticipant;
45
+ }): Promise<G.SlackTranscript>;
46
+ };
47
+ export type SlackUserOptions = Option<G.SlackFixture["createUser"]>;
48
+ export type SlackChannelOptions = Option<G.SlackFixture["createChannel"]>;
49
+ export type GitHubUserOptions = Option<G.GitHubFixture["createUser"]>;
50
+ export type GitHubRepoOptions = Option<G.GitHubFixture["createRepo"]>;
51
+ export type GitHubChanges = Parameters<G.GitHubUser["push"]>[0];
52
+ export type LinearUserOptions = Option<G.LinearFixture["createUser"]>;
53
+ export type LinearTeamOptions = Option<G.LinearFixture["createTeam"]>;
54
+ export type LinearStateType = G.LinearIssueState["type"];
55
+ export type LinearPriority = NonNullable<Parameters<G.LinearUser["createIssue"]>[0]["priority"]>;
56
+ export type LinearSessionState = Awaited<ReturnType<G.LinearAgentSession["state"]>>;
57
+ export type LinearActivityType = G.LinearAgentActivity["type"];
58
+ export type NotionUserOptions = Option<G.NotionFixture["createUser"]>;
59
+ export type NotionPageOptions = Option<G.NotionFixture["createPage"]>;
60
+ export type NotionDatabaseOptions = Option<G.NotionFixture["createDatabase"]>;
61
+ export type ResendUserOptions = Option<G.ResendFixture["createUser"]>;
62
+ export type ResendEventType = G.ResendDelivery["type"];
63
+ export type ResendDeliveryResendOptions = Option<G.ResendDelivery["resend"]>;
64
+ export type GoogleUserOptions = Option<G.GoogleFixture["createUser"]>;
65
+ export type GoogleEventType = G.GoogleDelivery["type"];
66
+ export type GoogleDeliveryResendOptions = Option<G.GoogleDelivery["resend"]>;
67
+ /** An email a person sends, with the channel's own people and app as its recipients. */
68
+ export type EmailSendOptions<TRecipient = unknown> = Omit<Option<G.ResendUser["send"]>, "to" | "cc"> & {
69
+ to: readonly TRecipient[];
70
+ cc?: readonly TRecipient[];
71
+ };
72
+ export type EmailReplyOptions = NonNullable<Parameters<G.ResendUser["reply"]>[1]>;
73
+ export type DiscordParticipant = G.DiscordUser | G.DiscordApp;
74
+ export type DiscordUserOptions = Option<G.DiscordFixture["createUser"]>;
75
+ export type DiscordChannelOptions = Option<G.DiscordFixture["createChannel"]>;
76
+ export type DiscordFaultOptions = Option<G.DiscordFixture["fault"]>;
77
+ /** Read as one person: Discord shows an ephemeral message only to its person. */
78
+ export type DiscordHasTranscript = {
79
+ transcript(options?: {
80
+ as?: DiscordParticipant;
81
+ }): Promise<G.DiscordTranscript>;
82
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,84 @@
1
1
  {
2
2
  "name": "channelstack",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Test the apps and agents you build for Slack, GitHub, Linear, Notion, Resend, Gmail and Discord: fake platforms and a fake OpenAI on localhost, the TypeScript SDK, Vitest fixtures and matchers.",
5
+ "keywords": [
6
+ "testing",
7
+ "test-harness",
8
+ "fake",
9
+ "slack",
10
+ "github",
11
+ "linear",
12
+ "notion",
13
+ "resend",
14
+ "gmail",
15
+ "discord",
16
+ "openai",
17
+ "agents",
18
+ "vitest"
19
+ ],
20
+ "homepage": "https://channelstack.dev",
21
+ "bugs": {
22
+ "url": "https://github.com/christian-bromann/channelstack/issues"
23
+ },
24
+ "license": "MIT",
25
+ "type": "module",
26
+ "repository": {
27
+ "type": "git",
28
+ "url": "git+https://github.com/christian-bromann/channelstack.git",
29
+ "directory": "sdks/typescript"
30
+ },
31
+ "engines": {
32
+ "node": ">=22"
33
+ },
34
+ "bin": {
35
+ "channelstack": "bin/channelstack.mjs"
36
+ },
37
+ "files": [
38
+ "bin",
39
+ "dist"
40
+ ],
41
+ "exports": {
42
+ ".": {
43
+ "types": "./dist/sdks/typescript/client.d.ts",
44
+ "default": "./dist/sdks/typescript/client.js"
45
+ },
46
+ "./client": {
47
+ "types": "./dist/sdks/typescript/client.d.ts",
48
+ "default": "./dist/sdks/typescript/client.js"
49
+ },
50
+ "./vitest": {
51
+ "types": "./dist/integrations/vitest/index.d.ts",
52
+ "default": "./dist/integrations/vitest/index.js"
53
+ },
54
+ "./checks": {
55
+ "types": "./dist/integrations/checks/index.d.ts",
56
+ "default": "./dist/integrations/checks/index.js"
57
+ },
58
+ "./vitest/setup": {
59
+ "default": "./dist/integrations/vitest/setup.js"
60
+ },
61
+ "./vitest/global-setup": {
62
+ "default": "./dist/integrations/vitest/global-setup.js"
63
+ },
64
+ "./package.json": "./package.json"
65
+ },
66
+ "scripts": {
67
+ "build": "tsc -p tsconfig.build.json"
68
+ },
69
+ "optionalDependencies": {
70
+ "@channelstack/server-darwin-arm64": "0.2.0",
71
+ "@channelstack/server-darwin-x64": "0.2.0",
72
+ "@channelstack/server-linux-arm64": "0.2.0",
73
+ "@channelstack/server-linux-x64": "0.2.0",
74
+ "@channelstack/server-win32-x64": "0.2.0"
75
+ },
76
+ "peerDependencies": {
77
+ "vitest": ">=5.0.0 <6"
78
+ },
79
+ "peerDependenciesMeta": {
80
+ "vitest": {
81
+ "optional": true
82
+ }
83
+ }
84
+ }