managed-deepagents 0.10.0-dev.14 → 0.10.0-dev.16

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 (118) hide show
  1. package/README.md +17 -295
  2. package/dist/channels/github/connections.d.ts.map +1 -1
  3. package/dist/channels/github/connections.js +2 -2
  4. package/dist/channels/github/connections.js.map +1 -1
  5. package/dist/channels/github/index.d.ts +8 -1
  6. package/dist/channels/github/index.d.ts.map +1 -1
  7. package/dist/channels/github/index.js +137 -39
  8. package/dist/channels/github/index.js.map +1 -1
  9. package/dist/channels/github/schema.d.ts +0 -168
  10. package/dist/channels/github/schema.d.ts.map +1 -1
  11. package/dist/channels/github/schema.js +3 -9
  12. package/dist/channels/github/schema.js.map +1 -1
  13. package/dist/channels/github/types.d.ts +3 -49
  14. package/dist/channels/github/types.d.ts.map +1 -1
  15. package/dist/channels/http/http.d.ts.map +1 -1
  16. package/dist/channels/http/http.js +65 -224
  17. package/dist/channels/http/http.js.map +1 -1
  18. package/dist/channels/http/index.d.ts +1 -1
  19. package/dist/channels/http/index.d.ts.map +1 -1
  20. package/dist/channels/http/index.js.map +1 -1
  21. package/dist/channels/http/ingress.d.ts +3 -23
  22. package/dist/channels/http/ingress.d.ts.map +1 -1
  23. package/dist/channels/http/ingress.js +30 -51
  24. package/dist/channels/http/ingress.js.map +1 -1
  25. package/dist/channels/http/types.d.ts +6 -59
  26. package/dist/channels/http/types.d.ts.map +1 -1
  27. package/dist/channels/message-schema.d.ts +0 -2
  28. package/dist/channels/message-schema.d.ts.map +1 -1
  29. package/dist/channels/message-schema.js +0 -4
  30. package/dist/channels/message-schema.js.map +1 -1
  31. package/dist/channels/reserved-connections.d.ts +2 -2
  32. package/dist/channels/reserved-connections.d.ts.map +1 -1
  33. package/dist/channels/reserved-connections.js +9 -26
  34. package/dist/channels/reserved-connections.js.map +1 -1
  35. package/dist/channels/run-input.d.ts +1 -17
  36. package/dist/channels/run-input.d.ts.map +1 -1
  37. package/dist/channels/run-input.js +5 -50
  38. package/dist/channels/run-input.js.map +1 -1
  39. package/dist/channels/slack/index.d.ts +1 -33
  40. package/dist/channels/slack/index.d.ts.map +1 -1
  41. package/dist/channels/slack/index.js +4 -54
  42. package/dist/channels/slack/index.js.map +1 -1
  43. package/dist/channels/source-providers.js +1 -1
  44. package/dist/channels/source-providers.js.map +1 -1
  45. package/dist/connections.d.ts +0 -5
  46. package/dist/connections.d.ts.map +1 -1
  47. package/dist/connections.js +1 -14
  48. package/dist/connections.js.map +1 -1
  49. package/dist/index.d.ts +2 -7
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +0 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/ingress/runs.d.ts +1 -10
  54. package/dist/ingress/runs.d.ts.map +1 -1
  55. package/dist/ingress/runs.js +4 -40
  56. package/dist/ingress/runs.js.map +1 -1
  57. package/dist/namespaces.d.ts +0 -15
  58. package/dist/namespaces.d.ts.map +1 -1
  59. package/dist/namespaces.js +0 -2
  60. package/dist/namespaces.js.map +1 -1
  61. package/dist/runtime/auth.d.ts.map +1 -1
  62. package/dist/runtime/auth.js +1 -20
  63. package/dist/runtime/auth.js.map +1 -1
  64. package/dist/runtime/channel.d.ts +0 -6
  65. package/dist/runtime/channel.d.ts.map +1 -1
  66. package/dist/runtime/channel.js.map +1 -1
  67. package/dist/runtime/identity-http.d.ts +0 -2
  68. package/dist/runtime/identity-http.d.ts.map +1 -1
  69. package/dist/runtime/identity-http.js +0 -35
  70. package/dist/runtime/identity-http.js.map +1 -1
  71. package/dist/runtime/index.d.ts.map +1 -1
  72. package/dist/runtime/index.js +0 -2
  73. package/dist/runtime/index.js.map +1 -1
  74. package/package.json +7 -7
  75. package/dist/channels/github/mentions.d.ts +0 -7
  76. package/dist/channels/github/mentions.d.ts.map +0 -1
  77. package/dist/channels/github/mentions.js +0 -112
  78. package/dist/channels/github/mentions.js.map +0 -1
  79. package/dist/channels/http/endpoint.d.ts +0 -77
  80. package/dist/channels/http/endpoint.d.ts.map +0 -1
  81. package/dist/channels/http/endpoint.js +0 -204
  82. package/dist/channels/http/endpoint.js.map +0 -1
  83. package/dist/channels/http/provider.d.ts +0 -110
  84. package/dist/channels/http/provider.d.ts.map +0 -1
  85. package/dist/channels/http/provider.js +0 -208
  86. package/dist/channels/http/provider.js.map +0 -1
  87. package/dist/channels/http/reply.d.ts +0 -20
  88. package/dist/channels/http/reply.d.ts.map +0 -1
  89. package/dist/channels/http/reply.js +0 -116
  90. package/dist/channels/http/reply.js.map +0 -1
  91. package/dist/channels/http/studio.d.ts +0 -23
  92. package/dist/channels/http/studio.d.ts.map +0 -1
  93. package/dist/channels/http/studio.js +0 -92
  94. package/dist/channels/http/studio.js.map +0 -1
  95. package/dist/channels/linear/connections.d.ts +0 -11
  96. package/dist/channels/linear/connections.d.ts.map +0 -1
  97. package/dist/channels/linear/connections.js +0 -14
  98. package/dist/channels/linear/connections.js.map +0 -1
  99. package/dist/channels/linear/graphql.d.ts +0 -57
  100. package/dist/channels/linear/graphql.d.ts.map +0 -1
  101. package/dist/channels/linear/graphql.js +0 -167
  102. package/dist/channels/linear/graphql.js.map +0 -1
  103. package/dist/channels/linear/index.d.ts +0 -9
  104. package/dist/channels/linear/index.d.ts.map +0 -1
  105. package/dist/channels/linear/index.js +0 -481
  106. package/dist/channels/linear/index.js.map +0 -1
  107. package/dist/channels/linear/schema.d.ts +0 -1064
  108. package/dist/channels/linear/schema.d.ts.map +0 -1
  109. package/dist/channels/linear/schema.js +0 -249
  110. package/dist/channels/linear/schema.js.map +0 -1
  111. package/dist/channels/linear/types.d.ts +0 -153
  112. package/dist/channels/linear/types.d.ts.map +0 -1
  113. package/dist/channels/linear/types.js +0 -2
  114. package/dist/channels/linear/types.js.map +0 -1
  115. package/dist/runtime/channel-icon.d.ts +0 -22
  116. package/dist/runtime/channel-icon.d.ts.map +0 -1
  117. package/dist/runtime/channel-icon.js +0 -70
  118. package/dist/runtime/channel-icon.js.map +0 -1
