managed-deepagents 0.10.0-dev.3 → 0.10.0-dev.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +104 -6
  2. package/dist/channels/github/index.d.ts +1 -8
  3. package/dist/channels/github/index.d.ts.map +1 -1
  4. package/dist/channels/github/index.js +4 -50
  5. package/dist/channels/github/index.js.map +1 -1
  6. package/dist/channels/http/http.d.ts.map +1 -1
  7. package/dist/channels/http/http.js +162 -17
  8. package/dist/channels/http/http.js.map +1 -1
  9. package/dist/channels/http/ingress.d.ts +16 -0
  10. package/dist/channels/http/ingress.d.ts.map +1 -1
  11. package/dist/channels/http/ingress.js +30 -5
  12. package/dist/channels/http/ingress.js.map +1 -1
  13. package/dist/channels/http/reply.d.ts +20 -0
  14. package/dist/channels/http/reply.d.ts.map +1 -0
  15. package/dist/channels/http/reply.js +116 -0
  16. package/dist/channels/http/reply.js.map +1 -0
  17. package/dist/channels/http/studio.d.ts +13 -0
  18. package/dist/channels/http/studio.d.ts.map +1 -0
  19. package/dist/channels/http/studio.js +80 -0
  20. package/dist/channels/http/studio.js.map +1 -0
  21. package/dist/channels/http/types.d.ts +32 -2
  22. package/dist/channels/http/types.d.ts.map +1 -1
  23. package/dist/channels/linear/connections.d.ts +11 -0
  24. package/dist/channels/linear/connections.d.ts.map +1 -0
  25. package/dist/channels/linear/connections.js +14 -0
  26. package/dist/channels/linear/connections.js.map +1 -0
  27. package/dist/channels/linear/graphql.d.ts +69 -0
  28. package/dist/channels/linear/graphql.d.ts.map +1 -0
  29. package/dist/channels/linear/graphql.js +169 -0
  30. package/dist/channels/linear/graphql.js.map +1 -0
  31. package/dist/channels/linear/index.d.ts +9 -0
  32. package/dist/channels/linear/index.d.ts.map +1 -0
  33. package/dist/channels/linear/index.js +466 -0
  34. package/dist/channels/linear/index.js.map +1 -0
  35. package/dist/channels/linear/schema.d.ts +1035 -0
  36. package/dist/channels/linear/schema.d.ts.map +1 -0
  37. package/dist/channels/linear/schema.js +216 -0
  38. package/dist/channels/linear/schema.js.map +1 -0
  39. package/dist/channels/linear/types.d.ts +112 -0
  40. package/dist/channels/linear/types.d.ts.map +1 -0
  41. package/dist/channels/linear/types.js +2 -0
  42. package/dist/channels/linear/types.js.map +1 -0
  43. package/dist/channels/reserved-connections.d.ts +2 -2
  44. package/dist/channels/reserved-connections.d.ts.map +1 -1
  45. package/dist/channels/reserved-connections.js +26 -9
  46. package/dist/channels/reserved-connections.js.map +1 -1
  47. package/dist/channels/source-providers.js +1 -1
  48. package/dist/channels/source-providers.js.map +1 -1
  49. package/dist/connections.d.ts +14 -3
  50. package/dist/connections.d.ts.map +1 -1
  51. package/dist/connections.js +32 -9
  52. package/dist/connections.js.map +1 -1
  53. package/dist/credential-gate.d.ts.map +1 -1
  54. package/dist/credential-gate.js +8 -6
  55. package/dist/credential-gate.js.map +1 -1
  56. package/dist/index.d.ts +2 -0
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +1 -0
  59. package/dist/index.js.map +1 -1
  60. package/dist/ingress/runs.d.ts +5 -0
  61. package/dist/ingress/runs.d.ts.map +1 -1
  62. package/dist/ingress/runs.js +33 -1
  63. package/dist/ingress/runs.js.map +1 -1
  64. package/dist/namespaces.d.ts +15 -0
  65. package/dist/namespaces.d.ts.map +1 -1
  66. package/dist/namespaces.js +2 -0
  67. package/dist/namespaces.js.map +1 -1
  68. package/dist/runtime/auth.d.ts +2 -0
  69. package/dist/runtime/auth.d.ts.map +1 -1
  70. package/dist/runtime/auth.js +138 -22
  71. package/dist/runtime/auth.js.map +1 -1
  72. package/dist/runtime/channel-icon.d.ts +22 -0
  73. package/dist/runtime/channel-icon.d.ts.map +1 -0
  74. package/dist/runtime/channel-icon.js +70 -0
  75. package/dist/runtime/channel-icon.js.map +1 -0
  76. package/dist/runtime/channel.d.ts +6 -0
  77. package/dist/runtime/channel.d.ts.map +1 -1
  78. package/dist/runtime/channel.js.map +1 -1
  79. package/dist/runtime/identity-http.d.ts +2 -0
  80. package/dist/runtime/identity-http.d.ts.map +1 -1
  81. package/dist/runtime/identity-http.js +35 -0
  82. package/dist/runtime/identity-http.js.map +1 -1
  83. package/dist/runtime/index.d.ts.map +1 -1
  84. package/dist/runtime/index.js +2 -0
  85. package/dist/runtime/index.js.map +1 -1
  86. package/dist/runtime/schedule-auth.d.ts.map +1 -1
  87. package/dist/runtime/schedule-auth.js +19 -2
  88. package/dist/runtime/schedule-auth.js.map +1 -1
  89. package/package.json +7 -7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/channels/linear/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,kFAAkF;AAClF,eAAO,MAAM,mBAAmB;;;;;;;iBAO9B,CAAC;AA+GH,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAiD/B,CAAC;AAEH,eAAO,MAAM,oBAAoB,qHAEhC,CAAC;AAyDF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAxBrB,MAAM;eAAS,MAAM;eAAS,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyC3C,CAAC"}
