@mastra/connect 1.3.2-alpha.3 → 1.4.0-alpha.5

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.
@@ -0,0 +1,38 @@
1
+ import type { CodeModeConfig, CodeModeTransport } from '@mastra/core/tools';
2
+ import type { ToolsResolverContext } from './tools.js';
3
+ type ResolvedToolsRecord = Record<string, {
4
+ id: string;
5
+ description?: string;
6
+ }>;
7
+ /** Options for {@link ToolsResolver.codeMode}: everything `createCodeMode()` takes except `tools`. */
8
+ export interface CodeModeOptions extends Omit<CodeModeConfig, 'tools'> {
9
+ /** Transport passed to `createCodeMode()`. Defaults to its stdio transport, which needs a sandbox. */
10
+ transport?: CodeModeTransport;
11
+ /**
12
+ * List only function names in the instructions and give the model a
13
+ * `search_functions` tool that returns the declarations it needs. Saves
14
+ * context when many providers are connected. By default it turns on when
15
+ * declaring every function would take more than about 10k tokens.
16
+ */
17
+ toolSearch?: boolean;
18
+ }
19
+ /**
20
+ * Connect tools in Code Mode. Pass both halves to an agent; each resolves the
21
+ * current connections per request, like the resolver itself.
22
+ */
23
+ export interface ConnectCodeMode {
24
+ /**
25
+ * The code tool (`execute_typescript` by default) plus the tools that must
26
+ * stay direct: tools that need the user's approval and `request_connection`,
27
+ * which pause the agent run. Pass as the agent's `tools`.
28
+ */
29
+ tools(ctx?: ToolsResolverContext): Promise<ResolvedToolsRecord>;
30
+ /**
31
+ * Instructions declaring the functions the program can call. Add to the
32
+ * agent's instructions. Empty when there is nothing to orchestrate.
33
+ */
34
+ instructions(ctx?: ToolsResolverContext): Promise<string>;
35
+ }
36
+ export declare function connectCodeMode(resolve: (ctx?: ToolsResolverContext) => Promise<ResolvedToolsRecord>, options?: CodeModeOptions): ConnectCodeMode;
37
+ export {};
38
+ //# sourceMappingURL=code-mode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-mode.d.ts","sourceRoot":"","sources":["../src/code-mode.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAG5E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,KAAK,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEhF,sGAAsG;AACtG,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC;IACpE,sGAAsG;IACtG,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAChE;;;OAGG;IACH,YAAY,CAAC,GAAG,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC3D;AAmCD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAC,mBAAmB,CAAC,EACrE,OAAO,GAAE,eAAoB,GAC5B,eAAe,CA8CjB"}
@@ -3,7 +3,7 @@ name: mastra-connect
3
3
  description: Documentation for @mastra/connect. Use when working with @mastra/connect APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/connect"
