@firebase/ai 2.3.0-20250917161512 → 2.3.0-canary.0ffcb26af

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.
@@ -853,6 +853,7 @@ export declare interface GenerateContentCandidate {
853
853
  safetyRatings?: SafetyRating[];
854
854
  citationMetadata?: CitationMetadata;
855
855
  groundingMetadata?: GroundingMetadata;
856
+ urlContextMetadata?: URLContextMetadata;
856
857
  }
857
858
 
858
859
  /**
@@ -2854,7 +2855,7 @@ export declare interface ThinkingConfig {
2854
2855
  * Defines a tool that model can call to access external knowledge.
2855
2856
  * @public
2856
2857
  */
2857
- export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
2858
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
2858
2859
 
2859
2860
  /**
2860
2861
  * Tool config. This config is shared for all tools provided in the request.
@@ -2870,6 +2871,115 @@ export declare interface ToolConfig {
2870
2871
  */
2871
2872
  export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
2872
2873
 
2874
+ /**
2875
+ * Specifies the URL Context configuration.
2876
+ *
2877
+ * @beta
2878
+ */
2879
+ export declare interface URLContext {
2880
+ }
2881
+
2882
+ /**
2883
+ * Metadata related to {@link URLContextTool}.
2884
+ *
2885
+ * @beta
2886
+ */
2887
+ export declare interface URLContextMetadata {
2888
+ /**
2889
+ * List of URL metadata used to provide context to the Gemini model.
2890
+ */
2891
+ urlMetadata: URLMetadata[];
2892
+ }
2893
+
2894
+ /**
2895
+ * A tool that allows you to provide additional context to the models in the form of public web
2896
+ * URLs. By including URLs in your request, the Gemini model will access the content from those
2897
+ * pages to inform and enhance its response.
2898
+ *
2899
+ * @beta
2900
+ */
2901
+ export declare interface URLContextTool {
2902
+ /**
2903
+ * Specifies the URL Context configuration.
2904
+ */
2905
+ urlContext: URLContext;
2906
+ }
2907
+
2908
+ /**
2909
+ * Metadata for a single URL retrieved by the {@link URLContextTool} tool.
2910
+ *
2911
+ * @beta
2912
+ */
2913
+ export declare interface URLMetadata {
2914
+ /**
2915
+ * The retrieved URL.
2916
+ */
2917
+ retrievedUrl?: string;
2918
+ /**
2919
+ * The status of the URL retrieval.
2920
+ */
2921
+ urlRetrievalStatus?: URLRetrievalStatus;
2922
+ }
2923
+
2924
+ /**
2925
+ * The status of a URL retrieval.
2926
+ *
2927
+ * @remarks
2928
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
2929
+ * <br/>
2930
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
2931
+ * <br/>
2932
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
2933
+ * <br/>
2934
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
2935
+ * <br/>
2936
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
2937
+ * <br/>
2938
+ *
2939
+ * @beta
2940
+ */
2941
+ export declare const URLRetrievalStatus: {
2942
+ /**
2943
+ * Unspecified retrieval status.
2944
+ */
2945
+ URL_RETRIEVAL_STATUS_UNSPECIFIED: string;
2946
+ /**
2947
+ * The URL retrieval was successful.
2948
+ */
2949
+ URL_RETRIEVAL_STATUS_SUCCESS: string;
2950
+ /**
2951
+ * The URL retrieval failed.
2952
+ */
2953
+ URL_RETRIEVAL_STATUS_ERROR: string;
2954
+ /**
2955
+ * The URL retrieval failed because the content is behind a paywall.
2956
+ */
2957
+ URL_RETRIEVAL_STATUS_PAYWALL: string;
2958
+ /**
2959
+ * The URL retrieval failed because the content is unsafe.
2960
+ */
2961
+ URL_RETRIEVAL_STATUS_UNSAFE: string;
2962
+ };
2963
+
2964
+ /**
2965
+ * The status of a URL retrieval.
2966
+ *
2967
+ * @remarks
2968
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
2969
+ * <br/>
2970
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
2971
+ * <br/>
2972
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
2973
+ * <br/>
2974
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
2975
+ * <br/>
2976
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
2977
+ * <br/>
2978
+ *
2979
+ * @beta
2980
+ */
2981
+ export declare type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
2982
+
2873
2983
  /**
2874
2984
  * Usage metadata about a {@link GenerateContentResponse}.
2875
2985
  *
@@ -2883,8 +2993,16 @@ export declare interface UsageMetadata {
2883
2993
  */
