Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
c1128d8
cc
twishabansal Sep 8, 2025
625741f
package init
twishabansal Oct 21, 2025
765c70e
remove unwanted files
twishabansal Oct 21, 2025
dbba3de
chore: add more exports
twishabansal Oct 22, 2025
4d790be
try
twishabansal Oct 22, 2025
21cbc22
fix
twishabansal Oct 22, 2025
6dff39b
remove unwanted changes
twishabansal Oct 22, 2025
a66c30b
lint
twishabansal Oct 22, 2025
06491b3
package init
twishabansal Oct 21, 2025
a15d309
fix
twishabansal Oct 22, 2025
2f0a5bc
Merge branch 'adk-setup' into client-proxy
twishabansal Oct 22, 2025
a67be81
Update index.ts
twishabansal Oct 22, 2025
c0dfbb3
Update client.ts
twishabansal Oct 22, 2025
ec6e714
Update tool.ts
twishabansal Oct 22, 2025
9276f29
Update utils.ts
twishabansal Oct 22, 2025
7ee9295
fix
twishabansal Oct 22, 2025
23bb1d5
fix
twishabansal Oct 22, 2025
7cb61f1
fix
twishabansal Oct 22, 2025
3a698f9
Merge branch 'fix-export' into adk-setup
twishabansal Oct 22, 2025
910a8f7
Update index.ts
twishabansal Oct 22, 2025
b973b4b
Update client.ts
twishabansal Oct 22, 2025
4f7099f
Update tool.ts
twishabansal Oct 22, 2025
afcdc01
Update utils.ts
twishabansal Oct 22, 2025
81b0d4f
fix
twishabansal Oct 22, 2025
c1913c6
fix
twishabansal Oct 22, 2025
5a65d3a
Update client.ts
twishabansal Oct 22, 2025
39bdf25
Update tool.ts
twishabansal Oct 22, 2025
236090c
Update utils.ts
twishabansal Oct 22, 2025
a88817a
fix
twishabansal Oct 22, 2025
6f6b3fe
fix
twishabansal Oct 22, 2025
a0b2e44
Merge branch 'adk-setup' into client-proxy
twishabansal Oct 22, 2025
11437a2
fix package files
twishabansal Oct 22, 2025
c2b749f
fix package
twishabansal Oct 22, 2025
e1f5b70
fix license file
twishabansal Oct 22, 2025
f500227
small fix
twishabansal Oct 22, 2025
35c8175
fix
twishabansal Oct 22, 2025
af1bf57
remove not needed files
twishabansal Oct 22, 2025
61be59f
Config files
twishabansal Oct 23, 2025
de9d92f
Merge branch 'main' into adk-setup
twishabansal Oct 23, 2025
9761f5d
add e2e tests
twishabansal Oct 23, 2025
7f6a18b
add e2e test ci
twishabansal Oct 23, 2025
9e1800d
Merge branch 'adk-setup' into client-proxy
twishabansal Oct 23, 2025
86315d9
add e2e test
twishabansal Oct 23, 2025
913ab3f
revert wrong changes
twishabansal Oct 23, 2025
82539bb
fix package.json
twishabansal Oct 23, 2025
296708c
fix tests
twishabansal Oct 23, 2025
e3318db
config fixes
twishabansal Oct 23, 2025
dd94073
test with code in main
twishabansal Oct 23, 2025
5091440
fix trigger config
twishabansal Oct 23, 2025
e44107a
fix
twishabansal Oct 23, 2025
a66f6b0
fix
twishabansal Oct 23, 2025
cfb4a5d
fix
twishabansal Oct 23, 2025
c5a276c
fix config
twishabansal Oct 23, 2025
1e9fe3e
fix
twishabansal Oct 23, 2025
b97ec4a
revert config changes
twishabansal Oct 23, 2025
1d77342
compile package
twishabansal Oct 23, 2025
274af80
fix path
twishabansal Oct 23, 2025
a88b1ff
package update
twishabansal Oct 23, 2025
1da126f
fix config
twishabansal Oct 23, 2025
dbaa095
fix package
twishabansal Oct 23, 2025
2871f49
fix config
twishabansal Oct 24, 2025
266ca40
add build location
twishabansal Oct 24, 2025
cb755d2
fix warning
twishabansal Oct 24, 2025
fbc0949
fix tsconfig
twishabansal Oct 24, 2025
112810d
fix
twishabansal Oct 24, 2025
57f3739
fix config
twishabansal Oct 24, 2025
cbfa08a
fix
twishabansal Oct 24, 2025
a8d5080
e2e config preset
twishabansal Oct 24, 2025
a505fc1
add type cast
twishabansal Oct 24, 2025
8faffde
fix tests
twishabansal Oct 24, 2025
3127d83
Update jest.e2e.config.json
twishabansal Oct 24, 2025
a452af9
Update tsconfig.json
twishabansal Oct 24, 2025
d7415c2
Update tsconfig.test.json
twishabansal Oct 24, 2025
992d319
Merge branch 'adk-setup' into client-proxy
twishabansal Oct 24, 2025
9a51921
Merge branch 'main' into client-proxy
twishabansal Oct 24, 2025
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
c9b972b
fix
twishabansal Oct 24, 2025
6da96d9
fix tests
twishabansal Oct 24, 2025
89f1d1b
uncomplicate tests
twishabansal Oct 24, 2025
65b635d
uncomplicate
twishabansal Oct 24, 2025
24b1573
fix tests
twishabansal Oct 24, 2025
4cdc41c
cc
twishabansal Oct 24, 2025
2350ece
ci: add linter workflow for toolbox-adk
twishabansal Oct 24, 2025
699d195
fix deps
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
2e647ea
ci: add linter workflow for toolbox-adk
twishabansal Oct 24, 2025
628f2e7
Rename lint-toolbox-adk to lint-toolbox-adk.yaml
twishabansal Oct 24, 2025
7949d1c
Merge branch 'adk-protocol' into adk-tool
twishabansal Oct 24, 2025
fae2f3f
ci: add linter workflow for toolbox-adk
twishabansal Oct 24, 2025
02906f5
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
4a48b69
Merge branch 'adk-protocol' into adk-tool
twishabansal Oct 24, 2025
73264c0
Merge branch 'adk-tool' into adk-client
twishabansal Oct 24, 2025
38c9abc
move axios to deps
twishabansal Oct 24, 2025
9be4cec
Merge branch 'adk-client' into client-proxy
twishabansal Oct 24, 2025
4303b1f
fix deps
twishabansal Oct 24, 2025
69f5174
Update test.protocol.ts
twishabansal Oct 24, 2025
0e4c006
lint
twishabansal Oct 24, 2025
f834523
fix deps
twishabansal Oct 24, 2025
125a4b0
lint config fix
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
efd5266
fix
twishabansal Oct 24, 2025
f943345
fix tests
twishabansal Oct 24, 2025
a6654f5
uncomplicate tests
twishabansal Oct 24, 2025
587294f
uncomplicate
twishabansal Oct 24, 2025
4993456
ci: add linter workflow for toolbox-adk
twishabansal Oct 24, 2025
113ebb7
Rename lint-toolbox-adk to lint-toolbox-adk.yaml
twishabansal Oct 24, 2025
14c8d67
Merge branch 'adk-protocol' into adk-tool
twishabansal Oct 29, 2025
8a2600a
fix deps
twishabansal Oct 29, 2025
015b690
remove lock file
twishabansal Oct 29, 2025
b55f679
Merge branch 'adk-tool' into adk-client
twishabansal Oct 29, 2025
f45279e
Update package.json
twishabansal Oct 29, 2025
2313e5f
Update package.json
twishabansal Oct 29, 2025
fc183ac
remove lock files
twishabansal Oct 29, 2025
d501063
Merge branch 'adk-client' into client-proxy
twishabansal Oct 29, 2025
f8e863a
fix lock file
twishabansal Oct 29, 2025
3ef68e3
updated lock file
twishabansal Oct 29, 2025
6276265
remove extra lock file
twishabansal Oct 29, 2025
b213094
Merge branch 'main' into adk-protocol
twishabansal Oct 30, 2025
a56e145
comment out integration tests
twishabansal Oct 30, 2025
510aa14
Merge branch 'adk-protocol' into adk-tool
twishabansal Oct 30, 2025
6554f3b
Merge branch 'adk-tool' into adk-client
twishabansal Oct 30, 2025
fc79925
update lock file
twishabansal Oct 30, 2025
7a0a2ed
Merge branch 'adk-client' into client-proxy
twishabansal Oct 30, 2025
5727bf0
run integration tests in trigger
twishabansal Oct 30, 2025
6b2d0bc
Merge branch 'main' into client-proxy
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
24 changes: 12 additions & 12 deletions packages/toolbox-adk/integration.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ steps:
- '-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
- 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
Expand Down
7 changes: 2 additions & 5 deletions packages/toolbox-adk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@toolbox-sdk/adk",
"version": "0.0.1",
"version": "0.1.2",
"type": "module",
"description": "JavaScript ADK SDK for interacting with the Toolbox service",
"license": "Apache-2.0",
Expand Down Expand Up @@ -41,7 +41,7 @@
"compile:cjs": "tsc -p tsconfig.cjs.json",
"prepare": "npm run compile",
"test:unit": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.json",
"test:e2e": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.e2e.config.json --runInBand",
"test:e2e": "npx tsc -p tsconfig.test.json && cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.e2e.config.json --runInBand",
"coverage": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.json --coverage"
},
"dependencies": {
Expand All @@ -51,9 +51,6 @@
"@toolbox-sdk/core": "workspace:*",
"axios": "^1.12.2",
"openapi-types": "^12.1.3",
"openapi-types": "^12.1.3",
"@google/genai": "^1.14.0",
"@toolbox-sdk/core": "workspace:*",
"zod": "^3.24.4"
}
}
168 changes: 168 additions & 0 deletions packages/toolbox-adk/test/e2e/jest.globalSetup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
// 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 * as path from 'path';
import fs from 'fs-extra';
import {spawn} from 'child_process';
import {fileURLToPath} from 'url';
import {
getEnvVar,
accessSecretVersion,
createTmpFile,
downloadBlob,
getToolboxBinaryGcsPath,
delay,
} from './utils.js';
import {CustomGlobal} from './types.js';

