@mastra/connect 0.3.1-alpha.0 → 0.4.0-alpha.0
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 +22 -0
- package/dist/channels.d.ts +127 -0
- package/dist/channels.d.ts.map +1 -0
- package/dist/connect.d.ts +15 -59
- package/dist/connect.d.ts.map +1 -1
- package/dist/environment.d.ts +48 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/index.cjs +455 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +450 -44
- package/dist/index.js.map +1 -1
- package/dist/providers/channel-provider.d.ts +32 -0
- package/dist/providers/channel-provider.d.ts.map +1 -0
- package/dist/providers/channels.d.ts +30 -0
- package/dist/providers/channels.d.ts.map +1 -0
- package/dist/registry.d.ts +13 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/resolution.d.ts +21 -0
- package/dist/resolution.d.ts.map +1 -0
- package/dist/tools.d.ts +66 -0
- package/dist/tools.d.ts.map +1 -0
- package/package.json +23 -6
- package/dist/connect.test-d.d.ts +0 -2
- package/dist/connect.test-d.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -62,6 +62,28 @@ Resend requires a verified sending domain and a key authorized for the operation
|
|
|
62
62
|
|
|
63
63
|
List tools return one provider page and preserve its response envelope. When `next_cursor` is present, pass it as `after` for Resend and incident.io. Preserve filters and sort options between pages.
|
|
64
64
|
|
|
65
|
+
### Sandbox environment
|
|
66
|
+
|
|
67
|
+
Some agents run inside a sandbox that shells out to CLIs (git, `gh`) or needs provider tokens in the process environment. `environment()` materializes those credentials from the same project connections `connect()` uses, so an agent that already has GitHub attached needs no separate credential wiring.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { environment } from '@mastra/connect';
|
|
71
|
+
|
|
72
|
+
const env = environment({
|
|
73
|
+
projectId: process.env.MASTRA_PROJECT_ID,
|
|
74
|
+
client: { accessToken: process.env.MASTRA_PLATFORM_ACCESS_TOKEN },
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const { env: envVars, onStart } = await env();
|
|
78
|
+
|
|
79
|
+
await sandbox.start({
|
|
80
|
+
env: envVars, // GH_TOKEN, GITHUB_TOKEN, …
|
|
81
|
+
onStart, // runs `git config --global credential.https://github.com.helper …`
|
|
82
|
+
});
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`environment()` mirrors `connect()`: same `projectId`, `client`, and per-provider `integrations` overrides (`connectionId` to pin, `disabled: true` to exclude). GitHub is the first provider with an env contributor — its OAuth token is exported as `GH_TOKEN`/`GITHUB_TOKEN` so both `gh` and `git` HTTPS operations authenticate as the connected user, and `onStart` wires a git credential helper that reads the token from the environment rather than baking it into git config.
|
|
86
|
+
|
|
65
87
|
### Template provenance
|
|
66
88
|
|
|
67
89
|
Resend and incident.io are generated from integration-template contributions [#667](https://github.com/NangoHQ/integration-templates/pull/667) and [#668](https://github.com/NangoHQ/integration-templates/pull/668). Slack, GitHub, Google Mail, Google Calendar, Fireflies, PostHog, Stripe, Discord, Twitter/X, and HubSpot are generated from contribution [#677](https://github.com/NangoHQ/integration-templates/pull/677), which adds agent-focused actions (PostHog HogQL queries, Stripe balance/dispute/coupon/account reads, GitHub tags and trees, Slack Connect invites, Twitter search and following, HubSpot form submission) on top of upstream main. Until they land upstream, each provider manifest pins the contributing repository and exact commit and records generated file checksums.
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { ChannelProvider } from '@mastra/core/channels';
|
|
2
|
+
import type { ConnectClientOptions } from './client.js';
|
|
3
|
+
import type { DiscordReservedProviderOption, SlackReservedProviderOption, TelegramReservedProviderOption } from './providers/channels.js';
|
|
4
|
+
/**
|
|
5
|
+
* `providerOptions` fields that `channels()` refuses to forward to a
|
|
6
|
+
* `ChannelProvider` constructor. Marking them `never` here makes the compiler
|
|
7
|
+
* reject them at the call site; the resolver also strips them at runtime with
|
|
8
|
+
* a warning as a defensive layer.
|
|
9
|
+
*
|
|
10
|
+
* Two categories, applied per integration:
|
|
11
|
+
*
|
|
12
|
+
* - **Credentials.** The whole point of `channels()` is that the credential
|
|
13
|
+
* comes from the platform connection. Passing another `refreshToken` /
|
|
14
|
+
* `botToken` via `providerOptions` would silently override the connection
|
|
15
|
+
* (and thereby bypass rotation, revocation, and auditing).
|
|
16
|
+
* - **Framework-managed.** `baseUrl` is derived from the Mastra server config
|
|
17
|
+
* so webhook URLs match the actually-bound host. `encryptionKey` is a
|
|
18
|
+
* process-wide at-rest secret sourced from `MASTRA_ENCRYPTION_KEY`; letting
|
|
19
|
+
* `providerOptions` override it per integration would fragment the
|
|
20
|
+
* encryption boundary.
|
|
21
|
+
*/
|
|
22
|
+
type ForbidReservedOptions<Reserved extends string> = {
|
|
23
|
+
[K in Reserved]?: never;
|
|
24
|
+
};
|
|
25
|
+
/** Per-integration `providerOptions` shapes with reserved fields disallowed. */
|
|
26
|
+
export type SlackChannelsProviderOptions = Record<string, unknown> & ForbidReservedOptions<SlackReservedProviderOption>;
|
|
27
|
+
export type TelegramChannelsProviderOptions = Record<string, unknown> & ForbidReservedOptions<TelegramReservedProviderOption>;
|
|
28
|
+
export type DiscordChannelsProviderOptions = Record<string, unknown> & {
|
|
29
|
+
applicationId?: string;
|
|
30
|
+
publicKey?: string;
|
|
31
|
+
} & ForbidReservedOptions<DiscordReservedProviderOption>;
|
|
32
|
+
/** Base shape shared by every integration override; per-id specializations narrow `providerOptions`. */
|
|
33
|
+
export interface ChannelsIntegrationOptions<ProviderOptions = Record<string, unknown>> {
|
|
34
|
+
/** Pin a specific connection id (bypasses single-active-connection resolution). */
|
|
35
|
+
connectionId?: string;
|
|
36
|
+
/** Exclude this provider entirely, even if a connection exists. */
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/** Provider-specific options merged into the second argument of `ChannelProviderRegistration.build()`. */
|
|
39
|
+
providerOptions?: ProviderOptions;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Integration overrides map, typed per known channel id. Unknown ids are
|
|
43
|
+
* allowed with a generic option shape so future channels don't need a type
|
|
44
|
+
* change here.
|
|
45
|
+
*/
|
|
46
|
+
export interface ChannelsIntegrationOverrides {
|
|
47
|
+
slack?: ChannelsIntegrationOptions<SlackChannelsProviderOptions>;
|
|
48
|
+
telegram?: ChannelsIntegrationOptions<TelegramChannelsProviderOptions>;
|
|
49
|
+
discord?: ChannelsIntegrationOptions<DiscordChannelsProviderOptions>;
|
|
50
|
+
[integrationId: string]: ChannelsIntegrationOptions | undefined;
|
|
51
|
+
}
|
|
52
|
+
export interface ChannelsOptions {
|
|
53
|
+
/** Platform project whose connections to discover. Falls back to MASTRA_PROJECT_ID. */
|
|
54
|
+
projectId?: string;
|
|
55
|
+
/** Optional per-provider overrides keyed by integrationId. */
|
|
56
|
+
integrations?: ChannelsIntegrationOverrides;
|
|
57
|
+
client?: ConnectClientOptions;
|
|
58
|
+
/** How long a resolved snapshot stays fresh, in milliseconds. Default 30_000. `0` revalidates every resolution. */
|
|
59
|
+
ttlMs?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The result of resolving a project's connections into a
|
|
63
|
+
* `ChannelProvider` map. Assignable directly to `Mastra({ channels })`.
|
|
64
|
+
*/
|
|
65
|
+
export type ResolvedChannels = Record<string, ChannelProvider>;
|
|
66
|
+
/**
|
|
67
|
+
* Callback context passed to `channels()`'s resolver when invoked with a
|
|
68
|
+
* runtime context. Mirrors the shape used by `tools()` and other dynamic
|
|
69
|
+
* agent fields — currently unused (per-request provider variance isn't
|
|
70
|
+
* modeled here) but kept for signature symmetry.
|
|
71
|
+
*/
|
|
72
|
+
export interface ChannelsResolverContext {
|
|
73
|
+
requestContext?: unknown;
|
|
74
|
+
mastra?: unknown;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The value returned by `channels()`. Symmetric with `tools()`:
|
|
78
|
+
*
|
|
79
|
+
* - Thenable — `await channels({ projectId })` yields a
|
|
80
|
+
* `Record<string, ChannelProvider>` directly, ready to hand to
|
|
81
|
+
* `new Mastra({ channels: await channels({ projectId }) })`.
|
|
82
|
+
* - Callable — `channels(opts)(ctx)` returns the same
|
|
83
|
+
* `Record<string, ChannelProvider>`; identical to `await channels(opts)`.
|
|
84
|
+
* - Handles — `invalidate()` / `refresh()` / `disconnect()` scope to the
|
|
85
|
+
* resolver's private cache only. `Mastra({ channels })` reads the
|
|
86
|
+
* `Record<string, ChannelProvider>` **synchronously** at construction time,
|
|
87
|
+
* so the constructed Mastra instance will not pick up newly-added
|
|
88
|
+
* connections or rotated credentials without a restart. These handles are
|
|
89
|
+
* for standalone/test usage where the resolver is being called directly —
|
|
90
|
+
* not for the Mastra-registered snapshot.
|
|
91
|
+
*/
|
|
92
|
+
export interface ChannelsResolver extends PromiseLike<ResolvedChannels> {
|
|
93
|
+
/** Callable form used for symmetry with `tools()`; returns the resolved map. */
|
|
94
|
+
(context?: ChannelsResolverContext): Promise<ResolvedChannels>;
|
|
95
|
+
/** Drops the cached snapshot; the next resolution fetches fresh from the platform. */
|
|
96
|
+
invalidate(): void;
|
|
97
|
+
/** Fetches providers from the platform now and updates the cache. Rejects if the platform fetch fails. */
|
|
98
|
+
refresh(): Promise<ResolvedChannels>;
|
|
99
|
+
/** Clears the cached snapshot. Reserved for symmetry with `tools()`; currently a no-op beyond invalidation. */
|
|
100
|
+
disconnect(): Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns a live channels resolver over the project's Platform connections.
|
|
104
|
+
* Channel-capable integrations (Slack, Telegram, Discord) with an active
|
|
105
|
+
* project connection are materialized into `ChannelProvider` instances ready
|
|
106
|
+
* to hand to `new Mastra({ channels: await channels({...}) })`.
|
|
107
|
+
*
|
|
108
|
+
* Configuration errors (missing project id, bad ttlMs, malformed integration
|
|
109
|
+
* id) throw at call time so they surface at startup. Actionable per-integration
|
|
110
|
+
* problems during resolution (needs re-auth, ambiguity, missing peer package)
|
|
111
|
+
* are downgraded to warn-and-skip so one bad integration never takes down the
|
|
112
|
+
* whole map.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* import { Mastra } from '@mastra/core/mastra';
|
|
117
|
+
* import { channels } from '@mastra/connect';
|
|
118
|
+
*
|
|
119
|
+
* export const mastra = new Mastra({
|
|
120
|
+
* agents: { pat },
|
|
121
|
+
* channels: await channels({ projectId }),
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export declare function channels(options?: ChannelsOptions): ChannelsResolver;
|
|
126
|
+
export {};
|
|
127
|
+
//# sourceMappingURL=channels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../src/channels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,oBAAoB,EAA2D,MAAM,aAAa,CAAC;AAIjH,OAAO,KAAK,EACV,6BAA6B,EAC7B,2BAA2B,EAC3B,8BAA8B,EAC/B,MAAM,yBAAyB,CAAC;AAIjC;;;;;;;;;;;;;;;;;GAiBG;AACH,KAAK,qBAAqB,CAAC,QAAQ,SAAS,MAAM,IAAI;KAAG,CAAC,IAAI,QAAQ,CAAC,CAAC,EAAE,KAAK;CAAE,CAAC;AAElF,gFAAgF;AAChF,MAAM,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,qBAAqB,CAAC,2BAA2B,CAAC,CAAC;AACxH,MAAM,MAAM,+BAA+B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnE,qBAAqB,CAAC,8BAA8B,CAAC,CAAC;AACxD,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACrE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,qBAAqB,CAAC,6BAA6B,CAAC,CAAC;AAEzD,wGAAwG;AACxG,MAAM,WAAW,0BAA0B,CAAC,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACnF,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0GAA0G;IAC1G,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C,KAAK,CAAC,EAAE,0BAA0B,CAAC,4BAA4B,CAAC,CAAC;IACjE,QAAQ,CAAC,EAAE,0BAA0B,CAAC,+BAA+B,CAAC,CAAC;IACvE,OAAO,CAAC,EAAE,0BAA0B,CAAC,8BAA8B,CAAC,CAAC;IACrE,CAAC,aAAa,EAAE,MAAM,GAAG,0BAA0B,GAAG,SAAS,CAAC;CACjE;AAED,MAAM,WAAW,eAAe;IAC9B,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,4BAA4B,CAAC;IAC5C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,mHAAmH;IACnH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW,CAAC,gBAAgB,CAAC;IACrE,gFAAgF;IAChF,CAAC,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC/D,sFAAsF;IACtF,UAAU,IAAI,IAAI,CAAC;IACnB,0GAA0G;IAC1G,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACrC,+GAA+G;IAC/G,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAMD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,QAAQ,CAAC,OAAO,GAAE,eAAoB,GAAG,gBAAgB,CAuGxE"}
|
package/dist/connect.d.ts
CHANGED
|
@@ -1,66 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface ConnectIntegrationOptions {
|
|
3
|
-
/** Pin a specific connection id (bypasses env-var fallback and single-active-connection resolution). */
|
|
4
|
-
connectionId?: string;
|
|
5
|
-
/** Restrict the returned toolset to these tool keys. Unknown names throw at build time. */
|
|
6
|
-
allowTools?: string[];
|
|
7
|
-
/**
|
|
8
|
-
* MCP tool keys that may run without tool approval. Every other discovered
|
|
9
|
-
* MCP tool requires approval, whatever the server's annotations claim, since
|
|
10
|
-
* a remote catalog cannot be trusted to classify its own tools. An unknown
|
|
11
|
-
* name skips the provider with a warning, so a typo never widens access.
|
|
12
|
-
*/
|
|
13
|
-
autoApproveTools?: string[];
|
|
14
|
-
/** Exclude this provider entirely, even if a connection exists. */
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
}
|
|
17
|
-
export interface ConnectOptions {
|
|
18
|
-
/** Platform project whose connections to discover. Falls back to MASTRA_PROJECT_ID. */
|
|
19
|
-
projectId?: string;
|
|
20
|
-
/** Optional per-provider overrides keyed by integrationId. */
|
|
21
|
-
integrations?: Record<string, ConnectIntegrationOptions>;
|
|
22
|
-
client?: ConnectClientOptions;
|
|
23
|
-
/** How long a resolved snapshot stays fresh, in milliseconds. Default 30_000. `0` revalidates every resolution. */
|
|
24
|
-
ttlMs?: number;
|
|
25
|
-
}
|
|
26
|
-
type ResolvedConnectTools = Record<string, {
|
|
27
|
-
id: string;
|
|
28
|
-
}>;
|
|
1
|
+
import type { ToolsIntegrationOptions, ToolsOptions, ToolsResolver } from './tools.js';
|
|
29
2
|
/**
|
|
30
|
-
*
|
|
31
|
-
* dynamic `tools` argument: Mastra calls it per generate/stream, so project
|
|
32
|
-
* integrations attached or detached on the platform are reflected without
|
|
33
|
-
* restarting the server. Call it directly (`await tools()`) when you need the
|
|
34
|
-
* current flat tool record.
|
|
3
|
+
* @deprecated Renamed to {@link ToolsIntegrationOptions}.
|
|
35
4
|
*/
|
|
36
|
-
export
|
|
37
|
-
(ctx?: {
|
|
38
|
-
requestContext?: unknown;
|
|
39
|
-
mastra?: unknown;
|
|
40
|
-
}): Promise<ResolvedConnectTools>;
|
|
41
|
-
/** Drops the cached snapshot; the next resolution fetches fresh from the platform. */
|
|
42
|
-
invalidate(): void;
|
|
43
|
-
/** Fetches tools from the platform now and updates the cache. Rejects if the platform fetch fails. */
|
|
44
|
-
refresh(): Promise<ResolvedConnectTools>;
|
|
45
|
-
/** Closes MCP transports owned by this resolver and clears its cached snapshot. */
|
|
46
|
-
disconnect(): Promise<void>;
|
|
47
|
-
}
|
|
5
|
+
export type ConnectIntegrationOptions = ToolsIntegrationOptions;
|
|
48
6
|
/**
|
|
49
|
-
*
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
*
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
7
|
+
* @deprecated Renamed to {@link ToolsOptions}.
|
|
8
|
+
*/
|
|
9
|
+
export type ConnectOptions = ToolsOptions;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Renamed to {@link ToolsResolver}.
|
|
12
|
+
*/
|
|
13
|
+
export type ConnectTools = ToolsResolver;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Renamed to {@link tools}.
|
|
57
16
|
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* problems during resolution (needs re-auth or ambiguity) are downgraded to
|
|
62
|
-
* warn-and-skip so one bad integration never takes down the whole toolset.
|
|
17
|
+
* `connect(options)` is a drop-in alias for `tools(options)`. Prefer `tools`
|
|
18
|
+
* from `@mastra/connect` in new code; this export will be removed in the next
|
|
19
|
+
* minor version.
|
|
63
20
|
*/
|
|
64
21
|
export declare function connect(options?: ConnectOptions): ConnectTools;
|
|
65
|
-
export {};
|
|
66
22
|
//# sourceMappingURL=connect.d.ts.map
|
package/dist/connect.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../src/connect.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEvF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAEhE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,YAAY,CAElE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { SandboxStartHook } from '@mastra/core/workspace';
|
|
2
|
+
import type { ConnectClientOptions } from './client.js';
|
|
3
|
+
export interface EnvironmentIntegrationOptions {
|
|
4
|
+
/** Pin a specific connection id (bypasses env-var fallback and single-active-connection resolution). */
|
|
5
|
+
connectionId?: string;
|
|
6
|
+
/** Exclude this provider entirely, even if a connection exists. */
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface EnvironmentOptions {
|
|
10
|
+
/** Platform project whose connections to discover. Falls back to MASTRA_PROJECT_ID. */
|
|
11
|
+
projectId?: string;
|
|
12
|
+
/** Optional per-provider overrides keyed by integrationId. */
|
|
13
|
+
integrations?: Record<string, EnvironmentIntegrationOptions>;
|
|
14
|
+
client?: ConnectClientOptions;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Sandbox credentials materialized from the project's Platform connections.
|
|
18
|
+
* Pass `env` into the sandbox's environment and `onStart` as (or inside) its
|
|
19
|
+
* start hook so CLI tooling in the sandbox is authenticated out of the box.
|
|
20
|
+
*/
|
|
21
|
+
export interface ConnectEnvironment {
|
|
22
|
+
/** Environment variables to inject into the sandbox (e.g. GH_TOKEN). Never log these. */
|
|
23
|
+
env: Record<string, string | undefined>;
|
|
24
|
+
/** Runs provider setup inside the sandbox (e.g. git credential wiring). Safe no-op when nothing to do. */
|
|
25
|
+
onStart: SandboxStartHook;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolves the project's Platform connections into sandbox credentials:
|
|
29
|
+
* environment variables plus a start hook that finishes in-sandbox setup.
|
|
30
|
+
* Currently GitHub-aware (`GH_TOKEN`/`GITHUB_TOKEN` + git credential helper);
|
|
31
|
+
* more providers plug in over time.
|
|
32
|
+
*
|
|
33
|
+
* Connection resolution matches `connect()`: a per-integration `connectionId`
|
|
34
|
+
* or the provider's `MASTRA_*_CONNECTION_ID` env var wins, else a single
|
|
35
|
+
* active connection; ambiguity, needs_reauth, and credential-fetch failures
|
|
36
|
+
* warn and skip that provider. Configuration errors (missing project id,
|
|
37
|
+
* malformed integration id) throw here so they surface at startup.
|
|
38
|
+
*
|
|
39
|
+
* The returned `env` is a snapshot: call `environment()` again for a fresh
|
|
40
|
+
* token when starting new sandboxes.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* const { env, onStart } = await environment({ projectId });
|
|
44
|
+
* const sandbox = new E2BSandbox({ env, onStart });
|
|
45
|
+
* // in the sandbox: `gh pr list`, `git clone https://github.com/org/repo` just work
|
|
46
|
+
*/
|
|
47
|
+
export declare function environment(options?: EnvironmentOptions): Promise<ConnectEnvironment>;
|
|
48
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAAE,oBAAoB,EAAwB,MAAM,aAAa,CAAC;AAK9E,MAAM,WAAW,6BAA6B;IAC5C,wGAAwG;IACxG,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;IAC7D,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,yFAAyF;IACzF,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IACxC,0GAA0G;IAC1G,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAuDD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAuD/F"}
|