@firebase/ai 2.1.0-canary.84b8bed35 → 2.1.0-canary.984086b0b
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.
- package/dist/ai-public.d.ts +496 -1
- package/dist/ai.d.ts +600 -1
- package/dist/esm/index.esm.js +1176 -321
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/api.d.ts +18 -3
- package/dist/esm/src/constants.d.ts +1 -1
- package/dist/esm/src/index.d.ts +2 -1
- package/dist/esm/src/methods/chrome-adapter.d.ts +7 -3
- package/dist/esm/src/methods/live-session-helpers.d.ts +154 -0
- package/dist/esm/src/methods/live-session.d.ts +90 -0
- package/dist/esm/src/models/index.d.ts +1 -0
- package/dist/esm/src/models/live-generative-model.d.ts +55 -0
- package/dist/esm/src/requests/request.d.ts +6 -0
- package/dist/esm/src/service.d.ts +4 -2
- package/dist/esm/src/types/content.d.ts +17 -0
- package/dist/esm/src/types/enums.d.ts +5 -0
- package/dist/esm/src/types/error.d.ts +2 -0
- package/dist/esm/src/types/imagen/internal.d.ts +10 -0
- package/dist/esm/src/types/live-responses.d.ts +53 -0
- package/dist/esm/src/types/requests.d.ts +96 -0
- package/dist/esm/src/types/responses.d.ts +64 -0
- package/dist/esm/src/websocket.d.ts +67 -0
- package/dist/index.cjs.js +1179 -319
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +830 -265
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +827 -267
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/api.d.ts +18 -3
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/index.d.ts +2 -1
- package/dist/src/methods/chrome-adapter.d.ts +7 -3
- package/dist/src/methods/live-session-helpers.d.ts +154 -0
- package/dist/src/methods/live-session.d.ts +90 -0
- package/dist/src/models/index.d.ts +1 -0
- package/dist/src/models/live-generative-model.d.ts +55 -0
- package/dist/src/requests/request.d.ts +6 -0
- package/dist/src/service.d.ts +4 -2
- package/dist/src/types/content.d.ts +17 -0
- package/dist/src/types/enums.d.ts +5 -0
- package/dist/src/types/error.d.ts +2 -0
- package/dist/src/types/imagen/internal.d.ts +10 -0
- package/dist/src/types/live-responses.d.ts +53 -0
- package/dist/src/types/requests.d.ts +96 -0
- package/dist/src/types/responses.d.ts +64 -0
- package/dist/src/websocket.d.ts +67 -0
- package/package.json +10 -8
|
@@ -397,3 +397,67 @@ export interface CountTokensResponse {
|
|
|
397
397
|
*/
|
|
398
398
|
promptTokensDetails?: ModalityTokenCount[];
|
|
399
399
|
}
|
|
400
|
+
/**
|
|
401
|
+
* An incremental content update from the model.
|
|
402
|
+
*
|
|
403
|
+
* @beta
|
|
404
|
+
*/
|
|
405
|
+
export interface LiveServerContent {
|
|
406
|
+
type: 'serverContent';
|
|
407
|
+
/**
|
|
408
|
+
* The content that the model has generated as part of the current conversation with the user.
|
|
409
|
+
*/
|
|
410
|
+
modelTurn?: Content;
|
|
411
|
+
/**
|
|
412
|
+
* Indicates whether the turn is complete. This is `undefined` if the turn is not complete.
|
|
413
|
+
*/
|
|
414
|
+
turnComplete?: boolean;
|
|
415
|
+
/**
|
|
416
|
+
* Indicates whether the model was interrupted by the client. An interruption occurs when
|
|
417
|
+
* the client sends a message before the model finishes it's turn. This is `undefined` if the
|
|
418
|
+
* model was not interrupted.
|
|
419
|
+
*/
|
|
420
|
+
interrupted?: boolean;
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* A request from the model for the client to execute one or more functions.
|
|
424
|
+
*
|
|
425
|
+
* @beta
|
|
426
|
+
*/
|
|
427
|
+
export interface LiveServerToolCall {
|
|
428
|
+
type: 'toolCall';
|
|
429
|
+
/**
|
|
430
|
+
* An array of function calls to run.
|
|
431
|
+
*/
|
|
432
|
+
functionCalls: FunctionCall[];
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Notification to cancel a previous function call triggered by {@link LiveServerToolCall}.
|
|
436
|
+
*
|
|
437
|
+
* @beta
|
|
438
|
+
*/
|
|
439
|
+
export interface LiveServerToolCallCancellation {
|
|
440
|
+
type: 'toolCallCancellation';
|
|
441
|
+
/**
|
|
442
|
+
* IDs of function calls that were cancelled. These refer to the `id` property of a {@link FunctionCall}.
|
|
443
|
+
*/
|
|
444
|
+
functionIds: string[];
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* The types of responses that can be returned by {@link LiveSession.receive}.
|
|
448
|
+
*
|
|
449
|
+
* @beta
|
|
450
|
+
*/
|
|
451
|
+
export declare const LiveResponseType: {
|
|
452
|
+
SERVER_CONTENT: string;
|
|
453
|
+
TOOL_CALL: string;
|
|
454
|
+
TOOL_CALL_CANCELLATION: string;
|
|
455
|
+
};
|
|
456
|
+
/**
|
|
457
|
+
* The types of responses that can be returned by {@link LiveSession.receive}.
|
|
458
|
+
* This is a property on all messages that can be used for type narrowing. This property is not
|
|
459
|
+
* returned by the server, it is assigned to a server message object once it's parsed.
|
|
460
|
+
*
|
|
461
|
+
* @beta
|
|
462
|
+
*/
|
|
463
|
+
export type LiveResponseType = (typeof LiveResponseType)[keyof typeof LiveResponseType];
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* A standardized interface for interacting with a WebSocket connection.
|
|
19
|
+
* This abstraction allows the SDK to use the appropriate WebSocket implementation
|
|
20
|
+
* for the current JS environment (Browser vs. Node) without
|
|
21
|
+
* changing the core logic of the `LiveSession`.
|
|
22
|
+
* @internal
|
|
23
|
+
*/
|
|
24
|
+
export interface WebSocketHandler {
|
|
25
|
+
/**
|
|
26
|
+
* Establishes a connection to the given URL.
|
|
27
|
+
*
|
|
28
|
+
* @param url The WebSocket URL (e.g., wss://...).
|
|
29
|
+
* @returns A promise that resolves on successful connection or rejects on failure.
|
|
30
|
+
*/
|
|
31
|
+
connect(url: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Sends data over the WebSocket.
|
|
34
|
+
*
|
|
35
|
+
* @param data The string or binary data to send.
|
|
36
|
+
*/
|
|
37
|
+
send(data: string | ArrayBuffer): void;
|
|
38
|
+
/**
|
|
39
|
+
* Returns an async generator that yields parsed JSON objects from the server.
|
|
40
|
+
* The yielded type is `unknown` because the handler cannot guarantee the shape of the data.
|
|
41
|
+
* The consumer is responsible for type validation.
|
|
42
|
+
* The generator terminates when the connection is closed.
|
|
43
|
+
*
|
|
44
|
+
* @returns A generator that allows consumers to pull messages using a `for await...of` loop.
|
|
45
|
+
*/
|
|
46
|
+
listen(): AsyncGenerator<unknown>;
|
|
47
|
+
/**
|
|
48
|
+
* Closes the WebSocket connection.
|
|
49
|
+
*
|
|
50
|
+
* @param code - A numeric status code explaining why the connection is closing.
|
|
51
|
+
* @param reason - A human-readable string explaining why the connection is closing.
|
|
52
|
+
*/
|
|
53
|
+
close(code?: number, reason?: string): Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A wrapper for the native `WebSocket` available in both Browsers and Node >= 22.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export declare class WebSocketHandlerImpl implements WebSocketHandler {
|
|
61
|
+
private ws?;
|
|
62
|
+
constructor();
|
|
63
|
+
connect(url: string): Promise<void>;
|
|
64
|
+
send(data: string | ArrayBuffer): void;
|
|
65
|
+
listen(): AsyncGenerator<unknown>;
|
|
66
|
+
close(code?: number, reason?: string): Promise<void>;
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firebase/ai",
|
|
3
|
-
"version": "2.1.0-canary.
|
|
3
|
+
"version": "2.1.0-canary.984086b0b",
|
|
4
4
|
"description": "The Firebase AI SDK",
|
|
5
5
|
"author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
|
|
6
6
|
"engines": {
|
|
@@ -39,25 +39,27 @@
|
|
|
39
39
|
"test:ci": "yarn testsetup && node ../../scripts/run_tests_in_ci.js -s test",
|
|
40
40
|
"test:skip-clone": "karma start",
|
|
41
41
|
"test:browser": "yarn testsetup && karma start",
|
|
42
|
+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha --require ts-node/register --require src/index.node.ts 'src/**/!(*-browser)*.test.ts' --config ../../config/mocharc.node.js",
|
|
42
43
|
"test:integration": "karma start --integration",
|
|
44
|
+
"test:integration:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' mocha integration/**/*.test.ts --config ../../config/mocharc.node.js",
|
|
43
45
|
"api-report": "api-extractor run --local --verbose",
|
|
44
46
|
"typings:public": "node ../../scripts/build/use_typings.js ./dist/ai-public.d.ts",
|
|
45
47
|
"trusted-type-check": "tsec -p tsconfig.json --noEmit"
|
|
46
48
|
},
|
|
47
49
|
"peerDependencies": {
|
|
48
|
-
"@firebase/app": "0.14.1-canary.
|
|
49
|
-
"@firebase/app-types": "0.9.3-canary.
|
|
50
|
+
"@firebase/app": "0.14.1-canary.984086b0b",
|
|
51
|
+
"@firebase/app-types": "0.9.3-canary.984086b0b"
|
|
50
52
|
},
|
|
51
53
|
"dependencies": {
|
|
52
|
-
"@firebase/app-check-interop-types": "0.3.3-canary.
|
|
53
|
-
"@firebase/component": "0.7.0-canary.
|
|
54
|
-
"@firebase/logger": "0.5.0-canary.
|
|
55
|
-
"@firebase/util": "1.13.0-canary.
|
|
54
|
+
"@firebase/app-check-interop-types": "0.3.3-canary.984086b0b",
|
|
55
|
+
"@firebase/component": "0.7.0-canary.984086b0b",
|
|
56
|
+
"@firebase/logger": "0.5.0-canary.984086b0b",
|
|
57
|
+
"@firebase/util": "1.13.0-canary.984086b0b",
|
|
56
58
|
"tslib": "^2.1.0"
|
|
57
59
|
},
|
|
58
60
|
"license": "Apache-2.0",
|
|
59
61
|
"devDependencies": {
|
|
60
|
-
"@firebase/app": "0.14.1-canary.
|
|
62
|
+
"@firebase/app": "0.14.1-canary.984086b0b",
|
|
61
63
|
"@rollup/plugin-json": "6.1.0",
|
|
62
64
|
"rollup": "2.79.2",
|
|
63
65
|
"rollup-plugin-replace": "2.2.0",
|