managed-deepagents 0.10.0-dev.16 → 0.10.0-dev.17
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 +328 -18
- 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 -8
- package/dist/channels/github/index.d.ts.map +1 -1
- package/dist/channels/github/index.js +43 -138
- package/dist/channels/github/index.js.map +1 -1
- package/dist/channels/github/mentions.d.ts +12 -0
- package/dist/channels/github/mentions.d.ts.map +1 -0
- package/dist/channels/github/mentions.js +185 -0
- package/dist/channels/github/mentions.js.map +1 -0
- package/dist/channels/github/schema.d.ts +222 -0
- package/dist/channels/github/schema.d.ts.map +1 -1
- package/dist/channels/github/schema.js +22 -3
- package/dist/channels/github/schema.js.map +1 -1
- package/dist/channels/github/types.d.ts +57 -4
- package/dist/channels/github/types.d.ts.map +1 -1
- package/dist/channels/http/endpoint.d.ts +93 -0
- package/dist/channels/http/endpoint.d.ts.map +1 -0
- package/dist/channels/http/endpoint.js +276 -0
- package/dist/channels/http/endpoint.js.map +1 -0
- package/dist/channels/http/http.d.ts.map +1 -1
- package/dist/channels/http/http.js +319 -77
- 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.map +1 -1
- package/dist/channels/http/ingress.d.ts +38 -3
- package/dist/channels/http/ingress.d.ts.map +1 -1
- package/dist/channels/http/ingress.js +64 -29
- package/dist/channels/http/ingress.js.map +1 -1
- package/dist/channels/http/provider.d.ts +114 -0
- package/dist/channels/http/provider.d.ts.map +1 -0
- package/dist/channels/http/provider.js +220 -0
- package/dist/channels/http/provider.js.map +1 -0
- package/dist/channels/http/reply.d.ts +20 -0
- package/dist/channels/http/reply.d.ts.map +1 -0
- package/dist/channels/http/reply.js +116 -0
- package/dist/channels/http/reply.js.map +1 -0
- package/dist/channels/http/studio.d.ts +24 -0
- package/dist/channels/http/studio.d.ts.map +1 -0
- package/dist/channels/http/studio.js +97 -0
- package/dist/channels/http/studio.js.map +1 -0
- package/dist/channels/http/types.d.ts +100 -6
- package/dist/channels/http/types.d.ts.map +1 -1
- package/dist/channels/linear/connections.d.ts +11 -0
- package/dist/channels/linear/connections.d.ts.map +1 -0
- package/dist/channels/linear/connections.js +14 -0
- package/dist/channels/linear/connections.js.map +1 -0
- package/dist/channels/linear/graphql.d.ts +57 -0
- package/dist/channels/linear/graphql.d.ts.map +1 -0
- package/dist/channels/linear/graphql.js +167 -0
- package/dist/channels/linear/graphql.js.map +1 -0
- package/dist/channels/linear/index.d.ts +9 -0
- package/dist/channels/linear/index.d.ts.map +1 -0
- package/dist/channels/linear/index.js +484 -0
- package/dist/channels/linear/index.js.map +1 -0
- package/dist/channels/linear/schema.d.ts +1064 -0
- package/dist/channels/linear/schema.d.ts.map +1 -0
- package/dist/channels/linear/schema.js +249 -0
- package/dist/channels/linear/schema.js.map +1 -0
- package/dist/channels/linear/types.d.ts +155 -0
- package/dist/channels/linear/types.d.ts.map +1 -0
- package/dist/channels/linear/types.js +2 -0
- package/dist/channels/linear/types.js.map +1 -0
- 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/reserved-connections.d.ts +2 -2
- package/dist/channels/reserved-connections.d.ts.map +1 -1
- package/dist/channels/reserved-connections.js +26 -9
- package/dist/channels/reserved-connections.js.map +1 -1
- package/dist/channels/run-input.d.ts +24 -2
- package/dist/channels/run-input.d.ts.map +1 -1
- package/dist/channels/run-input.js +56 -6
- package/dist/channels/run-input.js.map +1 -1
- package/dist/channels/slack/index.d.ts +33 -1
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +54 -4
- package/dist/channels/slack/index.js.map +1 -1
- package/dist/channels/source-providers.js +1 -1
- package/dist/channels/source-providers.js.map +1 -1
- package/dist/connections.d.ts +5 -0
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +14 -1
- package/dist/connections.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/ingress/runs.d.ts +10 -1
- package/dist/ingress/runs.d.ts.map +1 -1
- package/dist/ingress/runs.js +40 -4
- package/dist/ingress/runs.js.map +1 -1
- package/dist/namespaces.d.ts +15 -0
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +2 -0
- package/dist/namespaces.js.map +1 -1
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +20 -1
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/channel-icon.d.ts +22 -0
- package/dist/runtime/channel-icon.d.ts.map +1 -0
- package/dist/runtime/channel-icon.js +70 -0
- package/dist/runtime/channel-icon.js.map +1 -0
- package/dist/runtime/channel.d.ts +6 -0
- package/dist/runtime/channel.d.ts.map +1 -1
- package/dist/runtime/channel.js.map +1 -1
- package/dist/runtime/identity-http.d.ts +2 -0
- package/dist/runtime/identity-http.d.ts.map +1 -1
- package/dist/runtime/identity-http.js +35 -0
- package/dist/runtime/identity-http.js.map +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/index.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An HTTP channel run posts its own answer.
|
|
3
|
+
*
|
|
4
|
+
* The run does it, not the process that received the delivery, so a restart
|
|
5
|
+
* of that process doesn't lose the answer, and a run LangSmith Studio resumes
|
|
6
|
+
* after a decision answers the conversation the paused run came from.
|
|
7
|
+
*/
|
|
8
|
+
import { getConfig } from "@langchain/langgraph";
|
|
9
|
+
import { createMiddleware } from "langchain";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
import { extractAssistantContent } from "../assistant-text.js";
|
|
12
|
+
import { resolveChannelBinding } from "../binding.js";
|
|
13
|
+
import { isJsonValue } from "../message-schema.js";
|
|
14
|
+
import { messagingTransportForName } from "../messaging-registry.js";
|
|
15
|
+
import { isTrustedScheduleDeliveryRun } from "../schedule-delivery.js";
|
|
16
|
+
import { CHANNEL_THREAD_METADATA, configurableFromRuntime, resolveAmbientConfigurable, } from "../../runtime/identity-runtime.js";
|
|
17
|
+
import { logger } from "../../runtime/log.js";
|
|
18
|
+
/**
|
|
19
|
+
* Where the thread's latest channel delivery came from, kept in its state.
|
|
20
|
+
* Private (the leading `_`), so it's never part of a run's input or output.
|
|
21
|
+
*/
|
|
22
|
+
export const CHANNEL_REPLY_STATE_KEY = "_mda_channel_reply";
|
|
23
|
+
const replyTargetSchema = z.object({
|
|
24
|
+
name: z.string().min(1),
|
|
25
|
+
target: z.custom((value) => isJsonValue(value)),
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* The run's verified HTTP channel delivery: one the channel's ingress started
|
|
29
|
+
* for that conversation (the binding matches the run's authenticated source),
|
|
30
|
+
* never one a caller put in the run's context.
|
|
31
|
+
*/
|
|
32
|
+
function deliveredTarget(runtime) {
|
|
33
|
+
const configurable = configurableFromRuntime(runtime) ??
|
|
34
|
+
resolveAmbientConfigurable();
|
|
35
|
+
const binding = resolveChannelBinding(undefined, configurable);
|
|
36
|
+
// Only HTTP channels deliver directly; others answer on their own.
|
|
37
|
+
if (!binding || binding.transport !== "direct")
|
|
38
|
+
return undefined;
|
|
39
|
+
return { name: binding.name, target: binding.target };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether the run is on a channel's thread. Only managed ingress marks one;
|
|
43
|
+
* the runtime's auth strips the marker from every other thread and run, so a
|
|
44
|
+
* caller can't point its own thread's stored target at someone else's
|
|
45
|
+
* conversation. Channel threads take runs only from their channel and resumes
|
|
46
|
+
* from LangSmith Studio.
|
|
47
|
+
*/
|
|
48
|
+
function onChannelThread() {
|
|
49
|
+
try {
|
|
50
|
+
const metadata = getConfig().metadata;
|
|
51
|
+
return metadata?.[CHANNEL_THREAD_METADATA] === "true";
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Outside a runnable context.
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function storedTarget(state) {
|
|
59
|
+
if (!onChannelThread())
|
|
60
|
+
return undefined;
|
|
61
|
+
const value = state && typeof state === "object" && !Array.isArray(state)
|
|
62
|
+
? state[CHANNEL_REPLY_STATE_KEY]
|
|
63
|
+
: undefined;
|
|
64
|
+
const parsed = replyTargetSchema.safeParse(value);
|
|
65
|
+
return parsed.success ? parsed.data : undefined;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Remember a channel delivery's target in the thread's state, and post the
|
|
69
|
+
* answer to it when the agent finishes. A run that stops on `interrupt()` or
|
|
70
|
+
* is cancelled doesn't finish, so it posts nothing; the run that resumes it
|
|
71
|
+
* carries no delivery, so it answers the remembered target.
|
|
72
|
+
*/
|
|
73
|
+
export function createChannelReplyMiddleware() {
|
|
74
|
+
return createMiddleware({
|
|
75
|
+
name: "mda-channel-reply",
|
|
76
|
+
stateSchema: z.object({
|
|
77
|
+
[CHANNEL_REPLY_STATE_KEY]: replyTargetSchema.optional(),
|
|
78
|
+
}),
|
|
79
|
+
beforeAgent(_state, runtime) {
|
|
80
|
+
const delivered = deliveredTarget(runtime);
|
|
81
|
+
return delivered ? { [CHANNEL_REPLY_STATE_KEY]: delivered } : undefined;
|
|
82
|
+
},
|
|
83
|
+
async afterAgent(state, runtime) {
|
|
84
|
+
const configurable = configurableFromRuntime(runtime) ??
|
|
85
|
+
resolveAmbientConfigurable();
|
|
86
|
+
// Scheduled runs post through schedule delivery.
|
|
87
|
+
if (isTrustedScheduleDeliveryRun(configurable))
|
|
88
|
+
return undefined;
|
|
89
|
+
const reply = deliveredTarget(runtime) ?? storedTarget(state);
|
|
90
|
+
if (!reply)
|
|
91
|
+
return undefined;
|
|
92
|
+
const content = extractAssistantContent({
|
|
93
|
+
messages: state.messages,
|
|
94
|
+
});
|
|
95
|
+
if (content === null)
|
|
96
|
+
return undefined;
|
|
97
|
+
const transport = messagingTransportForName(reply.name);
|
|
98
|
+
if (!transport) {
|
|
99
|
+
logger.warn(`channel reply skipped: no channel ${JSON.stringify(logger.logIdentifier(reply.name))}`);
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
await transport.post({
|
|
104
|
+
message: { type: "content", content },
|
|
105
|
+
target: reply.target,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
// The answer stays in the thread; the run itself succeeded.
|
|
110
|
+
logger.error(`channel reply failed (${logger.safeErrorLabel(error)})`);
|
|
111
|
+
}
|
|
112
|
+
return undefined;
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=reply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reply.js","sourceRoot":"","sources":["../../../src/channels/http/reply.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,0BAA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K,CAAC,IAAI,CAAC,CAAC;YACxD,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,MAAM,CAAC,IAAI,CACT,qCAAqC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CACxF,CAAC;gBACF,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,IAAI,CAAC;gBACH,MAAM,SAAS,CAAC,IAAI,CAAC;oBACnB,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE;oBACrC,MAAM,EAAE,KAAK,CAAC,MAAM;iBACrB,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,4DAA4D;gBAC5D,MAAM,CAAC,KAAK,CAAC,yBAAyB,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACzE,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HttpDelivery, HttpFinish } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The thread in the deployment's Studio, or the deployment's page when the
|
|
4
|
+
* deployment's name or the thread's assistant is unknown. The LangSmith UI is
|
|
5
|
+
* the one `mda deploy` recorded for the deployment's environment
|
|
6
|
+
* (`MDA_LANGSMITH_URL`); without it there is nothing to link to.
|
|
7
|
+
*/
|
|
8
|
+
export declare function studioUrl(run: HttpDelivery | undefined, env?: NodeJS.ProcessEnv): string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* What a finished delivery leaves the thread waiting on a decision as: its
|
|
11
|
+
* run stopped on interrupts (`interrupted`), or the message found the thread
|
|
12
|
+
* already waiting (`waiting`). Undefined when nothing waits, or the delivery
|
|
13
|
+
* was a cancel or lost.
|
|
14
|
+
*/
|
|
15
|
+
export declare function pendingDecision(finish: HttpFinish): "interrupted" | "waiting" | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* What a channel tells the conversation when its thread waits on a decision,
|
|
18
|
+
* with a link to the thread in Studio, where the decision is made: the run
|
|
19
|
+
* the delivery started stopped on interrupts (`interrupted`), or the message
|
|
20
|
+
* found the thread waiting (`waiting`). `again` says how to continue once it
|
|
21
|
+
* is made, such as "comment again".
|
|
22
|
+
*/
|
|
23
|
+
export declare function interruptedNotice(outcome: "interrupted" | "waiting", delivery: HttpDelivery, again: string): string;
|
|
24
|
+
//# sourceMappingURL=studio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio.d.ts","sourceRoot":"","sources":["../../../src/channels/http/studio.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAS3D;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,YAAY,GAAG,SAAS,EAC7B,GAAG,oBAAc,GAChB,MAAM,GAAG,SAAS,CAsBpB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,UAAU,GACjB,aAAa,GAAG,SAAS,GAAG,SAAS,CAMvC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,MAAM,GACZ,MAAM,CAMR"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/** Links from channel notices into the deployment's LangSmith Studio. */
|
|
2
|
+
import { v5 as uuidv5 } from "uuid";
|
|
3
|
+
import { DEPLOYMENT_ID_ENV } from "../../connections.js";
|
|
4
|
+
import { managedDeploymentName } from "../../runtime/sandbox-manager.js";
|
|
5
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
6
|
+
const DEPLOYMENT_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
7
|
+
const GRAPH_ID_PATTERN = /^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/;
|
|
8
|
+
/** The namespace the Agent Server derives a graph's default assistant from. */
|
|
9
|
+
const GRAPH_NAMESPACE = "6ba7b821-9dad-11d1-80b4-00c04fd430c8";
|
|
10
|
+
/**
|
|
11
|
+
* The thread in the deployment's Studio, or the deployment's page when the
|
|
12
|
+
* deployment's name or the thread's assistant is unknown. The LangSmith UI is
|
|
13
|
+
* the one `mda deploy` recorded for the deployment's environment
|
|
14
|
+
* (`MDA_LANGSMITH_URL`); without it there is nothing to link to.
|
|
15
|
+
*/
|
|
16
|
+
export function studioUrl(run, env = process.env) {
|
|
17
|
+
const threadId = run?.threadId;
|
|
18
|
+
const thread = threadId && UUID_PATTERN.test(threadId) ? threadId : undefined;
|
|
19
|
+
const workspace = env.LANGSMITH_TENANT_ID?.trim() ?? "";
|
|
20
|
+
const deployment = env[DEPLOYMENT_ID_ENV]?.trim() ?? "";
|
|
21
|
+
if (!UUID_PATTERN.test(workspace) || !UUID_PATTERN.test(deployment))
|
|
22
|
+
return undefined;
|
|
23
|
+
const origin = parseHttpUrl(env.MDA_LANGSMITH_URL)?.origin;
|
|
24
|
+
if (!origin)
|
|
25
|
+
return undefined;
|
|
26
|
+
const name = managedDeploymentName(env);
|
|
27
|
+
const assistantId = assistantUuid(run?.assistantId);
|
|
28
|
+
if (!name || !DEPLOYMENT_NAME_PATTERN.test(name) || !thread || !assistantId)
|
|
29
|
+
return `${origin}/o/${workspace}/host/deployments/${deployment}`;
|
|
30
|
+
const query = new URLSearchParams({
|
|
31
|
+
organizationId: workspace,
|
|
32
|
+
render: "interact",
|
|
33
|
+
hostProjectId: deployment,
|
|
34
|
+
assistantId,
|
|
35
|
+
mode: "chat",
|
|
36
|
+
threadId: thread,
|
|
37
|
+
});
|
|
38
|
+
return `${origin}/o/${workspace}/a/${encodeURIComponent(name)}/studio/thread?${query}`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* What a finished delivery leaves the thread waiting on a decision as: its
|
|
42
|
+
* run stopped on interrupts (`interrupted`), or the message found the thread
|
|
43
|
+
* already waiting (`waiting`). Undefined when nothing waits, or the delivery
|
|
44
|
+
* was a cancel or lost.
|
|
45
|
+
*/
|
|
46
|
+
export function pendingDecision(finish) {
|
|
47
|
+
if (!finish.interrupts.length)
|
|
48
|
+
return undefined;
|
|
49
|
+
if (finish.type === "run")
|
|
50
|
+
return "interrupted";
|
|
51
|
+
return finish.type === "skipped" && finish.reason === "waiting"
|
|
52
|
+
? "waiting"
|
|
53
|
+
: undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* What a channel tells the conversation when its thread waits on a decision,
|
|
57
|
+
* with a link to the thread in Studio, where the decision is made: the run
|
|
58
|
+
* the delivery started stopped on interrupts (`interrupted`), or the message
|
|
59
|
+
* found the thread waiting (`waiting`). `again` says how to continue once it
|
|
60
|
+
* is made, such as "comment again".
|
|
61
|
+
*/
|
|
62
|
+
export function interruptedNotice(outcome, delivery, again) {
|
|
63
|
+
const url = studioUrl(delivery);
|
|
64
|
+
const studio = url ? `[LangSmith Studio](${url})` : "LangSmith Studio";
|
|
65
|
+
return outcome === "interrupted"
|
|
66
|
+
? `I need a decision before I continue. Review the pending step in ${studio}.`
|
|
67
|
+
: `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}.`;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Studio opens an assistant by its ID. Channels start runs by graph ID, whose
|
|
71
|
+
* default assistant the Agent Server derives from it.
|
|
72
|
+
*/
|
|
73
|
+
function assistantUuid(assistant) {
|
|
74
|
+
if (!assistant)
|
|
75
|
+
return undefined;
|
|
76
|
+
if (UUID_PATTERN.test(assistant))
|
|
77
|
+
return assistant;
|
|
78
|
+
return GRAPH_ID_PATTERN.test(assistant)
|
|
79
|
+
? uuidv5(assistant, GRAPH_NAMESPACE)
|
|
80
|
+
: undefined;
|
|
81
|
+
}
|
|
82
|
+
function parseHttpUrl(value) {
|
|
83
|
+
if (!value?.trim())
|
|
84
|
+
return undefined;
|
|
85
|
+
try {
|
|
86
|
+
const url = new URL(value.trim());
|
|
87
|
+
return (url.protocol === "https:" || url.protocol === "http:") &&
|
|
88
|
+
!url.username &&
|
|
89
|
+
!url.password
|
|
90
|
+
? url
|
|
91
|
+
: undefined;
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=studio.js.map
|
|
@@ -0,0 +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,GAAG,qCAAqC,CAAC;AAC/D,+EAA+E;AAC/E,MAAM,eAAe,GAAG,sCAAsC,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CACvB,GAA6B,EAC7B,GAAG,GAAG,OAAO,CAAC,GAAG;IAEjB,MAAM,QAAQ,GAAG,GAAG,EAAE,QAAQ,CAAC;IAC/B,MAAM,MAAM,GAAG,QAAQ,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9E,MAAM,SAAS,GAAG,GAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxD,MAAM,UAAU,GAAG,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upt } from "@langchain/langgraph-sdk";
|
|
1
2
|
import type { MultitaskStrategy } from "../../ingress/runs.js";
|
|
2
3
|
import type { MessageContent } from "@langchain/core/messages";
|
|
3
4
|
import type { ChannelMessage, JsonValue } from "../types.js";
|
|
@@ -18,6 +19,20 @@ export interface HttpChannelInboundMessage {
|
|
|
18
19
|
* a redelivered event starts nothing.
|
|
19
20
|
*/
|
|
20
21
|
deliveryKey?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Answer the provider before the adapter's `input` decides what the run
|
|
24
|
+
* starts with, and start it in the background: for input that may take
|
|
25
|
+
* longer than the provider waits, such as an event endpoint's. A failure
|
|
26
|
+
* then can't fail the delivery, so the provider doesn't redeliver it.
|
|
27
|
+
*/
|
|
28
|
+
background?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** The thread a `cancel` result stops, and who to tell. */
|
|
31
|
+
export interface HttpChannelCancelMessage {
|
|
32
|
+
userId: string;
|
|
33
|
+
threadId: string;
|
|
34
|
+
/** Where to report the stop. */
|
|
35
|
+
target: JsonValue;
|
|
21
36
|
}
|
|
22
37
|
export type HttpChannelParseResult = {
|
|
23
38
|
type: "message";
|
|
@@ -28,6 +43,15 @@ export type HttpChannelParseResult = {
|
|
|
28
43
|
} | {
|
|
29
44
|
type: "ignore";
|
|
30
45
|
response?: Response;
|
|
46
|
+
} | {
|
|
47
|
+
/**
|
|
48
|
+
* Stop the work on the message's thread: MDA cancels its queued and
|
|
49
|
+
* running runs, keeping their progress, then calls `onFinish`.
|
|
50
|
+
*/
|
|
51
|
+
type: "cancel";
|
|
52
|
+
message: HttpChannelCancelMessage;
|
|
53
|
+
rawEvent?: JsonValue;
|
|
54
|
+
response?: Response;
|
|
31
55
|
};
|
|
32
56
|
/** MDA adds the verified reply target to the validated message. */
|
|
33
57
|
export type HttpChannelPostInput = ChannelMessage & {
|
|
@@ -55,6 +79,10 @@ export interface HttpChannelAdapter {
|
|
|
55
79
|
/** Decode the verified request body in the provider's format. */
|
|
56
80
|
parse(context: HttpChannelRequest): HttpChannelParseResult | Promise<HttpChannelParseResult>;
|
|
57
81
|
post?(input: HttpChannelPostInput): Promise<HttpPostedMessage>;
|
|
82
|
+
/**
|
|
83
|
+
* The run a message started failed: tell the sender instead of the default
|
|
84
|
+
* apology `post` sends. Called before `onFinish`.
|
|
85
|
+
*/
|
|
58
86
|
onError?(error: unknown, target: JsonValue): Promise<void>;
|
|
59
87
|
/**
|
|
60
88
|
* What a message without `content` starts a run with, asked only once the
|
|
@@ -63,19 +91,85 @@ export interface HttpChannelAdapter {
|
|
|
63
91
|
*/
|
|
64
92
|
input?(message: HttpChannelInboundMessage, rawEvent: JsonValue | undefined): ChannelRunResult | null | undefined | Promise<ChannelRunResult | null | undefined>;
|
|
65
93
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
94
|
+
* A verified message reached its thread, before MDA starts or queues
|
|
95
|
+
* anything for it. For providers that expect a prompt acknowledgement.
|
|
96
|
+
* Each message that gets it later gets `onFinish`. Runs in the
|
|
97
|
+
* background; failures are logged.
|
|
98
|
+
*/
|
|
99
|
+
onReceived?(target: JsonValue, delivery: HttpDelivery): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* A message is done, once, with how: the run it started ended (`run`), it
|
|
102
|
+
* started none and why (`skipped`), or MDA couldn't start the run or lost
|
|
103
|
+
* track of it (`failed`); see {@link HttpFinish}. `interrupts` are what the
|
|
104
|
+
* thread waits on now, non-empty while a decision is pending, made in
|
|
105
|
+
* Studio. Called after `onReceived` and `onError`, in the background;
|
|
106
|
+
* failures are logged.
|
|
107
|
+
*
|
|
108
|
+
* It runs in the process that took the delivery, so a restart loses it,
|
|
109
|
+
* and a run Studio resumes has no delivery. Keep a reconciliation, or set
|
|
110
|
+
* the run's `webhook`, for anything that must not miss a run.
|
|
68
111
|
*/
|
|
69
|
-
|
|
112
|
+
onFinish?(target: JsonValue, delivery: HttpFinishedDelivery): Promise<void>;
|
|
70
113
|
}
|
|
71
|
-
/**
|
|
72
|
-
export interface
|
|
114
|
+
/** A delivery's thread, for notices and links into LangSmith Studio. */
|
|
115
|
+
export interface HttpDelivery {
|
|
73
116
|
threadId: string;
|
|
74
117
|
/** The assistant that runs on the thread, when known. */
|
|
75
118
|
assistantId?: string;
|
|
76
|
-
/** The provider event
|
|
119
|
+
/** The provider event `parse` returned, if any. */
|
|
77
120
|
rawEvent?: JsonValue;
|
|
78
121
|
}
|
|
122
|
+
/** A delivery that is done; see {@link HttpChannelAdapter.onFinish}. */
|
|
123
|
+
export type HttpFinishedDelivery = HttpDelivery & HttpFinish;
|
|
124
|
+
/**
|
|
125
|
+
* How a delivery finished, to switch on by `type`. Each comes with
|
|
126
|
+
* `interrupts`, the thread's pending interrupts: what it waits on now.
|
|
127
|
+
*
|
|
128
|
+
* - `run`: the run it started ended; `run.status` says how.
|
|
129
|
+
* - `skipped`: it started no run; `reason` says why.
|
|
130
|
+
* - `failed`: MDA couldn't start its run after the provider got its answer,
|
|
131
|
+
* so nothing redelivers it (`start`); couldn't start it and answered the
|
|
132
|
+
* provider with an error, so it may redeliver it as a new delivery, which
|
|
133
|
+
* reports its own outcome (`retry`); or lost track of the run it started
|
|
134
|
+
* (`observe`), which may still answer. Only `start` is a final failure.
|
|
135
|
+
*/
|
|
136
|
+
export type HttpFinish = {
|
|
137
|
+
type: "run";
|
|
138
|
+
run: HttpFinishedRun;
|
|
139
|
+
interrupts: Interrupt[];
|
|
140
|
+
} | {
|
|
141
|
+
type: "skipped";
|
|
142
|
+
reason: HttpSkipReason;
|
|
143
|
+
interrupts: Interrupt[];
|
|
144
|
+
} | {
|
|
145
|
+
type: "failed";
|
|
146
|
+
reason: "start" | "retry" | "observe";
|
|
147
|
+
interrupts: Interrupt[];
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Why a delivery started no run:
|
|
151
|
+
*
|
|
152
|
+
* - `cancel`: it was a cancel, and MDA cancelled the thread's runs.
|
|
153
|
+
* - `waiting`: its thread waits on a decision; `interrupts` say on what.
|
|
154
|
+
* - `ignored`: its input started nothing, such as a handler that declined.
|
|
155
|
+
* - `duplicate`: a redelivery of a delivery the thread already took; that
|
|
156
|
+
* delivery's own `onFinish` reports its run.
|
|
157
|
+
* - `rejected`: its thread was busy, and the channel's `multitaskStrategy`
|
|
158
|
+
* is `reject`.
|
|
159
|
+
* - `dropped`: a cancel dropped it while it waited for its busy thread or
|
|
160
|
+
* for its input.
|
|
161
|
+
*/
|
|
162
|
+
export type HttpSkipReason = "cancel" | "waiting" | "ignored" | "duplicate" | "rejected" | "dropped";
|
|
163
|
+
/**
|
|
164
|
+
* How a LangGraph run ended: `interrupted` when it was cancelled, by a cancel
|
|
165
|
+
* or a newer message, or replaced by a newer message's `rollback`.
|
|
166
|
+
*/
|
|
167
|
+
export type HttpRunStatus = "success" | "error" | "timeout" | "interrupted";
|
|
168
|
+
/** A run a delivery started, and how it ended. */
|
|
169
|
+
export interface HttpFinishedRun {
|
|
170
|
+
id: string;
|
|
171
|
+
status: HttpRunStatus;
|
|
172
|
+
}
|
|
79
173
|
export interface HttpChannelRequest {
|
|
80
174
|
request: Request;
|
|
81
175
|
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,C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G;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,CAAC;AAE5E,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,UAAU,CAAC;CACrB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reserved agent connection for the deployment's Linear app: reading it
|
|
3
|
+
* returns the app's access token, which Agent Auth renews.
|
|
4
|
+
*/
|
|
5
|
+
export declare const LINEAR_TOKEN_SLUG = "mda/linear-token";
|
|
6
|
+
/**
|
|
7
|
+
* The deployment's Linear app connection, or one of the app values stored
|
|
8
|
+
* beside it (`webhook-secret`) when `suffix` is given.
|
|
9
|
+
*/
|
|
10
|
+
export declare function linearAppConnectionSlug(deploymentId: string, suffix?: string): string;
|
|
11
|
+
//# sourceMappingURL=connections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { appConnectionSlug } from "../http/provider.js";
|
|
2
|
+
/**
|
|
3
|
+
* Reserved agent connection for the deployment's Linear app: reading it
|
|
4
|
+
* returns the app's access token, which Agent Auth renews.
|
|
5
|
+
*/
|
|
6
|
+
export const LINEAR_TOKEN_SLUG = "mda/linear-token";
|
|
7
|
+
/**
|
|
8
|
+
* The deployment's Linear app connection, or one of the app values stored
|
|
9
|
+
* beside it (`webhook-secret`) when `suffix` is given.
|
|
10
|
+
*/
|
|
11
|
+
export function linearAppConnectionSlug(deploymentId, suffix) {
|
|
12
|
+
return appConnectionSlug("linear", deploymentId, suffix);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=connections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Linear refused a request for exceeding its rate limit. */
|
|
3
|
+
export declare class LinearRateLimitError extends Error {
|
|
4
|
+
constructor();
|
|
5
|
+
}
|
|
6
|
+
/** Forget the cached app token; for tests. */
|
|
7
|
+
export declare function resetLinearToken(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Run a GraphQL operation as the app. `query` is a constant; everything that
|
|
10
|
+
* varies goes in `variables`. A rejected token is read again once. Returns
|
|
11
|
+
* the response's `data`, checked against `schema`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function linearRequest<T>(query: string, variables: Record<string, unknown>, schema: z.ZodType<T>): Promise<T>;
|
|
14
|
+
/** The Linear user the app acts as. */
|
|
15
|
+
export type LinearAppUser = {
|
|
16
|
+
id: string;
|
|
17
|
+
displayName: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function linearAppUser(): Promise<LinearAppUser>;
|
|
20
|
+
/** Forget the cached app user; for tests. */
|
|
21
|
+
export declare function resetLinearAppUser(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Comment on an issue as the app, threaded under `parentId` when given.
|
|
24
|
+
* Returns the comment's id and URL.
|
|
25
|
+
*/
|
|
26
|
+
export declare function createLinearComment(input: {
|
|
27
|
+
issueId: string;
|
|
28
|
+
body: string;
|
|
29
|
+
parentId?: string;
|
|
30
|
+
}): Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
}>;
|
|
34
|
+
/** Whether a comment belongs to an agent session's thread. */
|
|
35
|
+
export declare function commentInAgentSession(commentId: string): Promise<boolean>;
|
|
36
|
+
/** What the app says in an agent session. */
|
|
37
|
+
export type LinearActivityContent = {
|
|
38
|
+
type: "thought" | "response" | "error" | "elicitation";
|
|
39
|
+
body: string;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Post an activity to an agent session as the app. An `ephemeral` thought is
|
|
43
|
+
* replaced by the next activity.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createLinearActivity(input: {
|
|
46
|
+
agentSessionId: string;
|
|
47
|
+
content: LinearActivityContent;
|
|
48
|
+
ephemeral?: boolean;
|
|
49
|
+
}): Promise<{
|
|
50
|
+
id: string;
|
|
51
|
+
}>;
|
|
52
|
+
/** Link an agent session to a page about it, such as its Studio thread. */
|
|
53
|
+
export declare function addLinearSessionUrl(agentSessionId: string, link: {
|
|
54
|
+
label: string;
|
|
55
|
+
url: string;
|
|
56
|
+
}): Promise<void>;
|
|
57
|
+
//# sourceMappingURL=graphql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../../../src/channels/linear/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiCxB,6DAA6D;AAC7D,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,cAGC;CACF;AAQD,8CAA8C;AAC9C,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AAWD;;;;GAIG;AACH,wBAAsB,aAAa,CA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