@@ -0,0 +1,216 @@
1
+ import { z } from "zod";
2
+ // Shared scalar constraints. Linear identifiers are UUIDs, but only their
3
+ // presence matters here.
4
+ const nonblankStringSchema = z
5
+ .string()
6
+ .refine((value) => value.trim().length > 0);
7
+ const optionalTextSchema = z.string().nullish();
8
+ /** Receipt metadata only, not a complete Linear webhook payload specification. */
9
+ export const linearReceiptSchema = z.object({
10
+ deliveryId: nonblankStringSchema,
11
+ payload: z.looseObject({
12
+ type: nonblankStringSchema,
13
+ action: nonblankStringSchema,
14
+ organizationId: z.string().optional(),
15
+ }),
16
+ });
17
+ const teamSchema = z.looseObject({
18
+ id: nonblankStringSchema,
19
+ key: nonblankStringSchema,
20
+ name: z.string().optional(),
21
+ });
22
+ const actorSchema = z.looseObject({
23
+ id: nonblankStringSchema,
24
+ type: z.string().optional(),
25
+ name: z.string().optional(),
26
+ });
27
+ // Payload subjects. Loose objects retain unmodeled provider fields.
28
+ const issueSchema = z.looseObject({
29
+ id: nonblankStringSchema,
30
+ identifier: nonblankStringSchema,
31
+ title: z.string(),
32
+ description: optionalTextSchema,
33
+ url: z.string().optional(),
34
+ teamId: z.string().optional(),
35
+ team: teamSchema.optional(),
36
+ labelIds: z.array(z.string()).optional(),
37
+ labels: z
38
+ .array(z.looseObject({ id: z.string(), name: z.string() }))
39
+ .optional(),
40
+ botActor: z.unknown().optional(),
41
+ });
42
+ const commentSchema = z.looseObject({
43
+ id: nonblankStringSchema,
44
+ body: z.string(),
45
+ issueId: nonblankStringSchema,
46
+ parentId: z.string().nullish(),
47
+ userId: z.string().nullish(),
48
+ user: z
49
+ .looseObject({ id: z.string(), name: z.string().optional() })
50
+ .nullish(),
51
+ issue: z
52
+ .looseObject({
53
+ id: nonblankStringSchema,
54
+ identifier: z.string().optional(),
55
+ title: z.string().optional(),
56
+ url: z.string().optional(),
57
+ team: teamSchema.optional(),
58
+ })
59
+ .optional(),
60
+ botActor: z.unknown().optional(),
61
+ });
62
+ const sessionIssueSchema = z.looseObject({
63
+ id: nonblankStringSchema,
64
+ identifier: z.string().optional(),
65
+ title: z.string().optional(),
66
+ url: z.string().optional(),
67
+ description: optionalTextSchema,
68
+ team: teamSchema.optional(),
69
+ });
70
+ /** A Linear agent session: the app was mentioned or delegated an issue. */
71
+ const agentSessionSchema = z.looseObject({
72
+ id: nonblankStringSchema,
73
+ status: z.string().optional(),
74
+ url: z.string().optional(),
75
+ issueId: z.string().nullish(),
76
+ issue: sessionIssueSchema.nullish(),
77
+ // The comment that started the session, when a mention did.
78
+ commentId: z.string().nullish(),
79
+ comment: z
80
+ .looseObject({ id: nonblankStringSchema, body: z.string().optional() })
81
+ .nullish(),
82
+ creatorId: z.string().nullish(),
83
+ creator: z
84
+ .looseObject({ id: nonblankStringSchema, name: z.string().optional() })
85
+ .nullish(),
86
+ });
87
+ /** What a user said in a session: a reply, or a signal such as `stop`. */
88
+ const agentActivitySchema = z.looseObject({
89
+ content: z.looseObject({ type: z.string(), body: z.string().optional() }),
90
+ signal: z.string().nullish(),
91
+ signalMetadata: z.unknown().optional(),
92
+ sourceCommentId: z.string().nullish(),
93
+ userId: z.string().nullish(),
94
+ user: z
95
+ .looseObject({ id: nonblankStringSchema, name: z.string().optional() })
96
+ .nullish(),
97
+ });
98
+ // Common delivery context.
99
+ const envelopeSchema = z.looseObject({
100
+ organizationId: nonblankStringSchema,
101
+ webhookId: z.string().optional(),
102
+ webhookTimestamp: z.number(),
103
+ createdAt: z.string().optional(),
104
+ url: z.string().optional(),
105
+ actor: actorSchema.optional(),
106
+ });
107
+ function dispatchEventSchema(key, payloadSchema) {
108
+ return z.object({
109
+ key: z.literal(key),
110
+ deliveryId: nonblankStringSchema,
111
+ payload: payloadSchema,
112
+ });
113
+ }
114
+ /** Each supported event key requires its exact type, action and subject. */
115
+ export const linearDispatchSchema = z.discriminatedUnion("key", [
116
+ dispatchEventSchema("Issue.create", envelopeSchema.extend({
117
+ type: z.literal("Issue"),
118
+ action: z.literal("create"),
119
+ data: issueSchema,
120
+ })),
121
+ dispatchEventSchema("Issue.update", envelopeSchema.extend({
122
+ type: z.literal("Issue"),
123
+ action: z.literal("update"),
124
+ data: issueSchema,
125
+ // The changed fields' previous values.
126
+ updatedFrom: z.record(z.string(), z.unknown()).optional(),
127
+ })),
128
+ dispatchEventSchema("Comment.create", envelopeSchema.extend({
129
+ type: z.literal("Comment"),
130
+ action: z.literal("create"),
131
+ data: commentSchema,
132
+ })),
133
+ dispatchEventSchema("AgentSessionEvent.created", envelopeSchema.extend({
134
+ type: z.literal("AgentSessionEvent"),
135
+ action: z.literal("created"),
136
+ appUserId: z.string().optional(),
137
+ agentSession: agentSessionSchema,
138
+ // Linear's ready-made prompt: the issue, the thread and who asked.
139
+ promptContext: z.string().nullish(),
140
+ guidance: z.unknown().optional(),
141
+ })),
142
+ dispatchEventSchema("AgentSessionEvent.prompted", envelopeSchema.extend({
143
+ type: z.literal("AgentSessionEvent"),
144
+ action: z.literal("prompted"),
145
+ appUserId: z.string().optional(),
146
+ agentSession: agentSessionSchema,
147
+ agentActivity: agentActivitySchema,
148
+ })),
149
+ ]);
150
+ export const SUPPORTED_EVENT_KEYS = linearDispatchSchema.options.map((option) => option.shape.key.value);
151
+ /** The issue an event is about, wherever its payload keeps it. */
152
+ function eventIssue(event) {
153
+ if (event.payload.type === "AgentSessionEvent") {
154
+ const session = event.payload.agentSession;
155
+ const id = session.issue?.id ?? session.issueId;
156
+ // Linear opens sessions on issues; one without could not be answered.
157
+ if (!id)
158
+ throw new TypeError("Linear agent session has no issue");
159
+ return { id, ...(session.issue?.team && { team: session.issue.team }) };
160
+ }
161
+ if (event.payload.type === "Comment") {
162
+ const { data } = event.payload;
163
+ return {
164
+ id: data.issueId,
165
+ ...(data.issue?.team && { team: data.issue.team }),
166
+ };
167
+ }
168
+ const { data } = event.payload;
169
+ return { id: data.id, ...(data.team && { team: data.team }) };
170
+ }
171
+ /**
172
+ * Who acted: the webhook's actor, or for a session the user who started it or
173
+ * replied in it.
174
+ */
175
+ function eventActor(event) {
176
+ const payload = event.payload;
177
+ const person = payload.type !== "AgentSessionEvent"
178
+ ? payload.actor
179
+ : payload.action === "prompted"
180
+ ? (payload.agentActivity.user ??
181
+ (payload.agentActivity.userId
182
+ ? { id: payload.agentActivity.userId }
183
+ : undefined))
184
+ : (payload.agentSession.creator ??
185
+ (payload.agentSession.creatorId
186
+ ? { id: payload.agentSession.creatorId }
187
+ : undefined));
188
+ if (!person)
189
+ return undefined;
190
+ const { type, name } = person;
191
+ return {
192
+ id: person.id,
193
+ ...(typeof type === "string" && { type }),
194
+ ...(typeof name === "string" && { name }),
195
+ };
196
+ }
197
+ // Expose common routing metadata while preserving the original payload.
198
+ export const linearEventSchema = linearDispatchSchema.transform((event) => {
199
+ const issue = eventIssue(event);
200
+ const actor = eventActor(event);
201
+ return {
202
+ ...event,
203
+ type: event.payload.type,
204
+ action: event.payload.action,
205
+ organizationId: event.payload.organizationId,
206
+ issueId: issue.id,
207
+ ...(issue.team && {
208
+ team: { id: issue.team.id, key: issue.team.key },
209
+ }),
210
+ ...(actor && { actor }),
211
+ ...(event.payload.type === "AgentSessionEvent" && {
212
+ sessionId: event.payload.agentSession.id,
213
+ }),
214
+ };
215
+ });
216
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/channels/linear/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0EAA0E;AAC1E,yBAAyB;AACzB,MAAM,oBAAoB,GAAG,CAAC;KAC3B,MAAM,EAAE;KACR,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC9C,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;AAEhD,kFAAkF;AAClF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,UAAU,EAAE,oBAAoB;IAChC,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC;QACrB,IAAI,EAAE,oBAAoB;QAC1B,MAAM,EAAE,oBAAoB;QAC5B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACtC,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,CAAC,CAAC,WAAW,CAAC;IAC/B,EAAE,EAAE,oBAAoB;IACxB,GAAG,EAAE,oBAAoB;IACzB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC;IAChC,EAAE,EAAE,oBAAoB;IACxB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CA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AAC;KACH,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,112 @@
1
+ import type { z } from "zod";
2
+ import type { MultitaskStrategy } from "../../ingress/runs.js";
3
+ import type { linearEventSchema } from "./schema.js";
4
+ import type { ChannelRunResult } from "../run-input.js";
5
+ /** Handwritten schema subsets; unmodeled provider fields remain unknown. */
6
+ type EventUnion = z.output<typeof linearEventSchema>;
7
+ export type LinearEventKey = EventUnion["key"];
8
+ export type LinearEvent<K extends LinearEventKey = LinearEventKey> = Extract<EventUnion, {
9
+ key: K;
10
+ }>;
11
+ export type LinearPayloadFor<K extends LinearEventKey> = LinearEvent<K>["payload"];
12
+ export interface LinearChannelRuntime {
13
+ channel: {
14
+ name: string;
15
+ };
16
+ }
17
+ /**
18
+ * What an event handler returns: a run's input, as `agent.invoke` takes it —
19
+ * a string, a message such as `new HumanMessage(...)`, state such as
20
+ * `{ messages: [...] }`, or `[input, { context }]`. `null` or `undefined`
21
+ * starts nothing.
22
+ */
23
+ export type LinearEventResult = ChannelRunResult | null | undefined | void;
24
+ export type LinearEventCallback<K extends LinearEventKey> = (event: LinearEvent<K>, runtime: LinearChannelRuntime) => LinearEventResult | Promise<LinearEventResult>;
25
+ /** The Linear app `mda deploy` sets up: how it looks, and what it may do. */
26
+ export interface LinearAppOptions {
27
+ /**
28
+ * The app's name, shown where people mention it and in its comments: 2–80
29
+ * characters, without "Linear" or a URL. Defaults to the agent's name.
30
+ * Deploy fills it in when the app is created; rename an existing app on
31
+ * its settings page in Linear.
32
+ */
33
+ name?: string;
34
+ /**
35
+ * What the app does, shown when a workspace admin installs it: up to 1,000
36
+ * characters. Like `name`, it applies when the app is created.
37
+ */
38
+ description?: string;
39
+ /**
40
+ * The app's icon: a PNG or JPEG image, as a path relative to `channels/`
41
+ * like the Slack channel's `icon`, such as `assets/icon.png`. At least
42
+ * 256×256 pixels and at most 1 MB. The deployment serves it at
43
+ * `/channels/{name}/icon`, and deploy points the new app's icon there.
44
+ */
45
+ icon?: string;
46
+ /**
47
+ * Keys of the teams (as in `ENG-123`) the channel is limited to: events
48
+ * about other teams' issues start nothing. Defaults to every team the app
49
+ * can see. The app's token still reaches every team it was granted, so
50
+ * limit its team access in Linear too.
51
+ */
52
+ teams?: string[];
53
+ }
54
+ /**
55
+ * Options for `channels.linear(...)`: the app's scope and event handlers that
56
+ * start runs. Each issue is one conversation.
57
+ */
58
+ export interface LinearChannelOptions {
59
+ /** The Linear app `mda deploy` sets up: its name, description, icon and teams. */
60
+ app?: LinearAppOptions;
61
+ /**
62
+ * What an event that starts a run does while its conversation already
63
+ * runs: `enqueue` (the default) waits for the run and starts after it,
64
+ * `interrupt` cancels the run, keeping its progress, and starts at once,
65
+ * `rollback` cancels it and discards its progress, and `reject` starts
66
+ * nothing.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * // A newer comment replaces the work on an older one.
71
+ * channels.linear({ multitaskStrategy: "interrupt", onEvent })
72
+ * ```
73
+ */
74
+ multitaskStrategy?: MultitaskStrategy;
75
+ /**
76
+ * Event handlers that start runs. Return a prompt (string, message, or
77
+ * state), or nothing to skip. The run's final reply is posted as a comment
78
+ * on the issue, under the comment that started it.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * { "Issue.create": (e) => `Triage ${e.payload.data.identifier}` }
83
+ * ```
84
+ *
85
+ * In agent sessions the reply goes to the session instead.
86
+ */
87
+ onEvent?: {
88
+ [K in LinearEventKey]?: LinearEventCallback<K>;
89
+ };
90
+ /**
91
+ * Answer Linear agent sessions, which open when someone mentions the app or
92
+ * delegates an issue to it. Defaults to `true`. Without a handler, a new
93
+ * session runs with Linear's prompt for it (`promptContext`), and a reply
94
+ * in the session continues the conversation. The run's progress and reply
95
+ * show in the session, and Stop cancels the run. A run that stops on
96
+ * interrupts answers with a link to its thread in LangSmith Studio, where
97
+ * they are resumed.
98
+ *
99
+ * @experimental Sessions use Linear's Agents API, a Developer Preview, so
100
+ * they may change as Linear changes it.
101
+ */
102
+ sessions?: boolean;
103
+ /**
104
+ * Ignore changes made by other apps and integrations (a delivery whose
105
+ * actor isn't a person, or the creation of an issue or comment with a
106
+ * `botActor`), so automations don't trigger each other. Defaults to `true`.
107
+ * The app's own changes are always ignored.
108
+ */
109
+ ignoreBots?: boolean;
110
+ }
111
+ export {};
112
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/channels/linear/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,4EAA4E;AAC5E,KAAK,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACrD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;AAC/C,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IAAI,OAAO,CAC1E,UAAU,EACV;IAAE,GAAG,EAAE,CAAC,CAAA;CAAE,CACX,CAAC;AACF,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,cAAc,IACnD,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAE5B,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,MAAM,iBAAiB,GAAG,gBAAgB,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;AAE3E,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,cAAc,IAAI,CAC1D,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EACrB,OAAO,EAAE,oBAAoB,KAC1B,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEpD,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,kFAAkF;IAClF,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB;;;;;;;;;;;;OAYG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE;SAAG,CAAC,IAAI,cAAc,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC;KAAE,CAAC;IAC7D;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/channels/linear/types.ts"],"names":[],"mappings":""}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Why a channel's reserved agent connection cannot be read as a user
3
- * connection, or undefined for any other slug. Reading the GitHub App's token
4
- * as the person running the agent is not supported yet.
3
+ * connection, or undefined for any other slug. Reading an app's token as the
4
+ * person running the agent is not supported yet.
5
5
  */
