managed-deepagents 0.5.4-dev.3 → 0.5.4-dev.31
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 +54 -11
- package/dist/channels/manifest.d.ts +2 -0
- package/dist/channels/manifest.d.ts.map +1 -1
- package/dist/channels/response-format.d.ts +5 -0
- package/dist/channels/response-format.d.ts.map +1 -0
- package/dist/channels/response-format.js +41 -0
- package/dist/channels/response-format.js.map +1 -0
- package/dist/channels/slack/index.d.ts +29 -71
- package/dist/channels/slack/index.d.ts.map +1 -1
- package/dist/channels/slack/index.js +56 -113
- package/dist/channels/slack/index.js.map +1 -1
- package/dist/channels/trigger/client.d.ts +30 -0
- package/dist/channels/trigger/client.d.ts.map +1 -0
- package/dist/channels/trigger/client.js +118 -0
- package/dist/channels/trigger/client.js.map +1 -0
- package/dist/channels/trigger/http.d.ts +27 -0
- package/dist/channels/trigger/http.d.ts.map +1 -0
- package/dist/channels/trigger/http.js +140 -0
- package/dist/channels/trigger/http.js.map +1 -0
- package/dist/channels/trigger/types.d.ts +46 -0
- package/dist/channels/trigger/types.d.ts.map +1 -0
- package/dist/channels/trigger/types.js +28 -0
- package/dist/channels/trigger/types.js.map +1 -0
- package/dist/channels/trigger/uuid.d.ts +3 -0
- package/dist/channels/trigger/uuid.d.ts.map +1 -0
- package/dist/channels/trigger/uuid.js +22 -0
- package/dist/channels/trigger/uuid.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/ingress/index.d.ts +22 -0
- package/dist/ingress/index.d.ts.map +1 -1
- package/dist/ingress/index.js +54 -1
- package/dist/ingress/index.js.map +1 -1
- package/dist/namespaces.d.ts +8 -6
- package/dist/namespaces.d.ts.map +1 -1
- package/dist/namespaces.js +1 -1
- package/dist/namespaces.js.map +1 -1
- package/dist/runtime/auth.d.ts +3 -0
- package/dist/runtime/auth.d.ts.map +1 -1
- package/dist/runtime/auth.js +20 -10
- package/dist/runtime/auth.js.map +1 -1
- package/dist/runtime/backend.d.ts.map +1 -1
- package/dist/runtime/backend.js +2 -1
- package/dist/runtime/backend.js.map +1 -1
- package/dist/runtime/channel.d.ts +5 -4
- package/dist/runtime/channel.d.ts.map +1 -1
- package/dist/runtime/channel.js.map +1 -1
- package/dist/runtime/identity-http.d.ts +3 -3
- package/dist/runtime/identity-http.d.ts.map +1 -1
- package/dist/runtime/identity-http.js +53 -12
- package/dist/runtime/identity-http.js.map +1 -1
- package/dist/runtime/index.d.ts +22 -8
- 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/sandbox-manager.d.ts +5 -4
- package/dist/runtime/sandbox-manager.d.ts.map +1 -1
- package/dist/runtime/sandbox-manager.js +39 -12
- package/dist/runtime/sandbox-manager.js.map +1 -1
- package/dist/runtime/sandbox-names.d.ts +9 -0
- package/dist/runtime/sandbox-names.d.ts.map +1 -0
- package/dist/runtime/sandbox-names.js +9 -0
- package/dist/runtime/sandbox-names.js.map +1 -0
- package/package.json +18 -17
package/README.md
CHANGED
|
@@ -45,26 +45,35 @@ per-platform optional dependencies, so install only downloads the binary for you
|
|
|
45
45
|
OS and CPU architecture. This npm-installed CLI scaffolds and compiles TypeScript
|
|
46
46
|
projects only and vendors the TypeScript runtime bundled with this package.
|
|
47
47
|
|
|
48
|
-
To start a new project, run `mda init
|
|
48
|
+
To start a new project, run `mda init`. In a terminal, the CLI asks you to name
|
|
49
|
+
the agent:
|
|
49
50
|
|
|
50
51
|
```bash
|
|
51
52
|
mda init
|
|
52
53
|
```
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
Run `mda init -i` to initialize your agent interactively and optionally hand it
|
|
56
|
+
off to a coding agent to build:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
mda init -i
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Choose a coding agent to continue in the new project, or select **View raw
|
|
63
|
+
prompt** to copy the setup instructions.
|
|
64
|
+
|
|
65
|
+
For coding agents and other headless use, pass the project name:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
mda init my-agent
|
|
69
|
+
```
|
|
59
70
|
|
|
60
71
|
`mda init` can shape the project up front — `--instructions "..."` (or
|
|
61
72
|
`--instructions-file <path>`) writes the system prompt, `--model <spec>` picks
|
|
62
|
-
the model, `--memory agent` opts into deployment-shared durable memory,
|
|
63
|
-
`--no-sandbox` leaves out the sandbox
|
|
73
|
+
the model, `--memory agent` opts into deployment-shared durable memory,
|
|
74
|
+
`--no-sandbox` leaves out the sandbox, and `-c slack` (also `--channel` /
|
|
75
|
+
`--channels`) writes `channels/slack.ts`. Every new project includes an
|
|
64
76
|
`identity.ts` that explicitly selects `auth.langsmithApiKey()` authentication.
|
|
65
|
-
Managed Deep Agent evals are Harbor tasks under `evals/tasks/`. Optionally create
|
|
66
|
-
a minimal source task under `evals/scaffold/` with `mda evals init <name>`, then
|
|
67
|
-
package the managed agent and scaffolded tasks with `mda evals compile`.
|
|
68
77
|
|
|
69
78
|
`mda init my-agent --gateway` runs the agent on
|
|
70
79
|
[LangSmith Gateway](https://docs.langchain.com/langsmith/gateway) — a model
|
|
@@ -72,6 +81,40 @@ LangSmith hosts, billed to your workspace's Gateway Credits, authenticated with
|
|
|
72
81
|
a LangSmith API key instead of a model provider key of your own. It is mutually
|
|
73
82
|
exclusive with `--model`, which names a provider you hold the key for.
|
|
74
83
|
|
|
84
|
+
## Evaluate
|
|
85
|
+
|
|
86
|
+
Managed Deep Agent evals run in Harbor. Install `uv` and Docker before running
|
|
87
|
+
them.
|
|
88
|
+
|
|
89
|
+
1. From the project root, initialize the eval workspace:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
mda evals init -i
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
2. Follow the coding-agent prompt to author tasks directly under
|
|
96
|
+
`evals/<task>/`. The CLI creates the user-owned `evals/harbor-job.json` once
|
|
97
|
+
and preserves later edits. `.mda/evals/` is generated.
|
|
98
|
+
A task may include an authored `evals/<task>/identity.json` fixture. It
|
|
99
|
+
requires a non-empty `user.id`; `user.kind`, `user.email`, and top-level
|
|
100
|
+
`groups`, `claims`, and `source.provider` are optional. Keep it with the
|
|
101
|
+
task, not in generated `.mda/evals/`.
|
|
102
|
+
3. Export `LANGSMITH_API_KEY`, `LANGSMITH_WORKSPACE_ID` when your credentials
|
|
103
|
+
require it, and the model or tool credential variables used by the agent.
|
|
104
|
+
4. From the same project root, run the pinned Harbor 0.21.0 command included at
|
|
105
|
+
the end of the coding-agent prompt. The command loads `MDAJobPlugin` and
|
|
106
|
+
`LangSmithPlugin`. It uses POSIX syntax on macOS/Linux and PowerShell on
|
|
107
|
+
native Windows.
|
|
108
|
+
5. From the same project root, inspect results:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
uv run --python 3.12 --with 'harbor[langsmith]==0.21.0' harbor view .mda/evals/jobs
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
`MDAJobPlugin` compiles a fresh eval artifact at every Harbor job start.
|
|
115
|
+
This POC keeps MDA's custom Harbor adapter; migration to Harbor's built-in
|
|
116
|
+
LangGraph agent is deferred.
|
|
117
|
+
|
|
75
118
|
## Define an Agent
|
|
76
119
|
|
|
77
120
|
Create an `agent.ts` that exports a named `agent` definition:
|
|
@@ -20,6 +20,8 @@ export interface ChannelManifest {
|
|
|
20
20
|
name: string;
|
|
21
21
|
/** Adapter key used by the runtime registry. */
|
|
22
22
|
provider: string;
|
|
23
|
+
/** Optional provider-neutral ingress transport discriminator. */
|
|
24
|
+
readonly transport?: "trigger_server";
|
|
23
25
|
/** Whether the managed runner should auto-reply after invoke. */
|
|
24
26
|
autoReply: boolean;
|
|
25
27
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/channels/manifest.ts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 -0,0 +1,5 @@
|
|
|
1
|
+
import { createMiddleware } from "langchain";
|
|
2
|
+
export declare const CHANNEL_RESPONSE_FORMAT_MIDDLEWARE_NAME = "mda-channel-response-format";
|
|
3
|
+
export declare const SLACK_MRKDWN_INSTRUCTIONS = "Your final response will be posted to Slack. Format it using Slack mrkdwn.";
|
|
4
|
+
export declare function createChannelResponseFormatMiddleware(): ReturnType<typeof createMiddleware>;
|
|
5
|
+
//# sourceMappingURL=response-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-format.d.ts","sourceRoot":"","sources":["../../src/channels/response-format.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,WAAW,CAAC;AAOhE,eAAO,MAAM,uCAAuC,gCACrB,CAAC;AAEhC,eAAO,MAAM,yBAAyB,+EACwC,CAAC;AAkC/E,wBAAgB,qCAAqC,IAAI,UAAU,CACjE,OAAO,gBAAgB,CACxB,CAWA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SystemMessage } from "@langchain/core/messages";
|
|
2
|
+
import { createMiddleware } from "langchain";
|
|
3
|
+
import { resolveRuntimeConfigurable, } from "../runtime/identity-runtime.js";
|
|
4
|
+
export const CHANNEL_RESPONSE_FORMAT_MIDDLEWARE_NAME = "mda-channel-response-format";
|
|
5
|
+
export const SLACK_MRKDWN_INSTRUCTIONS = "Your final response will be posted to Slack. Format it using Slack mrkdwn.";
|
|
6
|
+
function sourceProvider(request) {
|
|
7
|
+
const configurable = resolveRuntimeConfigurable(request.runtime);
|
|
8
|
+
const user = configurable?.langgraph_auth_user;
|
|
9
|
+
return user && typeof user === "object"
|
|
10
|
+
? user.mda_source_provider
|
|
11
|
+
: undefined;
|
|
12
|
+
}
|
|
13
|
+
function systemMessageBlocks(request) {
|
|
14
|
+
const existing = request.systemMessage?.content ?? request.systemPrompt;
|
|
15
|
+
if (typeof existing === "string") {
|
|
16
|
+
return existing.trim() ? [{ type: "text", text: existing }] : [];
|
|
17
|
+
}
|
|
18
|
+
return Array.isArray(existing) ? existing : [];
|
|
19
|
+
}
|
|
20
|
+
function appendSlackMrkdwnInstructions(request) {
|
|
21
|
+
return {
|
|
22
|
+
...request,
|
|
23
|
+
systemMessage: new SystemMessage({
|
|
24
|
+
content: [
|
|
25
|
+
...systemMessageBlocks(request),
|
|
26
|
+
{ type: "text", text: SLACK_MRKDWN_INSTRUCTIONS },
|
|
27
|
+
],
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function createChannelResponseFormatMiddleware() {
|
|
32
|
+
return createMiddleware({
|
|
33
|
+
name: CHANNEL_RESPONSE_FORMAT_MIDDLEWARE_NAME,
|
|
34
|
+
async wrapModelCall(request, handler) {
|
|
35
|
+
return handler(sourceProvider(request) === "slack"
|
|
36
|
+
? appendSlackMrkdwnInstructions(request)
|
|
37
|
+
: request);
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=response-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-format.js","sourceRoot":"","sources":["../../src/channels/response-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAqB,MAAM,WAAW,CAAC;AAEhE,OAAO,EACL,0BAA0B,GAE3B,MAAM,gCAAgC,CAAC;AAExC,MAAM,CAAC,MAAM,uCAAuC,GAClD,6BAA6B,CAAC;AAEhC,MAAM,CAAC,MAAM,yBAAyB,GACpC,4EAA4E,CAAC;AAI/E,SAAS,cAAc,CAAC,OAAqB;IAC3C,MAAM,YAAY,GAAG,0BAA0B,CAC7C,OAAO,CAAC,OAAuC,CAChD,CAAC;IACF,MAAM,IAAI,GAAG,YAAY,EAAE,mBAAmB,CAAC;IAC/C,OAAO,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QACrC,CAAC,CAAE,IAA0C,CAAC,mBAAmB;QACjE,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAqB;IAChD,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,EAAE,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC;IACxE,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAE,QAA2B,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,CAAC;AAED,SAAS,6BAA6B,CAAC,OAAqB;IAC1D,OAAO;QACL,GAAG,OAAO;QACV,aAAa,EAAE,IAAI,aAAa,CAAC;YAC/B,OAAO,EAAE;gBACP,GAAG,mBAAmB,CAAC,OAAO,CAAC;gBAC/B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAyB,EAAE;aAClD;SACF,CAAC;KACH,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qCAAqC;IAGnD,OAAO,gBAAgB,CAAC;QACtB,IAAI,EAAE,uCAAuC;QAC7C,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO;YAClC,OAAO,OAAO,CACZ,cAAc,CAAC,OAAO,CAAC,KAAK,OAAO;gBACjC,CAAC,CAAC,6BAA6B,CAAC,OAAO,CAAC;gBACxC,CAAC,CAAC,OAAO,CACZ,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,57 +1,38 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `channels.slack` — Slack Events ingress, messaging, and deploy requirements.
|
|
3
|
-
*
|
|
4
|
-
* Files under `channels/` export a named `channel` created with
|
|
5
|
-
* `channels.slack(...)`.
|
|
6
|
-
*
|
|
7
|
-
* Event Subscriptions and OAuth scopes are configured on the developer's Slack
|
|
8
|
-
* app (api.slack.com/apps). This authoring surface only covers MDA runtime
|
|
9
|
-
* behavior that the Slack app manifest cannot express.
|
|
10
|
-
*/
|
|
1
|
+
/** Trigger Server-backed Slack channel authoring surface. */
|
|
11
2
|
import type { ChannelManifest } from "../manifest.js";
|
|
12
3
|
import { type Channel } from "../../runtime/channel.js";
|
|
13
4
|
export type { ChannelManifest } from "../manifest.js";
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export type SlackMentionBehavior = "strip" | "preserve";
|
|
23
|
-
export type SlackConversationMapping = "thread" | "conversation" | "message";
|
|
24
|
-
export interface SlackChannelFilters {
|
|
25
|
-
includeConversations?: readonly string[];
|
|
26
|
-
excludeConversations?: readonly string[];
|
|
27
|
-
/** Fully-qualified mapped actor IDs such as `slack:T123:U456`. */
|
|
28
|
-
includeUsers?: readonly string[];
|
|
29
|
-
excludeUsers?: readonly string[];
|
|
30
|
-
/**
|
|
31
|
-
* Slack Connect shared conversations. Phase 1 rejects `true`.
|
|
32
|
-
* @default false
|
|
33
|
-
*/
|
|
34
|
-
allowSharedConversations?: boolean;
|
|
5
|
+
export interface SlackChannelConfig {
|
|
6
|
+
/** Your agent's name, used in mentions like `@support-agent`. */
|
|
7
|
+
name: string;
|
|
8
|
+
/** A short description of what your agent does. */
|
|
9
|
+
description?: string;
|
|
10
|
+
icon?: string;
|
|
11
|
+
triggerOnAllMessages?: boolean;
|
|
12
|
+
allowBotTriggers?: boolean;
|
|
35
13
|
}
|
|
36
|
-
export interface
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
directMessage?: SlackConversationMapping;
|
|
14
|
+
export interface TriggerSlackAppConfig {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
icon?: string;
|
|
41
18
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export interface SlackChannelConfig {
|
|
47
|
-
/** @default true */
|
|
48
|
-
autoReply?: boolean;
|
|
49
|
-
/** @default "strip" */
|
|
50
|
-
mentionBehavior?: SlackMentionBehavior;
|
|
51
|
-
filters?: SlackChannelFilters;
|
|
52
|
-
conversation?: SlackConversationPolicy;
|
|
19
|
+
export interface RequiredTriggerSlackChannelConfig {
|
|
20
|
+
app: TriggerSlackAppConfig;
|
|
21
|
+
triggerOnAllMessages: boolean;
|
|
22
|
+
allowBotTriggers: boolean;
|
|
53
23
|
}
|
|
54
|
-
/**
|
|
24
|
+
/** Branded Trigger-backed Slack declaration. */
|
|
25
|
+
export type SlackChannel = Channel & RequiredTriggerSlackChannelConfig & {
|
|
26
|
+
kind: "slack";
|
|
27
|
+
transport: "trigger_server";
|
|
28
|
+
};
|
|
29
|
+
/** Declare a Slack channel whose ingress and callbacks use Trigger Server. */
|
|
30
|
+
export declare function slackChannel(config: SlackChannelConfig): SlackChannel;
|
|
31
|
+
/** Build deploy/runtime requirements for a file-derived channel instance. */
|
|
32
|
+
export declare function toSlackRequirements(name: string, definition: RequiredTriggerSlackChannelConfig | SlackChannel): ChannelManifest;
|
|
33
|
+
export type SlackChannelTrigger = "app_mention" | "direct_message" | "thread_reply";
|
|
34
|
+
export type SlackMentionBehavior = "strip" | "preserve";
|
|
35
|
+
export type SlackConversationMapping = "thread" | "conversation" | "message";
|
|
55
36
|
export interface RequiredSlackChannelConfig {
|
|
56
37
|
autoReply: boolean;
|
|
57
38
|
mentionBehavior: SlackMentionBehavior;
|
|
@@ -67,29 +48,6 @@ export interface RequiredSlackChannelConfig {
|
|
|
67
48
|
directMessage: SlackConversationMapping;
|
|
68
49
|
};
|
|
69
50
|
}
|
|
70
|
-
/** Branded Slack channel declaration. */
|
|
71
|
-
export type SlackChannel = Channel & RequiredSlackChannelConfig & {
|
|
72
|
-
kind: "slack";
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Recommended bot token scopes for a BYO Slack app that handles Phase 1
|
|
76
|
-
* events (`app_mention`, DMs, and channel/group thread replies). Configure
|
|
77
|
-
* these under OAuth & Permissions on api.slack.com/apps — MDA does not
|
|
78
|
-
* provision the app.
|
|
79
|
-
*/
|
|
80
|
-
export declare const RECOMMENDED_SLACK_SCOPES: readonly ["app_mentions:read", "channels:history", "chat:write", "groups:history", "im:history"];
|
|
81
|
-
/**
|
|
82
|
-
* Declare a managed Slack channel. Files under `channels/*.ts` export a named
|
|
83
|
-
* `channel` created with `channels.slack(...)`.
|
|
84
|
-
*
|
|
85
|
-
* Subscribe to bot events and add OAuth scopes on your Slack app at
|
|
86
|
-
* api.slack.com/apps.
|
|
87
|
-
*/
|
|
88
|
-
export declare function slackChannel(config?: SlackChannelConfig): SlackChannel;
|
|
89
|
-
/** Recommended Slack OAuth scopes for a BYO app handling Phase 1 events. */
|
|
90
|
-
export declare function requiredSlackScopes(): string[];
|
|
91
|
-
/** Build deploy/runtime requirements for a file-derived channel name. */
|
|
92
|
-
export declare function toSlackRequirements(name: string, definition: RequiredSlackChannelConfig | SlackChannel): ChannelManifest;
|
|
93
51
|
export { decodeSlackEscaping, normalizeSlackEvent, verifySlackRequest, } from "./normalize.js";
|
|
94
52
|
export type { NormalizeSlackEventInput, NormalizeSlackEventResult, SlackInstallationContext, SlackSignatureHeaders, } from "./normalize.js";
|
|
95
53
|
export { createSlackWebApiTransport, setSlackAssistantStatus, DEFAULT_ASSISTANT_STATUS, DEFAULT_LOADING_MESSAGES, SLACK_API_BASE_ENV, } from "./transport.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/channels/slack/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/channels/slack/index.ts"],"names":[],"mappings":"AAAA,6D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AE,MAAM,cAAc,CAAC"}
|
|
@@ -1,143 +1,86 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `channels.slack` — Slack Events ingress, messaging, and deploy requirements.
|
|
3
|
-
*
|
|
4
|
-
* Files under `channels/` export a named `channel` created with
|
|
5
|
-
* `channels.slack(...)`.
|
|
6
|
-
*
|
|
7
|
-
* Event Subscriptions and OAuth scopes are configured on the developer's Slack
|
|
8
|
-
* app (api.slack.com/apps). This authoring surface only covers MDA runtime
|
|
9
|
-
* behavior that the Slack app manifest cannot express.
|
|
10
|
-
*/
|
|
1
|
+
/** Trigger Server-backed Slack channel authoring surface. */
|
|
11
2
|
import { z } from "zod";
|
|
3
|
+
import { handleTriggerChannelEventRequest } from "../trigger/http.js";
|
|
12
4
|
import { CHANNEL_BRAND, } from "../../runtime/channel.js";
|
|
13
|
-
import { handleSlackEventsRequest } from "./http.js";
|
|
14
|
-
import { createSlackWebApiTransport } from "./transport.js";
|
|
15
|
-
/** Env vars deploy must ensure for Slack Events + auto-reply. */
|
|
16
|
-
export const SLACK_CHANNEL_REQUIRED_ENV = [
|
|
17
|
-
"SLACK_SIGNING_SECRET",
|
|
18
|
-
"SLACK_BOT_TOKEN",
|
|
19
|
-
];
|
|
20
|
-
/**
|
|
21
|
-
* Recommended bot token scopes for a BYO Slack app that handles Phase 1
|
|
22
|
-
* events (`app_mention`, DMs, and channel/group thread replies). Configure
|
|
23
|
-
* these under OAuth & Permissions on api.slack.com/apps — MDA does not
|
|
24
|
-
* provision the app.
|
|
25
|
-
*/
|
|
26
|
-
export const RECOMMENDED_SLACK_SCOPES = [
|
|
27
|
-
"app_mentions:read",
|
|
28
|
-
"channels:history",
|
|
29
|
-
"chat:write",
|
|
30
|
-
"groups:history",
|
|
31
|
-
"im:history",
|
|
32
|
-
];
|
|
33
|
-
/** Slack IDs and mapped actor IDs, e.g. `C123` or `slack:T123:U456`. */
|
|
34
|
-
const identifiers = z
|
|
35
|
-
.array(z
|
|
36
|
-
.string("must be a list of non-empty strings")
|
|
37
|
-
.refine((entry) => entry.trim().length > 0, "must be a list of non-empty strings"))
|
|
38
|
-
.optional();
|
|
39
|
-
const conversationMapping = z.enum(["thread", "conversation", "message"], {
|
|
40
|
-
error: 'must be "thread", "conversation", or "message"',
|
|
41
|
-
});
|
|
42
5
|
const slackChannelConfig = z
|
|
43
6
|
.object({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
.
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
.object({
|
|
50
|
-
includeConversations: identifiers,
|
|
51
|
-
excludeConversations: identifiers,
|
|
52
|
-
includeUsers: identifiers,
|
|
53
|
-
excludeUsers: identifiers,
|
|
54
|
-
allowSharedConversations: z
|
|
55
|
-
.literal(false, { error: "is not supported in Phase 1" })
|
|
56
|
-
.default(false),
|
|
7
|
+
name: z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.refine((value) => [...value].length <= 35, {
|
|
11
|
+
message: "Must contain at most 35 characters",
|
|
57
12
|
})
|
|
58
|
-
.
|
|
59
|
-
|
|
60
|
-
.object({
|
|
61
|
-
appMention: conversationMapping.default("thread"),
|
|
62
|
-
directMessage: conversationMapping.default("conversation"),
|
|
13
|
+
.regex(/^[a-zA-Z0-9_.\- ]+$/, {
|
|
14
|
+
message: "Must contain only letters, numbers, spaces, underscores, dashes, and periods",
|
|
63
15
|
})
|
|
64
|
-
.
|
|
16
|
+
.refine((value) => !value.startsWith(" ") &&
|
|
17
|
+
!value.startsWith("-") &&
|
|
18
|
+
!value.endsWith(" ") &&
|
|
19
|
+
!value.endsWith("-"), { message: "Must not start or end with a space or dash" }),
|
|
20
|
+
description: z
|
|
21
|
+
.string()
|
|
22
|
+
.refine((value) => [...value].length <= 139, {
|
|
23
|
+
message: "Must contain at most 139 characters",
|
|
24
|
+
})
|
|
25
|
+
.default(""),
|
|
26
|
+
icon: z.string().min(1).optional(),
|
|
27
|
+
triggerOnAllMessages: z.boolean().default(false),
|
|
28
|
+
allowBotTriggers: z.boolean().default(false),
|
|
65
29
|
})
|
|
66
|
-
.strict()
|
|
67
|
-
.prefault({});
|
|
30
|
+
.strict();
|
|
68
31
|
function hide(target, key, value) {
|
|
69
32
|
Object.defineProperty(target, key, { value, enumerable: false });
|
|
70
33
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Declare a managed Slack channel. Files under `channels/*.ts` export a named
|
|
73
|
-
* `channel` created with `channels.slack(...)`.
|
|
74
|
-
*
|
|
75
|
-
* Subscribe to bot events and add OAuth scopes on your Slack app at
|
|
76
|
-
* api.slack.com/apps.
|
|
77
|
-
*/
|
|
34
|
+
/** Declare a Slack channel whose ingress and callbacks use Trigger Server. */
|
|
78
35
|
export function slackChannel(config) {
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
"under Event Subscriptions on your Slack app (api.slack.com/apps).");
|
|
83
|
-
}
|
|
84
|
-
const validate = slackChannelConfig["~standard"].validate;
|
|
85
|
-
const result = validate(config ?? {});
|
|
86
|
-
if (result instanceof Promise) {
|
|
87
|
-
throw new TypeError("channels.slack(...) needs a schema that validates synchronously");
|
|
88
|
-
}
|
|
89
|
-
if (result.issues) {
|
|
90
|
-
const message = result.issues
|
|
36
|
+
const result = slackChannelConfig.safeParse(config);
|
|
37
|
+
if (!result.success) {
|
|
38
|
+
const message = result.error.issues
|
|
91
39
|
.map((issue) => {
|
|
92
|
-
const path =
|
|
93
|
-
|
|
94
|
-
? segment.key
|
|
95
|
-
: segment))
|
|
96
|
-
.join(".");
|
|
97
|
-
return path.length > 0 ? `${path}: ${issue.message}` : issue.message;
|
|
40
|
+
const path = issue.path.join(".");
|
|
41
|
+
return path ? `${path}: ${issue.message}` : issue.message;
|
|
98
42
|
})
|
|
99
43
|
.join("; ");
|
|
100
44
|
throw new Error(`channels.slack(...) ${message}`);
|
|
101
45
|
}
|
|
102
|
-
const
|
|
103
|
-
const self = {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
filters: self.filters,
|
|
111
|
-
conversation: self.conversation,
|
|
46
|
+
const { name, description, icon, ...options } = result.data;
|
|
47
|
+
const self = {
|
|
48
|
+
kind: "slack",
|
|
49
|
+
transport: "trigger_server",
|
|
50
|
+
app: {
|
|
51
|
+
name,
|
|
52
|
+
description,
|
|
53
|
+
...(icon === undefined ? {} : { icon }),
|
|
112
54
|
},
|
|
55
|
+
...options,
|
|
56
|
+
};
|
|
57
|
+
hide(self, CHANNEL_BRAND, true);
|
|
58
|
+
hide(self, "events", (ctx) => handleTriggerChannelEventRequest(ctx.request, {
|
|
113
59
|
rawBody: ctx.rawBody,
|
|
60
|
+
sourceProvider: "slack",
|
|
114
61
|
}));
|
|
115
|
-
hide(self, "messaging", (env) => {
|
|
116
|
-
const token = env.SLACK_BOT_TOKEN;
|
|
117
|
-
if (!token)
|
|
118
|
-
return undefined;
|
|
119
|
-
return createSlackWebApiTransport({ botToken: token });
|
|
120
|
-
});
|
|
121
62
|
hide(self, "requirements", (name) => toSlackRequirements(name, self));
|
|
122
63
|
return self;
|
|
123
64
|
}
|
|
124
|
-
/**
|
|
125
|
-
export function requiredSlackScopes() {
|
|
126
|
-
return [...RECOMMENDED_SLACK_SCOPES];
|
|
127
|
-
}
|
|
128
|
-
/** Build deploy/runtime requirements for a file-derived channel name. */
|
|
65
|
+
/** Build deploy/runtime requirements for a file-derived channel instance. */
|
|
129
66
|
export function toSlackRequirements(name, definition) {
|
|
130
|
-
const config = definition;
|
|
131
67
|
return {
|
|
132
68
|
name,
|
|
133
69
|
provider: "slack",
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
70
|
+
transport: "trigger_server",
|
|
71
|
+
autoReply: true,
|
|
72
|
+
requiredPermissions: [],
|
|
73
|
+
requiredEnv: [],
|
|
137
74
|
providerConfig: {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
75
|
+
app: {
|
|
76
|
+
name: definition.app.name,
|
|
77
|
+
description: definition.app.description,
|
|
78
|
+
...(definition.app.icon === undefined
|
|
79
|
+
? {}
|
|
80
|
+
: { icon: definition.app.icon }),
|
|
81
|
+
},
|
|
82
|
+
triggerOnAllMessages: definition.triggerOnAllMessages,
|
|
83
|
+
allowBotTriggers: definition.allowBotTriggers,
|
|
141
84
|
},
|
|
142
85
|
};
|
|
143
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/channels/slack/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/channels/slack/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,gCAAgC,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EACL,aAAa,GAGd,MAAM,0BAA0B,CAAC;AAiClC,MAAM,kBAAkB,GAAG,CAAC;KACzB,MAAM,CAAC;IACN,IAAI,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,IAAI,EAAE,EAAE;QAC1C,OAAO,EAAE,oCAAoC;KAC9C,CAAC;SACD,KAAK,CAAC,qBAAqB,EAAE;QAC5B,OAAO,EACL,8EAA8E;KACjF,CAAC;SACD,MAAM,CACL,CAAC,KAAK,EAAE,EAAE,CACR,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QACtB,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QACtB,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QACpB,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,EACtB,EAAE,OAAO,EAAE,4CAA4C,EAAE,CAC1D;IACH,WAAW,EAAE,CAAC;SACX,MAAM,EAAE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,GAAG,CAAC,IAAI,EAAE,CAAC;aACnC;YACD,oBAAoB,EAAE,UAAU,CAAC,oBAAoB;YACrD,gBAAgB,EAAE,UAAU,CAAC,gBAAgB;SAC9C;KACF,CAAC;AACJ,CAAC;AAyBD,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAQxB,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAMxB,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAOnB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { TriggerChannelActionRequest, TriggerChannelActionResponse, TriggerChannelRuntimeEventRequest, TriggerChannelRuntimeEventResponse } from "./types.js";
|
|
2
|
+
export declare const LANGSMITH_MDA_TRIGGER_SERVER_URL_ENV = "LANGSMITH_MDA_TRIGGER_SERVER_URL";
|
|
3
|
+
export declare const TRIGGER_HTTP_TIMEOUT_MS = 30000;
|
|
4
|
+
type TriggerClientOperation = "actions" | "events";
|
|
5
|
+
export interface TriggerClientLike {
|
|
6
|
+
postAction(channelId: string, body: TriggerChannelActionRequest): Promise<TriggerChannelActionResponse>;
|
|
7
|
+
postRuntimeEvent(channelId: string, body: TriggerChannelRuntimeEventRequest): Promise<TriggerChannelRuntimeEventResponse>;
|
|
8
|
+
}
|
|
9
|
+
export interface TriggerClientOptions {
|
|
10
|
+
userId?: string;
|
|
11
|
+
env?: NodeJS.ProcessEnv;
|
|
12
|
+
fetch?: typeof fetch;
|
|
13
|
+
timeoutMs?: number;
|
|
14
|
+
}
|
|
15
|
+
/** Fixed-message callback error safe for logs and diagnostics. */
|
|
16
|
+
export declare class TriggerClientError extends Error {
|
|
17
|
+
readonly operation: TriggerClientOperation;
|
|
18
|
+
readonly status?: number | undefined;
|
|
19
|
+
constructor(operation: TriggerClientOperation, status?: number | undefined);
|
|
20
|
+
}
|
|
21
|
+
/** Minimal Trigger Server client authenticated by the hosted server key. */
|
|
22
|
+
export declare class TriggerClient implements TriggerClientLike {
|
|
23
|
+
#private;
|
|
24
|
+
constructor(options?: TriggerClientOptions);
|
|
25
|
+
postAction(channelId: string, body: TriggerChannelActionRequest): Promise<TriggerChannelActionResponse>;
|
|
26
|
+
postRuntimeEvent(channelId: string, body: TriggerChannelRuntimeEventRequest): Promise<TriggerChannelRuntimeEventResponse>;
|
|
27
|
+
}
|
|
28
|
+
export declare function createTriggerClient(options?: TriggerClientOptions): TriggerClient | undefined;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/channels/trigger/client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,iCAAiC,EACjC,kCAAkC,EACnC,MAAM,YAAY,CAAC;AAGpB,eAAO,MAAM,oCAAoC,qCACb,CAAC;AACrC,eAAO,MAAM,uBAAuB,QAA2B,CAAC;AAEhE,KAAK,sBAAsB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEnD,MAAM,WAAW,iBAAiB;IAChC,UAAU,CACR,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,2BAA2B,GAChC,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACzC,gBAAgB,CACd,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,iCAAiC,GACtC,OAAO,CAAC,kCAAkC,CAAC,CAAC;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