managed-deepagents 0.10.0-dev.6 → 0.10.0-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -58
- package/dist/channels/github/connections.d.ts.map +1 -1
- package/dist/channels/github/connections.js +2 -2
- package/dist/channels/github/connections.js.map +1 -1
- package/dist/channels/github/index.d.ts +1 -1
- package/dist/channels/github/index.d.ts.map +1 -1
- package/dist/channels/github/index.js +42 -89
- package/dist/channels/github/index.js.map +1 -1
- package/dist/channels/github/schema.d.ts.map +1 -1
- package/dist/channels/github/schema.js +1 -3
- package/dist/channels/github/schema.js.map +1 -1
- package/dist/channels/github/types.d.ts +18 -10
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/http/http.d.ts.map +1 -1
- package/dist/channels/http/http.js +92 -95
- package/dist/channels/http/http.js.map +1 -1
- package/dist/channels/http/index.d.ts +1 -1
- package/dist/channels/http/index.d.ts.map +1 -1
- package/dist/channels/http/index.js +9 -0
- package/dist/channels/http/index.js.map +1 -1
- package/dist/channels/http/ingress.d.ts +26 -11
- package/dist/channels/http/ingress.d.ts.map +1 -1
- package/dist/channels/http/ingress.js +19 -34
- package/dist/channels/http/ingress.js.map +1 -1
- package/dist/channels/http/provider.d.ts +68 -0
- package/dist/channels/http/provider.d.ts.map +1 -0
- package/dist/channels/http/provider.js +149 -0
- package/dist/channels/http/provider.js.map +1 -0
- package/dist/channels/http/studio.d.ts +7 -5
- package/dist/channels/http/studio.d.ts.map +1 -1
- package/dist/channels/http/studio.js +12 -12
- package/dist/channels/http/studio.js.map +1 -1
- package/dist/channels/http/types.d.ts +27 -15
- package/dist/channels/http/types.d.ts.map +1 -1
- package/dist/channels/linear/connections.d.ts.map +1 -1
- package/dist/channels/linear/connections.js +2 -2
- package/dist/channels/linear/connections.js.map +1 -1
- package/dist/channels/linear/graphql.d.ts +5 -17
- package/dist/channels/linear/graphql.d.ts.map +1 -1
- package/dist/channels/linear/graphql.js +55 -57
- package/dist/channels/linear/graphql.js.map +1 -1
- package/dist/channels/linear/index.d.ts +1 -1
- package/dist/channels/linear/index.d.ts.map +1 -1
- package/dist/channels/linear/index.js +133 -146
- package/dist/channels/linear/index.js.map +1 -1
- package/dist/channels/linear/schema.d.ts +173 -144
- package/dist/channels/linear/schema.d.ts.map +1 -1
- package/dist/channels/linear/schema.js +45 -12
- package/dist/channels/linear/schema.js.map +1 -1
- package/dist/channels/linear/types.d.ts +21 -21
- package/dist/channels/linear/types.d.ts.map +1 -1
- package/dist/channels/message-schema.d.ts +2 -0
- package/dist/channels/message-schema.d.ts.map +1 -1
- package/dist/channels/message-schema.js +4 -0
- package/dist/channels/message-schema.js.map +1 -1
- package/dist/channels/run-input.d.ts +3 -9
- package/dist/channels/run-input.d.ts.map +1 -1
- package/dist/channels/run-input.js +7 -17
- package/dist/channels/run-input.js.map +1 -1
- package/dist/channels/trigger/client.js +7 -3
- package/dist/channels/trigger/client.js.map +1 -1
- package/dist/channels/trigger/http.d.ts.map +1 -1
- package/dist/channels/trigger/http.js +6 -3
- package/dist/channels/trigger/http.js.map +1 -1
- package/dist/channels/trigger/tracing-project.d.ts +16 -0
- package/dist/channels/trigger/tracing-project.d.ts.map +1 -0
- package/dist/channels/trigger/tracing-project.js +54 -0
- package/dist/channels/trigger/tracing-project.js.map +1 -0
- package/dist/channels/trigger/types.d.ts +6 -0
- package/dist/channels/trigger/types.d.ts.map +1 -1
- package/dist/channels/trigger/types.js.map +1 -1
- package/dist/connections.d.ts +6 -0
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +27 -0
- package/dist/connections.js.map +1 -1
- package/dist/connectors/mcp/index.d.ts.map +1 -1
- package/dist/connectors/mcp/index.js +52 -2
- package/dist/connectors/mcp/index.js.map +1 -1
- package/dist/credential-gate.d.ts.map +1 -1
- package/dist/credential-gate.js +13 -3
- package/dist/credential-gate.js.map +1 -1
- package/dist/identity/options.d.ts +0 -9
- package/dist/identity/options.d.ts.map +1 -1
- package/dist/identity/options.js +1 -6
- package/dist/identity/options.js.map +1 -1
- package/dist/identity/types.d.ts +0 -6
- package/dist/identity/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ingress/runs.d.ts +2 -4
- package/dist/ingress/runs.d.ts.map +1 -1
- package/dist/ingress/runs.js +5 -6
- package/dist/ingress/runs.js.map +1 -1
- package/dist/runtime/auth.d.ts +0 -9
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +2 -55
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/schedule-auth.d.ts +1 -1
- package/dist/runtime/schedule-auth.d.ts.map +1 -1
- package/dist/runtime/schedule-auth.js +12 -4
- package/dist/runtime/schedule-auth.js.map +1 -1
- package/dist/runtime-schedules.js +6 -6
- package/dist/runtime-schedules.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/** HTTP content and reply handling around the shared ingress run lifecycle. */
|
|
2
2
|
import { INTERRUPT } from "@langchain/langgraph";
|
|
3
3
|
import { HumanMessage, } from "@langchain/core/messages";
|
|
4
|
-
import { extractAssistantContent } from "../assistant-text.js";
|
|
5
4
|
import { logger } from "../../runtime/log.js";
|
|
6
5
|
import { buildIngressRunContext } from "../../ingress/index.js";
|
|
7
6
|
import { ChannelError } from "../errors.js";
|
|
8
|
-
import { validateMessage } from "../runtime.js";
|
|
9
7
|
import { createIngressLoopbackClient, hasLoopbackCredential, } from "../../ingress/loopback.js";
|
|
10
8
|
import { DELIVERY_KEY_METADATA, cancelIngressRuns, ingressThreadState, lookupStatus, startIngressRun, waitForIdleThread, observeIngressRun, recordThreadDelivery, } from "../../ingress/runs.js";
|
|
11
9
|
/** Wait until the thread's queued and running runs have finished. */
|
|
@@ -19,7 +17,7 @@ export async function waitForHttpIngressThread(input) {
|
|
|
19
17
|
}
|
|
20
18
|
/**
|
|
21
19
|
* Cancel the thread's queued and running runs, keeping their progress.
|
|
22
|
-
* Returns
|
|
20
|
+
* Returns the IDs of the runs it cancelled.
|
|
23
21
|
*/
|
|
24
22
|
export async function cancelHttpIngressRuns(input) {
|
|
25
23
|
if (!hasLoopbackCredential()) {
|
|
@@ -38,9 +36,6 @@ export async function startHttpIngressAgent(input) {
|
|
|
38
36
|
sourceProvider: input.sourceProvider ?? input.binding.provider,
|
|
39
37
|
});
|
|
40
38
|
const { state, assistantId } = await ingressThreadState(client, input.threadId, input.deliveryKey);
|
|
41
|
-
const deliveryMetadata = input.deliveryKey !== undefined
|
|
42
|
-
? { [DELIVERY_KEY_METADATA]: input.deliveryKey }
|
|
43
|
-
: undefined;
|
|
44
39
|
// A new turn would abandon the decision the thread waits on.
|
|
45
40
|
if (state === "paused")
|
|
46
41
|
return {
|
|
@@ -59,17 +54,19 @@ export async function startHttpIngressAgent(input) {
|
|
|
59
54
|
: await input.prepare?.();
|
|
60
55
|
if (!prepared)
|
|
61
56
|
return { skipped: "ignored" };
|
|
57
|
+
// The handler's metadata goes under MDA's own.
|
|
58
|
+
const metadata = {
|
|
59
|
+
...prepared.metadata,
|
|
60
|
+
...(input.deliveryKey !== undefined && {
|
|
61
|
+
[DELIVERY_KEY_METADATA]: input.deliveryKey,
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
62
64
|
let started;
|
|
63
65
|
try {
|
|
64
|
-
// The handler's metadata goes under MDA's own.
|
|
65
|
-
const metadata = prepared.metadata || deliveryMetadata
|
|
66
|
-
? { ...prepared.metadata, ...deliveryMetadata }
|
|
67
|
-
: undefined;
|
|
68
66
|
started = await startIngressRun(client, {
|
|
69
67
|
threadId: input.threadId,
|
|
70
68
|
assistantId: input.assistantId,
|
|
71
|
-
...(metadata && { metadata }),
|
|
72
|
-
...(prepared.webhook !== undefined && { webhook: prepared.webhook }),
|
|
69
|
+
...(Object.keys(metadata).length && { metadata }),
|
|
73
70
|
multitaskStrategy: strategy,
|
|
74
71
|
messages: prepared.messages,
|
|
75
72
|
...(Object.keys(prepared.state).length && { state: prepared.state }),
|
|
@@ -150,26 +147,23 @@ export async function observeHttpIngressAgent(input) {
|
|
|
150
147
|
if (lookupStatus(error) !== 404)
|
|
151
148
|
throw error;
|
|
152
149
|
logger.info(`channel run was replaced ${JSON.stringify({ threadId: input.threadId })}`);
|
|
153
|
-
return {
|
|
150
|
+
return { type: "replaced" };
|
|
154
151
|
}
|
|
155
152
|
const { values, status } = observed;
|
|
156
153
|
// A cancelled run ends `interrupted` too; only pending interrupts pause.
|
|
157
154
|
const paused = async () => {
|
|
158
155
|
const { state, assistantId } = await ingressThreadState(client, input.threadId);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
: status === "interrupted" && { cancelled: true }),
|
|
166
|
-
};
|
|
156
|
+
if (state === "paused")
|
|
157
|
+
return {
|
|
158
|
+
type: "paused",
|
|
159
|
+
...(assistantId !== undefined && { assistantId }),
|
|
160
|
+
};
|
|
161
|
+
return { type: status === "interrupted" ? "cancelled" : "answered" };
|
|
167
162
|
};
|
|
168
163
|
if (status === "interrupted")
|
|
169
164
|
return await paused();
|
|
170
|
-
if (status !== "success")
|
|
171
|
-
|
|
172
|
-
}
|
|
165
|
+
if (status !== "success")
|
|
166
|
+
return { type: "failed" };
|
|
173
167
|
const state = values && typeof values === "object" && !Array.isArray(values)
|
|
174
168
|
? values
|
|
175
169
|
: {};
|
|
@@ -180,15 +174,6 @@ export async function observeHttpIngressAgent(input) {
|
|
|
180
174
|
// A run that stops on `interrupt()` can still end `success`.
|
|
181
175
|
if (interrupted)
|
|
182
176
|
return await paused();
|
|
183
|
-
|
|
184
|
-
if (content === null)
|
|
185
|
-
return { replyContent: null, threadId: input.threadId, runId: input.runId };
|
|
186
|
-
const reply = { type: "content", content };
|
|
187
|
-
validateMessage(reply);
|
|
188
|
-
return {
|
|
189
|
-
replyContent: reply.content,
|
|
190
|
-
threadId: input.threadId,
|
|
191
|
-
runId: input.runId,
|
|
192
|
-
};
|
|
177
|
+
return { type: "answered" };
|
|
193
178
|
}
|
|
194
179
|
//# sourceMappingURL=ingress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingress.js","sourceRoot":"","sources":["../../../src/channels/http/ingress.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EACL,YAAY,GAGb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ingress.js","sourceRoot":"","sources":["../../../src/channels/http/ingress.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EACL,YAAY,GAGb,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,GAErB,MAAM,uBAAuB,CAAC;AA6C/B,qEAAqE;AACrE,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,KAA+C;IAE/C,MAAM,MAAM,GAAG,2BAA2B,CAAC;QACzC,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ;KAC/D,CAAC,CAAC;IACH,MAAM,iBAAiB,CAAC,MAAM,EAAE,KAAK,CAAC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I,EAAE,QAAQ;gBACd,GAAG,CAAC,WAAW,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,CAAC;aAClD,CAAC;QACJ,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,aAAa,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC;IACvE,CAAC,CAAC;IACF,IAAI,MAAM,KAAK,aAAa;QAAE,OAAO,MAAM,MAAM,EAAE,CAAC;IACpD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IACpD,MAAM,KAAK,GACT,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAC5D,CAAC,CAAE,MAAkC;QACrC,CAAC,CAAC,EAAE,CAAC;IACT,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IACpC,MAAM,WAAW,GACf,UAAU;QACV,OAAO,UAAU,KAAK,QAAQ;QAC9B,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACrC,6DAA6D;IAC7D,IAAI,WAAW;QAAE,OAAO,MAAM,MAAM,EAAE,CAAC;IACvC,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
/** The channel's name in the project, or its provider before it has one. */
|
|
6
|
+
export declare function channelName(channel: HttpChannel): string;
|
|
7
|
+
/**
|
|
8
|
+
* Check a channel's `onEvent` keys. The types limit them, but a JavaScript
|
|
9
|
+
* caller or a cast gets no error, and a key nothing dispatches never runs.
|
|
10
|
+
*/
|
|
11
|
+
export declare function checkEventKeys(provider: string, handlers: object, supported: ReadonlySet<string>): void;
|
|
12
|
+
/** The events deploy subscribes the provider's webhook to: the handled ones. */
|
|
13
|
+
export declare function handledEventKeys(handlers: object): string[];
|
|
14
|
+
/**
|
|
15
|
+
* The connection `mda deploy` stores for the provider's app, or one of the
|
|
16
|
+
* values stored beside it, such as `webhook-secret`, when `suffix` is given.
|
|
17
|
+
*/
|
|
18
|
+
export declare function appConnectionSlug(provider: string, deploymentId: string, suffix?: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* A frozen copy of a parsed event, kept as the delivery's raw event so a
|
|
21
|
+
* handler that changes its argument can't change what MDA keeps.
|
|
22
|
+
*/
|
|
23
|
+
export declare function eventSnapshot(event: unknown, provider: string): JsonValue;
|
|
24
|
+
/** App options for deploy, without unset fields. */
|
|
25
|
+
export declare function definedFields(fields: Record<string, JsonValue | undefined>): JsonObject;
|
|
26
|
+
/**
|
|
27
|
+
* Whether `signature`, a hex HMAC-SHA256 the caller checked the format of,
|
|
28
|
+
* signs `rawBody` with `secret`. Compared in constant time.
|
|
29
|
+
*/
|
|
30
|
+
export declare function verifyHmacSha256(secret: string, rawBody: Uint8Array, signature: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* A value read at most every `ttlMs(value)` milliseconds. Concurrent callers
|
|
33
|
+
* share the read in flight; a failed read is not kept, so the next call reads
|
|
34
|
+
* again.
|
|
35
|
+
*/
|
|
36
|
+
export declare class CachedRead<T> {
|
|
37
|
+
#private;
|
|
38
|
+
private readonly read;
|
|
39
|
+
private readonly ttlMs;
|
|
40
|
+
constructor(read: () => Promise<T>, ttlMs: (value: T) => number);
|
|
41
|
+
get(): Promise<T>;
|
|
42
|
+
/** Read again on the next call. */
|
|
43
|
+
reset(): void;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A value `mda deploy` stored for the deployment, such as a webhook secret:
|
|
47
|
+
* the `env` override when set, otherwise the agent secret Agent Auth keeps at
|
|
48
|
+
* `slug(deploymentId)`. Only a missing connection reads as `undefined`, and is
|
|
49
|
+
* logged as `label`; credential store failures propagate.
|
|
50
|
+
*/
|
|
51
|
+
export declare function readDeploymentSecret(env: string, slug: (deploymentId: string) => string, label: string): Promise<string | undefined>;
|
|
52
|
+
/** Forget values read from Agent Auth; for tests. */
|
|
53
|
+
export declare function resetDeploymentSecrets(): void;
|
|
54
|
+
/** What an event's handler did: returned run input, skipped, or threw. */
|
|
55
|
+
export type EventHandlerOutcome = {
|
|
56
|
+
type: "input";
|
|
57
|
+
input: ChannelRunResult;
|
|
58
|
+
} | {
|
|
59
|
+
type: "skipped";
|
|
60
|
+
} | {
|
|
61
|
+
type: "failed";
|
|
62
|
+
};
|
|
63
|
+
/** Run an event's handler. A throw is logged, not raised. */
|
|
64
|
+
export declare function runEventHandler(provider: string, event: {
|
|
65
|
+
key: string;
|
|
66
|
+
deliveryId: string;
|
|
67
|
+
}, call: () => unknown): Promise<EventHandlerOutcome>;
|
|
68
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/channels/http/provider.ts"],"names":[],"mappings":"AAOA,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;AAQ9C,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,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,QAA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AE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB,6DAA6D;AAC7D,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EAC1C,IAAI,EAAE,MAAM,OAAO,GAClB,OAAO,CAAC,mBAAmB,CAAC,CAgB9B"}
|
|
@@ -0,0 +1,149 @@
|
|
|
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, and running an event's handler.
|
|
5
|
+
*/
|
|
6
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
7
|
+
import { isJsonValue } from "../message-schema.js";
|
|
8
|
+
import { immutableCopy } from "../runtime.js";
|
|
9
|
+
import { logger } from "../../runtime/log.js";
|
|
10
|
+
import { ConnectionNotFoundError, DEPLOYMENT_ID_ENV, connections, } from "../../connections.js";
|
|
11
|
+
/** The channel's name in the project, or its provider before it has one. */
|
|
12
|
+
export function channelName(channel) {
|
|
13
|
+
return channel.name ?? channel.kind;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check a channel's `onEvent` keys. The types limit them, but a JavaScript
|
|
17
|
+
* caller or a cast gets no error, and a key nothing dispatches never runs.
|
|
18
|
+
*/
|
|
19
|
+
export function checkEventKeys(provider, handlers, supported) {
|
|
20
|
+
const unknown = Object.keys(handlers).filter((key) => !supported.has(key));
|
|
21
|
+
if (unknown.length)
|
|
22
|
+
throw new TypeError(`unsupported ${provider} event key ${unknown.sort().join(", ")}`);
|
|
23
|
+
}
|
|
24
|
+
/** The events deploy subscribes the provider's webhook to: the handled ones. */
|
|
25
|
+
export function handledEventKeys(handlers) {
|
|
26
|
+
return Object.entries(handlers)
|
|
27
|
+
.filter(([, handler]) => handler !== undefined)
|
|
28
|
+
.map(([key]) => key)
|
|
29
|
+
.sort();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The connection `mda deploy` stores for the provider's app, or one of the
|
|
33
|
+
* values stored beside it, such as `webhook-secret`, when `suffix` is given.
|
|
34
|
+
*/
|
|
35
|
+
export function appConnectionSlug(provider, deploymentId, suffix) {
|
|
36
|
+
const slug = `mda/${provider}-app/${deploymentId}`;
|
|
37
|
+
return suffix ? `${slug}/${suffix}` : slug;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A frozen copy of a parsed event, kept as the delivery's raw event so a
|
|
41
|
+
* handler that changes its argument can't change what MDA keeps.
|
|
42
|
+
*/
|
|
43
|
+
export function eventSnapshot(event, provider) {
|
|
44
|
+
if (!isJsonValue(event))
|
|
45
|
+
throw new TypeError(`invalid ${provider} event`);
|
|
46
|
+
return immutableCopy(event);
|
|
47
|
+
}
|
|
48
|
+
/** App options for deploy, without unset fields. */
|
|
49
|
+
export function definedFields(fields) {
|
|
50
|
+
return Object.fromEntries(Object.entries(fields).filter(([, value]) => value !== undefined));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether `signature`, a hex HMAC-SHA256 the caller checked the format of,
|
|
54
|
+
* signs `rawBody` with `secret`. Compared in constant time.
|
|
55
|
+
*/
|
|
56
|
+
export function verifyHmacSha256(secret, rawBody, signature) {
|
|
57
|
+
const expected = createHmac("sha256", secret).update(rawBody).digest();
|
|
58
|
+
const given = Buffer.from(signature, "hex");
|
|
59
|
+
return given.length === expected.length && timingSafeEqual(expected, given);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A value read at most every `ttlMs(value)` milliseconds. Concurrent callers
|
|
63
|
+
* share the read in flight; a failed read is not kept, so the next call reads
|
|
64
|
+
* again.
|
|
65
|
+
*/
|
|
66
|
+
export class CachedRead {
|
|
67
|
+
read;
|
|
68
|
+
ttlMs;
|
|
69
|
+
#entry;
|
|
70
|
+
constructor(read, ttlMs) {
|
|
71
|
+
this.read = read;
|
|
72
|
+
this.ttlMs = ttlMs;
|
|
73
|
+
}
|
|
74
|
+
get() {
|
|
75
|
+
if (this.#entry && this.#entry.expiresAt > Date.now())
|
|
76
|
+
return this.#entry.value;
|
|
77
|
+
const entry = {
|
|
78
|
+
value: this.read().then((value) => {
|
|
79
|
+
entry.expiresAt = Date.now() + this.ttlMs(value);
|
|
80
|
+
return value;
|
|
81
|
+
}, (error) => {
|
|
82
|
+
if (this.#entry === entry)
|
|
83
|
+
this.#entry = undefined;
|
|
84
|
+
throw error;
|
|
85
|
+
}),
|
|
86
|
+
expiresAt: Number.POSITIVE_INFINITY,
|
|
87
|
+
};
|
|
88
|
+
this.#entry = entry;
|
|
89
|
+
return entry.value;
|
|
90
|
+
}
|
|
91
|
+
/** Read again on the next call. */
|
|
92
|
+
reset() {
|
|
93
|
+
this.#entry = undefined;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** How long a value read from Agent Auth is reused before it is read again. */
|
|
97
|
+
const SECRET_TTL_MS = 5 * 60_000;
|
|
98
|
+
/** How long a missing value is remembered, so unsigned traffic can't hammer Agent Auth. */
|
|
99
|
+
const MISSING_SECRET_TTL_MS = 60_000;
|
|
100
|
+
const deploymentSecrets = new Map();
|
|
101
|
+
/**
|
|
102
|
+
* A value `mda deploy` stored for the deployment, such as a webhook secret:
|
|
103
|
+
* the `env` override when set, otherwise the agent secret Agent Auth keeps at
|
|
104
|
+
* `slug(deploymentId)`. Only a missing connection reads as `undefined`, and is
|
|
105
|
+
* logged as `label`; credential store failures propagate.
|
|
106
|
+
*/
|
|
107
|
+
export function readDeploymentSecret(env, slug, label) {
|
|
108
|
+
const override = process.env[env]?.trim();
|
|
109
|
+
if (override)
|
|
110
|
+
return Promise.resolve(override);
|
|
111
|
+
const deploymentId = process.env[DEPLOYMENT_ID_ENV]?.trim();
|
|
112
|
+
if (!deploymentId)
|
|
113
|
+
return Promise.resolve(undefined);
|
|
114
|
+
const key = slug(deploymentId);
|
|
115
|
+
let cached = deploymentSecrets.get(key);
|
|
116
|
+
if (!cached) {
|
|
117
|
+
cached = new CachedRead(() => connections.resolveDeploymentSecret(key).catch((error) => {
|
|
118
|
+
if (!(error instanceof ConnectionNotFoundError))
|
|
119
|
+
throw error;
|
|
120
|
+
logger.error(`${label} is not stored in Agent Auth`);
|
|
121
|
+
return undefined;
|
|
122
|
+
}), (value) => (value === undefined ? MISSING_SECRET_TTL_MS : SECRET_TTL_MS));
|
|
123
|
+
deploymentSecrets.set(key, cached);
|
|
124
|
+
}
|
|
125
|
+
return cached.get();
|
|
126
|
+
}
|
|
127
|
+
/** Forget values read from Agent Auth; for tests. */
|
|
128
|
+
export function resetDeploymentSecrets() {
|
|
129
|
+
deploymentSecrets.clear();
|
|
130
|
+
}
|
|
131
|
+
/** Run an event's handler. A throw is logged, not raised. */
|
|
132
|
+
export async function runEventHandler(provider, event, call) {
|
|
133
|
+
const receipt = JSON.stringify({
|
|
134
|
+
event: logger.logIdentifier(event.key),
|
|
135
|
+
deliveryId: logger.logIdentifier(event.deliveryId),
|
|
136
|
+
});
|
|
137
|
+
try {
|
|
138
|
+
const input = (await call());
|
|
139
|
+
if (input === undefined || input === null)
|
|
140
|
+
return { type: "skipped" };
|
|
141
|
+
logger.info(`${provider} handler returned run input ${receipt}`);
|
|
142
|
+
return { type: "input", input };
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
logger.error(`${provider.toLowerCase()} callback failed ${receipt} (${logger.safeErrorLabel(error)})`);
|
|
146
|
+
return { type: "failed" };
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/channels/http/provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,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K,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,13 +1,15 @@
|
|
|
1
|
-
import type { HttpChannelRunInfo } from "./types.js";
|
|
1
|
+
import type { HttpChannelRunInfo, HttpInterruptedReason } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* The thread in the deployment's Studio, or the deployment's page when the
|
|
4
4
|
* deployment's name or the thread's assistant is unknown. The LangSmith UI is
|
|
5
5
|
* the one `mda deploy` recorded for the deployment's environment
|
|
6
6
|
* (`MDA_LANGSMITH_URL`); without it there is nothing to link to.
|
|
7
|
-
*
|
|
8
|
-
* A platform that serves its own Studio for the deployment, such as the local
|
|
9
|
-
* stack, names it in `MDA_STUDIO_URL`; the link then opens that Studio on the
|
|
10
|
-
* thread.
|
|
11
7
|
*/
|
|
12
8
|
export declare function studioUrl(run: HttpChannelRunInfo | undefined, env?: NodeJS.ProcessEnv): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* What a channel tells the conversation when its thread waits on a decision,
|
|
11
|
+
* with a link to the thread in Studio, where the decision is made. `again`
|
|
12
|
+
* says how to continue once it is made, such as "comment again".
|
|
13
|
+
*/
|
|
14
|
+
export declare function interruptedNotice(reason: HttpInterruptedReason, run: HttpChannelRunInfo, again: string): string;
|
|
13
15
|
//# sourceMappingURL=studio.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio.d.ts","sourceRoot":"","sources":["../../../src/channels/http/studio.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"studio.d.ts","sourceRoot":"","sources":["../../../src/channels/http/studio.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAS5E;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,kBAAkB,GAAG,SAAS,EACnC,GAAG,oBAAc,GAChB,MAAM,GAAG,SAAS,CAsBpB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,qBAAqB,EAC7B,GAAG,EAAE,kBAAkB,EACvB,KAAK,EAAE,MAAM,GACZ,MAAM,CAMR"}
|
|
@@ -12,22 +12,10 @@ const GRAPH_NAMESPACE = "6ba7b821-9dad-11d1-80b4-00c04fd430c8";
|
|
|
12
12
|
* deployment's name or the thread's assistant is unknown. The LangSmith UI is
|
|
13
13
|
* the one `mda deploy` recorded for the deployment's environment
|
|
14
14
|
* (`MDA_LANGSMITH_URL`); without it there is nothing to link to.
|
|
15
|
-
*
|
|
16
|
-
* A platform that serves its own Studio for the deployment, such as the local
|
|
17
|
-
* stack, names it in `MDA_STUDIO_URL`; the link then opens that Studio on the
|
|
18
|
-
* thread.
|
|
19
15
|
*/
|
|
20
16
|
export function studioUrl(run, env = process.env) {
|
|
21
17
|
const threadId = run?.threadId;
|
|
22
18
|
const thread = threadId && UUID_PATTERN.test(threadId) ? threadId : undefined;
|
|
23
|
-
const standalone = parseHttpUrl(env.MDA_STUDIO_URL);
|
|
24
|
-
if (standalone) {
|
|
25
|
-
if (thread) {
|
|
26
|
-
standalone.searchParams.set("threadId", thread);
|
|
27
|
-
standalone.searchParams.set("mode", "chat");
|
|
28
|
-
}
|
|
29
|
-
return standalone.href;
|
|
30
|
-
}
|
|
31
19
|
const workspace = env.LANGSMITH_TENANT_ID?.trim() ?? "";
|
|
32
20
|
const deployment = env[DEPLOYMENT_ID_ENV]?.trim() ?? "";
|
|
33
21
|
if (!UUID_PATTERN.test(workspace) || !UUID_PATTERN.test(deployment))
|
|
@@ -49,6 +37,18 @@ export function studioUrl(run, env = process.env) {
|
|
|
49
37
|
});
|
|
50
38
|
return `${origin}/o/${workspace}/a/${encodeURIComponent(name)}/studio/thread?${query}`;
|
|
51
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* What a channel tells the conversation when its thread waits on a decision,
|
|
42
|
+
* with a link to the thread in Studio, where the decision is made. `again`
|
|
43
|
+
* says how to continue once it is made, such as "comment again".
|
|
44
|
+
*/
|
|
45
|
+
export function interruptedNotice(reason, run, again) {
|
|
46
|
+
const url = studioUrl(run);
|
|
47
|
+
const studio = url ? `[LangSmith Studio](${url})` : "LangSmith Studio";
|
|
48
|
+
return reason === "stopped"
|
|
49
|
+
? `I need a decision before I continue. Review the pending step in ${studio}.`
|
|
50
|
+
: `I'm waiting for a decision on an earlier step in this conversation, so I haven't read this yet. Review the pending step in ${studio}, then ${again}.`;
|
|
51
|
+
}
|
|
52
52
|
/**
|
|
53
53
|
* Studio opens an assistant by its ID. Channels start runs by graph ID, whose
|
|
54
54
|
* default assistant the Agent Server derives from it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studio.js","sourceRoot":"","sources":["../../../src/channels/http/studio.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGzE,MAAM,YAAY,GAChB,iEAAiE,CAAC;AACpE,MAAM,uBAAuB,GAAG,oCAAoC,CAAC;AACrE,MAAM,gBAAgB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C,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,KAAyB;IAC7C,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE;QAAE,OAAO,SAAS,CAAC;IACrC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAClC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC;YAC5D,CAAC,GAAG,CAAC,QAAQ;YACb,CAAC,GAAG,CAAC,QAAQ;YACb,CAAC,CAAC,GAAG;YACL,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -19,6 +19,13 @@ export interface HttpChannelInboundMessage {
|
|
|
19
19
|
*/
|
|
20
20
|
deliveryKey?: string;
|
|
21
21
|
}
|
|
22
|
+
/** The thread a `cancel` result stops, and who to tell. */
|
|
23
|
+
export interface HttpChannelCancelMessage {
|
|
24
|
+
userId: string;
|
|
25
|
+
threadId: string;
|
|
26
|
+
/** Where to report the stop. */
|
|
27
|
+
target: JsonValue;
|
|
28
|
+
}
|
|
22
29
|
export type HttpChannelParseResult = {
|
|
23
30
|
type: "message";
|
|
24
31
|
message: HttpChannelInboundMessage;
|
|
@@ -31,11 +38,10 @@ export type HttpChannelParseResult = {
|
|
|
31
38
|
} | {
|
|
32
39
|
/**
|
|
33
40
|
* Stop the work on the message's thread: MDA cancels its queued and
|
|
34
|
-
* running runs, keeping their progress, then calls `onCancelled`.
|
|
35
|
-
* message needs no `content`.
|
|
41
|
+
* running runs, keeping their progress, then calls `onCancelled`.
|
|
36
42
|
*/
|
|
37
43
|
type: "cancel";
|
|
38
|
-
message:
|
|
44
|
+
message: HttpChannelCancelMessage;
|
|
39
45
|
rawEvent?: JsonValue;
|
|
40
46
|
response?: Response;
|
|
41
47
|
};
|
|
@@ -61,6 +67,11 @@ export interface HttpChannelAdapter {
|
|
|
61
67
|
* either way.
|
|
62
68
|
*/
|
|
63
69
|
multitaskStrategy?: MultitaskStrategy;
|
|
70
|
+
/**
|
|
71
|
+
* Why `onInterrupted` is called; by default only `"waiting"`. Add `"stopped"` to
|
|
72
|
+
* also hear when the run a delivery started stops on interrupts.
|
|
73
|
+
*/
|
|
74
|
+
interruptedReasons?: readonly HttpInterruptedReason[];
|
|
64
75
|
verify(context: HttpChannelRequest): boolean | Promise<boolean>;
|
|
65
76
|
/** Decode the verified request body in the provider's format. */
|
|
66
77
|
parse(context: HttpChannelRequest): HttpChannelParseResult | Promise<HttpChannelParseResult>;
|
|
@@ -69,16 +80,20 @@ export interface HttpChannelAdapter {
|
|
|
69
80
|
/**
|
|
70
81
|
* What a message without `content` starts a run with, asked only once the
|
|
71
82
|
* thread takes a new turn, never while it waits on an interrupt. `null` or
|
|
72
|
-
* `undefined` starts nothing.
|
|
73
|
-
* came in, which never reaches the run.
|
|
83
|
+
* `undefined` starts nothing.
|
|
74
84
|
*/
|
|
75
|
-
input?(message: HttpChannelInboundMessage, rawEvent: JsonValue | undefined
|
|
85
|
+
input?(message: HttpChannelInboundMessage, rawEvent: JsonValue | undefined): ChannelRunResult | null | undefined | Promise<ChannelRunResult | null | undefined>;
|
|
76
86
|
/**
|
|
77
|
-
* The thread waits on a decision
|
|
78
|
-
*
|
|
79
|
-
*
|
|
87
|
+
* The thread waits on a decision. Tell the sender where to make it (Studio
|
|
88
|
+
* resumes interrupts). Failures are logged. `reason` says why:
|
|
89
|
+
*
|
|
90
|
+
* - `"waiting"`: a message arrived while the thread waits, so MDA started
|
|
91
|
+
* no run.
|
|
92
|
+
* - `"stopped"`: the run this delivery started just stopped on interrupts.
|
|
93
|
+
*
|
|
94
|
+
* It is called only for the reasons in `interruptedReasons`.
|
|
80
95
|
*/
|
|
81
|
-
|
|
96
|
+
onInterrupted?(target: JsonValue, run: HttpChannelRunInfo, reason: HttpInterruptedReason): Promise<void>;
|
|
82
97
|
/**
|
|
83
98
|
* A verified message reached its thread, before MDA starts or queues
|
|
84
99
|
* anything for it, and whatever it then does. For providers that
|
|
@@ -101,12 +116,9 @@ export interface HttpChannelRunInfo {
|
|
|
101
116
|
assistantId?: string;
|
|
102
117
|
/** The provider event of the delivery the notice is about, when parsed. */
|
|
103
118
|
rawEvent?: JsonValue;
|
|
104
|
-
/**
|
|
105
|
-
* For `onPaused`: the delivery's own run just stopped on interrupts, rather
|
|
106
|
-
* than the message arriving while the thread already waited.
|
|
107
|
-
*/
|
|
108
|
-
stopped?: true;
|
|
109
119
|
}
|
|
120
|
+
/** Why `onInterrupted` is called; see {@link HttpChannelAdapter.onInterrupted}. */
|
|
121
|
+
export type HttpInterruptedReason = "waiting" | "stopped";
|
|
110
122
|
export interface HttpChannelRequest {
|
|
111
123
|
request: Request;
|
|
112
124
|
rawBody: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/channels/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,MAAM,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,sBAAsB,GAC9B;IACE,IAAI,EAAE,SA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C,CAAC;IACjD;;;;;;;;;OASG;IACH,aAAa,CAAC,CACZ,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,kBAAkB,EACvB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE;;;OAGG;IACH,WAAW,CAAC,CACV,MAAM,EAAE,SAAS,EACjB,GAAG,EAAE,kBAAkB,GAAG;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAC9C,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAED,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,mFAAmF;AACnF,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,SAAS,CAAC;AAE1D,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,UAAU,CAAC;CACrB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../../src/channels/linear/connections.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connections.d.ts","sourceRoot":"","sources":["../../../src/channels/linear/connections.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,iBAAiB,qBAAqB,CAAC;AAEpD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAER"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { appConnectionSlug } from "../http/provider.js";
|
|
1
2
|
/**
|
|
2
3
|
* Reserved agent connection for the deployment's Linear app: reading it
|
|
3
4
|
* returns the app's access token, which Agent Auth renews.
|
|
@@ -8,7 +9,6 @@ export const LINEAR_TOKEN_SLUG = "mda/linear-token";
|
|
|
8
9
|
* beside it (`webhook-secret`) when `suffix` is given.
|
|
9
10
|
*/
|
|
10
11
|
export function linearAppConnectionSlug(deploymentId, suffix) {
|
|
11
|
-
|
|
12
|
-
return suffix ? `${slug}/${suffix}` : slug;
|
|
12
|
+
return appConnectionSlug("linear", deploymentId, suffix);
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=connections.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../src/channels/linear/connections.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAoB,EACpB,MAAe;IAEf,
|
|
1
|
+
{"version":3,"file":"connections.js","sourceRoot":"","sources":["../../../src/channels/linear/connections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAoB,EACpB,MAAe;IAEf,OAAO,iBAAiB,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
/** Linear refused a request for exceeding its rate limit. */
|
|
2
3
|
export declare class LinearRateLimitError extends Error {
|
|
3
4
|
constructor();
|
|
@@ -7,19 +8,14 @@ export declare function resetLinearToken(): void;
|
|
|
7
8
|
/**
|
|
8
9
|
* Run a GraphQL operation as the app. `query` is a constant; everything that
|
|
9
10
|
* varies goes in `variables`. A rejected token is read again once. Returns
|
|
10
|
-
* the response's `data`.
|
|
11
|
+
* the response's `data`, checked against `schema`.
|
|
11
12
|
*/
|
|
12
|
-
export declare function linearRequest<T>(query: string, variables
|
|
13
|
+
export declare function linearRequest<T>(query: string, variables: Record<string, unknown>, schema: z.ZodType<T>): Promise<T>;
|
|
13
14
|
/** The Linear user the app acts as. */
|
|
14
15
|
export type LinearAppUser = {
|
|
15
16
|
id: string;
|
|
16
17
|
displayName: string;
|
|
17
18
|
};
|
|
18
|
-
/**
|
|
19
|
-
* The Linear user the app acts as, read once per process: its own comments
|
|
20
|
-
* and changes are ignored, and a comment mentioning its `displayName` starts
|
|
21
|
-
* an agent session.
|
|
22
|
-
*/
|
|
23
19
|
export declare function linearAppUser(): Promise<LinearAppUser>;
|
|
24
20
|
/** Forget the cached app user; for tests. */
|
|
25
21
|
export declare function resetLinearAppUser(): void;
|
|
@@ -41,23 +37,15 @@ export declare function commentInAgentSession(commentId: string): Promise<boolea
|
|
|
41
37
|
export type LinearActivityContent = {
|
|
42
38
|
type: "thought" | "response" | "error" | "elicitation";
|
|
43
39
|
body: string;
|
|
44
|
-
} | {
|
|
45
|
-
type: "action";
|
|
46
|
-
action: string;
|
|
47
|
-
parameter: string;
|
|
48
|
-
result?: string;
|
|
49
40
|
};
|
|
50
41
|
/**
|
|
51
|
-
* Post an activity to an agent session as the app. `ephemeral`
|
|
52
|
-
*
|
|
53
|
-
* options to choose from.
|
|
42
|
+
* Post an activity to an agent session as the app. An `ephemeral` thought is
|
|
43
|
+
* replaced by the next activity.
|
|
54
44
|
*/
|
|
55
45
|
export declare function createLinearActivity(input: {
|
|
56
46
|
agentSessionId: string;
|
|
57
47
|
content: LinearActivityContent;
|
|
58
48
|
ephemeral?: boolean;
|
|
59
|
-
signal?: "select" | "auth";
|
|
60
|
-
signalMetadata?: Record<string, unknown>;
|
|
61
49
|
}): Promise<{
|
|
62
50
|
id: string;
|
|
63
51
|
}>;
|