Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 6 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@
"docs-test": "linkinator docs",
"compile:oss": "tsc -p tsconfig.json.oss",
"fix": "gts fix",
"test": "npm run test:src && npm run test:test",
"test": "npm run test:legacy:src && npm run test:legacy:test",
"test:src": "npm run test:legacy:src",
"test:test": "npm run test:legacy:test",
"test:system": "npm run test:legacy:system && npm run test:genai:system",
"test:legacy:src": "jasmine build/vertexai/src/functions/test/*_test.js build/vertexai/src/models/test/*_test.js --reporter=test/spec/reporter.js",
"test:legacy:test": "jasmine build/vertexai/test/*_test.js --reporter=test/spec/reporter.js",
"test:legacy:system": "jasmine build/vertexai/system_test/*_test.js --reporter=test/spec/reporter.js",
"test:genai:system": "jasmine build/system_test/*_test.js --reporter=test/spec/reporter.js",
"lint": "ESLINT_USE_FLAT_CONFIG=true eslint src/genai --no-ignore --config src/genai/eslint.config.mjs",
"format": "prettier 'src/genai/**/*.ts' 'src/genai/**/*.mjs' --write",
"test": "npm run test:unit",
"test:unit": "jasmine build/test/unit/*_test.js --reporter=test/spec/reporter.js",
"test:system": "jasmine build/system_test/*_test.js --reporter=test/spec/reporter.js",
"test:replays": "jasmine build/test/replays/*_test.js --reporter=test/spec/reporter.js",
"lint": "ESLINT_USE_FLAT_CONFIG=true eslint src --no-ignore --config src/eslint.config.mjs",
"format": "prettier 'src/**/*.ts' 'src/**/*.mjs' --write",
"clean-js-files": "find . -type f -name \"*.js\" -exec rm -f {} +",
"clean-js-map-files": "find . -type f -name \"*.js.map\" -exec rm -f {} +",
"postpack": "if [ \"${CLEAN}\" ]; then npm run clean-after-pack; fi",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 2 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,5 @@
* limitations under the License.
*/

export {VertexAI} from '../vertexai/src/vertex_ai';
export {Client} from './genai/client';

export * from '../vertexai/src/types';
export * from '../vertexai/src/models';
export {Client} from './client';
export * from './types';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion system_test/agent_engine_e2e_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import {Client} from '../src/genai/client';
import {Client} from '../src/client';

const PROJECT = process.env['GCLOUD_PROJECT'];
const LOCATION = 'us-central1';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Pager} from '@google/genai';
import * as fs from 'fs';
import * as path from 'path';

import {Client} from '../../src/genai/client.js';
import {Client} from '../../src/client.js';

/**
* Bypass real credential fetching during replay.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'jasmine';

import {NodeAuth} from '@google/genai/vertex_internal';

import * as types from '../../src/genai/types.js';
import * as types from '../../src/types.js';

import {ReplayClient} from './_replay_client.js';

Expand Down
File renamed without changes.
65 changes: 65 additions & 0 deletions test/replays/run_replay_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

# This script runs replay tests for the Vertex SDK JS GenAI modules.
# It is intended to be used from the google3 directory of a CitC client.
#
# Example:
# ./third_party/javascript/node_modules/vertexai/test/genai/run_replay_tests.sh

START_DIR=$(pwd)

if [[ "$START_DIR" != */google3 ]]; then
echo "Error: This script must be run from your client's '/google3' directory."
echo "Your current directory is: $START_DIR"
exit 1
fi

export GOOGLE_GENAI_REPLAYS_DIRECTORY="$START_DIR/google/cloud/aiplatform/sdk/genai/replays/tests/vertex_sdk_genai_replays/"

if [ ! -d "$GOOGLE_GENAI_REPLAYS_DIRECTORY" ]; then
echo "Error: Replays directory not found at $GOOGLE_GENAI_REPLAYS_DIRECTORY"
exit 1
fi

PARSED_ARGS=$(getopt -o "" -l "mode:" -- "$@")

if [ $? -ne 0 ]; then
echo "Error: Failed to parse command line arguments." >&2
exit 1
fi

eval set -- "$PARSED_ARGS"
MODE_VALUE="replay"

while true; do
case "$1" in
--mode)
MODE_VALUE="$2"
shift 2
;;
--)
shift
break
;;
*)
echo "Internal error: Unrecognized arg option: '$1'" >&2
exit 1
;;
esac
done