const TOOLBOX_BINARY_NAME = 'toolbox';
const SERVER_READY_TIMEOUT_MS = 30000; // 30 seconds
const SERVER_READY_POLL_INTERVAL_MS = 2000; // 2 seconds

export default async function globalSetup(): Promise<void> {
console.log('\nJest Global Setup: Starting...');

try {
const projectId = getEnvVar('GOOGLE_CLOUD_PROJECT');
const toolboxVersion = getEnvVar('TOOLBOX_VERSION');
(globalThis as CustomGlobal).__GOOGLE_CLOUD_PROJECT__ = projectId;

// Fetch tools manifest and create temp file
const toolsManifest = await accessSecretVersion(
projectId,
'sdk_testing_tools',
getEnvVar('TOOLBOX_MANIFEST_VERSION'),
);
const toolsFilePath = await createTmpFile(toolsManifest);
(globalThis as CustomGlobal).__TOOLS_FILE_PATH__ = toolsFilePath;
console.log(`Tools manifest stored at: ${toolsFilePath}`);

// Download toolbox binary
const toolboxGcsPath = getToolboxBinaryGcsPath(toolboxVersion);

// Add these two lines to define __dirname
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const localToolboxPath = path.resolve(__dirname, TOOLBOX_BINARY_NAME);

console.log(
`Downloading toolbox binary from gs://genai-toolbox/${toolboxGcsPath} to ${localToolboxPath}...`,
);
await downloadBlob('genai-toolbox', toolboxGcsPath, localToolboxPath);
console.log('Toolbox binary downloaded successfully.');

// Make toolbox executable
await fs.chmod(localToolboxPath, 0o700);

// Start toolbox server
console.log('Starting toolbox server process...');
const serverProcess = spawn(
localToolboxPath,
['--tools-file', toolsFilePath],
{
stdio: ['ignore', 'pipe', 'pipe'], // ignore stdin, pipe stdout/stderr
},
);

(globalThis as CustomGlobal).__TOOLBOX_SERVER_PROCESS__ = serverProcess;

serverProcess.stdout?.on('data', (data: Buffer) => {
console.log(`[ToolboxServer STDOUT]: ${data.toString().trim()}`);
});

serverProcess.stderr?.on('data', (data: Buffer) => {
console.error(`[ToolboxServer STDERR]: ${data.toString().trim()}`);
});

serverProcess.on('error', err => {
console.error('Toolbox server process error:', err);
throw new Error('Failed to start toolbox server process.');
});

serverProcess.on('exit', (code, signal) => {
console.log(
`Toolbox server process exited with code ${code}, signal ${signal}.`,
);
if (
(globalThis as CustomGlobal).__TOOLBOX_SERVER_PROCESS__ &&
!(globalThis as CustomGlobal).__SERVER_TEARDOWN_INITIATED__
) {
console.error('Toolbox server exited prematurely during setup.');
}
});

// Wait for server to start (basic poll check)
let started = false;
const startTime = Date.now();
while (Date.now() - startTime < SERVER_READY_TIMEOUT_MS) {
if (
serverProcess.pid &&
!serverProcess.killed &&
serverProcess.exitCode === null
) {
console.log(
'Toolbox server process appears to be running. Polling for stability...',
);
await delay(SERVER_READY_POLL_INTERVAL_MS * 2);
if (serverProcess.exitCode === null) {
console.log(
'Toolbox server started successfully (process is active).',
);
started = true;
break;
} else {
console.log('Toolbox server process exited after initial start.');
break;
}
}
await delay(SERVER_READY_POLL_INTERVAL_MS);
console.log('Checking if toolbox server is started...');
}

if (!started) {
if (serverProcess && !serverProcess.killed) {
serverProcess.kill('SIGTERM');
}
throw new Error(
`Toolbox server failed to start within ${SERVER_READY_TIMEOUT_MS / 1000} seconds.`,
);
}

console.log('Jest Global Setup: Completed successfully.');
} catch (error) {
console.error('Jest Global Setup Failed:', error);
// Attempt to kill server if it started partially
const serverProcess = (globalThis as CustomGlobal)
.__TOOLBOX_SERVER_PROCESS__;
if (serverProcess && !serverProcess.killed) {
console.log('Attempting to terminate partially started server...');
serverProcess.kill('SIGKILL');
}
// Clean up temp file if created
const toolsFilePath = (globalThis as CustomGlobal).__TOOLS_FILE_PATH__;
if (toolsFilePath) {
try {
await fs.remove(toolsFilePath);
} catch (e) {
console.error(
'Error removing temp tools file during setup failure:',
e,
);
}
}
(globalThis as CustomGlobal).__GOOGLE_CLOUD_PROJECT__ = undefined;
throw error;
}
}
86 changes: 86 additions & 0 deletions packages/toolbox-adk/test/e2e/jest.globalTeardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// 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 * as fs from 'fs-extra';
import {CustomGlobal} from './types.js';

