managed-deepagents 0.10.0-dev.6 → 0.10.0-dev.8
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 +100 -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 +52 -93
- 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 +38 -10
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/http/forward.d.ts +13 -0
- package/dist/channels/http/forward.d.ts.map +1 -0
- package/dist/channels/http/forward.js +128 -0
- package/dist/channels/http/forward.js.map +1 -0
- package/dist/channels/http/http.d.ts.map +1 -1
- package/dist/channels/http/http.js +94 -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 +83 -0
- package/dist/channels/http/provider.d.ts.map +1 -0
- package/dist/channels/http/provider.js +176 -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 +53 -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 +162 -160
- 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 +42 -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/channels/github/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/channels/github/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,sBAAsB,aAA8B,CAAC;AAElE,gFAAgF;AAChF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;iBAW9B,CAAC;AAsFH,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAEL,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { nonblankStringSchema } from "../message-schema.js";
|
|
2
3
|
// Shared scalar constraints. Dispatch IDs are positive safe integers.
|
|
3
|
-
const nonblankStringSchema = z
|
|
4
|
-
.string()
|
|
5
|
-
.refine((value) => value.trim().length > 0);
|
|
6
4
|
const nullableTextSchema = z.string().nullable();
|
|
7
5
|
export const githubIdentifierSchema = z.number().int().positive();
|
|
8
6
|
/** Receipt metadata only, not a complete GitHub event payload specification. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/channels/github/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/channels/github/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE5D,sEAAsE;AACtE,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC;AACjD,MAAM,CA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,CAAC"}
|
|
@@ -2,6 +2,7 @@ import type { z } from "zod";
|
|
|
2
2
|
import type { MultitaskStrategy } from "../../ingress/runs.js";
|
|
3
3
|
import type { githubEventSchema } from "./schema.js";
|
|
4
4
|
import type { ChannelRunResult } from "../run-input.js";
|
|
5
|
+
import type { EventForward } from "../http/provider.js";
|
|
5
6
|
/** Handwritten schema subsets; unmodeled provider fields remain unknown. */
|
|
6
7
|
type EventUnion = z.output<typeof githubEventSchema>;
|
|
7
8
|
export type SupportedEventKey = EventUnion["key"];
|
|
@@ -9,28 +10,36 @@ export type GitHubEvent<K extends SupportedEventKey = SupportedEventKey> = Extra
|
|
|
9
10
|
key: K;
|
|
10
11
|
}>;
|
|
11
12
|
export type PayloadFor<K extends SupportedEventKey> = GitHubEvent<K>["payload"];
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* The conversation's thread an event belongs to. A handler runs before any
|
|
15
|
+
* run exists, so this is not a run's runtime.
|
|
16
|
+
*/
|
|
17
|
+
export interface GitHubChannelThread {
|
|
18
|
+
/**
|
|
19
|
+
* The thread's ID: the one a run the handler starts runs on, or, when
|
|
20
|
+
* `interrupted`, the one that waits. Useful for run context that names the
|
|
21
|
+
* thread, such as a token a backend signs for it.
|
|
22
|
+
*/
|
|
23
|
+
id: string;
|
|
13
24
|
channel: {
|
|
14
25
|
name: string;
|
|
15
26
|
};
|
|
16
|
-
/** The conversation's thread, which the run starts on. */
|
|
17
|
-
threadId: string;
|
|
18
27
|
/**
|
|
19
|
-
* Set when the
|
|
20
|
-
*
|
|
21
|
-
*
|
|
28
|
+
* Set when the thread waits on an interrupt. No run starts: what the
|
|
29
|
+
* handler returns only decides whether the App tells the issue or pull
|
|
30
|
+
* request that a decision is pending, so skip side effects such as
|
|
22
31
|
* reactions.
|
|
23
32
|
*/
|
|
24
|
-
|
|
33
|
+
interrupted?: true;
|
|
25
34
|
}
|
|
26
35
|
/**
|
|
27
36
|
* What an event handler returns: a run's input, as `agent.invoke` takes it —
|
|
28
37
|
* a string, a message such as `new HumanMessage(...)`, state such as
|
|
29
|
-
* `{ messages: [...] }`, or `[input, { context }]`. `null` or `undefined`
|
|
38
|
+
* `{ messages: [...] }`, or `[input, { context, metadata }]`. `null` or `undefined`
|
|
30
39
|
* starts nothing.
|
|
31
40
|
*/
|
|
32
41
|
export type GitHubEventResult = ChannelRunResult | null | undefined | void;
|
|
33
|
-
export type GitHubEventCallback<K extends SupportedEventKey> = (event: GitHubEvent<K>,
|
|
42
|
+
export type GitHubEventCallback<K extends SupportedEventKey> = (event: GitHubEvent<K>, thread: GitHubChannelThread) => GitHubEventResult | Promise<GitHubEventResult>;
|
|
34
43
|
/**
|
|
35
44
|
* What the agent may do with the GitHub App `mda deploy` sets up. Deploy
|
|
36
45
|
* applies changes to these on every run, except to the App's own
|
|
@@ -85,7 +94,7 @@ export interface GitHubChannelOptions {
|
|
|
85
94
|
/**
|
|
86
95
|
* Event handlers that start runs. Return a prompt (string, message, or
|
|
87
96
|
* state), or nothing to skip. While a thread waits on an interrupt, events
|
|
88
|
-
* start nothing: the handler still runs, with `
|
|
97
|
+
* start nothing: the handler still runs, with `thread.interrupted` set, to
|
|
89
98
|
* decide whether the issue or pull request is told to continue it in
|
|
90
99
|
* LangSmith Studio.
|
|
91
100
|
*
|
|
@@ -97,6 +106,25 @@ export interface GitHubChannelOptions {
|
|
|
97
106
|
onEvent?: {
|
|
98
107
|
[K in SupportedEventKey]?: GitHubEventCallback<K>;
|
|
99
108
|
};
|
|
109
|
+
/**
|
|
110
|
+
* More events for the App to receive, beyond the handled ones, to forward
|
|
111
|
+
* them: they start nothing here. Deploy subscribes the App to them too.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* { events: ["push"], forward: (request) => new Request(url, request) }
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
events?: SupportedEventKey[];
|
|
119
|
+
/**
|
|
120
|
+
* Send a delivery on to other services, besides acting on it here: return
|
|
121
|
+
* a request, such as `new Request(url, request)`, several, or nothing. It
|
|
122
|
+
* is called for every delivery of a handled or received event that the
|
|
123
|
+
* channel's filters (repositories, the App's own) keep, with the delivery
|
|
124
|
+
* as GitHub sent it, `X-Hub-Signature-256` included, and its parsed event.
|
|
125
|
+
* Sent in the background, best effort; see `channels.http`'s `forward`.
|
|
126
|
+
*/
|
|
127
|
+
forward?: EventForward<GitHubEvent>;
|
|
100
128
|
}
|
|
101
129
|
export {};
|
|
102
130
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/channels/github/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,4EAA4E;AAC5E,KAAK,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACrD,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;AAClD,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,IACrE,OAAO,CAAC,UAAU,EAAE;IAAE,GAAG,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC;AAClC,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,iBAAiB,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAEhF,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/channels/github/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KA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,OAAO,CAAC,CAAC;IAC/C;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,wFAAwF;AACxF,MAAM,WAAW,oBAAoB;IACnC,sEAAsE;IACtE,GAAG,CAAC,EAAE,gBAAgB,CAAC;IACvB;;;;;;;;;;;;;OAaG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE;SAAG,CAAC,IAAI,iBAAiB,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC;KAAE,CAAC;IAChE;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC7B;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;CACrC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forwarding: an HTTP channel's adapter may send each verified delivery on to
|
|
3
|
+
* other services, as the provider sent it, besides acting on it here.
|
|
4
|
+
*/
|
|
5
|
+
import type { ChannelEventsContext } from "../../runtime/channel.js";
|
|
6
|
+
import type { HttpChannelAdapter, HttpChannelParseResult } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Forward a verified delivery as the adapter's `forward` asks, in the
|
|
9
|
+
* background: the provider gets its answer without waiting, and a failure is
|
|
10
|
+
* logged, never raised.
|
|
11
|
+
*/
|
|
12
|
+
export declare function scheduleForwards(ctx: ChannelEventsContext, adapter: HttpChannelAdapter, rawBody: Uint8Array, result: HttpChannelParseResult): void;
|
|
13
|
+
//# sourceMappingURL=forward.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forward.d.ts","sourceRoot":"","sources":["../../../src/channels/http/forward.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EAGvB,MAAM,YAAY,CAAC;AAgHpB;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,oBAAoB,EACzB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,sBAAsB,GAC7B,IAAI,CA2BN"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { scheduleIngressWork } from "../../ingress/index.js";
|
|
2
|
+
import { logger } from "../../runtime/log.js";
|
|
3
|
+
/** How long one forwarded request may take. */
|
|
4
|
+
const FORWARD_TIMEOUT_MS = 10_000;
|
|
5
|
+
/** The most requests one delivery is forwarded as. */
|
|
6
|
+
const MAX_FORWARDS = 10;
|
|
7
|
+
/**
|
|
8
|
+
* Headers the platform in front of the deployment adds, or that describe the
|
|
9
|
+
* connection rather than the delivery. The provider's own headers, such as its
|
|
10
|
+
* signature and delivery ID, are kept, so the receiver can verify it.
|
|
11
|
+
*/
|
|
12
|
+
const DROPPED_HEADERS = new Set([
|
|
13
|
+
"authorization",
|
|
14
|
+
"connection",
|
|
15
|
+
"content-length",
|
|
16
|
+
"cookie",
|
|
17
|
+
"forwarded",
|
|
18
|
+
"host",
|
|
19
|
+
"keep-alive",
|
|
20
|
+
"proxy-authorization",
|
|
21
|
+
"te",
|
|
22
|
+
"trailer",
|
|
23
|
+
"transfer-encoding",
|
|
24
|
+
"upgrade",
|
|
25
|
+
"x-api-key",
|
|
26
|
+
"x-auth-scheme",
|
|
27
|
+
"x-real-ip",
|
|
28
|
+
"x-request-id",
|
|
29
|
+
]);
|
|
30
|
+
const DROPPED_HEADER_PREFIXES = ["x-forwarded-", "x-mda-", "x-langsmith-"];
|
|
31
|
+
function forwardedHeaders(headers) {
|
|
32
|
+
const kept = new Headers();
|
|
33
|
+
headers.forEach((value, name) => {
|
|
34
|
+
const key = name.toLowerCase();
|
|
35
|
+
if (DROPPED_HEADERS.has(key))
|
|
36
|
+
return;
|
|
37
|
+
if (DROPPED_HEADER_PREFIXES.some((prefix) => key.startsWith(prefix)))
|
|
38
|
+
return;
|
|
39
|
+
kept.append(name, value);
|
|
40
|
+
});
|
|
41
|
+
return kept;
|
|
42
|
+
}
|
|
43
|
+
/** What the adapter's `forward` learns about the delivery. */
|
|
44
|
+
function forwardContext(result) {
|
|
45
|
+
return {
|
|
46
|
+
result: result.type,
|
|
47
|
+
...("rawEvent" in result &&
|
|
48
|
+
result.rawEvent !== undefined && { rawEvent: result.rawEvent }),
|
|
49
|
+
...(result.type !== "ignore" && {
|
|
50
|
+
threadId: result.message.threadId.toLowerCase(),
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/** The requests `forward` returned, checked; anything else is logged. */
|
|
55
|
+
function forwardRequests(value) {
|
|
56
|
+
const requests = (Array.isArray(value) ? value : [value]).filter((request) => request !== null && request !== undefined);
|
|
57
|
+
if (requests.length > MAX_FORWARDS) {
|
|
58
|
+
logger.error(`channel forward returned more than ${MAX_FORWARDS} requests; sending the first ${MAX_FORWARDS}`);
|
|
59
|
+
}
|
|
60
|
+
return requests.slice(0, MAX_FORWARDS).filter((request) => {
|
|
61
|
+
if (!(request instanceof Request)) {
|
|
62
|
+
logger.error("channel forward returned something other than a Request");
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
let url;
|
|
66
|
+
try {
|
|
67
|
+
url = new URL(request.url);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
logger.error("channel forward returned a request without a valid URL");
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
if ((url.protocol !== "https:" && url.protocol !== "http:") ||
|
|
74
|
+
url.username ||
|
|
75
|
+
url.password) {
|
|
76
|
+
logger.error("channel forward URLs must be http(s), without credentials in them");
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return true;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async function send(request) {
|
|
83
|
+
const host = logger.logIdentifier(new URL(request.url).host);
|
|
84
|
+
try {
|
|
85
|
+
const response = await fetch(request, {
|
|
86
|
+
redirect: "manual",
|
|
87
|
+
signal: AbortSignal.timeout(FORWARD_TIMEOUT_MS),
|
|
88
|
+
});
|
|
89
|
+
// Only the status matters; the body is never read.
|
|
90
|
+
await response.body?.cancel();
|
|
91
|
+
if (!response.ok)
|
|
92
|
+
logger.warn(`channel forward to ${host} answered HTTP ${response.status}`);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
logger.error(`channel forward to ${host} failed (${logger.safeErrorLabel(error)})`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Forward a verified delivery as the adapter's `forward` asks, in the
|
|
100
|
+
* background: the provider gets its answer without waiting, and a failure is
|
|
101
|
+
* logged, never raised.
|
|
102
|
+
*/
|
|
103
|
+
export function scheduleForwards(ctx, adapter, rawBody, result) {
|
|
104
|
+
const forward = adapter.forward?.bind(adapter);
|
|
105
|
+
if (!forward)
|
|
106
|
+
return;
|
|
107
|
+
const headers = forwardedHeaders(ctx.request.headers);
|
|
108
|
+
const body = new Uint8Array(rawBody);
|
|
109
|
+
const context = forwardContext(result);
|
|
110
|
+
scheduleIngressWork(async () => {
|
|
111
|
+
const method = ctx.request.method;
|
|
112
|
+
const delivery = new Request(ctx.request.url, {
|
|
113
|
+
method,
|
|
114
|
+
headers,
|
|
115
|
+
...(method !== "GET" && method !== "HEAD" && { body }),
|
|
116
|
+
});
|
|
117
|
+
let requests;
|
|
118
|
+
try {
|
|
119
|
+
requests = forwardRequests(await forward(delivery, context));
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
logger.error(`channel forward failed (${logger.safeErrorLabel(error)})`);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
await Promise.all(requests.map(send));
|
|
126
|
+
}, { label: `channel "${ctx.name}" forward` });
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=forward.js.map
|
|
@@ -0,0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;IACtD,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IACvC,mBAAmB,CACjB,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;QAClC,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,EAAE;YAC5C,MAAM;YACN,OAAO;YACP,GAAG,CAAC,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,MAAM,IAAI,EAAE,IAAI,EAAE,CAAC;SACvD,CAAC,CAAC;QACH,IAAI,QAAmB,CAAC;QACxB,IAAI,CAAC;YACH,QAAQ,GAAG,eAAe,CAAC,MAAM,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;QAC/D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CACV,2BAA2B,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAC3D,CAAC;YACF,OAAO;QACT,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC,EACD,EAAE,KAAK,EAAE,YAAY,GAAG,CAAC,IAAI,WAAW,EAAE,CAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/channels/http/http.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,kBAAkB,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/channels/http/http.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,kBAAkB,EAOnB,MAAM,YAAY,CAAC;AAapB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAwCrE,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,oBAAoB,EACzB,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,QAAQ,CAAC,CAwTnB"}
|
|
@@ -3,7 +3,9 @@ import { immutableCopy, validateMessage } from "../runtime.js";
|
|
|
3
3
|
import { isJsonValue } from "../message-schema.js";
|
|
4
4
|
import { normalizeRunInput } from "../run-input.js";
|
|
5
5
|
import { cancelHttpIngressRuns, startHttpIngressAgent, observeHttpIngressAgent, waitForHttpIngressThread, } from "./ingress.js";
|
|
6
|
+
import { ChannelError } from "../errors.js";
|
|
6
7
|
import { scheduleIngressWork } from "../../ingress/index.js";
|
|
8
|
+
import { scheduleForwards } from "./forward.js";
|
|
7
9
|
import { logger } from "../../runtime/log.js";
|
|
8
10
|
const ASSISTANT_ID_ENV = "MDA_ASSISTANT_ID";
|
|
9
11
|
/**
|
|
@@ -30,28 +32,6 @@ function joinThreadWaiters(threadId) {
|
|
|
30
32
|
threadWaiters.set(threadId, waiters.add(waiter));
|
|
31
33
|
return waiter;
|
|
32
34
|
}
|
|
33
|
-
/**
|
|
34
|
-
* The threads this process recently stopped for a `cancel` result, and which
|
|
35
|
-
* target asked. A run cancelled by someone else's stop, such as another
|
|
36
|
-
* session on the same issue, tells its own target too; the one who asked was
|
|
37
|
-
* already told.
|
|
38
|
-
*/
|
|
39
|
-
const recentStops = new Map();
|
|
40
|
-
const RECENT_STOP_MS = 10 * 60 * 1000;
|
|
41
|
-
function recordStop(threadId, target) {
|
|
42
|
-
const now = Date.now();
|
|
43
|
-
for (const [thread, stop] of recentStops)
|
|
44
|
-
if (now - stop.at > RECENT_STOP_MS)
|
|
45
|
-
recentStops.delete(thread);
|
|
46
|
-
recentStops.set(threadId, { target: JSON.stringify(target), at: now });
|
|
47
|
-
}
|
|
48
|
-
/** Whether this process stopped the thread lately for another target. */
|
|
49
|
-
function stoppedForAnother(threadId, target) {
|
|
50
|
-
const stop = recentStops.get(threadId);
|
|
51
|
-
return (stop !== undefined &&
|
|
52
|
-
Date.now() - stop.at <= RECENT_STOP_MS &&
|
|
53
|
-
stop.target !== JSON.stringify(target));
|
|
54
|
-
}
|
|
55
35
|
function leaveThreadWaiters(threadId, waiter) {
|
|
56
36
|
const waiters = threadWaiters.get(threadId);
|
|
57
37
|
waiters?.delete(waiter);
|
|
@@ -88,31 +68,29 @@ export async function handleHttpRequest(ctx, adapter) {
|
|
|
88
68
|
if (!validParseResult(result)) {
|
|
89
69
|
return jsonError(400, "invalid channel parse result");
|
|
90
70
|
}
|
|
71
|
+
scheduleForwards(ctx, adapter, rawBody, result);
|
|
91
72
|
if (result.type === "ignore") {
|
|
92
73
|
return (result.response ?? Response.json({ status: "ignored" }, { status: 202 }));
|
|
93
74
|
}
|
|
94
|
-
let message = result.message;
|
|
95
|
-
try {
|
|
96
|
-
// A cancel names a thread; it starts nothing, so it needs no content.
|
|
97
|
-
validateInboundMessage(message, result.type === "cancel" || adapter.input !== undefined);
|
|
98
|
-
message = immutableCopy(message);
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
return jsonError(400, "invalid channel message");
|
|
102
|
-
}
|
|
103
75
|
const assistantId = process.env[ASSISTANT_ID_ENV]?.trim();
|
|
104
76
|
if (!assistantId) {
|
|
105
77
|
return jsonError(500, "channel runtime is not configured");
|
|
106
78
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
79
|
+
if (result.type === "cancel") {
|
|
80
|
+
let stop;
|
|
81
|
+
try {
|
|
82
|
+
validateCancelMessage(result.message);
|
|
83
|
+
stop = immutableCopy(result.message);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return jsonError(400, "invalid channel message");
|
|
87
|
+
}
|
|
88
|
+
const threadId = stop.threadId.toLowerCase();
|
|
111
89
|
return cancelThreadRuns(ctx, adapter, {
|
|
112
|
-
userId:
|
|
113
|
-
sourceThreadKey,
|
|
90
|
+
userId: stop.userId,
|
|
91
|
+
sourceThreadKey: `http:v1:${JSON.stringify([ctx.name, threadId])}`,
|
|
114
92
|
threadId,
|
|
115
|
-
target:
|
|
93
|
+
target: stop.target,
|
|
116
94
|
run: {
|
|
117
95
|
threadId,
|
|
118
96
|
assistantId,
|
|
@@ -122,6 +100,18 @@ export async function handleHttpRequest(ctx, adapter) {
|
|
|
122
100
|
},
|
|
123
101
|
...(result.response !== undefined && { response: result.response }),
|
|
124
102
|
});
|
|
103
|
+
}
|
|
104
|
+
let message = result.message;
|
|
105
|
+
try {
|
|
106
|
+
validateInboundMessage(message, adapter.input !== undefined);
|
|
107
|
+
message = immutableCopy(message);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
return jsonError(400, "invalid channel message");
|
|
111
|
+
}
|
|
112
|
+
const deliveryId = crypto.randomUUID();
|
|
113
|
+
const threadId = message.threadId.toLowerCase();
|
|
114
|
+
const sourceThreadKey = `http:v1:${JSON.stringify([ctx.name, threadId])}`;
|
|
125
115
|
const binding = channelContextSchema.parse({
|
|
126
116
|
name: ctx.name,
|
|
127
117
|
provider: ctx.channel.kind,
|
|
@@ -161,7 +151,7 @@ export async function handleHttpRequest(ctx, adapter) {
|
|
|
161
151
|
const inputHook = adapter.input?.bind(adapter);
|
|
162
152
|
async function prepare() {
|
|
163
153
|
try {
|
|
164
|
-
return normalizeRunInput(await inputHook?.(immutableCopy(message), rawEvent === undefined ? undefined : structuredClone(rawEvent)
|
|
154
|
+
return normalizeRunInput(await inputHook?.(immutableCopy(message), rawEvent === undefined ? undefined : structuredClone(rawEvent)));
|
|
165
155
|
}
|
|
166
156
|
catch (error) {
|
|
167
157
|
logger.error(`channel input failed (${logger.safeErrorLabel(error)})`);
|
|
@@ -205,69 +195,62 @@ export async function handleHttpRequest(ctx, adapter) {
|
|
|
205
195
|
if (!("skipped" in outcome && outcome.skipped === "busy"))
|
|
206
196
|
leaveThreadWaiters(threadId, waiter);
|
|
207
197
|
const label = `channel "${ctx.name}" delivery`;
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
198
|
+
const onInterrupted = adapter.onInterrupted?.bind(adapter);
|
|
199
|
+
const interruptedReasons = new Set(adapter.interruptedReasons ?? ["waiting"]);
|
|
200
|
+
async function notifyInterrupted(assistantId, reason) {
|
|
201
|
+
if (!onInterrupted || !interruptedReasons.has(reason))
|
|
211
202
|
return;
|
|
212
203
|
try {
|
|
213
204
|
// The thread's assistant lets the notice link to it in Studio.
|
|
214
|
-
await
|
|
215
|
-
...runInfo(assistantId),
|
|
216
|
-
...(stopped && { stopped }),
|
|
217
|
-
});
|
|
205
|
+
await onInterrupted(immutableCopy(message.target), runInfo(assistantId), reason);
|
|
218
206
|
}
|
|
219
207
|
catch (error) {
|
|
220
|
-
logger.error(`channel
|
|
208
|
+
logger.error(`channel interrupted notice failed (${logger.safeErrorLabel(error)})`);
|
|
221
209
|
}
|
|
222
210
|
}
|
|
223
|
-
|
|
224
|
-
const
|
|
225
|
-
async function
|
|
226
|
-
if (!onCancelled)
|
|
227
|
-
return;
|
|
211
|
+
const post = adapter.post?.bind(adapter);
|
|
212
|
+
const onError = adapter.onError?.bind(adapter);
|
|
213
|
+
async function notifyFailed(error) {
|
|
228
214
|
try {
|
|
229
|
-
|
|
215
|
+
if (onError) {
|
|
216
|
+
await onError(error, immutableCopy(message.target));
|
|
217
|
+
}
|
|
218
|
+
else if (post) {
|
|
219
|
+
await post(immutableCopy({
|
|
220
|
+
type: "content",
|
|
221
|
+
content: "Something went wrong while processing your request.",
|
|
222
|
+
target: message.target,
|
|
223
|
+
}));
|
|
224
|
+
}
|
|
230
225
|
}
|
|
231
|
-
catch (
|
|
232
|
-
|
|
226
|
+
catch (replyError) {
|
|
227
|
+
const action = onError ? "callback" : "reply";
|
|
228
|
+
logger.error(`channel error ${action} failed (${logger.safeErrorLabel(replyError)})`);
|
|
233
229
|
}
|
|
234
230
|
}
|
|
235
|
-
const post = adapter.post?.bind(adapter);
|
|
236
|
-
const onError = adapter.onError?.bind(adapter);
|
|
237
231
|
// The run posts its own answer (see `./reply.ts`): this reports what a run
|
|
238
232
|
// can't say itself, that it stopped on interrupts, was stopped, or failed.
|
|
239
233
|
async function deliver(started) {
|
|
240
234
|
logger.info(`channel run started ${JSON.stringify({ threadId, runId: logger.logIdentifier(started.runId) })}`);
|
|
235
|
+
let outcome;
|
|
241
236
|
try {
|
|
242
|
-
|
|
243
|
-
...input,
|
|
244
|
-
...started,
|
|
245
|
-
});
|
|
246
|
-
// Say where to answer the interrupts now, not only when the next message
|
|
247
|
-
// finds the thread waiting. The run Studio resumes posts the answer.
|
|
248
|
-
if (invocation.paused)
|
|
249
|
-
return await notifyPaused(invocation.paused.assistantId, true);
|
|
250
|
-
if (invocation.cancelled && stoppedForAnother(threadId, message.target))
|
|
251
|
-
await notifyCancelled(message.target, runInfo(assistantId));
|
|
237
|
+
outcome = await observeHttpIngressAgent({ ...input, ...started });
|
|
252
238
|
}
|
|
253
239
|
catch (error) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const action = onError ? "callback" : "reply";
|
|
269
|
-
logger.error(`channel error ${action} failed (${logger.safeErrorLabel(replyError)})`);
|
|
270
|
-
}
|
|
240
|
+
// The run may have answered already; only its own failure is reported.
|
|
241
|
+
logger.error(`channel run could not be observed (${logger.safeErrorLabel(error)})`);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
switch (outcome.type) {
|
|
245
|
+
case "paused":
|
|
246
|
+
// Say where to answer the interrupts now, not only when the next
|
|
247
|
+
// message finds the thread waiting. The run Studio resumes answers.
|
|
248
|
+
return notifyInterrupted(outcome.assistantId, "stopped");
|
|
249
|
+
case "failed":
|
|
250
|
+
logger.error(`channel run failed ${JSON.stringify({ threadId })}`);
|
|
251
|
+
return notifyFailed(new ChannelError("channel_run_failed", "channel run failed"));
|
|
252
|
+
default:
|
|
253
|
+
return;
|
|
271
254
|
}
|
|
272
255
|
}
|
|
273
256
|
// The thread's current run may still stop for a decision, so the message
|
|
@@ -296,16 +279,16 @@ export async function handleHttpRequest(ctx, adapter) {
|
|
|
296
279
|
return deliver(next);
|
|
297
280
|
logger.info(`channel run skipped ${JSON.stringify({ threadId, reason: next.skipped })}`);
|
|
298
281
|
if (next.skipped === "paused")
|
|
299
|
-
await
|
|
282
|
+
await notifyInterrupted(next.assistantId, "waiting");
|
|
300
283
|
}
|
|
301
284
|
if ("skipped" in outcome) {
|
|
302
285
|
logger.info(`channel run skipped ${JSON.stringify({ threadId, reason: outcome.skipped })}`);
|
|
303
286
|
if (outcome.skipped === "busy")
|
|
304
287
|
scheduleIngressWork(startWhenIdle, { label });
|
|
305
|
-
else if (outcome.skipped === "paused" &&
|
|
288
|
+
else if (outcome.skipped === "paused" && onInterrupted) {
|
|
306
289
|
const { assistantId } = outcome;
|
|
307
|
-
scheduleIngressWork(() =>
|
|
308
|
-
label: `channel "${ctx.name}"
|
|
290
|
+
scheduleIngressWork(() => notifyInterrupted(assistantId, "waiting"), {
|
|
291
|
+
label: `channel "${ctx.name}" interrupted notice`,
|
|
309
292
|
});
|
|
310
293
|
}
|
|
311
294
|
return (result.response ??
|
|
@@ -347,15 +330,14 @@ async function cancelThreadRuns(ctx, adapter, input) {
|
|
|
347
330
|
// Before the server's cancel, so waiters it wakes see it.
|
|
348
331
|
for (const waiter of threadWaiters.get(input.threadId) ?? [])
|
|
349
332
|
waiter.cancelled = true;
|
|
350
|
-
recordStop(input.threadId, input.target);
|
|
351
333
|
let cancelled;
|
|
352
334
|
try {
|
|
353
|
-
cancelled = await cancelHttpIngressRuns({
|
|
335
|
+
cancelled = (await cancelHttpIngressRuns({
|
|
354
336
|
userId: input.userId,
|
|
355
337
|
sourceThreadKey: input.sourceThreadKey,
|
|
356
338
|
sourceProvider: ctx.channel.kind,
|
|
357
339
|
threadId: input.threadId,
|
|
358
|
-
});
|
|
340
|
+
})).length;
|
|
359
341
|
}
|
|
360
342
|
catch (error) {
|
|
361
343
|
logger.error(`channel run could not be cancelled (${logger.safeErrorLabel(error)})`);
|
|
@@ -378,19 +360,36 @@ async function cancelThreadRuns(ctx, adapter, input) {
|
|
|
378
360
|
return (input.response ??
|
|
379
361
|
Response.json({ status: "cancelled", cancelled }, { status: 202 }));
|
|
380
362
|
}
|
|
363
|
+
const CANCEL_MESSAGE_KEYS = new Set([
|
|
364
|
+
"userId",
|
|
365
|
+
"threadId",
|
|
366
|
+
"target",
|
|
367
|
+
]);
|
|
368
|
+
/** A cancel names a thread and who to tell; it starts nothing. */
|
|
369
|
+
function validateCancelMessage(message) {
|
|
370
|
+
if (!message || typeof message !== "object")
|
|
371
|
+
throw new Error("channel cancel must be an object");
|
|
372
|
+
for (const key of Object.keys(message))
|
|
373
|
+
if (!CANCEL_MESSAGE_KEYS.has(key))
|
|
374
|
+
throw new Error("channel cancel takes only userId, threadId and target");
|
|
375
|
+
validateAddress(message);
|
|
376
|
+
}
|
|
381
377
|
function validateInboundMessage(message, adapterInput) {
|
|
382
|
-
nonblank(message.userId, "channel userId");
|
|
383
378
|
if (message.deliveryKey !== undefined)
|
|
384
379
|
nonblank(message.deliveryKey, "channel deliveryKey");
|
|
380
|
+
validateAddress(message);
|
|
381
|
+
// The adapter's `input` supplies what a message without content starts.
|
|
382
|
+
if (message.content !== undefined || !adapterInput)
|
|
383
|
+
validateMessageContent(message.content);
|
|
384
|
+
}
|
|
385
|
+
function validateAddress(message) {
|
|
386
|
+
nonblank(message.userId, "channel userId");
|
|
385
387
|
if (typeof message.threadId !== "string" ||
|
|
386
388
|
!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(message.threadId)) {
|
|
387
389
|
throw new Error("channel threadId must be a UUID");
|
|
388
390
|
}
|
|
389
391
|
if (!isJsonValue(message.target))
|
|
390
392
|
throw new Error("channel target must be JSON");
|
|
391
|
-
// The adapter's `input` supplies what a message without content starts.
|
|
392
|
-
if (message.content !== undefined || !adapterInput)
|
|
393
|
-
validateMessageContent(message.content);
|
|
394
393
|
}
|
|
395
394
|
function validateMessageContent(content) {
|
|
396
395
|
validateMessage({ type: "content", content });
|