6
6
  export declare function reservedUserConnectionError(slug: string): string | undefined;
7
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"reserved-connections.d.ts","sourceRoot":"","sources":["../../src/channels/reserved-connections.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ5E;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,CAGR"}
1
+ {"version":3,"file":"reserved-connections.d.ts","sourceRoot":"","sources":["../../src/channels/reserved-connections.ts"],"names":[],"mappings":"AAuCA;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAS5E;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,CAGR"}
@@ -1,28 +1,45 @@
1
1
  import { GITHUB_TOKEN_SLUG, githubAppConnectionSlug, } from "./github/connections.js";
2
+ import { LINEAR_TOKEN_SLUG, linearAppConnectionSlug, } from "./linear/connections.js";
2
3
  // First-party channels' reserved agent connection names, listed here so
3
4
  // resolution does not depend on adapter modules being loaded.
4
5
  const builtinReservedConnections = new Map([
5
- [GITHUB_TOKEN_SLUG, (deploymentId) => githubAppConnectionSlug(deploymentId)],
6
+ [
7
+ GITHUB_TOKEN_SLUG,
8
+ {
9
+ resolve: githubAppConnectionSlug,
10
+ token: "the GitHub App's installation token",
11
+ actsAs: "act on GitHub as the App",
12
+ },
13
+ ],
14
+ [
15
+ LINEAR_TOKEN_SLUG,
16
+ {
17
+ resolve: linearAppConnectionSlug,
18
+ token: "the Linear app's token",
19
+ actsAs: "act in Linear as the app",
20
+ },
21
+ ],
6
22
  ]);