const SERVER_TERMINATE_TIMEOUT_MS = 10000; // 10 seconds

export default async function globalTeardown(): Promise<void> {
console.log('\nJest Global Teardown: Starting...');
(globalThis as CustomGlobal).__SERVER_TEARDOWN_INITIATED__ = true;

const customGlobal = globalThis as CustomGlobal;
const serverProcess = customGlobal.__TOOLBOX_SERVER_PROCESS__;
const toolsFilePath = customGlobal.__TOOLS_FILE_PATH__;

if (serverProcess && !serverProcess.killed) {
console.log('Stopping toolbox server process...');
serverProcess.kill('SIGTERM'); // Graceful termination

// Wait for the process to exit
const stopPromise = new Promise<void>((resolve, reject) => {
const timeout = setTimeout(() => {
if (!serverProcess.killed) {
console.warn(
'Toolbox server did not terminate gracefully, sending SIGKILL.',
);
serverProcess.kill('SIGKILL');
}
// Resolve even if SIGKILL is needed, as we want teardown to finish
resolve();
}, SERVER_TERMINATE_TIMEOUT_MS);

serverProcess.on('exit', (code, signal) => {
clearTimeout(timeout);
console.log(
`Toolbox server process exited with code ${code}, signal ${signal} during teardown.`,
);
resolve();
});
serverProcess.on('error', err => {
// Should not happen if already running
clearTimeout(timeout);
console.error('Error during server process termination:', err);
reject(err);
});
});

try {
await stopPromise;
} catch (error) {
console.error('Error while waiting for server to stop:', error);
if (!serverProcess.killed) serverProcess.kill('SIGKILL'); // Ensure it's killed
}
} else {
console.log('Toolbox server process was not running or already handled.');
}

if (toolsFilePath) {
try {
console.log(`Removing temporary tools file: ${toolsFilePath}`);
await fs.remove(toolsFilePath);
} catch (error) {
console.error(
`Failed to remove temporary tools file ${toolsFilePath}:`,
error,
);
}
}
customGlobal.__TOOLBOX_SERVER_PROCESS__ = undefined;
customGlobal.__TOOLS_FILE_PATH__ = undefined;
customGlobal.__GOOGLE_CLOUD_PROJECT__ = undefined;

console.log('Jest Global Teardown: Completed.');
}
Loading