@toolbox-sdk/adk 0.1.3 → 0.1.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,47 @@
1
+ import { AuthTokenGetters, BoundParams, ClientHeadersConfig } from '@toolbox-sdk/core';
2
+ import { ToolboxTool } from './tool.js';
3
+ import type { AxiosInstance } from 'axios';
4
+ /**
5
+ * An asynchronous client for interacting with a Toolbox service, specifically
6
+ * designed to work with the Google ADK.
7
+ *
8
+ * This client mirrors the interface of the core ToolboxClient but returns
9
+ * ADK-compatible `ToolboxTool` instances that can be used directly in an
10
+ * ADK Agent.
11
+ */
12
+ export declare class ToolboxClient {
13
+ private readonly coreClient;
14
+ /**
15
+ * Initializes the ADK ToolboxClient.
16
+ * @param {string} url - The base URL for the Toolbox service API (e.g., "http://localhost:5000").
17
+ * @param {AxiosInstance} [session] - Optional Axios instance for making HTTP
18
+ * requests. If not provided, a new one will be created.
19
+ * @param {ClientHeadersConfig} [clientHeaders] - Optional initial headers to
20
+ * be included in each request.
21
+ */
22
+ constructor(url: string, session?: AxiosInstance | null, clientHeaders?: ClientHeadersConfig | null);
23
+ /**
24
+ * Asynchronously loads a tool from the server.
25
+ *
26
+ * Retrieves the schema for the specified tool and returns an ADK-compatible
27
+ * `ToolboxTool` adapter instance, ready to be used in an ADK Agent.
28
+ *
29
+ * @param {string} name - The unique name or identifier of the tool to load.
30
+ * @param {AuthTokenGetters | null} [authTokenGetters] - Optional map of auth service names to token getters.
31
+ * @param {BoundParams | null} [boundParams] - Optional parameters to pre-bind to the tool.
32
+ * @returns {Promise<ToolboxTool>} A promise that resolves to an ADK ToolboxTool,
33
+ * ready for execution.
34
+ */
35
+ loadTool(name: string, authTokenGetters?: AuthTokenGetters | null, boundParams?: BoundParams | null): Promise<ToolboxTool>;
36
+ /**
37
+ * Asynchronously fetches a toolset and loads all tools defined within it.
38
+ *
39
+ * @param {string | null} [name] - Name of the toolset to load. If null or undefined, loads the default toolset.
40
+ * @param {AuthTokenGetters | null} [authTokenGetters] - Optional map of auth service names to token getters.
41
+ * @param {BoundParams | null} [boundParams] - Optional parameters to pre-bind to the tools in the toolset.
42
+ * @param {boolean} [strict=false] - If true, throws an error if any provided auth token or bound param is not used by at least one tool.
43
+ * @returns {Promise<Array<ToolboxTool>>} A promise that resolves to a list of
44
+ * ADK ToolboxTool instances, ready for execution.
45
+ */
46
+ loadToolset(name?: string, authTokenGetters?: AuthTokenGetters | null, boundParams?: BoundParams | null, strict?: boolean): Promise<Array<ToolboxTool>>;
47
+ }
@@ -0,0 +1,68 @@
1
+ // Copyright 2025 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { ToolboxClient as CoreToolboxClient, } from '@toolbox-sdk/core';
15
+ import { ToolboxTool } from './tool.js';
16
+ /**
17
+ * An asynchronous client for interacting with a Toolbox service, specifically
18
+ * designed to work with the Google ADK.
19
+ *
20
+ * This client mirrors the interface of the core ToolboxClient but returns
21
+ * ADK-compatible `ToolboxTool` instances that can be used directly in an
22
+ * ADK Agent.
23
+ */
24
+ export class ToolboxClient {
25
+ coreClient;
26
+ /**
27
+ * Initializes the ADK ToolboxClient.
28
+ * @param {string} url - The base URL for the Toolbox service API (e.g., "http://localhost:5000").
29
+ * @param {AxiosInstance} [session] - Optional Axios instance for making HTTP
30
+ * requests. If not provided, a new one will be created.
31
+ * @param {ClientHeadersConfig} [clientHeaders] - Optional initial headers to
32
+ * be included in each request.
33
+ */
34
+ constructor(url, session, clientHeaders) {
35
+ this.coreClient = new CoreToolboxClient(url, session, clientHeaders);
36
+ }
37
+ /**
38
+ * Asynchronously loads a tool from the server.
39
+ *
40
+ * Retrieves the schema for the specified tool and returns an ADK-compatible
41
+ * `ToolboxTool` adapter instance, ready to be used in an ADK Agent.
42
+ *
43
+ * @param {string} name - The unique name or identifier of the tool to load.
44
+ * @param {AuthTokenGetters | null} [authTokenGetters] - Optional map of auth service names to token getters.
45
+ * @param {BoundParams | null} [boundParams] - Optional parameters to pre-bind to the tool.
46
+ * @returns {Promise<ToolboxTool>} A promise that resolves to an ADK ToolboxTool,
47
+ * ready for execution.
48
+ */
49
+ async loadTool(name, authTokenGetters = {}, boundParams = {}) {
50
+ const coreTool = await this.coreClient.loadTool(name, authTokenGetters, boundParams);
51
+ return new ToolboxTool(coreTool);
52
+ }
53
+ /**
54
+ * Asynchronously fetches a toolset and loads all tools defined within it.
55
+ *
56
+ * @param {string | null} [name] - Name of the toolset to load. If null or undefined, loads the default toolset.
57
+ * @param {AuthTokenGetters | null} [authTokenGetters] - Optional map of auth service names to token getters.
58
+ * @param {BoundParams | null} [boundParams] - Optional parameters to pre-bind to the tools in the toolset.
59
+ * @param {boolean} [strict=false] - If true, throws an error if any provided auth token or bound param is not used by at least one tool.
60
+ * @returns {Promise<Array<ToolboxTool>>} A promise that resolves to a list of
61
+ * ADK ToolboxTool instances, ready for execution.
62
+ */
63
+ async loadToolset(name, authTokenGetters = {}, boundParams = {}, strict = false) {
64
+ const coreTools = await this.coreClient.loadToolset(name, authTokenGetters, boundParams, strict);
65
+ return coreTools.map(coreTool => new ToolboxTool(coreTool));
66
+ }
67
+ }
68
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/toolbox_adk/client.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EACL,aAAa,IAAI,iBAAiB,GAInC,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAW,MAAM,WAAW,CAAC;AAGhD;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IACP,UAAU,CAAoB;IAE/C;;;;;;;OAOG;IACH,YACE,GAAW,EACX,OAA8B,EAC9B,aAA0C;QAE1C,IAAI,CAAC,UAAU,GAAG,IAAI,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC;IACvE,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,QAAQ,CACZ,IAAY,EACZ,mBAA4C,EAAE,EAC9C,cAAkC,EAAE;QAEpC,MAAM,QAAQ,GAAa,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CACvD,IAAI,EACJ,gBAAgB,EAChB,WAAW,CACZ,CAAC;QACF,OAAO,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;;;;;;;;OASG;IACH,KAAK,CAAC,WAAW,CACf,IAAa,EACb,mBAA4C,EAAE,EAC9C,cAAkC,EAAE,EACpC,MAAM,GAAG,KAAK;QAEd,MAAM,SAAS,GAAe,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAC7D,IAAI,EACJ,gBAAgB,EAChB,WAAW,EACX,MAAM,CACP,CAAC;QACF,OAAO,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export { ToolboxClient } from './client.js';
2
+ export { ToolboxTool } from './tool.js';
package/build/index.js ADDED
@@ -0,0 +1,18 @@
1
+ // Copyright 2025 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ // This file defines the public API for the @toolbox-sdk/adk package.
15
+ // Export the main factory function and the core tool type
16
+ export { ToolboxClient } from './client.js';
17
+ export { ToolboxTool } from './tool.js';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/toolbox_adk/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,qEAAqE;AAErE,0DAA0D;AAC1D,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { FunctionDeclaration } from '@google/genai';
2
+ import { ZodObject, ZodRawShape } from 'zod';
3
+ /**
4
+ * Converts a ZodObject schema into a FunctionDeclaration for the Google ADK.
5
+ *
6
+ * @param name The name of the function/tool.
7
+ * @param description The description of the function/tool.
8
+ * @param zodSchema The Zod schema for the tool's parameters.
9
+ * @returns A FunctionDeclaration object for the Google Genai API.
10
+ */
11
+ export declare function ConvertZodToFunctionDeclaration(name: string, description: string, zodSchema: ZodObject<ZodRawShape>): FunctionDeclaration;
@@ -0,0 +1,87 @@
1
+ // Copyright 2025 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { Type } from '@google/genai';
15
+ import { z } from 'zod';
16
+ /**
17
+ * Safely determines the JSON Schema type enum from a Zod type object.
18
+ *
19
+ * @param zodType The Zod type instance to inspect.
20
+ * @returns A value from the `Type` enum.
21
+ */
22
+ function getJsonSchemaTypeFromZod(zodType) {
23
+ // Handle optional and nullable types by recursively unwrapping them
24
+ if (zodType instanceof z.ZodOptional || zodType instanceof z.ZodNullable) {
25
+ return getJsonSchemaTypeFromZod(zodType.unwrap());
26
+ }
27
+ // Handle specific base types
28
+ if (zodType instanceof z.ZodNull) {
29
+ return Type.NULL;
30
+ }
31
+ if (zodType instanceof z.ZodString || zodType instanceof z.ZodEnum) {
32
+ return Type.STRING;
33
+ }
34
+ if (zodType instanceof z.ZodNumber) {
35
+ const isInteger = zodType._def.checks.some(check => check.kind === 'int');
36
+ return isInteger ? Type.INTEGER : Type.NUMBER;
37
+ }
38
+ if (zodType instanceof z.ZodBoolean) {
39
+ return Type.BOOLEAN;
40
+ }
41
+ if (zodType instanceof z.ZodArray) {
42
+ return Type.ARRAY;
43
+ }
44
+ if (zodType instanceof z.ZodObject) {
45
+ return Type.OBJECT;
46
+ }
47
+ // Fallback for unhandled types
48
+ return Type.TYPE_UNSPECIFIED;
49
+ }
50
+ /**
51
+ * Converts a ZodObject schema into a FunctionDeclaration for the Google ADK.
52
+ *
53
+ * @param name The name of the function/tool.
54
+ * @param description The description of the function/tool.
55
+ * @param zodSchema The Zod schema for the tool's parameters.
56
+ * @returns A FunctionDeclaration object for the Google Genai API.
57
+ */
58
+ export function ConvertZodToFunctionDeclaration(name, description, zodSchema) {
59
+ const properties = {};
60
+ const required = [];
61
+ if (!zodSchema?.shape) {
62
+ return {
63
+ name,
64
+ description,
65
+ parameters: { type: Type.OBJECT, properties, required },
66
+ };
67
+ }
68
+ for (const [key, zodType] of Object.entries(zodSchema.shape)) {
69
+ properties[key] = {
70
+ type: getJsonSchemaTypeFromZod(zodType),
71
+ description: zodType.description || '',
72
+ };
73
+ if (!zodType.isOptional()) {
74
+ required.push(key);
75
+ }
76
+ }
77
+ return {
78
+ name,
79
+ description,
80
+ parameters: {
81
+ type: Type.OBJECT,
82
+ properties,
83
+ required,
84
+ },
85
+ };
86
+ }
87
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/toolbox_adk/protocol.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EAAC,CAAC,EAAqC,MAAM,KAAK,CAAC;AAE1D;;;;;GAKG;AACH,SAAS,wBAAwB,CAAC,OAAmB;IACnD,oEAAoE;IACpE,IAAI,OAAO,YAAY,CAAC,CAAC,WAAW,IAAI,OAAO,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;QACzE,OAAO,wBAAwB,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,6BAA6B;IAC7B,IAAI,OAAO,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,IAAI,OAAO,YAAY,CAAC,CAAC,SAAS,IAAI,OAAO,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;QACnE,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,IAAI,OAAO,YAA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W,IAAI,EAAE;SACvC,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;YAC1B,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;IAED,OAAO;QACL,IAAI;QACJ,WAAW;QACX,UAAU,EAAE;YACV,IAAI,EAAE,IAAI,CAAC,MAAM;YACjB,UAAU;YACV,QAAQ;SACT;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { BaseTool, RunAsyncToolRequest } from '@google/adk';
2
+ import type { FunctionDeclaration } from '@google/genai';
3
+ import { ToolboxClient, AuthTokenGetter, AuthTokenGetters, BoundParams, BoundValue } from '@toolbox-sdk/core';
4
+ type ResolvedPromiseType<T> = T extends Promise<infer U> ? U : T;
5
+ export type CoreTool = ResolvedPromiseType<ReturnType<typeof ToolboxClient.prototype.loadTool>>;
6
+ /**
7
+ * An adapter class that wraps a `CoreTool` from the `@toolbox-sdk/core`
8
+ * to make it compatible with the `@google/adk` `BaseTool` interface.
9
+ */
10
+ export declare class ToolboxTool extends BaseTool {
11
+ private readonly coreTool;
12
+ /**
13
+ * Creates a new instance of the ADK-compatible tool wrapper.
14
+ * @param coreTool The original callable tool object from `@toolbox-sdk/core`.
15
+ */
16
+ constructor(coreTool: CoreTool);
17
+ /**
18
+ * Runs the tool by delegating the call to the wrapped `coreTool`.
19
+ *
20
+ * @param request The `RunAsyncToolRequest` from the ADK agent.
21
+ * @returns A promise that resolves to the tool's execution result.
22
+ */
23
+ runAsync(request: RunAsyncToolRequest): Promise<unknown>;
24
+ /**
25
+ * Generates the `FunctionDeclaration` (JSON Schema) for this tool
26
+ * by converting the Zod schema from the `coreTool`.
27
+ *
28
+ * @returns A `FunctionDeclaration` for the LLM.
29
+ */
30
+ _getDeclaration(): FunctionDeclaration | undefined;
31
+ /**
32
+ * Creates a new `ToolboxTool` with additional auth token getters.
33
+ *
34
+ * @param newAuthTokenGetters A map of auth sources to token getters.
35
+ * @returns A new `ToolboxTool` instance.
36
+ */
37
+ addAuthTokenGetters(newAuthTokenGetters: AuthTokenGetters): ToolboxTool;
38
+ /**
39
+ * Creates a new `ToolboxTool` with an additional auth token getter.
40
+ *
41
+ * @param authSource The name of the auth source.
42
+ * @param getIdToken The token getter function.
43
+ * @returns A new `ToolboxTool` instance.
44
+ */
45
+ addAuthTokenGetter(authSource: string, getIdToken: AuthTokenGetter): ToolboxTool;
46
+ /**
47
+ * Creates a new `ToolboxTool` with bound parameters.
48
+ *
49
+ * @param paramsToBind A map of parameter names to values or getters.
50
+ * @returns A new `ToolboxTool` instance.
51
+ */
52
+ bindParams(paramsToBind: BoundParams): ToolboxTool;
53
+ /**
54
+ * Creates a new `ToolboxTool` with a single bound parameter.
55
+ *
56
+ * @param paramName The name of the parameter to bind.
57
+ * @param paramValue The value or getter to bind.
58
+ * @returns A new `ToolboxTool` instance.
59
+ */
60
+ bindParam(paramName: string, paramValue: BoundValue): ToolboxTool;
61
+ /**
62
+ * Gets the underlying `CoreTool` object.
63
+ * @returns The wrapped `CoreTool` instance.
64
+ */
65
+ getCoreTool(): CoreTool;
66
+ }
67
+ export {};
package/build/tool.js ADDED
@@ -0,0 +1,103 @@
1
+ // Copyright 2025 Google LLC
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { BaseTool } from '@google/adk';
15
+ import { ConvertZodToFunctionDeclaration } from './protocol.js';
16
+ /**
17
+ * An adapter class that wraps a `CoreTool` from the `@toolbox-sdk/core`
18
+ * to make it compatible with the `@google/adk` `BaseTool` interface.
19
+ */
20
+ export class ToolboxTool extends BaseTool {
21
+ coreTool;
22
+ /**
23
+ * Creates a new instance of the ADK-compatible tool wrapper.
24
+ * @param coreTool The original callable tool object from `@toolbox-sdk/core`.
25
+ */
26
+ constructor(coreTool) {
27
+ super({
28
+ name: coreTool.toolName,
29
+ description: coreTool.description,
30
+ isLongRunning: false,
31
+ });
32
+ this.coreTool = coreTool;
33
+ }
34
+ /**
35
+ * Runs the tool by delegating the call to the wrapped `coreTool`.
36
+ *
37
+ * @param request The `RunAsyncToolRequest` from the ADK agent.
38
+ * @returns A promise that resolves to the tool's execution result.
39
+ */
40
+ async runAsync(request) {
41
+ return this.coreTool(request.args);
42
+ }
43
+ /**
44
+ * Generates the `FunctionDeclaration` (JSON Schema) for this tool
45
+ * by converting the Zod schema from the `coreTool`.
46
+ *
47
+ * @returns A `FunctionDeclaration` for the LLM.
48
+ */
49
+ _getDeclaration() {
50
+ const zodSchema = this.coreTool.params;
51
+ return ConvertZodToFunctionDeclaration(this.name, this.description, zodSchema);
52
+ }
53
+ /**
54
+ * Creates a new `ToolboxTool` with additional auth token getters.
55
+ *
56
+ * @param newAuthTokenGetters A map of auth sources to token getters.
57
+ * @returns A new `ToolboxTool` instance.
58
+ */
59
+ addAuthTokenGetters(newAuthTokenGetters) {
60
+ const newCoreTool = this.coreTool.addAuthTokenGetters(newAuthTokenGetters);
61
+ return new ToolboxTool(newCoreTool);
62
+ }
63
+ /**
64
+ * Creates a new `ToolboxTool` with an additional auth token getter.
65
+ *
66
+ * @param authSource The name of the auth source.
67
+ * @param getIdToken The token getter function.
68
+ * @returns A new `ToolboxTool` instance.
69
+ */
70
+ addAuthTokenGetter(authSource, getIdToken) {
71
+ const newCoreTool = this.coreTool.addAuthTokenGetter(authSource, getIdToken);
72
+ return new ToolboxTool(newCoreTool);
73
+ }
74
+ /**
75
+ * Creates a new `ToolboxTool` with bound parameters.
76
+ *
77
+ * @param paramsToBind A map of parameter names to values or getters.
78
+ * @returns A new `ToolboxTool` instance.
79
+ */
80
+ bindParams(paramsToBind) {
81
+ const newCoreTool = this.coreTool.bindParams(paramsToBind);
82
+ return new ToolboxTool(newCoreTool);
83
+ }
84
+ /**
85
+ * Creates a new `ToolboxTool` with a single bound parameter.
86
+ *
87
+ * @param paramName The name of the parameter to bind.
88
+ * @param paramValue The value or getter to bind.
89
+ * @returns A new `ToolboxTool` instance.
90
+ */
91
+ bindParam(paramName, paramValue) {
92
+ const newCoreTool = this.coreTool.bindParam(paramName, paramValue);
93
+ return new ToolboxTool(newCoreTool);
94
+ }
95
+ /**
96
+ * Gets the underlying `CoreTool` object.
97
+ * @returns The wrapped `CoreTool` instance.
98
+ */
99
+ getCoreTool() {
100
+ return this.coreTool;
101
+ }
102
+ }
103
+ //# sourceMappingURL=tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/toolbox_adk/tool.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,kDAAkD;AAClD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,EAAC,QAAQ,EAAsB,MAAM,aAAa,CAAC;AAU1D,OAAO,EAAC,+BAA+B,EAAC,MAAM,eAAe,CAAC;AAU9D;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,QAAQ;IACtB,QAAQ,CAAW;IAEpC;;;OAGG;IACH,YAAY,QAAkB;QAC5B,KAAK,CAAC;YACJ,IAAI,EAAE,QAAQ,CAAC,QAAQ;YACvB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,aAAa,EAAE,KAAK;SACrB,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,OAA4B;QACzC,OAAO,IAAI,CAAC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
5
  "description": "JavaScript ADK SDK for interacting with the Toolbox service",