7
23
  /**
8
24
  * Why a channel's reserved agent connection cannot be read as a user
9
- * connection, or undefined for any other slug. Reading the GitHub App's token
10
- * as the person running the agent is not supported yet.
25
+ * connection, or undefined for any other slug. Reading an app's token as the
26
+ * person running the agent is not supported yet.
11
27
  */
12
28
  export function reservedUserConnectionError(slug) {
13
- if (!builtinReservedConnections.has(slug))
29
+ const reserved = builtinReservedConnections.get(slug);
30
+ if (!reserved)
14
31
  return undefined;
15
32
  const name = JSON.stringify(slug);
16
- return (`${name} is not supported as a user connection yet: it is the GitHub App's ` +
17
- `installation token, an agent connection. Use connections.get(${name}, ` +
18
- `{ type: "agent" }) to act on GitHub as the App.`);
33
+ return (`${name} is not supported as a user connection yet: it is ${reserved.token}, ` +
34
+ `an agent connection. Use connections.get(${name}, { type: "agent" }) to ` +
35
+ `${reserved.actsAs}.`);
19
36
  }
20
37
  /**
21
38
  * The connection that actually holds a channel's reserved agent connection;
22
39
  * other slugs pass through unchanged.
23
40
  */
24
41
  export function reservedAgentConnectionSlug(slug, deploymentId) {
25
- const resolve = builtinReservedConnections.get(slug);
26
- return resolve && deploymentId ? resolve(deploymentId) : slug;
42
+ const reserved = builtinReservedConnections.get(slug);
43
+ return reserved && deploymentId ? reserved.resolve(deploymentId) : slug;
27
44
  }