2884
2994
  thoughtsTokenCount?: number;
2885
2995
  totalTokenCount: number;
2996
+ /**
2997
+ * The number of tokens used by tools.
2998
+ */
2999
+ toolUsePromptTokenCount?: number;
2886
3000
  promptTokensDetails?: ModalityTokenCount[];
2887
3001
  candidatesTokensDetails?: ModalityTokenCount[];
3002
+ /**
3003
+ * A list of tokens used by tools, broken down by modality.
3004
+ */
3005
+ toolUsePromptTokensDetails?: ModalityTokenCount[];
2888
3006
  }
2889
3007
 
2890
3008
  /**
package/dist/ai.d.ts CHANGED
@@ -911,6 +911,7 @@ export declare interface GenerateContentCandidate {
911
911
  safetyRatings?: SafetyRating[];
912
912
  citationMetadata?: CitationMetadata;
913
913
  groundingMetadata?: GroundingMetadata;
914
+ urlContextMetadata?: URLContextMetadata;
914
915
  }
915
916
 
916
917
  /**
@@ -1166,6 +1167,7 @@ export declare interface GoogleAIGenerateContentCandidate {
1166
1167
  safetyRatings?: SafetyRating[];
1167
1168
  citationMetadata?: GoogleAICitationMetadata;
1168
1169
  groundingMetadata?: GroundingMetadata;
1170
+ urlContextMetadata?: URLContextMetadata;
1169
1171
  }
1170
1172
 
1171
1173
  /**
@@ -2995,7 +2997,7 @@ export declare interface ThinkingConfig {
2995
2997
  * Defines a tool that model can call to access external knowledge.
2996
2998
  * @public
2997
2999
  */
2998
- export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool;
3000
+ export declare type Tool = FunctionDeclarationsTool | GoogleSearchTool | CodeExecutionTool | URLContextTool;
2999
3001
 
3000
3002
  /**
3001
3003
  * Tool config. This config is shared for all tools provided in the request.
@@ -3011,6 +3013,115 @@ export declare interface ToolConfig {
3011
3013
  */
3012
3014
  export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
3013
3015
 
3016
+ /**
3017
+ * Specifies the URL Context configuration.
3018
+ *
3019
+ * @beta
3020
+ */
3021
+ export declare interface URLContext {
3022
+ }
3023
+
3024
+ /**
3025
+ * Metadata related to {@link URLContextTool}.
3026
+ *
3027
+ * @beta
3028
+ */
3029
+ export declare interface URLContextMetadata {
3030
+ /**
3031
+ * List of URL metadata used to provide context to the Gemini model.
3032
+ */
3033
+ urlMetadata: URLMetadata[];
3034
+ }
3035
+
3036
+ /**
3037
+ * A tool that allows you to provide additional context to the models in the form of public web
3038
+ * URLs. By including URLs in your request, the Gemini model will access the content from those
3039
+ * pages to inform and enhance its response.
3040
+ *
3041
+ * @beta
3042
+ */
3043
+ export declare interface URLContextTool {
3044
+ /**
3045
+ * Specifies the URL Context configuration.
3046
+ */
3047
+ urlContext: URLContext;
3048
+ }
3049
+
3050
+ /**
3051
+ * Metadata for a single URL retrieved by the {@link URLContextTool} tool.
3052
+ *
3053
+ * @beta
3054
+ */
3055
+ export declare interface URLMetadata {
3056
+ /**
3057
+ * The retrieved URL.
3058
+ */
3059
+ retrievedUrl?: string;
3060
+ /**
3061
+ * The status of the URL retrieval.
3062
+ */
3063
+ urlRetrievalStatus?: URLRetrievalStatus;
3064
+ }
3065
+
3066
+ /**
3067
+ * The status of a URL retrieval.
3068
+ *
3069
+ * @remarks
3070
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
3071
+ * <br/>
3072
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
3073
+ * <br/>
3074
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
3075
+ * <br/>
3076
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
3077
+ * <br/>
3078
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
3079
+ * <br/>
3080
+ *
3081
+ * @beta
3082
+ */
3083
+ export declare const URLRetrievalStatus: {
3084
+ /**
3085
+ * Unspecified retrieval status.
3086
+ */
3087
+ URL_RETRIEVAL_STATUS_UNSPECIFIED: string;
3088
+ /**
3089
+ * The URL retrieval was successful.
3090
+ */
3091
+ URL_RETRIEVAL_STATUS_SUCCESS: string;
3092
+ /**
3093
+ * The URL retrieval failed.
3094
+ */
3095
+ URL_RETRIEVAL_STATUS_ERROR: string;
3096
+ /**
3097
+ * The URL retrieval failed because the content is behind a paywall.
3098
+ */
3099
+ URL_RETRIEVAL_STATUS_PAYWALL: string;
3100
+ /**
3101
+ * The URL retrieval failed because the content is unsafe.
3102
+ */
3103
+ URL_RETRIEVAL_STATUS_UNSAFE: string;
3104
+ };
3105
+
3106
+ /**
3107
+ * The status of a URL retrieval.
3108
+ *
3109
+ * @remarks
3110
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
3111
+ * <br/>
3112
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
3113
+ * <br/>
3114
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
3115
+ * <br/>
3116
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
3117
+ * <br/>
3118
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
3119
+ * <br/>
3120
+ *
3121
+ * @beta
3122
+ */
3123
+ export declare type URLRetrievalStatus = (typeof URLRetrievalStatus)[keyof typeof URLRetrievalStatus];
3124
+
3014
3125
  /**
3015
3126
  * Usage metadata about a {@link GenerateContentResponse}.
3016
3127
  *
@@ -3024,8 +3135,16 @@ export declare interface UsageMetadata {
3024
3135
  */