@@ -1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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwD3C,CAAC"}
@@ -1,249 +0,0 @@
1
- import { z } from "zod";
2
- import { nonblankStringSchema } from "../message-schema.js";
3
- // Shared scalar constraints. Linear identifiers are UUIDs, but only their
4
- // presence matters here.
5
- const optionalTextSchema = z.string().nullish();
6
- /** Receipt metadata only, not a complete Linear webhook payload specification. */
7
- export const linearReceiptSchema = z.object({
8
- deliveryId: nonblankStringSchema,
9
- payload: z.looseObject({
10
- type: nonblankStringSchema,
11
- action: nonblankStringSchema,
12
- organizationId: z.string().optional(),
13
- }),
14
- });
15
- const teamSchema = z.looseObject({
16
- id: nonblankStringSchema,
17
- key: nonblankStringSchema,
18
- name: z.string().optional(),
19
- });
20
- const actorSchema = z.looseObject({
21
- id: nonblankStringSchema,
22
- type: z.string().optional(),
23
- name: z.string().optional(),
24
- });
25
- // Payload subjects. Loose objects retain unmodeled provider fields.
26
- const issueSchema = z.looseObject({
27
- id: nonblankStringSchema,
28
- identifier: nonblankStringSchema,
29
- title: z.string(),
30
- description: optionalTextSchema,
31
- url: z.string().optional(),
32
- teamId: z.string().optional(),
33
- team: teamSchema.optional(),
34
- labelIds: z.array(z.string()).optional(),
35
- labels: z
36
- .array(z.looseObject({ id: z.string(), name: z.string() }))
37
- .optional(),
38
- botActor: z.unknown().optional(),
39
- });
40
- const commentSchema = z.looseObject({
41
- id: nonblankStringSchema,
42
- body: z.string(),
43
- issueId: nonblankStringSchema,
44
- parentId: z.string().nullish(),
45
- userId: z.string().nullish(),
46
- user: z
47
- .looseObject({ id: z.string(), name: z.string().optional() })
48
- .nullish(),
49
- issue: z
50
- .looseObject({
51
- id: nonblankStringSchema,
52
- identifier: z.string().optional(),
53
- title: z.string().optional(),
54
- url: z.string().optional(),
55
- team: teamSchema.optional(),
56
- })
57
- .optional(),
58
- botActor: z.unknown().optional(),
59
- });
60
- const sessionIssueSchema = z.looseObject({
61
- id: nonblankStringSchema,
62
- identifier: z.string().optional(),
63
- title: z.string().optional(),
64
- url: z.string().optional(),
65
- description: optionalTextSchema,
66
- team: teamSchema.optional(),
67
- });
68
- /** A Linear agent session: the app was mentioned or delegated an issue. */
69
- const agentSessionSchema = z.looseObject({
70
- id: nonblankStringSchema,
71
- status: z.string().optional(),
72
- url: z.string().optional(),
73
- issueId: z.string().nullish(),
74
- issue: sessionIssueSchema.nullish(),
75
- // The comment that started the session, when a mention did.
76
- commentId: z.string().nullish(),
77
- comment: z
78
- .looseObject({ id: nonblankStringSchema, body: z.string().optional() })
79
- .nullish(),
80
- creatorId: z.string().nullish(),
81
- creator: z
82
- .looseObject({ id: nonblankStringSchema, name: z.string().optional() })
83
- .nullish(),
84
- });
85
- /**
86
- * The activity content types Linear documents; one it adds later reads as
87
- * `unknown`. A user's reply is a `prompt`.
88
- */
89
- export const LINEAR_ACTIVITY_TYPES = [
90
- "prompt",
91
- "thought",
92
- "action",
93
- "response",
94
- "error",
95
- "elicitation",
96
- ];
97
- /**
98
- * The signals Linear documents on a user's activity; one it adds later reads
99
- * as `unknown`. `stop` asks the agent to stop.
100
- */
101
- export const LINEAR_PROMPT_SIGNALS = ["stop"];
102
- /** What a user said in a session: a reply, or a signal such as `stop`. */
103
- const agentActivitySchema = z.looseObject({
104
- content: z.looseObject({
105
- type: z.enum([...LINEAR_ACTIVITY_TYPES, "unknown"]).catch("unknown"),
106
- body: z.string().optional(),
107
- }),
108
- signal: z
109
- .enum([...LINEAR_PROMPT_SIGNALS, "unknown"])
110
- .catch("unknown")
111
- .nullish(),
112
- signalMetadata: z.unknown().optional(),
113
- sourceCommentId: z.string().nullish(),
114
- userId: z.string().nullish(),
115
- user: z
116
- .looseObject({ id: nonblankStringSchema, name: z.string().optional() })
117
- .nullish(),
118
- });
119
- // Common delivery context.
120
- const envelopeSchema = z.looseObject({
121
- organizationId: nonblankStringSchema,
122
- webhookId: z.string().optional(),
123
- webhookTimestamp: z.number(),
124
- createdAt: z.string().optional(),
125
- url: z.string().optional(),
126
- actor: actorSchema.optional(),
127
- });
128
- function dispatchEventSchema(key, payloadSchema) {
129
- return z.object({
130
- key: z.literal(key),
131
- deliveryId: nonblankStringSchema,
132
- payload: payloadSchema,
133
- });
134
- }
135
- /** Each supported event key requires its exact type, action and subject. */
136
- export const linearDispatchSchema = z.discriminatedUnion("key", [
137
- dispatchEventSchema("Issue.create", envelopeSchema.extend({
138
- type: z.literal("Issue"),
139
- action: z.literal("create"),
140
- data: issueSchema,
141
- })),
142
- dispatchEventSchema("Issue.update", envelopeSchema.extend({
143
- type: z.literal("Issue"),
144
- action: z.literal("update"),
145
- data: issueSchema,
146
- // The changed fields' previous values.
147
- updatedFrom: z.record(z.string(), z.unknown()).optional(),
148
- })),
149
- dispatchEventSchema("Comment.create", envelopeSchema.extend({
150
- type: z.literal("Comment"),
151
- action: z.literal("create"),
152
- data: commentSchema,
153
- })),
154
- dispatchEventSchema("AgentSessionEvent.created", envelopeSchema.extend({
155
- type: z.literal("AgentSessionEvent"),
156
- action: z.literal("created"),
157
- appUserId: z.string().optional(),
158
- agentSession: agentSessionSchema,
159
- // Linear's ready-made prompt: the issue, the thread and who asked.
160
- promptContext: z.string().nullish(),
161
- guidance: z.unknown().optional(),
162
- })),
163
- dispatchEventSchema("AgentSessionEvent.prompted", envelopeSchema.extend({
164
- type: z.literal("AgentSessionEvent"),
165
- action: z.literal("prompted"),
166
- appUserId: z.string().optional(),
167
- agentSession: agentSessionSchema,
168
- agentActivity: agentActivitySchema,
169
- })),
170
- ]);
171
- export const SUPPORTED_EVENT_KEYS = linearDispatchSchema.options.map((option) => option.shape.key.value);
172
- /** The issue an event is about, wherever its payload keeps it. */
173
- function eventIssue(event) {
174
- if (event.payload.type === "AgentSessionEvent") {
175
- const session = event.payload.agentSession;
176
- const id = session.issue?.id ?? session.issueId;
177
- // Linear opens sessions on issues; one without could not be answered.
178
- if (!id)
179
- throw new TypeError("Linear agent session has no issue");
180
- return { id, ...(session.issue?.team && { team: session.issue.team }) };
181
- }
182
- if (event.payload.type === "Comment") {
183
- const { data } = event.payload;
184
- return {
185
- id: data.issueId,
186
- ...(data.issue?.team && { team: data.issue.team }),
187
- };
188
- }
189
- const { data } = event.payload;
190
- return { id: data.id, ...(data.team && { team: data.team }) };
191
- }
192
- /**
193
- * Who acted: the webhook's actor, or for a session the user who started it or
194
- * replied in it.
195
- */
196
- function eventActor(event) {
197
- const payload = event.payload;
198
- const person = payload.type !== "AgentSessionEvent"
199
- ? payload.actor
200
- : payload.action === "prompted"
201
- ? (payload.agentActivity.user ??
202
- (payload.agentActivity.userId
203
- ? { id: payload.agentActivity.userId }
204
- : undefined))
205
- : (payload.agentSession.creator ??
206
- (payload.agentSession.creatorId
207
- ? { id: payload.agentSession.creatorId }
208
- : undefined));
209
- if (!person)
210
- return undefined;
211
- const { type, name } = person;
212
- return {
213
- id: person.id,
214
- ...(typeof type === "string" && { type }),
215
- ...(typeof name === "string" && { name }),
216
- };
217
- }
218
- /** Routing metadata every event exposes next to its payload. */
219
- function routing(event) {
220
- const issue = eventIssue(event);
221
- const actor = eventActor(event);
222
- return {
223
- organizationId: event.payload.organizationId,
224
- issueId: issue.id,
225
- ...(issue.team && {
226
- team: { id: issue.team.id, key: issue.team.key },
227
- }),
228
- ...(actor && { actor }),
229
- };
230
- }
231
- // Expose common routing metadata while preserving the original payload.
232
- export const linearEventSchema = linearDispatchSchema.transform((event) => {
233
- if (event.key === "AgentSessionEvent.created" ||
234
- event.key === "AgentSessionEvent.prompted")
235
- return {
236
- ...event,
237
- type: event.payload.type,
238
- action: event.payload.action,
239
- ...routing(event),
240
- sessionId: event.payload.agentSession.id,
241
- };
242
- return {
243
- ...event,
244
- type: event.payload.type,
245
- action: event.payload.action,
246
- ...routing(event),
247
- };
248
- });
249
- //# sourceMappingURL=schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/channels/linear/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,0EAA0E;AAC1E,yBAAyB;AACzB,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,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I,CAAC,GAAG,EAAE;SACjD,CAAC;QACF,GAAG,CAAC,KAAK,IAAI,EAAE,KAAK,EAAE,CAAC;KACxB,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE;IACxE,IACE,KAAK,CAAC,GAAG,KAAK,2BAA2B;QACzC,KAAK,CAAC,GAAG,KAAK,4BAA4B;QAE1C,OAAO;YACL,GAAG,KAAK;YACR,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;YACxB,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM;YAC5B,GAAG,OAAO,CAAC,KAAK,CAAC;YACjB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;SACzC,CAAC;IACJ,OAAO;QACL,GAAG,KAAK;QACR,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI;QACxB,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM;QAC5B,GAAG,OAAO,CAAC,KAAK,CAAC;KAClB,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -1,153 +0,0 @@
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
- import type { EventFinished } from "../http/provider.js";
6
- import type { EndpointRequest, EventEndpoint } from "../http/endpoint.js";
7
- /** Handwritten schema subsets; unmodeled provider fields remain unknown. */
8
- type EventUnion = z.output<typeof linearEventSchema>;
9
- export type LinearEventKey = EventUnion["key"];
10
- export type LinearEvent<K extends LinearEventKey = LinearEventKey> = Extract<EventUnion, {
11
- key: K;
12
- }>;
13
- export type LinearPayloadFor<K extends LinearEventKey> = LinearEvent<K>["payload"];
14
- /**
15
- * The conversation's thread an event belongs to. A handler runs before any
16
- * run exists, so this is not a run's runtime.
17
- */
18
- export interface LinearChannelThread {
19
- /**
20
- * The conversation's thread, the issue's or an agent session's, which the
21
- * run the handler starts runs on. Useful for run context that names the
22
- * thread, such as a token a backend signs for it.
23
- */
24
- id: string;
25
- channel: {
26
- name: string;
27
- };
28
- }
29
- /**
30
- * What an event handler returns: a run's input, as `agent.invoke` takes it —
31
- * a string, a message such as `new HumanMessage(...)`, state such as
32
- * `{ messages: [...] }`, or `[input, { context, metadata }]`. `null` or `undefined`
33
- * starts nothing.
34
- */
35
- export type LinearEventResult = ChannelRunResult | null | undefined | void;
36
- export type LinearEventCallback<K extends LinearEventKey> = (event: LinearEvent<K>, thread: LinearChannelThread) => LinearEventResult | Promise<LinearEventResult>;
37
- /** The Linear app `mda deploy` sets up: how it looks, and what it may do. */
38
- export interface LinearAppOptions {
39
- /**
40
- * The app's name, shown where people mention it and in its comments: 2–80
41
- * characters, without "Linear" or a URL. Defaults to the agent's name.
42
- *
43
- * Applies only when deploy creates the app. Linear has no API to change an
44
- * app, so changing it later does nothing: rename an existing app on its
45
- * settings page in Linear. Deploy reminds you when it keeps an existing app.
46
- */
47
- name?: string;
48
- /**
49
- * What the app does, shown when a workspace admin installs it: up to 1,000
50
- * characters. Like `name`, it applies only when deploy creates the app;
51
- * change an existing app's description on its settings page in Linear.
52
- */
53
- description?: string;
54
- /**
55
- * The app's icon: a PNG or JPEG image, as a path relative to `channels/`
56
- * like the Slack channel's `icon`, such as `assets/icon.png`. At least
57
- * 256×256 pixels and at most 1 MB. The deployment serves it at
58
- * `/channels/{name}/icon`, and deploy points the new app's icon there.
59
- * Like `name`, it applies only when deploy creates the app.
60
- */
61
- icon?: string;
62
- /**
63
- * Keys of the teams (as in `ENG-123`) the channel is limited to: events
64
- * about other teams' issues start nothing. Defaults to every team the app
65
- * can see. The app's token still reaches every team it was granted, so
66
- * limit its team access in Linear too.
67
- */
68
- teams?: string[];
69
- }
70
- /**
71
- * Options for `channels.linear(...)`: the app's scope and event handlers that
72
- * start runs. Each issue is one conversation, and each agent session on it
73
- * another.
74
- */
75
- export interface LinearChannelOptions {
76
- /** The Linear app `mda deploy` sets up: its name, description, icon and teams. */
77
- app?: LinearAppOptions;
78
- /**
79
- * What an event that starts a run does while its conversation already
80
- * runs: `enqueue` (the default) waits for the run and starts after it,
81
- * `interrupt` cancels the run, keeping its progress, and starts at once,
82
- * `rollback` cancels it and discards its progress, and `reject` starts
83
- * nothing.
84
- *
85
- * @example
86
- * ```ts
87
- * // A newer comment replaces the work on an older one.
88
- * channels.linear({ multitaskStrategy: "interrupt", onEvent })
89
- * ```
90
- */
91
- multitaskStrategy?: MultitaskStrategy;
92
- /**
93
- * Event handlers that start runs. Return a prompt (string, message, or
94
- * state), or nothing to skip. The run's final reply is posted as a comment
95
- * on the issue, under the comment that started it.
96
- *
97
- * @example
98
- * ```ts
99
- * { "Issue.create": (e) => `Triage ${e.payload.data.identifier}` }
100
- * ```
101
- *
102
- * In agent sessions the reply goes to the session instead.
103
- *
104
- * A handler may also be an endpoint, a URL or a `Request` carrying headers,
105
- * to have a service of yours decide: MDA POSTs it the event and its thread,
106
- * and starts the run it answers with. See the README's "Asking your service
107
- * what to start".
108
- */
109
- onEvent?: {
110
- [K in LinearEventKey]?: LinearEventCallback<K> | EventEndpoint;
111
- };
112
- /**
113
- * Answer Linear agent sessions, which open when someone mentions the app or
114
- * delegates an issue to it. Defaults to `true`. Without a handler, a new
115
- * session runs with Linear's prompt for it (`promptContext`), and a reply
116
- * in the session continues the conversation. The run's progress and reply
117
- * show in the session, and Stop cancels the run. A run that stops on
118
- * interrupts answers with a link to its thread in LangSmith Studio, where
119
- * they are resumed.
120
- *
121
- * @experimental Sessions use Linear's Agents API, a Developer Preview, so
122
- * they may change as Linear changes it.
123
- */
124
- sessions?: boolean;
125
- /**
126
- * Ignore changes made by other apps and integrations (a delivery whose
127
- * actor isn't a person, or the creation of an issue or comment with a
128
- * `botActor`), so automations don't trigger each other. Defaults to `true`.
129
- * The app's own changes are always ignored.
130
- */
131
- ignoreBots?: boolean;
132
- /**
133
- * A delivery of a handled event is done, once: with the run it started and
134
- * how that run ended, as LangGraph names it, and the decisions the thread
135
- * waits on. A delivery that started no run, such as a Stop or one whose
136
- * handler returned nothing, has no `run`. Called after the channel's own
137
- * activities, such as the session's elicitation or "Stopped.", in the
138
- * background; failures are logged. See `channels.http`'s `onFinish` for
139
- * its limits.
140
- *
141
- * @example
142
- * ```ts
143
- * onFinish: async (event, thread, { run }) => {
144
- * if (run?.status === "success") await reportRun(thread.id, run.id);
145
- * }
146
- * ```
147
- */
148
- onFinish?: EventFinished<LinearEvent, LinearChannelThread>;
149
- }
150
- /** What a Linear channel POSTs an endpoint, for one event key or any. */
151
- export type LinearEndpointRequest<K extends LinearEventKey = LinearEventKey> = EndpointRequest<LinearEvent<K>>;
152
- export {};
153
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
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;AACxD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE1E,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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;;;;;;;;OAeG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;CAC5D;AAED,yEAAyE;AACzE,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,IACzE,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/channels/linear/types.ts"],"names":[],"mappings":""}
@@ -1,22 +0,0 @@
1
- /** Largest icon a channel serves. */
2
- export declare const CHANNEL_ICON_MAX_BYTES: number;
3
- /** A channel icon read from the project, ready to serve. */
4
- export interface ChannelIcon {
5
- bytes: Uint8Array;
6
- contentType: string;
7
- }
8
- /**
9
- * Check an icon option: a path relative to the project's `channels/`, such as
10
- * `assets/icon.png`, of a PNG or JPEG image, as for the Slack channel's icon.
11
- * Returns the path with `/` separators.
12
- */
13
- export declare function validateChannelIconPath(path: string, option: string): string;
14
- /**
15
- * Read a channel's icon from `channels/` in the project at `root`. Only a PNG
16
- * or JPEG file inside `channels/`, of at most {@link CHANNEL_ICON_MAX_BYTES},
17
- * whose content matches its extension, is served; anything else throws.
18
- */
19
- export declare function loadChannelIcon(root: string, path: string): ChannelIcon;
20
- /** Headers for a served icon: an image that never runs as a page. */
21
- export declare function channelIconHeaders(icon: ChannelIcon): Record<string, string>;
22
- //# sourceMappingURL=channel-icon.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"channel-icon.d.ts","sourceRoot":"","sources":["../../src/runtime/channel-icon.ts"],"names":[],"mappings":"AAGA,qCAAqC;AACrC,eAAO,MAAM,sBAAsB,QAAc,CAAC;AAalD,4DAA4D;AAC5D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB;AASD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAgB5E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAuBvE;AAED,qEAAqE;AACrE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ5E"}
@@ -1,70 +0,0 @@
1
- import { readFileSync, realpathSync, statSync } from "node:fs";
2
- import { isAbsolute, relative, resolve, sep } from "node:path";
3
- /** Largest icon a channel serves. */
4
- export const CHANNEL_ICON_MAX_BYTES = 1024 * 1024;
5
- const ICON_TYPES = {
6
- png: {
7
- contentType: "image/png",
8
- magic: [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a],
9
- },
10
- jpg: { contentType: "image/jpeg", magic: [0xff, 0xd8, 0xff] },
11
- jpeg: { contentType: "image/jpeg", magic: [0xff, 0xd8, 0xff] },
12
- };
13
- function iconExtension(path) {
14
- const extension = /\.([a-z]+)$/i.exec(path)?.[1]?.toLowerCase();
15
- return extension && Object.hasOwn(ICON_TYPES, extension)
16
- ? extension
17
- : undefined;
18
- }
19
- /**
20
- * Check an icon option: a path relative to the project's `channels/`, such as
21
- * `assets/icon.png`, of a PNG or JPEG image, as for the Slack channel's icon.
22
- * Returns the path with `/` separators.
23
- */
24
- export function validateChannelIconPath(path, option) {
25
- const trimmed = path.trim();
26
- const segments = trimmed.split("/");
27
- if (!trimmed ||
28
- isAbsolute(trimmed) ||
29
- trimmed.includes("\\") ||
30
- segments.some((segment) => !segment || segment === "." || segment === "..") ||
31
- !iconExtension(trimmed))
32
- throw new TypeError(`${option} must be a path relative to channels/, such as assets/icon.png, of a PNG or JPEG image`);
33
- return trimmed;
34
- }
35
- /**
36
- * Read a channel's icon from `channels/` in the project at `root`. Only a PNG
37
- * or JPEG file inside `channels/`, of at most {@link CHANNEL_ICON_MAX_BYTES},
38
- * whose content matches its extension, is served; anything else throws.
39
- */
40
- export function loadChannelIcon(root, path) {
41
- const relativePath = validateChannelIconPath(path, "icon");
42
- const extension = iconExtension(relativePath);
43
- const realRoot = realpathSync(resolve(root, "channels"));
44
- // Resolve links before the containment check, so none leads out.
45
- const file = realpathSync(resolve(realRoot, relativePath));
46
- const inside = relative(realRoot, file);
47
- if (!inside || inside.split(sep)[0] === ".." || isAbsolute(inside))
48
- throw new Error("icon is outside channels/");
49
- const stats = statSync(file);
50
- if (!stats.isFile() ||
51
- stats.size === 0 ||
52
- stats.size > CHANNEL_ICON_MAX_BYTES)
53
- throw new Error(`icon must be a file of at most ${CHANNEL_ICON_MAX_BYTES} bytes`);
54
- const bytes = new Uint8Array(readFileSync(file));
55
- const { contentType, magic } = ICON_TYPES[extension];
56
- if (!magic.every((byte, index) => bytes[index] === byte))
57
- throw new Error(`icon is not a ${extension.toUpperCase()} image`);
58
- return { bytes, contentType };
59
- }
60
- /** Headers for a served icon: an image that never runs as a page. */
61
- export function channelIconHeaders(icon) {
62
- return {
63
- "Content-Type": icon.contentType,
64
- "Content-Length": String(icon.bytes.byteLength),
65
- "Cache-Control": "public, max-age=3600",
66
- "Content-Security-Policy": "default-src 'none'",
67
- "X-Content-Type-Options": "nosniff",
68
- };
69
- }
70
- //# sourceMappingURL=channel-icon.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"channel-icon.js","sourceRoot":"","sources":["../../src/runtime/channel-icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAE/D,qCAAqC;AACrC,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,GAAG,IAAI,CAAC;AAElD,MAAM,UAAU,GAAG;IACjB,GAAG,EAA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