if [ "$MODE_VALUE" != "replay" ]; then
echo "Error: The JS SDK currently only supports --mode replay."
exit 1
fi

echo "Running JS GenAI replay tests via blaze..."

blaze test --test_strategy=local \
--test_env=GOOGLE_GENAI_REPLAYS_DIRECTORY="$GOOGLE_GENAI_REPLAYS_DIRECTORY" \
--test_output=errors \
//third_party/javascript/node_modules/vertexai/test:genai_modules_replay_tests

EXIT_CODE=$?
echo "Tests completed with exit code: $EXIT_CODE."
exit $EXIT_CODE
File renamed without changes.
24 changes: 24 additions & 0 deletions test/replays/test_env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

const path = require('path');

module.exports = {
beforeJasmine: () => {
process.env['GOOGLE_CLOUD_PROJECT'] = 'vertex-sdk-dev';
process.env['GOOGLE_CLOUD_LOCATION'] = 'us-central1';

if (process.env['RUNFILES']) {
process.env['GOOGLE_GENAI_REPLAYS_DIRECTORY'] = path.join(
process.env['RUNFILES'],
'google3/google/cloud/aiplatform/sdk/genai/replays/tests/vertex_sdk_genai_replays'
);
}

return Promise.resolve();
},
afterJasmine: (failureReason) => Promise.resolve(failureReason),
};
30 changes: 30 additions & 0 deletions test/unit/client_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {AgentEngines} from '../../src/agentengines';
import {Client} from '../../src/client';

describe('GenAI Client Instantiation', () => {
const options = {
project: 'test-project',
location: 'us-central1',
};

it('should initialize with provided project and location', () => {
const client = new Client(options);
expect(client).toBeDefined();
});

it('should expose agentEnginesInternal as an instance of AgentEngines',
() => {
const client = new Client(options);
// This will log an experimental warning.
expect(client.agentEnginesInternal).toBeDefined();
expect(client.agentEnginesInternal instanceof AgentEngines).toBe(true);
});

it('should correctly initialize AgentEngines submodules', () => {
const client = new Client(options);
const ae = client.agentEnginesInternal;
expect(ae.sessions).toBeDefined();
expect(ae.sandboxes).toBeDefined();
expect(ae.memories).toBeDefined();
});
});
17 changes: 6 additions & 11 deletions vertexai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@
"docs-test": "linkinator docs",
"compile:oss": "tsc -p tsconfig.json.oss",
"fix": "gts fix",
"test": "npm run test:src && npm run test:test",
"test": "npm run test:legacy:src && npm run test:legacy:test",
"test:src": "npm run test:legacy:src",
"test:test": "npm run test:legacy:test",
"test:system": "npm run test:legacy:system && npm run test:genai:system",
"test:legacy:src": "jasmine build/vertexai/src/functions/test/*_test.js build/vertexai/src/models/test/*_test.js --reporter=test/spec/reporter.js",
"test:legacy:test": "jasmine build/vertexai/test/*_test.js --reporter=test/spec/reporter.js",
"test:legacy:system": "jasmine build/vertexai/system_test/*_test.js --reporter=test/spec/reporter.js",
"test:genai:system": "jasmine build/system_test/*_test.js --reporter=test/spec/reporter.js",
"lint": "ESLINT_USE_FLAT_CONFIG=true eslint src/genai --no-ignore --config src/genai/eslint.config.mjs",
"format": "prettier 'src/genai/**/*.ts' 'src/genai/**/*.mjs' --write",
"test": "npm run test:unit",
"test:unit": "jasmine build/test/unit/*_test.js --reporter=test/spec/reporter.js",
"test:system": "jasmine build/system_test/*_test.js --reporter=test/spec/reporter.js",
"test:replays": "jasmine build/test/replays/*_test.js --reporter=test/spec/reporter.js",
"lint": "ESLINT_USE_FLAT_CONFIG=true eslint src --no-ignore --config src/eslint.config.mjs",
"format": "prettier 'src/**/*.ts' 'src/**/*.mjs' --write",
"clean-js-files": "find . -type f -name \"*.js\" -exec rm -f {} +",
"clean-js-map-files": "find . -type f -name \"*.js.map\" -exec rm -f {} +",
"postpack": "if [ \"${CLEAN}\" ]; then npm run clean-after-pack; fi",
Expand Down
Loading