6
- version: "1.3.2-alpha.3"
6
+ version: "1.4.0-alpha.5"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,16 +1,16 @@
1
1
  {
2
- "version": "1.3.2-alpha.3",
2
+ "version": "1.4.0-alpha.5",
3
3
  "package": "@mastra/connect",
4
4
  "exports": {
5
5
  "CHANNELS": {
6
6
  "types": "dist/registry.d.ts",
7
7
  "implementation": "dist/index.js",
8
- "line": 85421
8
+ "line": 85603
9
9
  },
10
10
  "CONNECT_PROMPT_TOOL_KEY": {
11
11
  "types": "dist/connect-prompt-tool.d.ts",
12
12
  "implementation": "dist/index.js",
13
- "line": 684
13
+ "line": 852
14
14
  },
15
15
  "MastraConnectError": {
16
16
  "types": "dist/errors.d.ts",
@@ -20,27 +20,27 @@
20
20
  "PROVIDERS": {
21
21
  "types": "dist/registry.d.ts",
22
22
  "implementation": "dist/index.js",
23
- "line": 85378
23
+ "line": 85560
24
24
  },
25
25
  "channels": {
26
26
  "types": "dist/channels.d.ts",
27
27
  "implementation": "dist/index.js",
28
- "line": 86403
28
+ "line": 86588
29
29
  },
30
30
  "credential": {
31
31
  "types": "dist/credential.d.ts",
32
32
  "implementation": "dist/index.js",
33
- "line": 86634
33
+ "line": 86819
34
34
  },
35
35
  "tools": {
36
36
  "types": "dist/tools.d.ts",
37
37
  "implementation": "dist/index.js",
38
- "line": 85849
38
+ "line": 86031
39
39
  },
40
40
  "userConnectRoutes": {
41
41
  "types": "dist/user-connect-routes.d.ts",
42
42
  "implementation": "dist/index.js",
43
- "line": 86939
43
+ "line": 87124
44
44
  }
45
45
  },
46
46
  "modules": {}
@@ -109,6 +109,7 @@ The resolver also exposes methods for manual control:
109
109
  - `refresh()` fetches from the platform immediately, then updates the cache and returns the tool record. Rejects if the platform fetch fails.
110
110
  - `disconnect()` clears the cached snapshots and closes the MCP transports of the state behind this resolver. Resolvers created with identical options share that state, so this disconnects them too. A later resolution rebuilds the state, and already-returned MCP tools reconnect on their next call.
111
111
  - `with(extra)` returns a new resolver that merges extra tools into every resolution, giving extras priority on key collision. It accepts a static tool record or a function (sync or async) and calls chain. For the same merge using a spread of the resolver's result in a `tools` callback, see [Add tools to an agent](https://mastra.ai/docs/mastra-platform/connect).
112
+ - `codeMode(options)` exposes the tools through [Code Mode](#code-mode).
112
113
 
113
114
  To filter on something other than tool keys, or on data that options can't express, post-process the resolved record in the agent's `tools` function. Create the resolver once, outside the function, so its cache is shared:
114
115
 
@@ -144,6 +145,64 @@ Error handling depends on the cause:
144
145
  - If a background refresh fails while a snapshot is cached, the resolver keeps serving the cached toolsets and warns. It rejects only when nothing was ever cached.
145
146
  - A problem with one provider, such as a connection that needs reauthorization, logs a warning and skips that provider. The other providers' tools still load.
146
147
 
148
+ ## Code Mode
149
+
150
+ `codeMode()` gives the agent the connected tools through [Code Mode](https://mastra.ai/docs/agents/code-mode): the agent writes one TypeScript program that calls the tools as `external_*` functions, instead of calling each tool in its own step. Use it when tasks fan out across many calls or providers, such as listing items in one provider and looking each one up in another.
151
+
152
+ ```typescript
153
+ import { Agent } from '@mastra/core/agent'
154
+ import { LocalSandbox } from '@mastra/core/workspace'
155
+ import { tools } from '@mastra/connect'
156
+
157
+ const code = tools({ providers: ['linear', 'slack'] }).codeMode({ sandbox: new LocalSandbox() })
158
+
159
+ export const opsAgent = new Agent({
160
+ id: 'ops',
161
+ name: 'ops',
162
+ instructions: async ctx => ['You help the team track work.', await code.instructions(ctx)],
163
+ model: 'openai/gpt-6-luna',
164
+ tools: code.tools,
165
+ })
166
+ ```
167
+
168
+ > **Warning:** `LocalSandbox` runs the model-written program as a host `node` process with host privileges. Connected tools return third-party data, such as issue text, that can influence the code the model writes. Use `LocalSandbox` only for trusted or local development. See [how Code Mode works](https://mastra.ai/docs/agents/code-mode) for isolated alternatives.
169
+
170
+ `codeMode()` returns two functions, `tools` and `instructions`. Pass both to the agent. Like the resolver, they resolve the current connections on every request. The functions the program can call change as providers are connected or disconnected. Within one request both use the same resolution, and the instructions never declare a function the program can't call.
171
+
172
+ The method accepts every [`createCodeMode()` option](https://mastra.ai/reference/tools/create-code-mode) except `tools` (`sandbox`, `timeout`, `id`), plus `transport` for a [remote sandbox](https://mastra.ai/docs/agents/code-mode) or [in-process isolation](https://mastra.ai/docs/agents/code-mode), and `toolSearch` for [tool search](#tool-search). Every resolver provides it, including the callback form and resolvers returned by `with()`. Extra tools from `with()` join the program's functions.
173
+
174
+ Some tools stay direct agent tools instead of program functions, because they pause the agent run and a call from inside a program can't:
175
+
176
+ - Tools that need approval through `requireApproval`. The agent still waits for the user to approve each call.
177
+ - The `request_connection` tool, so the connect prompt can still pause the run until the user connects.
178
+
179
+ For [MCP providers](#mcp-providers), a `requireApproval` list keeps **all** of that provider's tools direct, including the ones the list doesn't name. Mastra discovers MCP tools at request time and checks the list on each call, so Code Mode has no way to know in advance which calls need approval and keeps every tool from that provider out of the program. Generated HTTP tools work differently, because only the tools that match the list stay direct.
180
+
181
+ ```typescript
182
+ // Every neon-mcp tool stays direct, not just neon-mcp_run_sql
183
+ const ops = tools({
184
+ providers: { 'neon-mcp': { requireApproval: ['neon-mcp_run_sql'] } },
185
+ }).codeMode({ sandbox })
186
+ ```
187
+
188
+ To let a program call that provider's other tools, remove the gated tools with `disallowTools` instead of gating them. To keep them gated, accept that the agent calls the provider's tools one at a time.
189
+
190
+ When there is nothing to orchestrate, for example when the project has no connections yet, `tools` returns only the direct tools and `instructions` returns an empty string.
191
+
192
+ ### Tool search
193
+
194
+ Declaring every function in the instructions uses context on every request: about 4,000 tokens for Linear alone and over 20,000 for Linear, GitHub, and Stripe together. With tool search, the instructions list only the function names, and the agent gets a `search_functions` tool that returns the TypeScript declarations for the functions it needs. The agent searches by what it wants to do or by exact names from the list, then writes the program. The program can still call every function. Only the declarations move behind the search.
195
+
196
+ Tool search turns on by itself when declaring every function would take more than about 10,000 tokens. Set `toolSearch` to choose:
197
+
198
+ ```typescript
199
+ // Always list names only and search for declarations
200
+ const searching = tools().codeMode({ sandbox: new LocalSandbox(), toolSearch: true })
201
+
202
+ // Always declare every function up front
203
+ const declared = tools().codeMode({ sandbox: new LocalSandbox(), toolSearch: false })
204
+ ```
205
+
147
206
  ## Choosing providers
148
207
 
149
208
  The `providers` array form is an allowlist: only listed providers are returned. Without the option, every connected provider with a supported toolset is included. A listed provider with no connection in the project yet is skipped and included automatically once a connection is attached. In the record form, `false` excludes a provider and never errors, even for IDs that match nothing.
@@ -0,0 +1,17 @@
1
+ import type { CodeModeStub } from '@mastra/core/tools';
2
+ type ToolRecord = Record<string, {
3
+ id: string;
4
+ description?: string;
5
+ }>;
6
+ export declare const SEARCH_TOOL_ID = "search_functions";
7
+ /** The `search_functions` tool: returns declarations for the functions that match a query. */
8
+ export declare function createFunctionSearchTool(tools: ToolRecord, stubs: CodeModeStub[], codeToolId: string): import("@mastra/core/tools").Tool<{
9
+ query: string;
10
+ limit?: number | undefined;
11
+ }, {
12
+ declarations: string;
13
+ }, unknown, unknown, import("@mastra/core/tools").ToolExecutionContext<unknown, unknown, unknown>, "search_functions", unknown>;
14
+ /** Code Mode instructions that list function names only; declarations come from `search_functions`. */
15
+ export declare function searchModeInstructions(stubs: CodeModeStub[], codeToolId: string): string;
16
+ export {};
17
+ //# sourceMappingURL=function-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function-search.d.ts","sourceRoot":"","sources":["../src/function-search.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEvE,eAAO,MAAM,cAAc,qBAAqB,CAAC;AAwEjD,8FAA8F;AAC9F,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,MAAM;;;;;gIA4BpG;AAED,uGAAuG;AACvG,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CA4BxF"}
package/dist/index.cjs CHANGED
@@ -677,6 +677,174 @@ async function disconnectConnection(client, connectionId) {
677
677
  const response = await platformFetch(client, `/v2/connections/${encodeURIComponent(connectionId)}`, { method: "DELETE" });
678
678
  if (!response.ok) await throwPlatformError(response, `disconnecting connection ${connectionId}`);
679
679
  }
680
+ // src/function-search.ts
681
+ const SEARCH_TOOL_ID = "search_functions";
682
+ const DEFAULT_LIMIT = 8;
683
+ const MAX_LIMIT = 25;
684
+ /** Lowercase word list with a light plural strip, so "issues" finds `create_issue`. */
685
+ function words(text) {
686
+ return text.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean).map((word) => word.length > 3 && word.endsWith("s") && !word.endsWith("ss") ? word.slice(0, -1) : word);
687
+ }
688
+ /**
689
+ * Ranks the program's functions for a query. Name words outweigh description
690
+ * words, rare words outweigh common ones (every Linear function says "linear"),
691
+ * and a query term that is a function's exact name always returns it.
692
+ */
693
+ function createSearch(tools, stubs) {
694
+ const descriptions = new Map(Object.values(tools).map((tool) => [tool.id, tool.description ?? ""]));
695
+ const entries = stubs.map((stub) => {
696
+ const name = new Set(words(stub.externalName));
697
+ return {
698
+ stub,
699
+ name,
700
+ text: /* @__PURE__ */ new Set([...name, ...words(descriptions.get(stub.toolId) ?? "")])
701
+ };
702
+ });
703
+ const frequency = /* @__PURE__ */ new Map();
704
+ for (const entry of entries) for (const word of entry.text) frequency.set(word, (frequency.get(word) ?? 0) + 1);
705
+ const weight = (word) => Math.log(1 + entries.length / (frequency.get(word) ?? entries.length));
706
+ const byName = new Map(entries.map((entry) => [entry.stub.externalName.toLowerCase(), entry]));
707
+ return (query, limit) => {
708
+ const exact = query.split(/\s+/).map((term) => byName.get(term.toLowerCase().replace(/^external_/, "").replace(/\(.*$/, ""))).filter((entry) => entry !== void 0);
709
+ const terms = [...new Set(words(query))];
710
+ const scored = entries.filter((entry) => !exact.includes(entry)).map((entry) => {
711
+ let score = 0;
712
+ for (const term of terms) if (entry.name.has(term)) score += 3 * weight(term);
713
+ else if (entry.text.has(term)) score += .5 * weight(term);
714
+ else if (term.length >= 4 && [...entry.name].some((word) => word.startsWith(term))) score += 2 * weight(term);
715
+ return {
716
+ entry,
717
+ score
718
+ };
719
+ }).filter(({ score }) => score > 0).sort((a, b) => b.score - a.score || a.entry.name.size - b.entry.name.size || a.entry.stub.externalName.localeCompare(b.entry.stub.externalName));
720
+ return [.../* @__PURE__ */ new Set([...exact, ...scored.map(({ entry }) => entry)])].slice(0, limit).map((entry) => entry.stub);
721
+ };
722
+ }
723
+ /** The `search_functions` tool: returns declarations for the functions that match a query. */
724
+ function createFunctionSearchTool(tools, stubs, codeToolId) {
725
+ const search = createSearch(tools, stubs);
726
+ return (0, _mastra_core_tools.createTool)({
727
+ id: SEARCH_TOOL_ID,
728
+ description: `Find the external_* functions a \`${codeToolId}\` program can call and get their TypeScript declarations. Search by what you need ("list linear teams") or by exact function names. Call this before writing a program that uses functions you have no declaration for.`,
729
+ inputSchema: zod.z.object({
730
+ query: zod.z.string().min(1).describe("What the functions should do, or exact function names separated by spaces."),
731
+ limit: zod.z.number().int().min(1).max(MAX_LIMIT).optional().describe(`How many functions to return (default ${DEFAULT_LIMIT}).`)
732
+ }),
733
+ outputSchema: zod.z.object({ declarations: zod.z.string() }),
734
+ execute: async ({ query, limit }) => {
735
+ const found = search(query, limit ?? DEFAULT_LIMIT);
736
+ return { declarations: found.length ? found.map((stub) => stub.declaration).join("\n\n") : "No functions matched. Try other words, or exact names from the function list in your instructions." };
737
+ }
738
+ });
739
+ }
740
+ /** Code Mode instructions that list function names only; declarations come from `search_functions`. */
741
+ function searchModeInstructions(stubs, codeToolId) {
742
+ return `# Code Mode
743
+
744
+ You have access to the \`${codeToolId}\` tool. Instead of calling tools one at a time,
745
+ write a single TypeScript program that orchestrates them and returns one result.
746
+
747
+ There are too many functions to declare here, so only their names are listed
748
+ below, without their parameters. Work in two steps:
749
+ 1. Call the \`${SEARCH_TOOL_ID}\` tool directly (a regular tool call, not from inside a
750
+ program) with what you need, or with exact names from the list. It returns the
751
+ functions' TypeScript declarations.
752
+ 2. Call \`${codeToolId}\` with a program that only uses functions whose declarations
753
+ you have. Guessed parameters fail validation.
754
+
755
+ Rules:
756
+ - Call the available tools via the \`external_*\` functions. Each returns a
757
+ Promise — \`await\` it.
758
+ - Batch independent calls with \`Promise.all\`. Do arithmetic and data shaping in
759
+ JavaScript, not in your head.
760
+ - End the program by \`return\`-ing the final value (objects/arrays are fine).
761
+ - The only supported capabilities are the \`external_*\` functions. Do not rely
762
+ on filesystem, network, or process access — depending on the configured
763
+ sandbox and transport, the program may run fully isolated with none of those
764
+ available.
765
+ - Use \`console.log\` for debugging; logs are captured and returned.
766
+
767
+ Functions:
768
+ ${stubs.map((stub) => `external_${stub.externalName}`).join("\n")}`;
769
+ }
770
+ // src/code-mode.ts
771
+ /**
772
+ * How long one request reuses its build. An agent call resolves its
773
+ * instructions and tools separately; sharing one build keeps the declared
774
+ * functions identical to the ones the program can call. The window is short
775
+ * so a RequestContext reused across calls still picks up connection changes.
776
+ */
777
+ const REQUEST_BUILD_MS = 3e4;
778
+ /** Declarations above this size (about 10k tokens) switch to tool search unless `toolSearch` says otherwise. */
779
+ const SEARCH_THRESHOLD_CHARS = 4e4;
780
+ /**
781
+ * Tools that only work as direct agent tools: approval and suspension are
782
+ * handled by the agent loop, and a call from inside a program bypasses it. A
783
+ * per-call approval function counts too, since it cannot be decided up front.
784
+ */
785
+ function needsAgentLoop(tool) {
786
+ const candidate = tool;
787
+ return Boolean(candidate.requireApproval || candidate.needsApprovalFn || candidate.suspendSchema || candidate.resumeSchema);
788
+ }
789
+ function connectCodeMode(resolve, options = {}) {
790
+ const { transport, toolSearch, ...config } = options;
791
+ const builds = /* @__PURE__ */ new WeakMap();
792
+ const build = async (ctx) => {
793
+ const direct = {};
794
+ const orchestrated = {};
795
+ for (const [key, tool] of Object.entries(await resolve(ctx))) (needsAgentLoop(tool) ? direct : orchestrated)[key] = tool;
796
+ if (Object.keys(orchestrated).length === 0) return {
797
+ tools: direct,
798
+ instructions: ""
799
+ };
800
+ const stubs = (0, _mastra_core_tools.generateStubs)(orchestrated);
801
+ if (!(toolSearch ?? stubs.reduce((size, stub) => size + stub.declaration.length, 0) > SEARCH_THRESHOLD_CHARS)) {
802
+ const codeMode = (0, _mastra_core_tools.createCodeMode)({
803
+ ...config,
804
+ tools: orchestrated
805
+ }, transport);
806
+ return {
807
+ tools: {
808
+ ...direct,
809
+ [codeMode.tool.id]: codeMode.tool
810
+ },
811
+ instructions: codeMode.instructions
812
+ };
813
+ }
814
+ const codeTool = (0, _mastra_core_tools.createCodeModeTool)({
815
+ ...config,
816
+ tools: orchestrated
817
+ }, transport);
818
+ const searchTool = createFunctionSearchTool(orchestrated, stubs, codeTool.id);
819
+ return {
820
+ tools: {
821
+ ...direct,
822
+ [codeTool.id]: codeTool,
823
+ [searchTool.id]: searchTool
824
+ },
825
+ instructions: searchModeInstructions(stubs, codeTool.id)
826
+ };
827
+ };
828
+ const buildFor = (ctx) => {
829
+ const key = ctx?.requestContext;
830
+ if (typeof key !== "object" || key === null) return build(ctx);
831
+ const cached = builds.get(key);
832
+ if (cached && Date.now() - cached.startedAt < REQUEST_BUILD_MS) return cached.build;
833
+ const entry = {
834
+ build: build(ctx),
835
+ startedAt: Date.now()
836
+ };
837
+ builds.set(key, entry);
838
+ entry.build.catch(() => {
839
+ if (builds.get(key) === entry) builds.delete(key);
840
+ });
841
+ return entry.build;
842
+ };
843
+ return {
844
+ tools: async (ctx) => (await buildFor(ctx)).tools,
845
+ instructions: async (ctx) => (await buildFor(ctx)).instructions
846
+ };
847
+ }
680
848
  // src/connect-prompt-tool.ts
681
849
  /**
682
850
  * Record key of the built-in connect-prompt tool. Reserved: a provider tool
@@ -8134,11 +8302,15 @@ const SummarySchema = zod.z.object({
8134
8302
  transcript_chapters: zod.z.array(zod.z.string()).nullish(),
8135
8303
  extended_sections: zod.z.array(SummarySectionSchema).nullish()
8136
8304
  });
8137
- const ProviderSummarySchema$1 = SummarySchema.extend({ action_items: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).nullish() });
8305
+ const ProviderSummarySchema$1 = SummarySchema.extend({
8306
+ action_items: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).nullish(),
8307
+ keywords: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).nullish()
8308
+ });
8138
8309
  const SpeakerSchema = zod.z.object({
8139
8310
  id: zod.z.string().nullish(),
8140
8311
  name: zod.z.string().nullish()
8141
8312
  });
8313
+ const ProviderSpeakerSchema = SpeakerSchema.extend({ id: zod.z.union([zod.z.string(), zod.z.number()]).nullish() });
8142
8314
  const MeetingInfoSchema = zod.z.object({
8143
8315
  fred_joined: zod.z.boolean().nullish(),
8144
8316
  silent_meeting: zod.z.boolean().nullish(),
@@ -8184,7 +8356,7 @@ const TranscriptSchema = zod.z.object({
8184
8356
  title: zod.z.string().nullish(),
8185
8357
  sentences: zod.z.array(ProviderSentenceSchema).nullish(),
8186
8358
  summary: ProviderSummarySchema$1.nullable().optional(),
8187
- speakers: zod.z.array(SpeakerSchema).nullish(),
8359
+ speakers: zod.z.array(ProviderSpeakerSchema).nullish(),
8188
8360
  meeting_info: MeetingInfoSchema.nullable().optional(),
8189
8361
  meeting_attendees: zod.z.array(MeetingAttendeeSchema).nullish(),
8190
8362
  analytics: AnalyticsSchema.nullable().optional()
@@ -8210,6 +8382,15 @@ const getTranscriptOutputSchema = zod.z.object({
8210
8382
  function normalizeActionItems$1(actionItems) {
8211
8383
  return Array.isArray(actionItems) ? actionItems.join("\n") : actionItems;
8212
8384
  }
8385
+ function normalizeKeywords(keywords) {
8386
+ return Array.isArray(keywords) ? keywords.join(", ") : keywords;
8387
+ }
8388
+ function normalizeSpeaker(speaker) {
8389
+ return {
8390
+ ...speaker,
8391
+ id: speaker.id != null ? String(speaker.id) : speaker.id
8392
+ };
8393
+ }
8213
8394
  function toFiniteNumber(value) {
8214
8395
  if (value == null) return void 0;
8215
8396
  if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
@@ -8334,9 +8515,10 @@ function getTranscriptTool(proxy) {
8334
8515
  sentences: transcript.sentences ? transcript.sentences.map(normalizeSentence) : void 0,
8335
8516
  summary: transcript.summary ? {
8336
8517
  ...transcript.summary,
8337
- action_items: transcript.summary.action_items != null ? normalizeActionItems$1(transcript.summary.action_items) : transcript.summary.action_items
8518
+ action_items: transcript.summary.action_items != null ? normalizeActionItems$1(transcript.summary.action_items) : transcript.summary.action_items,
8519
+ keywords: transcript.summary.keywords != null ? normalizeKeywords(transcript.summary.keywords) : transcript.summary.keywords
8338
8520
  } : void 0,
8339
- speakers: transcript.speakers ?? void 0,
8521
+ speakers: transcript.speakers ? transcript.speakers.map(normalizeSpeaker) : void 0,
8340
8522
  meeting_info: transcript.meeting_info ?? void 0,
8341
8523
  meeting_attendees: transcript.meeting_attendees ?? void 0,
8342
8524
  analytics: transcript.analytics ?? void 0
@@ -85885,7 +86067,8 @@ function tools(options = {}) {
85885
86067
  return refreshScope(state, acquireScope(state, staticResourceId));
85886
86068
  },
85887
86069
  disconnect: () => disconnectState(state),
85888
- with: (extra) => withExtraTools(resolver, extra)
86070
+ with: (extra) => withExtraTools(resolver, extra),
86071
+ codeMode: (codeModeOptions) => connectCodeMode(resolve, codeModeOptions)
85889
86072
  }));
85890
86073
  return resolver;
85891
86074
  }
@@ -85974,7 +86157,8 @@ function dynamicTools(getOptions) {
85974
86157
  })();
85975
86158
  return closing;
85976
86159
  },
85977
- with: (extra) => withExtraTools(resolver, extra)
86160
+ with: (extra) => withExtraTools(resolver, extra),
86161
+ codeMode: (codeModeOptions) => connectCodeMode(resolve, codeModeOptions)
85978
86162
  }));
85979
86163
  return resolver;
85980
86164
  }
@@ -86034,7 +86218,8 @@ function withExtraTools(base, extra) {
86034
86218
  };
86035
86219
  },
86036
86220
  disconnect: () => base.disconnect(),
86037
- with: (more) => withExtraTools(resolver, more)
86221
+ with: (more) => withExtraTools(resolver, more),
86222
+ codeMode: (codeModeOptions) => connectCodeMode(resolve, codeModeOptions)
86038
86223
  }));
86039
86224
  return resolver;
86040
86225
  }