Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
078f0f1
feat: add for toolbox-adk protocol
twishabansal Oct 24, 2025
bd08c46
fix package deps
twishabansal Oct 24, 2025
301c0d0
fix config
twishabansal Oct 24, 2025
3e31029
lint
twishabansal Oct 24, 2025
2350ece
ci: add linter workflow for toolbox-adk
twishabansal Oct 24, 2025
45e6dd8
Merge branch 'twishabansal-patch-3' into adk-protocol
twishabansal Oct 24, 2025
f8cf048
Rename lint-toolbox-adk to lint-toolbox-adk.yaml
twishabansal Oct 24, 2025
a1548bb
Rename lint-toolbox-adk to lint-toolbox-adk.yaml
twishabansal Oct 24, 2025
4c65205
Merge branch 'twishabansal-patch-3' into adk-protocol
twishabansal Oct 24, 2025
69f5174
Update test.protocol.ts
twishabansal Oct 24, 2025
97b873f
basic monorepo setup
twishabansal Oct 29, 2025
1714120
fix lint workflow
twishabansal Oct 29, 2025
1603b52
fix integration test workflow
twishabansal Oct 29, 2025
a63c833
ignore header checker for lock file
twishabansal Oct 29, 2025
e7cfcab
add lock file
twishabansal Oct 29, 2025
62900c5
fix adk files
twishabansal Oct 29, 2025
0139bb2
fix package file
twishabansal Oct 29, 2025
c6d2f6a
fix file
twishabansal Oct 29, 2025
24b6af1
add empty index file
twishabansal Oct 29, 2025
2cfb402
update lock file
twishabansal Oct 29, 2025
d1adf5e
Merge branch 'main' into monorepo-config-final
twishabansal Oct 29, 2025
f9e0cba
fix adk lint
twishabansal Oct 29, 2025
58ce458
Merge branch 'main' into adk-protocol
twishabansal Oct 29, 2025
0cae93f
Merge branch 'monorepo-config-final' into adk-protocol
twishabansal Oct 29, 2025
ae3619c
Update integration.cloudbuild.yaml
twishabansal Oct 29, 2025
fe2d29f
Update package.json
twishabansal Oct 29, 2025
9f9c947
fix package.json
twishabansal Oct 29, 2025
4a9ddcf
update deps
twishabansal Oct 29, 2025
f9a0eba
remove package lock files
twishabansal Oct 29, 2025
4de004b
remove package lock files
twishabansal Oct 29, 2025
7c4284a
Merge branch 'monorepo-config-final' into adk-protocol
twishabansal Oct 29, 2025
b213094
Merge branch 'main' into adk-protocol
twishabansal Oct 30, 2025
a56e145
comment out integration tests
twishabansal Oct 30, 2025
6929a8b
Merge branch 'main' into adk-protocol
twishabansal Oct 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions packages/toolbox-adk/integration.cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

steps:
- id: Install dependencies
name: 'node:${_VERSION}'
entrypoint: /bin/bash
args:
- -c
- corepack enable && pnpm install --frozen-lockfile

- id: Run unit tests
name: 'node:${_VERSION}'
entrypoint: /bin/bash
waitFor: ['Install dependencies']
args:
- '-c'
- corepack enable && pnpm --filter @toolbox-sdk/adk run test:unit

# - id: Run integration tests
# name: 'node:${_VERSION}'
# entrypoint: /bin/bash
# waitFor: ['Install dependencies']
# env:
# - TOOLBOX_URL=$_TOOLBOX_URL
# - TOOLBOX_VERSION=$_TOOLBOX_VERSION
# - GOOGLE_CLOUD_PROJECT=$PROJECT_ID
# - TOOLBOX_MANIFEST_VERSION=$_TOOLBOX_MANIFEST_VERSION
# args:
# - '-c'
# - corepack enable && pnpm --filter @toolbox-sdk/adk run test:e2e

options:
logging: CLOUD_LOGGING_ONLY
substitutions:
_VERSION: '22.16.0'
_TOOLBOX_VERSION: '0.17.0'
_TOOLBOX_MANIFEST_VERSION: '34'
4 changes: 3 additions & 1 deletion packages/toolbox-adk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
"coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.json --coverage"
},
"dependencies": {
"@toolbox-sdk/core": "workspace:*"
"@google/genai": "^1.14.0",
"@toolbox-sdk/core": "workspace:*",
"zod": "^3.24.4"
}
}
102 changes: 102 additions & 0 deletions packages/toolbox-adk/src/toolbox_adk/protocol.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import type {FunctionDeclaration, Schema} from '@google/genai';
import {Type} from '@google/genai';
import {z, ZodObject, ZodRawShape, ZodTypeAny} from 'zod';

/**
* Safely determines the JSON Schema type enum from a Zod type object.
*
* @param zodType The Zod type instance to inspect.
* @returns A value from the `Type` enum.
*/
function getJsonSchemaTypeFromZod(zodType: ZodTypeAny): Type {
// Handle optional and nullable types by recursively unwrapping them
if (zodType instanceof z.ZodOptional || zodType instanceof z.ZodNullable) {
return getJsonSchemaTypeFromZod(zodType.unwrap());
}

// Handle specific base types
if (zodType instanceof z.ZodNull) {
return Type.NULL;
}

if (zodType instanceof z.ZodString || zodType instanceof z.ZodEnum) {
return Type.STRING;
}

if (zodType instanceof z.ZodNumber) {
const isInteger = zodType._def.checks.some(check => check.kind === 'int');
return isInteger ? Type.INTEGER : Type.NUMBER;
}

if (zodType instanceof z.ZodBoolean) {
return Type.BOOLEAN;
}
if (zodType instanceof z.ZodArray) {
return Type.ARRAY;
}
if (zodType instanceof z.ZodObject) {
return Type.OBJECT;
}
// Fallback for unhandled types
return Type.TYPE_UNSPECIFIED;
}

/**
* Converts a ZodObject schema into a FunctionDeclaration for the Google ADK.
*
* @param name The name of the function/tool.
* @param description The description of the function/tool.
* @param zodSchema The Zod schema for the tool's parameters.
* @returns A FunctionDeclaration object for the Google Genai API.
*/
export function ConvertZodToFunctionDeclaration(
name: string,
description: string,
zodSchema: ZodObject<ZodRawShape>,
): FunctionDeclaration {
const properties: Record<string, Schema> = {};
const required: string[] = [];

if (!zodSchema?.shape) {
return {
name,
description,
parameters: {type: Type.OBJECT, properties, required},
};
}

for (const [key, zodType] of Object.entries(zodSchema.shape)) {
properties[key] = {
type: getJsonSchemaTypeFromZod(zodType),
description: zodType.description || '',
};

if (!zodType.isOptional()) {
required.push(key);
}
}

return {
name,
description,
parameters: {
type: Type.OBJECT,
properties,
required,
},
};
}
Loading