managed-deepagents 0.8.0-dev.5 → 0.8.0-dev.6
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 +131 -74
- package/dist/agent-auth.d.ts +2 -2
- package/dist/agent-auth.d.ts.map +1 -1
- package/dist/agent-auth.js +8 -5
- package/dist/agent-auth.js.map +1 -1
- package/dist/channels/assistant-text.d.ts +5 -1
- package/dist/channels/assistant-text.d.ts.map +1 -1
- package/dist/channels/assistant-text.js +26 -7
- package/dist/channels/assistant-text.js.map +1 -1
- package/dist/channels/binding.d.ts +7 -30
- package/dist/channels/binding.d.ts.map +1 -1
- package/dist/channels/binding.js +53 -55
- package/dist/channels/binding.js.map +1 -1
- package/dist/channels/http/http.d.ts +4 -0
- package/dist/channels/http/http.d.ts.map +1 -0
- package/dist/channels/http/http.js +168 -0
- package/dist/channels/http/http.js.map +1 -0
- package/dist/channels/http/index.d.ts +8 -0
- package/dist/channels/http/index.d.ts.map +1 -0
- package/dist/channels/http/index.js +36 -0
- package/dist/channels/http/index.js.map +1 -0
- package/dist/channels/http/ingress.d.ts +21 -0
- package/dist/channels/http/ingress.d.ts.map +1 -0
- package/dist/channels/http/ingress.js +67 -0
- package/dist/channels/http/ingress.js.map +1 -0
- package/dist/channels/http/types.d.ts +35 -0
- package/dist/channels/http/types.d.ts.map +1 -0
- package/dist/channels/http/types.js +2 -0
- package/dist/channels/http/types.js.map +1 -0
- package/dist/channels/manifest.d.ts +2 -0
- package/dist/channels/manifest.d.ts.map +1 -1
- package/dist/channels/message-schema.d.ts +22 -0
- package/dist/channels/message-schema.d.ts.map +1 -0
- package/dist/channels/message-schema.js +38 -0
- package/dist/channels/message-schema.js.map +1 -0
- package/dist/channels/messaging-registry.d.ts +3 -4
- package/dist/channels/messaging-registry.d.ts.map +1 -1
- package/dist/channels/messaging-registry.js +15 -11
- package/dist/channels/messaging-registry.js.map +1 -1
- package/dist/channels/runtime.d.ts +13 -28
- package/dist/channels/runtime.d.ts.map +1 -1
- package/dist/channels/runtime.js +39 -63
- package/dist/channels/runtime.js.map +1 -1
- package/dist/channels/schedule-delivery.d.ts.map +1 -1
- package/dist/channels/schedule-delivery.js +2 -3
- package/dist/channels/schedule-delivery.js.map +1 -1
- package/dist/channels/slack/index.d.ts +0 -28
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +1 -6
- package/dist/channels/slack/index.js.map +1 -1
- package/dist/channels/slack/transport.d.ts +3 -31
- package/dist/channels/slack/transport.d.ts.map +1 -1
- package/dist/channels/slack/transport.js +19 -101
- package/dist/channels/slack/transport.js.map +1 -1
- package/dist/channels/source-providers.d.ts +13 -0
- package/dist/channels/source-providers.d.ts.map +1 -0
- package/dist/channels/source-providers.js +29 -0
- package/dist/channels/source-providers.js.map +1 -0
- package/dist/channels/trigger/http.d.ts +8 -4
- package/dist/channels/trigger/http.d.ts.map +1 -1
- package/dist/channels/trigger/http.js +13 -9
- package/dist/channels/trigger/http.js.map +1 -1
- package/dist/channels/trigger/ingress.d.ts +60 -0
- package/dist/channels/trigger/ingress.d.ts.map +1 -0
- package/dist/channels/trigger/ingress.js +124 -0
- package/dist/channels/trigger/ingress.js.map +1 -0
- package/dist/channels/trigger/transport.d.ts +6 -0
- package/dist/channels/trigger/transport.d.ts.map +1 -0
- package/dist/channels/trigger/transport.js +28 -0
- package/dist/channels/trigger/transport.js.map +1 -0
- package/dist/channels/trigger/types.d.ts +4 -10
- package/dist/channels/trigger/types.d.ts.map +1 -1
- package/dist/channels/trigger/types.js +44 -15
- package/dist/channels/trigger/types.js.map +1 -1
- package/dist/channels/types.d.ts +30 -60
- package/dist/channels/types.d.ts.map +1 -1
- package/dist/channels/types.js.map +1 -1
- package/dist/connections.d.ts +2 -1
- package/dist/connections.d.ts.map +1 -1
- package/dist/connections.js +8 -2
- package/dist/connections.js.map +1 -1
- package/dist/extension.d.ts +2 -2
- package/dist/extension.d.ts.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/ingress/index.d.ts +14 -94
- package/dist/ingress/index.d.ts.map +1 -1
- package/dist/ingress/index.js +10 -252
- package/dist/ingress/index.js.map +1 -1
- package/dist/ingress/loopback.d.ts +10 -0
- package/dist/ingress/loopback.d.ts.map +1 -0
- package/dist/ingress/loopback.js +40 -0
- package/dist/ingress/loopback.js.map +1 -0
- package/dist/ingress/runs.d.ts +33 -0
- package/dist/ingress/runs.d.ts.map +1 -0
- package/dist/ingress/runs.js +38 -0
- package/dist/ingress/runs.js.map +1 -0
- package/dist/memory/types.d.ts +4 -4
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/namespaces.d.ts +9 -1
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +2 -0
- package/dist/namespaces.js.map +1 -1
- package/dist/run-context.d.ts +56 -11
- package/dist/run-context.d.ts.map +1 -1
- package/dist/run-context.js +28 -0
- package/dist/run-context.js.map +1 -1
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +2 -10
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/channel.d.ts +3 -2
- package/dist/runtime/channel.d.ts.map +1 -1
- package/dist/runtime/channel.js +2 -0
- package/dist/runtime/channel.js.map +1 -1
- package/dist/runtime/connector.d.ts +2 -2
- package/dist/runtime/connector.d.ts.map +1 -1
- package/dist/runtime/connector.js +2 -0
- package/dist/runtime/connector.js.map +1 -1
- package/dist/runtime/identity-http.d.ts.map +1 -1
- package/dist/runtime/identity-http.js +3 -0
- package/dist/runtime/identity-http.js.map +1 -1
- package/dist/runtime/identity-runtime.js +3 -6
- package/dist/runtime/identity-runtime.js.map +1 -1
- package/dist/runtime/index.d.ts +3 -3
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +21 -10
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/managed-tools.d.ts +2 -1
- package/dist/runtime/managed-tools.d.ts.map +1 -1
- package/dist/runtime/managed-tools.js +11 -1
- package/dist/runtime/managed-tools.js.map +1 -1
- package/dist/runtime/memory/policy.d.ts +1 -1
- package/dist/runtime/memory/policy.d.ts.map +1 -1
- package/dist/runtime/memory/policy.js +12 -30
- package/dist/runtime/memory/policy.js.map +1 -1
- package/dist/runtime/run-input.d.ts +31 -0
- package/dist/runtime/run-input.d.ts.map +1 -0
- package/dist/runtime/run-input.js +20 -0
- package/dist/runtime/run-input.js.map +1 -0
- package/dist/runtime/types.d.ts +6 -1
- package/dist/runtime/types.d.ts.map +1 -1
- package/package.json +7 -7
- package/dist/channels/registry-store.d.ts +0 -12
- package/dist/channels/registry-store.d.ts.map +0 -1
- package/dist/channels/registry-store.js +0 -18
- package/dist/channels/registry-store.js.map +0 -1
- package/dist/channels/registry-types.d.ts +0 -32
- package/dist/channels/registry-types.d.ts.map +0 -1
- package/dist/channels/registry-types.js +0 -5
- package/dist/channels/registry-types.js.map +0 -1
- package/dist/channels/registry.d.ts +0 -15
- package/dist/channels/registry.d.ts.map +0 -1
- package/dist/channels/registry.js +0 -24
- package/dist/channels/registry.js.map +0 -1
- package/dist/channels/slack/adapter-core.d.ts +0 -6
- package/dist/channels/slack/adapter-core.d.ts.map +0 -1
- package/dist/channels/slack/adapter-core.js +0 -24
- package/dist/channels/slack/adapter-core.js.map +0 -1
- package/dist/channels/slack/adapter.d.ts +0 -9
- package/dist/channels/slack/adapter.d.ts.map +0 -1
- package/dist/channels/slack/adapter.js +0 -20
- package/dist/channels/slack/adapter.js.map +0 -1
- package/dist/channels/slack/http.d.ts +0 -65
- package/dist/channels/slack/http.d.ts.map +0 -1
- package/dist/channels/slack/http.js +0 -403
- package/dist/channels/slack/http.js.map +0 -1
- package/dist/channels/slack/normalize.d.ts +0 -64
- package/dist/channels/slack/normalize.d.ts.map +0 -1
- package/dist/channels/slack/normalize.js +0 -353
- package/dist/channels/slack/normalize.js.map +0 -1
- package/dist/channels/slack/source-thread.d.ts +0 -34
- package/dist/channels/slack/source-thread.d.ts.map +0 -1
- package/dist/channels/slack/source-thread.js +0 -92
- package/dist/channels/slack/source-thread.js.map +0 -1
- package/dist/channels/store.d.ts +0 -65
- package/dist/channels/store.d.ts.map +0 -1
- package/dist/channels/store.js +0 -90
- package/dist/channels/store.js.map +0 -1
package/dist/ingress/index.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Managed ingress pipeline: verified inbound event → agent run.
|
|
3
|
-
*
|
|
4
|
-
* Providers keep signature verification, event normalization, and reply
|
|
5
|
-
* transport. This module owns the shared pieces: deterministic thread ids,
|
|
6
|
-
* trusted loopback invoke with source-provider stamps, and source-thread
|
|
7
|
-
* existence probes.
|
|
8
|
-
*/
|
|
9
|
-
import { createHash } from "node:crypto";
|
|
10
|
-
import { Client } from "@langchain/langgraph-sdk";
|
|
11
|
-
import { extractAssistantText } from "../channels/assistant-text.js";
|
|
12
|
-
import { CHANNEL_BINDING_KEY, } from "../channels/binding.js";
|
|
13
|
-
import { ChannelError } from "../channels/errors.js";
|
|
14
|
-
import { isLoopbackUrl, resolveLoopbackApiKey, resolveLoopbackApiUrl, } from "../identity/loopback.js";
|
|
15
|
-
import { HANDOFF_SECRET_ENV, HANDOFF_SECRET_HEADER, USER_HEADER, INGRESS_SECRET_ENV, INGRESS_SECRET_HEADER, LANGCHAIN_API_KEY_ENV, LANGSMITH_API_KEY_ENV, AGENT_AUTH_PRINCIPAL_HEADER, SOURCE_PROVIDER_HEADER, SOURCE_THREAD_HEADER, } from "../runtime/auth.js";
|
|
16
1
|
/**
|
|
17
2
|
* Schedule background work after the provider ACK. Defaults to fire-and-forget
|
|
18
3
|
* with error logging; tests pass an inline runner.
|
|
@@ -26,245 +11,18 @@ export function scheduleIngressWork(work, options) {
|
|
|
26
11
|
});
|
|
27
12
|
schedule(work);
|
|
28
13
|
}
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (!hasLoopbackCredential()) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
const client = createIngressLoopbackClient({
|
|
40
|
-
userId: input.userId,
|
|
41
|
-
sourceThreadKey: input.sourceThreadKey,
|
|
42
|
-
});
|
|
43
|
-
const threadId = stableThreadId(input.sourceThreadKey);
|
|
44
|
-
try {
|
|
45
|
-
await client.threads.get(threadId);
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Parked interrupts on a thread. A thread that does not exist has none.
|
|
54
|
-
*
|
|
55
|
-
* Any other lookup failure propagates: reporting "nothing parked" would start a
|
|
56
|
-
* fresh turn and abandon the checkpoint the answer was meant to resume.
|
|
57
|
-
*/
|
|
58
|
-
export async function ingressThreadInterrupts(input) {
|
|
59
|
-
const client = createTriggerIngressLoopbackClient({
|
|
60
|
-
provider: input.sourceProvider,
|
|
61
|
-
threadKey: input.sourceThreadKey,
|
|
62
|
-
userId: input.userId,
|
|
63
|
-
});
|
|
64
|
-
let thread;
|
|
65
|
-
try {
|
|
66
|
-
thread = await client.threads.get(input.threadId);
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
if (lookupStatus(error) === 404)
|
|
70
|
-
return [];
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
const pending = [];
|
|
74
|
-
// Keyed by task id; resume keys on the interrupt id alone.
|
|
75
|
-
for (const entries of Object.values(thread.interrupts ?? {})) {
|
|
76
|
-
for (const { id, value } of entries) {
|
|
77
|
-
if (typeof id === "string" &&
|
|
78
|
-
id.trim() &&
|
|
79
|
-
!pending.some((p) => p.id === id)) {
|
|
80
|
-
pending.push({ id, value });
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return pending;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* HTTP status behind a failed loopback read.
|
|
88
|
-
*
|
|
89
|
-
* `AsyncCaller.fetch` rejects with the raw `Response`, so the status is usually
|
|
90
|
-
* on the thrown value itself; wrapped clients expose it under `response`.
|
|
91
|
-
*/
|
|
92
|
-
function lookupStatus(error) {
|
|
93
|
-
if (typeof error !== "object" || error === null)
|
|
94
|
-
return undefined;
|
|
95
|
-
const direct = error.status;
|
|
96
|
-
if (typeof direct === "number")
|
|
97
|
-
return direct;
|
|
98
|
-
const response = error.response;
|
|
99
|
-
if (typeof response !== "object" || response === null)
|
|
100
|
-
return undefined;
|
|
101
|
-
const nested = response.status;
|
|
102
|
-
return typeof nested === "number" ? nested : undefined;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Invoke the managed graph over a trusted loopback with ingress identity stamped.
|
|
106
|
-
*
|
|
107
|
-
* Only this path may set `x-mda-source-provider` / `x-mda-source-thread-id`.
|
|
108
|
-
*/
|
|
109
|
-
export async function invokeIngressAgent(input) {
|
|
110
|
-
if (!hasLoopbackCredential()) {
|
|
111
|
-
throw new ChannelError("channel_run_failed", "managed loopback authentication is not configured");
|
|
14
|
+
/** Agent Server accepts context or configurable, never both. */
|
|
15
|
+
export function buildIngressRunContext(input) {
|
|
16
|
+
if (input.context && "channel" in input.context)
|
|
17
|
+
throw new Error("context.channel is reserved for managed ingress");
|
|
18
|
+
if (input.config?.configurable &&
|
|
19
|
+
Object.keys(input.config.configurable).length) {
|
|
20
|
+
throw new Error("managed ingress cannot combine context and config.configurable");
|
|
112
21
|
}
|
|
113
|
-
const
|
|
114
|
-
userId: input.userId,
|
|
115
|
-
sourceThreadKey: input.sourceThreadKey,
|
|
116
|
-
sourceProvider: input.sourceProvider ?? input.binding.provider,
|
|
117
|
-
});
|
|
118
|
-
const threadId = stableThreadId(input.sourceThreadKey);
|
|
119
|
-
try {
|
|
120
|
-
await client.threads.create({
|
|
121
|
-
threadId,
|
|
122
|
-
metadata: { owner: input.sourceThreadKey },
|
|
123
|
-
ifExists: "do_nothing",
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
// Some SDK versions use different ifExists semantics; continue and let run fail loudly.
|
|
128
|
-
}
|
|
129
|
-
const run = (await client.runs.wait(threadId, input.assistantId, {
|
|
130
|
-
input: {
|
|
131
|
-
messages: [{ role: "human", content: input.text }],
|
|
132
|
-
},
|
|
133
|
-
config: {
|
|
134
|
-
configurable: {
|
|
135
|
-
[CHANNEL_BINDING_KEY]: input.binding,
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
}));
|
|
22
|
+
const { configurable: _ignored, ...config } = input.config ?? {};
|
|
139
23
|
return {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
threadId,
|
|
24
|
+
context: { ...input.context, channel: input.binding },
|
|
25
|
+
...(Object.keys(config).length ? { config } : {}),
|
|
143
26
|
};
|
|
144
27
|
}
|
|
145
|
-
/** Create a Trigger-addressed thread and enqueue its run. */
|
|
146
|
-
export async function startIngressAgent(input) {
|
|
147
|
-
const client = createTriggerIngressLoopbackClient({
|
|
148
|
-
provider: input.sourceProvider,
|
|
149
|
-
threadKey: input.sourceThreadKey,
|
|
150
|
-
userId: input.userId,
|
|
151
|
-
});
|
|
152
|
-
await client.threads.create({
|
|
153
|
-
threadId: input.threadId,
|
|
154
|
-
ifExists: "do_nothing",
|
|
155
|
-
});
|
|
156
|
-
const run = await client.runs.create(input.threadId, input.assistantId, {
|
|
157
|
-
input: { messages: input.messages },
|
|
158
|
-
...(input.context ? { context: input.context } : {}),
|
|
159
|
-
multitaskStrategy: "enqueue",
|
|
160
|
-
});
|
|
161
|
-
if (typeof run.run_id !== "string" || !run.run_id.trim()) {
|
|
162
|
-
throw new ChannelError("channel_run_failed", "Agent Server did not return run_id");
|
|
163
|
-
}
|
|
164
|
-
return { threadId: input.threadId, runId: run.run_id };
|
|
165
|
-
}
|
|
166
|
-
/** Resume a Trigger-addressed thread with a keyed interrupt response. */
|
|
167
|
-
export async function resumeIngressAgent(input) {
|
|
168
|
-
const client = createTriggerIngressLoopbackClient({
|
|
169
|
-
provider: input.sourceProvider,
|
|
170
|
-
threadKey: input.sourceThreadKey,
|
|
171
|
-
userId: input.userId,
|
|
172
|
-
});
|
|
173
|
-
const run = await client.runs.create(input.threadId, input.assistantId, {
|
|
174
|
-
command: { resume: input.resume },
|
|
175
|
-
...(input.context ? { context: input.context } : {}),
|
|
176
|
-
multitaskStrategy: "enqueue",
|
|
177
|
-
});
|
|
178
|
-
if (typeof run.run_id !== "string" || !run.run_id.trim()) {
|
|
179
|
-
throw new ChannelError("channel_run_failed", "Agent Server did not return run_id");
|
|
180
|
-
}
|
|
181
|
-
return { threadId: input.threadId, runId: run.run_id };
|
|
182
|
-
}
|
|
183
|
-
/** Join an accepted Trigger run and read its terminal status. */
|
|
184
|
-
export async function observeIngressAgent(input) {
|
|
185
|
-
const client = createTriggerIngressLoopbackClient({
|
|
186
|
-
provider: input.sourceProvider,
|
|
187
|
-
threadKey: input.sourceThreadKey,
|
|
188
|
-
userId: input.userId,
|
|
189
|
-
});
|
|
190
|
-
const values = await client.runs.join(input.threadId, input.runId);
|
|
191
|
-
const run = await client.runs.get(input.threadId, input.runId);
|
|
192
|
-
if (!isIngressRunStatus(run.status)) {
|
|
193
|
-
throw new ChannelError("channel_run_failed", "Agent Server returned an unknown run status");
|
|
194
|
-
}
|
|
195
|
-
return { values, status: run.status };
|
|
196
|
-
}
|
|
197
|
-
function createTriggerIngressLoopbackClient(source) {
|
|
198
|
-
const apiKey = process.env[LANGCHAIN_API_KEY_ENV]?.trim();
|
|
199
|
-
if (!apiKey) {
|
|
200
|
-
throw new ChannelError("channel_run_failed", "managed loopback authentication is not configured");
|
|
201
|
-
}
|
|
202
|
-
const userId = source.userId.trim();
|
|
203
|
-
if (!userId) {
|
|
204
|
-
throw new ChannelError("channel_run_failed", "channel run requires an identity_context principal");
|
|
205
|
-
}
|
|
206
|
-
const headers = {
|
|
207
|
-
[USER_HEADER]: userId,
|
|
208
|
-
[AGENT_AUTH_PRINCIPAL_HEADER]: userId,
|
|
209
|
-
[SOURCE_PROVIDER_HEADER]: source.provider,
|
|
210
|
-
[SOURCE_THREAD_HEADER]: source.threadKey,
|
|
211
|
-
};
|
|
212
|
-
return new Client({
|
|
213
|
-
apiUrl: resolveLoopbackApiUrl(),
|
|
214
|
-
apiKey,
|
|
215
|
-
defaultHeaders: headers,
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
function isIngressRunStatus(value) {
|
|
219
|
-
return (value === "error" ||
|
|
220
|
-
value === "success" ||
|
|
221
|
-
value === "timeout" ||
|
|
222
|
-
value === "interrupted");
|
|
223
|
-
}
|
|
224
|
-
function createIngressLoopbackClient(input) {
|
|
225
|
-
const apiUrl = resolveLoopbackApiUrl();
|
|
226
|
-
const apiKey = resolveLoopbackApiKey();
|
|
227
|
-
const isLocal = isLoopbackUrl(apiUrl);
|
|
228
|
-
const handoffSecret = isLocal
|
|
229
|
-
? process.env[HANDOFF_SECRET_ENV]?.trim()
|
|
230
|
-
: undefined;
|
|
231
|
-
const serverApiKey = process.env[LANGSMITH_API_KEY_ENV]?.trim();
|
|
232
|
-
const ingressSecret = isLocal
|
|
233
|
-
? process.env[INGRESS_SECRET_ENV]?.trim()
|
|
234
|
-
: undefined;
|
|
235
|
-
const headers = {
|
|
236
|
-
[USER_HEADER]: input.userId,
|
|
237
|
-
[SOURCE_PROVIDER_HEADER]: input.sourceProvider ?? "slack",
|
|
238
|
-
[SOURCE_THREAD_HEADER]: input.sourceThreadKey,
|
|
239
|
-
};
|
|
240
|
-
if (handoffSecret) {
|
|
241
|
-
headers[HANDOFF_SECRET_HEADER] = handoffSecret;
|
|
242
|
-
}
|
|
243
|
-
else if (!serverApiKey && ingressSecret) {
|
|
244
|
-
headers[INGRESS_SECRET_HEADER] = ingressSecret;
|
|
245
|
-
}
|
|
246
|
-
return new Client({
|
|
247
|
-
apiUrl,
|
|
248
|
-
apiKey,
|
|
249
|
-
defaultHeaders: headers,
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
function hasLoopbackCredential() {
|
|
253
|
-
const isLocal = isLoopbackUrl(resolveLoopbackApiUrl());
|
|
254
|
-
return Boolean(process.env[LANGSMITH_API_KEY_ENV]?.trim() ||
|
|
255
|
-
(isLocal &&
|
|
256
|
-
(process.env[HANDOFF_SECRET_ENV]?.trim() ||
|
|
257
|
-
process.env[INGRESS_SECRET_ENV]?.trim())));
|
|
258
|
-
}
|
|
259
|
-
/** Deterministic LangGraph thread id from a provider source-thread key. */
|
|
260
|
-
export function stableThreadId(sourceThreadKey) {
|
|
261
|
-
const hex = createHash("sha256").update(sourceThreadKey).digest("hex");
|
|
262
|
-
return [
|
|
263
|
-
hex.slice(0, 8),
|
|
264
|
-
hex.slice(8, 12),
|
|
265
|
-
`5${hex.slice(13, 16)}`,
|
|
266
|
-
`a${hex.slice(17, 20)}`,
|
|
267
|
-
hex.slice(20, 32),
|
|
268
|
-
].join("-");
|
|
269
|
-
}
|
|
270
28
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ingress/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ingress/index.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,IAAyB,EACzB,OAGC;IAED,MAAM,QAAQ,GACZ,OAAO,CAAC,QAAQ;QAChB,CAAC,CAAC,EAAE,EAAE,EAAE;YACN,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;gBAC5B,OAAO,CAAC,KAAK,CAAC,SAAS,OAAO,CAAC,KAAK,UAAU,EAAE,KAAK,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,QAAQ,CAAC,IAAI,CAAC,CAAC;AACjB,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,sBAAsB,CAAC,KAItC;IACC,IAAI,KAAK,CAAC,OAAO,IAAI,SAAS,IAAI,KAAK,CAAC,OAAO;QAC7C,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,IACE,KAAK,CAAC,MAAM,EAAE,YAAY;QAC1B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,MAAM,EAC7C,CAAC;QACD,MAAM,IAAI,KAAK,CACb,gEAAgE,CACjE,CAAC;IACJ,CAAC;IACD,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;IACjE,OAAO;QACL,OAAO,EAAE,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;QACrD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAClD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Managed loopback authentication for HTTP channel ingress. */
|
|
2
|
+
import { Client } from "@langchain/langgraph-sdk";
|
|
3
|
+
import type { ChannelBinding } from "../channels/binding.js";
|
|
4
|
+
export declare function createIngressLoopbackClient(input: {
|
|
5
|
+
userId: string;
|
|
6
|
+
sourceThreadKey: string;
|
|
7
|
+
sourceProvider?: ChannelBinding["provider"];
|
|
8
|
+
}): Client;
|
|
9
|
+
export declare function hasLoopbackCredential(): boolean;
|
|
10
|
+
//# sourceMappingURL=loopback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopback.d.ts","sourceRoot":"","sources":["../../src/ingress/loopback.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAiB7D,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;CAC7C,GAAG,MAAM,CA0BT;AAED,wBAAgB,qBAAqB,IAAI,OAAO,CAQ/C"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Managed loopback authentication for HTTP channel ingress. */
|
|
2
|
+
import { Client } from "@langchain/langgraph-sdk";
|
|
3
|
+
import { isLoopbackUrl, resolveLoopbackApiKey, resolveLoopbackApiUrl, } from "../identity/loopback.js";
|
|
4
|
+
import { HANDOFF_SECRET_ENV, HANDOFF_SECRET_HEADER, USER_HEADER, INGRESS_SECRET_ENV, INGRESS_SECRET_HEADER, LANGSMITH_API_KEY_ENV, SOURCE_PROVIDER_HEADER, SOURCE_THREAD_HEADER, } from "../runtime/auth.js";
|
|
5
|
+
export function createIngressLoopbackClient(input) {
|
|
6
|
+
const apiUrl = resolveLoopbackApiUrl();
|
|
7
|
+
const apiKey = resolveLoopbackApiKey();
|
|
8
|
+
const isLocal = isLoopbackUrl(apiUrl);
|
|
9
|
+
const handoffSecret = isLocal
|
|
10
|
+
? process.env[HANDOFF_SECRET_ENV]?.trim()
|
|
11
|
+
: undefined;
|
|
12
|
+
const serverApiKey = process.env[LANGSMITH_API_KEY_ENV]?.trim();
|
|
13
|
+
const ingressSecret = isLocal
|
|
14
|
+
? process.env[INGRESS_SECRET_ENV]?.trim()
|
|
15
|
+
: undefined;
|
|
16
|
+
const headers = {
|
|
17
|
+
[USER_HEADER]: input.userId,
|
|
18
|
+
[SOURCE_PROVIDER_HEADER]: input.sourceProvider ?? "slack",
|
|
19
|
+
[SOURCE_THREAD_HEADER]: input.sourceThreadKey,
|
|
20
|
+
};
|
|
21
|
+
if (handoffSecret) {
|
|
22
|
+
headers[HANDOFF_SECRET_HEADER] = handoffSecret;
|
|
23
|
+
}
|
|
24
|
+
else if (!serverApiKey && ingressSecret) {
|
|
25
|
+
headers[INGRESS_SECRET_HEADER] = ingressSecret;
|
|
26
|
+
}
|
|
27
|
+
return new Client({
|
|
28
|
+
apiUrl,
|
|
29
|
+
apiKey,
|
|
30
|
+
defaultHeaders: headers,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function hasLoopbackCredential() {
|
|
34
|
+
const isLocal = isLoopbackUrl(resolveLoopbackApiUrl());
|
|
35
|
+
return Boolean(process.env[LANGSMITH_API_KEY_ENV]?.trim() ||
|
|
36
|
+
(isLocal &&
|
|
37
|
+
(process.env[HANDOFF_SECRET_ENV]?.trim() ||
|
|
38
|
+
process.env[INGRESS_SECRET_ENV]?.trim())));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=loopback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loopback.js","sourceRoot":"","sources":["../../src/ingress/loopback.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,UAAU,2BAA2B,CAAC,KAI3C;IACC,MAAM,MAAM,GAAG,qBAAqB,EAAE,CAAC;IACvC,MAAM,MAAM,GAAG,qBAAqB,EAAE,CAAC;IACvC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,aAAa,GAAG,OAAO;QAC3B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CA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+
*
|
|
4
|
+
* A channel verifies the delivery, builds an authenticated client, and normalizes
|
|
5
|
+
* its messages or resume data before calling these helpers. The channel owns
|
|
6
|
+
* acknowledgments, status handling, interrupts, and replies after observation.
|
|
7
|
+
*/
|
|
8
|
+
import type { Client, Config } from "@langchain/langgraph-sdk";
|
|
9
|
+
export interface StartedIngressRun {
|
|
10
|
+
threadId: string;
|
|
11
|
+
runId: string;
|
|
12
|
+
}
|
|
13
|
+
interface IngressRunInput {
|
|
14
|
+
threadId: string;
|
|
15
|
+
assistantId: string;
|
|
16
|
+
config?: Config;
|
|
17
|
+
context?: unknown;
|
|
18
|
+
}
|
|
19
|
+
/** Create the addressed thread and enqueue a run without waiting for its result. */
|
|
20
|
+
export declare function startIngressRun(client: Client, input: IngressRunInput & {
|
|
21
|
+
messages: Record<string, unknown>[];
|
|
22
|
+
}): Promise<StartedIngressRun>;
|
|
23
|
+
/** Enqueue a keyed interrupt response on an existing thread. */
|
|
24
|
+
export declare function resumeIngressRun(client: Client, input: IngressRunInput & {
|
|
25
|
+
resume: Record<string, unknown>;
|
|
26
|
+
}): Promise<StartedIngressRun>;
|
|
27
|
+
/** Join an accepted run, then read its status for the channel to interpret. */
|
|
28
|
+
export declare function observeIngressRun(client: Client, input: StartedIngressRun): Promise<{
|
|
29
|
+
values: unknown;
|
|
30
|
+
status: unknown;
|
|
31
|
+
}>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=runs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/ingress/runs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAI/D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,oFAAoF;AACpF,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,eAAe,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAA;CAAE,GAC/D,OAAO,CAAC,iBAAiB,CAAC,CAY5B;AAED,gEAAgE;AAChE,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,eAAe,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAC3D,OAAO,CAAC,iBAAiB,CAAC,CAQ5B;AAED,+EAA+E;AAC/E,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAC,CAI/C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ChannelError } from "../channels/errors.js";
|
|
2
|
+
/** Create the addressed thread and enqueue a run without waiting for its result. */
|
|
3
|
+
export async function startIngressRun(client, input) {
|
|
4
|
+
await client.threads.create({
|
|
5
|
+
threadId: input.threadId,
|
|
6
|
+
ifExists: "do_nothing",
|
|
7
|
+
});
|
|
8
|
+
const run = await client.runs.create(input.threadId, input.assistantId, {
|
|
9
|
+
input: { messages: input.messages },
|
|
10
|
+
...(input.config !== undefined ? { config: input.config } : {}),
|
|
11
|
+
...(input.context !== undefined ? { context: input.context } : {}),
|
|
12
|
+
multitaskStrategy: "enqueue",
|
|
13
|
+
});
|
|
14
|
+
return startedRun(input.threadId, run.run_id);
|
|
15
|
+
}
|
|
16
|
+
/** Enqueue a keyed interrupt response on an existing thread. */
|
|
17
|
+
export async function resumeIngressRun(client, input) {
|
|
18
|
+
const run = await client.runs.create(input.threadId, input.assistantId, {
|
|
19
|
+
command: { resume: input.resume },
|
|
20
|
+
...(input.config !== undefined ? { config: input.config } : {}),
|
|
21
|
+
...(input.context !== undefined ? { context: input.context } : {}),
|
|
22
|
+
multitaskStrategy: "enqueue",
|
|
23
|
+
});
|
|
24
|
+
return startedRun(input.threadId, run.run_id);
|
|
25
|
+
}
|
|
26
|
+
/** Join an accepted run, then read its status for the channel to interpret. */
|
|
27
|
+
export async function observeIngressRun(client, input) {
|
|
28
|
+
const values = await client.runs.join(input.threadId, input.runId);
|
|
29
|
+
const run = await client.runs.get(input.threadId, input.runId);
|
|
30
|
+
return { values, status: run.status };
|
|
31
|
+
}
|
|
32
|
+
function startedRun(threadId, runId) {
|
|
33
|
+
if (typeof runId !== "string" || !runId.trim()) {
|
|
34
|
+
throw new ChannelError("channel_run_failed", "Agent Server did not return run_id");
|
|
35
|
+
}
|
|
36
|
+
return { threadId, runId };
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=runs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs.js","sourceRoot":"","sources":["../../src/ingress/runs.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAcrD,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,KAAgE;IAEhE,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,YAAY;KACvB,CAAC,CAAC;IACH,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,EAAE;QACtE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE;QACnC,GAAG,CAAC,KAAK,CAAC,MA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K,CAAC,CAAC;IACnE,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC;AACxC,CAAC;AAED,SAAS,UAAU,CAAC,QAAgB,EAAE,KAAc;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,YAAY,CACpB,oBAAoB,EACpB,oCAAoC,CACrC,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC"}
|
package/dist/memory/types.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface AgentMemoryLayer<Context = ManagedRunContext> {
|
|
|
15
15
|
* excess property the union quietly accepts from `UserMemoryLayer`.
|
|
16
16
|
*/
|
|
17
17
|
id?: never;
|
|
18
|
-
allow?: (context: Context) => boolean | Promise<boolean>;
|
|
18
|
+
allow?: (context: ManagedRunContext<Context>) => boolean | Promise<boolean>;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Caller-scoped memory, keyed by the trusted principal.
|
|
@@ -28,7 +28,7 @@ export interface UserMemoryLayer<Context = ManagedRunContext> {
|
|
|
28
28
|
type: "user";
|
|
29
29
|
id?: string;
|
|
30
30
|
/** Evaluated per run. Omitted enables user memory only in managed Slack one-to-one DMs. */
|
|
31
|
-
allow?: (context: Context) => boolean | Promise<boolean>;
|
|
31
|
+
allow?: (context: ManagedRunContext<Context>) => boolean | Promise<boolean>;
|
|
32
32
|
}
|
|
33
33
|
/** One mounted layer. The union mirrors `CredentialOwner`. */
|
|
34
34
|
export type MemoryLayer<Context = ManagedRunContext> = AgentMemoryLayer<Context> | UserMemoryLayer<Context>;
|
|
@@ -42,12 +42,12 @@ export type MemoryLayerType = MemoryLayer["type"];
|
|
|
42
42
|
export type MemoryLayers<Context = ManagedRunContext> = MemoryLayer<Context>[];
|
|
43
43
|
/** A per-run policy. Omitted uses the selected layer's default. */
|
|
44
44
|
export interface MemoryLayerOptions<Context = ManagedRunContext> {
|
|
45
|
-
allow?: (context: Context) => boolean | Promise<boolean>;
|
|
45
|
+
allow?: (context: ManagedRunContext<Context>) => boolean | Promise<boolean>;
|
|
46
46
|
}
|
|
47
47
|
/** A layer declaration returned by `memoryLayer()`. */
|
|
48
48
|
export interface MemoryLayerDefinition<Context = ManagedRunContext> {
|
|
49
49
|
readonly kind: "memory-layer";
|
|
50
|
-
readonly allow?: (context: Context) => boolean | Promise<boolean>;
|
|
50
|
+
readonly allow?: (context: ManagedRunContext<Context>) => boolean | Promise<boolean>;
|
|
51
51
|
}
|
|
52
52
|
/** The memory declaration. Omitted layers are disabled. */
|
|
53
53
|
export interface MemoryOptions<Context = ManagedRunContext> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/memory/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D;;;;;;GAMG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB,CAAC,OAAO,GAAG,iBAAiB;IAC3D,IAAI,EAAE,OAAO,CAAC;IACd;;;;OAIG;IACH,EAAE,CAAC,EAAE,KAAK,CAAC;IACX,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/memory/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3D;;;;;;GAMG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB,CAAC,OAAO,GAA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AAC;CACjC;AAED,2DAA2D;AAC3D,MAAM,WAAW,aAAa,CAAC,OAAO,GAAG,iBAAiB;IACxD,KAAK,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC;IACtC;;;;OAIG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;CACvD;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAAC,OAAO,GAAG,iBAAiB;IACvD,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,+DAA+D;IAC/D,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;CACvC;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,OAAO,GAAG,iBAAiB;IAC3D,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;CACxC"}
|
package/dist/namespaces.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* These are the only primitives the managed runtime will mount. A project
|
|
16
16
|
* cannot contribute its own — `defineExtension` stays internal.
|
|
17
17
|
*/
|
|
18
|
+
import { httpChannel } from "./channels/http/index.js";
|
|
18
19
|
import { slackChannel } from "./channels/slack/index.js";
|
|
19
20
|
import { defineMcp } from "./connectors/mcp/index.js";
|
|
20
21
|
export { auth } from "./identity/index.js";
|
|
@@ -39,11 +40,18 @@ export interface Connectors {
|
|
|
39
40
|
*/
|
|
40
41
|
export declare const connectors: Connectors;
|
|
41
42
|
/**
|
|
42
|
-
* Inbound messaging surfaces. Exported from `channels/*`.
|
|
43
|
+
* Inbound messaging surfaces. Exported from `channels/*`.
|
|
43
44
|
*
|
|
44
45
|
* Docs live on this interface so IDE hover on `channels.<name>` stays useful.
|
|
45
46
|
*/
|
|
46
47
|
export interface Channels {
|
|
48
|
+
/**
|
|
49
|
+
* Declare a provider http as a managed channel.
|
|
50
|
+
*
|
|
51
|
+
* MDA verifies and parses each request through the supplied callbacks, then
|
|
52
|
+
* owns caller handoff, thread selection, agent invocation, and auto-reply.
|
|
53
|
+
*/
|
|
54
|
+
http: typeof httpChannel;
|
|
47
55
|
/**
|
|
48
56
|
* Slack ingress through Trigger Server and deploy requirements.
|
|
49
57
|
*
|
package/dist/namespaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespaces.d.ts","sourceRoot":"","sources":["../src/namespaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAMtD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,gBAAgB;AAChB,eAAO,MAAM,0BAA0B,gGACwD,CAAC;AAyBhG;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,GAAG,EAAE,OAAO,SAAS,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,UAExB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;;;;;;;;;;OAcG;IACH,KAAK,EAAE,OAAO,YAAY,CAAC;CAC5B;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"namespaces.d.ts","sourceRoot":"","sources":["../src/namespaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAMtD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,gBAAgB;AAChB,eAAO,MAAM,0BAA0B,gGACwD,CAAC;AAyBhG;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,GAAG,EAAE,OAAO,SAAS,CAAC;CACvB;AAED;;;GAGG;AACH,eAAO,MAAM,UAAU,EAAE,UAExB,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB;;;;;OAKG;IACH,IAAI,EAAE,OAAO,WAAW,CAAC;IACzB;;;;;;;;;;;;;;OAcG;IACH,KAAK,EAAE,OAAO,YAAY,CAAC;CAC5B;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,QAGtB,CAAC"}
|
package/dist/namespaces.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* These are the only primitives the managed runtime will mount. A project
|
|
16
16
|
* cannot contribute its own — `defineExtension` stays internal.
|
|
17
17
|
*/
|
|
18
|
+
import { httpChannel } from "./channels/http/index.js";
|
|
18
19
|
import { slackChannel } from "./channels/slack/index.js";
|
|
19
20
|
import { defineMcp } from "./connectors/mcp/index.js";
|
|
20
21
|
export { auth } from "./identity/index.js";
|
|
@@ -52,5 +53,6 @@ export const connectors = {
|
|
|
52
53
|
*/
|
|
53
54
|
export const channels = {
|
|
54
55
|
slack: slackChannel,
|
|
56
|
+
http: httpChannel,
|
|
55
57
|
};
|
|
56
58
|
//# sourceMappingURL=namespaces.js.map
|
package/dist/namespaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespaces.js","sourceRoot":"","sources":["../src/namespaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAMtD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAE3C,gB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AC,IAAI,CAAC,0BAA0B,CAAC,CAAC;AAC3C,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,MAAwB;IAC7C,4BAA4B,EAAE,CAAC;IAC/B,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC;AAgBD;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAe;IACpC,GAAG,EAAE,aAAa;CACnB,CAAC;AAiCF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAa;IAChC,KAAK,EAAE,YAAY;IACnB,IAAI,EAAE,WAAW;CAClB,CAAC"}
|
package/dist/run-context.d.ts
CHANGED
|
@@ -1,14 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Serializable routing and event data for the current managed delivery. */
|
|
3
|
+
export declare const channelContextSchema: z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
provider: z.ZodString;
|
|
6
|
+
sourceThreadKey: z.ZodString;
|
|
7
|
+
deliveryId: z.ZodString;
|
|
8
|
+
transport: z.ZodEnum<{
|
|
9
|
+
direct: "direct";
|
|
10
|
+
trigger_server: "trigger_server";
|
|
11
|
+
}>;
|
|
12
|
+
event: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
13
|
+
type: z.ZodLiteral<"message">;
|
|
14
|
+
messages: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
15
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
|
+
type: z.ZodLiteral<"interrupt_resume">;
|
|
17
|
+
resume: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
18
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
19
|
+
type: z.ZodLiteral<"user_prompt_response">;
|
|
20
|
+
action: z.ZodString;
|
|
21
|
+
value: z.ZodOptional<z.ZodJSONSchema>;
|
|
22
|
+
correlation_id: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>], "type">;
|
|
24
|
+
target: z.ZodJSONSchema;
|
|
25
|
+
rawEvent: z.ZodOptional<z.ZodJSONSchema>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export declare const managedChannelContextSchema: z.ZodObject<{
|
|
28
|
+
channel: z.ZodObject<{
|
|
29
|
+
name: z.ZodString;
|
|
30
|
+
provider: z.ZodString;
|
|
31
|
+
sourceThreadKey: z.ZodString;
|
|
32
|
+
deliveryId: z.ZodString;
|
|
33
|
+
transport: z.ZodEnum<{
|
|
34
|
+
direct: "direct";
|
|
35
|
+
trigger_server: "trigger_server";
|
|
36
|
+
}>;
|
|
37
|
+
event: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
38
|
+
type: z.ZodLiteral<"message">;
|
|
39
|
+
messages: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
|
|
40
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
41
|
+
type: z.ZodLiteral<"interrupt_resume">;
|
|
42
|
+
resume: z.ZodRecord<z.ZodString, z.ZodJSONSchema>;
|
|
43
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
44
|
+
type: z.ZodLiteral<"user_prompt_response">;
|
|
45
|
+
action: z.ZodString;
|
|
46
|
+
value: z.ZodOptional<z.ZodJSONSchema>;
|
|
47
|
+
correlation_id: z.ZodOptional<z.ZodString>;
|
|
48
|
+
}, z.core.$strip>], "type">;
|
|
49
|
+
target: z.ZodJSONSchema;
|
|
50
|
+
rawEvent: z.ZodOptional<z.ZodJSONSchema>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
export type ChannelContext = z.infer<typeof channelContextSchema>;
|
|
54
|
+
export type ManagedChannelContext = z.infer<typeof managedChannelContextSchema>;
|
|
55
|
+
/** Direct runs use the authored context; channel runs use the MDA contract. */
|
|
56
|
+
export type ManagedRunContext<AppContext = Record<string, unknown>> = AppContext | ManagedChannelContext;
|
|
12
57
|
/**
|
|
13
58
|
* Key an app sets on the value it passes to `interrupt()` so a later answer can
|
|
14
59
|
* be matched back to that interrupt. Carry the same id on the prompt you post.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-context.d.ts","sourceRoot":"","sources":["../src/run-context.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"run-context.d.ts","sourceRoot":"","sources":["../src/run-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgBxB,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;iBAS/B,CAAC;AACH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;iBAEtC,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,+EAA+E;AAC/E,MAAM,MAAM,iBAAiB,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAC9D,UAAU,GACV,qBAAqB,CAAC;AAE1B;;;GAGG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,mFAAmF;IACnF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,CAAC"}
|