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.
- package/LICENSE +21 -0
- package/README.md +56 -2
- package/bin/channelstack.mjs +31 -0
- package/dist/integrations/checks/checks.test.d.ts +1 -0
- package/dist/integrations/checks/checks.test.js +31 -0
- package/dist/integrations/checks/index.d.ts +102 -0
- package/dist/integrations/checks/index.js +1034 -0
- package/dist/integrations/matchers-core/index.d.ts +217 -0
- package/dist/integrations/matchers-core/index.js +799 -0
- package/dist/integrations/matchers-core/matchers.test.d.ts +1 -0
- package/dist/integrations/matchers-core/matchers.test.js +407 -0
- package/dist/integrations/vitest/global-setup.d.ts +3 -0
- package/dist/integrations/vitest/global-setup.js +19 -0
- package/dist/integrations/vitest/index.d.ts +82 -0
- package/dist/integrations/vitest/index.js +42 -0
- package/dist/integrations/vitest/plugin.test.d.ts +1 -0
- package/dist/integrations/vitest/plugin.test.js +19 -0
- package/dist/integrations/vitest/refused.d.ts +22 -0
- package/dist/integrations/vitest/refused.js +49 -0
- package/dist/integrations/vitest/setup.d.ts +1 -0
- package/dist/integrations/vitest/setup.js +139 -0
- package/dist/sdks/typescript/client.d.ts +14 -0
- package/dist/sdks/typescript/client.js +11 -0
- package/dist/sdks/typescript/generated/channels.d.ts +32 -0
- package/dist/sdks/typescript/generated/channels.js +4 -0
- package/dist/sdks/typescript/generated/index.d.ts +4178 -0
- package/dist/sdks/typescript/generated/index.js +4608 -0
- package/dist/sdks/typescript/generated/normalisation.d.ts +18 -0
- package/dist/sdks/typescript/generated/normalisation.js +14 -0
- package/dist/sdks/typescript/runtime/client.d.ts +56 -0
- package/dist/sdks/typescript/runtime/client.js +74 -0
- package/dist/sdks/typescript/runtime/credentials.d.ts +7 -0
- package/dist/sdks/typescript/runtime/credentials.js +20 -0
- package/dist/sdks/typescript/runtime/duration.d.ts +4 -0
- package/dist/sdks/typescript/runtime/duration.js +13 -0
- package/dist/sdks/typescript/runtime/files.d.ts +47 -0
- package/dist/sdks/typescript/runtime/files.js +53 -0
- package/dist/sdks/typescript/runtime/launcher.d.ts +27 -0
- package/dist/sdks/typescript/runtime/launcher.js +124 -0
- package/dist/sdks/typescript/runtime/responder.d.ts +26 -0
- package/dist/sdks/typescript/runtime/responder.js +42 -0
- package/dist/sdks/typescript/runtime/transport.d.ts +43 -0
- package/dist/sdks/typescript/runtime/transport.js +95 -0
- package/dist/sdks/typescript/runtime/wait.d.ts +96 -0
- package/dist/sdks/typescript/runtime/wait.js +159 -0
- package/dist/sdks/typescript/types.d.ts +82 -0
- package/dist/sdks/typescript/types.js +1 -0
- package/package.json +82 -4
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { type DiscordChannel, type Duration, type SlackConversation } from "../../sdks/typescript/client.ts";
|
|
2
|
+
export interface MatcherResult {
|
|
3
|
+
pass: boolean;
|
|
4
|
+
/** Why it failed (or, for a negated matcher, why it unexpectedly passed). */
|
|
5
|
+
message: () => string;
|
|
6
|
+
}
|
|
7
|
+
export interface MatcherState {
|
|
8
|
+
/** True under `.not`. */
|
|
9
|
+
isNot: boolean;
|
|
10
|
+
/** The test framework's own equality, which understands asymmetric matchers (`expect.any(Number)`). */
|
|
11
|
+
equals?: (actual: unknown, expected: unknown) => boolean;
|
|
12
|
+
/** Defaults from the integration's options. */
|
|
13
|
+
timeout: Duration;
|
|
14
|
+
quietFor: Duration;
|
|
15
|
+
}
|
|
16
|
+
interface Timing {
|
|
17
|
+
timeout?: Duration;
|
|
18
|
+
quietFor?: Duration;
|
|
19
|
+
}
|
|
20
|
+
type Author = {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly name: string;
|
|
23
|
+
};
|
|
24
|
+
type AuthorRef = Author | string;
|
|
25
|
+
/**
|
|
26
|
+
* Who a transcript is read as, in the channels that show some messages to one person only (Slack's
|
|
27
|
+
* and Discord's ephemeral ones): the SDK's own types, so a change to that signature fails to compile here.
|
|
28
|
+
*/
|
|
29
|
+
type ViewerOf<Handle extends {
|
|
30
|
+
transcript(options?: {
|
|
31
|
+
as?: unknown;
|
|
32
|
+
}): unknown;
|
|
33
|
+
}> = NonNullable<NonNullable<Parameters<Handle["transcript"]>[0]>["as"]>;
|
|
34
|
+
type Viewer = ViewerOf<SlackConversation> | ViewerOf<DiscordChannel>;
|
|
35
|
+
/** A model call no session claimed, as `GET /sessions/{sid}/openai/unattributed` lists it. */
|
|
36
|
+
interface UnattributedCall {
|
|
37
|
+
readonly id: string;
|
|
38
|
+
readonly lastUserText?: string | undefined;
|
|
39
|
+
readonly sinceMs: number;
|
|
40
|
+
readonly message: string;
|
|
41
|
+
}
|
|
42
|
+
/** A model call of the session, as far as its attribution goes. */
|
|
43
|
+
interface AttributedCall {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly request: {
|
|
46
|
+
readonly context: {
|
|
47
|
+
readonly attributedBy?: string | undefined;
|
|
48
|
+
readonly matched?: string | undefined;
|
|
49
|
+
readonly tiedWith?: readonly string[] | undefined;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** The lines of `modelNotesOf`, from what the server answered. */
|
|
54
|
+
export declare function modelNotes(unattributed: readonly UnattributedCall[], calls: readonly AttributedCall[]): string[];
|
|
55
|
+
/**
|
|
56
|
+
* The app messages of a conversation since a person last wrote in it, those before a check began
|
|
57
|
+
* included, and their authors in turn (`my-agent → coder → my-agent`): what `toGoQuiet` and each
|
|
58
|
+
* `<channel>.no-reply-loop` name when apps answer each other (decision 0027).
|
|
59
|
+
*/
|
|
60
|
+
export declare function appTurns(subject: unknown): Promise<{
|
|
61
|
+
count: number;
|
|
62
|
+
turns: string;
|
|
63
|
+
}>;
|
|
64
|
+
export declare const matchers: {
|
|
65
|
+
/**
|
|
66
|
+
* The conversation goes quiet within `within`, holding at most `maxReplies` app messages since
|
|
67
|
+
* a person last wrote in it, those before the check began included: apps that answer each other
|
|
68
|
+
* without end fail it (decision 0027).
|
|
69
|
+
*/
|
|
70
|
+
toGoQuiet(state: MatcherState, subject: unknown, options: {
|
|
71
|
+
within?: Duration;
|
|
72
|
+
maxReplies: number;
|
|
73
|
+
quietFor?: Duration;
|
|
74
|
+
}): Promise<{
|
|
75
|
+
pass: boolean;
|
|
76
|
+
message: () => string;
|
|
77
|
+
}>;
|
|
78
|
+
/** The thread (or DM) has at least one reply from this author. */
|
|
79
|
+
toHaveReplyFrom(state: MatcherState, subject: unknown, author: AuthorRef, options?: Timing & {
|
|
80
|
+
text?: string | RegExp;
|
|
81
|
+
}): Promise<MatcherResult>;
|
|
82
|
+
/** Exactly `count` replies from this author, checked once the agent is quiet. */
|
|
83
|
+
toHaveRepliesFrom(state: MatcherState, subject: unknown, author: AuthorRef, options: Timing & {
|
|
84
|
+
count: number;
|
|
85
|
+
text?: string | RegExp;
|
|
86
|
+
}): Promise<MatcherResult>;
|
|
87
|
+
/** A message from this author directly in the channel, outside any thread. */
|
|
88
|
+
toHaveChannelMessageFrom(state: MatcherState, subject: unknown, author: AuthorRef, options?: Timing): Promise<MatcherResult>;
|
|
89
|
+
/** Some entry a person would see contains this text. `count` makes it exact. */
|
|
90
|
+
toContainText(state: MatcherState, subject: unknown, text: string | RegExp, options?: Timing & {
|
|
91
|
+
count?: number;
|
|
92
|
+
from?: AuthorRef;
|
|
93
|
+
as?: Viewer;
|
|
94
|
+
}): Promise<MatcherResult>;
|
|
95
|
+
/** A reply from this author is being streamed right now. */
|
|
96
|
+
toHaveStreamingReplyFrom(state: MatcherState, subject: unknown, author?: AuthorRef, options?: Timing): Promise<MatcherResult>;
|
|
97
|
+
/** The agent's state in this thread: `working`, `streaming`, `stopped` or `idle`. */
|
|
98
|
+
toHaveStatus(state: MatcherState, subject: unknown, expected: "working" | "streaming" | "stopped" | "idle", options?: Timing): Promise<MatcherResult>;
|
|
99
|
+
/** The status line the agent set. */
|
|
100
|
+
toHaveStatusText(state: MatcherState, subject: unknown, text: string | RegExp, options?: Timing): Promise<MatcherResult>;
|
|
101
|
+
/** The message has a button with this label; for a thread or a conversation, the agent's latest message there. */
|
|
102
|
+
toHaveButton(state: MatcherState, subject: unknown, label: string | RegExp, options?: Timing): Promise<MatcherResult>;
|
|
103
|
+
toHaveReaction(state: MatcherState, subject: unknown, emoji: string, options?: Timing & {
|
|
104
|
+
by?: AuthorRef;
|
|
105
|
+
}): Promise<MatcherResult>;
|
|
106
|
+
/** Subject: a person. The agent opened a modal for them (it may be submitted by now), with this title if one is given. */
|
|
107
|
+
toHaveOpenedModal(state: MatcherState, subject: unknown, title?: string | RegExp, options?: Timing): Promise<MatcherResult>;
|
|
108
|
+
/** Subject: a GitHub issue or pull request, a Linear issue or a Notion discussion. At least one comment from this author. */
|
|
109
|
+
toHaveCommentFrom(state: MatcherState, subject: unknown, author: AuthorRef, options?: Timing & {
|
|
110
|
+
text?: string | RegExp;
|
|
111
|
+
}): Promise<MatcherResult>;
|
|
112
|
+
/** Exactly `count` comments from this author, checked once the agent is quiet. */
|
|
113
|
+
toHaveCommentsFrom(state: MatcherState, subject: unknown, author: AuthorRef, options: Timing & {
|
|
114
|
+
count: number;
|
|
115
|
+
}): Promise<MatcherResult>;
|
|
116
|
+
/** Subject: a pull request. A comment on the diff, matched by every field that is given. */
|
|
117
|
+
toHaveReviewComment(state: MatcherState, subject: unknown, expected: {
|
|
118
|
+
path?: string;
|
|
119
|
+
line?: number;
|
|
120
|
+
from?: AuthorRef;
|
|
121
|
+
text?: string | RegExp;
|
|
122
|
+
}, options?: Timing): Promise<MatcherResult>;
|
|
123
|
+
/** Subject: a pull request. A review from this author, with this verdict if one is given. */
|
|
124
|
+
toHaveReviewFrom(state: MatcherState, subject: unknown, author: AuthorRef, options?: Timing & {
|
|
125
|
+
state?: string;
|
|
126
|
+
}): Promise<MatcherResult>;
|
|
127
|
+
/** Subject: a pull request or a commit. A check run of this name, in this state if one is given. */
|
|
128
|
+
toHaveCheckRun(state: MatcherState, subject: unknown, name: string | RegExp, options?: Timing & {
|
|
129
|
+
status?: string;
|
|
130
|
+
conclusion?: string;
|
|
131
|
+
}): Promise<MatcherResult>;
|
|
132
|
+
/** Subject: an issue or a pull request. It has this label. */
|
|
133
|
+
toHaveLabel(state: MatcherState, subject: unknown, name: string, options?: Timing): Promise<MatcherResult>;
|
|
134
|
+
/** Subject: a pull request. It has been merged. */
|
|
135
|
+
toBeMerged(state: MatcherState, subject: unknown, options?: Timing): Promise<MatcherResult>;
|
|
136
|
+
/** Subject: a Linear agent session, or an issue (its latest session). The session's status. */
|
|
137
|
+
toHaveSessionState(state: MatcherState, subject: unknown, wanted: string, options?: Timing): Promise<MatcherResult>;
|
|
138
|
+
/**
|
|
139
|
+
* Subject: a Linear agent session, or an issue (its latest session). An activity of the agent's
|
|
140
|
+
* matching every field that is given: a person's turns (`prompt`, delegating's first among them)
|
|
141
|
+
* aren't what it published.
|
|
142
|
+
*/
|
|
143
|
+
toHaveActivity(state: MatcherState, subject: unknown, expected: {
|
|
144
|
+
type?: string;
|
|
145
|
+
from?: AuthorRef;
|
|
146
|
+
text?: string | RegExp;
|
|
147
|
+
}, options?: Timing): Promise<MatcherResult>;
|
|
148
|
+
/** Subject: a Linear issue. It is delegated to this app, or (with `undefined`) to none. */
|
|
149
|
+
toBeDelegatedTo(state: MatcherState, subject: unknown, app: Author | undefined, options?: Timing): Promise<MatcherResult>;
|
|
150
|
+
/** Subject: a Linear issue. It is assigned to this person, or (with `undefined`) to no one. */
|
|
151
|
+
toBeAssignedTo(state: MatcherState, subject: unknown, user: Author | undefined, options?: Timing): Promise<MatcherResult>;
|
|
152
|
+
/** Subject: a Notion page. A block (at any depth) whose text matches. */
|
|
153
|
+
toHaveBlock(state: MatcherState, subject: unknown, text: string | RegExp, options?: Timing): Promise<MatcherResult>;
|
|
154
|
+
/** Subject: a Notion page. A property has this value; asymmetric matchers (`expect.any(Number)`) work. */
|
|
155
|
+
toHavePropertyValue(state: MatcherState, subject: unknown, name: string, expected: unknown, options?: Timing): Promise<MatcherResult>;
|
|
156
|
+
/** Subject: a Linear issue. Its workflow state, by name. */
|
|
157
|
+
toHaveState(state: MatcherState, subject: unknown, name: string, options?: Timing): Promise<MatcherResult>;
|
|
158
|
+
/** Only this person can see the message. */
|
|
159
|
+
toBeEphemeralFor(state: MatcherState, subject: unknown, user: {
|
|
160
|
+
readonly id: string;
|
|
161
|
+
readonly name: string;
|
|
162
|
+
}): Promise<MatcherResult>;
|
|
163
|
+
/** The agent answered the delivery with 2xx, within the platform's window. */
|
|
164
|
+
toBeAccepted(state: MatcherState, subject: unknown, options?: Timing & {
|
|
165
|
+
within?: Duration;
|
|
166
|
+
}): Promise<MatcherResult>;
|
|
167
|
+
/** A forged delivery (bad signature, stale timestamp) was refused by the agent with a 4xx. */
|
|
168
|
+
toBeRejected(state: MatcherState, subject: unknown, options?: Timing): Promise<MatcherResult>;
|
|
169
|
+
/** The delivery needed retries. */
|
|
170
|
+
toBeRetried(state: MatcherState, subject: unknown, options?: Timing & {
|
|
171
|
+
times?: number;
|
|
172
|
+
}): Promise<MatcherResult>;
|
|
173
|
+
/** The agent made this API call. */
|
|
174
|
+
toHaveReceivedCall(state: MatcherState, subject: unknown, operation: string | RegExp, options?: Timing & {
|
|
175
|
+
times?: number;
|
|
176
|
+
error?: string;
|
|
177
|
+
}): Promise<MatcherResult>;
|
|
178
|
+
/**
|
|
179
|
+
* What the agent sent the model: text, a pattern, a message's text, or several messages in order
|
|
180
|
+
* (thread history). The subject is the `openai` fixture (any of the session's calls), a script
|
|
181
|
+
* (the calls it answered), or one call.
|
|
182
|
+
*/
|
|
183
|
+
toHaveSent(state: MatcherState, subject: unknown, expected: string | RegExp | Texted | readonly (string | Texted)[], options?: Timing & {
|
|
184
|
+
ordered?: boolean;
|
|
185
|
+
}): Promise<MatcherResult>;
|
|
186
|
+
/**
|
|
187
|
+
* The agent sent the model this image, file or audio, compared by its SHA-256: a fixture file's
|
|
188
|
+
* path (read as a `MediaSource` is, from the files root) or its bytes. The subject is the
|
|
189
|
+
* `openai` fixture, a script or one call, as for `toHaveSent`.
|
|
190
|
+
*/
|
|
191
|
+
toHaveSentFile(state: MatcherState, subject: unknown, file: string | Uint8Array, options?: Timing): Promise<MatcherResult>;
|
|
192
|
+
/** A secret channelstack knows (a token, a signing secret, a key) was sent to the model. Use it as `not.`. */
|
|
193
|
+
toHaveSentSecrets(state: MatcherState, subject: unknown, options?: Timing): Promise<MatcherResult>;
|
|
194
|
+
/** The call offered the model this tool (with this JSON Schema). */
|
|
195
|
+
toHaveOfferedTool(state: MatcherState, subject: unknown, name: string, options?: Timing & {
|
|
196
|
+
schema?: unknown;
|
|
197
|
+
}): Promise<MatcherResult>;
|
|
198
|
+
/** The agent ran the model's call to this tool and sent its result back (with this text). */
|
|
199
|
+
toHaveSentToolResult(state: MatcherState, subject: unknown, name: string, options?: Timing & {
|
|
200
|
+
text?: string | RegExp;
|
|
201
|
+
}): Promise<MatcherResult>;
|
|
202
|
+
/** The agent hung up before the model's answer was complete: it cancelled the request (Stop), or timed out. */
|
|
203
|
+
toBeAborted(state: MatcherState, subject: unknown, options?: Timing): Promise<MatcherResult>;
|
|
204
|
+
/**
|
|
205
|
+
* The script answered calls (exactly `times` of them, once the agent is quiet): a call counts once
|
|
206
|
+
* the script's turn reached the agent, not one it was given and the fake refused.
|
|
207
|
+
*/
|
|
208
|
+
toHaveAnswered(state: MatcherState, subject: unknown, options?: Timing & {
|
|
209
|
+
times?: number;
|
|
210
|
+
}): Promise<MatcherResult>;
|
|
211
|
+
};
|
|
212
|
+
/** Something with text: a channel's message, comment or email. */
|
|
213
|
+
interface Texted {
|
|
214
|
+
readonly text: string;
|
|
215
|
+
}
|
|
216
|
+
export type MatcherName = keyof typeof matchers;
|
|
217
|
+
export {};
|