channelstack 0.1.1 → 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/README.md +1 -1
- package/dist/integrations/checks/index.d.ts +40 -7
- package/dist/integrations/checks/index.js +525 -69
- package/dist/integrations/matchers-core/index.d.ts +90 -11
- package/dist/integrations/matchers-core/index.js +356 -15
- package/dist/integrations/matchers-core/matchers.test.js +251 -3
- package/dist/integrations/vitest/index.d.ts +4 -2
- package/dist/integrations/vitest/setup.js +33 -3
- package/dist/sdks/typescript/client.d.ts +5 -4
- package/dist/sdks/typescript/client.js +4 -4
- package/dist/sdks/typescript/generated/channels.d.ts +17 -9
- package/dist/sdks/typescript/generated/channels.js +3 -1
- package/dist/sdks/typescript/generated/index.d.ts +1744 -313
- package/dist/sdks/typescript/generated/index.js +1991 -422
- 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 +9 -0
- package/dist/sdks/typescript/runtime/client.js +5 -0
- package/dist/sdks/typescript/runtime/files.d.ts +17 -2
- package/dist/sdks/typescript/runtime/files.js +11 -3
- package/dist/sdks/typescript/runtime/launcher.d.ts +5 -2
- package/dist/sdks/typescript/runtime/launcher.js +6 -3
- package/dist/sdks/typescript/runtime/responder.d.ts +26 -0
- package/dist/sdks/typescript/runtime/responder.js +42 -0
- package/dist/sdks/typescript/runtime/wait.d.ts +14 -0
- package/dist/sdks/typescript/runtime/wait.js +23 -0
- package/dist/sdks/typescript/types.d.ts +16 -6
- package/package.json +9 -7
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Generated by codegen from spec/ir.json. Do not edit: change the routes and run `pnpm sdk`.
|
|
2
|
-
import { ClientBase, connectWith, disposeQuietly, printsAs, QUIET, quietOf, sessionOf } from "../runtime/client.js";
|
|
2
|
+
import { ClientBase, connectWith, CONTEXT, disposeQuietly, printsAs, QUIET, quietOf, sessionOf } from "../runtime/client.js";
|
|
3
3
|
import { credential } from "../runtime/credentials.js";
|
|
4
4
|
import { parseDuration } from "../runtime/duration.js";
|
|
5
|
-
import { readChanges, readDocument, readTree } from "../runtime/files.js";
|
|
5
|
+
import { readChanges, readDocument, readMedia, readTree } from "../runtime/files.js";
|
|
6
|
+
import { respondWith } from "../runtime/responder.js";
|
|
6
7
|
import { ChannelstackError, segment } from "../runtime/transport.js";
|
|
7
8
|
import { describeWait, fromMatches, textMatches, latestOnceQuiet, waitFor, waitForNext, retryWhile, untilQuiet, patternOnWire } from "../runtime/wait.js";
|
|
8
9
|
/** The server version this SDK was generated for. */
|
|
9
|
-
export const VERSION = "0.
|
|
10
|
+
export const VERSION = "0.2.0";
|
|
10
11
|
export class AccountInactiveError extends ChannelstackError {
|
|
11
12
|
}
|
|
12
13
|
export class ActionRequiresError extends ChannelstackError {
|
|
@@ -15,6 +16,12 @@ export class AlreadyInChannelError extends ChannelstackError {
|
|
|
15
16
|
}
|
|
16
17
|
export class AlreadyReactedError extends ChannelstackError {
|
|
17
18
|
}
|
|
19
|
+
export class CannotDmBotError extends ChannelstackError {
|
|
20
|
+
}
|
|
21
|
+
export class CannotEditOthersMessageError extends ChannelstackError {
|
|
22
|
+
}
|
|
23
|
+
export class CannotMessageUserError extends ChannelstackError {
|
|
24
|
+
}
|
|
18
25
|
export class CantDeleteMessageError extends ChannelstackError {
|
|
19
26
|
}
|
|
20
27
|
export class CantUpdateMessageError extends ChannelstackError {
|
|
@@ -23,6 +30,8 @@ export class CrossWorkspaceCredentialError extends ChannelstackError {
|
|
|
23
30
|
}
|
|
24
31
|
export class DispatchFailedError extends ChannelstackError {
|
|
25
32
|
}
|
|
33
|
+
export class EmptyMessageError extends ChannelstackError {
|
|
34
|
+
}
|
|
26
35
|
export class FakeActorInLiveWorldError extends ChannelstackError {
|
|
27
36
|
}
|
|
28
37
|
export class ForbiddenError extends ChannelstackError {
|
|
@@ -33,10 +42,18 @@ export class InvalidArgumentError extends ChannelstackError {
|
|
|
33
42
|
}
|
|
34
43
|
export class InvalidAuthError extends ChannelstackError {
|
|
35
44
|
}
|
|
45
|
+
export class InvalidFormBodyError extends ChannelstackError {
|
|
46
|
+
}
|
|
36
47
|
export class LiveMisconfiguredError extends ChannelstackError {
|
|
37
48
|
}
|
|
38
49
|
export class LiveNotAllowlistedError extends ChannelstackError {
|
|
39
50
|
}
|
|
51
|
+
export class MethodNotSupportedForChannelTypeError extends ChannelstackError {
|
|
52
|
+
}
|
|
53
|
+
export class MissingAccessError extends ChannelstackError {
|
|
54
|
+
}
|
|
55
|
+
export class MissingPermissionsError extends ChannelstackError {
|
|
56
|
+
}
|
|
40
57
|
export class MsgTooLongError extends ChannelstackError {
|
|
41
58
|
}
|
|
42
59
|
export class NameTakenError extends ChannelstackError {
|
|
@@ -53,18 +70,26 @@ export class NotInChannelError extends ChannelstackError {
|
|
|
53
70
|
}
|
|
54
71
|
export class NotInRoomError extends ChannelstackError {
|
|
55
72
|
}
|
|
73
|
+
export class ObjectNotFoundError extends ChannelstackError {
|
|
74
|
+
}
|
|
75
|
+
export class RestrictedResourceError extends ChannelstackError {
|
|
76
|
+
}
|
|
56
77
|
export class SessionNotFoundError extends ChannelstackError {
|
|
57
78
|
}
|
|
58
79
|
export class SplitViewUnavailableError extends ChannelstackError {
|
|
59
80
|
}
|
|
60
81
|
export class StopUnavailableError extends ChannelstackError {
|
|
61
82
|
}
|
|
83
|
+
export class ThreadAlreadyCreatedError extends ChannelstackError {
|
|
84
|
+
}
|
|
62
85
|
export class UnauthorizedError extends ChannelstackError {
|
|
63
86
|
}
|
|
64
87
|
export class UnsupportedInFakeError extends ChannelstackError {
|
|
65
88
|
}
|
|
66
89
|
export class UnsupportedInLiveError extends ChannelstackError {
|
|
67
90
|
}
|
|
91
|
+
export class ValidationErrorError extends ChannelstackError {
|
|
92
|
+
}
|
|
68
93
|
export class ValidationFailedError extends ChannelstackError {
|
|
69
94
|
}
|
|
70
95
|
const ERRORS = {
|
|
@@ -72,17 +97,25 @@ const ERRORS = {
|
|
|
72
97
|
action_requires: ActionRequiresError,
|
|
73
98
|
already_in_channel: AlreadyInChannelError,
|
|
74
99
|
already_reacted: AlreadyReactedError,
|
|
100
|
+
cannot_dm_bot: CannotDmBotError,
|
|
101
|
+
cannot_edit_others_message: CannotEditOthersMessageError,
|
|
102
|
+
cannot_message_user: CannotMessageUserError,
|
|
75
103
|
cant_delete_message: CantDeleteMessageError,
|
|
76
104
|
cant_update_message: CantUpdateMessageError,
|
|
77
105
|
cross_workspace_credential: CrossWorkspaceCredentialError,
|
|
78
106
|
dispatch_failed: DispatchFailedError,
|
|
107
|
+
empty_message: EmptyMessageError,
|
|
79
108
|
fake_actor_in_live_world: FakeActorInLiveWorldError,
|
|
80
109
|
forbidden: ForbiddenError,
|
|
81
110
|
internal: InternalError,
|
|
82
111
|
invalid_argument: InvalidArgumentError,
|
|
83
112
|
invalid_auth: InvalidAuthError,
|
|
113
|
+
invalid_form_body: InvalidFormBodyError,
|
|
84
114
|
live_misconfigured: LiveMisconfiguredError,
|
|
85
115
|
live_not_allowlisted: LiveNotAllowlistedError,
|
|
116
|
+
method_not_supported_for_channel_type: MethodNotSupportedForChannelTypeError,
|
|
117
|
+
missing_access: MissingAccessError,
|
|
118
|
+
missing_permissions: MissingPermissionsError,
|
|
86
119
|
msg_too_long: MsgTooLongError,
|
|
87
120
|
name_taken: NameTakenError,
|
|
88
121
|
no_reaction: NoReactionError,
|
|
@@ -91,14 +124,24 @@ const ERRORS = {
|
|
|
91
124
|
not_found: NotFoundError,
|
|
92
125
|
not_in_channel: NotInChannelError,
|
|
93
126
|
not_in_room: NotInRoomError,
|
|
127
|
+
object_not_found: ObjectNotFoundError,
|
|
128
|
+
restricted_resource: RestrictedResourceError,
|
|
94
129
|
session_not_found: SessionNotFoundError,
|
|
95
130
|
split_view_unavailable: SplitViewUnavailableError,
|
|
96
131
|
stop_unavailable: StopUnavailableError,
|
|
132
|
+
thread_already_created: ThreadAlreadyCreatedError,
|
|
97
133
|
unauthorized: UnauthorizedError,
|
|
98
134
|
unsupported_in_fake: UnsupportedInFakeError,
|
|
99
135
|
unsupported_in_live: UnsupportedInLiveError,
|
|
136
|
+
validation_error: ValidationErrorError,
|
|
100
137
|
validation_failed: ValidationFailedError,
|
|
101
138
|
};
|
|
139
|
+
function decodeEchoApps(ctx, data) {
|
|
140
|
+
return data.map((item) => new EchoApp(ctx, item));
|
|
141
|
+
}
|
|
142
|
+
function decodeSlackApps(ctx, data) {
|
|
143
|
+
return data.map((item) => new SlackApp(ctx, item));
|
|
144
|
+
}
|
|
102
145
|
function decodeSlackUsers(ctx, data) {
|
|
103
146
|
return data.map((item) => new SlackUser(ctx, item));
|
|
104
147
|
}
|
|
@@ -141,6 +184,21 @@ function decodeSlackDeliveries(ctx, data) {
|
|
|
141
184
|
function decodeSlackUninstallDeliveries(ctx, data) {
|
|
142
185
|
return data.map((item) => new SlackDelivery(ctx, item));
|
|
143
186
|
}
|
|
187
|
+
function decodeGitHubUsers(ctx, data) {
|
|
188
|
+
return data.map((item) => new GitHubUser(ctx, item));
|
|
189
|
+
}
|
|
190
|
+
function decodeGitHubRepos(ctx, data) {
|
|
191
|
+
return data.map((item) => new GitHubRepo(ctx, item));
|
|
192
|
+
}
|
|
193
|
+
function decodeGitHubIssues(ctx, data) {
|
|
194
|
+
return data.map((item) => decodeGitHubIssueListing(ctx, item));
|
|
195
|
+
}
|
|
196
|
+
function decodeGitHubIssueListing(ctx, data) {
|
|
197
|
+
return { ...data, issue: new GitHubIssue(ctx, data.issue) };
|
|
198
|
+
}
|
|
199
|
+
function decodeGitHubApps(ctx, data) {
|
|
200
|
+
return data.map((item) => new GitHubApp(ctx, item));
|
|
201
|
+
}
|
|
144
202
|
function decodeGitHubCommits(ctx, data) {
|
|
145
203
|
return data.map((item) => new GitHubCommit(ctx, item));
|
|
146
204
|
}
|
|
@@ -189,6 +247,21 @@ function decodeGitHubReviewCommentReplies(ctx, data) {
|
|
|
189
247
|
function decodeGitHubDeliveries(ctx, data) {
|
|
190
248
|
return data.map((item) => new GitHubDelivery(ctx, item));
|
|
191
249
|
}
|
|
250
|
+
function decodeLinearApps(ctx, data) {
|
|
251
|
+
return data.map((item) => new LinearApp(ctx, item));
|
|
252
|
+
}
|
|
253
|
+
function decodeLinearUsers(ctx, data) {
|
|
254
|
+
return data.map((item) => new LinearUser(ctx, item));
|
|
255
|
+
}
|
|
256
|
+
function decodeLinearTeams(ctx, data) {
|
|
257
|
+
return data.map((item) => new LinearTeam(ctx, item));
|
|
258
|
+
}
|
|
259
|
+
function decodeLinearIssues(ctx, data) {
|
|
260
|
+
return data.map((item) => decodeLinearIssueListing(ctx, item));
|
|
261
|
+
}
|
|
262
|
+
function decodeLinearIssueListing(ctx, data) {
|
|
263
|
+
return { ...data, issue: new LinearIssue(ctx, data.issue) };
|
|
264
|
+
}
|
|
192
265
|
function decodeLinearComments(ctx, data) {
|
|
193
266
|
return data.map((item) => new LinearComment(ctx, item));
|
|
194
267
|
}
|
|
@@ -207,6 +280,15 @@ function decodeLinearAgentActivities(ctx, data) {
|
|
|
207
280
|
function decodeLinearDeliveries(ctx, data) {
|
|
208
281
|
return data.map((item) => new LinearDelivery(ctx, item));
|
|
209
282
|
}
|
|
283
|
+
function decodeNotionIntegrations(ctx, data) {
|
|
284
|
+
return data.map((item) => new NotionIntegration(ctx, item));
|
|
285
|
+
}
|
|
286
|
+
function decodeNotionUsers(ctx, data) {
|
|
287
|
+
return data.map((item) => new NotionUser(ctx, item));
|
|
288
|
+
}
|
|
289
|
+
function decodeNotionPages(ctx, data) {
|
|
290
|
+
return data.map((item) => new NotionPage(ctx, item));
|
|
291
|
+
}
|
|
210
292
|
function decodeNotionPropertyValue(ctx, data) {
|
|
211
293
|
return (data === null ? undefined : data);
|
|
212
294
|
}
|
|
@@ -231,6 +313,15 @@ function decodeNotionComments(ctx, data) {
|
|
|
231
313
|
function decodeNotionDeliveries(ctx, data) {
|
|
232
314
|
return data.map((item) => new NotionDelivery(ctx, item));
|
|
233
315
|
}
|
|
316
|
+
function decodeResendApps(ctx, data) {
|
|
317
|
+
return data.map((item) => new ResendApp(ctx, item));
|
|
318
|
+
}
|
|
319
|
+
function decodeResendUsers(ctx, data) {
|
|
320
|
+
return data.map((item) => new ResendUser(ctx, item));
|
|
321
|
+
}
|
|
322
|
+
function decodeResendThreads(ctx, data) {
|
|
323
|
+
return data.map((item) => new ResendThread(ctx, item));
|
|
324
|
+
}
|
|
234
325
|
function decodeResendInbox(ctx, data) {
|
|
235
326
|
return data.map((item) => new ResendEmail(ctx, item));
|
|
236
327
|
}
|
|
@@ -246,6 +337,15 @@ function decodeResendTranscript(_ctx, data) {
|
|
|
246
337
|
function decodeResendDeliveries(ctx, data) {
|
|
247
338
|
return data.map((item) => new ResendDelivery(ctx, item));
|
|
248
339
|
}
|
|
340
|
+
function decodeGoogleApps(ctx, data) {
|
|
341
|
+
return data.map((item) => new GoogleApp(ctx, item));
|
|
342
|
+
}
|
|
343
|
+
function decodeGoogleUsers(ctx, data) {
|
|
344
|
+
return data.map((item) => new GoogleUser(ctx, item));
|
|
345
|
+
}
|
|
346
|
+
function decodeGoogleThreads(ctx, data) {
|
|
347
|
+
return data.map((item) => new GoogleThread(ctx, item));
|
|
348
|
+
}
|
|
249
349
|
function decodeGoogleInbox(ctx, data) {
|
|
250
350
|
return data.map((item) => new GoogleEmail(ctx, item));
|
|
251
351
|
}
|
|
@@ -261,6 +361,60 @@ function decodeGoogleTranscript(_ctx, data) {
|
|
|
261
361
|
function decodeGoogleDeliveries(ctx, data) {
|
|
262
362
|
return data.map((item) => new GoogleDelivery(ctx, item));
|
|
263
363
|
}
|
|
364
|
+
function decodeDiscordApps(ctx, data) {
|
|
365
|
+
return data.map((item) => new DiscordApp(ctx, item));
|
|
366
|
+
}
|
|
367
|
+
function decodeDiscordUsers(ctx, data) {
|
|
368
|
+
return data.map((item) => new DiscordUser(ctx, item));
|
|
369
|
+
}
|
|
370
|
+
function decodeDiscordChannels(ctx, data) {
|
|
371
|
+
return data.map((item) => new DiscordChannel(ctx, item));
|
|
372
|
+
}
|
|
373
|
+
function decodeDiscordEphemeralMessages(ctx, data) {
|
|
374
|
+
return data.map((item) => new DiscordMessage(ctx, item));
|
|
375
|
+
}
|
|
376
|
+
function decodeDiscordMessages(ctx, data) {
|
|
377
|
+
return data.map((item) => new DiscordMessage(ctx, item));
|
|
378
|
+
}
|
|
379
|
+
function decodeDiscordMembers(ctx, data) {
|
|
380
|
+
return data.map((item) => item.kind === "user" ? new DiscordUser(ctx, item) : new DiscordApp(ctx, item));
|
|
381
|
+
}
|
|
382
|
+
function decodeDiscordThreads(ctx, data) {
|
|
383
|
+
return data.map((item) => new DiscordChannel(ctx, item));
|
|
384
|
+
}
|
|
385
|
+
function decodeDiscordTranscript(_ctx, data) {
|
|
386
|
+
return printsAs({ ...data }, data.text);
|
|
387
|
+
}
|
|
388
|
+
function decodeDiscordReplies(ctx, data) {
|
|
389
|
+
return data.map((item) => new DiscordMessage(ctx, item));
|
|
390
|
+
}
|
|
391
|
+
function decodeDiscordReactions(ctx, data) {
|
|
392
|
+
return data.map((item) => decodeDiscordReaction(ctx, item));
|
|
393
|
+
}
|
|
394
|
+
function decodeDiscordReaction(ctx, data) {
|
|
395
|
+
return { ...data, by: data.by.map((item) => item.kind === "user" ? new DiscordUser(ctx, item) : new DiscordApp(ctx, item)) };
|
|
396
|
+
}
|
|
397
|
+
function decodeDiscordMessageDeliveries(ctx, data) {
|
|
398
|
+
return data.map((item) => new DiscordDelivery(ctx, item));
|
|
399
|
+
}
|
|
400
|
+
function decodeDiscordDeliveries(ctx, data) {
|
|
401
|
+
return data.map((item) => new DiscordDelivery(ctx, item));
|
|
402
|
+
}
|
|
403
|
+
function decodeOpenAICalls(ctx, data) {
|
|
404
|
+
return data.map((item) => new OpenAICall(ctx, item));
|
|
405
|
+
}
|
|
406
|
+
function decodeOpenAIPausedCalls(ctx, data) {
|
|
407
|
+
return data.map((item) => new OpenAICall(ctx, item));
|
|
408
|
+
}
|
|
409
|
+
function decodeOpenAISessionCalls(ctx, data) {
|
|
410
|
+
return data.map((item) => new OpenAICall(ctx, item));
|
|
411
|
+
}
|
|
412
|
+
function decodePlaces(ctx, data) {
|
|
413
|
+
return data.map((item) => new Place(ctx, item));
|
|
414
|
+
}
|
|
415
|
+
function decodePlaceTranscript(_ctx, data) {
|
|
416
|
+
return printsAs({ ...data }, data.text);
|
|
417
|
+
}
|
|
264
418
|
export class Channelstack extends ClientBase {
|
|
265
419
|
#ctx;
|
|
266
420
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
@@ -288,7 +442,7 @@ export class Channelstack extends ClientBase {
|
|
|
288
442
|
/** Env vars for the agent: fake tokens, signing secrets and API URLs (what `channelstack env` prints). With `proxy`, the proxy and the CA instead of the API URLs. */
|
|
289
443
|
async env(options = {}) {
|
|
290
444
|
const ctx = this.#ctx;
|
|
291
|
-
const data = (await ctx.transport.request("GET", `/env`, { query: { proxy: options.proxy } }));
|
|
445
|
+
const data = (await ctx.transport.request("GET", `/env`, { query: { proxy: options.proxy, app: options.app, channel: options.channel } }));
|
|
292
446
|
return data;
|
|
293
447
|
}
|
|
294
448
|
/** A new one-time link that opens the UI in a browser (what `channelstack ui` prints). Experimental. */
|
|
@@ -370,10 +524,32 @@ export class Session {
|
|
|
370
524
|
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/google`));
|
|
371
525
|
return new GoogleFixture(ctx, data);
|
|
372
526
|
}
|
|
527
|
+
/** The Discord fixture: the agent's app, the guild, and where the agent reaches the fake. Experimental. */
|
|
528
|
+
async discord() {
|
|
529
|
+
const ctx = this.#ctx;
|
|
530
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord`));
|
|
531
|
+
return new DiscordFixture(ctx, data);
|
|
532
|
+
}
|
|
533
|
+
/** The OpenAI fixture: where the agent reaches the fake model. Experimental. */
|
|
534
|
+
async openai() {
|
|
535
|
+
const ctx = this.#ctx;
|
|
536
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai`));
|
|
537
|
+
return new OpenAIFixture(ctx, data);
|
|
538
|
+
}
|
|
539
|
+
/** Every channel's places in the session, as the dev tools name them (a Slack channel, a GitHub issue, a Notion page, an email thread, a Discord channel), the most recently active last. Experimental. */
|
|
540
|
+
async places() {
|
|
541
|
+
const ctx = this.#ctx;
|
|
542
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/places`));
|
|
543
|
+
return decodePlaces(ctx, data);
|
|
544
|
+
}
|
|
373
545
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
374
546
|
[QUIET]() {
|
|
375
547
|
return quietOf(this.#ctx);
|
|
376
548
|
}
|
|
549
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
550
|
+
[CONTEXT]() {
|
|
551
|
+
return this.#ctx;
|
|
552
|
+
}
|
|
377
553
|
}
|
|
378
554
|
export class EchoFixture {
|
|
379
555
|
app;
|
|
@@ -391,6 +567,18 @@ export class EchoFixture {
|
|
|
391
567
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/echo/users`, { body: { name: options.name } }));
|
|
392
568
|
return new EchoUser(ctx, data);
|
|
393
569
|
}
|
|
570
|
+
/** Make another app (decision 0027), or return the one with this name. Its events go to CHANNELSTACK_ECHO_APP_<NAME>_WEBHOOK_URL. Experimental. */
|
|
571
|
+
async createApp(options) {
|
|
572
|
+
const ctx = this.#ctx;
|
|
573
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/echo/apps`, { body: { name: options.name } }));
|
|
574
|
+
return new EchoApp(ctx, data);
|
|
575
|
+
}
|
|
576
|
+
/** The apps this session used: the built-in one first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here. Experimental. */
|
|
577
|
+
async apps() {
|
|
578
|
+
const ctx = this.#ctx;
|
|
579
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/echo/apps`));
|
|
580
|
+
return decodeEchoApps(ctx, data);
|
|
581
|
+
}
|
|
394
582
|
/** Create a room. Only the listed participants are members; include the app for it to receive events. Experimental. */
|
|
395
583
|
async createRoom(options = {}) {
|
|
396
584
|
const ctx = this.#ctx;
|
|
@@ -407,6 +595,10 @@ export class EchoFixture {
|
|
|
407
595
|
[QUIET]() {
|
|
408
596
|
return quietOf(this.#ctx);
|
|
409
597
|
}
|
|
598
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
599
|
+
[CONTEXT]() {
|
|
600
|
+
return this.#ctx;
|
|
601
|
+
}
|
|
410
602
|
}
|
|
411
603
|
export class EchoApp {
|
|
412
604
|
id;
|
|
@@ -420,10 +612,20 @@ export class EchoApp {
|
|
|
420
612
|
this.name = data.name;
|
|
421
613
|
this.kind = data.kind;
|
|
422
614
|
}
|
|
615
|
+
/** An app a test made posts in a room it is a member of, as its own call would. Experimental. */
|
|
616
|
+
async say(text, options) {
|
|
617
|
+
const ctx = this.#ctx;
|
|
618
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/echo/apps/${segment(this.id)}/say`, { body: { text, room: options.room.id } }));
|
|
619
|
+
return data;
|
|
620
|
+
}
|
|
423
621
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
424
622
|
[QUIET]() {
|
|
425
623
|
return quietOf(this.#ctx);
|
|
426
624
|
}
|
|
625
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
626
|
+
[CONTEXT]() {
|
|
627
|
+
return this.#ctx;
|
|
628
|
+
}
|
|
427
629
|
}
|
|
428
630
|
export class EchoUser {
|
|
429
631
|
id;
|
|
@@ -447,6 +649,10 @@ export class EchoUser {
|
|
|
447
649
|
[QUIET]() {
|
|
448
650
|
return quietOf(this.#ctx);
|
|
449
651
|
}
|
|
652
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
653
|
+
[CONTEXT]() {
|
|
654
|
+
return this.#ctx;
|
|
655
|
+
}
|
|
450
656
|
}
|
|
451
657
|
export class EchoRoom {
|
|
452
658
|
id;
|
|
@@ -476,6 +682,10 @@ export class EchoRoom {
|
|
|
476
682
|
[QUIET]() {
|
|
477
683
|
return quietOf(this.#ctx);
|
|
478
684
|
}
|
|
685
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
686
|
+
[CONTEXT]() {
|
|
687
|
+
return this.#ctx;
|
|
688
|
+
}
|
|
479
689
|
}
|
|
480
690
|
export class SlackFixture {
|
|
481
691
|
app;
|
|
@@ -504,6 +714,18 @@ export class SlackFixture {
|
|
|
504
714
|
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/users`));
|
|
505
715
|
return decodeSlackUsers(ctx, data);
|
|
506
716
|
}
|
|
717
|
+
/** Make another app in the workspace, with its own bot user, tokens and signing secret (decision 0027), or return the one made with this name and settings. Its events go to CHANNELSTACK_SLACK_APP_<NAME>_WEBHOOK_URL, or over its own Socket Mode connection. Experimental. */
|
|
718
|
+
async createApp(options) {
|
|
719
|
+
const ctx = this.#ctx;
|
|
720
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/apps`, { body: { name: options.name, scopes: options.scopes, botEvents: options.botEvents } }));
|
|
721
|
+
return new SlackApp(ctx, data);
|
|
722
|
+
}
|
|
723
|
+
/** The apps this session used: the built-in one first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here. Experimental. */
|
|
724
|
+
async apps() {
|
|
725
|
+
const ctx = this.#ctx;
|
|
726
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/apps`));
|
|
727
|
+
return decodeSlackApps(ctx, data);
|
|
728
|
+
}
|
|
507
729
|
/** The session's conversations, the one with the newest message last. Experimental. */
|
|
508
730
|
async conversations() {
|
|
509
731
|
const ctx = this.#ctx;
|
|
@@ -517,9 +739,9 @@ export class SlackFixture {
|
|
|
517
739
|
return new SlackConversation(ctx, data);
|
|
518
740
|
}
|
|
519
741
|
/** Every event channelstack sent the agent for this session, with every attempt. Experimental. */
|
|
520
|
-
async deliveries() {
|
|
742
|
+
async deliveries(options = {}) {
|
|
521
743
|
const ctx = this.#ctx;
|
|
522
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/deliveries
|
|
744
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/deliveries`, { query: { app: options.app === undefined ? undefined : options.app.id } }));
|
|
523
745
|
return decodeSlackDeliveries(ctx, data);
|
|
524
746
|
}
|
|
525
747
|
/** The Web API calls the agent made about this session's conversations, people and files. Calls about nothing a session owns (auth.test, users.list) are in no session. Experimental. */
|
|
@@ -528,26 +750,30 @@ export class SlackFixture {
|
|
|
528
750
|
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/calls`, { query: { operation: options.operation, error: options.error } }));
|
|
529
751
|
return data;
|
|
530
752
|
}
|
|
531
|
-
/** The workspace uninstalls the
|
|
532
|
-
async uninstallApp() {
|
|
753
|
+
/** The workspace uninstalls an app: the built-in one, or the one given. Undone when this session closes; run such tests on their own. Experimental. */
|
|
754
|
+
async uninstallApp(options = {}) {
|
|
533
755
|
const ctx = this.#ctx;
|
|
534
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/uninstall
|
|
756
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/uninstall`, { body: { app: options.app === undefined ? undefined : options.app.id } }));
|
|
535
757
|
return decodeSlackUninstallDeliveries(ctx, data);
|
|
536
758
|
}
|
|
537
759
|
/** Inject a fault: into the agent's Web API calls (removed when this session closes), or drop its Socket Mode connection once. Experimental. */
|
|
538
760
|
async fault(options) {
|
|
539
761
|
const ctx = this.#ctx;
|
|
540
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/faults`, { body: { type: options.type, operation: options.operation, retryAfter: options.retryAfter === undefined ? undefined : parseDuration(options.retryAfter), delay: options.delay === undefined ? undefined : parseDuration(options.delay), after: options.after === undefined ? undefined : parseDuration(options.after), error: options.error, times: options.times } }));
|
|
762
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/faults`, { body: { type: options.type, operation: options.operation, retryAfter: options.retryAfter === undefined ? undefined : parseDuration(options.retryAfter), delay: options.delay === undefined ? undefined : parseDuration(options.delay), after: options.after === undefined ? undefined : parseDuration(options.after), error: options.error, times: options.times, app: options.app === undefined ? undefined : options.app.id } }));
|
|
541
763
|
return new SlackFault(ctx, data);
|
|
542
764
|
}
|
|
543
765
|
/** Wait for the next new API call from the agent, after the last one this handle saw. */
|
|
544
|
-
async waitForCall(filter, options = {}) {
|
|
766
|
+
async waitForCall(filter = {}, options = {}) {
|
|
545
767
|
return waitForNext(this.#seen, `waitForCall:${JSON.stringify(filter)}`, () => this.calls(filter), () => true, "an API call from the agent", options);
|
|
546
768
|
}
|
|
547
769
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
548
770
|
[QUIET]() {
|
|
549
771
|
return quietOf(this.#ctx);
|
|
550
772
|
}
|
|
773
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
774
|
+
[CONTEXT]() {
|
|
775
|
+
return this.#ctx;
|
|
776
|
+
}
|
|
551
777
|
}
|
|
552
778
|
export class SlackApp {
|
|
553
779
|
id;
|
|
@@ -573,10 +799,38 @@ export class SlackApp {
|
|
|
573
799
|
this.signingSecret = data.signingSecret;
|
|
574
800
|
this.scopes = data.scopes;
|
|
575
801
|
}
|
|
802
|
+
/** An app a test made writes a top-level message, as its own chat.postMessage would: in a conversation it is a member of, or in a DM with the people in `to`. Experimental. */
|
|
803
|
+
async say(message, options = {}) {
|
|
804
|
+
const ctx = this.#ctx;
|
|
805
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/apps/${segment(this.id)}/say`, { body: { message: typeof message === "string" ? { text: message } : (typeof message === "string" ? { text: message } : message), channel: options.channel === undefined ? undefined : options.channel.id, to: options.to === undefined ? undefined : [options.to].flat().map((item) => item.id) } }));
|
|
806
|
+
return new SlackMessage(ctx, data);
|
|
807
|
+
}
|
|
808
|
+
/** An app a test made replies in a thread: pass the message that starts it, or any reply in it. Experimental. */
|
|
809
|
+
async reply(message, options) {
|
|
810
|
+
const ctx = this.#ctx;
|
|
811
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/apps/${segment(this.id)}/reply`, { body: { message: typeof message === "string" ? { text: message } : (typeof message === "string" ? { text: message } : message), thread: { channel: options.thread.channel, ts: options.thread.ts } } }));
|
|
812
|
+
return new SlackMessage(ctx, data);
|
|
813
|
+
}
|
|
814
|
+
/** An app a test made reacts to a message. Experimental. */
|
|
815
|
+
async react(emoji, options) {
|
|
816
|
+
const ctx = this.#ctx;
|
|
817
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/apps/${segment(this.id)}/react`, { body: { emoji, message: { channel: options.message.channel, ts: options.message.ts } } }));
|
|
818
|
+
return (data === null ? undefined : new SlackDelivery(ctx, data));
|
|
819
|
+
}
|
|
820
|
+
/** An app a test made takes its reaction back. Experimental. */
|
|
821
|
+
async unreact(emoji, options) {
|
|
822
|
+
const ctx = this.#ctx;
|
|
823
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/apps/${segment(this.id)}/unreact`, { body: { emoji, message: { channel: options.message.channel, ts: options.message.ts } } }));
|
|
824
|
+
return (data === null ? undefined : new SlackDelivery(ctx, data));
|
|
825
|
+
}
|
|
576
826
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
577
827
|
[QUIET]() {
|
|
578
828
|
return quietOf(this.#ctx);
|
|
579
829
|
}
|
|
830
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
831
|
+
[CONTEXT]() {
|
|
832
|
+
return this.#ctx;
|
|
833
|
+
}
|
|
580
834
|
}
|
|
581
835
|
export class SlackUser {
|
|
582
836
|
id;
|
|
@@ -604,19 +858,19 @@ export class SlackUser {
|
|
|
604
858
|
/** Post a top-level message in a conversation, or in a DM with the people in `to`. Experimental. */
|
|
605
859
|
async say(message, options = {}) {
|
|
606
860
|
const ctx = this.#ctx;
|
|
607
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/say`, { body: { message: typeof message === "string" ? { text: message } : message, channel: options.channel === undefined ? undefined : options.channel.id, to: options.to === undefined ? undefined : [options.to].flat().map((item) => item.id), files: options.files === undefined ? undefined : readTree(options.files) } }));
|
|
861
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/say`, { body: { message: typeof message === "string" ? { text: message } : (typeof message === "string" ? { text: message } : message), channel: options.channel === undefined ? undefined : options.channel.id, to: options.to === undefined ? undefined : [options.to].flat().map((item) => item.id), files: options.files === undefined ? undefined : readTree(options.files) } }));
|
|
608
862
|
return new SlackMessage(ctx, data);
|
|
609
863
|
}
|
|
610
864
|
/** Reply in a thread: pass the message that starts it, or any reply in it. Experimental. */
|
|
611
865
|
async reply(message, options) {
|
|
612
866
|
const ctx = this.#ctx;
|
|
613
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/reply`, { body: { message: typeof message === "string" ? { text: message } : message, thread: { channel: options.thread.channel, ts: options.thread.ts }, alsoSendToChannel: options.alsoSendToChannel, files: options.files === undefined ? undefined : readTree(options.files) } }));
|
|
867
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/reply`, { body: { message: typeof message === "string" ? { text: message } : (typeof message === "string" ? { text: message } : message), thread: { channel: options.thread.channel, ts: options.thread.ts }, alsoSendToChannel: options.alsoSendToChannel, files: options.files === undefined ? undefined : readTree(options.files) } }));
|
|
614
868
|
return new SlackMessage(ctx, data);
|
|
615
869
|
}
|
|
616
870
|
/** Edit one of this person's own messages. Experimental. */
|
|
617
871
|
async edit(text, options) {
|
|
618
872
|
const ctx = this.#ctx;
|
|
619
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/edit`, { body: { text: typeof text === "string" ? { text: text } : text, message: { channel: options.message.channel, ts: options.message.ts } } }));
|
|
873
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/edit`, { body: { text: typeof text === "string" ? { text: text } : (typeof text === "string" ? { text: text } : text), message: { channel: options.message.channel, ts: options.message.ts } } }));
|
|
620
874
|
return new SlackMessage(ctx, data);
|
|
621
875
|
}
|
|
622
876
|
/** Delete a message: this person's own, or anyone's for an admin. Experimental. */
|
|
@@ -627,25 +881,25 @@ export class SlackUser {
|
|
|
627
881
|
/** Click a button, found by its label or action_id: on a message, or on the app's latest message that has it in a thread or a conversation. Experimental. */
|
|
628
882
|
async click(button, options = {}) {
|
|
629
883
|
const ctx = this.#ctx;
|
|
630
|
-
const data = (await retryWhile(["not_found"], () => ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/click`, { body: { button: typeof button === "string" ? { label: button } : button, message: options.message === undefined ? undefined : { channel: options.message.channel, ts: options.message.ts }, thread: options.thread === undefined ? undefined : { channel: options.thread.channel, ts: options.thread.ts }, channel: options.channel === undefined ? undefined : options.channel.id } })));
|
|
884
|
+
const data = (await retryWhile(["not_found"], () => ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/click`, { body: { button: typeof button === "string" ? { label: button } : (typeof button === "string" ? { label: button } : button), message: options.message === undefined ? undefined : { channel: options.message.channel, ts: options.message.ts }, thread: options.thread === undefined ? undefined : { channel: options.thread.channel, ts: options.thread.ts }, channel: options.channel === undefined ? undefined : options.channel.id } })));
|
|
631
885
|
return (data === null ? undefined : new SlackDelivery(ctx, data));
|
|
632
886
|
}
|
|
633
887
|
/** Choose from a select menu on a message: options by their text or value, the menu by its placeholder or action_id. Experimental. */
|
|
634
888
|
async select(option, options) {
|
|
635
889
|
const ctx = this.#ctx;
|
|
636
|
-
const data = (await retryWhile(["not_found"], () => ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/select`, { body: { option: [option].flat(), menu: typeof options.menu === "string" ? { label: options.menu } : options.menu, message: { channel: options.message.channel, ts: options.message.ts } } })));
|
|
890
|
+
const data = (await retryWhile(["not_found"], () => ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/select`, { body: { option: [option].flat(), menu: typeof options.menu === "string" ? { label: options.menu } : (typeof options.menu === "string" ? { label: options.menu } : options.menu), message: { channel: options.message.channel, ts: options.message.ts } } })));
|
|
637
891
|
return new SlackDelivery(ctx, data);
|
|
638
892
|
}
|
|
639
|
-
/** Run
|
|
893
|
+
/** Run an app's message shortcut on a message: it goes to that app alone. Experimental. */
|
|
640
894
|
async shortcut(callbackId, options) {
|
|
641
895
|
const ctx = this.#ctx;
|
|
642
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/shortcut`, { body: { callbackId, message: { channel: options.message.channel, ts: options.message.ts } } }));
|
|
896
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/shortcut`, { body: { callbackId, message: { channel: options.message.channel, ts: options.message.ts }, app: options.app === undefined ? undefined : options.app.id } }));
|
|
643
897
|
return new SlackDelivery(ctx, data);
|
|
644
898
|
}
|
|
645
|
-
/** Run
|
|
899
|
+
/** Run an app's slash command in a conversation, e.g. `/deploy web staging`: it goes to that app alone. Experimental. */
|
|
646
900
|
async runCommand(command, options) {
|
|
647
901
|
const ctx = this.#ctx;
|
|
648
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/commands`, { body: { command, channel: options.channel.id } }));
|
|
902
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/commands`, { body: { command, channel: options.channel.id, app: options.app === undefined ? undefined : options.app.id } }));
|
|
649
903
|
return new SlackDelivery(ctx, data);
|
|
650
904
|
}
|
|
651
905
|
/** Press Stop on the app's work in a thread: what is streaming there ends, and the app is told. Experimental. */
|
|
@@ -654,10 +908,10 @@ export class SlackUser {
|
|
|
654
908
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/stop`, { body: { thread: { channel: options.thread.channel, ts: options.thread.ts } } }));
|
|
655
909
|
return new SlackDelivery(ctx, data);
|
|
656
910
|
}
|
|
657
|
-
/** Open
|
|
911
|
+
/** Open an app's split view: a new thread in this person's DM with that app, started from the channel they are looking at. Experimental. */
|
|
658
912
|
async openAgentThread(options = {}) {
|
|
659
913
|
const ctx = this.#ctx;
|
|
660
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/agent-threads`, { body: { from: options.from === undefined ? undefined : options.from.id } }));
|
|
914
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/slack/users/${segment(this.id)}/agent-threads`, { body: { from: options.from === undefined ? undefined : options.from.id, app: options.app === undefined ? undefined : options.app.id } }));
|
|
661
915
|
return new SlackThread(ctx, data);
|
|
662
916
|
}
|
|
663
917
|
/** Pick one of the prompts the app suggested in a thread: this person says its message there. Experimental. */
|
|
@@ -721,51 +975,9 @@ export class SlackUser {
|
|
|
721
975
|
[QUIET]() {
|
|
722
976
|
return quietOf(this.#ctx);
|
|
723
977
|
}
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
kind;
|
|
728
|
-
name;
|
|
729
|
-
#ctx;
|
|
730
|
-
#seen = new Map();
|
|
731
|
-
/** @internal Handles come from the SDK, never from `new`. */
|
|
732
|
-
constructor(ctx, data) {
|
|
733
|
-
this.#ctx = ctx;
|
|
734
|
-
this.id = data.id;
|
|
735
|
-
this.kind = data.kind;
|
|
736
|
-
this.name = data.name;
|
|
737
|
-
}
|
|
738
|
-
/** The newest message of a conversation, replies included. Experimental. */
|
|
739
|
-
async latestMessage() {
|
|
740
|
-
const ctx = this.#ctx;
|
|
741
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/conversations/${segment(this.id)}/latest`));
|
|
742
|
-
return new SlackMessage(ctx, data);
|
|
743
|
-
}
|
|
744
|
-
/** Top-level messages of a conversation, oldest first. Experimental. */
|
|
745
|
-
async messages() {
|
|
746
|
-
const ctx = this.#ctx;
|
|
747
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/conversations/${segment(this.id)}/messages`));
|
|
748
|
-
return decodeSlackMessages(ctx, data);
|
|
749
|
-
}
|
|
750
|
-
/** The people and apps in a conversation. Experimental. */
|
|
751
|
-
async members() {
|
|
752
|
-
const ctx = this.#ctx;
|
|
753
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/conversations/${segment(this.id)}/members`));
|
|
754
|
-
return decodeSlackMembers(ctx, data);
|
|
755
|
-
}
|
|
756
|
-
/** The conversation as a person would read it, threads included. Experimental. */
|
|
757
|
-
async transcript(options = {}) {
|
|
758
|
-
const ctx = this.#ctx;
|
|
759
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/conversations/${segment(this.id)}/transcript`, { query: { as: options.as === undefined ? undefined : options.as.id } }));
|
|
760
|
-
return decodeSlackTranscript(ctx, data);
|
|
761
|
-
}
|
|
762
|
-
/** Wait for the next new message matching `from` (anyone if omitted), after the last one this handle saw. */
|
|
763
|
-
async waitForMessage(options = {}) {
|
|
764
|
-
return waitForNext(this.#seen, "waitForMessage", () => this.messages(), (item) => fromMatches(item.author, options.from), describeWait("a message", options.from), options);
|
|
765
|
-
}
|
|
766
|
-
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
767
|
-
[QUIET]() {
|
|
768
|
-
return quietOf(this.#ctx);
|
|
978
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
979
|
+
[CONTEXT]() {
|
|
980
|
+
return this.#ctx;
|
|
769
981
|
}
|
|
770
982
|
}
|
|
771
983
|
export class SlackMessage {
|
|
@@ -775,6 +987,7 @@ export class SlackMessage {
|
|
|
775
987
|
author;
|
|
776
988
|
text;
|
|
777
989
|
blocks;
|
|
990
|
+
files;
|
|
778
991
|
postedAt;
|
|
779
992
|
threadTs;
|
|
780
993
|
edited;
|
|
@@ -792,6 +1005,7 @@ export class SlackMessage {
|
|
|
792
1005
|
this.author = data.author.kind === "user" ? new SlackUser(ctx, data.author) : new SlackApp(ctx, data.author);
|
|
793
1006
|
this.text = data.text;
|
|
794
1007
|
this.blocks = data.blocks;
|
|
1008
|
+
this.files = data.files;
|
|
795
1009
|
this.postedAt = data.postedAt;
|
|
796
1010
|
this.threadTs = data.threadTs;
|
|
797
1011
|
this.edited = data.edited;
|
|
@@ -818,6 +1032,12 @@ export class SlackMessage {
|
|
|
818
1032
|
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/conversations/${segment(this.channel)}/messages/${segment(this.ts)}/transcript`, { query: { as: options.as === undefined ? undefined : options.as.id } }));
|
|
819
1033
|
return decodeSlackTranscript(ctx, data);
|
|
820
1034
|
}
|
|
1035
|
+
/** The first delivery this message caused to this app (decision 0027), or nothing when it wasn't told. Experimental. */
|
|
1036
|
+
async deliveryFor(app) {
|
|
1037
|
+
const ctx = this.#ctx;
|
|
1038
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/conversations/${segment(this.channel)}/messages/${segment(this.ts)}/delivery-for`, { query: { app: app.id } }));
|
|
1039
|
+
return (data === null ? undefined : new SlackDelivery(ctx, data));
|
|
1040
|
+
}
|
|
821
1041
|
/** Every delivery this message caused to the agent. Experimental. */
|
|
822
1042
|
async deliveries() {
|
|
823
1043
|
const ctx = this.#ctx;
|
|
@@ -828,6 +1048,60 @@ export class SlackMessage {
|
|
|
828
1048
|
[QUIET]() {
|
|
829
1049
|
return quietOf(this.#ctx);
|
|
830
1050
|
}
|
|
1051
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1052
|
+
[CONTEXT]() {
|
|
1053
|
+
return this.#ctx;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
export class SlackConversation {
|
|
1057
|
+
id;
|
|
1058
|
+
kind;
|
|
1059
|
+
name;
|
|
1060
|
+
#ctx;
|
|
1061
|
+
#seen = new Map();
|
|
1062
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
1063
|
+
constructor(ctx, data) {
|
|
1064
|
+
this.#ctx = ctx;
|
|
1065
|
+
this.id = data.id;
|
|
1066
|
+
this.kind = data.kind;
|
|
1067
|
+
this.name = data.name;
|
|
1068
|
+
}
|
|
1069
|
+
/** The newest message of a conversation, replies included. Experimental. */
|
|
1070
|
+
async latestMessage() {
|
|
1071
|
+
const ctx = this.#ctx;
|
|
1072
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/conversations/${segment(this.id)}/latest`));
|
|
1073
|
+
return new SlackMessage(ctx, data);
|
|
1074
|
+
}
|
|
1075
|
+
/** Top-level messages of a conversation, oldest first. Experimental. */
|
|
1076
|
+
async messages() {
|
|
1077
|
+
const ctx = this.#ctx;
|
|
1078
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/conversations/${segment(this.id)}/messages`));
|
|
1079
|
+
return decodeSlackMessages(ctx, data);
|
|
1080
|
+
}
|
|
1081
|
+
/** The people and apps in a conversation. Experimental. */
|
|
1082
|
+
async members() {
|
|
1083
|
+
const ctx = this.#ctx;
|
|
1084
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/conversations/${segment(this.id)}/members`));
|
|
1085
|
+
return decodeSlackMembers(ctx, data);
|
|
1086
|
+
}
|
|
1087
|
+
/** The conversation as a person would read it, threads included. Experimental. */
|
|
1088
|
+
async transcript(options = {}) {
|
|
1089
|
+
const ctx = this.#ctx;
|
|
1090
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/slack/conversations/${segment(this.id)}/transcript`, { query: { as: options.as === undefined ? undefined : options.as.id } }));
|
|
1091
|
+
return decodeSlackTranscript(ctx, data);
|
|
1092
|
+
}
|
|
1093
|
+
/** Wait for the next new message matching `from` (anyone if omitted), after the last one this handle saw. */
|
|
1094
|
+
async waitForMessage(options = {}) {
|
|
1095
|
+
return waitForNext(this.#seen, "waitForMessage", () => this.messages(), (item) => fromMatches(item.author, options.from), describeWait("a message", options.from), options);
|
|
1096
|
+
}
|
|
1097
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1098
|
+
[QUIET]() {
|
|
1099
|
+
return quietOf(this.#ctx);
|
|
1100
|
+
}
|
|
1101
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1102
|
+
[CONTEXT]() {
|
|
1103
|
+
return this.#ctx;
|
|
1104
|
+
}
|
|
831
1105
|
}
|
|
832
1106
|
export class SlackThread {
|
|
833
1107
|
channel;
|
|
@@ -885,10 +1159,15 @@ export class SlackThread {
|
|
|
885
1159
|
[QUIET]() {
|
|
886
1160
|
return quietOf(this.#ctx);
|
|
887
1161
|
}
|
|
1162
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1163
|
+
[CONTEXT]() {
|
|
1164
|
+
return this.#ctx;
|
|
1165
|
+
}
|
|
888
1166
|
}
|
|
889
1167
|
export class SlackDelivery {
|
|
890
1168
|
id;
|
|
891
1169
|
channel;
|
|
1170
|
+
app;
|
|
892
1171
|
type;
|
|
893
1172
|
eventType;
|
|
894
1173
|
eventId;
|
|
@@ -901,6 +1180,7 @@ export class SlackDelivery {
|
|
|
901
1180
|
this.#ctx = ctx;
|
|
902
1181
|
this.id = data.id;
|
|
903
1182
|
this.channel = data.channel;
|
|
1183
|
+
this.app = data.app;
|
|
904
1184
|
this.type = data.type;
|
|
905
1185
|
this.eventType = data.eventType;
|
|
906
1186
|
this.eventId = data.eventId;
|
|
@@ -937,6 +1217,10 @@ export class SlackDelivery {
|
|
|
937
1217
|
[QUIET]() {
|
|
938
1218
|
return quietOf(this.#ctx);
|
|
939
1219
|
}
|
|
1220
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1221
|
+
[CONTEXT]() {
|
|
1222
|
+
return this.#ctx;
|
|
1223
|
+
}
|
|
940
1224
|
}
|
|
941
1225
|
export class SlackStream {
|
|
942
1226
|
channel;
|
|
@@ -973,6 +1257,10 @@ export class SlackStream {
|
|
|
973
1257
|
[QUIET]() {
|
|
974
1258
|
return quietOf(this.#ctx);
|
|
975
1259
|
}
|
|
1260
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1261
|
+
[CONTEXT]() {
|
|
1262
|
+
return this.#ctx;
|
|
1263
|
+
}
|
|
976
1264
|
}
|
|
977
1265
|
export class SlackModal {
|
|
978
1266
|
viewId;
|
|
@@ -1014,6 +1302,10 @@ export class SlackModal {
|
|
|
1014
1302
|
[QUIET]() {
|
|
1015
1303
|
return quietOf(this.#ctx);
|
|
1016
1304
|
}
|
|
1305
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1306
|
+
[CONTEXT]() {
|
|
1307
|
+
return this.#ctx;
|
|
1308
|
+
}
|
|
1017
1309
|
}
|
|
1018
1310
|
export class SlackFault {
|
|
1019
1311
|
id;
|
|
@@ -1035,6 +1327,10 @@ export class SlackFault {
|
|
|
1035
1327
|
[QUIET]() {
|
|
1036
1328
|
return quietOf(this.#ctx);
|
|
1037
1329
|
}
|
|
1330
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1331
|
+
[CONTEXT]() {
|
|
1332
|
+
return this.#ctx;
|
|
1333
|
+
}
|
|
1038
1334
|
}
|
|
1039
1335
|
export class GitHubFixture {
|
|
1040
1336
|
app;
|
|
@@ -1055,16 +1351,52 @@ export class GitHubFixture {
|
|
|
1055
1351
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/users`, { body: { login: options.login, id: options.id, name: options.name, email: options.email, role: options.role, token: options.token ?? credential("CHANNELSTACK_GITHUB_USER_{login}_TOKEN", { login: options.login }) } }));
|
|
1056
1352
|
return new GitHubUser(ctx, data);
|
|
1057
1353
|
}
|
|
1354
|
+
/** The people this session created. Experimental. */
|
|
1355
|
+
async users() {
|
|
1356
|
+
const ctx = this.#ctx;
|
|
1357
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/github/users`));
|
|
1358
|
+
return decodeGitHubUsers(ctx, data);
|
|
1359
|
+
}
|
|
1058
1360
|
/** Create a repository in the org. The App hears about it only when it is listed in `apps`: an App must be installed on a repository. Experimental. */
|
|
1059
1361
|
async createRepo(options = {}) {
|
|
1060
1362
|
const ctx = this.#ctx;
|
|
1061
1363
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/repos`, { body: { name: options.name, private: options.private, defaultBranch: options.defaultBranch, files: options.files === undefined ? undefined : readTree(options.files), collaborators: options.collaborators === undefined ? undefined : options.collaborators.map((item) => (item instanceof GitHubUser ? { user: item.id } : { ...item, user: item.user.id })), apps: options.apps === undefined ? undefined : options.apps.map((item) => item.id), labels: options.labels === undefined ? undefined : options.labels.map((item) => (typeof item === "string" ? { name: item } : item)) } }));
|
|
1062
1364
|
return new GitHubRepo(ctx, data);
|
|
1063
1365
|
}
|
|
1366
|
+
/** The repositories this session created. Experimental. */
|
|
1367
|
+
async repos() {
|
|
1368
|
+
const ctx = this.#ctx;
|
|
1369
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/github/repos`));
|
|
1370
|
+
return decodeGitHubRepos(ctx, data);
|
|
1371
|
+
}
|
|
1372
|
+
/** The issues and pull requests in this session's repositories, read again from GitHub live, the most recently updated last. Experimental. */
|
|
1373
|
+
async issues() {
|
|
1374
|
+
const ctx = this.#ctx;
|
|
1375
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/github/issues`));
|
|
1376
|
+
return decodeGitHubIssues(ctx, data);
|
|
1377
|
+
}
|
|
1378
|
+
/** The id of the built-in App's installation, for a repository it is installed on. The same as `github.app.installationId(repo)`. Experimental. */
|
|
1379
|
+
async installationId(repo) {
|
|
1380
|
+
const ctx = this.#ctx;
|
|
1381
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/installation-id`, { body: { repo: repo.id } }));
|
|
1382
|
+
return data;
|
|
1383
|
+
}
|
|
1384
|
+
/** Make another GitHub App on the org, with its own App id, bot user, installation, private key and webhook secret (decision 0027), or return the one made with this name and settings. It reaches no repository until it is installed on one; its webhooks go to CHANNELSTACK_GITHUB_APP_<NAME>_WEBHOOK_URL. Experimental. */
|
|
1385
|
+
async createApp(options) {
|
|
1386
|
+
const ctx = this.#ctx;
|
|
1387
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps`, { body: { name: options.name, permissions: options.permissions, events: options.events } }));
|
|
1388
|
+
return new GitHubApp(ctx, data);
|
|
1389
|
+
}
|
|
1390
|
+
/** The Apps this session used: the built-in one first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here. Experimental. */
|
|
1391
|
+
async apps() {
|
|
1392
|
+
const ctx = this.#ctx;
|
|
1393
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/github/apps`));
|
|
1394
|
+
return decodeGitHubApps(ctx, data);
|
|
1395
|
+
}
|
|
1064
1396
|
/** Every webhook channelstack sent the agent for this session, with every attempt. Experimental. */
|
|
1065
1397
|
async deliveries(options = {}) {
|
|
1066
1398
|
const ctx = this.#ctx;
|
|
1067
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/github/deliveries`, { query: { type: options.type, resource: options.resource === undefined ? undefined : options.resource.id } }));
|
|
1399
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/github/deliveries`, { query: { type: options.type, resource: options.resource === undefined ? undefined : options.resource.id, app: options.app === undefined ? undefined : options.app.id } }));
|
|
1068
1400
|
return decodeGitHubDeliveries(ctx, data);
|
|
1069
1401
|
}
|
|
1070
1402
|
/** The REST calls the agent made about this session's repositories. Calls about no repository (`GET /app`) are in no session. Experimental. */
|
|
@@ -1080,13 +1412,17 @@ export class GitHubFixture {
|
|
|
1080
1412
|
return data;
|
|
1081
1413
|
}
|
|
1082
1414
|
/** Wait for the next new API call from the agent, after the last one this handle saw. */
|
|
1083
|
-
async waitForCall(filter, options = {}) {
|
|
1415
|
+
async waitForCall(filter = {}, options = {}) {
|
|
1084
1416
|
return waitForNext(this.#seen, `waitForCall:${JSON.stringify(filter)}`, () => this.calls(filter), () => true, "an API call from the agent", options);
|
|
1085
1417
|
}
|
|
1086
1418
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1087
1419
|
[QUIET]() {
|
|
1088
1420
|
return quietOf(this.#ctx);
|
|
1089
1421
|
}
|
|
1422
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1423
|
+
[CONTEXT]() {
|
|
1424
|
+
return this.#ctx;
|
|
1425
|
+
}
|
|
1090
1426
|
}
|
|
1091
1427
|
export class GitHubApp {
|
|
1092
1428
|
id;
|
|
@@ -1112,91 +1448,225 @@ export class GitHubApp {
|
|
|
1112
1448
|
this.privateKey = data.privateKey;
|
|
1113
1449
|
this.webhookSecret = data.webhookSecret;
|
|
1114
1450
|
}
|
|
1115
|
-
/** The id of
|
|
1451
|
+
/** The id of this App's installation, for a repository it is installed on. Experimental. */
|
|
1116
1452
|
async installationId(repo) {
|
|
1117
1453
|
const ctx = this.#ctx;
|
|
1118
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/installation-id`, { body: { repo: repo.id } }));
|
|
1454
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/installation-id`, { body: { repo: repo.id } }));
|
|
1119
1455
|
return data;
|
|
1120
1456
|
}
|
|
1121
|
-
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1122
|
-
[QUIET]() {
|
|
1123
|
-
return quietOf(this.#ctx);
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
export class GitHubUser {
|
|
1127
|
-
id;
|
|
1128
|
-
name;
|
|
1129
|
-
kind;
|
|
1130
|
-
login;
|
|
1131
|
-
numericId;
|
|
1132
|
-
displayName;
|
|
1133
|
-
email;
|
|
1134
|
-
role;
|
|
1135
|
-
#ctx;
|
|
1136
|
-
/** @internal Handles come from the SDK, never from `new`. */
|
|
1137
|
-
constructor(ctx, data) {
|
|
1138
|
-
this.#ctx = ctx;
|
|
1139
|
-
this.id = data.id;
|
|
1140
|
-
this.name = data.name;
|
|
1141
|
-
this.kind = data.kind;
|
|
1142
|
-
this.login = data.login;
|
|
1143
|
-
this.numericId = data.numericId;
|
|
1144
|
-
this.displayName = data.displayName;
|
|
1145
|
-
this.email = data.email;
|
|
1146
|
-
this.role = data.role;
|
|
1147
|
-
}
|
|
1148
1457
|
/** Push a commit to a branch (created from the default branch if it isn't there). Sends `push`, and `pull_request` `synchronize` for open pull requests from it. Experimental. */
|
|
1149
1458
|
async push(changes, options) {
|
|
1150
1459
|
const ctx = this.#ctx;
|
|
1151
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/
|
|
1460
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/push`, { body: { changes: readChanges(changes), repo: options.repo.id, branch: options.branch, message: options.message } }));
|
|
1152
1461
|
return new GitHubCommit(ctx, data);
|
|
1153
1462
|
}
|
|
1154
1463
|
/** Open an issue. Sends `issues` (action `opened`). Experimental. */
|
|
1155
1464
|
async openIssue(issue, options) {
|
|
1156
1465
|
const ctx = this.#ctx;
|
|
1157
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/
|
|
1466
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/issues`, { body: { issue: { ...issue, assignees: issue.assignees === undefined ? undefined : issue.assignees.map((item) => item.id) }, repo: options.repo.id } }));
|
|
1158
1467
|
return new GitHubIssue(ctx, data);
|
|
1159
1468
|
}
|
|
1160
1469
|
/** Open a pull request. With `changes`, they are pushed to `from` first; without, `from` is an existing branch. Sends `pull_request` (action `opened`). Experimental. */
|
|
1161
1470
|
async openPullRequest(pr, options) {
|
|
1162
1471
|
const ctx = this.#ctx;
|
|
1163
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/
|
|
1472
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/pulls`, { body: { pr: { ...pr, changes: pr.changes === undefined ? undefined : readChanges(pr.changes), reviewers: pr.reviewers === undefined ? undefined : pr.reviewers.map((item) => item.id) }, repo: options.repo.id } }));
|
|
1164
1473
|
return new GitHubPullRequest(ctx, data);
|
|
1165
1474
|
}
|
|
1166
1475
|
/** Edit the title or the body of an issue or a pull request. Sends `issues` or `pull_request` (action `edited`). Experimental. */
|
|
1167
1476
|
async editIssue(changes, options) {
|
|
1168
1477
|
const ctx = this.#ctx;
|
|
1169
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/
|
|
1478
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/edit-issue`, { body: { changes, issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1170
1479
|
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1171
1480
|
}
|
|
1172
1481
|
/** Close an issue or a pull request. Sends `issues` or `pull_request` (action `closed`). Experimental. */
|
|
1173
1482
|
async close(options) {
|
|
1174
1483
|
const ctx = this.#ctx;
|
|
1175
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/
|
|
1484
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/close`, { body: { issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1176
1485
|
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1177
1486
|
}
|
|
1178
1487
|
/** Reopen an issue or a pull request. Sends `issues` or `pull_request` (action `reopened`). Experimental. */
|
|
1179
1488
|
async reopen(options) {
|
|
1180
1489
|
const ctx = this.#ctx;
|
|
1181
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/
|
|
1490
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/reopen`, { body: { issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1182
1491
|
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1183
1492
|
}
|
|
1184
1493
|
/** Put labels on an issue or a pull request. Sends one `labeled` event per label. Experimental. */
|
|
1185
1494
|
async label(labels, options) {
|
|
1186
1495
|
const ctx = this.#ctx;
|
|
1187
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/
|
|
1496
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/label`, { body: { labels: [labels].flat(), issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1188
1497
|
return decodeGitHubLabelDeliveries(ctx, data);
|
|
1189
1498
|
}
|
|
1190
1499
|
/** Take labels off an issue or a pull request. Sends one `unlabeled` event per label. Experimental. */
|
|
1191
1500
|
async unlabel(labels, options) {
|
|
1192
1501
|
const ctx = this.#ctx;
|
|
1193
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/
|
|
1502
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/unlabel`, { body: { labels: [labels].flat(), issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1194
1503
|
return decodeGitHubUnlabelDeliveries(ctx, data);
|
|
1195
1504
|
}
|
|
1196
1505
|
/** Assign people or the App's bot. Sends one `assigned` event per assignee. Experimental. */
|
|
1197
1506
|
async assign(assignees, options) {
|
|
1198
1507
|
const ctx = this.#ctx;
|
|
1199
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/
|
|
1508
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/assign`, { body: { assignees: [assignees].flat().map((item) => item.id), issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1509
|
+
return decodeGitHubAssignDeliveries(ctx, data);
|
|
1510
|
+
}
|
|
1511
|
+
/** Comment on an issue or a pull request's conversation. Sends `issue_comment` (action `created`). Experimental. */
|
|
1512
|
+
async comment(body, options) {
|
|
1513
|
+
const ctx = this.#ctx;
|
|
1514
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/comment`, { body: { body, issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1515
|
+
return new GitHubComment(ctx, data);
|
|
1516
|
+
}
|
|
1517
|
+
/** Edit a conversation comment or a comment on the diff. Sends the comment's event with action `edited`. Experimental. */
|
|
1518
|
+
async edit(body, options) {
|
|
1519
|
+
const ctx = this.#ctx;
|
|
1520
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/edit`, { body: { body, comment: options.comment.id } }));
|
|
1521
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1522
|
+
}
|
|
1523
|
+
/** Delete a conversation comment or a comment on the diff. Sends the comment's event with action `deleted`. Experimental. */
|
|
1524
|
+
async delete(options) {
|
|
1525
|
+
const ctx = this.#ctx;
|
|
1526
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/delete`, { body: { comment: options.comment.id } }));
|
|
1527
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1528
|
+
}
|
|
1529
|
+
/** React to an issue, a pull request or a comment. GitHub sends no webhook for a reaction. Experimental. */
|
|
1530
|
+
async react(content, options = {}) {
|
|
1531
|
+
const ctx = this.#ctx;
|
|
1532
|
+
await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/react`, { body: { content, issue: options.issue === undefined ? undefined : { repoId: options.issue.repoId, number: options.issue.number }, comment: options.comment === undefined ? undefined : options.comment.id } });
|
|
1533
|
+
}
|
|
1534
|
+
/** Hide a comment as outdated, spam, off-topic or resolved. GitHub sends no webhook for it. Experimental. */
|
|
1535
|
+
async minimize(options) {
|
|
1536
|
+
const ctx = this.#ctx;
|
|
1537
|
+
await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/minimize`, { body: { comment: options.comment.id, reason: options.reason } });
|
|
1538
|
+
}
|
|
1539
|
+
/** Submit a review, with comments on the diff if any. Sends `pull_request_review`, and one `pull_request_review_comment` per comment. Experimental. */
|
|
1540
|
+
async review(review) {
|
|
1541
|
+
const ctx = this.#ctx;
|
|
1542
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/review`, { body: { review: { ...review, pr: { repoId: review.pr.repoId, number: review.pr.number } } } }));
|
|
1543
|
+
return decodeGitHubReview(ctx, data);
|
|
1544
|
+
}
|
|
1545
|
+
/** One comment on the diff, outside a review. Sends `pull_request_review_comment`. Experimental. */
|
|
1546
|
+
async reviewComment(body, options) {
|
|
1547
|
+
const ctx = this.#ctx;
|
|
1548
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/review-comment`, { body: { body, pr: { repoId: options.pr.repoId, number: options.pr.number }, path: options.path, line: options.line, side: options.side } }));
|
|
1549
|
+
return new GitHubReviewComment(ctx, data);
|
|
1550
|
+
}
|
|
1551
|
+
/** Reply in a thread on the diff. Sends `pull_request_review_comment`. Experimental. */
|
|
1552
|
+
async reply(body, options) {
|
|
1553
|
+
const ctx = this.#ctx;
|
|
1554
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/reply`, { body: { body, comment: options.comment.id } }));
|
|
1555
|
+
return new GitHubReviewComment(ctx, data);
|
|
1556
|
+
}
|
|
1557
|
+
/** Resolve a thread on the diff. Sends `pull_request_review_thread`. Experimental. */
|
|
1558
|
+
async resolve(options) {
|
|
1559
|
+
const ctx = this.#ctx;
|
|
1560
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/resolve`, { body: { comment: options.comment.id } }));
|
|
1561
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1562
|
+
}
|
|
1563
|
+
/** Reopen a thread on the diff. Sends `pull_request_review_thread`. Experimental. */
|
|
1564
|
+
async unresolve(options) {
|
|
1565
|
+
const ctx = this.#ctx;
|
|
1566
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/unresolve`, { body: { comment: options.comment.id } }));
|
|
1567
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1568
|
+
}
|
|
1569
|
+
/** Request a review from people or the App's bot. Sends `pull_request` (action `review_requested`) per reviewer. Experimental. */
|
|
1570
|
+
async requestReview(reviewers, options) {
|
|
1571
|
+
const ctx = this.#ctx;
|
|
1572
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/request-review`, { body: { reviewers: [reviewers].flat().map((item) => item.id), pr: { repoId: options.pr.repoId, number: options.pr.number } } }));
|
|
1573
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1574
|
+
}
|
|
1575
|
+
/** Mark a draft pull request as ready for review. Sends `pull_request` (action `ready_for_review`). Experimental. */
|
|
1576
|
+
async markReady(options) {
|
|
1577
|
+
const ctx = this.#ctx;
|
|
1578
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/mark-ready`, { body: { pr: { repoId: options.pr.repoId, number: options.pr.number } } }));
|
|
1579
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1580
|
+
}
|
|
1581
|
+
/** Merge a pull request. Sends `push` for the base branch, then `pull_request` (action `closed`, merged). Experimental. */
|
|
1582
|
+
async merge(options) {
|
|
1583
|
+
const ctx = this.#ctx;
|
|
1584
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/apps/${segment(this.id)}/merge`, { body: { pr: { repoId: options.pr.repoId, number: options.pr.number }, method: options.method } }));
|
|
1585
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1586
|
+
}
|
|
1587
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1588
|
+
[QUIET]() {
|
|
1589
|
+
return quietOf(this.#ctx);
|
|
1590
|
+
}
|
|
1591
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1592
|
+
[CONTEXT]() {
|
|
1593
|
+
return this.#ctx;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
export class GitHubUser {
|
|
1597
|
+
id;
|
|
1598
|
+
name;
|
|
1599
|
+
kind;
|
|
1600
|
+
login;
|
|
1601
|
+
numericId;
|
|
1602
|
+
displayName;
|
|
1603
|
+
email;
|
|
1604
|
+
role;
|
|
1605
|
+
#ctx;
|
|
1606
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
1607
|
+
constructor(ctx, data) {
|
|
1608
|
+
this.#ctx = ctx;
|
|
1609
|
+
this.id = data.id;
|
|
1610
|
+
this.name = data.name;
|
|
1611
|
+
this.kind = data.kind;
|
|
1612
|
+
this.login = data.login;
|
|
1613
|
+
this.numericId = data.numericId;
|
|
1614
|
+
this.displayName = data.displayName;
|
|
1615
|
+
this.email = data.email;
|
|
1616
|
+
this.role = data.role;
|
|
1617
|
+
}
|
|
1618
|
+
/** Push a commit to a branch (created from the default branch if it isn't there). Sends `push`, and `pull_request` `synchronize` for open pull requests from it. Experimental. */
|
|
1619
|
+
async push(changes, options) {
|
|
1620
|
+
const ctx = this.#ctx;
|
|
1621
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/users/${segment(this.id)}/push`, { body: { changes: readChanges(changes), repo: options.repo.id, branch: options.branch, message: options.message } }));
|
|
1622
|
+
return new GitHubCommit(ctx, data);
|
|
1623
|
+
}
|
|
1624
|
+
/** Open an issue. Sends `issues` (action `opened`). Experimental. */
|
|
1625
|
+
async openIssue(issue, options) {
|
|
1626
|
+
const ctx = this.#ctx;
|
|
1627
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/users/${segment(this.id)}/issues`, { body: { issue: { ...issue, assignees: issue.assignees === undefined ? undefined : issue.assignees.map((item) => item.id) }, repo: options.repo.id } }));
|
|
1628
|
+
return new GitHubIssue(ctx, data);
|
|
1629
|
+
}
|
|
1630
|
+
/** Open a pull request. With `changes`, they are pushed to `from` first; without, `from` is an existing branch. Sends `pull_request` (action `opened`). Experimental. */
|
|
1631
|
+
async openPullRequest(pr, options) {
|
|
1632
|
+
const ctx = this.#ctx;
|
|
1633
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/users/${segment(this.id)}/pulls`, { body: { pr: { ...pr, changes: pr.changes === undefined ? undefined : readChanges(pr.changes), reviewers: pr.reviewers === undefined ? undefined : pr.reviewers.map((item) => item.id) }, repo: options.repo.id } }));
|
|
1634
|
+
return new GitHubPullRequest(ctx, data);
|
|
1635
|
+
}
|
|
1636
|
+
/** Edit the title or the body of an issue or a pull request. Sends `issues` or `pull_request` (action `edited`). Experimental. */
|
|
1637
|
+
async editIssue(changes, options) {
|
|
1638
|
+
const ctx = this.#ctx;
|
|
1639
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/users/${segment(this.id)}/edit-issue`, { body: { changes, issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1640
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1641
|
+
}
|
|
1642
|
+
/** Close an issue or a pull request. Sends `issues` or `pull_request` (action `closed`). Experimental. */
|
|
1643
|
+
async close(options) {
|
|
1644
|
+
const ctx = this.#ctx;
|
|
1645
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/users/${segment(this.id)}/close`, { body: { issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1646
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1647
|
+
}
|
|
1648
|
+
/** Reopen an issue or a pull request. Sends `issues` or `pull_request` (action `reopened`). Experimental. */
|
|
1649
|
+
async reopen(options) {
|
|
1650
|
+
const ctx = this.#ctx;
|
|
1651
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/users/${segment(this.id)}/reopen`, { body: { issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1652
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1653
|
+
}
|
|
1654
|
+
/** Put labels on an issue or a pull request. Sends one `labeled` event per label. Experimental. */
|
|
1655
|
+
async label(labels, options) {
|
|
1656
|
+
const ctx = this.#ctx;
|
|
1657
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/users/${segment(this.id)}/label`, { body: { labels: [labels].flat(), issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1658
|
+
return decodeGitHubLabelDeliveries(ctx, data);
|
|
1659
|
+
}
|
|
1660
|
+
/** Take labels off an issue or a pull request. Sends one `unlabeled` event per label. Experimental. */
|
|
1661
|
+
async unlabel(labels, options) {
|
|
1662
|
+
const ctx = this.#ctx;
|
|
1663
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/users/${segment(this.id)}/unlabel`, { body: { labels: [labels].flat(), issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1664
|
+
return decodeGitHubUnlabelDeliveries(ctx, data);
|
|
1665
|
+
}
|
|
1666
|
+
/** Assign people or the App's bot. Sends one `assigned` event per assignee. Experimental. */
|
|
1667
|
+
async assign(assignees, options) {
|
|
1668
|
+
const ctx = this.#ctx;
|
|
1669
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/users/${segment(this.id)}/assign`, { body: { assignees: [assignees].flat().map((item) => item.id), issue: { repoId: options.issue.repoId, number: options.issue.number } } }));
|
|
1200
1670
|
return decodeGitHubAssignDeliveries(ctx, data);
|
|
1201
1671
|
}
|
|
1202
1672
|
/** Comment on an issue or a pull request's conversation. Sends `issue_comment` (action `created`). Experimental. */
|
|
@@ -1291,6 +1761,10 @@ export class GitHubUser {
|
|
|
1291
1761
|
[QUIET]() {
|
|
1292
1762
|
return quietOf(this.#ctx);
|
|
1293
1763
|
}
|
|
1764
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1765
|
+
[CONTEXT]() {
|
|
1766
|
+
return this.#ctx;
|
|
1767
|
+
}
|
|
1294
1768
|
}
|
|
1295
1769
|
export class GitHubRepo {
|
|
1296
1770
|
id;
|
|
@@ -1310,13 +1784,13 @@ export class GitHubRepo {
|
|
|
1310
1784
|
this.defaultBranch = data.defaultBranch;
|
|
1311
1785
|
this.private = data.private;
|
|
1312
1786
|
}
|
|
1313
|
-
/** Install
|
|
1787
|
+
/** Install an App on this repository. Sends that App `installation_repositories`. Experimental. */
|
|
1314
1788
|
async installApp(app) {
|
|
1315
1789
|
const ctx = this.#ctx;
|
|
1316
1790
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/repos/${segment(this.id)}/install`, { body: { app: app.id } }));
|
|
1317
1791
|
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
1318
1792
|
}
|
|
1319
|
-
/** Take
|
|
1793
|
+
/** Take an App off this repository. Sends that App `installation_repositories`. Experimental. */
|
|
1320
1794
|
async uninstallApp(app) {
|
|
1321
1795
|
const ctx = this.#ctx;
|
|
1322
1796
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/repos/${segment(this.id)}/uninstall`, { body: { app: app.id } }));
|
|
@@ -1351,57 +1825,9 @@ export class GitHubRepo {
|
|
|
1351
1825
|
[QUIET]() {
|
|
1352
1826
|
return quietOf(this.#ctx);
|
|
1353
1827
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
channel;
|
|
1358
|
-
type;
|
|
1359
|
-
action;
|
|
1360
|
-
guid;
|
|
1361
|
-
payload;
|
|
1362
|
-
attempts;
|
|
1363
|
-
status;
|
|
1364
|
-
#ctx;
|
|
1365
|
-
/** @internal Handles come from the SDK, never from `new`. */
|
|
1366
|
-
constructor(ctx, data) {
|
|
1367
|
-
this.#ctx = ctx;
|
|
1368
|
-
this.id = data.id;
|
|
1369
|
-
this.channel = data.channel;
|
|
1370
|
-
this.type = data.type;
|
|
1371
|
-
this.action = data.action;
|
|
1372
|
-
this.guid = data.guid;
|
|
1373
|
-
this.payload = data.payload;
|
|
1374
|
-
this.attempts = data.attempts;
|
|
1375
|
-
this.status = data.status;
|
|
1376
|
-
}
|
|
1377
|
-
/** Re-read a delivery: its attempts and status. Experimental. */
|
|
1378
|
-
async refresh() {
|
|
1379
|
-
const ctx = this.#ctx;
|
|
1380
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/github/deliveries/${segment(this.id)}`));
|
|
1381
|
-
return new GitHubDelivery(ctx, data);
|
|
1382
|
-
}
|
|
1383
|
-
/** Redeliver from the App's delivery log, as GitHub's UI and API do: the same GUID, a new attempt. Experimental. */
|
|
1384
|
-
async redeliver() {
|
|
1385
|
-
const ctx = this.#ctx;
|
|
1386
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/deliveries/${segment(this.id)}/redeliver`));
|
|
1387
|
-
return data;
|
|
1388
|
-
}
|
|
1389
|
-
/** Send the delivery again, unchanged or signed with a secret that isn't the App's. Experimental. */
|
|
1390
|
-
async resend(options = {}) {
|
|
1391
|
-
const ctx = this.#ctx;
|
|
1392
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/deliveries/${segment(this.id)}/resend`, { body: { badSignature: options.badSignature } }));
|
|
1393
|
-
return data;
|
|
1394
|
-
}
|
|
1395
|
-
/** Wait for the delivery to settle, and resolve with the value as it is then. */
|
|
1396
|
-
async settled(options = {}) {
|
|
1397
|
-
return waitFor("the delivery to settle", async () => {
|
|
1398
|
-
const value = await this.refresh();
|
|
1399
|
-
return value.status === "pending" ? undefined : value;
|
|
1400
|
-
}, options);
|
|
1401
|
-
}
|
|
1402
|
-
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1403
|
-
[QUIET]() {
|
|
1404
|
-
return quietOf(this.#ctx);
|
|
1828
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1829
|
+
[CONTEXT]() {
|
|
1830
|
+
return this.#ctx;
|
|
1405
1831
|
}
|
|
1406
1832
|
}
|
|
1407
1833
|
export class GitHubIssue {
|
|
@@ -1476,6 +1902,68 @@ export class GitHubIssue {
|
|
|
1476
1902
|
[QUIET]() {
|
|
1477
1903
|
return quietOf(this.#ctx);
|
|
1478
1904
|
}
|
|
1905
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1906
|
+
[CONTEXT]() {
|
|
1907
|
+
return this.#ctx;
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
export class GitHubDelivery {
|
|
1911
|
+
id;
|
|
1912
|
+
channel;
|
|
1913
|
+
app;
|
|
1914
|
+
type;
|
|
1915
|
+
action;
|
|
1916
|
+
guid;
|
|
1917
|
+
payload;
|
|
1918
|
+
attempts;
|
|
1919
|
+
status;
|
|
1920
|
+
#ctx;
|
|
1921
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
1922
|
+
constructor(ctx, data) {
|
|
1923
|
+
this.#ctx = ctx;
|
|
1924
|
+
this.id = data.id;
|
|
1925
|
+
this.channel = data.channel;
|
|
1926
|
+
this.app = data.app;
|
|
1927
|
+
this.type = data.type;
|
|
1928
|
+
this.action = data.action;
|
|
1929
|
+
this.guid = data.guid;
|
|
1930
|
+
this.payload = data.payload;
|
|
1931
|
+
this.attempts = data.attempts;
|
|
1932
|
+
this.status = data.status;
|
|
1933
|
+
}
|
|
1934
|
+
/** Re-read a delivery: its attempts and status. Experimental. */
|
|
1935
|
+
async refresh() {
|
|
1936
|
+
const ctx = this.#ctx;
|
|
1937
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/github/deliveries/${segment(this.id)}`));
|
|
1938
|
+
return new GitHubDelivery(ctx, data);
|
|
1939
|
+
}
|
|
1940
|
+
/** Redeliver from the App's delivery log, as GitHub's UI and API do: the same GUID, a new attempt. Experimental. */
|
|
1941
|
+
async redeliver() {
|
|
1942
|
+
const ctx = this.#ctx;
|
|
1943
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/deliveries/${segment(this.id)}/redeliver`));
|
|
1944
|
+
return data;
|
|
1945
|
+
}
|
|
1946
|
+
/** Send the delivery again, unchanged or signed with a secret that isn't the App's. Experimental. */
|
|
1947
|
+
async resend(options = {}) {
|
|
1948
|
+
const ctx = this.#ctx;
|
|
1949
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/github/deliveries/${segment(this.id)}/resend`, { body: { badSignature: options.badSignature } }));
|
|
1950
|
+
return data;
|
|
1951
|
+
}
|
|
1952
|
+
/** Wait for the delivery to settle, and resolve with the value as it is then. */
|
|
1953
|
+
async settled(options = {}) {
|
|
1954
|
+
return waitFor("the delivery to settle", async () => {
|
|
1955
|
+
const value = await this.refresh();
|
|
1956
|
+
return value.status === "pending" ? undefined : value;
|
|
1957
|
+
}, options);
|
|
1958
|
+
}
|
|
1959
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1960
|
+
[QUIET]() {
|
|
1961
|
+
return quietOf(this.#ctx);
|
|
1962
|
+
}
|
|
1963
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
1964
|
+
[CONTEXT]() {
|
|
1965
|
+
return this.#ctx;
|
|
1966
|
+
}
|
|
1479
1967
|
}
|
|
1480
1968
|
export class GitHubCommit {
|
|
1481
1969
|
repoId;
|
|
@@ -1511,6 +1999,10 @@ export class GitHubCommit {
|
|
|
1511
1999
|
[QUIET]() {
|
|
1512
2000
|
return quietOf(this.#ctx);
|
|
1513
2001
|
}
|
|
2002
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2003
|
+
[CONTEXT]() {
|
|
2004
|
+
return this.#ctx;
|
|
2005
|
+
}
|
|
1514
2006
|
}
|
|
1515
2007
|
export class GitHubCheckRun {
|
|
1516
2008
|
id;
|
|
@@ -1542,6 +2034,10 @@ export class GitHubCheckRun {
|
|
|
1542
2034
|
[QUIET]() {
|
|
1543
2035
|
return quietOf(this.#ctx);
|
|
1544
2036
|
}
|
|
2037
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2038
|
+
[CONTEXT]() {
|
|
2039
|
+
return this.#ctx;
|
|
2040
|
+
}
|
|
1545
2041
|
}
|
|
1546
2042
|
export class GitHubComment {
|
|
1547
2043
|
id;
|
|
@@ -1575,10 +2071,20 @@ export class GitHubComment {
|
|
|
1575
2071
|
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/github/comments/${segment(this.id)}/reactions`));
|
|
1576
2072
|
return decodeGitHubReactions(ctx, data);
|
|
1577
2073
|
}
|
|
1578
|
-
/**
|
|
2074
|
+
/** The `issue_comment` (`created`) delivery this comment caused to this App (decision 0027), or nothing when it wasn't told. The comment's `delivery` is the built-in App's. Experimental. */
|
|
2075
|
+
async deliveryFor(app) {
|
|
2076
|
+
const ctx = this.#ctx;
|
|
2077
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/github/comments/${segment(this.id)}/delivery-for`, { query: { app: app.id } }));
|
|
2078
|
+
return (data === null ? undefined : new GitHubDelivery(ctx, data));
|
|
2079
|
+
}
|
|
2080
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1579
2081
|
[QUIET]() {
|
|
1580
2082
|
return quietOf(this.#ctx);
|
|
1581
2083
|
}
|
|
2084
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2085
|
+
[CONTEXT]() {
|
|
2086
|
+
return this.#ctx;
|
|
2087
|
+
}
|
|
1582
2088
|
}
|
|
1583
2089
|
export class GitHubReviewComment {
|
|
1584
2090
|
id;
|
|
@@ -1625,6 +2131,10 @@ export class GitHubReviewComment {
|
|
|
1625
2131
|
[QUIET]() {
|
|
1626
2132
|
return quietOf(this.#ctx);
|
|
1627
2133
|
}
|
|
2134
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2135
|
+
[CONTEXT]() {
|
|
2136
|
+
return this.#ctx;
|
|
2137
|
+
}
|
|
1628
2138
|
}
|
|
1629
2139
|
export class LinearFixture {
|
|
1630
2140
|
app;
|
|
@@ -1643,16 +2153,46 @@ export class LinearFixture {
|
|
|
1643
2153
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/linear/users`, { body: { name: options.name, id: options.id, displayName: options.displayName, email: options.email, admin: options.admin, guest: options.guest, token: options.token ?? credential("CHANNELSTACK_LINEAR_USER_{name}_TOKEN", { name: options.name }) } }));
|
|
1644
2154
|
return new LinearUser(ctx, data);
|
|
1645
2155
|
}
|
|
2156
|
+
/** The people this session created. Experimental. */
|
|
2157
|
+
async users() {
|
|
2158
|
+
const ctx = this.#ctx;
|
|
2159
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/users`));
|
|
2160
|
+
return decodeLinearUsers(ctx, data);
|
|
2161
|
+
}
|
|
2162
|
+
/** Make another OAuth app in the workspace, installed with `actor=app`: its own app user (mentionable and assignable), access token, client and webhook secret. Or return the one made with this name and settings. Its webhooks go to CHANNELSTACK_LINEAR_APP_<NAME>_WEBHOOK_URL. Experimental. */
|
|
2163
|
+
async createApp(options) {
|
|
2164
|
+
const ctx = this.#ctx;
|
|
2165
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/linear/apps`, { body: { name: options.name, events: options.events } }));
|
|
2166
|
+
return new LinearApp(ctx, data);
|
|
2167
|
+
}
|
|
2168
|
+
/** The apps this session used: the built-in one first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here. Experimental. */
|
|
2169
|
+
async apps() {
|
|
2170
|
+
const ctx = this.#ctx;
|
|
2171
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/apps`));
|
|
2172
|
+
return decodeLinearApps(ctx, data);
|
|
2173
|
+
}
|
|
2174
|
+
/** The teams this session created. Experimental. */
|
|
2175
|
+
async teams() {
|
|
2176
|
+
const ctx = this.#ctx;
|
|
2177
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/teams`));
|
|
2178
|
+
return decodeLinearTeams(ctx, data);
|
|
2179
|
+
}
|
|
1646
2180
|
/** Create a team: its members, workflow states and labels. Without a key one is made up, so parallel tests never share one. Experimental. */
|
|
1647
2181
|
async createTeam(options = {}) {
|
|
1648
2182
|
const ctx = this.#ctx;
|
|
1649
2183
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/linear/teams`, { body: { key: options.key, name: options.name, members: options.members === undefined ? undefined : options.members.map((item) => item.id), states: options.states, labels: options.labels } }));
|
|
1650
2184
|
return new LinearTeam(ctx, data);
|
|
1651
2185
|
}
|
|
2186
|
+
/** The issues in this session's teams, read again from Linear live, oldest first. Experimental. */
|
|
2187
|
+
async issues() {
|
|
2188
|
+
const ctx = this.#ctx;
|
|
2189
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/issues`));
|
|
2190
|
+
return decodeLinearIssues(ctx, data);
|
|
2191
|
+
}
|
|
1652
2192
|
/** Every webhook channelstack sent the agent for this session, with every attempt. Experimental. */
|
|
1653
2193
|
async deliveries(options = {}) {
|
|
1654
2194
|
const ctx = this.#ctx;
|
|
1655
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/deliveries`, { query: { type: options.type, resource: options.resource === undefined ? undefined : options.resource.id } }));
|
|
2195
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/deliveries`, { query: { type: options.type, resource: options.resource === undefined ? undefined : options.resource.id, app: options.app === undefined ? undefined : options.app.id } }));
|
|
1656
2196
|
return decodeLinearDeliveries(ctx, data);
|
|
1657
2197
|
}
|
|
1658
2198
|
/** The GraphQL operations the agent sent about this session's issues and sessions, by root field (`agentActivityCreate`). Experimental. */
|
|
@@ -1662,13 +2202,17 @@ export class LinearFixture {
|
|
|
1662
2202
|
return data;
|
|
1663
2203
|
}
|
|
1664
2204
|
/** Wait for the next new API call from the agent, after the last one this handle saw. */
|
|
1665
|
-
async waitForCall(filter, options = {}) {
|
|
2205
|
+
async waitForCall(filter = {}, options = {}) {
|
|
1666
2206
|
return waitForNext(this.#seen, `waitForCall:${JSON.stringify(filter)}`, () => this.calls(filter), () => true, "an API call from the agent", options);
|
|
1667
2207
|
}
|
|
1668
2208
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1669
2209
|
[QUIET]() {
|
|
1670
2210
|
return quietOf(this.#ctx);
|
|
1671
2211
|
}
|
|
2212
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2213
|
+
[CONTEXT]() {
|
|
2214
|
+
return this.#ctx;
|
|
2215
|
+
}
|
|
1672
2216
|
}
|
|
1673
2217
|
export class LinearApp {
|
|
1674
2218
|
id;
|
|
@@ -1692,10 +2236,26 @@ export class LinearApp {
|
|
|
1692
2236
|
this.clientId = data.clientId;
|
|
1693
2237
|
this.clientSecret = data.clientSecret;
|
|
1694
2238
|
}
|
|
2239
|
+
/** An app a test made comments on an issue, as its own `commentCreate` would. Its mention of another app is refused (to confirm, B6). Experimental. */
|
|
2240
|
+
async comment(body, options) {
|
|
2241
|
+
const ctx = this.#ctx;
|
|
2242
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/linear/apps/${segment(this.id)}/comment`, { body: { body, issue: options.issue.id } }));
|
|
2243
|
+
return new LinearComment(ctx, data);
|
|
2244
|
+
}
|
|
2245
|
+
/** An app a test made replies in a comment's thread, as its own `commentCreate` with a `parentId` would. Experimental. */
|
|
2246
|
+
async reply(body, options) {
|
|
2247
|
+
const ctx = this.#ctx;
|
|
2248
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/linear/apps/${segment(this.id)}/reply`, { body: { body, comment: options.comment.id } }));
|
|
2249
|
+
return new LinearComment(ctx, data);
|
|
2250
|
+
}
|
|
1695
2251
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1696
2252
|
[QUIET]() {
|
|
1697
2253
|
return quietOf(this.#ctx);
|
|
1698
2254
|
}
|
|
2255
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2256
|
+
[CONTEXT]() {
|
|
2257
|
+
return this.#ctx;
|
|
2258
|
+
}
|
|
1699
2259
|
}
|
|
1700
2260
|
export class LinearUser {
|
|
1701
2261
|
id;
|
|
@@ -1753,7 +2313,7 @@ export class LinearUser {
|
|
|
1753
2313
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/linear/users/${segment(this.id)}/label`, { body: { labels: [labels].flat(), issue: options.issue.id } }));
|
|
1754
2314
|
return (data === null ? undefined : new LinearDelivery(ctx, data));
|
|
1755
2315
|
}
|
|
1756
|
-
/** Delegate an issue to
|
|
2316
|
+
/** Delegate an issue to an app. Opens that app's agent session and sends it `AgentSessionEvent` (`created`); an issue delegated to another app moves. Experimental. */
|
|
1757
2317
|
async delegate(app, options) {
|
|
1758
2318
|
const ctx = this.#ctx;
|
|
1759
2319
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/linear/users/${segment(this.id)}/delegate`, { body: { app: app.id, issue: options.issue.id } }));
|
|
@@ -1810,29 +2370,60 @@ export class LinearUser {
|
|
|
1810
2370
|
[QUIET]() {
|
|
1811
2371
|
return quietOf(this.#ctx);
|
|
1812
2372
|
}
|
|
2373
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2374
|
+
[CONTEXT]() {
|
|
2375
|
+
return this.#ctx;
|
|
2376
|
+
}
|
|
1813
2377
|
}
|
|
1814
|
-
export class
|
|
2378
|
+
export class LinearComment {
|
|
1815
2379
|
id;
|
|
1816
|
-
|
|
1817
|
-
|
|
2380
|
+
issue;
|
|
2381
|
+
author;
|
|
2382
|
+
body;
|
|
2383
|
+
createdAt;
|
|
2384
|
+
url;
|
|
2385
|
+
session;
|
|
2386
|
+
delivery;
|
|
1818
2387
|
#ctx;
|
|
1819
2388
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
1820
2389
|
constructor(ctx, data) {
|
|
1821
2390
|
this.#ctx = ctx;
|
|
1822
2391
|
this.id = data.id;
|
|
1823
|
-
this.
|
|
1824
|
-
this.
|
|
2392
|
+
this.issue = new LinearIssue(ctx, data.issue);
|
|
2393
|
+
this.author = data.author.kind === "user" ? new LinearUser(ctx, data.author) : new LinearApp(ctx, data.author);
|
|
2394
|
+
this.body = data.body;
|
|
2395
|
+
this.createdAt = data.createdAt;
|
|
2396
|
+
this.url = data.url;
|
|
2397
|
+
this.session = data.session === undefined ? undefined : new LinearAgentSession(ctx, data.session);
|
|
2398
|
+
this.delivery = data.delivery === undefined ? undefined : new LinearDelivery(ctx, data.delivery);
|
|
1825
2399
|
}
|
|
1826
|
-
/**
|
|
1827
|
-
async
|
|
2400
|
+
/** The replies in a comment's thread, once the agent is quiet. Experimental. */
|
|
2401
|
+
async replies() {
|
|
1828
2402
|
const ctx = this.#ctx;
|
|
1829
|
-
|
|
1830
|
-
|
|
2403
|
+
await untilQuiet(() => quietOf(ctx));
|
|
2404
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/comments/${segment(this.id)}/replies`));
|
|
2405
|
+
return decodeLinearCommentReplies(ctx, data);
|
|
2406
|
+
}
|
|
2407
|
+
/** The `Comment` (`create`) delivery this comment caused to this app (decision 0027), or nothing when it wasn't told. The comment's `delivery` is the built-in app's. Experimental. */
|
|
2408
|
+
async deliveryFor(app) {
|
|
2409
|
+
const ctx = this.#ctx;
|
|
2410
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/comments/${segment(this.id)}/delivery-for`, { query: { app: app.id } }));
|
|
2411
|
+
return (data === null ? undefined : new LinearDelivery(ctx, data));
|
|
2412
|
+
}
|
|
2413
|
+
/** A comment's thread as a person reads it. Experimental. */
|
|
2414
|
+
async transcript() {
|
|
2415
|
+
const ctx = this.#ctx;
|
|
2416
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/comments/${segment(this.id)}/transcript`));
|
|
2417
|
+
return decodeLinearTranscript(ctx, data);
|
|
1831
2418
|
}
|
|
1832
2419
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1833
2420
|
[QUIET]() {
|
|
1834
2421
|
return quietOf(this.#ctx);
|
|
1835
2422
|
}
|
|
2423
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2424
|
+
[CONTEXT]() {
|
|
2425
|
+
return this.#ctx;
|
|
2426
|
+
}
|
|
1836
2427
|
}
|
|
1837
2428
|
export class LinearIssue {
|
|
1838
2429
|
id;
|
|
@@ -1923,58 +2514,37 @@ export class LinearIssue {
|
|
|
1923
2514
|
[QUIET]() {
|
|
1924
2515
|
return quietOf(this.#ctx);
|
|
1925
2516
|
}
|
|
2517
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2518
|
+
[CONTEXT]() {
|
|
2519
|
+
return this.#ctx;
|
|
2520
|
+
}
|
|
1926
2521
|
}
|
|
1927
|
-
export class
|
|
2522
|
+
export class LinearTeam {
|
|
1928
2523
|
id;
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
action;
|
|
1932
|
-
webhookId;
|
|
1933
|
-
payload;
|
|
1934
|
-
attempts;
|
|
1935
|
-
status;
|
|
2524
|
+
key;
|
|
2525
|
+
name;
|
|
1936
2526
|
#ctx;
|
|
1937
2527
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
1938
2528
|
constructor(ctx, data) {
|
|
1939
2529
|
this.#ctx = ctx;
|
|
1940
2530
|
this.id = data.id;
|
|
1941
|
-
this.
|
|
1942
|
-
this.
|
|
1943
|
-
this.action = data.action;
|
|
1944
|
-
this.webhookId = data.webhookId;
|
|
1945
|
-
this.payload = data.payload;
|
|
1946
|
-
this.attempts = data.attempts;
|
|
1947
|
-
this.status = data.status;
|
|
1948
|
-
}
|
|
1949
|
-
/** Re-read a delivery: its attempts and status. Experimental. */
|
|
1950
|
-
async refresh() {
|
|
1951
|
-
const ctx = this.#ctx;
|
|
1952
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/deliveries/${segment(this.id)}`));
|
|
1953
|
-
return new LinearDelivery(ctx, data);
|
|
1954
|
-
}
|
|
1955
|
-
/** Redeliver, as Linear retries: the same delivery, with a new `webhookTimestamp` and a new signature. Experimental. */
|
|
1956
|
-
async redeliver() {
|
|
1957
|
-
const ctx = this.#ctx;
|
|
1958
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/linear/deliveries/${segment(this.id)}/redeliver`));
|
|
1959
|
-
return data;
|
|
2531
|
+
this.key = data.key;
|
|
2532
|
+
this.name = data.name;
|
|
1960
2533
|
}
|
|
1961
|
-
/**
|
|
1962
|
-
async
|
|
2534
|
+
/** An issue of this team by its identifier (`ENG-12`). Experimental. */
|
|
2535
|
+
async issue(identifier) {
|
|
1963
2536
|
const ctx = this.#ctx;
|
|
1964
|
-
const data = (await ctx.transport.request("
|
|
1965
|
-
return data;
|
|
1966
|
-
}
|
|
1967
|
-
/** Wait for the delivery to settle, and resolve with the value as it is then. */
|
|
1968
|
-
async settled(options = {}) {
|
|
1969
|
-
return waitFor("the delivery to settle", async () => {
|
|
1970
|
-
const value = await this.refresh();
|
|
1971
|
-
return value.status === "pending" ? undefined : value;
|
|
1972
|
-
}, options);
|
|
2537
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/teams/${segment(this.id)}/issue`, { query: { identifier } }));
|
|
2538
|
+
return new LinearIssue(ctx, data);
|
|
1973
2539
|
}
|
|
1974
2540
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
1975
2541
|
[QUIET]() {
|
|
1976
2542
|
return quietOf(this.#ctx);
|
|
1977
2543
|
}
|
|
2544
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2545
|
+
[CONTEXT]() {
|
|
2546
|
+
return this.#ctx;
|
|
2547
|
+
}
|
|
1978
2548
|
}
|
|
1979
2549
|
export class LinearAgentSession {
|
|
1980
2550
|
id;
|
|
@@ -2039,46 +2609,68 @@ export class LinearAgentSession {
|
|
|
2039
2609
|
[QUIET]() {
|
|
2040
2610
|
return quietOf(this.#ctx);
|
|
2041
2611
|
}
|
|
2612
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2613
|
+
[CONTEXT]() {
|
|
2614
|
+
return this.#ctx;
|
|
2615
|
+
}
|
|
2042
2616
|
}
|
|
2043
|
-
export class
|
|
2617
|
+
export class LinearDelivery {
|
|
2044
2618
|
id;
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2619
|
+
channel;
|
|
2620
|
+
app;
|
|
2621
|
+
type;
|
|
2622
|
+
action;
|
|
2623
|
+
webhookId;
|
|
2624
|
+
payload;
|
|
2625
|
+
attempts;
|
|
2626
|
+
status;
|
|
2052
2627
|
#ctx;
|
|
2053
2628
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
2054
2629
|
constructor(ctx, data) {
|
|
2055
2630
|
this.#ctx = ctx;
|
|
2056
2631
|
this.id = data.id;
|
|
2057
|
-
this.
|
|
2058
|
-
this.
|
|
2059
|
-
this.
|
|
2060
|
-
this.
|
|
2061
|
-
this.
|
|
2062
|
-
this.
|
|
2063
|
-
this.
|
|
2632
|
+
this.channel = data.channel;
|
|
2633
|
+
this.app = data.app;
|
|
2634
|
+
this.type = data.type;
|
|
2635
|
+
this.action = data.action;
|
|
2636
|
+
this.webhookId = data.webhookId;
|
|
2637
|
+
this.payload = data.payload;
|
|
2638
|
+
this.attempts = data.attempts;
|
|
2639
|
+
this.status = data.status;
|
|
2064
2640
|
}
|
|
2065
|
-
/**
|
|
2066
|
-
async
|
|
2641
|
+
/** Re-read a delivery: its attempts and status. Experimental. */
|
|
2642
|
+
async refresh() {
|
|
2067
2643
|
const ctx = this.#ctx;
|
|
2068
|
-
await
|
|
2069
|
-
|
|
2070
|
-
return decodeLinearCommentReplies(ctx, data);
|
|
2644
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/linear/deliveries/${segment(this.id)}`));
|
|
2645
|
+
return new LinearDelivery(ctx, data);
|
|
2071
2646
|
}
|
|
2072
|
-
/**
|
|
2073
|
-
async
|
|
2647
|
+
/** Redeliver, as Linear retries: the same delivery, with a new `webhookTimestamp` and a new signature. Experimental. */
|
|
2648
|
+
async redeliver() {
|
|
2074
2649
|
const ctx = this.#ctx;
|
|
2075
|
-
const data = (await ctx.transport.request("
|
|
2076
|
-
return
|
|
2650
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/linear/deliveries/${segment(this.id)}/redeliver`));
|
|
2651
|
+
return data;
|
|
2652
|
+
}
|
|
2653
|
+
/** Send the delivery again: stale (its `webhookTimestamp` two minutes old), or signed with a secret that isn't the app's. Experimental. */
|
|
2654
|
+
async resend(options = {}) {
|
|
2655
|
+
const ctx = this.#ctx;
|
|
2656
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/linear/deliveries/${segment(this.id)}/resend`, { body: { badSignature: options.badSignature, stale: options.stale } }));
|
|
2657
|
+
return data;
|
|
2658
|
+
}
|
|
2659
|
+
/** Wait for the delivery to settle, and resolve with the value as it is then. */
|
|
2660
|
+
async settled(options = {}) {
|
|
2661
|
+
return waitFor("the delivery to settle", async () => {
|
|
2662
|
+
const value = await this.refresh();
|
|
2663
|
+
return value.status === "pending" ? undefined : value;
|
|
2664
|
+
}, options);
|
|
2077
2665
|
}
|
|
2078
2666
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2079
2667
|
[QUIET]() {
|
|
2080
2668
|
return quietOf(this.#ctx);
|
|
2081
2669
|
}
|
|
2670
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2671
|
+
[CONTEXT]() {
|
|
2672
|
+
return this.#ctx;
|
|
2673
|
+
}
|
|
2082
2674
|
}
|
|
2083
2675
|
export class LinearAgentActivity {
|
|
2084
2676
|
id;
|
|
@@ -2106,6 +2698,10 @@ export class LinearAgentActivity {
|
|
|
2106
2698
|
[QUIET]() {
|
|
2107
2699
|
return quietOf(this.#ctx);
|
|
2108
2700
|
}
|
|
2701
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2702
|
+
[CONTEXT]() {
|
|
2703
|
+
return this.#ctx;
|
|
2704
|
+
}
|
|
2109
2705
|
}
|
|
2110
2706
|
export class NotionFixture {
|
|
2111
2707
|
app;
|
|
@@ -2124,6 +2720,30 @@ export class NotionFixture {
|
|
|
2124
2720
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/notion/users`, { body: { name: options.name, id: options.id, email: options.email, avatarUrl: options.avatarUrl, token: options.token ?? credential("CHANNELSTACK_NOTION_USER_{name}_TOKEN", { name: options.name }) } }));
|
|
2125
2721
|
return new NotionUser(ctx, data);
|
|
2126
2722
|
}
|
|
2723
|
+
/** The people this session created. Experimental. */
|
|
2724
|
+
async users() {
|
|
2725
|
+
const ctx = this.#ctx;
|
|
2726
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/users`));
|
|
2727
|
+
return decodeNotionUsers(ctx, data);
|
|
2728
|
+
}
|
|
2729
|
+
/** Make another internal integration in the workspace, with its own bot user, token and webhook subscription (decision 0027), or return the one made with this name and settings. Its events go to CHANNELSTACK_NOTION_APP_<NAME>_WEBHOOK_URL, and it sees only the pages connected to it. Experimental. */
|
|
2730
|
+
async createApp(options) {
|
|
2731
|
+
const ctx = this.#ctx;
|
|
2732
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/notion/apps`, { body: { name: options.name, capabilities: options.capabilities, events: options.events } }));
|
|
2733
|
+
return new NotionIntegration(ctx, data);
|
|
2734
|
+
}
|
|
2735
|
+
/** The integrations this session used: the built-in one first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here. Experimental. */
|
|
2736
|
+
async apps() {
|
|
2737
|
+
const ctx = this.#ctx;
|
|
2738
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/apps`));
|
|
2739
|
+
return decodeNotionIntegrations(ctx, data);
|
|
2740
|
+
}
|
|
2741
|
+
/** The pages this session created, a database's rows included, read again from Notion live, oldest first. Not those in the trash. Experimental. */
|
|
2742
|
+
async pages() {
|
|
2743
|
+
const ctx = this.#ctx;
|
|
2744
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages`));
|
|
2745
|
+
return decodeNotionPages(ctx, data);
|
|
2746
|
+
}
|
|
2127
2747
|
/** Create a page as seed data. The integration sees it only through `connections`, its own or a parent's. In the fake it sends no event; live, a real person makes it, so Notion sends `page.created` to a connected integration. A person creating the page sends the event in both worlds. Experimental. */
|
|
2128
2748
|
async createPage(options) {
|
|
2129
2749
|
const ctx = this.#ctx;
|
|
@@ -2141,16 +2761,16 @@ export class NotionFixture {
|
|
|
2141
2761
|
const ctx = this.#ctx;
|
|
2142
2762
|
await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/notion/content-delay`, { body: { delay: parseDuration(delay) } });
|
|
2143
2763
|
}
|
|
2144
|
-
/** Send
|
|
2145
|
-
async sendVerification() {
|
|
2764
|
+
/** Send a subscription's verification request (`{ verification_token }`), as Notion does once when a subscription is created: the built-in integration's, or the one given's. Experimental. */
|
|
2765
|
+
async sendVerification(options = {}) {
|
|
2146
2766
|
const ctx = this.#ctx;
|
|
2147
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/notion/verification
|
|
2767
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/notion/verification`, { body: { app: options.app === undefined ? undefined : options.app.id } }));
|
|
2148
2768
|
return (data === null ? undefined : new NotionDelivery(ctx, data));
|
|
2149
2769
|
}
|
|
2150
2770
|
/** Every webhook channelstack sent the agent for this session, with every attempt. Experimental. */
|
|
2151
2771
|
async deliveries(options = {}) {
|
|
2152
2772
|
const ctx = this.#ctx;
|
|
2153
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/deliveries`, { query: { type: options.type, resource: options.resource === undefined ? undefined : options.resource.id } }));
|
|
2773
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/deliveries`, { query: { type: options.type, resource: options.resource === undefined ? undefined : options.resource.id, app: options.app === undefined ? undefined : options.app.id } }));
|
|
2154
2774
|
return decodeNotionDeliveries(ctx, data);
|
|
2155
2775
|
}
|
|
2156
2776
|
/** The REST calls the agent made about this session's pages, by the client's method name (`comments.create`). Experimental. */
|
|
@@ -2160,13 +2780,17 @@ export class NotionFixture {
|
|
|
2160
2780
|
return data;
|
|
2161
2781
|
}
|
|
2162
2782
|
/** Wait for the next new API call from the agent, after the last one this handle saw. */
|
|
2163
|
-
async waitForCall(filter, options = {}) {
|
|
2783
|
+
async waitForCall(filter = {}, options = {}) {
|
|
2164
2784
|
return waitForNext(this.#seen, `waitForCall:${JSON.stringify(filter)}`, () => this.calls(filter), () => true, "an API call from the agent", options);
|
|
2165
2785
|
}
|
|
2166
2786
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2167
2787
|
[QUIET]() {
|
|
2168
2788
|
return quietOf(this.#ctx);
|
|
2169
2789
|
}
|
|
2790
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2791
|
+
[CONTEXT]() {
|
|
2792
|
+
return this.#ctx;
|
|
2793
|
+
}
|
|
2170
2794
|
}
|
|
2171
2795
|
export class NotionIntegration {
|
|
2172
2796
|
id;
|
|
@@ -2188,10 +2812,38 @@ export class NotionIntegration {
|
|
|
2188
2812
|
this.token = data.token;
|
|
2189
2813
|
this.webhookSecret = data.webhookSecret;
|
|
2190
2814
|
}
|
|
2815
|
+
/** An integration a test made starts a discussion on a page, or anchored to the block with `anchor` in its text, as its own `comments.create` would: on a page connected to it, mentioning people only. Sends `comment.created` to every integration that sees the page. Experimental. */
|
|
2816
|
+
async comment(text, options) {
|
|
2817
|
+
const ctx = this.#ctx;
|
|
2818
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/notion/apps/${segment(this.id)}/comment`, { body: { text, page: options.page.id, anchor: options.anchor === undefined ? undefined : patternOnWire(options.anchor) } }));
|
|
2819
|
+
return new NotionComment(ctx, data);
|
|
2820
|
+
}
|
|
2821
|
+
/** An integration a test made replies in a discussion, as `comments.create` with `discussion_id` would. Sends `comment.created`. Experimental. */
|
|
2822
|
+
async reply(text, options) {
|
|
2823
|
+
const ctx = this.#ctx;
|
|
2824
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/notion/apps/${segment(this.id)}/reply`, { body: { text, discussion: options.discussion.id } }));
|
|
2825
|
+
return new NotionComment(ctx, data);
|
|
2826
|
+
}
|
|
2827
|
+
/** An integration a test made edits a page's body, as its own block calls would: append, or replace it. Sends one `page.content_updated` once Notion's batching delay is over. Experimental. */
|
|
2828
|
+
async edit(change, options) {
|
|
2829
|
+
const ctx = this.#ctx;
|
|
2830
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/notion/apps/${segment(this.id)}/edit`, { body: { change: { ...change, append: change.append === undefined ? undefined : readDocument(change.append), replace: change.replace === undefined ? undefined : readDocument(change.replace) }, page: options.page.id } }));
|
|
2831
|
+
return (data === null ? undefined : new NotionDelivery(ctx, data));
|
|
2832
|
+
}
|
|
2833
|
+
/** An integration a test made changes a page's title, as its own `pages.update` would. Sends `page.properties_updated`. Experimental. */
|
|
2834
|
+
async rename(title, options) {
|
|
2835
|
+
const ctx = this.#ctx;
|
|
2836
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/notion/apps/${segment(this.id)}/rename`, { body: { title, page: options.page.id } }));
|
|
2837
|
+
return (data === null ? undefined : new NotionDelivery(ctx, data));
|
|
2838
|
+
}
|
|
2191
2839
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2192
2840
|
[QUIET]() {
|
|
2193
2841
|
return quietOf(this.#ctx);
|
|
2194
2842
|
}
|
|
2843
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2844
|
+
[CONTEXT]() {
|
|
2845
|
+
return this.#ctx;
|
|
2846
|
+
}
|
|
2195
2847
|
}
|
|
2196
2848
|
export class NotionUser {
|
|
2197
2849
|
id;
|
|
@@ -2295,70 +2947,93 @@ export class NotionUser {
|
|
|
2295
2947
|
[QUIET]() {
|
|
2296
2948
|
return quietOf(this.#ctx);
|
|
2297
2949
|
}
|
|
2950
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2951
|
+
[CONTEXT]() {
|
|
2952
|
+
return this.#ctx;
|
|
2953
|
+
}
|
|
2298
2954
|
}
|
|
2299
|
-
export class
|
|
2955
|
+
export class NotionComment {
|
|
2300
2956
|
id;
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2957
|
+
discussion;
|
|
2958
|
+
author;
|
|
2959
|
+
text;
|
|
2960
|
+
createdAt;
|
|
2961
|
+
delivery;
|
|
2304
2962
|
#ctx;
|
|
2305
2963
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
2306
2964
|
constructor(ctx, data) {
|
|
2307
2965
|
this.#ctx = ctx;
|
|
2308
2966
|
this.id = data.id;
|
|
2309
|
-
this.
|
|
2310
|
-
this.
|
|
2311
|
-
this.
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
async discussions() {
|
|
2315
|
-
const ctx = this.#ctx;
|
|
2316
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages/${segment(this.id)}/discussions`));
|
|
2317
|
-
return decodeNotionDiscussions(ctx, data);
|
|
2967
|
+
this.discussion = new NotionDiscussion(ctx, data.discussion);
|
|
2968
|
+
this.author = data.author.kind === "user" ? new NotionUser(ctx, data.author) : new NotionIntegration(ctx, data.author);
|
|
2969
|
+
this.text = data.text;
|
|
2970
|
+
this.createdAt = data.createdAt;
|
|
2971
|
+
this.delivery = data.delivery === undefined ? undefined : new NotionDelivery(ctx, data.delivery);
|
|
2318
2972
|
}
|
|
2319
|
-
/** The
|
|
2320
|
-
async
|
|
2973
|
+
/** The `comment.created` delivery this comment caused to this integration (decision 0027), or nothing when it wasn't told. The comment's `delivery` is the built-in integration's. Experimental. */
|
|
2974
|
+
async deliveryFor(app) {
|
|
2321
2975
|
const ctx = this.#ctx;
|
|
2322
|
-
await
|
|
2323
|
-
|
|
2324
|
-
return data;
|
|
2976
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/comments/${segment(this.id)}/delivery-for`, { query: { app: app.id } }));
|
|
2977
|
+
return (data === null ? undefined : new NotionDelivery(ctx, data));
|
|
2325
2978
|
}
|
|
2326
|
-
/**
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages/${segment(this.id)}/blocks`));
|
|
2330
|
-
return data;
|
|
2979
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2980
|
+
[QUIET]() {
|
|
2981
|
+
return quietOf(this.#ctx);
|
|
2331
2982
|
}
|
|
2332
|
-
/**
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages/${segment(this.id)}/property`, { query: { name } }));
|
|
2336
|
-
return decodeNotionPropertyValue(ctx, data);
|
|
2983
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
2984
|
+
[CONTEXT]() {
|
|
2985
|
+
return this.#ctx;
|
|
2337
2986
|
}
|
|
2338
|
-
|
|
2339
|
-
|
|
2987
|
+
}
|
|
2988
|
+
export class NotionDiscussion {
|
|
2989
|
+
id;
|
|
2990
|
+
page;
|
|
2991
|
+
anchor;
|
|
2992
|
+
#ctx;
|
|
2993
|
+
#seen = new Map();
|
|
2994
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
2995
|
+
constructor(ctx, data) {
|
|
2996
|
+
this.#ctx = ctx;
|
|
2997
|
+
this.id = data.id;
|
|
2998
|
+
this.page = new NotionPage(ctx, data.page);
|
|
2999
|
+
this.anchor = data.anchor;
|
|
3000
|
+
}
|
|
3001
|
+
/** The discussion's comments, oldest first. Experimental. */
|
|
3002
|
+
async comments() {
|
|
2340
3003
|
const ctx = this.#ctx;
|
|
2341
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/
|
|
2342
|
-
return
|
|
3004
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/discussions/${segment(this.id)}/comments`));
|
|
3005
|
+
return decodeNotionComments(ctx, data);
|
|
2343
3006
|
}
|
|
2344
|
-
/**
|
|
2345
|
-
async
|
|
3007
|
+
/** Whether the discussion is resolved. Experimental. */
|
|
3008
|
+
async resolved() {
|
|
2346
3009
|
const ctx = this.#ctx;
|
|
2347
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/
|
|
2348
|
-
return
|
|
3010
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/discussions/${segment(this.id)}/resolved`));
|
|
3011
|
+
return data;
|
|
2349
3012
|
}
|
|
2350
|
-
/** The
|
|
3013
|
+
/** The discussion as a person reads it. Experimental. */
|
|
2351
3014
|
async transcript() {
|
|
2352
3015
|
const ctx = this.#ctx;
|
|
2353
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/
|
|
3016
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/discussions/${segment(this.id)}/transcript`));
|
|
2354
3017
|
return decodeNotionTranscript(ctx, data);
|
|
2355
3018
|
}
|
|
3019
|
+
/** Wait for the next new comment matching `from` (anyone if omitted), after the last one this handle saw. */
|
|
3020
|
+
async waitForComment(options = {}) {
|
|
3021
|
+
return waitForNext(this.#seen, "waitForComment", () => this.comments(), (item) => fromMatches(item.author, options.from), describeWait("a comment", options.from), options);
|
|
3022
|
+
}
|
|
3023
|
+
/** The latest comment matching `from`, once the agent is quiet. Waits for at least one. */
|
|
3024
|
+
async latestComment(options = {}) {
|
|
3025
|
+
return latestOnceQuiet(() => this.comments(), (item) => fromMatches(item.author, options.from), () => quietOf(this.#ctx), describeWait("a comment", options.from), options);
|
|
3026
|
+
}
|
|
2356
3027
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2357
3028
|
[QUIET]() {
|
|
2358
3029
|
return quietOf(this.#ctx);
|
|
2359
3030
|
}
|
|
3031
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3032
|
+
[CONTEXT]() {
|
|
3033
|
+
return this.#ctx;
|
|
3034
|
+
}
|
|
2360
3035
|
}
|
|
2361
|
-
export class
|
|
3036
|
+
export class NotionPage {
|
|
2362
3037
|
id;
|
|
2363
3038
|
channel;
|
|
2364
3039
|
title;
|
|
@@ -2372,20 +3047,62 @@ export class NotionDatabase {
|
|
|
2372
3047
|
this.title = data.title;
|
|
2373
3048
|
this.url = data.url;
|
|
2374
3049
|
}
|
|
2375
|
-
/** The
|
|
2376
|
-
async
|
|
3050
|
+
/** The page's discussions: on the page itself, and on its blocks. Experimental. */
|
|
3051
|
+
async discussions() {
|
|
2377
3052
|
const ctx = this.#ctx;
|
|
2378
|
-
const data = (await ctx.transport.request("
|
|
2379
|
-
return
|
|
3053
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages/${segment(this.id)}/discussions`));
|
|
3054
|
+
return decodeNotionDiscussions(ctx, data);
|
|
3055
|
+
}
|
|
3056
|
+
/** The page body as Markdown, once the agent is quiet. Experimental. */
|
|
3057
|
+
async markdown() {
|
|
3058
|
+
const ctx = this.#ctx;
|
|
3059
|
+
await untilQuiet(() => quietOf(ctx));
|
|
3060
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages/${segment(this.id)}/markdown`));
|
|
3061
|
+
return data;
|
|
3062
|
+
}
|
|
3063
|
+
/** The page's blocks as the API has them, with nested blocks under `children`. Experimental. */
|
|
3064
|
+
async blocks() {
|
|
3065
|
+
const ctx = this.#ctx;
|
|
3066
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages/${segment(this.id)}/blocks`));
|
|
3067
|
+
return data;
|
|
3068
|
+
}
|
|
3069
|
+
/** A property's value as a person reads it: text, a number, option names, ids. Experimental. */
|
|
3070
|
+
async property(name) {
|
|
3071
|
+
const ctx = this.#ctx;
|
|
3072
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages/${segment(this.id)}/property`, { query: { name } }));
|
|
3073
|
+
return decodeNotionPropertyValue(ctx, data);
|
|
3074
|
+
}
|
|
3075
|
+
/** The pages directly under this page. Experimental. */
|
|
3076
|
+
async children() {
|
|
3077
|
+
const ctx = this.#ctx;
|
|
3078
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages/${segment(this.id)}/children`));
|
|
3079
|
+
return decodeNotionChildPages(ctx, data);
|
|
3080
|
+
}
|
|
3081
|
+
/** The integrations that can see the page: connected to it or to a page above it. Experimental. */
|
|
3082
|
+
async connections() {
|
|
3083
|
+
const ctx = this.#ctx;
|
|
3084
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages/${segment(this.id)}/connections`));
|
|
3085
|
+
return decodeNotionConnections(ctx, data);
|
|
3086
|
+
}
|
|
3087
|
+
/** The page and its discussions as a person reads them. Experimental. */
|
|
3088
|
+
async transcript() {
|
|
3089
|
+
const ctx = this.#ctx;
|
|
3090
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/pages/${segment(this.id)}/transcript`));
|
|
3091
|
+
return decodeNotionTranscript(ctx, data);
|
|
2380
3092
|
}
|
|
2381
3093
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2382
3094
|
[QUIET]() {
|
|
2383
3095
|
return quietOf(this.#ctx);
|
|
2384
3096
|
}
|
|
3097
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3098
|
+
[CONTEXT]() {
|
|
3099
|
+
return this.#ctx;
|
|
3100
|
+
}
|
|
2385
3101
|
}
|
|
2386
3102
|
export class NotionDelivery {
|
|
2387
3103
|
id;
|
|
2388
3104
|
channel;
|
|
3105
|
+
app;
|
|
2389
3106
|
type;
|
|
2390
3107
|
entity;
|
|
2391
3108
|
payload;
|
|
@@ -2397,6 +3114,7 @@ export class NotionDelivery {
|
|
|
2397
3114
|
this.#ctx = ctx;
|
|
2398
3115
|
this.id = data.id;
|
|
2399
3116
|
this.channel = data.channel;
|
|
3117
|
+
this.app = data.app;
|
|
2400
3118
|
this.type = data.type;
|
|
2401
3119
|
this.entity = data.entity;
|
|
2402
3120
|
this.payload = data.payload;
|
|
@@ -2432,73 +3150,39 @@ export class NotionDelivery {
|
|
|
2432
3150
|
[QUIET]() {
|
|
2433
3151
|
return quietOf(this.#ctx);
|
|
2434
3152
|
}
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
discussion;
|
|
2439
|
-
author;
|
|
2440
|
-
text;
|
|
2441
|
-
createdAt;
|
|
2442
|
-
delivery;
|
|
2443
|
-
#ctx;
|
|
2444
|
-
/** @internal Handles come from the SDK, never from `new`. */
|
|
2445
|
-
constructor(ctx, data) {
|
|
2446
|
-
this.#ctx = ctx;
|
|
2447
|
-
this.id = data.id;
|
|
2448
|
-
this.discussion = new NotionDiscussion(ctx, data.discussion);
|
|
2449
|
-
this.author = data.author.kind === "user" ? new NotionUser(ctx, data.author) : new NotionIntegration(ctx, data.author);
|
|
2450
|
-
this.text = data.text;
|
|
2451
|
-
this.createdAt = data.createdAt;
|
|
2452
|
-
this.delivery = data.delivery === undefined ? undefined : new NotionDelivery(ctx, data.delivery);
|
|
2453
|
-
}
|
|
2454
|
-
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2455
|
-
[QUIET]() {
|
|
2456
|
-
return quietOf(this.#ctx);
|
|
3153
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3154
|
+
[CONTEXT]() {
|
|
3155
|
+
return this.#ctx;
|
|
2457
3156
|
}
|
|
2458
3157
|
}
|
|
2459
|
-
export class
|
|
3158
|
+
export class NotionDatabase {
|
|
2460
3159
|
id;
|
|
2461
|
-
|
|
2462
|
-
|
|
3160
|
+
channel;
|
|
3161
|
+
title;
|
|
3162
|
+
url;
|
|
2463
3163
|
#ctx;
|
|
2464
|
-
#seen = new Map();
|
|
2465
3164
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
2466
3165
|
constructor(ctx, data) {
|
|
2467
3166
|
this.#ctx = ctx;
|
|
2468
3167
|
this.id = data.id;
|
|
2469
|
-
this.
|
|
2470
|
-
this.
|
|
2471
|
-
|
|
2472
|
-
/** The discussion's comments, oldest first. Experimental. */
|
|
2473
|
-
async comments() {
|
|
2474
|
-
const ctx = this.#ctx;
|
|
2475
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/discussions/${segment(this.id)}/comments`));
|
|
2476
|
-
return decodeNotionComments(ctx, data);
|
|
2477
|
-
}
|
|
2478
|
-
/** Whether the discussion is resolved. Experimental. */
|
|
2479
|
-
async resolved() {
|
|
2480
|
-
const ctx = this.#ctx;
|
|
2481
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/notion/discussions/${segment(this.id)}/resolved`));
|
|
2482
|
-
return data;
|
|
3168
|
+
this.channel = data.channel;
|
|
3169
|
+
this.title = data.title;
|
|
3170
|
+
this.url = data.url;
|
|
2483
3171
|
}
|
|
2484
|
-
/** The
|
|
2485
|
-
async
|
|
3172
|
+
/** The rows of a database, optionally only those whose properties have these values. Experimental. */
|
|
3173
|
+
async rows(filter) {
|
|
2486
3174
|
const ctx = this.#ctx;
|
|
2487
|
-
const data = (await ctx.transport.request("
|
|
2488
|
-
return
|
|
2489
|
-
}
|
|
2490
|
-
/** Wait for the next new comment matching `from` (anyone if omitted), after the last one this handle saw. */
|
|
2491
|
-
async waitForComment(options = {}) {
|
|
2492
|
-
return waitForNext(this.#seen, "waitForComment", () => this.comments(), (item) => fromMatches(item.author, options.from), describeWait("a comment", options.from), options);
|
|
2493
|
-
}
|
|
2494
|
-
/** The latest comment matching `from`, once the agent is quiet. Waits for at least one. */
|
|
2495
|
-
async latestComment(options = {}) {
|
|
2496
|
-
return latestOnceQuiet(() => this.comments(), (item) => fromMatches(item.author, options.from), () => quietOf(this.#ctx), describeWait("a comment", options.from), options);
|
|
3175
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/notion/databases/${segment(this.id)}/rows`, { body: { filter } }));
|
|
3176
|
+
return decodeNotionRows(ctx, data);
|
|
2497
3177
|
}
|
|
2498
3178
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2499
3179
|
[QUIET]() {
|
|
2500
3180
|
return quietOf(this.#ctx);
|
|
2501
3181
|
}
|
|
3182
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3183
|
+
[CONTEXT]() {
|
|
3184
|
+
return this.#ctx;
|
|
3185
|
+
}
|
|
2502
3186
|
}
|
|
2503
3187
|
export class ResendFixture {
|
|
2504
3188
|
app;
|
|
@@ -2511,16 +3195,40 @@ export class ResendFixture {
|
|
|
2511
3195
|
this.app = new ResendApp(ctx, data.app);
|
|
2512
3196
|
this.apiUrl = data.apiUrl;
|
|
2513
3197
|
}
|
|
3198
|
+
/** Make another app: a team of its own, with its own address and credentials (decision 0027), or return the one made with this name and settings. Its events go to CHANNELSTACK_RESEND_APP_<NAME>_WEBHOOK_URL. Experimental. */
|
|
3199
|
+
async createApp(options) {
|
|
3200
|
+
const ctx = this.#ctx;
|
|
3201
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/resend/apps`, { body: { name: options.name, domain: options.domain } }));
|
|
3202
|
+
return new ResendApp(ctx, data);
|
|
3203
|
+
}
|
|
3204
|
+
/** The teams this session used: the agent's first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here. Experimental. */
|
|
3205
|
+
async apps() {
|
|
3206
|
+
const ctx = this.#ctx;
|
|
3207
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/resend/apps`));
|
|
3208
|
+
return decodeResendApps(ctx, data);
|
|
3209
|
+
}
|
|
2514
3210
|
/** Create a person: a mailbox, at `<name>@example.com` unless a test gives the address. Experimental. */
|
|
2515
3211
|
async createUser(options) {
|
|
2516
3212
|
const ctx = this.#ctx;
|
|
2517
3213
|
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/resend/users`, { body: { name: options.name, address: options.address, token: options.token ?? credential("CHANNELSTACK_RESEND_USER_{name}_TOKEN", { name: options.name }) } }));
|
|
2518
3214
|
return new ResendUser(ctx, data);
|
|
2519
3215
|
}
|
|
3216
|
+
/** The people this session created. Experimental. */
|
|
3217
|
+
async users() {
|
|
3218
|
+
const ctx = this.#ctx;
|
|
3219
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/resend/users`));
|
|
3220
|
+
return decodeResendUsers(ctx, data);
|
|
3221
|
+
}
|
|
3222
|
+
/** The threads this session's people started, oldest first. Experimental. */
|
|
3223
|
+
async threads() {
|
|
3224
|
+
const ctx = this.#ctx;
|
|
3225
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/resend/threads`));
|
|
3226
|
+
return decodeResendThreads(ctx, data);
|
|
3227
|
+
}
|
|
2520
3228
|
/** Every webhook channelstack sent the agent for this session, with every attempt. Experimental. */
|
|
2521
3229
|
async deliveries(options = {}) {
|
|
2522
3230
|
const ctx = this.#ctx;
|
|
2523
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/resend/deliveries`, { query: { type: options.type, resource: options.resource === undefined ? undefined : options.resource.id } }));
|
|
3231
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/resend/deliveries`, { query: { type: options.type, resource: options.resource === undefined ? undefined : options.resource.id, app: options.app === undefined ? undefined : options.app.id } }));
|
|
2524
3232
|
return decodeResendDeliveries(ctx, data);
|
|
2525
3233
|
}
|
|
2526
3234
|
/** The REST calls the agent made about this session's emails, by the SDK's method name (`emails.send`). Experimental. */
|
|
@@ -2530,13 +3238,17 @@ export class ResendFixture {
|
|
|
2530
3238
|
return data;
|
|
2531
3239
|
}
|
|
2532
3240
|
/** Wait for the next new API call from the agent, after the last one this handle saw. */
|
|
2533
|
-
async waitForCall(filter, options = {}) {
|
|
3241
|
+
async waitForCall(filter = {}, options = {}) {
|
|
2534
3242
|
return waitForNext(this.#seen, `waitForCall:${JSON.stringify(filter)}`, () => this.calls(filter), () => true, "an API call from the agent", options);
|
|
2535
3243
|
}
|
|
2536
3244
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2537
3245
|
[QUIET]() {
|
|
2538
3246
|
return quietOf(this.#ctx);
|
|
2539
3247
|
}
|
|
3248
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3249
|
+
[CONTEXT]() {
|
|
3250
|
+
return this.#ctx;
|
|
3251
|
+
}
|
|
2540
3252
|
}
|
|
2541
3253
|
export class ResendApp {
|
|
2542
3254
|
id;
|
|
@@ -2545,6 +3257,9 @@ export class ResendApp {
|
|
|
2545
3257
|
name;
|
|
2546
3258
|
botUserId;
|
|
2547
3259
|
address;
|
|
3260
|
+
domain;
|
|
3261
|
+
apiKey;
|
|
3262
|
+
webhookSecret;
|
|
2548
3263
|
#ctx;
|
|
2549
3264
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
2550
3265
|
constructor(ctx, data) {
|
|
@@ -2555,55 +3270,30 @@ export class ResendApp {
|
|
|
2555
3270
|
this.name = data.name;
|
|
2556
3271
|
this.botUserId = data.botUserId;
|
|
2557
3272
|
this.address = data.address;
|
|
3273
|
+
this.domain = data.domain;
|
|
3274
|
+
this.apiKey = data.apiKey;
|
|
3275
|
+
this.webhookSecret = data.webhookSecret;
|
|
2558
3276
|
}
|
|
2559
|
-
/**
|
|
2560
|
-
[QUIET]() {
|
|
2561
|
-
return quietOf(this.#ctx);
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2564
|
-
export class ResendUser {
|
|
2565
|
-
id;
|
|
2566
|
-
channel;
|
|
2567
|
-
kind;
|
|
2568
|
-
name;
|
|
2569
|
-
address;
|
|
2570
|
-
#ctx;
|
|
2571
|
-
#seen = new Map();
|
|
2572
|
-
/** @internal Handles come from the SDK, never from `new`. */
|
|
2573
|
-
constructor(ctx, data) {
|
|
2574
|
-
this.#ctx = ctx;
|
|
2575
|
-
this.id = data.id;
|
|
2576
|
-
this.channel = data.channel;
|
|
2577
|
-
this.kind = data.kind;
|
|
2578
|
-
this.name = data.name;
|
|
2579
|
-
this.address = data.address;
|
|
2580
|
-
}
|
|
2581
|
-
/** The person emails someone: the agent (`resend.app`), or another person. Experimental. */
|
|
3277
|
+
/** An app a test made sends an email, through its own team's API, as its own call would. Experimental. */
|
|
2582
3278
|
async send(options) {
|
|
2583
3279
|
const ctx = this.#ctx;
|
|
2584
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/resend/
|
|
3280
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/resend/apps/${segment(this.id)}/send`, { body: { to: options.to.map((item) => item.id), cc: options.cc === undefined ? undefined : options.cc.map((item) => item.id), subject: options.subject, text: options.text, html: options.html, headers: options.headers } }));
|
|
2585
3281
|
return new ResendEmail(ctx, data);
|
|
2586
3282
|
}
|
|
2587
|
-
/**
|
|
3283
|
+
/** An app a test made replies to an email, in its thread, as its own call would. Experimental. */
|
|
2588
3284
|
async reply(email, options = {}) {
|
|
2589
3285
|
const ctx = this.#ctx;
|
|
2590
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/resend/
|
|
3286
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/resend/apps/${segment(this.id)}/reply`, { body: { email: email.id, text: options.text, html: options.html, all: options.all, headers: options.headers } }));
|
|
2591
3287
|
return new ResendEmail(ctx, data);
|
|
2592
3288
|
}
|
|
2593
|
-
/** What reached the person's mailbox, oldest first. Experimental. */
|
|
2594
|
-
async inbox() {
|
|
2595
|
-
const ctx = this.#ctx;
|
|
2596
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/resend/users/${segment(this.id)}/inbox`));
|
|
2597
|
-
return decodeResendInbox(ctx, data);
|
|
2598
|
-
}
|
|
2599
|
-
/** Wait for the next new email matching `from` (anyone if omitted), after the last one this handle saw. */
|
|
2600
|
-
async waitForEmail(options = {}) {
|
|
2601
|
-
return waitForNext(this.#seen, "waitForEmail", () => this.inbox(), (item) => fromMatches(item.author, options.from), describeWait("an email", options.from), options);
|
|
2602
|
-
}
|
|
2603
3289
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2604
3290
|
[QUIET]() {
|
|
2605
3291
|
return quietOf(this.#ctx);
|
|
2606
3292
|
}
|
|
3293
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3294
|
+
[CONTEXT]() {
|
|
3295
|
+
return this.#ctx;
|
|
3296
|
+
}
|
|
2607
3297
|
}
|
|
2608
3298
|
export class ResendEmail {
|
|
2609
3299
|
id;
|
|
@@ -2617,6 +3307,7 @@ export class ResendEmail {
|
|
|
2617
3307
|
text;
|
|
2618
3308
|
at;
|
|
2619
3309
|
messageId;
|
|
3310
|
+
headers;
|
|
2620
3311
|
delivery;
|
|
2621
3312
|
#ctx;
|
|
2622
3313
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
@@ -2633,6 +3324,7 @@ export class ResendEmail {
|
|
|
2633
3324
|
this.text = data.text;
|
|
2634
3325
|
this.at = data.at;
|
|
2635
3326
|
this.messageId = data.messageId;
|
|
3327
|
+
this.headers = data.headers;
|
|
2636
3328
|
this.delivery = data.delivery === undefined ? undefined : new ResendDelivery(ctx, data.delivery);
|
|
2637
3329
|
}
|
|
2638
3330
|
/** Re-read an email. Experimental. */
|
|
@@ -2641,10 +3333,20 @@ export class ResendEmail {
|
|
|
2641
3333
|
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/resend/emails/${segment(this.id)}`));
|
|
2642
3334
|
return new ResendEmail(ctx, data);
|
|
2643
3335
|
}
|
|
3336
|
+
/** The delivery that told this app of the email (decision 0027), or nothing when it wasn't told. Experimental. */
|
|
3337
|
+
async deliveryFor(app) {
|
|
3338
|
+
const ctx = this.#ctx;
|
|
3339
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/resend/emails/${segment(this.id)}/delivery-for`, { query: { app: app.id } }));
|
|
3340
|
+
return (data === null ? undefined : new ResendDelivery(ctx, data));
|
|
3341
|
+
}
|
|
2644
3342
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2645
3343
|
[QUIET]() {
|
|
2646
3344
|
return quietOf(this.#ctx);
|
|
2647
3345
|
}
|
|
3346
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3347
|
+
[CONTEXT]() {
|
|
3348
|
+
return this.#ctx;
|
|
3349
|
+
}
|
|
2648
3350
|
}
|
|
2649
3351
|
export class ResendThread {
|
|
2650
3352
|
id;
|
|
@@ -2689,10 +3391,15 @@ export class ResendThread {
|
|
|
2689
3391
|
[QUIET]() {
|
|
2690
3392
|
return quietOf(this.#ctx);
|
|
2691
3393
|
}
|
|
3394
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3395
|
+
[CONTEXT]() {
|
|
3396
|
+
return this.#ctx;
|
|
3397
|
+
}
|
|
2692
3398
|
}
|
|
2693
3399
|
export class ResendDelivery {
|
|
2694
3400
|
id;
|
|
2695
3401
|
channel;
|
|
3402
|
+
app;
|
|
2696
3403
|
type;
|
|
2697
3404
|
email;
|
|
2698
3405
|
payload;
|
|
@@ -2704,6 +3411,7 @@ export class ResendDelivery {
|
|
|
2704
3411
|
this.#ctx = ctx;
|
|
2705
3412
|
this.id = data.id;
|
|
2706
3413
|
this.channel = data.channel;
|
|
3414
|
+
this.app = data.app;
|
|
2707
3415
|
this.type = data.type;
|
|
2708
3416
|
this.email = data.email;
|
|
2709
3417
|
this.payload = data.payload;
|
|
@@ -2739,76 +3447,136 @@ export class ResendDelivery {
|
|
|
2739
3447
|
[QUIET]() {
|
|
2740
3448
|
return quietOf(this.#ctx);
|
|
2741
3449
|
}
|
|
3450
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3451
|
+
[CONTEXT]() {
|
|
3452
|
+
return this.#ctx;
|
|
3453
|
+
}
|
|
2742
3454
|
}
|
|
2743
|
-
export class
|
|
2744
|
-
|
|
2745
|
-
|
|
3455
|
+
export class ResendUser {
|
|
3456
|
+
id;
|
|
3457
|
+
channel;
|
|
3458
|
+
kind;
|
|
3459
|
+
name;
|
|
3460
|
+
address;
|
|
2746
3461
|
#ctx;
|
|
2747
3462
|
#seen = new Map();
|
|
2748
3463
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
2749
3464
|
constructor(ctx, data) {
|
|
2750
3465
|
this.#ctx = ctx;
|
|
2751
|
-
this.
|
|
2752
|
-
this.
|
|
3466
|
+
this.id = data.id;
|
|
3467
|
+
this.channel = data.channel;
|
|
3468
|
+
this.kind = data.kind;
|
|
3469
|
+
this.name = data.name;
|
|
3470
|
+
this.address = data.address;
|
|
2753
3471
|
}
|
|
2754
|
-
/**
|
|
2755
|
-
async
|
|
3472
|
+
/** The person emails someone: the agent (`resend.app`), another app, or another person. Experimental. */
|
|
3473
|
+
async send(options) {
|
|
2756
3474
|
const ctx = this.#ctx;
|
|
2757
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/
|
|
2758
|
-
return new
|
|
3475
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/resend/users/${segment(this.id)}/send`, { body: { to: options.to.map((item) => item.id), cc: options.cc === undefined ? undefined : options.cc.map((item) => item.id), subject: options.subject, text: options.text, html: options.html } }));
|
|
3476
|
+
return new ResendEmail(ctx, data);
|
|
2759
3477
|
}
|
|
2760
|
-
/**
|
|
2761
|
-
async
|
|
3478
|
+
/** The person replies to an email, in its thread: `Re:` its subject, with `In-Reply-To` and `References`. Experimental. */
|
|
3479
|
+
async reply(email, options = {}) {
|
|
2762
3480
|
const ctx = this.#ctx;
|
|
2763
|
-
const data = (await ctx.transport.request("
|
|
2764
|
-
return
|
|
3481
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/resend/users/${segment(this.id)}/reply`, { body: { email: email.id, text: options.text, html: options.html, all: options.all } }));
|
|
3482
|
+
return new ResendEmail(ctx, data);
|
|
2765
3483
|
}
|
|
2766
|
-
/**
|
|
2767
|
-
async
|
|
3484
|
+
/** What reached the person's mailbox, oldest first. Experimental. */
|
|
3485
|
+
async inbox() {
|
|
2768
3486
|
const ctx = this.#ctx;
|
|
2769
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/
|
|
2770
|
-
return data;
|
|
3487
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/resend/users/${segment(this.id)}/inbox`));
|
|
3488
|
+
return decodeResendInbox(ctx, data);
|
|
2771
3489
|
}
|
|
2772
|
-
/** Wait for the next new
|
|
2773
|
-
async
|
|
2774
|
-
return waitForNext(this.#seen,
|
|
3490
|
+
/** Wait for the next new email matching `from` (anyone if omitted), after the last one this handle saw. */
|
|
3491
|
+
async waitForEmail(options = {}) {
|
|
3492
|
+
return waitForNext(this.#seen, "waitForEmail", () => this.inbox(), (item) => fromMatches(item.author, options.from), describeWait("an email", options.from), options);
|
|
2775
3493
|
}
|
|
2776
3494
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2777
3495
|
[QUIET]() {
|
|
2778
3496
|
return quietOf(this.#ctx);
|
|
2779
3497
|
}
|
|
3498
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3499
|
+
[CONTEXT]() {
|
|
3500
|
+
return this.#ctx;
|
|
3501
|
+
}
|
|
2780
3502
|
}
|
|
2781
|
-
export class
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
kind;
|
|
2785
|
-
name;
|
|
2786
|
-
botUserId;
|
|
2787
|
-
address;
|
|
3503
|
+
export class GoogleFixture {
|
|
3504
|
+
app;
|
|
3505
|
+
apiUrl;
|
|
2788
3506
|
#ctx;
|
|
3507
|
+
#seen = new Map();
|
|
2789
3508
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
2790
3509
|
constructor(ctx, data) {
|
|
2791
3510
|
this.#ctx = ctx;
|
|
2792
|
-
this.
|
|
2793
|
-
this.
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
3511
|
+
this.app = new GoogleApp(ctx, data.app);
|
|
3512
|
+
this.apiUrl = data.apiUrl;
|
|
3513
|
+
}
|
|
3514
|
+
/** Make another app: a mailbox of its own, with its own address and credentials (decision 0027), or return the one made with this name and settings. Its events go to CHANNELSTACK_GOOGLE_APP_<NAME>_WEBHOOK_URL. Experimental. */
|
|
3515
|
+
async createApp(options) {
|
|
3516
|
+
const ctx = this.#ctx;
|
|
3517
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/google/apps`, { body: { name: options.name } }));
|
|
3518
|
+
return new GoogleApp(ctx, data);
|
|
3519
|
+
}
|
|
3520
|
+
/** The mailboxs this session used: the agent's first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here. Experimental. */
|
|
3521
|
+
async apps() {
|
|
3522
|
+
const ctx = this.#ctx;
|
|
3523
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/google/apps`));
|
|
3524
|
+
return decodeGoogleApps(ctx, data);
|
|
3525
|
+
}
|
|
3526
|
+
/** Create a person: a mailbox, at `<name>@example.com` unless a test gives the address. Experimental. */
|
|
3527
|
+
async createUser(options) {
|
|
3528
|
+
const ctx = this.#ctx;
|
|
3529
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/google/users`, { body: { name: options.name, address: options.address, token: options.token ?? credential("CHANNELSTACK_GOOGLE_USER_{name}_TOKEN", { name: options.name }) } }));
|
|
3530
|
+
return new GoogleUser(ctx, data);
|
|
3531
|
+
}
|
|
3532
|
+
/** The people this session created. Experimental. */
|
|
3533
|
+
async users() {
|
|
3534
|
+
const ctx = this.#ctx;
|
|
3535
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/google/users`));
|
|
3536
|
+
return decodeGoogleUsers(ctx, data);
|
|
3537
|
+
}
|
|
3538
|
+
/** The threads this session's people started, oldest first. Experimental. */
|
|
3539
|
+
async threads() {
|
|
3540
|
+
const ctx = this.#ctx;
|
|
3541
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/google/threads`));
|
|
3542
|
+
return decodeGoogleThreads(ctx, data);
|
|
3543
|
+
}
|
|
3544
|
+
/** Every push channelstack sent the agent for this session, with every attempt. Experimental. */
|
|
3545
|
+
async deliveries(options = {}) {
|
|
3546
|
+
const ctx = this.#ctx;
|
|
3547
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/google/deliveries`, { query: { type: options.type, resource: options.resource === undefined ? undefined : options.resource.id, app: options.app === undefined ? undefined : options.app.id } }));
|
|
3548
|
+
return decodeGoogleDeliveries(ctx, data);
|
|
3549
|
+
}
|
|
3550
|
+
/** The Gmail calls the agent made about this session's mail, by the SDK's method name (`users.messages.send`). Experimental. */
|
|
3551
|
+
async calls(options = {}) {
|
|
3552
|
+
const ctx = this.#ctx;
|
|
3553
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/google/calls`, { query: { operation: options.operation, error: options.error } }));
|
|
3554
|
+
return data;
|
|
3555
|
+
}
|
|
3556
|
+
/** Wait for the next new API call from the agent, after the last one this handle saw. */
|
|
3557
|
+
async waitForCall(filter = {}, options = {}) {
|
|
3558
|
+
return waitForNext(this.#seen, `waitForCall:${JSON.stringify(filter)}`, () => this.calls(filter), () => true, "an API call from the agent", options);
|
|
2798
3559
|
}
|
|
2799
3560
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2800
3561
|
[QUIET]() {
|
|
2801
3562
|
return quietOf(this.#ctx);
|
|
2802
3563
|
}
|
|
3564
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3565
|
+
[CONTEXT]() {
|
|
3566
|
+
return this.#ctx;
|
|
3567
|
+
}
|
|
2803
3568
|
}
|
|
2804
|
-
export class
|
|
3569
|
+
export class GoogleApp {
|
|
2805
3570
|
id;
|
|
2806
3571
|
channel;
|
|
2807
3572
|
kind;
|
|
2808
3573
|
name;
|
|
3574
|
+
botUserId;
|
|
2809
3575
|
address;
|
|
3576
|
+
clientId;
|
|
3577
|
+
clientSecret;
|
|
3578
|
+
refreshToken;
|
|
2810
3579
|
#ctx;
|
|
2811
|
-
#seen = new Map();
|
|
2812
3580
|
/** @internal Handles come from the SDK, never from `new`. */
|
|
2813
3581
|
constructor(ctx, data) {
|
|
2814
3582
|
this.#ctx = ctx;
|
|
@@ -2816,34 +3584,32 @@ export class GoogleUser {
|
|
|
2816
3584
|
this.channel = data.channel;
|
|
2817
3585
|
this.kind = data.kind;
|
|
2818
3586
|
this.name = data.name;
|
|
3587
|
+
this.botUserId = data.botUserId;
|
|
2819
3588
|
this.address = data.address;
|
|
3589
|
+
this.clientId = data.clientId;
|
|
3590
|
+
this.clientSecret = data.clientSecret;
|
|
3591
|
+
this.refreshToken = data.refreshToken;
|
|
2820
3592
|
}
|
|
2821
|
-
/**
|
|
3593
|
+
/** An app a test made sends an email, through its own mailbox's API, as its own call would. Experimental. */
|
|
2822
3594
|
async send(options) {
|
|
2823
3595
|
const ctx = this.#ctx;
|
|
2824
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/google/
|
|
3596
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/google/apps/${segment(this.id)}/send`, { body: { to: options.to.map((item) => item.id), cc: options.cc === undefined ? undefined : options.cc.map((item) => item.id), subject: options.subject, text: options.text, html: options.html, headers: options.headers } }));
|
|
2825
3597
|
return new GoogleEmail(ctx, data);
|
|
2826
3598
|
}
|
|
2827
|
-
/**
|
|
3599
|
+
/** An app a test made replies to an email, in its thread, as its own call would. Experimental. */
|
|
2828
3600
|
async reply(email, options = {}) {
|
|
2829
3601
|
const ctx = this.#ctx;
|
|
2830
|
-
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/google/
|
|
3602
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/google/apps/${segment(this.id)}/reply`, { body: { email: email.id, text: options.text, html: options.html, all: options.all, headers: options.headers } }));
|
|
2831
3603
|
return new GoogleEmail(ctx, data);
|
|
2832
3604
|
}
|
|
2833
|
-
/** What reached the person's mailbox, oldest first. Experimental. */
|
|
2834
|
-
async inbox() {
|
|
2835
|
-
const ctx = this.#ctx;
|
|
2836
|
-
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/google/users/${segment(this.id)}/inbox`));
|
|
2837
|
-
return decodeGoogleInbox(ctx, data);
|
|
2838
|
-
}
|
|
2839
|
-
/** Wait for the next new email matching `from` (anyone if omitted), after the last one this handle saw. */
|
|
2840
|
-
async waitForEmail(options = {}) {
|
|
2841
|
-
return waitForNext(this.#seen, "waitForEmail", () => this.inbox(), (item) => fromMatches(item.author, options.from), describeWait("an email", options.from), options);
|
|
2842
|
-
}
|
|
2843
3605
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2844
3606
|
[QUIET]() {
|
|
2845
3607
|
return quietOf(this.#ctx);
|
|
2846
3608
|
}
|
|
3609
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3610
|
+
[CONTEXT]() {
|
|
3611
|
+
return this.#ctx;
|
|
3612
|
+
}
|
|
2847
3613
|
}
|
|
2848
3614
|
export class GoogleEmail {
|
|
2849
3615
|
id;
|
|
@@ -2857,6 +3623,7 @@ export class GoogleEmail {
|
|
|
2857
3623
|
text;
|
|
2858
3624
|
at;
|
|
2859
3625
|
messageId;
|
|
3626
|
+
headers;
|
|
2860
3627
|
labels;
|
|
2861
3628
|
delivery;
|
|
2862
3629
|
#ctx;
|
|
@@ -2874,6 +3641,7 @@ export class GoogleEmail {
|
|
|
2874
3641
|
this.text = data.text;
|
|
2875
3642
|
this.at = data.at;
|
|
2876
3643
|
this.messageId = data.messageId;
|
|
3644
|
+
this.headers = data.headers;
|
|
2877
3645
|
this.labels = data.labels;
|
|
2878
3646
|
this.delivery = data.delivery === undefined ? undefined : new GoogleDelivery(ctx, data.delivery);
|
|
2879
3647
|
}
|
|
@@ -2883,10 +3651,20 @@ export class GoogleEmail {
|
|
|
2883
3651
|
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/google/emails/${segment(this.id)}`));
|
|
2884
3652
|
return new GoogleEmail(ctx, data);
|
|
2885
3653
|
}
|
|
3654
|
+
/** The delivery that told this app of the email (decision 0027), or nothing when it wasn't told. Experimental. */
|
|
3655
|
+
async deliveryFor(app) {
|
|
3656
|
+
const ctx = this.#ctx;
|
|
3657
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/google/emails/${segment(this.id)}/delivery-for`, { query: { app: app.id } }));
|
|
3658
|
+
return (data === null ? undefined : new GoogleDelivery(ctx, data));
|
|
3659
|
+
}
|
|
2886
3660
|
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
2887
3661
|
[QUIET]() {
|
|
2888
3662
|
return quietOf(this.#ctx);
|
|
2889
3663
|
}
|
|
3664
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3665
|
+
[CONTEXT]() {
|
|
3666
|
+
return this.#ctx;
|
|
3667
|
+
}
|
|
2890
3668
|
}
|
|
2891
3669
|
export class GoogleThread {
|
|
2892
3670
|
id;
|
|
@@ -2931,10 +3709,15 @@ export class GoogleThread {
|
|
|
2931
3709
|
[QUIET]() {
|
|
2932
3710
|
return quietOf(this.#ctx);
|
|
2933
3711
|
}
|
|
3712
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3713
|
+
[CONTEXT]() {
|
|
3714
|
+
return this.#ctx;
|
|
3715
|
+
}
|
|
2934
3716
|
}
|
|
2935
3717
|
export class GoogleDelivery {
|
|
2936
3718
|
id;
|
|
2937
3719
|
channel;
|
|
3720
|
+
app;
|
|
2938
3721
|
type;
|
|
2939
3722
|
emailAddress;
|
|
2940
3723
|
historyId;
|
|
@@ -2947,6 +3730,7 @@ export class GoogleDelivery {
|
|
|
2947
3730
|
this.#ctx = ctx;
|
|
2948
3731
|
this.id = data.id;
|
|
2949
3732
|
this.channel = data.channel;
|
|
3733
|
+
this.app = data.app;
|
|
2950
3734
|
this.type = data.type;
|
|
2951
3735
|
this.emailAddress = data.emailAddress;
|
|
2952
3736
|
this.historyId = data.historyId;
|
|
@@ -2983,6 +3767,791 @@ export class GoogleDelivery {
|
|
|
2983
3767
|
[QUIET]() {
|
|
2984
3768
|
return quietOf(this.#ctx);
|
|
2985
3769
|
}
|
|
3770
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3771
|
+
[CONTEXT]() {
|
|
3772
|
+
return this.#ctx;
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3775
|
+
export class GoogleUser {
|
|
3776
|
+
id;
|
|
3777
|
+
channel;
|
|
3778
|
+
kind;
|
|
3779
|
+
name;
|
|
3780
|
+
address;
|
|
3781
|
+
#ctx;
|
|
3782
|
+
#seen = new Map();
|
|
3783
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
3784
|
+
constructor(ctx, data) {
|
|
3785
|
+
this.#ctx = ctx;
|
|
3786
|
+
this.id = data.id;
|
|
3787
|
+
this.channel = data.channel;
|
|
3788
|
+
this.kind = data.kind;
|
|
3789
|
+
this.name = data.name;
|
|
3790
|
+
this.address = data.address;
|
|
3791
|
+
}
|
|
3792
|
+
/** The person emails someone: the agent (`google.app`), another app, or another person. Experimental. */
|
|
3793
|
+
async send(options) {
|
|
3794
|
+
const ctx = this.#ctx;
|
|
3795
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/google/users/${segment(this.id)}/send`, { body: { to: options.to.map((item) => item.id), cc: options.cc === undefined ? undefined : options.cc.map((item) => item.id), subject: options.subject, text: options.text, html: options.html } }));
|
|
3796
|
+
return new GoogleEmail(ctx, data);
|
|
3797
|
+
}
|
|
3798
|
+
/** The person replies to an email, in its thread: `Re:` its subject, with `In-Reply-To` and `References`. Experimental. */
|
|
3799
|
+
async reply(email, options = {}) {
|
|
3800
|
+
const ctx = this.#ctx;
|
|
3801
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/google/users/${segment(this.id)}/reply`, { body: { email: email.id, text: options.text, html: options.html, all: options.all } }));
|
|
3802
|
+
return new GoogleEmail(ctx, data);
|
|
3803
|
+
}
|
|
3804
|
+
/** What reached the person's mailbox, oldest first. Experimental. */
|
|
3805
|
+
async inbox() {
|
|
3806
|
+
const ctx = this.#ctx;
|
|
3807
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/google/users/${segment(this.id)}/inbox`));
|
|
3808
|
+
return decodeGoogleInbox(ctx, data);
|
|
3809
|
+
}
|
|
3810
|
+
/** Wait for the next new email matching `from` (anyone if omitted), after the last one this handle saw. */
|
|
3811
|
+
async waitForEmail(options = {}) {
|
|
3812
|
+
return waitForNext(this.#seen, "waitForEmail", () => this.inbox(), (item) => fromMatches(item.author, options.from), describeWait("an email", options.from), options);
|
|
3813
|
+
}
|
|
3814
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
3815
|
+
[QUIET]() {
|
|
3816
|
+
return quietOf(this.#ctx);
|
|
3817
|
+
}
|
|
3818
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3819
|
+
[CONTEXT]() {
|
|
3820
|
+
return this.#ctx;
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
export class DiscordFixture {
|
|
3824
|
+
app;
|
|
3825
|
+
apiUrl;
|
|
3826
|
+
guild;
|
|
3827
|
+
gatewayConnections;
|
|
3828
|
+
#ctx;
|
|
3829
|
+
#seen = new Map();
|
|
3830
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
3831
|
+
constructor(ctx, data) {
|
|
3832
|
+
this.#ctx = ctx;
|
|
3833
|
+
this.app = new DiscordApp(ctx, data.app);
|
|
3834
|
+
this.apiUrl = data.apiUrl;
|
|
3835
|
+
this.guild = data.guild;
|
|
3836
|
+
this.gatewayConnections = data.gatewayConnections;
|
|
3837
|
+
}
|
|
3838
|
+
/** Create a person in the guild. Experimental. */
|
|
3839
|
+
async createUser(options) {
|
|
3840
|
+
const ctx = this.#ctx;
|
|
3841
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users`, { body: { name: options.name, id: options.id, admin: options.admin, bot: options.bot, token: options.token ?? credential("CHANNELSTACK_DISCORD_USER_{name}_TOKEN", { name: options.name }) } }));
|
|
3842
|
+
return new DiscordUser(ctx, data);
|
|
3843
|
+
}
|
|
3844
|
+
/** The people this session created. Experimental. */
|
|
3845
|
+
async users() {
|
|
3846
|
+
const ctx = this.#ctx;
|
|
3847
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/users`));
|
|
3848
|
+
return decodeDiscordUsers(ctx, data);
|
|
3849
|
+
}
|
|
3850
|
+
/** Make another app in the guild, with its own application, bot user, token and Ed25519 key (decision 0027), or return the one made with this name and settings. Its bot connects to the Gateway with its own token; its interactions go to CHANNELSTACK_DISCORD_APP_<NAME>_WEBHOOK_URL, or over its Gateway connection. Experimental. */
|
|
3851
|
+
async createApp(options) {
|
|
3852
|
+
const ctx = this.#ctx;
|
|
3853
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/apps`, { body: { name: options.name, privilegedIntents: options.privilegedIntents } }));
|
|
3854
|
+
return new DiscordApp(ctx, data);
|
|
3855
|
+
}
|
|
3856
|
+
/** The apps this session used: the built-in one first, then each it got from `createApp`, in the order it first did. Another session's are `not_found` here. Experimental. */
|
|
3857
|
+
async apps() {
|
|
3858
|
+
const ctx = this.#ctx;
|
|
3859
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/apps`));
|
|
3860
|
+
return decodeDiscordApps(ctx, data);
|
|
3861
|
+
}
|
|
3862
|
+
/** Create a text channel. Only the listed participants see it (a private channel); include the app for the bot to hear it. Experimental. */
|
|
3863
|
+
async createChannel(options = {}) {
|
|
3864
|
+
const ctx = this.#ctx;
|
|
3865
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/channels`, { body: { name: options.name, participants: options.participants === undefined ? undefined : options.participants.map((item) => item.id), readOnly: options.readOnly, topic: options.topic } }));
|
|
3866
|
+
return new DiscordChannel(ctx, data);
|
|
3867
|
+
}
|
|
3868
|
+
/** The session's channels, threads and DMs. Experimental. */
|
|
3869
|
+
async channels() {
|
|
3870
|
+
const ctx = this.#ctx;
|
|
3871
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels`));
|
|
3872
|
+
return decodeDiscordChannels(ctx, data);
|
|
3873
|
+
}
|
|
3874
|
+
/** Discord's check of the app's interactions endpoint, as when it is saved in the developer portal: a PING it must answer with a PONG, and one with a bad signature it must refuse with 401. Experimental. */
|
|
3875
|
+
async verifyEndpoint() {
|
|
3876
|
+
const ctx = this.#ctx;
|
|
3877
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/verify-endpoint`));
|
|
3878
|
+
return data;
|
|
3879
|
+
}
|
|
3880
|
+
/** Every Gateway dispatch and interaction channelstack sent the bot for this session, with every attempt. Experimental. */
|
|
3881
|
+
async deliveries(options = {}) {
|
|
3882
|
+
const ctx = this.#ctx;
|
|
3883
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/deliveries`, { query: { type: options.type, resource: options.resource === undefined ? undefined : options.resource.id, app: options.app === undefined ? undefined : options.app.id } }));
|
|
3884
|
+
return decodeDiscordDeliveries(ctx, data);
|
|
3885
|
+
}
|
|
3886
|
+
/** The REST calls the bot made about this session's channels, messages and interactions, by route (`POST /channels/{channel.id}/messages`). Calls about nothing a session owns (`GET /gateway/bot`) are in no session. Experimental. */
|
|
3887
|
+
async calls(options = {}) {
|
|
3888
|
+
const ctx = this.#ctx;
|
|
3889
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/calls`, { query: { operation: options.operation, error: options.error } }));
|
|
3890
|
+
return data;
|
|
3891
|
+
}
|
|
3892
|
+
/** Inject a fault: rate-limit the bot's calls of a route (removed when this session closes), or drop its Gateway connection just before the next dispatch. Experimental. */
|
|
3893
|
+
async fault(options) {
|
|
3894
|
+
const ctx = this.#ctx;
|
|
3895
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/faults`, { body: { type: options.type, route: options.route, retryAfter: options.retryAfter === undefined ? undefined : parseDuration(options.retryAfter), times: options.times, app: options.app === undefined ? undefined : options.app.id } }));
|
|
3896
|
+
return new DiscordFault(ctx, data);
|
|
3897
|
+
}
|
|
3898
|
+
/** Wait for the next new API call from the agent, after the last one this handle saw. */
|
|
3899
|
+
async waitForCall(filter = {}, options = {}) {
|
|
3900
|
+
return waitForNext(this.#seen, `waitForCall:${JSON.stringify(filter)}`, () => this.calls(filter), () => true, "an API call from the agent", options);
|
|
3901
|
+
}
|
|
3902
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
3903
|
+
[QUIET]() {
|
|
3904
|
+
return quietOf(this.#ctx);
|
|
3905
|
+
}
|
|
3906
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3907
|
+
[CONTEXT]() {
|
|
3908
|
+
return this.#ctx;
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
export class DiscordApp {
|
|
3912
|
+
id;
|
|
3913
|
+
name;
|
|
3914
|
+
kind;
|
|
3915
|
+
channel;
|
|
3916
|
+
botUserId;
|
|
3917
|
+
botToken;
|
|
3918
|
+
publicKey;
|
|
3919
|
+
guildId;
|
|
3920
|
+
#ctx;
|
|
3921
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
3922
|
+
constructor(ctx, data) {
|
|
3923
|
+
this.#ctx = ctx;
|
|
3924
|
+
this.id = data.id;
|
|
3925
|
+
this.name = data.name;
|
|
3926
|
+
this.kind = data.kind;
|
|
3927
|
+
this.channel = data.channel;
|
|
3928
|
+
this.botUserId = data.botUserId;
|
|
3929
|
+
this.botToken = data.botToken;
|
|
3930
|
+
this.publicKey = data.publicKey;
|
|
3931
|
+
this.guildId = data.guildId;
|
|
3932
|
+
}
|
|
3933
|
+
/** An app a test made writes, as its own `POST /channels/{id}/messages` would: in a channel or thread its bot sees, or in a DM with the person in `to`. No bot writes to another bot in a DM (50007). Experimental. */
|
|
3934
|
+
async say(text, options = {}) {
|
|
3935
|
+
const ctx = this.#ctx;
|
|
3936
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/apps/${segment(this.id)}/say`, { body: { text: typeof text === "string" ? { content: text } : (typeof text === "string" ? { content: text } : text), channel: options.channel === undefined ? undefined : options.channel.id, to: options.to === undefined ? undefined : [options.to].flat().map((item) => item.id) } }));
|
|
3937
|
+
return new DiscordMessage(ctx, data);
|
|
3938
|
+
}
|
|
3939
|
+
/** An app a test made replies to a message: Discord's reply, in the message's channel, which quotes it. Experimental. */
|
|
3940
|
+
async reply(text, options) {
|
|
3941
|
+
const ctx = this.#ctx;
|
|
3942
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/apps/${segment(this.id)}/reply`, { body: { text: typeof text === "string" ? { content: text } : (typeof text === "string" ? { content: text } : text), message: { channelId: options.message.channelId, id: options.message.id } } }));
|
|
3943
|
+
return new DiscordMessage(ctx, data);
|
|
3944
|
+
}
|
|
3945
|
+
/** An app a test made reacts to a message. Experimental. */
|
|
3946
|
+
async react(emoji, options) {
|
|
3947
|
+
const ctx = this.#ctx;
|
|
3948
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/apps/${segment(this.id)}/react`, { body: { emoji, message: { channelId: options.message.channelId, id: options.message.id } } }));
|
|
3949
|
+
return (data === null ? undefined : new DiscordDelivery(ctx, data));
|
|
3950
|
+
}
|
|
3951
|
+
/** An app a test made takes its reaction back. Experimental. */
|
|
3952
|
+
async unreact(emoji, options) {
|
|
3953
|
+
const ctx = this.#ctx;
|
|
3954
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/apps/${segment(this.id)}/unreact`, { body: { emoji, message: { channelId: options.message.channelId, id: options.message.id } } }));
|
|
3955
|
+
return (data === null ? undefined : new DiscordDelivery(ctx, data));
|
|
3956
|
+
}
|
|
3957
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
3958
|
+
[QUIET]() {
|
|
3959
|
+
return quietOf(this.#ctx);
|
|
3960
|
+
}
|
|
3961
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
3962
|
+
[CONTEXT]() {
|
|
3963
|
+
return this.#ctx;
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
3966
|
+
export class DiscordUser {
|
|
3967
|
+
id;
|
|
3968
|
+
name;
|
|
3969
|
+
kind;
|
|
3970
|
+
channel;
|
|
3971
|
+
username;
|
|
3972
|
+
isAdmin;
|
|
3973
|
+
isBot;
|
|
3974
|
+
#ctx;
|
|
3975
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
3976
|
+
constructor(ctx, data) {
|
|
3977
|
+
this.#ctx = ctx;
|
|
3978
|
+
this.id = data.id;
|
|
3979
|
+
this.name = data.name;
|
|
3980
|
+
this.kind = data.kind;
|
|
3981
|
+
this.channel = data.channel;
|
|
3982
|
+
this.username = data.username;
|
|
3983
|
+
this.isAdmin = data.isAdmin;
|
|
3984
|
+
this.isBot = data.isBot;
|
|
3985
|
+
}
|
|
3986
|
+
/** Write a message in a channel or thread, or in a DM with the person or app in `to`. Experimental. */
|
|
3987
|
+
async say(text, options = {}) {
|
|
3988
|
+
const ctx = this.#ctx;
|
|
3989
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/say`, { body: { text: typeof text === "string" ? { content: text } : (typeof text === "string" ? { content: text } : text), channel: options.channel === undefined ? undefined : options.channel.id, to: options.to === undefined ? undefined : [options.to].flat().map((item) => item.id) } }));
|
|
3990
|
+
return new DiscordMessage(ctx, data);
|
|
3991
|
+
}
|
|
3992
|
+
/** Reply to a message: Discord's reply, in the message's channel, which quotes it. Experimental. */
|
|
3993
|
+
async reply(text, options) {
|
|
3994
|
+
const ctx = this.#ctx;
|
|
3995
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/reply`, { body: { text: typeof text === "string" ? { content: text } : (typeof text === "string" ? { content: text } : text), message: { channelId: options.message.channelId, id: options.message.id } } }));
|
|
3996
|
+
return new DiscordMessage(ctx, data);
|
|
3997
|
+
}
|
|
3998
|
+
/** Edit one of this person's own messages. Experimental. */
|
|
3999
|
+
async edit(text, options) {
|
|
4000
|
+
const ctx = this.#ctx;
|
|
4001
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/edit`, { body: { text: typeof text === "string" ? { content: text } : (typeof text === "string" ? { content: text } : text), message: { channelId: options.message.channelId, id: options.message.id } } }));
|
|
4002
|
+
return new DiscordMessage(ctx, data);
|
|
4003
|
+
}
|
|
4004
|
+
/** Delete a message: this person's own, or anyone's for an admin. Experimental. */
|
|
4005
|
+
async delete(options) {
|
|
4006
|
+
const ctx = this.#ctx;
|
|
4007
|
+
await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/delete`, { body: { message: { channelId: options.message.channelId, id: options.message.id } } });
|
|
4008
|
+
}
|
|
4009
|
+
/** React to a message with an emoji. Experimental. */
|
|
4010
|
+
async react(emoji, options) {
|
|
4011
|
+
const ctx = this.#ctx;
|
|
4012
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/react`, { body: { emoji, message: { channelId: options.message.channelId, id: options.message.id } } }));
|
|
4013
|
+
return (data === null ? undefined : new DiscordDelivery(ctx, data));
|
|
4014
|
+
}
|
|
4015
|
+
/** Take this person's reaction off a message. Experimental. */
|
|
4016
|
+
async unreact(emoji, options) {
|
|
4017
|
+
const ctx = this.#ctx;
|
|
4018
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/unreact`, { body: { emoji, message: { channelId: options.message.channelId, id: options.message.id } } }));
|
|
4019
|
+
return (data === null ? undefined : new DiscordDelivery(ctx, data));
|
|
4020
|
+
}
|
|
4021
|
+
/** Start a thread: from a message, or in a channel. Experimental. */
|
|
4022
|
+
async startThread(name, options = {}) {
|
|
4023
|
+
const ctx = this.#ctx;
|
|
4024
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/threads`, { body: { name, message: options.message === undefined ? undefined : { channelId: options.message.channelId, id: options.message.id }, channel: options.channel === undefined ? undefined : options.channel.id } }));
|
|
4025
|
+
return new DiscordChannel(ctx, data);
|
|
4026
|
+
}
|
|
4027
|
+
/** Open (or reuse) a DM with the app or another person. Experimental. */
|
|
4028
|
+
async openDM(participant) {
|
|
4029
|
+
const ctx = this.#ctx;
|
|
4030
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/open-dm`, { body: { participant: participant.id } }));
|
|
4031
|
+
return new DiscordChannel(ctx, data);
|
|
4032
|
+
}
|
|
4033
|
+
/** Let people or the app see a channel. The person must be an admin. Experimental. */
|
|
4034
|
+
async invite(participants, options) {
|
|
4035
|
+
const ctx = this.#ctx;
|
|
4036
|
+
await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/invite`, { body: { participants: [participants].flat().map((item) => item.id), channel: options.channel.id } });
|
|
4037
|
+
}
|
|
4038
|
+
/** Run one of an app's slash commands in a channel, e.g. `/deploy web staging` or `/deploy service:web`: the built-in app's, or `app`'s, as a person picks one app's command when several have it. Experimental. */
|
|
4039
|
+
async runCommand(command, options) {
|
|
4040
|
+
const ctx = this.#ctx;
|
|
4041
|
+
const data = (await retryWhile(["not_found"], () => ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/commands`, { body: { command, channel: options.channel.id, app: options.app === undefined ? undefined : options.app.id } })));
|
|
4042
|
+
return (data === null ? undefined : new DiscordDelivery(ctx, data));
|
|
4043
|
+
}
|
|
4044
|
+
/** Press a button, found by its label or custom_id: on a message, or on the app's newest message in a channel or thread that has it. Experimental. */
|
|
4045
|
+
async click(button, options = {}) {
|
|
4046
|
+
const ctx = this.#ctx;
|
|
4047
|
+
const data = (await retryWhile(["not_found"], () => ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/click`, { body: { button: typeof button === "string" ? { label: button } : (typeof button === "string" ? { label: button } : button), message: options.message === undefined ? undefined : { channelId: options.message.channelId, id: options.message.id }, channel: options.channel === undefined ? undefined : options.channel.id } })));
|
|
4048
|
+
return (data === null ? undefined : new DiscordDelivery(ctx, data));
|
|
4049
|
+
}
|
|
4050
|
+
/** Messages only this person sees: the app's ephemeral responses, and "This interaction failed". Experimental. */
|
|
4051
|
+
async ephemeral() {
|
|
4052
|
+
const ctx = this.#ctx;
|
|
4053
|
+
await untilQuiet(() => quietOf(ctx));
|
|
4054
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/users/${segment(this.id)}/ephemeral`));
|
|
4055
|
+
return decodeDiscordEphemeralMessages(ctx, data);
|
|
4056
|
+
}
|
|
4057
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
4058
|
+
[QUIET]() {
|
|
4059
|
+
return quietOf(this.#ctx);
|
|
4060
|
+
}
|
|
4061
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
4062
|
+
[CONTEXT]() {
|
|
4063
|
+
return this.#ctx;
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
export class DiscordMessage {
|
|
4067
|
+
id;
|
|
4068
|
+
channelId;
|
|
4069
|
+
channel;
|
|
4070
|
+
author;
|
|
4071
|
+
text;
|
|
4072
|
+
content;
|
|
4073
|
+
embeds;
|
|
4074
|
+
components;
|
|
4075
|
+
postedAt;
|
|
4076
|
+
edited;
|
|
4077
|
+
replyTo;
|
|
4078
|
+
thread;
|
|
4079
|
+
visibleTo;
|
|
4080
|
+
delivery;
|
|
4081
|
+
#ctx;
|
|
4082
|
+
#seen = new Map();
|
|
4083
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
4084
|
+
constructor(ctx, data) {
|
|
4085
|
+
this.#ctx = ctx;
|
|
4086
|
+
this.id = data.id;
|
|
4087
|
+
this.channelId = data.channelId;
|
|
4088
|
+
this.channel = new DiscordChannel(ctx, data.channel);
|
|
4089
|
+
this.author = data.author.kind === "user" ? new DiscordUser(ctx, data.author) : new DiscordApp(ctx, data.author);
|
|
4090
|
+
this.text = data.text;
|
|
4091
|
+
this.content = data.content;
|
|
4092
|
+
this.embeds = data.embeds;
|
|
4093
|
+
this.components = data.components;
|
|
4094
|
+
this.postedAt = data.postedAt;
|
|
4095
|
+
this.edited = data.edited;
|
|
4096
|
+
this.replyTo = data.replyTo;
|
|
4097
|
+
this.thread = data.thread === undefined ? undefined : new DiscordChannel(ctx, data.thread);
|
|
4098
|
+
this.visibleTo = data.visibleTo === undefined ? undefined : new DiscordUser(ctx, data.visibleTo);
|
|
4099
|
+
this.delivery = data.delivery === undefined ? undefined : new DiscordDelivery(ctx, data.delivery);
|
|
4100
|
+
}
|
|
4101
|
+
/** Re-read a message: its latest text, edits and thread. Experimental. */
|
|
4102
|
+
async refresh() {
|
|
4103
|
+
const ctx = this.#ctx;
|
|
4104
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels/${segment(this.channelId)}/messages/${segment(this.id)}`));
|
|
4105
|
+
return new DiscordMessage(ctx, data);
|
|
4106
|
+
}
|
|
4107
|
+
/** What answers a message, oldest first: Discord's replies to it, and the messages of the thread started from it. Experimental. */
|
|
4108
|
+
async replies() {
|
|
4109
|
+
const ctx = this.#ctx;
|
|
4110
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels/${segment(this.channelId)}/messages/${segment(this.id)}/replies`));
|
|
4111
|
+
return decodeDiscordReplies(ctx, data);
|
|
4112
|
+
}
|
|
4113
|
+
/** A message and what answers it, as a person reads them. Experimental. */
|
|
4114
|
+
async transcript(options = {}) {
|
|
4115
|
+
const ctx = this.#ctx;
|
|
4116
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels/${segment(this.channelId)}/messages/${segment(this.id)}/transcript`, { query: { as: options.as === undefined ? undefined : options.as.id } }));
|
|
4117
|
+
return decodeDiscordTranscript(ctx, data);
|
|
4118
|
+
}
|
|
4119
|
+
/** The reactions on a message, and who added each. Experimental. */
|
|
4120
|
+
async reactions() {
|
|
4121
|
+
const ctx = this.#ctx;
|
|
4122
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels/${segment(this.channelId)}/messages/${segment(this.id)}/reactions`));
|
|
4123
|
+
return decodeDiscordReactions(ctx, data);
|
|
4124
|
+
}
|
|
4125
|
+
/** The first Gateway dispatch this message caused to this app's bot (decision 0027), or nothing when it wasn't told. Experimental. */
|
|
4126
|
+
async deliveryFor(app) {
|
|
4127
|
+
const ctx = this.#ctx;
|
|
4128
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels/${segment(this.channelId)}/messages/${segment(this.id)}/delivery-for`, { query: { app: app.id } }));
|
|
4129
|
+
return (data === null ? undefined : new DiscordDelivery(ctx, data));
|
|
4130
|
+
}
|
|
4131
|
+
/** Every Gateway dispatch this message caused to the apps' bots. Experimental. */
|
|
4132
|
+
async deliveries() {
|
|
4133
|
+
const ctx = this.#ctx;
|
|
4134
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels/${segment(this.channelId)}/messages/${segment(this.id)}/deliveries`));
|
|
4135
|
+
return decodeDiscordMessageDeliveries(ctx, data);
|
|
4136
|
+
}
|
|
4137
|
+
/** Wait for the next new reply matching `from` (anyone if omitted), after the last one this handle saw. */
|
|
4138
|
+
async waitForReply(options = {}) {
|
|
4139
|
+
return waitForNext(this.#seen, "waitForReply", () => this.replies(), (item) => fromMatches(item.author, options.from), describeWait("a reply", options.from), options);
|
|
4140
|
+
}
|
|
4141
|
+
/** The latest reply matching `from`, once the agent is quiet. Waits for at least one. */
|
|
4142
|
+
async latestReply(options = {}) {
|
|
4143
|
+
return latestOnceQuiet(() => this.replies(), (item) => fromMatches(item.author, options.from), () => quietOf(this.#ctx), describeWait("a reply", options.from), options);
|
|
4144
|
+
}
|
|
4145
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
4146
|
+
[QUIET]() {
|
|
4147
|
+
return quietOf(this.#ctx);
|
|
4148
|
+
}
|
|
4149
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
4150
|
+
[CONTEXT]() {
|
|
4151
|
+
return this.#ctx;
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
export class DiscordChannel {
|
|
4155
|
+
id;
|
|
4156
|
+
kind;
|
|
4157
|
+
channel;
|
|
4158
|
+
name;
|
|
4159
|
+
parentId;
|
|
4160
|
+
starterId;
|
|
4161
|
+
#ctx;
|
|
4162
|
+
#seen = new Map();
|
|
4163
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
4164
|
+
constructor(ctx, data) {
|
|
4165
|
+
this.#ctx = ctx;
|
|
4166
|
+
this.id = data.id;
|
|
4167
|
+
this.kind = data.kind;
|
|
4168
|
+
this.channel = data.channel;
|
|
4169
|
+
this.name = data.name;
|
|
4170
|
+
this.parentId = data.parentId;
|
|
4171
|
+
this.starterId = data.starterId;
|
|
4172
|
+
}
|
|
4173
|
+
/** A channel's or thread's messages, oldest first. Experimental. */
|
|
4174
|
+
async messages() {
|
|
4175
|
+
const ctx = this.#ctx;
|
|
4176
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels/${segment(this.id)}/messages`));
|
|
4177
|
+
return decodeDiscordMessages(ctx, data);
|
|
4178
|
+
}
|
|
4179
|
+
/** Who sees a channel: a text channel's participants, a DM's two ends; a thread's are its channel's. Admins see every channel without being listed. Experimental. */
|
|
4180
|
+
async members() {
|
|
4181
|
+
const ctx = this.#ctx;
|
|
4182
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels/${segment(this.id)}/members`));
|
|
4183
|
+
return decodeDiscordMembers(ctx, data);
|
|
4184
|
+
}
|
|
4185
|
+
/** The threads in a channel. Experimental. */
|
|
4186
|
+
async threads() {
|
|
4187
|
+
const ctx = this.#ctx;
|
|
4188
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels/${segment(this.id)}/threads`));
|
|
4189
|
+
return decodeDiscordThreads(ctx, data);
|
|
4190
|
+
}
|
|
4191
|
+
/** A channel or thread as a person reads it, each thread under the message that starts it. Experimental. */
|
|
4192
|
+
async transcript(options = {}) {
|
|
4193
|
+
const ctx = this.#ctx;
|
|
4194
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/channels/${segment(this.id)}/transcript`, { query: { as: options.as === undefined ? undefined : options.as.id } }));
|
|
4195
|
+
return decodeDiscordTranscript(ctx, data);
|
|
4196
|
+
}
|
|
4197
|
+
/** Wait for the next new message matching `from` (anyone if omitted), after the last one this handle saw. */
|
|
4198
|
+
async waitForMessage(options = {}) {
|
|
4199
|
+
return waitForNext(this.#seen, "waitForMessage", () => this.messages(), (item) => fromMatches(item.author, options.from), describeWait("a message", options.from), options);
|
|
4200
|
+
}
|
|
4201
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
4202
|
+
[QUIET]() {
|
|
4203
|
+
return quietOf(this.#ctx);
|
|
4204
|
+
}
|
|
4205
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
4206
|
+
[CONTEXT]() {
|
|
4207
|
+
return this.#ctx;
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4210
|
+
export class DiscordDelivery {
|
|
4211
|
+
id;
|
|
4212
|
+
channel;
|
|
4213
|
+
app;
|
|
4214
|
+
type;
|
|
4215
|
+
payload;
|
|
4216
|
+
attempts;
|
|
4217
|
+
status;
|
|
4218
|
+
#ctx;
|
|
4219
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
4220
|
+
constructor(ctx, data) {
|
|
4221
|
+
this.#ctx = ctx;
|
|
4222
|
+
this.id = data.id;
|
|
4223
|
+
this.channel = data.channel;
|
|
4224
|
+
this.app = data.app;
|
|
4225
|
+
this.type = data.type;
|
|
4226
|
+
this.payload = data.payload;
|
|
4227
|
+
this.attempts = data.attempts;
|
|
4228
|
+
this.status = data.status;
|
|
4229
|
+
}
|
|
4230
|
+
/** Re-read a delivery: its attempts and status. Experimental. */
|
|
4231
|
+
async refresh() {
|
|
4232
|
+
const ctx = this.#ctx;
|
|
4233
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/discord/deliveries/${segment(this.id)}`));
|
|
4234
|
+
return new DiscordDelivery(ctx, data);
|
|
4235
|
+
}
|
|
4236
|
+
/** Dispatch the same event to the bot again, as a replay after a RESUME would. Experimental. */
|
|
4237
|
+
async redeliver() {
|
|
4238
|
+
const ctx = this.#ctx;
|
|
4239
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/deliveries/${segment(this.id)}/redeliver`));
|
|
4240
|
+
return data;
|
|
4241
|
+
}
|
|
4242
|
+
/** Send an interaction again, forged: signed with a key that isn't the app's, which its endpoint must refuse with 401. Experimental. */
|
|
4243
|
+
async resend(options = {}) {
|
|
4244
|
+
const ctx = this.#ctx;
|
|
4245
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/discord/deliveries/${segment(this.id)}/resend`, { body: { badSignature: options.badSignature } }));
|
|
4246
|
+
return data;
|
|
4247
|
+
}
|
|
4248
|
+
/** Wait for the delivery to settle, and resolve with the value as it is then. */
|
|
4249
|
+
async settled(options = {}) {
|
|
4250
|
+
return waitFor("the delivery to settle", async () => {
|
|
4251
|
+
const value = await this.refresh();
|
|
4252
|
+
return value.status === "pending" ? undefined : value;
|
|
4253
|
+
}, options);
|
|
4254
|
+
}
|
|
4255
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
4256
|
+
[QUIET]() {
|
|
4257
|
+
return quietOf(this.#ctx);
|
|
4258
|
+
}
|
|
4259
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
4260
|
+
[CONTEXT]() {
|
|
4261
|
+
return this.#ctx;
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
export class DiscordFault {
|
|
4265
|
+
id;
|
|
4266
|
+
#ctx;
|
|
4267
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
4268
|
+
constructor(ctx, data) {
|
|
4269
|
+
this.#ctx = ctx;
|
|
4270
|
+
this.id = data.id;
|
|
4271
|
+
}
|
|
4272
|
+
/** Remove a fault. Experimental. */
|
|
4273
|
+
async undo() {
|
|
4274
|
+
const ctx = this.#ctx;
|
|
4275
|
+
await ctx.transport.request("DELETE", `/sessions/${segment(sessionOf(ctx))}/discord/faults/${segment(this.id)}`);
|
|
4276
|
+
}
|
|
4277
|
+
async [Symbol.asyncDispose]() {
|
|
4278
|
+
await disposeQuietly(() => this.undo());
|
|
4279
|
+
}
|
|
4280
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
4281
|
+
[QUIET]() {
|
|
4282
|
+
return quietOf(this.#ctx);
|
|
4283
|
+
}
|
|
4284
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
4285
|
+
[CONTEXT]() {
|
|
4286
|
+
return this.#ctx;
|
|
4287
|
+
}
|
|
4288
|
+
}
|
|
4289
|
+
export class OpenAIFixture {
|
|
4290
|
+
baseUrl;
|
|
4291
|
+
#ctx;
|
|
4292
|
+
#seen = new Map();
|
|
4293
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
4294
|
+
constructor(ctx, data) {
|
|
4295
|
+
this.#ctx = ctx;
|
|
4296
|
+
this.baseUrl = data.baseUrl;
|
|
4297
|
+
}
|
|
4298
|
+
/** Script what the model answers: turns used in order, one per matching call, or a responder the test answers. Scripts are tried in the order they were added. Experimental. */
|
|
4299
|
+
async respond(turns, options = {}) {
|
|
4300
|
+
const ctx = this.#ctx;
|
|
4301
|
+
const answer = typeof turns === "function" ? turns : undefined;
|
|
4302
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/openai/scripts`, { body: { turns: (answer === undefined ? turns : undefined) === undefined ? undefined : [(answer === undefined ? turns : undefined)].flat().map((item) => (typeof item === "object" && item !== null && !Array.isArray(item) ? { ...item, toolCalls: item.toolCalls === undefined ? undefined : item.toolCalls.map((item) => ({ ...item, codeInterpreter: item.codeInterpreter === undefined ? undefined : { ...item.codeInterpreter, files: item.codeInterpreter.files === undefined ? undefined : item.codeInterpreter.files.map((item) => readMedia(item)) }, imageGeneration: item.imageGeneration === undefined ? undefined : { ...item.imageGeneration, image: readMedia(item.imageGeneration.image) } })), image: item.image === undefined ? undefined : [item.image].flat().map((item) => readMedia(item)), audio: item.audio === undefined ? undefined : readMedia(item.audio) } : item)), when: options.when === undefined ? undefined : { ...options.when, text: options.when.text === undefined ? undefined : patternOnWire(options.when.text), prompt: options.when.prompt === undefined ? undefined : patternOnWire(options.when.prompt), model: options.when.model === undefined ? undefined : patternOnWire(options.when.model), from: options.when.from === undefined ? undefined : options.when.from.id, in: options.when.in === undefined ? undefined : options.when.in.id }, times: options.times, timing: options.timing, responder: answer !== undefined } }));
|
|
4303
|
+
const handle = new OpenAIScript(ctx, data);
|
|
4304
|
+
if (answer !== undefined)
|
|
4305
|
+
respondWith({ held: (o) => handle.heldCalls(o), answer: (id, o) => handle.answerHeld(id, o) }, answer);
|
|
4306
|
+
return handle;
|
|
4307
|
+
}
|
|
4308
|
+
/** Every model call attributed to this session, oldest first. Experimental. */
|
|
4309
|
+
async calls(options = {}) {
|
|
4310
|
+
const ctx = this.#ctx;
|
|
4311
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/calls`, { query: { endpoint: options.endpoint, error: options.error } }));
|
|
4312
|
+
return decodeOpenAISessionCalls(ctx, data);
|
|
4313
|
+
}
|
|
4314
|
+
/** Every tool call the model made in this session, each with the result the agent sent back. Experimental. */
|
|
4315
|
+
async toolCalls(options = {}) {
|
|
4316
|
+
const ctx = this.#ctx;
|
|
4317
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/tool-calls`, { query: { name: options.name } }));
|
|
4318
|
+
return data;
|
|
4319
|
+
}
|
|
4320
|
+
/** What went wrong with the model in this session: a call no script answered, a script that ran out or did what the real API can't, a responder that threw. Matchers fail at once on these. Experimental. */
|
|
4321
|
+
async problems() {
|
|
4322
|
+
const ctx = this.#ctx;
|
|
4323
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/problems`));
|
|
4324
|
+
return data;
|
|
4325
|
+
}
|
|
4326
|
+
/** The calls that sent a secret channelstack knows to the model, and the kinds they sent (`slack.botToken`): never the values. Experimental. */
|
|
4327
|
+
async sentSecrets() {
|
|
4328
|
+
const ctx = this.#ctx;
|
|
4329
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/sent-secrets`));
|
|
4330
|
+
return data;
|
|
4331
|
+
}
|
|
4332
|
+
/** Model calls no session could be given (the agent calling the model at startup, for example), oldest first: what a failing matcher names. Experimental. */
|
|
4333
|
+
async unattributed(options = {}) {
|
|
4334
|
+
const ctx = this.#ctx;
|
|
4335
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/unattributed`, { query: { withinMs: options.withinMs } }));
|
|
4336
|
+
return data;
|
|
4337
|
+
}
|
|
4338
|
+
/** Limit this session's model calls: requests and tokens per window, with truthful x-ratelimit-* headers. Experimental. */
|
|
4339
|
+
async rateLimit(options = {}) {
|
|
4340
|
+
const ctx = this.#ctx;
|
|
4341
|
+
const data = (await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/openai/rate-limits`, { body: { requests: options.requests === undefined ? undefined : { ...options.requests, per: options.requests.per === undefined ? undefined : parseDuration(options.requests.per) }, tokens: options.tokens === undefined ? undefined : { ...options.tokens, per: options.tokens.per === undefined ? undefined : parseDuration(options.tokens.per) }, error: options.error } }));
|
|
4342
|
+
return new OpenAIRateLimit(ctx, data);
|
|
4343
|
+
}
|
|
4344
|
+
/** Wait for the next new model call from the agent, after the last one this handle saw. */
|
|
4345
|
+
async waitForCall(filter = {}, options = {}) {
|
|
4346
|
+
return waitForNext(this.#seen, `waitForCall:${JSON.stringify(filter)}`, () => this.calls(filter), () => true, "a model call from the agent", options);
|
|
4347
|
+
}
|
|
4348
|
+
/** The latest model call from the agent, once the agent is quiet. Waits for at least one. */
|
|
4349
|
+
async latestCall(filter = {}, options = {}) {
|
|
4350
|
+
return latestOnceQuiet(() => this.calls(filter), () => true, () => quietOf(this.#ctx), "a model call from the agent", options);
|
|
4351
|
+
}
|
|
4352
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
4353
|
+
[QUIET]() {
|
|
4354
|
+
return quietOf(this.#ctx);
|
|
4355
|
+
}
|
|
4356
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
4357
|
+
[CONTEXT]() {
|
|
4358
|
+
return this.#ctx;
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
export class OpenAIScript {
|
|
4362
|
+
id;
|
|
4363
|
+
responder;
|
|
4364
|
+
times;
|
|
4365
|
+
used;
|
|
4366
|
+
problems;
|
|
4367
|
+
#ctx;
|
|
4368
|
+
#seen = new Map();
|
|
4369
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
4370
|
+
constructor(ctx, data) {
|
|
4371
|
+
this.#ctx = ctx;
|
|
4372
|
+
this.id = data.id;
|
|
4373
|
+
this.responder = data.responder;
|
|
4374
|
+
this.times = data.times;
|
|
4375
|
+
this.used = data.used;
|
|
4376
|
+
this.problems = data.problems;
|
|
4377
|
+
}
|
|
4378
|
+
/** Re-read a script: how many calls it answered, and its problems. Experimental. */
|
|
4379
|
+
async refresh() {
|
|
4380
|
+
const ctx = this.#ctx;
|
|
4381
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/scripts/${segment(this.id)}`));
|
|
4382
|
+
return new OpenAIScript(ctx, data);
|
|
4383
|
+
}
|
|
4384
|
+
/** Remove a script. Closing the session does it too. Experimental. */
|
|
4385
|
+
async undo() {
|
|
4386
|
+
const ctx = this.#ctx;
|
|
4387
|
+
await ctx.transport.request("DELETE", `/sessions/${segment(sessionOf(ctx))}/openai/scripts/${segment(this.id)}`);
|
|
4388
|
+
}
|
|
4389
|
+
async [Symbol.asyncDispose]() {
|
|
4390
|
+
await disposeQuietly(() => this.undo());
|
|
4391
|
+
}
|
|
4392
|
+
/** Let the streams this script holds at `pauseAfter` go on. Experimental. */
|
|
4393
|
+
async resume() {
|
|
4394
|
+
const ctx = this.#ctx;
|
|
4395
|
+
await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/openai/scripts/${segment(this.id)}/resume`);
|
|
4396
|
+
}
|
|
4397
|
+
/** The calls this script answered. Experimental. */
|
|
4398
|
+
async calls() {
|
|
4399
|
+
const ctx = this.#ctx;
|
|
4400
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/scripts/${segment(this.id)}/calls`));
|
|
4401
|
+
return decodeOpenAICalls(ctx, data);
|
|
4402
|
+
}
|
|
4403
|
+
/** The calls whose streams this script holds at `pauseAfter`. Experimental. */
|
|
4404
|
+
async pausedCalls() {
|
|
4405
|
+
const ctx = this.#ctx;
|
|
4406
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/scripts/${segment(this.id)}/paused`));
|
|
4407
|
+
return decodeOpenAIPausedCalls(ctx, data);
|
|
4408
|
+
}
|
|
4409
|
+
/** The tool calls this script made, each with the result the agent sent back. Experimental. */
|
|
4410
|
+
async toolCalls(options = {}) {
|
|
4411
|
+
const ctx = this.#ctx;
|
|
4412
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/scripts/${segment(this.id)}/tool-calls`, { query: { name: options.name } }));
|
|
4413
|
+
return data;
|
|
4414
|
+
}
|
|
4415
|
+
/** For a responder's SDK: the calls held for it since `since`, waiting up to `waitMs` for one. Experimental. */
|
|
4416
|
+
async heldCalls(options = {}) {
|
|
4417
|
+
const ctx = this.#ctx;
|
|
4418
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/scripts/${segment(this.id)}/requests`, { query: { since: options.since, waitMs: options.waitMs } }));
|
|
4419
|
+
return data;
|
|
4420
|
+
}
|
|
4421
|
+
/** For a responder's SDK: answer a held call with a turn, or report that the test's function threw. Experimental. */
|
|
4422
|
+
async answerHeld(held, options = {}) {
|
|
4423
|
+
const ctx = this.#ctx;
|
|
4424
|
+
await ctx.transport.request("POST", `/sessions/${segment(sessionOf(ctx))}/openai/scripts/${segment(this.id)}/answers`, { body: { held, turn: options.turn === undefined ? undefined : (typeof options.turn === "object" && options.turn !== null && !Array.isArray(options.turn) ? { ...options.turn, toolCalls: options.turn.toolCalls === undefined ? undefined : options.turn.toolCalls.map((item) => ({ ...item, codeInterpreter: item.codeInterpreter === undefined ? undefined : { ...item.codeInterpreter, files: item.codeInterpreter.files === undefined ? undefined : item.codeInterpreter.files.map((item) => readMedia(item)) }, imageGeneration: item.imageGeneration === undefined ? undefined : { ...item.imageGeneration, image: readMedia(item.imageGeneration.image) } })), image: options.turn.image === undefined ? undefined : [options.turn.image].flat().map((item) => readMedia(item)), audio: options.turn.audio === undefined ? undefined : readMedia(options.turn.audio) } : options.turn), error: options.error } });
|
|
4425
|
+
}
|
|
4426
|
+
/** Wait for the next new model call this script answers, after the last one this handle saw. */
|
|
4427
|
+
async waitForCall(options = {}) {
|
|
4428
|
+
return waitForNext(this.#seen, "waitForCall", () => this.calls(), () => true, "a model call this script answers", options);
|
|
4429
|
+
}
|
|
4430
|
+
/** Wait for the next new stream held at pauseAfter, after the last one this handle saw. */
|
|
4431
|
+
async waitForPause(options = {}) {
|
|
4432
|
+
return waitForNext(this.#seen, "waitForPause", () => this.pausedCalls(), () => true, "a stream held at pauseAfter", options);
|
|
4433
|
+
}
|
|
4434
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
4435
|
+
[QUIET]() {
|
|
4436
|
+
return quietOf(this.#ctx);
|
|
4437
|
+
}
|
|
4438
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
4439
|
+
[CONTEXT]() {
|
|
4440
|
+
return this.#ctx;
|
|
4441
|
+
}
|
|
4442
|
+
}
|
|
4443
|
+
export class OpenAICall {
|
|
4444
|
+
id;
|
|
4445
|
+
endpoint;
|
|
4446
|
+
model;
|
|
4447
|
+
stream;
|
|
4448
|
+
at;
|
|
4449
|
+
durationMs;
|
|
4450
|
+
attempt;
|
|
4451
|
+
done;
|
|
4452
|
+
request;
|
|
4453
|
+
response;
|
|
4454
|
+
toolCalls;
|
|
4455
|
+
script;
|
|
4456
|
+
#ctx;
|
|
4457
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
4458
|
+
constructor(ctx, data) {
|
|
4459
|
+
this.#ctx = ctx;
|
|
4460
|
+
this.id = data.id;
|
|
4461
|
+
this.endpoint = data.endpoint;
|
|
4462
|
+
this.model = data.model;
|
|
4463
|
+
this.stream = data.stream;
|
|
4464
|
+
this.at = data.at;
|
|
4465
|
+
this.durationMs = data.durationMs;
|
|
4466
|
+
this.attempt = data.attempt;
|
|
4467
|
+
this.done = data.done;
|
|
4468
|
+
this.request = data.request;
|
|
4469
|
+
this.response = data.response;
|
|
4470
|
+
this.toolCalls = data.toolCalls;
|
|
4471
|
+
this.script = data.script;
|
|
4472
|
+
}
|
|
4473
|
+
/** Re-read a model call: whether it is done, how it ended. Experimental. */
|
|
4474
|
+
async refresh() {
|
|
4475
|
+
const ctx = this.#ctx;
|
|
4476
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/calls/${segment(this.id)}`));
|
|
4477
|
+
return new OpenAICall(ctx, data);
|
|
4478
|
+
}
|
|
4479
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
4480
|
+
[QUIET]() {
|
|
4481
|
+
return quietOf(this.#ctx);
|
|
4482
|
+
}
|
|
4483
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
4484
|
+
[CONTEXT]() {
|
|
4485
|
+
return this.#ctx;
|
|
4486
|
+
}
|
|
4487
|
+
}
|
|
4488
|
+
export class OpenAIRateLimit {
|
|
4489
|
+
id;
|
|
4490
|
+
requests;
|
|
4491
|
+
tokens;
|
|
4492
|
+
resetsInMs;
|
|
4493
|
+
#ctx;
|
|
4494
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
4495
|
+
constructor(ctx, data) {
|
|
4496
|
+
this.#ctx = ctx;
|
|
4497
|
+
this.id = data.id;
|
|
4498
|
+
this.requests = data.requests;
|
|
4499
|
+
this.tokens = data.tokens;
|
|
4500
|
+
this.resetsInMs = data.resetsInMs;
|
|
4501
|
+
}
|
|
4502
|
+
/** What the rate limit's headers would say now. Experimental. */
|
|
4503
|
+
async remaining() {
|
|
4504
|
+
const ctx = this.#ctx;
|
|
4505
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/openai/rate-limits/${segment(this.id)}`));
|
|
4506
|
+
return new OpenAIRateLimit(ctx, data);
|
|
4507
|
+
}
|
|
4508
|
+
/** Remove the rate limit. Experimental. */
|
|
4509
|
+
async undo() {
|
|
4510
|
+
const ctx = this.#ctx;
|
|
4511
|
+
await ctx.transport.request("DELETE", `/sessions/${segment(sessionOf(ctx))}/openai/rate-limits/${segment(this.id)}`);
|
|
4512
|
+
}
|
|
4513
|
+
async [Symbol.asyncDispose]() {
|
|
4514
|
+
await disposeQuietly(() => this.undo());
|
|
4515
|
+
}
|
|
4516
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
4517
|
+
[QUIET]() {
|
|
4518
|
+
return quietOf(this.#ctx);
|
|
4519
|
+
}
|
|
4520
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
4521
|
+
[CONTEXT]() {
|
|
4522
|
+
return this.#ctx;
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
export class Place {
|
|
4526
|
+
channel;
|
|
4527
|
+
title;
|
|
4528
|
+
id;
|
|
4529
|
+
name;
|
|
4530
|
+
active;
|
|
4531
|
+
#ctx;
|
|
4532
|
+
/** @internal Handles come from the SDK, never from `new`. */
|
|
4533
|
+
constructor(ctx, data) {
|
|
4534
|
+
this.#ctx = ctx;
|
|
4535
|
+
this.channel = data.channel;
|
|
4536
|
+
this.title = data.title;
|
|
4537
|
+
this.id = data.id;
|
|
4538
|
+
this.name = data.name;
|
|
4539
|
+
this.active = data.active;
|
|
4540
|
+
}
|
|
4541
|
+
/** A place as a person reads it: the transcript its channel's own transcript route has. Experimental. */
|
|
4542
|
+
async transcript() {
|
|
4543
|
+
const ctx = this.#ctx;
|
|
4544
|
+
const data = (await ctx.transport.request("GET", `/sessions/${segment(sessionOf(ctx))}/places/${segment(this.channel)}/${segment(this.id)}/transcript`));
|
|
4545
|
+
return decodePlaceTranscript(ctx, data);
|
|
4546
|
+
}
|
|
4547
|
+
/** @internal Is the agent quiet in this handle's session? Matchers ask this. */
|
|
4548
|
+
[QUIET]() {
|
|
4549
|
+
return quietOf(this.#ctx);
|
|
4550
|
+
}
|
|
4551
|
+
/** @internal The server and session this handle lives in: what a failing matcher reads the session's model calls with. */
|
|
4552
|
+
[CONTEXT]() {
|
|
4553
|
+
return this.#ctx;
|
|
4554
|
+
}
|
|
2986
4555
|
}
|
|
2987
4556
|
export class GitHubPullRequest extends GitHubIssue {
|
|
2988
4557
|
head;
|