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,77 +0,0 @@
1
- import { z } from "zod";
2
- import type { ChannelRunResult } from "../run-input.js";
3
- /**
4
- * The deployment's env var holding the secret it shares with your services:
5
- * every event endpoint request is signed with it, as Standard Webhooks does.
6
- * Several, separated by whitespace or commas, each sign the request, for
7
- * rotation.
8
- */
9
- export declare const SERVICE_SECRET_ENV = "MDA_SERVICE_SECRET";
10
- /**
11
- * Where an `onEvent` key's events go when a service of yours decides what
12
- * they start: its URL, or a `Request` that also carries headers, such as a
13
- * credential the service checks. See {@link endpointHandler}.
14
- */
15
- export type EventEndpoint = string | URL | Request;
16
- /** The key a Standard Webhooks secret stands for; a malformed one throws. */
17
- export declare function signingKey(secret: string): Buffer;
18
- /**
19
- * The Standard Webhooks headers that sign one request with `keys`: none
20
- * without a key. Each key signs `<id>.<timestamp>.<body>`.
21
- */
22
- export declare function signatureHeaders(keys: readonly Buffer[], id: string, timestamp: number, body: string): Record<string, string>;
23
- /** A channel's event, by the fields an endpoint is sent. */
24
- type ChannelEvent = {
25
- key: string;
26
- deliveryId: string;
27
- payload: unknown;
28
- };
29
- /**
30
- * The event a channel sends its endpoint: the event key, the provider's
31
- * delivery ID and its payload. For a union of events, the payload is typed by
32
- * the key.
33
- */
34
- export type EndpointEvent<E extends ChannelEvent = ChannelEvent> = E extends unknown ? Pick<E, "key" | "deliveryId" | "payload"> : never;
35
- /** The conversation's thread an endpoint request is about. */
36
- export interface EndpointThread {
37
- /** The thread the run starts on, or that waits on an interrupt. */
38
- id: string;
39
- channel: {
40
- name: string;
41
- };
42
- /** Set when the thread waits on an interrupt: no run starts, whatever the answer. */
43
- interrupted?: true;
44
- }
45
- /** What a channel POSTs its endpoint: the event, and the thread it belongs to. */
46
- export interface EndpointRequest<E extends ChannelEvent = ChannelEvent> {
47
- event: EndpointEvent<E>;
48
- thread: EndpointThread;
49
- }
50
- declare const answerSchema: z.ZodObject<{
51
- input: z.ZodCustom<import("../types.js").JsonValue, import("../types.js").JsonValue>;
52
- context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<import("../types.js").JsonValue, import("../types.js").JsonValue>>>;
53
- metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodCustom<import("../types.js").JsonValue, import("../types.js").JsonValue>>>;
54
- webhook: z.ZodOptional<z.ZodString>;
55
- }, z.core.$strict>;
56
- /**
57
- * What an endpoint answers: the run's input, as a handler returns it (text,
58
- * or state such as `{ messages }`), with the run options a handler may set,
59
- * all JSON. An endpoint answers `null` (or HTTP 204) instead to start nothing.
60
- * The channel checks an answer against the same schema.
61
- */
62
- export type EndpointAnswer = z.infer<typeof answerSchema>;
63
- /** Whether an `onEvent` value is an endpoint rather than a handler function. */
64
- export declare function isEventEndpoint(value: unknown): value is EventEndpoint;
65
- /**
66
- * The handler an endpoint stands for. When the event's thread takes a turn,
67
- * MDA POSTs `{ event: { key, deliveryId, payload }, thread: { id, channel,
68
- * interrupted? } }` as JSON to the endpoint's URL, with a `Request`'s headers,
69
- * signed when the deployment has `MDA_SERVICE_SECRET`, and starts the
70
- * run the service answers with: `{ input, context?, metadata?, webhook? }`.
71
- * `null` or HTTP 204 starts nothing. Any other answer, a
72
- * redirect, or no answer within 60 seconds fails the handler, as a handler
73
- * that throws does. The URL is http(s), without credentials in it.
74
- */
75
- export declare function endpointHandler(endpoint: EventEndpoint, label: string): (event: EndpointEvent, thread: EndpointThread) => Promise<ChannelRunResult | null>;
76
- export {};
77
- //# sourceMappingURL=endpoint.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"endpoint.d.ts","sourceRoot":"","sources":["../../../src/channels/http/endpoint.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAQxD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAQvD;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,GAAG,GAAG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AAe,CAC7B,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,MAAM,GACZ,CACD,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,cAAc,KACnB,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CA+CpC"}
@@ -1,204 +0,0 @@
1
- /**
2
- * Event endpoints: an `onEvent` value that is a URL or a `Request` rather than
3
- * a function. MDA asks that service of yours what the event starts, for logic
4
- * that lives outside the deployment.
5
- */
6
- import { createHmac } from "node:crypto";
7
- import { z } from "zod";
8
- import { jsonValueSchema } from "../message-schema.js";
9
- /** How long the service may take to answer. */
10
- const TIMEOUT_MS = 60_000;
11
- /** The largest answer read; run input may carry images. */
12
- const MAX_RESPONSE_BYTES = 10 * 1024 * 1024;
13
- const ANSWER_SHAPE = "event endpoint answer must be null or { input, context?, metadata?, webhook? }";
14
- /**
15
- * The deployment's env var holding the secret it shares with your services:
16
- * every event endpoint request is signed with it, as Standard Webhooks does.
17
- * Several, separated by whitespace or commas, each sign the request, for
18
- * rotation.
19
- */
20
- export const SERVICE_SECRET_ENV = "MDA_SERVICE_SECRET";
21
- /** Standard Webhooks' optional secret prefix. */
22
- const SECRET_PREFIX = "whsec_";
23
- /** The key sizes Standard Webhooks allows, in bytes. */
24
- const MIN_KEY_BYTES = 24;
25
- const MAX_KEY_BYTES = 64;
26
- const SECRET_SHAPE = `${SERVICE_SECRET_ENV} must hold Standard Webhooks secrets: padded base64 of 24 to 64 bytes, optionally prefixed with whsec_`;
27
- let cachedKeys;
28
- /** The signing keys `MDA_SERVICE_SECRET` holds; none when it's unset. */
29
- function signingKeys() {
30
- const secrets = process.env[SERVICE_SECRET_ENV]?.trim() ?? "";
31
- if (cachedKeys?.secrets !== secrets)
32
- cachedKeys = {
33
- secrets,
34
- // Stray separators, as rotation leaves behind, name no secret.
35
- keys: secrets
36
- .split(/[\s,]+/)
37
- .filter(Boolean)
38
- .map(signingKey),
39
- };
40
- return cachedKeys.keys;
41
- }
42
- /** The key a Standard Webhooks secret stands for; a malformed one throws. */
43
- export function signingKey(secret) {
44
- const encoded = secret.startsWith(SECRET_PREFIX)
45
- ? secret.slice(SECRET_PREFIX.length)
46
- : secret;
47
- // Buffer.from skips characters that aren't base64 and missing padding; the
48
- // round trip refuses both, as Standard Webhooks libraries' decoders do.
49
- const key = Buffer.from(encoded, "base64");
50
- if (!encoded ||
51
- key.toString("base64") !== encoded ||
52
- key.byteLength < MIN_KEY_BYTES ||
53
- key.byteLength > MAX_KEY_BYTES)
54
- throw new TypeError(SECRET_SHAPE);
55
- return key;
56
- }
57
- /**
58
- * The Standard Webhooks headers that sign one request with `keys`: none
59
- * without a key. Each key signs `<id>.<timestamp>.<body>`.
60
- */
61
- export function signatureHeaders(keys, id, timestamp, body) {
62
- if (!keys.length)
63
- return {};
64
- const signed = `${id}.${timestamp}.${body}`;
65
- return {
66
- "webhook-id": id,
67
- "webhook-timestamp": String(timestamp),
68
- "webhook-signature": keys
69
- .map((key) => `v1,${createHmac("sha256", key).update(signed).digest("base64")}`)
70
- .join(" "),
71
- };
72
- }
73
- const answerSchema = z.strictObject({
74
- input: jsonValueSchema,
75
- /** Run context, as `agent.invoke(input, { context })` takes it. */
76
- context: z.record(z.string(), jsonValueSchema).optional(),
77
- /** Metadata for the run; see `ChannelRunOptions`. */
78
- metadata: z.record(z.string(), jsonValueSchema).optional(),
79
- /** A URL the Agent Server POSTs the finished run to; see `ChannelRunOptions`. */
80
- webhook: z.string().optional(),
81
- });
82
- /** Whether an `onEvent` value is an endpoint rather than a handler function. */
83
- export function isEventEndpoint(value) {
84
- return (typeof value === "string" ||
85
- value instanceof URL ||
86
- value instanceof Request);
87
- }
88
- /**
89
- * The handler an endpoint stands for. When the event's thread takes a turn,
90
- * MDA POSTs `{ event: { key, deliveryId, payload }, thread: { id, channel,
91
- * interrupted? } }` as JSON to the endpoint's URL, with a `Request`'s headers,
92
- * signed when the deployment has `MDA_SERVICE_SECRET`, and starts the
93
- * run the service answers with: `{ input, context?, metadata?, webhook? }`.
94
- * `null` or HTTP 204 starts nothing. Any other answer, a
95
- * redirect, or no answer within 60 seconds fails the handler, as a handler
96
- * that throws does. The URL is http(s), without credentials in it.
97
- */
98
- export function endpointHandler(endpoint, label) {
99
- const template = endpoint instanceof Request ? endpoint : undefined;
100
- const target = endpointUrl(template ? template.url : String(endpoint), label);
101
- const baseHeaders = new Headers(template?.headers);
102
- baseHeaders.set("content-type", "application/json");
103
- baseHeaders.set("accept", "application/json");
104
- return async (event, thread) => {
105
- const request = {
106
- event: {
107
- key: event.key,
108
- deliveryId: event.deliveryId,
109
- payload: event.payload,
110
- },
111
- thread: {
112
- id: thread.id,
113
- channel: { name: thread.channel.name },
114
- ...(thread.interrupted && { interrupted: true }),
115
- },
116
- };
117
- // The exact bytes sent are the ones signed.
118
- const body = JSON.stringify(request);
119
- const headers = new Headers(baseHeaders);
120
- const signature = signatureHeaders(signingKeys(), `msg_${event.deliveryId}`, Math.floor(Date.now() / 1000), body);
121
- for (const [name, value] of Object.entries(signature))
122
- headers.set(name, value);
123
- const response = await fetch(target, {
124
- method: "POST",
125
- headers,
126
- body,
127
- redirect: "manual",
128
- signal: AbortSignal.timeout(TIMEOUT_MS),
129
- });
130
- if (response.status === 204) {
131
- await response.body?.cancel();
132
- return null;
133
- }
134
- if (!response.ok) {
135
- await response.body?.cancel();
136
- throw new Error(`event endpoint answered HTTP ${response.status}`);
137
- }
138
- return runResult(await boundedJson(response));
139
- };
140
- }
141
- function endpointUrl(url, label) {
142
- let parsed;
143
- try {
144
- parsed = new URL(url);
145
- }
146
- catch {
147
- parsed = undefined;
148
- }
149
- if (!parsed ||
150
- (parsed.protocol !== "https:" && parsed.protocol !== "http:") ||
151
- parsed.username ||
152
- parsed.password)
153
- throw new TypeError(`${label} must be an absolute http(s) URL, without credentials in it`);
154
- return parsed.href;
155
- }
156
- /** The answer as JSON, read only up to `MAX_RESPONSE_BYTES`. */
157
- async function boundedJson(response) {
158
- const declared = Number(response.headers.get("content-length"));
159
- if (declared > MAX_RESPONSE_BYTES) {
160
- await response.body?.cancel();
161
- throw new Error("event endpoint answer is too large");
162
- }
163
- const reader = response.body?.getReader();
164
- const chunks = [];
165
- let size = 0;
166
- for (;;) {
167
- const chunk = await reader?.read();
168
- if (!chunk || chunk.done)
169
- break;
170
- size += chunk.value.byteLength;
171
- if (size > MAX_RESPONSE_BYTES) {
172
- await reader?.cancel();
173
- throw new Error("event endpoint answer is too large");
174
- }
175
- chunks.push(chunk.value);
176
- }
177
- const text = new TextDecoder().decode(chunks.length === 1 ? chunks[0] : concat(chunks, size));
178
- try {
179
- return JSON.parse(text);
180
- }
181
- catch {
182
- throw new Error("event endpoint answer is not JSON");
183
- }
184
- }
185
- function concat(chunks, size) {
186
- const joined = new Uint8Array(size);
187
- let offset = 0;
188
- for (const chunk of chunks) {
189
- joined.set(chunk, offset);
190
- offset += chunk.byteLength;
191
- }
192
- return joined;
193
- }
194
- /** The run the answer names; the channel checks the input and options as a handler's. */
195
- function runResult(body) {
196
- const parsed = answerSchema.nullable().safeParse(body);
197
- if (!parsed.success)
198
- throw new Error(ANSWER_SHAPE);
199
- if (parsed.data === null)
200
- return null;
201
- const { input, ...options } = parsed.data;
202
- return (Object.keys(options).length ? [input, options] : input);
203
- }
204
- //# sourceMappingURL=endpoint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../../src/channels/http/endpoint.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,+CAA+C;AAC/C,MAAM,UAAU,GAAG,MAAM,CAAC;AAC1B,2DAA2D;AAC3D,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC5C,MAAM,YAAY,GAChB,gFAAgF,CAAC;AACnF;;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oB,EAAE,IAAY;IAChD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,yFAAyF;AACzF,SAAS,SAAS,CAAC,IAAa;IAC9B,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACvD,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IACnD,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC;IAC1C,OAAO,CACL,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CACnC,CAAC;AACxB,CAAC"}
@@ -1,110 +0,0 @@
1
- import type { JsonObject } from "../manifest.js";
2
- import type { JsonValue } from "../types.js";
3
- import type { ChannelRunResult } from "../run-input.js";
4
- import type { HttpChannel } from "./index.js";
5
- import type { HttpChannelAdapter, HttpFinishedDelivery } from "./types.js";
6
- import { type EventEndpoint } from "./endpoint.js";
7
- /** The channel's name in the project, or its provider before it has one. */
8
- export declare function channelName(channel: HttpChannel): string;
9
- /**
10
- * Check a channel's `onEvent` keys. The types limit them, but a JavaScript
11
- * caller or a cast gets no error, and a key nothing dispatches never runs.
12
- */
13
- export declare function checkEventKeys(provider: string, handlers: object, supported: ReadonlySet<string>): void;
14
- /**
15
- * A channel's `onEvent` with each endpoint, a URL or `Request`, replaced by
16
- * the handler it stands for, so the channel calls handlers alone. A bad
17
- * endpoint throws when the channel is declared.
18
- */
19
- export declare function resolveEndpoints<T extends object>(provider: string, onEvent: T | undefined): {
20
- [K in keyof T]: Exclude<T[K], EventEndpoint>;
21
- };
22
- /**
23
- * A provider channel's `onFinish`: a delivery of one of its events is done,
24
- * with the event, its thread, and the run it started and the decisions the
25
- * thread waits on; see `channels.http`'s `onFinish`.
26
- */
27
- export type EventFinished<E, T = EventThread> = (event: E, thread: T, finished: Pick<HttpFinishedDelivery, "run" | "interrupts">) => void | Promise<void>;
28
- /** The thread a provider channel's hooks hear about. */
29
- export interface EventThread {
30
- id: string;
31
- channel: {
32
- name: string;
33
- };
34
- }
35
- /**
36
- * The HTTP channel's `onFinish` for a provider channel: the channel's own
37
- * notice first, such as a link to a pending decision, then the user's hook,
38
- * for the deliveries whose event the channel parsed. A failing notice is
39
- * logged and doesn't keep the user's hook from running.
40
- */
41
- export declare function finishEvents<E>(notice: NonNullable<HttpChannelAdapter["onFinish"]>, onFinish: EventFinished<E> | undefined, parse: (rawEvent: JsonValue | undefined) => E | undefined, name: () => string): HttpChannelAdapter["onFinish"];
42
- /**
43
- * A provider channel's `onReceived`: a delivery of one of its events reached
44
- * its thread, before MDA reads the thread; see `channels.http`'s `onReceived`.
45
- */
46
- export type EventReceived<E, T = EventThread> = (event: E, thread: T) => void | Promise<void>;
47
- /**
48
- * The HTTP channel's `onReceived` for a provider channel's user hook, for the
49
- * deliveries whose event the channel parsed.
50
- */
51
- export declare function receiveEvents<E>(onReceived: EventReceived<E> | undefined, parse: (rawEvent: JsonValue | undefined) => E | undefined, name: () => string): HttpChannelAdapter["onReceived"];
52
- /** The events deploy subscribes the provider's webhook to: the handled ones. */
53
- export declare function handledEventKeys(handlers: object): string[];
54
- /**
55
- * The connection `mda deploy` stores for the provider's app, or one of the
56
- * values stored beside it, such as `webhook-secret`, when `suffix` is given.
57
- */
58
- export declare function appConnectionSlug(provider: string, deploymentId: string, suffix?: string): string;
59
- /**
60
- * A frozen copy of a parsed event, kept as the delivery's raw event so a
61
- * handler that changes its argument can't change what MDA keeps.
62
- */
63
- export declare function eventSnapshot(event: unknown, provider: string): JsonValue;
64
- /** App options for deploy, without unset fields. */
65
- export declare function definedFields(fields: Record<string, JsonValue | undefined>): JsonObject;
66
- /**
67
- * Whether `signature`, a hex HMAC-SHA256 the caller checked the format of,
68
- * signs `rawBody` with `secret`. Compared in constant time.
69
- */
70
- export declare function verifyHmacSha256(secret: string, rawBody: Uint8Array, signature: string): boolean;
71
- /**
72
- * A value read at most every `ttlMs(value)` milliseconds. Concurrent callers
73
- * share the read in flight; a failed read is not kept, so the next call reads
74
- * again.
75
- */
76
- export declare class CachedRead<T> {
77
- #private;
78
- private readonly read;
79
- private readonly ttlMs;
80
- constructor(read: () => Promise<T>, ttlMs: (value: T) => number);
81
- get(): Promise<T>;
82
- /** Read again on the next call. */
83
- reset(): void;
84
- }
85
- /**
86
- * A value `mda deploy` stored for the deployment, such as a webhook secret:
87
- * the `env` override when set, otherwise the agent secret Agent Auth keeps at
88
- * `slug(deploymentId)`. Only a missing connection reads as `undefined`, and is
89
- * logged as `label`; credential store failures propagate.
90
- */
91
- export declare function readDeploymentSecret(env: string, slug: (deploymentId: string) => string, label: string): Promise<string | undefined>;
92
- /** Forget values read from Agent Auth; for tests. */
93
- export declare function resetDeploymentSecrets(): void;
94
- /** What an event's handler did: returned run input, skipped, or threw. */
95
- export type EventHandlerOutcome = {
96
- type: "input";
97
- input: ChannelRunResult;
98
- } | {
99
- type: "skipped";
100
- } | {
101
- type: "failed";
102
- };
103
- /** What an event handler returns: run input, or nothing to skip. */
104
- export type EventHandlerResult = ChannelRunResult | null | undefined | void;
105
- /** Run an event's handler. A throw is logged, not raised. */
106
- export declare function runEventHandler(provider: string, event: {
107
- key: string;
108
- deliveryId: string;
109
- }, call: () => EventHandlerResult | Promise<EventHandlerResult>): Promise<EventHandlerOutcome>;
110
- //# sourceMappingURL=provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/channels/http/provider.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE3E,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAOvB,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAC7B,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,EAC/C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,CAAC,GAAG,SAAS,GACrB;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC;CAAE,CASlD;AAED;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,GAAG,WAAW,IAAI,CAC9C,KAAK,EAAE,CAAC,EACR,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,IAAI,CAAC,oBAAoB,EAAE,KAAK,GAAG,YAAY,CAAC,KACvD,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAE1B,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1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,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,GAC3D,OAAO,CAAC,mBAAmB,CAAC,CAgB9B"}
@@ -1,208 +0,0 @@
1
- /**
2
- * What webhook channels built on `httpChannel`, such as GitHub and Linear,
3
- * share: their name, the events they subscribe to, the secrets they read from
4
- * Agent Auth, signature checks, running an event's handler, and the hooks
5
- * that hand their typed events to the user.
6
- */
7
- import { createHmac, timingSafeEqual } from "node:crypto";
8
- import { isJsonValue } from "../message-schema.js";
9
- import { immutableCopy } from "../runtime.js";
10
- import { logger } from "../../runtime/log.js";
11
- import { endpointHandler, isEventEndpoint, } from "./endpoint.js";
12
- import { ConnectionNotFoundError, DEPLOYMENT_ID_ENV, connections, } from "../../connections.js";
13
- /** The channel's name in the project, or its provider before it has one. */
14
- export function channelName(channel) {
15
- return channel.name ?? channel.kind;
16
- }
17
- /**
18
- * Check a channel's `onEvent` keys. The types limit them, but a JavaScript
19
- * caller or a cast gets no error, and a key nothing dispatches never runs.
20
- */
21
- export function checkEventKeys(provider, handlers, supported) {
22
- const unknown = Object.keys(handlers).filter((key) => !supported.has(key));
23
- if (unknown.length)
24
- throw new TypeError(`unsupported ${provider} event key ${unknown.sort().join(", ")}`);
25
- }
26
- /**
27
- * A channel's `onEvent` with each endpoint, a URL or `Request`, replaced by
28
- * the handler it stands for, so the channel calls handlers alone. A bad
29
- * endpoint throws when the channel is declared.
30
- */
31
- export function resolveEndpoints(provider, onEvent) {
32
- return Object.fromEntries(Object.entries(onEvent ?? {}).map(([key, value]) => [
33
- key,
34
- isEventEndpoint(value)
35
- ? endpointHandler(value, `${provider} onEvent["${key}"]`)
36
- : value,
37
- ]));
38
- }
39
- /**
40
- * The HTTP channel's `onFinish` for a provider channel: the channel's own
41
- * notice first, such as a link to a pending decision, then the user's hook,
42
- * for the deliveries whose event the channel parsed. A failing notice is
43
- * logged and doesn't keep the user's hook from running.
44
- */
45
- export function finishEvents(notice, onFinish, parse, name) {
46
- return async (target, delivery) => {
47
- try {
48
- await notice(target, delivery);
49
- }
50
- catch (error) {
51
- logger.error(`channel finish notice failed (${logger.safeErrorLabel(error)})`);
52
- }
53
- const event = onFinish && parse(delivery.rawEvent);
54
- if (event === undefined)
55
- return;
56
- await onFinish?.(event, { id: delivery.threadId, channel: { name: name() } }, {
57
- ...(delivery.run && { run: delivery.run }),
58
- interrupts: delivery.interrupts,
59
- });
60
- };
61
- }
62
- /**
63
- * The HTTP channel's `onReceived` for a provider channel's user hook, for the
64
- * deliveries whose event the channel parsed.
65
- */
66
- export function receiveEvents(onReceived, parse, name) {
67
- if (!onReceived)
68
- return undefined;
69
- return async (_target, delivery) => {
70
- const event = parse(delivery.rawEvent);
71
- if (event === undefined)
72
- return;
73
- await onReceived(event, {
74
- id: delivery.threadId,
75
- channel: { name: name() },
76
- });
77
- };
78
- }
79
- /** The events deploy subscribes the provider's webhook to: the handled ones. */
80
- export function handledEventKeys(handlers) {
81
- return Object.entries(handlers)
82
- .filter(([, handler]) => handler !== undefined)
83
- .map(([key]) => key)
84
- .sort();
85
- }
86
- /**
87
- * The connection `mda deploy` stores for the provider's app, or one of the
88
- * values stored beside it, such as `webhook-secret`, when `suffix` is given.
89
- */
90
- export function appConnectionSlug(provider, deploymentId, suffix) {
91
- const slug = `mda/${provider}-app/${deploymentId}`;
92
- return suffix ? `${slug}/${suffix}` : slug;
93
- }
94
- /**
95
- * A frozen copy of a parsed event, kept as the delivery's raw event so a
96
- * handler that changes its argument can't change what MDA keeps.
97
- */
98
- export function eventSnapshot(event, provider) {
99
- if (!isJsonValue(event))
100
- throw new TypeError(`invalid ${provider} event`);
101
- return immutableCopy(event);
102
- }
103
- /** App options for deploy, without unset fields. */
104
- export function definedFields(fields) {
105
- const defined = {};
106
- for (const [key, value] of Object.entries(fields))
107
- if (value !== undefined)
108
- defined[key] = value;
109
- return defined;
110
- }
111
- /**
112
- * Whether `signature`, a hex HMAC-SHA256 the caller checked the format of,
113
- * signs `rawBody` with `secret`. Compared in constant time.
114
- */
115
- export function verifyHmacSha256(secret, rawBody, signature) {
116
- const expected = createHmac("sha256", secret).update(rawBody).digest();
117
- const given = Buffer.from(signature, "hex");
118
- return given.length === expected.length && timingSafeEqual(expected, given);
119
- }
120
- /**
121
- * A value read at most every `ttlMs(value)` milliseconds. Concurrent callers
122
- * share the read in flight; a failed read is not kept, so the next call reads
123
- * again.
124
- */
125
- export class CachedRead {
126
- read;
127
- ttlMs;
128
- #entry;
129
- constructor(read, ttlMs) {
130
- this.read = read;
131
- this.ttlMs = ttlMs;
132
- }
133
- get() {
134
- if (this.#entry && this.#entry.expiresAt > Date.now())
135
- return this.#entry.value;
136
- const entry = {
137
- value: this.read().then((value) => {
138
- entry.expiresAt = Date.now() + this.ttlMs(value);
139
- return value;
140
- }, (error) => {
141
- if (this.#entry === entry)
142
- this.#entry = undefined;
143
- throw error;
144
- }),
145
- expiresAt: Number.POSITIVE_INFINITY,
146
- };
147
- this.#entry = entry;
148
- return entry.value;
149
- }
150
- /** Read again on the next call. */
151
- reset() {
152
- this.#entry = undefined;
153
- }
154
- }
155
- /** How long a value read from Agent Auth is reused before it is read again. */
156
- const SECRET_TTL_MS = 5 * 60_000;
157
- /** How long a missing value is remembered, so unsigned traffic can't hammer Agent Auth. */
158
- const MISSING_SECRET_TTL_MS = 60_000;
159
- const deploymentSecrets = new Map();
160
- /**
161
- * A value `mda deploy` stored for the deployment, such as a webhook secret:
162
- * the `env` override when set, otherwise the agent secret Agent Auth keeps at
163
- * `slug(deploymentId)`. Only a missing connection reads as `undefined`, and is
164
- * logged as `label`; credential store failures propagate.
165
- */
166
- export function readDeploymentSecret(env, slug, label) {
167
- const override = process.env[env]?.trim();
168
- if (override)
169
- return Promise.resolve(override);
170
- const deploymentId = process.env[DEPLOYMENT_ID_ENV]?.trim();
171
- if (!deploymentId)
172
- return Promise.resolve(undefined);
173
- const key = slug(deploymentId);
174
- let cached = deploymentSecrets.get(key);
175
- if (!cached) {
176
- cached = new CachedRead(() => connections.resolveDeploymentSecret(key).catch((error) => {
177
- if (!(error instanceof ConnectionNotFoundError))
178
- throw error;
179
- logger.error(`${label} is not stored in Agent Auth`);
180
- return undefined;
181
- }), (value) => (value === undefined ? MISSING_SECRET_TTL_MS : SECRET_TTL_MS));
182
- deploymentSecrets.set(key, cached);
183
- }
184
- return cached.get();
185
- }
186
- /** Forget values read from Agent Auth; for tests. */
187
- export function resetDeploymentSecrets() {
188
- deploymentSecrets.clear();
189
- }
190
- /** Run an event's handler. A throw is logged, not raised. */
191
- export async function runEventHandler(provider, event, call) {
192
- const receipt = JSON.stringify({
193
- event: logger.logIdentifier(event.key),
194
- deliveryId: logger.logIdentifier(event.deliveryId),
195
- });
196
- try {
197
- const input = await call();
198
- if (input === undefined || input === null)
199
- return { type: "skipped" };
200
- logger.info(`${provider} handler returned run input ${receipt}`);
201
- return { type: "input", input };
202
- }
203
- catch (error) {
204
- logger.error(`${provider.toLowerCase()} callback failed ${receipt} (${logger.safeErrorLabel(error)})`);
205
- return { type: "failed" };
206
- }
207
- }
208
- //# sourceMappingURL=provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/channels/http/provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EACL,eAAe,EACf,eAAe,GAEhB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAE9B,4EAA4E;AAC5E,MAAM,UAAU,WAAW,CAAC,OAAoB;IAC9C,OAAO,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;AACtC,CAAC;AA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AU,CAAC;KACnD,CAAC,CAAC;IACH,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,IAAI,EAAE,CAAC;QAC3B,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QACtE,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,+BAA+B,OAAO,EAAE,CAAC,CAAC;QACjE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CACV,GAAG,QAAQ,CAAC,WAAW,EAAE,oBAAoB,OAAO,KAAK,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CACzF,CAAC;QACF,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC5B,CAAC;AACH,CAAC"}
@@ -1,20 +0,0 @@
1
- import { z } from "zod";
2
- import type { JsonValue } from "../types.js";
3
- /**
4
- * Where the thread's latest channel delivery came from, kept in its state.
5
- * Private (the leading `_`), so it's never part of a run's input or output.
6
- */
7
- export declare const CHANNEL_REPLY_STATE_KEY = "_mda_channel_reply";
8
- /**
9
- * Remember a channel delivery's target in the thread's state, and post the
10
- * answer to it when the agent finishes. A run that stops on `interrupt()` or
11
- * is cancelled doesn't finish, so it posts nothing; the run that resumes it
12
- * carries no delivery, so it answers the remembered target.
13
- */
14
- export declare function createChannelReplyMiddleware(): import("langchain").AgentMiddleware<z.ZodObject<{
15
- _mda_channel_reply: z.ZodOptional<z.ZodObject<{
16
- name: z.ZodString;
17
- target: z.ZodCustom<JsonValue, JsonValue>;
18
- }, z.core.$strip>>;
19
- }, z.core.$strip>, undefined, unknown, readonly (import("@langchain/core/tools").ServerTool | import("@langchain/core/tools").ClientTool)[], readonly []>;
20
- //# sourceMappingURL=reply.d.ts.map