3025
3136
  thoughtsTokenCount?: number;
3026
3137
  totalTokenCount: number;
3138
+ /**
3139
+ * The number of tokens used by tools.
3140
+ */
3141
+ toolUsePromptTokenCount?: number;
3027
3142
  promptTokensDetails?: ModalityTokenCount[];
3028
3143
  candidatesTokensDetails?: ModalityTokenCount[];
3144
+ /**
3145
+ * A list of tokens used by tools, broken down by modality.
3146
+ */
3147
+ toolUsePromptTokensDetails?: ModalityTokenCount[];
3029
3148
  }
3030
3149
 
3031
3150
  /**
@@ -4,7 +4,7 @@ import { FirebaseError, Deferred, getModularInstance } from '@firebase/util';
4
4
  import { Logger } from '@firebase/logger';
5
5
 
6
6
  var name = "@firebase/ai";
7
- var version = "2.3.0-20250917161512";
7
+ var version = "2.3.0-canary.0ffcb26af";
8
8
 
9
9
  /**
10
10
  * @license
@@ -416,6 +416,45 @@ const Language = {
416
416
  * See the License for the specific language governing permissions and
417
417
  * limitations under the License.
418
418
  */
419
+ /**
420
+ * The status of a URL retrieval.
421
+ *
422
+ * @remarks
423
+ * <b>URL_RETRIEVAL_STATUS_UNSPECIFIED:</b> Unspecified retrieval status.
424
+ * <br/>
425
+ * <b>URL_RETRIEVAL_STATUS_SUCCESS:</b> The URL retrieval was successful.
426
+ * <br/>
427
+ * <b>URL_RETRIEVAL_STATUS_ERROR:</b> The URL retrieval failed.
428
+ * <br/>
429
+ * <b>URL_RETRIEVAL_STATUS_PAYWALL:</b> The URL retrieval failed because the content is behind a paywall.
430
+ * <br/>
431
+ * <b>URL_RETRIEVAL_STATUS_UNSAFE:</b> The URL retrieval failed because the content is unsafe.
432
+ * <br/>
433
+ *
434
+ * @beta
435
+ */
436
+ const URLRetrievalStatus = {
437
+ /**
438
+ * Unspecified retrieval status.
439
+ */
440
+ URL_RETRIEVAL_STATUS_UNSPECIFIED: 'URL_RETRIEVAL_STATUS_UNSPECIFIED',
441
+ /**
442
+ * The URL retrieval was successful.
443
+ */
444
+ URL_RETRIEVAL_STATUS_SUCCESS: 'URL_RETRIEVAL_STATUS_SUCCESS',
445
+ /**
446
+ * The URL retrieval failed.
447
+ */
448
+ URL_RETRIEVAL_STATUS_ERROR: 'URL_RETRIEVAL_STATUS_ERROR',
449
+ /**
450
+ * The URL retrieval failed because the content is behind a paywall.
451
+ */
452
+ URL_RETRIEVAL_STATUS_PAYWALL: 'URL_RETRIEVAL_STATUS_PAYWALL',
453
+ /**
454
+ * The URL retrieval failed because the content is unsafe.
455
+ */
456
+ URL_RETRIEVAL_STATUS_UNSAFE: 'URL_RETRIEVAL_STATUS_UNSAFE'
457
+ };
419
458
  /**
420
459
  * The types of responses that can be returned by {@link LiveSession.receive}.
421
460
  *
@@ -1886,7 +1925,8 @@ function mapGenerateContentCandidates(candidates) {
1886
1925
  finishMessage: candidate.finishMessage,
1887
1926
  safetyRatings: mappedSafetyRatings,
1888
1927
  citationMetadata,
1889
- groundingMetadata: candidate.groundingMetadata
1928
+ groundingMetadata: candidate.groundingMetadata,
1929
+ urlContextMetadata: candidate.urlContextMetadata
1890
1930
  };
1891
1931
  mappedCandidates.push(mappedCandidate);
1892
1932
  });
@@ -2056,6 +2096,17 @@ function aggregateResponses(responses) {
2056
2096
  candidate.safetyRatings;
2057
2097
  aggregatedResponse.candidates[i].groundingMetadata =
2058
2098
  candidate.groundingMetadata;
2099
+ // The urlContextMetadata object is defined in the first chunk of the response stream.
2100
+ // In all subsequent chunks, the urlContextMetadata object will be undefined. We need to
2101
+ // make sure that we don't overwrite the first value urlContextMetadata object with undefined.
2102
+ // FIXME: What happens if we receive a second, valid urlContextMetadata object?
2103
+ const urlContextMetadata = candidate.urlContextMetadata;
2104
+ if (typeof urlContextMetadata === 'object' &&
2105
+ urlContextMetadata !== null &&
2106
+ Object.keys(urlContextMetadata).length > 0) {
2107
+ aggregatedResponse.candidates[i].urlContextMetadata =
2108
+ urlContextMetadata;
2109
+ }
2059
2110
  /**
2060
2111
  * Candidates should always have content and parts, but this handles
2061
2112
  * possible malformed responses.
@@ -4035,5 +4086,5 @@ function registerAI() {
4035
4086
  }
4036
4087
  registerAI();
4037
4088
 
4038
- export { AIError, AIErrorCode, AIModel, AnyOfSchema, ArraySchema, Backend, BackendType, BlockReason, BooleanSchema, ChatSession, FinishReason, FunctionCallingMode, GenerativeModel, GoogleAIBackend, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, ImagenAspectRatio, ImagenImageFormat, ImagenModel, ImagenPersonFilterLevel, ImagenSafetyFilterLevel, InferenceMode, IntegerSchema, Language, LiveGenerativeModel, LiveResponseType, LiveSession, Modality, NumberSchema, ObjectSchema, Outcome, POSSIBLE_ROLES, ResponseModality, Schema, SchemaType, StringSchema, VertexAIBackend, getAI, getGenerativeModel, getImagenModel, getLiveGenerativeModel, startAudioConversation };
4089
+ export { AIError, AIErrorCode, AIModel, AnyOfSchema, ArraySchema, Backend, BackendType, BlockReason, BooleanSchema, ChatSession, FinishReason, FunctionCallingMode, GenerativeModel, GoogleAIBackend, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, ImagenAspectRatio, ImagenImageFormat, ImagenModel, ImagenPersonFilterLevel, ImagenSafetyFilterLevel, InferenceMode, IntegerSchema, Language, LiveGenerativeModel, LiveResponseType, LiveSession, Modality, NumberSchema, ObjectSchema, Outcome, POSSIBLE_ROLES, ResponseModality, Schema, SchemaType, StringSchema, URLRetrievalStatus, VertexAIBackend, getAI, getGenerativeModel, getImagenModel, getLiveGenerativeModel, startAudioConversation };
4039
4090
  //# sourceMappingURL=index.esm.js.map