managed-deepagents 0.4.2 → 0.5.0-dev.77
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/dist/channels/collect.d.ts +2 -5
- package/dist/channels/collect.d.ts.map +1 -1
- package/dist/channels/collect.js +13 -9
- package/dist/channels/collect.js.map +1 -1
- package/dist/connectors/arcade/index.d.ts +116 -0
- package/dist/connectors/arcade/index.d.ts.map +1 -0
- package/dist/connectors/arcade/index.js +177 -0
- package/dist/connectors/arcade/index.js.map +1 -0
- package/dist/connectors/arcade/load.d.ts +35 -0
- package/dist/connectors/arcade/load.d.ts.map +1 -0
- package/dist/connectors/arcade/load.js +160 -0
- package/dist/connectors/arcade/load.js.map +1 -0
- package/dist/connectors/arcade/policy.d.ts +21 -0
- package/dist/connectors/arcade/policy.d.ts.map +1 -0
- package/dist/connectors/arcade/policy.js +40 -0
- package/dist/connectors/arcade/policy.js.map +1 -0
- package/dist/connectors/arcade/resolve.d.ts +78 -0
- package/dist/connectors/arcade/resolve.d.ts.map +1 -0
- package/dist/connectors/arcade/resolve.js +226 -0
- package/dist/connectors/arcade/resolve.js.map +1 -0
- package/dist/connectors/mcp/load.d.ts +12 -0
- package/dist/connectors/mcp/load.d.ts.map +1 -1
- package/dist/connectors/mcp/load.js +8 -6
- package/dist/connectors/mcp/load.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtime/connector.d.ts +15 -14
- package/dist/runtime/connector.d.ts.map +1 -1
- package/dist/runtime/connector.js +16 -11
- package/dist/runtime/connector.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -8
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +7 -24
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/types.d.ts +0 -6
- package/dist/runtime/types.d.ts.map +1 -1
- package/package.json +11 -7
- package/dist/runtime/eval-filesystem.d.ts +0 -7
- package/dist/runtime/eval-filesystem.d.ts.map +0 -1
- package/dist/runtime/eval-filesystem.js +0 -44
- package/dist/runtime/eval-filesystem.js.map +0 -1
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Collect validated channel declarations from discovered `channels/` modules.
|
|
3
3
|
*
|
|
4
|
-
* Mirrors {@link collectConnectors}: each module
|
|
5
|
-
* {@link ChannelDefinition}.
|
|
6
|
-
* value) are skipped — the CLI already omits files without `export const
|
|
7
|
-
* channel`, and this keeps helpers / mistaken bindings from crashing startup.
|
|
8
|
-
* Adapters are registered during collect.
|
|
4
|
+
* Mirrors {@link collectConnectors}: each module must export a named branded
|
|
5
|
+
* {@link ChannelDefinition}. Adapters are registered during collect.
|
|
9
6
|
*/
|
|
10
7
|
import { type ChannelDefinition } from "./plugin.js";
|
|
11
8
|
export interface ChannelModuleEntry {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../src/channels/collect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"collect.d.ts","sourceRoot":"","sources":["../../src/channels/collect.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG1E,MAAM,WAAW,kBAAkB;IACjC,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,MAAM,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,kBAAkB,EAAE,GACrC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CA4BnC"}
|
package/dist/channels/collect.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Collect validated channel declarations from discovered `channels/` modules.
|
|
3
3
|
*
|
|
4
|
-
* Mirrors {@link collectConnectors}: each module
|
|
5
|
-
* {@link ChannelDefinition}.
|
|
6
|
-
* value) are skipped — the CLI already omits files without `export const
|
|
7
|
-
* channel`, and this keeps helpers / mistaken bindings from crashing startup.
|
|
8
|
-
* Adapters are registered during collect.
|
|
4
|
+
* Mirrors {@link collectConnectors}: each module must export a named branded
|
|
5
|
+
* {@link ChannelDefinition}. Adapters are registered during collect.
|
|
9
6
|
*/
|
|
10
7
|
import { isChannelDefinition } from "./plugin.js";
|
|
11
8
|
import { registerChannelAdapter } from "./registry-store.js";
|
|
@@ -18,10 +15,17 @@ export function collectChannels(entries) {
|
|
|
18
15
|
const out = {};
|
|
19
16
|
for (const entry of entries) {
|
|
20
17
|
const channel = entry.module.channel;
|
|
21
|
-
if (channel === undefined ||
|
|
22
|
-
channel
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
if (channel === undefined || channel === null) {
|
|
19
|
+
throw new Error(`${entry.source} defines no \`channel\` export. A file under channels/ ` +
|
|
20
|
+
"must export exactly one branded channel as `channel` " +
|
|
21
|
+
"(e.g. `export const channel = defineGitHubChannel(...)` or a " +
|
|
22
|
+
"third-party `defineXChannel` that returns defineChannel(...)).");
|
|
23
|
+
}
|
|
24
|
+
if (!isChannelDefinition(channel)) {
|
|
25
|
+
throw new Error(`${entry.source} export \`channel\` is not a branded ChannelDefinition. ` +
|
|
26
|
+
"The define* helper must return an object with CHANNEL_BRAND, " +
|
|
27
|
+
"provider, adapter, toManifest, and config " +
|
|
28
|
+
"(use defineChannel(...) from managed-deepagents/channels).");
|
|
25
29
|
}
|
|
26
30
|
const name = channelStemName(entry.source);
|
|
27
31
|
if (out[name] !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect.js","sourceRoot":"","sources":["../../src/channels/collect.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"collect.js","sourceRoot":"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EAAE,CAAC,CAAC;IACtE,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CACb,yBAAyB,MAAM,4CAA4C,CAC5E,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arcade managed connector — tools egress via Arcade MCP gateways.
|
|
3
|
+
*
|
|
4
|
+
* Parallel to managed Slack channels (ingress). Authors declare which Arcade
|
|
5
|
+
* gateways the agent should use; MDA binds them at deploy time (Phase B) and
|
|
6
|
+
* loads tools over MCP. Manual install is an escape hatch that reuses the
|
|
7
|
+
* existing MCP connector stack with BYO URL/headers.
|
|
8
|
+
*
|
|
9
|
+
* Tool filters are per-gateway only (raw MCP tool names, before any managed
|
|
10
|
+
* `{server}__` prefix). There is no root-level include/exclude and no
|
|
11
|
+
* catch-all `defineConnections` API.
|
|
12
|
+
*
|
|
13
|
+
* @example Managed (default)
|
|
14
|
+
* ```ts
|
|
15
|
+
* // connectors/arcade.ts
|
|
16
|
+
* import { defineArcadeConnector } from "managed-deepagents/connectors/arcade";
|
|
17
|
+
*
|
|
18
|
+
* export default defineArcadeConnector({
|
|
19
|
+
* install: "managed",
|
|
20
|
+
* gateways: {
|
|
21
|
+
* notion: {},
|
|
22
|
+
* gmail: { includeTools: ["SendEmail", "ListThreads"] },
|
|
23
|
+
* },
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example Manual
|
|
28
|
+
* ```ts
|
|
29
|
+
* export default defineArcadeConnector({
|
|
30
|
+
* install: "manual",
|
|
31
|
+
* mcpServers: {
|
|
32
|
+
* custom: {
|
|
33
|
+
* transport: "http",
|
|
34
|
+
* url: "https://api.arcade.dev/mcp/my-gateway",
|
|
35
|
+
* includeTools: ["SendEmail"],
|
|
36
|
+
* headers: { Authorization: `Bearer ${process.env.ARCADE_API_KEY}` },
|
|
37
|
+
* },
|
|
38
|
+
* },
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
import { type Connector } from "../../runtime/connector.js";
|
|
43
|
+
import { type McpToolSelectionConfig, type RemoteMcpServerConfig } from "../mcp/index.js";
|
|
44
|
+
/** How Arcade tools are installed into the agent. Defaults to `"managed"`. */
|
|
45
|
+
export type ArcadeInstallMode = "managed" | "manual";
|
|
46
|
+
/**
|
|
47
|
+
* Per-gateway tool selection for managed install. Names are raw, unprefixed
|
|
48
|
+
* MCP tool names (same semantics as {@link McpToolSelectionConfig}).
|
|
49
|
+
*/
|
|
50
|
+
export type ArcadeGatewayConfig = McpToolSelectionConfig;
|
|
51
|
+
/** Configuration accepted by {@link defineArcadeConnector}. */
|
|
52
|
+
export type ArcadeConnectorConfig = ArcadeManagedConnectorConfig | ArcadeManualConnectorConfig;
|
|
53
|
+
/** Managed install: declare Arcade gateway slugs; MDA binds them at deploy. */
|
|
54
|
+
export interface ArcadeManagedConnectorConfig {
|
|
55
|
+
/**
|
|
56
|
+
* Managed install (default). Resolves workspace Arcade gateways via Fleet
|
|
57
|
+
* during deploy (Phase B). Rejects `mcpServers`.
|
|
58
|
+
*/
|
|
59
|
+
install?: "managed";
|
|
60
|
+
/**
|
|
61
|
+
* Arcade gateway slug → optional tool filters.
|
|
62
|
+
*
|
|
63
|
+
* Omit or leave empty to mean “all workspace Arcade gateways” once deploy
|
|
64
|
+
* binding has injected `MDA_ARCADE_GATEWAYS`.
|
|
65
|
+
*/
|
|
66
|
+
gateways?: Record<string, ArcadeGatewayConfig>;
|
|
67
|
+
/**
|
|
68
|
+
* Allow agent-scoped Arcade OAuth (shared grant for the deployment).
|
|
69
|
+
*
|
|
70
|
+
* Default `false`. Required when identity uses `scoping.credentials: "agent"`
|
|
71
|
+
* (e.g. shared-bot) so channel actors never silently share one Arcade token.
|
|
72
|
+
* Prefer `credentials: "actor"` for per-user Arcade.
|
|
73
|
+
*/
|
|
74
|
+
allowAgentScopedCredentials?: boolean;
|
|
75
|
+
/** Not allowed with `install: "managed"`. */
|
|
76
|
+
mcpServers?: never;
|
|
77
|
+
}
|
|
78
|
+
/** Manual install: BYO MCP server URLs/headers via the existing MCP stack. */
|
|
79
|
+
export interface ArcadeManualConnectorConfig {
|
|
80
|
+
install: "manual";
|
|
81
|
+
/**
|
|
82
|
+
* Remote MCP servers (same shape as {@link defineMcpServers}). Required for
|
|
83
|
+
* manual install. Rejects `gateways`.
|
|
84
|
+
*/
|
|
85
|
+
mcpServers: Record<string, RemoteMcpServerConfig>;
|
|
86
|
+
/** Not allowed with `install: "manual"`. */
|
|
87
|
+
gateways?: never;
|
|
88
|
+
prefixToolNameWithServerName?: boolean;
|
|
89
|
+
throwOnLoadError?: boolean;
|
|
90
|
+
useStandardContentBlocks?: boolean;
|
|
91
|
+
onConnectionError?: "throw";
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The connector exported from a `connectors/arcade` module. Branded managed
|
|
95
|
+
* {@link Connector} whose `tools` hook loads Arcade (or BYO MCP) tools.
|
|
96
|
+
*/
|
|
97
|
+
export interface ArcadeConnectorDefinition extends Connector {
|
|
98
|
+
readonly kind: "arcade";
|
|
99
|
+
readonly install: ArcadeInstallMode;
|
|
100
|
+
readonly gateways?: Record<string, ArcadeGatewayConfig>;
|
|
101
|
+
readonly allowAgentScopedCredentials?: boolean;
|
|
102
|
+
readonly mcpServers?: Record<string, RemoteMcpServerConfig>;
|
|
103
|
+
readonly prefixToolNameWithServerName?: boolean;
|
|
104
|
+
readonly throwOnLoadError?: boolean;
|
|
105
|
+
readonly useStandardContentBlocks?: boolean;
|
|
106
|
+
readonly onConnectionError?: "throw";
|
|
107
|
+
}
|
|
108
|
+
export { MANAGED_ARCADE_TOOLS_UNAVAILABLE } from "./load.js";
|
|
109
|
+
/**
|
|
110
|
+
* Declare Arcade gateways (managed) or BYO MCP servers (manual) whose tools
|
|
111
|
+
* should be loaded into the managed Deep Agent.
|
|
112
|
+
*
|
|
113
|
+
* Validates eagerly so misconfiguration surfaces at module load.
|
|
114
|
+
*/
|
|
115
|
+
export declare function defineArcadeConnector(config?: ArcadeConnectorConfig): ArcadeConnectorDefinition;
|
|
116
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connectors/arcade/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC3B,MAAM,iBAAiB,CAAC;AAEzB,8EAA8E;AAC9E,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAEzD,+DAA+D;AAC/D,MAAM,MAAM,qBAAqB,GAC7B,4BAA4B,GAC5B,2BAA2B,CAAC;AAEhC,+EAA+E;AAC/E,MAAM,WAAW,4BAA4B;IAC3C;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC/C;;;;;;OAMG;IACH,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,6CAA6C;IAC7C,UAAU,CAAC,EAAE,KAAK,CAAC;CACpB;AAED,8EAA8E;AAC9E,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,QAAQ,CAAC;IAClB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAClD,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,yBAA0B,SAAQ,SAAS;IAC1D,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACxD,QAAQ,CAAC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IAC/C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;IAC5D,QAAQ,CAAC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IAChD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACtC;AAED,OAAO,EAAE,gCAAgC,EAAE,MAAM,WAAW,CAAC;AAE7D;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,GAAE,qBAA0B,GACjC,yBAAyB,CAsF3B"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arcade managed connector — tools egress via Arcade MCP gateways.
|
|
3
|
+
*
|
|
4
|
+
* Parallel to managed Slack channels (ingress). Authors declare which Arcade
|
|
5
|
+
* gateways the agent should use; MDA binds them at deploy time (Phase B) and
|
|
6
|
+
* loads tools over MCP. Manual install is an escape hatch that reuses the
|
|
7
|
+
* existing MCP connector stack with BYO URL/headers.
|
|
8
|
+
*
|
|
9
|
+
* Tool filters are per-gateway only (raw MCP tool names, before any managed
|
|
10
|
+
* `{server}__` prefix). There is no root-level include/exclude and no
|
|
11
|
+
* catch-all `defineConnections` API.
|
|
12
|
+
*
|
|
13
|
+
* @example Managed (default)
|
|
14
|
+
* ```ts
|
|
15
|
+
* // connectors/arcade.ts
|
|
16
|
+
* import { defineArcadeConnector } from "managed-deepagents/connectors/arcade";
|
|
17
|
+
*
|
|
18
|
+
* export default defineArcadeConnector({
|
|
19
|
+
* install: "managed",
|
|
20
|
+
* gateways: {
|
|
21
|
+
* notion: {},
|
|
22
|
+
* gmail: { includeTools: ["SendEmail", "ListThreads"] },
|
|
23
|
+
* },
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example Manual
|
|
28
|
+
* ```ts
|
|
29
|
+
* export default defineArcadeConnector({
|
|
30
|
+
* install: "manual",
|
|
31
|
+
* mcpServers: {
|
|
32
|
+
* custom: {
|
|
33
|
+
* transport: "http",
|
|
34
|
+
* url: "https://api.arcade.dev/mcp/my-gateway",
|
|
35
|
+
* includeTools: ["SendEmail"],
|
|
36
|
+
* headers: { Authorization: `Bearer ${process.env.ARCADE_API_KEY}` },
|
|
37
|
+
* },
|
|
38
|
+
* },
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
import { CONNECTOR_BRAND, } from "../../runtime/connector.js";
|
|
43
|
+
import { defineMcpServers, } from "../mcp/index.js";
|
|
44
|
+
export { MANAGED_ARCADE_TOOLS_UNAVAILABLE } from "./load.js";
|
|
45
|
+
/**
|
|
46
|
+
* Declare Arcade gateways (managed) or BYO MCP servers (manual) whose tools
|
|
47
|
+
* should be loaded into the managed Deep Agent.
|
|
48
|
+
*
|
|
49
|
+
* Validates eagerly so misconfiguration surfaces at module load.
|
|
50
|
+
*/
|
|
51
|
+
export function defineArcadeConnector(config = {}) {
|
|
52
|
+
const provided = config;
|
|
53
|
+
const install = normalizeInstall(provided.install);
|
|
54
|
+
if (install === "managed") {
|
|
55
|
+
if ("mcpServers" in provided && provided.mcpServers !== undefined) {
|
|
56
|
+
throw new Error('defineArcadeConnector(...) with install: "managed" rejects ' +
|
|
57
|
+
"`mcpServers`. Use `gateways` for managed Arcade, or set " +
|
|
58
|
+
'install: "manual" for BYO MCP URLs.');
|
|
59
|
+
}
|
|
60
|
+
const gateways = provided.gateways;
|
|
61
|
+
if (gateways !== undefined) {
|
|
62
|
+
validateGateways(gateways);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
if ("gateways" in provided && provided.gateways !== undefined) {
|
|
67
|
+
throw new Error('defineArcadeConnector(...) with install: "manual" rejects ' +
|
|
68
|
+
"`gateways`. Pass `mcpServers` (same shape as defineMcpServers), " +
|
|
69
|
+
'or use install: "managed".');
|
|
70
|
+
}
|
|
71
|
+
if (provided.mcpServers === null ||
|
|
72
|
+
typeof provided.mcpServers !== "object" ||
|
|
73
|
+
Array.isArray(provided.mcpServers)) {
|
|
74
|
+
throw new Error('defineArcadeConnector(...) with install: "manual" requires an ' +
|
|
75
|
+
"`mcpServers` object mapping server names to remote MCP configs.");
|
|
76
|
+
}
|
|
77
|
+
// Reuse MCP validation (non-empty servers, transports, tool selectors).
|
|
78
|
+
defineMcpServers({
|
|
79
|
+
mcpServers: provided.mcpServers,
|
|
80
|
+
prefixToolNameWithServerName: provided.prefixToolNameWithServerName,
|
|
81
|
+
throwOnLoadError: provided.throwOnLoadError,
|
|
82
|
+
useStandardContentBlocks: provided.useStandardContentBlocks,
|
|
83
|
+
onConnectionError: provided.onConnectionError,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
const definition = {
|
|
87
|
+
kind: "arcade",
|
|
88
|
+
install,
|
|
89
|
+
...(install === "managed"
|
|
90
|
+
? {
|
|
91
|
+
gateways: provided.gateways ?? {},
|
|
92
|
+
...(provided.allowAgentScopedCredentials === true
|
|
93
|
+
? { allowAgentScopedCredentials: true }
|
|
94
|
+
: {}),
|
|
95
|
+
}
|
|
96
|
+
: {
|
|
97
|
+
mcpServers: provided.mcpServers,
|
|
98
|
+
prefixToolNameWithServerName: provided.prefixToolNameWithServerName,
|
|
99
|
+
throwOnLoadError: provided.throwOnLoadError,
|
|
100
|
+
useStandardContentBlocks: provided.useStandardContentBlocks,
|
|
101
|
+
onConnectionError: provided.onConnectionError,
|
|
102
|
+
}),
|
|
103
|
+
};
|
|
104
|
+
Object.defineProperty(definition, CONNECTOR_BRAND, {
|
|
105
|
+
value: true,
|
|
106
|
+
enumerable: false,
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(definition, "tools", {
|
|
109
|
+
value: async (ctx = {}) => {
|
|
110
|
+
const { loadArcadeTools } = await import("./load.js");
|
|
111
|
+
return loadArcadeTools(definition, ctx);
|
|
112
|
+
},
|
|
113
|
+
enumerable: false,
|
|
114
|
+
});
|
|
115
|
+
return definition;
|
|
116
|
+
}
|
|
117
|
+
function normalizeInstall(value) {
|
|
118
|
+
if (value === undefined) {
|
|
119
|
+
return "managed";
|
|
120
|
+
}
|
|
121
|
+
if (value === "managed" || value === "manual") {
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
throw new Error(`defineArcadeConnector(...) install must be "managed" or "manual"; got ${JSON.stringify(value)}.`);
|
|
125
|
+
}
|
|
126
|
+
function validateGateways(gateways) {
|
|
127
|
+
if (gateways === null ||
|
|
128
|
+
typeof gateways !== "object" ||
|
|
129
|
+
Array.isArray(gateways)) {
|
|
130
|
+
throw new Error("defineArcadeConnector(...) `gateways` must be an object mapping " +
|
|
131
|
+
"gateway slugs to optional tool-selection configs.");
|
|
132
|
+
}
|
|
133
|
+
for (const [name, gateway] of Object.entries(gateways)) {
|
|
134
|
+
if (typeof name !== "string" || name.trim().length === 0) {
|
|
135
|
+
throw new Error("defineArcadeConnector(...) gateway names must be non-empty strings.");
|
|
136
|
+
}
|
|
137
|
+
if (gateway === null ||
|
|
138
|
+
typeof gateway !== "object" ||
|
|
139
|
+
Array.isArray(gateway)) {
|
|
140
|
+
throw new Error(`Arcade gateway "${name}" must be a configuration object (use {} for all tools).`);
|
|
141
|
+
}
|
|
142
|
+
validateToolSelection(name, gateway);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function validateToolSelection(name, config) {
|
|
146
|
+
const includeTools = validateToolNameList(name, "includeTools", config.includeTools);
|
|
147
|
+
const excludeTools = validateToolNameList(name, "excludeTools", config.excludeTools);
|
|
148
|
+
if (!includeTools || !excludeTools) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const included = new Set(includeTools);
|
|
152
|
+
const conflicts = excludeTools.filter((toolName) => included.has(toolName));
|
|
153
|
+
if (conflicts.length > 0) {
|
|
154
|
+
throw new Error(`Arcade gateway "${name}" selects tool(s) in both \`includeTools\` and ` +
|
|
155
|
+
`\`excludeTools\`: ${conflicts.sort().join(", ")}.`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function validateToolNameList(gatewayName, field, value) {
|
|
159
|
+
if (value === undefined) {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
if (!Array.isArray(value)) {
|
|
163
|
+
throw new Error(`Arcade gateway "${gatewayName}" \`${field}\` must be an array of strings.`);
|
|
164
|
+
}
|
|
165
|
+
const seen = new Set();
|
|
166
|
+
for (const [index, item] of value.entries()) {
|
|
167
|
+
if (typeof item !== "string" || item.trim().length === 0) {
|
|
168
|
+
throw new Error(`Arcade gateway "${gatewayName}" \`${field}\` entry ${index} must be a non-empty string.`);
|
|
169
|
+
}
|
|
170
|
+
if (seen.has(item)) {
|
|
171
|
+
throw new Error(`Arcade gateway "${gatewayName}" \`${field}\` contains duplicate tool name "${item}".`);
|
|
172
|
+
}
|
|
173
|
+
seen.add(item);
|
|
174
|
+
}
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connectors/arcade/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,mBAAmB,WAAW,OAAO,KAAK,oCAAoC,IAAI,IAAI,CACvF,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arcade tool loading — manual MCP delegation + managed Phase C resolve.
|
|
3
|
+
*
|
|
4
|
+
* Managed mode uses a dedicated MCP client (not the generic process cache) so
|
|
5
|
+
* Authorization can be minted per tool call from runtime identity.
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolContext } from "../../runtime/connector.js";
|
|
8
|
+
import type { ArcadeConnectorDefinition } from "./index.js";
|
|
9
|
+
import type { ArcadeManagedResolution } from "./resolve.js";
|
|
10
|
+
/**
|
|
11
|
+
* Directed error when managed Arcade tools are requested without deploy
|
|
12
|
+
* binding (`MDA_ARCADE_GATEWAYS`). Do not invent fake tools.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MANAGED_ARCADE_TOOLS_UNAVAILABLE: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional resolver for managed Arcade gateways → MCP server configs.
|
|
17
|
+
*
|
|
18
|
+
* Default reads deploy-injected bindings. Tests can override via
|
|
19
|
+
* {@link setArcadeGatewayResolverForTests}.
|
|
20
|
+
*/
|
|
21
|
+
export interface ArcadeGatewayResolver {
|
|
22
|
+
resolve(definition: ArcadeConnectorDefinition): Promise<ArcadeManagedResolution>;
|
|
23
|
+
}
|
|
24
|
+
/** Override the managed gateway resolver. Test seam. */
|
|
25
|
+
export declare function setArcadeGatewayResolverForTests(resolver: ArcadeGatewayResolver | undefined): void;
|
|
26
|
+
/** Clear the managed Arcade tool cache. Test-only. */
|
|
27
|
+
export declare function clearArcadeToolsCacheForTests(): void;
|
|
28
|
+
/**
|
|
29
|
+
* Load tools for an Arcade connector.
|
|
30
|
+
*
|
|
31
|
+
* - `manual` → existing process-cached MCP loader
|
|
32
|
+
* - `managed` → deploy-bound resolve + per-call OAuth (Phase C)
|
|
33
|
+
*/
|
|
34
|
+
export declare function loadArcadeTools(definition: ArcadeConnectorDefinition, ctx?: ToolContext): Promise<unknown[]>;
|
|
35
|
+
//# sourceMappingURL=load.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../src/connectors/arcade/load.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAM9D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,gCAAgC,QAIkC,CAAC;AAEhF;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,OAAO,CACL,UAAU,EAAE,yBAAyB,GACpC,OAAO,CAAC,uBAAuB,CAAC,CAAC;CACrC;AAaD,wDAAwD;AACxD,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,qBAAqB,GAAG,SAAS,GAC1C,IAAI,CAEN;AAKD,sDAAsD;AACtD,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD;AA6JD;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,yBAAyB,EACrC,GAAG,GAAE,WAAgB,GACpB,OAAO,CAAC,OAAO,EAAE,CAAC,CAepB"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arcade tool loading — manual MCP delegation + managed Phase C resolve.
|
|
3
|
+
*
|
|
4
|
+
* Managed mode uses a dedicated MCP client (not the generic process cache) so
|
|
5
|
+
* Authorization can be minted per tool call from runtime identity.
|
|
6
|
+
*/
|
|
7
|
+
import { interrupt } from "@langchain/langgraph";
|
|
8
|
+
import { buildRuntimeIdentity, resolveAmbientConfigurable, } from "../../runtime/identity-runtime.js";
|
|
9
|
+
import { defineMcpServers } from "../mcp/index.js";
|
|
10
|
+
import { resolveArcadeMintMode } from "./policy.js";
|
|
11
|
+
/**
|
|
12
|
+
* Directed error when managed Arcade tools are requested without deploy
|
|
13
|
+
* binding (`MDA_ARCADE_GATEWAYS`). Do not invent fake tools.
|
|
14
|
+
*/
|
|
15
|
+
export const MANAGED_ARCADE_TOOLS_UNAVAILABLE = "Managed Arcade tools are not bound for this deployment. Configure Arcade in " +
|
|
16
|
+
"LangSmith (Fleet → Integrations → Arcade) and run `mda deploy` so MDA can " +
|
|
17
|
+
"install workspace gateways as Fleet MCP servers and inject " +
|
|
18
|
+
"MDA_ARCADE_GATEWAYS. See https://docs.langchain.com/langsmith/fleet/arcade.";
|
|
19
|
+
async function defaultManagedResolver(definition) {
|
|
20
|
+
const { resolveManagedArcadeGateways } = await import("./resolve.js");
|
|
21
|
+
return resolveManagedArcadeGateways(definition);
|
|
22
|
+
}
|
|
23
|
+
let managedResolver = {
|
|
24
|
+
resolve: defaultManagedResolver,
|
|
25
|
+
};
|
|
26
|
+
/** Override the managed gateway resolver. Test seam. */
|
|
27
|
+
export function setArcadeGatewayResolverForTests(resolver) {
|
|
28
|
+
managedResolver = resolver ?? { resolve: defaultManagedResolver };
|
|
29
|
+
}
|
|
30
|
+
/** Process-lifetime cache for managed Arcade tools (separate from generic MCP). */
|
|
31
|
+
let cachedArcadeTools;
|
|
32
|
+
/** Clear the managed Arcade tool cache. Test-only. */
|
|
33
|
+
export function clearArcadeToolsCacheForTests() {
|
|
34
|
+
cachedArcadeTools = undefined;
|
|
35
|
+
}
|
|
36
|
+
function manualAsMcpDefinition(definition) {
|
|
37
|
+
if (definition.install !== "manual" || !definition.mcpServers) {
|
|
38
|
+
throw new Error('manual Arcade load requires install: "manual" with mcpServers.');
|
|
39
|
+
}
|
|
40
|
+
return defineMcpServers({
|
|
41
|
+
mcpServers: definition.mcpServers,
|
|
42
|
+
prefixToolNameWithServerName: definition.prefixToolNameWithServerName,
|
|
43
|
+
throwOnLoadError: definition.throwOnLoadError,
|
|
44
|
+
useStandardContentBlocks: definition.useStandardContentBlocks,
|
|
45
|
+
onConnectionError: definition.onConnectionError,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
function withListingHeaders(mcp, tokenByProvider, providerByServer) {
|
|
49
|
+
const mcpServers = Object.fromEntries(Object.entries(mcp.mcpServers).map(([slug, server]) => {
|
|
50
|
+
const provider = providerByServer[slug];
|
|
51
|
+
const token = provider ? tokenByProvider.get(provider) : undefined;
|
|
52
|
+
if (!token) {
|
|
53
|
+
return [slug, server];
|
|
54
|
+
}
|
|
55
|
+
return [
|
|
56
|
+
slug,
|
|
57
|
+
{
|
|
58
|
+
...server,
|
|
59
|
+
headers: {
|
|
60
|
+
...(server.headers ?? {}),
|
|
61
|
+
Authorization: `Bearer ${token}`,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
}));
|
|
66
|
+
return { ...mcp, mcpServers };
|
|
67
|
+
}
|
|
68
|
+
function interruptIfAuthRequired(result) {
|
|
69
|
+
if (result.status === "completed" && result.token) {
|
|
70
|
+
return result.token;
|
|
71
|
+
}
|
|
72
|
+
if (result.status === "pending" ||
|
|
73
|
+
result.status === "connection_required" ||
|
|
74
|
+
result.status === "token_expired") {
|
|
75
|
+
// Fleet auth-format: pause the run so the user can complete OAuth.
|
|
76
|
+
interrupt({
|
|
77
|
+
auth_required: true,
|
|
78
|
+
...(result.authUrl ? { auth_url: result.authUrl } : {}),
|
|
79
|
+
...(result.authId ? { auth_id: result.authId } : {}),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
throw new Error(`Managed Arcade OAuth is not ready (status=${result.status}). ` +
|
|
83
|
+
"Complete Arcade authorization and retry.");
|
|
84
|
+
}
|
|
85
|
+
async function mintAuthorizationHeader(options) {
|
|
86
|
+
const { authenticateArcadeOAuth } = await import("./resolve.js");
|
|
87
|
+
let userId;
|
|
88
|
+
if (options.mintMode === "actor") {
|
|
89
|
+
const identity = buildRuntimeIdentity(resolveAmbientConfigurable());
|
|
90
|
+
const actorId = identity?.actor?.id?.trim();
|
|
91
|
+
if (!actorId) {
|
|
92
|
+
throw new Error("Managed Arcade with actor-scoped credentials requires a resolved " +
|
|
93
|
+
"runtime identity (langgraph_auth_user). Refusing to fall back to a " +
|
|
94
|
+
"shared deploy-user Arcade token.");
|
|
95
|
+
}
|
|
96
|
+
userId = actorId;
|
|
97
|
+
}
|
|
98
|
+
const result = await authenticateArcadeOAuth({
|
|
99
|
+
provider: options.provider,
|
|
100
|
+
agentId: options.agentId,
|
|
101
|
+
userId,
|
|
102
|
+
checkOnly: false,
|
|
103
|
+
env: options.env,
|
|
104
|
+
fetch: options.fetch,
|
|
105
|
+
});
|
|
106
|
+
const token = interruptIfAuthRequired(result);
|
|
107
|
+
return { Authorization: `Bearer ${token}` };
|
|
108
|
+
}
|
|
109
|
+
async function loadManagedArcadeTools(definition, identityConfig) {
|
|
110
|
+
const mintMode = resolveArcadeMintMode(identityConfig, definition.allowAgentScopedCredentials);
|
|
111
|
+
const resolution = await managedResolver.resolve(definition);
|
|
112
|
+
const { mintArcadeOAuthToken } = await import("./resolve.js");
|
|
113
|
+
// Tool listing needs a bootstrap Authorization header. Use the agent /
|
|
114
|
+
// deploy-user grant authorized during `mda deploy` — never an actor token
|
|
115
|
+
// (no actor exists at graph-compile / process-cache time).
|
|
116
|
+
const listingTokens = new Map();
|
|
117
|
+
for (const provider of new Set(Object.values(resolution.providerByServer))) {
|
|
118
|
+
const token = await mintArcadeOAuthToken({
|
|
119
|
+
provider,
|
|
120
|
+
agentId: resolution.agentId,
|
|
121
|
+
});
|
|
122
|
+
listingTokens.set(provider, token);
|
|
123
|
+
}
|
|
124
|
+
const mcpWithListingAuth = withListingHeaders(resolution.mcp, listingTokens, resolution.providerByServer);
|
|
125
|
+
const { loadMcpToolsUncached } = await import("../mcp/load.js");
|
|
126
|
+
return loadMcpToolsUncached(mcpWithListingAuth, {
|
|
127
|
+
beforeToolCall: async ({ serverName }) => {
|
|
128
|
+
const provider = resolution.providerByServer[serverName];
|
|
129
|
+
if (!provider) {
|
|
130
|
+
throw new Error(`Managed Arcade tool call for unknown gateway "${serverName}".`);
|
|
131
|
+
}
|
|
132
|
+
const headers = await mintAuthorizationHeader({
|
|
133
|
+
mintMode,
|
|
134
|
+
provider,
|
|
135
|
+
agentId: resolution.agentId,
|
|
136
|
+
});
|
|
137
|
+
return { headers };
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Load tools for an Arcade connector.
|
|
143
|
+
*
|
|
144
|
+
* - `manual` → existing process-cached MCP loader
|
|
145
|
+
* - `managed` → deploy-bound resolve + per-call OAuth (Phase C)
|
|
146
|
+
*/
|
|
147
|
+
export async function loadArcadeTools(definition, ctx = {}) {
|
|
148
|
+
if (definition.install === "manual") {
|
|
149
|
+
const { loadManagedMcpTools } = await import("../mcp/load.js");
|
|
150
|
+
return loadManagedMcpTools(manualAsMcpDefinition(definition));
|
|
151
|
+
}
|
|
152
|
+
if (!cachedArcadeTools) {
|
|
153
|
+
cachedArcadeTools = loadManagedArcadeTools(definition, ctx.identity).catch((error) => {
|
|
154
|
+
cachedArcadeTools = undefined;
|
|
155
|
+
throw error;
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return cachedArcadeTools;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=load.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load.js","sourceRoot":"","sources":["../../../src/connectors/arcade/load.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAA6B,MAAM,iBAAiB,CAAC;AAE9E,OAAO,EAAE,qBAAq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AAK,QAAQ,EAAE,CAAC;QACpC,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC;QAC/D,OAAO,mBAAmB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,sBAAsB,CAAC,UAAU,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CACxE,CAAC,KAAK,EAAE,EAAE;YACR,iBAAiB,GAAG,SAAS,CAAC;YAC9B,MAAM,KAAK,CAAC;QACd,CAAC,CACF,CAAC;IACJ,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fail-closed credential policy for managed Arcade (Phase C).
|
|
3
|
+
*
|
|
4
|
+
* Actor-scoped Arcade maps `runtime.identity.actor.id` → host `user_id`.
|
|
5
|
+
* Agent-scoped Arcade (shared-bot / internal-tool / service presets) requires
|
|
6
|
+
* an explicit authoring opt-in so channel actors never silently share one grant.
|
|
7
|
+
*/
|
|
8
|
+
import type { IdentityConfig } from "../../identity/index.js";
|
|
9
|
+
/** How managed Arcade mints host-backend OAuth tokens. */
|
|
10
|
+
export type ArcadeMintMode = "actor" | "agent";
|
|
11
|
+
export declare const AGENT_SCOPED_ARCADE_REQUIRES_OPT_IN: string;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve mint mode from the deployment identity + Arcade opt-in.
|
|
14
|
+
*
|
|
15
|
+
* - `credentials: "actor"` → per-actor `user_id` minting
|
|
16
|
+
* - `credentials: "agent" | "custom"` → agent mint only with explicit opt-in
|
|
17
|
+
* - `credentials: "none"` → rejected (Arcade needs an OAuth grant)
|
|
18
|
+
* - no identity / credentials unset → agent mint (single-user Phase B compat)
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveArcadeMintMode(identity: IdentityConfig | undefined, allowAgentScopedCredentials: boolean | undefined): ArcadeMintMode;
|
|
21
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../src/connectors/arcade/policy.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAE9D,0DAA0D;AAC1D,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,CAAC;AAE/C,eAAO,MAAM,mCAAmC,QAMa,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,cAAc,GAAG,SAAS,EACpC,2BAA2B,EAAE,OAAO,GAAG,SAAS,GAC/C,cAAc,CAuBhB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fail-closed credential policy for managed Arcade (Phase C).
|
|
3
|
+
*
|
|
4
|
+
* Actor-scoped Arcade maps `runtime.identity.actor.id` → host `user_id`.
|
|
5
|
+
* Agent-scoped Arcade (shared-bot / internal-tool / service presets) requires
|
|
6
|
+
* an explicit authoring opt-in so channel actors never silently share one grant.
|
|
7
|
+
*/
|
|
8
|
+
export const AGENT_SCOPED_ARCADE_REQUIRES_OPT_IN = "Managed Arcade with agent-scoped credentials requires " +
|
|
9
|
+
"`allowAgentScopedCredentials: true` on defineArcadeConnector(...). " +
|
|
10
|
+
"Without that opt-in, shared-bot / agent-scoped deployments would share one " +
|
|
11
|
+
"Arcade grant across all channel actors. Prefer an identity preset with " +
|
|
12
|
+
'`scoping.credentials: "actor"` (e.g. private-assistant), or set the opt-in ' +
|
|
13
|
+
"only when a single shared Arcade identity is intentional.";
|
|
14
|
+
/**
|
|
15
|
+
* Resolve mint mode from the deployment identity + Arcade opt-in.
|
|
16
|
+
*
|
|
17
|
+
* - `credentials: "actor"` → per-actor `user_id` minting
|
|
18
|
+
* - `credentials: "agent" | "custom"` → agent mint only with explicit opt-in
|
|
19
|
+
* - `credentials: "none"` → rejected (Arcade needs an OAuth grant)
|
|
20
|
+
* - no identity / credentials unset → agent mint (single-user Phase B compat)
|
|
21
|
+
*/
|
|
22
|
+
export function resolveArcadeMintMode(identity, allowAgentScopedCredentials) {
|
|
23
|
+
const mode = identity?.scoping?.credentials;
|
|
24
|
+
if (mode === "actor") {
|
|
25
|
+
return "actor";
|
|
26
|
+
}
|
|
27
|
+
if (mode === "none") {
|
|
28
|
+
throw new Error('Managed Arcade rejects scoping.credentials: "none". Use "actor" ' +
|
|
29
|
+
'(recommended) or "agent" with allowAgentScopedCredentials: true.');
|
|
30
|
+
}
|
|
31
|
+
if (mode === "agent" || mode === "custom") {
|
|
32
|
+
if (!allowAgentScopedCredentials) {
|
|
33
|
+
throw new Error(AGENT_SCOPED_ARCADE_REQUIRES_OPT_IN);
|
|
34
|
+
}
|
|
35
|
+
return "agent";
|
|
36
|
+
}
|
|
37
|
+
// No identity declaration (or credentials unset): deploy-user / agent grant.
|
|
38
|
+
return "agent";
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=policy.js.map
|