@mastra/connect 0.4.0 → 0.5.0-alpha.1
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.d.ts +40 -32
- package/dist/channels.d.ts.map +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.cjs +100 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -91
- package/dist/index.js.map +1 -1
- package/dist/providers/channel-provider.d.ts +45 -17
- package/dist/providers/channel-provider.d.ts.map +1 -1
- package/dist/providers/channels.d.ts +1 -1
- package/dist/providers/channels.d.ts.map +1 -1
- package/package.json +8 -22
|
@@ -1,32 +1,60 @@
|
|
|
1
1
|
import type { ChannelProvider } from '@mastra/core/channels';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ConnectionContext, ConnectionCredential, ResolvedClient } from '../client.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Live view of one integration's platform connection, handed to
|
|
5
|
+
* `ChannelProviderRegistration.create()`. The `channels()` resolver updates
|
|
6
|
+
* the current connection on every resolution, so a registration's provider
|
|
7
|
+
* and `sync()` closure always read the latest state through these accessors
|
|
8
|
+
* instead of capturing a connection at construction time.
|
|
8
9
|
*/
|
|
9
|
-
export interface
|
|
10
|
-
|
|
11
|
-
context?: ConnectionContext;
|
|
10
|
+
export interface ChannelRuntime {
|
|
11
|
+
/** Resolved platform client for follow-up lookups. */
|
|
12
12
|
client: ResolvedClient;
|
|
13
|
+
/** The currently-selected active connection id, or `undefined` when the integration has none. */
|
|
14
|
+
getConnectionId(): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Fetches a fresh credential for the current connection. Never cached —
|
|
17
|
+
* the platform's credential vendor owns token refresh, so each call may
|
|
18
|
+
* return a newer token than the last. Throws when no connection is active.
|
|
19
|
+
*/
|
|
20
|
+
getCredential(): Promise<ConnectionCredential>;
|
|
21
|
+
/** Fetches the current connection's non-secret context (metadata), or `undefined` when unavailable. */
|
|
22
|
+
getConnectionContext(): Promise<ConnectionContext | undefined>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A long-lived channel provider produced by a registration. The `provider`
|
|
26
|
+
* instance survives across resolutions (its routes are mounted once, at
|
|
27
|
+
* Mastra construction); `sync()` re-applies the current connection's
|
|
28
|
+
* credential/metadata on each resolution while a connection is active.
|
|
29
|
+
*/
|
|
30
|
+
export interface ChannelInstance {
|
|
31
|
+
provider: ChannelProvider;
|
|
32
|
+
/**
|
|
33
|
+
* Push the current connection's credential/metadata into the live
|
|
34
|
+
* provider (via `provider.configure()` or equivalent). Called on every
|
|
35
|
+
* resolution while a connection is active; implementations should be
|
|
36
|
+
* cheap when nothing changed. Omit for providers that pull credentials
|
|
37
|
+
* lazily themselves (e.g. Slack's `tokenResolver`).
|
|
38
|
+
*/
|
|
39
|
+
sync?(): Promise<void>;
|
|
13
40
|
}
|
|
14
41
|
/**
|
|
15
42
|
* Registers one channel-capable provider with `channels()`. An `integrationId`
|
|
16
|
-
* matches the project connection
|
|
17
|
-
*
|
|
18
|
-
* `
|
|
19
|
-
*
|
|
20
|
-
* so registrations stay minimal.
|
|
43
|
+
* matches the project connection; `create()` constructs the long-lived
|
|
44
|
+
* provider once, credential-less. Ambiguity is handled at the resolver level
|
|
45
|
+
* (`channels()` warns and picks the first active connection when more than
|
|
46
|
+
* one is present) so registrations stay minimal.
|
|
21
47
|
*/
|
|
22
48
|
export interface ChannelProviderRegistration<Options = Record<string, unknown>> {
|
|
23
49
|
/** Platform catalog id used to match project connections (e.g. 'slack', 'telegram', 'discord'). */
|
|
24
50
|
integrationId: string;
|
|
25
51
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
52
|
+
* Construct the long-lived Mastra `ChannelProvider`. Channel packages are
|
|
53
|
+
* imported inside `create()` with `await import()` so only registrations
|
|
54
|
+
* that aren't disabled pay the module-load cost. Must not call the
|
|
55
|
+
* platform: construction happens before any connection is resolved, so
|
|
56
|
+
* credentials arrive later through `runtime` (lazily, or on `sync()`).
|
|
29
57
|
*/
|
|
30
|
-
|
|
58
|
+
create(options: Options | undefined, runtime: ChannelRuntime): Promise<ChannelInstance>;
|
|
31
59
|
}
|
|
32
60
|
//# sourceMappingURL=channel-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channel-provider.d.ts","sourceRoot":"","sources":["../../src/providers/channel-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"channel-provider.d.ts","sourceRoot":"","sources":["../../src/providers/channel-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE5F;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,sDAAsD;IACtD,MAAM,EAAE,cAAc,CAAC;IACvB,iGAAiG;IACjG,eAAe,IAAI,MAAM,GAAG,SAAS,CAAC;IACtC;;;;OAIG;IACH,aAAa,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAC/C,uGAAuG;IACvG,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;CAChE;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,eAAe,CAAC;IAC1B;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,2BAA2B,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5E,mGAAmG;IACnG,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CACzF"}
|
|
@@ -18,7 +18,7 @@ import type { ChannelProviderRegistration } from './channel-provider.js';
|
|
|
18
18
|
* `providerOptions` (handlers, streaming, commands, handlers, threadContext,
|
|
19
19
|
* inlineMedia, etc.) is forwarded to the provider constructor unchanged.
|
|
20
20
|
*/
|
|
21
|
-
declare const SLACK_RESERVED_KEYS: readonly ['baseUrl', 'refreshToken', 'token', 'encryptionKey'];
|
|
21
|
+
declare const SLACK_RESERVED_KEYS: readonly ['baseUrl', 'refreshToken', 'token', 'tokenResolver', 'encryptionKey'];
|
|
22
22
|
declare const TELEGRAM_RESERVED_KEYS: readonly ['baseUrl', 'apiBaseUrl', 'botToken', 'encryptionKey'];
|
|
23
23
|
declare const DISCORD_RESERVED_KEYS: readonly ['baseUrl', 'encryptionKey'];
|
|
24
24
|
/** Reserved (credential + framework-managed) `providerOptions` keys per integration. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../../src/providers/channels.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"channels.d.ts","sourceRoot":"","sources":["../../src/providers/channels.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAMzE;;;;;;;;;;;;;;;;;;GAkBG;AACH,QAAA,MAAM,mBAAmB,YAAI,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,eAAe,CAAU,CAAC;AAC5G,QAAA,MAAM,sBAAsB,YAAI,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,CAAU,CAAC;AAC/F,QAAA,MAAM,qBAAqB,YAAI,SAAS,EAAE,eAAe,CAAU,CAAC;AAEpE,wFAAwF;AACxF,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAC/E,MAAM,MAAM,8BAA8B,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AACrF,MAAM,MAAM,6BAA6B,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAoMnF,eAAO,MAAM,QAAQ,EAAE,SAAS,2BAA2B,EAAoD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/connect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-alpha.1",
|
|
4
4
|
"description": "Use Mastra platform integration connections as agent toolsets",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -44,23 +44,9 @@
|
|
|
44
44
|
"node": ">=22.13.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"@mastra/core": ">=1.
|
|
48
|
-
"@mastra/discord": ">=1.0.0-0 <2.0.0-0",
|
|
49
|
-
"@mastra/slack": ">=1.0.0-0 <2.0.0-0",
|
|
50
|
-
"@mastra/telegram": ">=0.1.0-0 <1.0.0-0",
|
|
47
|
+
"@mastra/core": ">=1.72.0-0 <2.0.0-0",
|
|
51
48
|
"zod": ">=3.0.0 || >=4.0.0"
|
|
52
49
|
},
|
|
53
|
-
"peerDependenciesMeta": {
|
|
54
|
-
"@mastra/discord": {
|
|
55
|
-
"optional": true
|
|
56
|
-
},
|
|
57
|
-
"@mastra/slack": {
|
|
58
|
-
"optional": true
|
|
59
|
-
},
|
|
60
|
-
"@mastra/telegram": {
|
|
61
|
-
"optional": true
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
50
|
"devDependencies": {
|
|
65
51
|
"prettier": "3.9.5",
|
|
66
52
|
"ts-morph": "^27.0.2",
|
|
@@ -69,15 +55,15 @@
|
|
|
69
55
|
"typescript": "^7.0.2",
|
|
70
56
|
"vitest": "4.1.11",
|
|
71
57
|
"zod": "^4.6.4",
|
|
58
|
+
"@internal/types-builder": "0.0.112",
|
|
72
59
|
"@internal/lint": "0.0.137",
|
|
73
|
-
"@mastra/
|
|
74
|
-
"@mastra/slack": "1.6.4",
|
|
75
|
-
"@mastra/telegram": "0.1.3",
|
|
76
|
-
"@mastra/core": "1.71.0",
|
|
77
|
-
"@internal/types-builder": "0.0.112"
|
|
60
|
+
"@mastra/core": "1.72.0-alpha.5"
|
|
78
61
|
},
|
|
79
62
|
"dependencies": {
|
|
80
|
-
"@mastra/
|
|
63
|
+
"@mastra/discord": "^1.2.0-alpha.0",
|
|
64
|
+
"@mastra/mcp": "^2.1.0",
|
|
65
|
+
"@mastra/slack": "^1.7.0-alpha.0",
|
|
66
|
+
"@mastra/telegram": "^0.1.3"
|
|
81
67
|
},
|
|
82
68
|
"scripts": {
|
|
83
69
|
"add-provider": "tsx scripts/add-provider.ts",
|