managed-deepagents 0.9.4-dev.9 → 0.10.0-dev.10
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 +345 -19
- package/dist/agent-auth.d.ts +1 -1
- package/dist/agent-auth.d.ts.map +1 -1
- package/dist/agent-auth.js +36 -12
- package/dist/agent-auth.js.map +1 -1
- package/dist/channels/github/connections.d.ts +11 -0
- package/dist/channels/github/connections.d.ts.map +1 -0
- package/dist/channels/github/connections.js +14 -0
- package/dist/channels/github/connections.js.map +1 -0
- package/dist/channels/github/index.d.ts +8 -0
- package/dist/channels/github/index.d.ts.map +1 -0
- package/dist/channels/github/index.js +268 -0
- package/dist/channels/github/index.js.map +1 -0
- package/dist/channels/github/schema.d.ts +3894 -0
- package/dist/channels/github/schema.d.ts.map +1 -0
- package/dist/channels/github/schema.js +188 -0
- package/dist/channels/github/schema.js.map +1 -0
- package/dist/channels/github/types.d.ts +138 -0
- package/dist/channels/github/types.d.ts.map +1 -0
- package/dist/channels/github/types.js +2 -0
- package/dist/channels/github/types.js.map +1 -0
- package/dist/channels/http/endpoint.d.ts +41 -0
- package/dist/channels/http/endpoint.d.ts.map +1 -0
- package/dist/channels/http/endpoint.js +132 -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 +301 -49
- package/dist/channels/http/http.js.map +1 -1
- package/dist/channels/http/index.d.ts +2 -1
- package/dist/channels/http/index.d.ts.map +1 -1
- package/dist/channels/http/index.js +11 -1
- package/dist/channels/http/index.js.map +1 -1
- package/dist/channels/http/ingress.d.ts +61 -5
- package/dist/channels/http/ingress.d.ts.map +1 -1
- package/dist/channels/http/ingress.js +138 -29
- package/dist/channels/http/ingress.js.map +1 -1
- package/dist/channels/http/provider.d.ts +99 -0
- package/dist/channels/http/provider.d.ts.map +1 -0
- package/dist/channels/http/provider.js +188 -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 +17 -0
- package/dist/channels/http/studio.d.ts.map +1 -0
- package/dist/channels/http/studio.js +82 -0
- package/dist/channels/http/studio.js.map +1 -0
- package/dist/channels/http/threads.d.ts +7 -0
- package/dist/channels/http/threads.d.ts.map +1 -0
- package/dist/channels/http/threads.js +10 -0
- package/dist/channels/http/threads.js.map +1 -0
- package/dist/channels/http/types.d.ts +113 -1
- 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 +477 -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 +150 -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 +12 -0
- package/dist/channels/reserved-connections.d.ts.map +1 -0
- package/dist/channels/reserved-connections.js +45 -0
- package/dist/channels/reserved-connections.js.map +1 -0
- package/dist/channels/run-input.d.ts +54 -0
- package/dist/channels/run-input.d.ts.map +1 -0
- package/dist/channels/run-input.js +129 -0
- package/dist/channels/run-input.js.map +1 -0
- package/dist/channels/source-providers.js +1 -1
- package/dist/channels/source-providers.js.map +1 -1
- package/dist/channels/trigger/client.js +2 -6
- package/dist/channels/trigger/client.js.map +1 -1
- package/dist/channels/trigger/http.js +1 -1
- package/dist/channels/trigger/http.js.map +1 -1
- package/dist/channels/trigger/identity-context.d.ts +1 -1
- package/dist/channels/trigger/identity-context.d.ts.map +1 -1
- package/dist/channels/trigger/identity-context.js +2 -3
- package/dist/channels/trigger/identity-context.js.map +1 -1
- package/dist/channels/trigger/ingress.d.ts.map +1 -1
- package/dist/channels/trigger/ingress.js +1 -19
- package/dist/channels/trigger/ingress.js.map +1 -1
- package/dist/connections.d.ts +31 -0
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +106 -9
- package/dist/connections.js.map +1 -1
- package/dist/credential-gate.d.ts +2 -0
- package/dist/credential-gate.d.ts.map +1 -1
- package/dist/credential-gate.js +37 -3
- package/dist/credential-gate.js.map +1 -1
- package/dist/identity/loopback.d.ts +1 -1
- package/dist/identity/loopback.d.ts.map +1 -1
- package/dist/identity/loopback.js +2 -3
- package/dist/identity/loopback.js.map +1 -1
- package/dist/index.d.ts +6 -1
- 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 +50 -1
- package/dist/ingress/runs.d.ts.map +1 -1
- package/dist/ingress/runs.js +128 -2
- package/dist/ingress/runs.js.map +1 -1
- package/dist/memory/instructions-middleware.d.ts.map +1 -1
- package/dist/memory/instructions-middleware.js +5 -6
- package/dist/memory/instructions-middleware.js.map +1 -1
- package/dist/namespaces.d.ts +21 -0
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +4 -0
- package/dist/namespaces.js.map +1 -1
- package/dist/runtime/auth.d.ts +2 -1
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +115 -14
- 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 +36 -11
- package/dist/runtime/identity-http.js.map +1 -1
- package/dist/runtime/identity-runtime.d.ts +15 -0
- package/dist/runtime/identity-runtime.d.ts.map +1 -1
- package/dist/runtime/identity-runtime.js +35 -0
- package/dist/runtime/identity-runtime.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/dist/runtime/memory/mounts.d.ts +0 -42
- package/dist/runtime/memory/mounts.d.ts.map +1 -1
- package/dist/runtime/memory/mounts.js +7 -63
- package/dist/runtime/memory/mounts.js.map +1 -1
- package/dist/runtime/sandbox-manager.d.ts +1 -1
- package/dist/runtime/sandbox-manager.d.ts.map +1 -1
- package/dist/runtime/sandbox-manager.js +3 -3
- package/dist/runtime/sandbox-manager.js.map +1 -1
- package/package.json +8 -8
|
@@ -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,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC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AAI,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,17 @@
|
|
|
1
|
+
import type { HttpDelivery } 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 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: the run
|
|
12
|
+
* the delivery started stopped on interrupts (`interrupted`), or the message
|
|
13
|
+
* found the thread waiting (`waiting`). `again` says how to continue once it
|
|
14
|
+
* is made, such as "comment again".
|
|
15
|
+
*/
|
|
16
|
+
export declare function interruptedNotice(outcome: "interrupted" | "waiting", delivery: HttpDelivery, again: string): string;
|
|
17
|
+
//# 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,MAAM,YAAY,CAAC;AAS/C;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,YAAY,GAAG,SAAS,EAC7B,GAAG,oBAAc,GAChB,MAAM,GAAG,SAAS,CAsBpB;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,82 @@
|
|
|
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 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: the run
|
|
43
|
+
* the delivery started stopped on interrupts (`interrupted`), or the message
|
|
44
|
+
* found the thread waiting (`waiting`). `again` says how to continue once it
|
|
45
|
+
* is made, such as "comment again".
|
|
46
|
+
*/
|
|
47
|
+
export function interruptedNotice(outcome, delivery, again) {
|
|
48
|
+
const url = studioUrl(delivery);
|
|
49
|
+
const studio = url ? `[LangSmith Studio](${url})` : "LangSmith Studio";
|
|
50
|
+
return outcome === "interrupted"
|
|
51
|
+
? `I need a decision before I continue. Review the pending step in ${studio}.`
|
|
52
|
+
: `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}.`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Studio opens an assistant by its ID. Channels start runs by graph ID, whose
|
|
56
|
+
* default assistant the Agent Server derives from it.
|
|
57
|
+
*/
|
|
58
|
+
function assistantUuid(assistant) {
|
|
59
|
+
if (!assistant)
|
|
60
|
+
return undefined;
|
|
61
|
+
if (UUID_PATTERN.test(assistant))
|
|
62
|
+
return assistant;
|
|
63
|
+
return GRAPH_ID_PATTERN.test(assistant)
|
|
64
|
+
? uuidv5(assistant, GRAPH_NAMESPACE)
|
|
65
|
+
: undefined;
|
|
66
|
+
}
|
|
67
|
+
function parseHttpUrl(value) {
|
|
68
|
+
if (!value?.trim())
|
|
69
|
+
return undefined;
|
|
70
|
+
try {
|
|
71
|
+
const url = new URL(value.trim());
|
|
72
|
+
return (url.protocol === "https:" || url.protocol === "http:") &&
|
|
73
|
+
!url.username &&
|
|
74
|
+
!url.password
|
|
75
|
+
? url
|
|
76
|
+
: undefined;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# 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;;;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,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The thread for one provider conversation, such as an issue or a chat: the
|
|
3
|
+
* same channel and key always give the same UUID, so each message continues
|
|
4
|
+
* the conversation. The Python runtime derives the same IDs.
|
|
5
|
+
*/
|
|
6
|
+
export declare function channelThreadId(channelName: string, key: string): string;
|
|
7
|
+
//# sourceMappingURL=threads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threads.d.ts","sourceRoot":"","sources":["../../../src/channels/http/threads.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAKxE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { v5 as uuidv5 } from "uuid";
|
|
2
|
+
/**
|
|
3
|
+
* The thread for one provider conversation, such as an issue or a chat: the
|
|
4
|
+
* same channel and key always give the same UUID, so each message continues
|
|
5
|
+
* the conversation. The Python runtime derives the same IDs.
|
|
6
|
+
*/
|
|
7
|
+
export function channelThreadId(channelName, key) {
|
|
8
|
+
return uuidv5(`mda-thread:v1:${JSON.stringify([channelName, key])}`, uuidv5.URL);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=threads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"threads.js","sourceRoot":"","sources":["../../../src/channels/http/threads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,WAAmB,EAAE,GAAW;IAC9D,OAAO,MAAM,CACX,iBAAiB,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC,EAAE,EACrD,MAAM,CAAC,GAAG,CACX,CAAC;AACJ,CAAC"}
|
|
@@ -1,11 +1,30 @@
|
|
|
1
|
+
import type { MultitaskStrategy } from "../../ingress/runs.js";
|
|
1
2
|
import type { MessageContent } from "@langchain/core/messages";
|
|
2
3
|
import type { ChannelMessage, JsonValue } from "../types.js";
|
|
4
|
+
import type { ChannelRunResult } from "../run-input.js";
|
|
3
5
|
export interface HttpChannelInboundMessage {
|
|
4
6
|
userId: string;
|
|
7
|
+
/** See {@link channelThreadId} for one thread per provider conversation. */
|
|
5
8
|
threadId: string;
|
|
6
9
|
/** Provider destination, independent of the LangGraph thread UUID. */
|
|
7
10
|
target: JsonValue;
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* What a new run starts with. Without it, the adapter's `input` supplies it
|
|
13
|
+
* once MDA knows the thread takes a new turn.
|
|
14
|
+
*/
|
|
15
|
+
content?: MessageContent;
|
|
16
|
+
/**
|
|
17
|
+
* The provider's ID for this delivery. A thread runs each delivery once, so
|
|
18
|
+
* a redelivered event starts nothing.
|
|
19
|
+
*/
|
|
20
|
+
deliveryKey?: string;
|
|
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;
|
|
9
28
|
}
|
|
10
29
|
export type HttpChannelParseResult = {
|
|
11
30
|
type: "message";
|
|
@@ -16,6 +35,15 @@ export type HttpChannelParseResult = {
|
|
|
16
35
|
} | {
|
|
17
36
|
type: "ignore";
|
|
18
37
|
response?: Response;
|
|
38
|
+
} | {
|
|
39
|
+
/**
|
|
40
|
+
* Stop the work on the message's thread: MDA cancels its queued and
|
|
41
|
+
* running runs, keeping their progress, then calls `onSettled`.
|
|
42
|
+
*/
|
|
43
|
+
type: "cancel";
|
|
44
|
+
message: HttpChannelCancelMessage;
|
|
45
|
+
rawEvent?: JsonValue;
|
|
46
|
+
response?: Response;
|
|
19
47
|
};
|
|
20
48
|
/** MDA adds the verified reply target to the validated message. */
|
|
21
49
|
export type HttpChannelPostInput = ChannelMessage & {
|
|
@@ -29,12 +57,96 @@ export interface HttpPostedMessage {
|
|
|
29
57
|
}
|
|
30
58
|
export interface HttpChannelAdapter {
|
|
31
59
|
provider: string;
|
|
60
|
+
providerConfig?: Record<string, JsonValue>;
|
|
61
|
+
/**
|
|
62
|
+
* What a message that starts a turn does while its thread already runs:
|
|
63
|
+
* `enqueue` (the default) waits for the run and starts after it,
|
|
64
|
+
* `interrupt` cancels the run, keeping its progress, and starts at once,
|
|
65
|
+
* `rollback` cancels it and discards its progress, and `reject` starts
|
|
66
|
+
* nothing. Messages to a thread that waits on an interrupt start nothing
|
|
67
|
+
* either way.
|
|
68
|
+
*/
|
|
69
|
+
multitaskStrategy?: MultitaskStrategy;
|
|
32
70
|
verify(context: HttpChannelRequest): boolean | Promise<boolean>;
|
|
33
71
|
/** Decode the verified request body in the provider's format. */
|
|
34
72
|
parse(context: HttpChannelRequest): HttpChannelParseResult | Promise<HttpChannelParseResult>;
|
|
35
73
|
post?(input: HttpChannelPostInput): Promise<HttpPostedMessage>;
|
|
74
|
+
/**
|
|
75
|
+
* The run a message started failed: tell the sender instead of the default
|
|
76
|
+
* apology `post` sends. Called before `onSettled`.
|
|
77
|
+
*/
|
|
36
78
|
onError?(error: unknown, target: JsonValue): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* What a message without `content` starts a run with, asked only once the
|
|
81
|
+
* thread takes a new turn, never while it waits on an interrupt. `null` or
|
|
82
|
+
* `undefined` starts nothing.
|
|
83
|
+
*/
|
|
84
|
+
input?(message: HttpChannelInboundMessage, rawEvent: JsonValue | undefined): ChannelRunResult | null | undefined | Promise<ChannelRunResult | null | undefined>;
|
|
85
|
+
/**
|
|
86
|
+
* A verified message reached its thread, before MDA starts or queues
|
|
87
|
+
* anything for it. For providers that expect a prompt acknowledgement.
|
|
88
|
+
* Each message that gets it also gets one `onSettled`. Runs in the
|
|
89
|
+
* background; failures are logged.
|
|
90
|
+
*/
|
|
91
|
+
onReceived?(target: JsonValue, delivery: HttpDelivery): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* How a message or a cancel ended, once: the run it started completed,
|
|
94
|
+
* stopped on interrupts, was cancelled, replaced, or failed, or why it
|
|
95
|
+
* started none. See {@link HttpDeliveryOutcome}. Runs in the background;
|
|
96
|
+
* failures are logged.
|
|
97
|
+
*
|
|
98
|
+
* It runs in the process that took the delivery, so a restart while a run
|
|
99
|
+
* is in flight loses it; a run Studio resumes has no delivery, so it gets
|
|
100
|
+
* none.
|
|
101
|
+
*/
|
|
102
|
+
onSettled?(target: JsonValue, delivery: HttpSettledDelivery): Promise<void>;
|
|
37
103
|
}
|
|
104
|
+
/** A delivery's thread, for notices and links into LangSmith Studio. */
|
|
105
|
+
export interface HttpDelivery {
|
|
106
|
+
threadId: string;
|
|
107
|
+
/** The assistant that runs on the thread, when known. */
|
|
108
|
+
assistantId?: string;
|
|
109
|
+
/** The provider event `parse` returned, if any. */
|
|
110
|
+
rawEvent?: JsonValue;
|
|
111
|
+
}
|
|
112
|
+
/** A delivery and how it ended; see {@link HttpChannelAdapter.onSettled}. */
|
|
113
|
+
export type HttpSettledDelivery = HttpDelivery & {
|
|
114
|
+
outcome: HttpDeliveryOutcome;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* How a delivery ended. A message that started a run carries its `runId`:
|
|
118
|
+
*
|
|
119
|
+
* - `completed`: the run finished.
|
|
120
|
+
* - `interrupted`: it stopped on interrupts, so the thread waits on a
|
|
121
|
+
* decision, made in Studio.
|
|
122
|
+
* - `cancelled`: a cancel, or a newer message's `interrupt`, ended it.
|
|
123
|
+
* - `replaced`: a newer message's `rollback` deleted it.
|
|
124
|
+
* - `failed`: it failed, after `onError`. Without a `runId`, MDA couldn't
|
|
125
|
+
* start one.
|
|
126
|
+
* - `unknown`: MDA lost track of it; it may have answered.
|
|
127
|
+
*
|
|
128
|
+
* A message that started no run:
|
|
129
|
+
*
|
|
130
|
+
* - `waiting`: the thread waits on a decision.
|
|
131
|
+
* - `rejected`: the thread was busy and `multitaskStrategy` is `reject`.
|
|
132
|
+
* - `declined`: `input` returned nothing.
|
|
133
|
+
* - `dropped`: a cancel stopped the thread while the message waited for it.
|
|
134
|
+
* - `duplicate`: the thread already ran this `deliveryKey`.
|
|
135
|
+
*
|
|
136
|
+
* A cancel is `stopped`, with how many of the thread's runs were active.
|
|
137
|
+
*/
|
|
138
|
+
export type HttpDeliveryOutcome = {
|
|
139
|
+
type: "completed" | "interrupted" | "cancelled" | "replaced" | "unknown";
|
|
140
|
+
runId: string;
|
|
141
|
+
} | {
|
|
142
|
+
type: "failed";
|
|
143
|
+
runId?: string;
|
|
144
|
+
} | {
|
|
145
|
+
type: "waiting" | "rejected" | "declined" | "dropped" | "duplicate";
|
|
146
|
+
} | {
|
|
147
|
+
type: "stopped";
|
|
148
|
+
cancelled: number;
|
|
149
|
+
};
|
|
38
150
|
export interface HttpChannelRequest {
|
|
39
151
|
request: Request;
|
|
40
152
|
rawBody: Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/channels/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
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,C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,GAAG,UAAU,GAAG,SAAS,CAAC;IACzE,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAClC;IACE,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC;CACrE,GACD;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3C,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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