28
45
  //# sourceMappingURL=reserved-connections.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reserved-connections.js","sourceRoot":"","sources":["../../src/channels/reserved-connections.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AAEjC,wEAAwE;AACxE,8DAA8D;AAC9D,MAAM,0BAA0B,GAAG,IAAI,GAAG,CAGxC;IACA,CAAC,iBAAiB,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;CAC7E,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAY;IACtD,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5D,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,CACL,GAAG,IAAI,qEAAqE;QAC5E,gEAAgE,IAAI,IAAI;QACxE,iDAAiD,CAClD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,IAAY,EACZ,YAAgC;IAEhC,MAAM,OAAO,GAAG,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACrD,OAAO,OAAO,IAAI,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC"}
1
+ {"version":3,"file":"reserved-connections.js","sourceRoot":"","sources":["../../src/channels/reserved-connections.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,yBAAyB,CAAC;AAEjC,wEAAwE;AACxE,8DAA8D;AAC9D,MAAM,0BAA0B,GAAG,IAAI,GAAG,CASxC;IACA;QACE,iBAAiB;QACjB;YACE,OAAO,EAAE,uBAAuB;YAChC,KAAK,EAAE,qCAAqC;YAC5C,MAAM,EAAE,0BAA0B;SACnC;KACF;IACD;QACE,iBAAiB;QACjB;YACE,OAAO,EAAE,uBAAuB;YAChC,KAAK,EAAE,wBAAwB;YAC/B,MAAM,EAAE,0BAA0B;SACnC;KACF;CACF,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAY;IACtD,MAAM,QAAQ,GAAG,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtD,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,CACL,GAAG,IAAI,qDAAqD,QAAQ,CAAC,KAAK,IAAI;QAC9E,4CAA4C,IAAI,0BAA0B;QAC1E,GAAG,QAAQ,CAAC,MAAM,GAAG,CACtB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B,CACzC,IAAY,EACZ,YAAgC;IAEhC,MAAM,QAAQ,GAAG,0BAA0B,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACtD,OAAO,QAAQ,IAAI,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1E,CAAC"}
@@ -1,6 +1,6 @@
1
1
  const declaredProviders = new Set();
2
2
  // Keep first-party ingress working before adapter modules are loaded.
3
- const builtinProviders = new Set(["slack", "github"]);
3
+ const builtinProviders = new Set(["slack", "github", "linear"]);
4
4
  /** Register declared providers independently of outbound messaging support. */
5
5
  export function registerDeclaredSourceProviders(sources) {
6
6
  const providers = new Set();
@@ -1 +1 @@
1
- {"version":3,"file":"source-providers.js","sourceRoot":"","sources":["../../src/channels/source-providers.ts"],"names":[],"mappings":"AAMA,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;AAC5C,sEAAsE;AACtE,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAEtD,+EAA+E;AAC/E,MAAM,UAAU,+BAA+B,CAC7C,OAAkC;IAElC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;IACpC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,IAAI;YAAE,SAAS;QAC3B,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YAC1D,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;QACD,MAAM,YAAY,GAChB,OAAO,MAAM,CAAC,YAAY,KAAK,UAAU;YACvC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC;YAClC,CAAC,CAAC,SAAS,CAAC;QAChB,IAC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AC,SAAS,CAAC;QAChB,IACE,OAAO,YAAY,EAAE,QAAQ,KAAK,QAAQ;YAC1C,YAAY,CAAC,QAAQ,CAAC,IAAI,EAAE,EAC5B,CAAC;YACD,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IACD,0EAA0E;IAC1E,KAAK,MAAM,QAAQ,IAAI,SAAS;QAAE,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACpE,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,uBAAuB,CAAC,QAAgB;IACtD,OAAO,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,iBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAC3E,CAAC"}
@@ -71,6 +71,11 @@ export declare class Connections {
71
71
  resolve(slug: string, owner: ConnectionOwner): Promise<string>;
72
72
  resolveDeploymentSecret(slug: string): Promise<string>;
73
73
  }
74
+ /**
75
+ * The variable `mda dev` reads an agent connection's local value from:
76
+ * `MDA_DEV_` and the slug uppercased, `-` as `_` and `/` as `__`
77
+ * (`mda/github-token` → `MDA_DEV_MDA__GITHUB_TOKEN`), so shells keep it.
78
+ */
74
79
  export declare function agentConnectionEnvKey(slug: string): string;
75
80
  export declare function resolveOwnerId(owner: ConnectionOwner, identity: RuntimeIdentity | undefined, deploymentId: string | undefined): string;
76
81
  /**
@@ -82,11 +87,17 @@ export declare function resolveOwnerId(owner: ConnectionOwner, identity: Runtime
82
87
  */
83
88
  export declare function resolveAgentAuthContext(identity: RuntimeIdentity | undefined, env?: NodeJS.ProcessEnv, fetchImpl?: typeof fetch, timeoutMs?: number): Promise<AgentAuthContext>;
84
89
  /**
85
- * Why a run on a channel's conversation gets no user connections, even when a
86
- * person resumes it from Studio: the conversation holds content from outside
87
- * the workspace, which must not steer a person's grants.
90
+ * Why a Studio resume of a channel's conversation gets no user connections:
91
+ * the conversation holds content from outside the workspace, which must not
92
+ * steer the grants of whoever resumes it.
88
93
  */
89
94
  export declare const CHANNEL_THREAD_USER_CONNECTION_ERROR: string;
95
+ /**
96
+ * Whether the run continues a channel's conversation for a caller who is not
97
+ * that channel, such as a person resuming it from Studio. The channel's own
98
+ * runs, a linked Slack person's included, keep their connections.
99
+ */
100
+ export declare function outsideCallerOnChannelThread(identity: RuntimeIdentity | undefined): boolean;
90
101
  /**
91
102
  * The channel a run started by a channel event runs as, e.g. `github`. Such a
92
103
  * run runs as the channel, not as the person who sent the event, so there is
@@ -1 +1 @@
1
- {"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../src/connections.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAM3D,OAAO,EAKL,oBAAoB,EAEpB,KAAK,gBAAgB,EAEtB,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,kCAAkC,EAClC,oCAAoC,EACpC,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,oBAAoB,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AACrD,MAAM,MAAM,mBAAmB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAChE,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,mBAAmB,CAAC;AAEzE,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,eAAe,CAAC;IACvB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED,QAAA,MAAM,oBAAoB,eAA0C,CAAC;AASrE,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAA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C,OAAO,CAAC,gBAAgB,CAAC,CAe3B;AAED;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,QAGK,CAAC;AAEvD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,eAAe,GAAG,SAAS,GACpC,OAAO,CAIT;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,eAAe,GAAG,SAAS,GACpC,MAAM,GAAG,SAAS,CAOpB;AAED;;;;;;;;GAQG;AACH,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,eAAe,GAAG,SAAS,EACrC,MAAM,EAAE,eAAe,EACvB,SAAS,GAAE,OAAO,KAAa,EAC/B,SAAS,SAAwB,GAChC,OAAO,CAAC,MAAM,CAAC,CAqDjB;AAuCD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,GAAG,SAAS,CAMpB;AAuBD;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CAuBR;AAED,eAAO,MAAM,WAAW,aAAoB,CAAC"}
@@ -77,7 +77,8 @@ export class AgentAuthConnectionStore {
77
77
  }
78
78
  async fetch(request) {
79
79
  if (this.env.MDA_LOCAL_DEV === "1" && request.owner.type === "agent") {
80
- const value = this.env[agentConnectionEnvKey(request.slug)];
80
+ const value = this.env[agentConnectionEnvKey(request.slug)] ??
81
+ this.env[legacyAgentConnectionEnvKey(request.slug)];
81
82
  if (value !== undefined && value.trim()) {
82
83
  return value;
83
84
  }
@@ -170,7 +171,19 @@ export class Connections {
170
171
  return value;
171
172
  }
172
173
  }
174
+ /**
175
+ * The variable `mda dev` reads an agent connection's local value from:
176
+ * `MDA_DEV_` and the slug uppercased, `-` as `_` and `/` as `__`
177
+ * (`mda/github-token` → `MDA_DEV_MDA__GITHUB_TOKEN`), so shells keep it.
178
+ */
173
179
  export function agentConnectionEnvKey(slug) {
180
+ return `${DEV_CREDENTIAL_PREFIX}${normalizeSlug(slug)
181
+ .toUpperCase()
182
+ .replaceAll("-", "_")
183
+ .replaceAll("/", "__")}`;
184
+ }
185
+ /** The earlier spelling, with `/` kept; Linux shells drop such names. */
186
+ function legacyAgentConnectionEnvKey(slug) {
174
187
  return `${DEV_CREDENTIAL_PREFIX}${normalizeSlug(slug)
175
188
  .toUpperCase()
176
189
  .replaceAll("-", "_")}`;
@@ -246,13 +259,24 @@ export async function resolveAgentAuthContext(identity, env = process.env, fetch
246
259
  };
247
260
  }
248
261
  /**
249
- * Why a run on a channel's conversation gets no user connections, even when a
250
- * person resumes it from Studio: the conversation holds content from outside
251
- * the workspace, which must not steer a person's grants.
262
+ * Why a Studio resume of a channel's conversation gets no user connections:
263
+ * the conversation holds content from outside the workspace, which must not
264
+ * steer the grants of whoever resumes it.
265
+ */
266
+ export const CHANNEL_THREAD_USER_CONNECTION_ERROR = "user-owned connections are unavailable when resuming a channel's " +
267
+ "conversation from outside that channel: it holds content from outside " +
268
+ "the workspace, which must not act with your grants";
269
+ /**
270
+ * Whether the run continues a channel's conversation for a caller who is not
271
+ * that channel, such as a person resuming it from Studio. The channel's own
272
+ * runs, a linked Slack person's included, keep their connections.
252
273
  */
253
- export const CHANNEL_THREAD_USER_CONNECTION_ERROR = "user-owned connections are unavailable in a channel's conversation: " +
254
- "it holds content from outside the workspace, so its runs never act " +
255
- "with a person's grants, including runs resumed from Studio";
274
+ export function outsideCallerOnChannelThread(identity) {
275
+ if (!onChannelThread())
276
+ return false;
277
+ const provider = identity?.source.provider;
278
+ return !provider || !isTrustedSourceProvider(provider);
279
+ }
256
280
  /**
257
281
  * The channel a run started by a channel event runs as, e.g. `github`. Such a
258
282
  * run runs as the channel, not as the person who sent the event, so there is
@@ -279,8 +303,7 @@ export async function resolveCredentialPrincipalId(identity, config, fetchImpl =
279
303
  if (!identity?.user.id) {
280
304
  throw new CredentialStoreError("user connections require an authenticated user principal");
281
305
  }
282
- // A channel run gets the channel's own reason below.
283
- if (!channelProvider(identity) && onChannelThread()) {
306
+ if (outsideCallerOnChannelThread(identity)) {
284
307
  throw new CredentialStoreError(CHANNEL_THREAD_USER_CONNECTION_ERROR);
285
308
  }
286
309
  if (identity.user.kind === "service") {