@google/genai 2.9.0 → 2.10.0

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/index.mjs CHANGED
@@ -644,26 +644,6 @@ var Type;
644
644
  */
645
645
  Type["NULL"] = "NULL";
646
646
  })(Type || (Type = {}));
647
- /** The environment being operated. */
648
- var Environment;
649
- (function (Environment) {
650
- /**
651
- * Defaults to browser.
652
- */
653
- Environment["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
654
- /**
655
- * Operates in a web browser.
656
- */
657
- Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
658
- /**
659
- * Operates in a mobile environment.
660
- */
661
- Environment["ENVIRONMENT_MOBILE"] = "ENVIRONMENT_MOBILE";
662
- /**
663
- * Operates in a desktop environment.
664
- */
665
- Environment["ENVIRONMENT_DESKTOP"] = "ENVIRONMENT_DESKTOP";
666
- })(Environment || (Environment = {}));
667
647
  /** Type of auth scheme. This enum is not supported in Gemini API. */
668
648
  var AuthType;
669
649
  (function (AuthType) {
@@ -734,6 +714,62 @@ var ApiSpec;
734
714
  */
735
715
  ApiSpec["ELASTIC_SEARCH"] = "ELASTIC_SEARCH";
736
716
  })(ApiSpec || (ApiSpec = {}));
717
+ /** The environment being operated. */
718
+ var Environment;
719
+ (function (Environment) {
720
+ /**
721
+ * Defaults to browser.
722
+ */
723
+ Environment["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
724
+ /**
725
+ * Operates in a web browser.
726
+ */
727
+ Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
728
+ /**
729
+ * Operates in a mobile environment.
730
+ */
731
+ Environment["ENVIRONMENT_MOBILE"] = "ENVIRONMENT_MOBILE";
732
+ /**
733
+ * Operates in a desktop environment.
734
+ */
735
+ Environment["ENVIRONMENT_DESKTOP"] = "ENVIRONMENT_DESKTOP";
736
+ })(Environment || (Environment = {}));
737
+ /** SafetyPolicy */
738
+ var SafetyPolicy;
739
+ (function (SafetyPolicy) {
740
+ /**
741
+ * Unspecified safety policy.
742
+ */
743
+ SafetyPolicy["SAFETY_POLICY_UNSPECIFIED"] = "SAFETY_POLICY_UNSPECIFIED";
744
+ /**
745
+ * Safety policy for financial transactions.
746
+ */
747
+ SafetyPolicy["FINANCIAL_TRANSACTIONS"] = "FINANCIAL_TRANSACTIONS";
748
+ /**
749
+ * Safety policy for sensitive data modification.
750
+ */
751
+ SafetyPolicy["SENSITIVE_DATA_MODIFICATION"] = "SENSITIVE_DATA_MODIFICATION";
752
+ /**
753
+ * Safety policy for communication tools (e.g. Gmail, Chat, Meet).
754
+ */
755
+ SafetyPolicy["COMMUNICATION_TOOL"] = "COMMUNICATION_TOOL";
756
+ /**
757
+ * Safety policy for account creation.
758
+ */
759
+ SafetyPolicy["ACCOUNT_CREATION"] = "ACCOUNT_CREATION";
760
+ /**
761
+ * Safety policy for data modification.
762
+ */
763
+ SafetyPolicy["DATA_MODIFICATION"] = "DATA_MODIFICATION";
764
+ /**
765
+ * Safety policy for user consent management.
766
+ */
767
+ SafetyPolicy["USER_CONSENT_MANAGEMENT"] = "USER_CONSENT_MANAGEMENT";
768
+ /**
769
+ * Safety policy for legal terms and agreements.
770
+ */
771
+ SafetyPolicy["LEGAL_TERMS_AND_AGREEMENTS"] = "LEGAL_TERMS_AND_AGREEMENTS";
772
+ })(SafetyPolicy || (SafetyPolicy = {}));
737
773
  /** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
738
774
  var PhishBlockThreshold;
739
775
  (function (PhishBlockThreshold) {
@@ -5913,6 +5949,29 @@ function codeExecutionResultToVertex$3(fromObject) {
5913
5949
  }
5914
5950
  return toObject;
5915
5951
  }
5952
+ function computerUseToVertex$2(fromObject) {
5953
+ const toObject = {};
5954
+ const fromEnvironment = getValueByPath(fromObject, ['environment']);
5955
+ if (fromEnvironment != null) {
5956
+ setValueByPath(toObject, ['environment'], fromEnvironment);
5957
+ }
5958
+ const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
5959
+ 'excludedPredefinedFunctions',
5960
+ ]);
5961
+ if (fromExcludedPredefinedFunctions != null) {
5962
+ setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
5963
+ }
5964
+ const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
5965
+ 'enablePromptInjectionDetection',
5966
+ ]);
5967
+ if (fromEnablePromptInjectionDetection != null) {
5968
+ setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
5969
+ }
5970
+ if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
5971
+ throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
5972
+ }
5973
+ return toObject;
5974
+ }
5916
5975
  function contentToMldev$3(fromObject) {
5917
5976
  const toObject = {};
5918
5977
  const fromParts = getValueByPath(fromObject, ['parts']);
@@ -6588,7 +6647,7 @@ function toolToVertex$2(fromObject) {
6588
6647
  }
6589
6648
  const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
6590
6649
  if (fromComputerUse != null) {
6591
- setValueByPath(toObject, ['computerUse'], fromComputerUse);
6650
+ setValueByPath(toObject, ['computerUse'], computerUseToVertex$2(fromComputerUse));
6592
6651
  }
6593
6652
  if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
6594
6653
  throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
@@ -7739,7 +7798,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
7739
7798
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
7740
7799
  const USER_AGENT_HEADER = 'User-Agent';
7741
7800
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
7742
- const SDK_VERSION = '2.9.0'; // x-release-please-version
7801
+ const SDK_VERSION = '2.10.0'; // x-release-please-version
7743
7802
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
7744
7803
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
7745
7804
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -8748,7 +8807,7 @@ class Files extends BaseModule {
8748
8807
  * file extension.
8749
8808
  * - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
8750
8809
  * property.
8751
- * Somex eamples for file extension to mimeType mapping:
8810
+ * Some examples for file extension to mimeType mapping:
8752
8811
  * .txt -> text/plain
8753
8812
  * .json -> application/json
8754
8813
  * .jpg -> image/jpeg
@@ -13995,6 +14054,29 @@ function codeExecutionResultToVertex$2(fromObject) {
13995
14054
  }
13996
14055
  return toObject;
13997
14056
  }
14057
+ function computerUseToVertex$1(fromObject) {
14058
+ const toObject = {};
14059
+ const fromEnvironment = getValueByPath(fromObject, ['environment']);
14060
+ if (fromEnvironment != null) {
14061
+ setValueByPath(toObject, ['environment'], fromEnvironment);
14062
+ }
14063
+ const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
14064
+ 'excludedPredefinedFunctions',
14065
+ ]);
14066
+ if (fromExcludedPredefinedFunctions != null) {
14067
+ setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
14068
+ }
14069
+ const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
14070
+ 'enablePromptInjectionDetection',
14071
+ ]);
14072
+ if (fromEnablePromptInjectionDetection != null) {
14073
+ setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
14074
+ }
14075
+ if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
14076
+ throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
14077
+ }
14078
+ return toObject;
14079
+ }
13998
14080
  function contentToMldev$2(fromObject) {
13999
14081
  const toObject = {};
14000
14082
  const fromParts = getValueByPath(fromObject, ['parts']);
@@ -14953,7 +15035,7 @@ function toolToVertex$1(fromObject) {
14953
15035
  }
14954
15036
  const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
14955
15037
  if (fromComputerUse != null) {
14956
- setValueByPath(toObject, ['computerUse'], fromComputerUse);
15038
+ setValueByPath(toObject, ['computerUse'], computerUseToVertex$1(fromComputerUse));
14957
15039
  }
14958
15040
  if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
14959
15041
  throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
@@ -15297,6 +15379,29 @@ function computeTokensResponseFromVertex(fromObject, _rootObject) {
15297
15379
  }
15298
15380
  return toObject;
15299
15381
  }
15382
+ function computerUseToVertex(fromObject, _rootObject) {
15383
+ const toObject = {};
15384
+ const fromEnvironment = getValueByPath(fromObject, ['environment']);
15385
+ if (fromEnvironment != null) {
15386
+ setValueByPath(toObject, ['environment'], fromEnvironment);
15387
+ }
15388
+ const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
15389
+ 'excludedPredefinedFunctions',
15390
+ ]);
15391
+ if (fromExcludedPredefinedFunctions != null) {
15392
+ setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
15393
+ }
15394
+ const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
15395
+ 'enablePromptInjectionDetection',
15396
+ ]);
15397
+ if (fromEnablePromptInjectionDetection != null) {
15398
+ setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
15399
+ }
15400
+ if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
15401
+ throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
15402
+ }
15403
+ return toObject;
15404
+ }
15300
15405
  function contentEmbeddingFromVertex(fromObject, rootObject) {
15301
15406
  const toObject = {};
15302
15407
  const fromValues = getValueByPath(fromObject, ['values']);
@@ -18375,7 +18480,7 @@ function toolToVertex(fromObject, rootObject) {
18375
18480
  }
18376
18481
  const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
18377
18482
  if (fromComputerUse != null) {
18378
- setValueByPath(toObject, ['computerUse'], fromComputerUse);
18483
+ setValueByPath(toObject, ['computerUse'], computerUseToVertex(fromComputerUse));
18379
18484
  }
18380
18485
  if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
18381
18486
  throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
@@ -19771,7 +19876,7 @@ class Models extends BaseModule {
19771
19876
  this.generateContent = async (params) => {
19772
19877
  var _a, _b, _c, _d, _e;
19773
19878
  const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
19774
- this.maybeMoveToResponseJsonSchem(params);
19879
+ this.maybeMoveToResponseJsonSchema(params);
19775
19880
  if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
19776
19881
  return await this.generateContentInternal(transformedParams);
19777
19882
  }
@@ -19863,7 +19968,7 @@ class Models extends BaseModule {
19863
19968
  */
19864
19969
  this.generateContentStream = async (params) => {
19865
19970
  var _a, _b, _c, _d, _e;
19866
- this.maybeMoveToResponseJsonSchem(params);
19971
+ this.maybeMoveToResponseJsonSchema(params);
19867
19972
  if (shouldDisableAfc(params.config)) {
19868
19973
  const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
19869
19974
  return await this.generateContentStreamInternal(transformedParams);
@@ -20088,7 +20193,7 @@ class Models extends BaseModule {
20088
20193
  * To maintain backward compatibility, we move the data that was treated as
20089
20194
  * JSON schema from the responseSchema field to the responseJsonSchema field.
20090
20195
  */
20091
- maybeMoveToResponseJsonSchem(params) {
20196
+ maybeMoveToResponseJsonSchema(params) {
20092
20197
  if (params.config && params.config.responseSchema) {
20093
20198
  if (!params.config.responseJsonSchema) {
20094
20199
  if (Object.keys(params.config.responseSchema).includes('$schema')) {
@@ -20190,7 +20295,7 @@ class Models extends BaseModule {
20190
20295
  throw new Error('Function call name was not returned by the model.');
20191
20296
  }
20192
20297
  if (!afcTools.has(part.functionCall.name)) {
20193
- throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${afcTools.keys()}, mising tool: ${part.functionCall.name}`);
20298
+ throw new Error(`Automatic function calling was requested, but not all the tools the model used implement the CallableTool interface. Available tools: ${afcTools.keys()}, missing tool: ${part.functionCall.name}`);
20194
20299
  }
20195
20300
  else {
20196
20301
  const responseParts = yield __await(afcTools
@@ -24123,5 +24228,5 @@ class GoogleGenAI {
24123
24228
  }
24124
24229
  }
24125
24230
 
24126
- export { ActivityHandling, AdapterSize, AggregationMetric, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EmbeddingApiType, EndSensitivity, Environment, EvaluateDatasetResponse, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImageResizeMode, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MatchOperation, MediaModality, MediaResolution, Modality, ModelStage, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PairwiseChoice, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, ProminentPeople, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReinforcementTuningAutoraterScorerParsedResponseConversionScorer, ReinforcementTuningParseResponseConfig, ReinforcementTuningThinkingLevel, ReplayResponse, ResourceScope, ResponseParseType, SafetyFilterLevel, Scale, SegmentImageResponse, SegmentMode, ServiceTier, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, ToolResponse, ToolType, TrafficType, TuningJobState, TuningMethod, TuningMode, TuningSpeed, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, ValidateRewardResponse, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VideoOrientation, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
24231
+ export { ActivityHandling, AdapterSize, AggregationMetric, ApiError, ApiSpec, AuthType, Batches, Behavior, BlockedReason, Caches, CancelTuningJobResponse, Chat, Chats, ComputeTokensResponse, ContentReferenceImage, ControlReferenceImage, ControlReferenceType, CountTokensResponse, CreateFileResponse, DeleteCachedContentResponse, DeleteFileResponse, DeleteModelResponse, DocumentState, DynamicRetrievalConfigMode, EditImageResponse, EditMode, EmbedContentResponse, EmbeddingApiType, EndSensitivity, Environment, EvaluateDatasetResponse, FeatureSelectionPreference, FileSource, FileState, Files, FinishReason, FunctionCallingConfigMode, FunctionResponse, FunctionResponseBlob, FunctionResponseFileData, FunctionResponsePart, FunctionResponseScheduling, GenerateContentResponse, GenerateContentResponsePromptFeedback, GenerateContentResponseUsageMetadata, GenerateImagesResponse, GenerateVideosOperation, GenerateVideosResponse, GoogleGenAI, HarmBlockMethod, HarmBlockThreshold, HarmCategory, HarmProbability, HarmSeverity, HttpElementLocation, HttpResponse, ImagePromptLanguage, ImageResizeMode, ImportFileOperation, ImportFileResponse, InlinedEmbedContentResponse, InlinedResponse, JobState, Language, ListBatchJobsResponse, ListCachedContentsResponse, ListDocumentsResponse, ListFileSearchStoresResponse, ListFilesResponse, ListModelsResponse, ListTuningJobsResponse, Live, LiveClientToolResponse, LiveMusicPlaybackControl, LiveMusicServerMessage, LiveSendToolResponseParameters, LiveServerMessage, MaskReferenceImage, MaskReferenceMode, MatchOperation, MediaModality, MediaResolution, Modality, ModelStage, Models, MusicGenerationMode, Operations, Outcome, PagedItem, Pager, PairwiseChoice, PartMediaResolutionLevel, PersonGeneration, PhishBlockThreshold, ProminentPeople, RawReferenceImage, RecontextImageResponse, RegisterFilesResponse, ReinforcementTuningAutoraterScorerParsedResponseConversionScorer, ReinforcementTuningParseResponseConfig, ReinforcementTuningThinkingLevel, ReplayResponse, ResourceScope, ResponseParseType, SafetyFilterLevel, SafetyPolicy, Scale, SegmentImageResponse, SegmentMode, ServiceTier, Session, SingleEmbedContentResponse, StartSensitivity, StyleReferenceImage, SubjectReferenceImage, SubjectReferenceType, ThinkingLevel, Tokens, ToolResponse, ToolType, TrafficType, TuningJobState, TuningMethod, TuningMode, TuningSpeed, TuningTask, TurnCompleteReason, TurnCoverage, Type, UploadToFileSearchStoreOperation, UploadToFileSearchStoreResponse, UploadToFileSearchStoreResumableResponse, UpscaleImageResponse, UrlRetrievalStatus, VadSignalType, ValidateRewardResponse, VideoCompressionQuality, VideoGenerationMaskMode, VideoGenerationReferenceType, VideoOrientation, VoiceActivityType, createFunctionResponsePartFromBase64, createFunctionResponsePartFromUri, createModelContent, createPartFromBase64, createPartFromCodeExecutionResult, createPartFromExecutableCode, createPartFromFunctionCall, createPartFromFunctionResponse, createPartFromText, createPartFromUri, createUserContent, mcpToTool, setDefaultBaseUrls };
24127
24232
  //# sourceMappingURL=index.mjs.map