6
6
  "license": "Apache-2.0",
@@ -23,13 +23,13 @@
23
23
  }
24
24
  },
25
25
  "files": [
26
- "build"
26
+ "build/"
27
27
  ],
28
28
  "repository": {
29
29
  "type": "git",
30
30
  "url": "git+https://github.com/googleapis/mcp-toolbox-sdk-js.git"
31
31
  },
32
- "homepage": "https://github.com/googleapis/mcp-toolbox-sdk-js/blob/main/packages/toolbox-core",
32
+ "homepage": "https://github.com/googleapis/mcp-toolbox-sdk-js/blob/main/packages/toolbox-adk",
33
33
  "bugs": {
34
34
  "url": "https://github.com/googleapis/mcp-toolbox-sdk-js/issues"
35
35
  },
@@ -44,7 +44,11 @@
44
44
  "compile:cjs": "tsc -p tsconfig.cjs.json",
45
45
  "test:unit": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.json",
46
46
  "test:e2e": "npx tsc -p tsconfig.test.json && cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.e2e.config.json --runInBand",
47
- "coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.json --coverage"
47
+ "coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.json --coverage",
48
+ "clean": "rimraf ./build",
49
+ "build": "npm run clean && npm run compile",
50
+ "//": "Change prepack to invoke turbo from the root context",
51
+ "prepack": "npx turbo run build --filter=@toolbox-sdk/adk"
48
52
  },
49
53
  "dependencies": {
50
54
  "@google/adk": "^0.1.2",