@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.
@@ -674,26 +674,6 @@ var Type;
674
674
  */
675
675
  Type["NULL"] = "NULL";
676
676
  })(Type || (Type = {}));
677
- /** The environment being operated. */
678
- var Environment;
679
- (function (Environment) {
680
- /**
681
- * Defaults to browser.
682
- */
683
- Environment["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
684
- /**
685
- * Operates in a web browser.
686
- */
687
- Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
688
- /**
689
- * Operates in a mobile environment.
690
- */
691
- Environment["ENVIRONMENT_MOBILE"] = "ENVIRONMENT_MOBILE";
692
- /**
693
- * Operates in a desktop environment.
694
- */
695
- Environment["ENVIRONMENT_DESKTOP"] = "ENVIRONMENT_DESKTOP";
696
- })(Environment || (Environment = {}));
697
677
  /** Type of auth scheme. This enum is not supported in Gemini API. */
698
678
  var AuthType;
699
679
  (function (AuthType) {
@@ -764,6 +744,62 @@ var ApiSpec;
764
744
  */
765
745
  ApiSpec["ELASTIC_SEARCH"] = "ELASTIC_SEARCH";
766
746
  })(ApiSpec || (ApiSpec = {}));
747
+ /** The environment being operated. */
748
+ var Environment;
749
+ (function (Environment) {
750
+ /**
751
+ * Defaults to browser.
752
+ */
753
+ Environment["ENVIRONMENT_UNSPECIFIED"] = "ENVIRONMENT_UNSPECIFIED";
754
+ /**
755
+ * Operates in a web browser.
756
+ */
757
+ Environment["ENVIRONMENT_BROWSER"] = "ENVIRONMENT_BROWSER";
758
+ /**
759
+ * Operates in a mobile environment.
760
+ */
761
+ Environment["ENVIRONMENT_MOBILE"] = "ENVIRONMENT_MOBILE";
762
+ /**
763
+ * Operates in a desktop environment.
764
+ */
765
+ Environment["ENVIRONMENT_DESKTOP"] = "ENVIRONMENT_DESKTOP";
766
+ })(Environment || (Environment = {}));
767
+ /** SafetyPolicy */
768
+ var SafetyPolicy;
769
+ (function (SafetyPolicy) {
770
+ /**
771
+ * Unspecified safety policy.
772
+ */
773
+ SafetyPolicy["SAFETY_POLICY_UNSPECIFIED"] = "SAFETY_POLICY_UNSPECIFIED";
774
+ /**
775
+ * Safety policy for financial transactions.
776
+ */
777
+ SafetyPolicy["FINANCIAL_TRANSACTIONS"] = "FINANCIAL_TRANSACTIONS";
778
+ /**
779
+ * Safety policy for sensitive data modification.
780
+ */
781
+ SafetyPolicy["SENSITIVE_DATA_MODIFICATION"] = "SENSITIVE_DATA_MODIFICATION";
782
+ /**
783
+ * Safety policy for communication tools (e.g. Gmail, Chat, Meet).
784
+ */
785
+ SafetyPolicy["COMMUNICATION_TOOL"] = "COMMUNICATION_TOOL";
786
+ /**
787
+ * Safety policy for account creation.
788
+ */
789
+ SafetyPolicy["ACCOUNT_CREATION"] = "ACCOUNT_CREATION";
790
+ /**
791
+ * Safety policy for data modification.
792
+ */
793
+ SafetyPolicy["DATA_MODIFICATION"] = "DATA_MODIFICATION";
794
+ /**
795
+ * Safety policy for user consent management.
796
+ */
797
+ SafetyPolicy["USER_CONSENT_MANAGEMENT"] = "USER_CONSENT_MANAGEMENT";
798
+ /**
799
+ * Safety policy for legal terms and agreements.
800
+ */
801
+ SafetyPolicy["LEGAL_TERMS_AND_AGREEMENTS"] = "LEGAL_TERMS_AND_AGREEMENTS";
802
+ })(SafetyPolicy || (SafetyPolicy = {}));
767
803
  /** Sites with confidence level chosen & above this value will be blocked from the search results. This enum is not supported in Gemini API. */
768
804
  var PhishBlockThreshold;
769
805
  (function (PhishBlockThreshold) {
@@ -5943,6 +5979,29 @@ function codeExecutionResultToVertex$3(fromObject) {
5943
5979
  }
5944
5980
  return toObject;
5945
5981
  }
5982
+ function computerUseToVertex$2(fromObject) {
5983
+ const toObject = {};
5984
+ const fromEnvironment = getValueByPath(fromObject, ['environment']);
5985
+ if (fromEnvironment != null) {
5986
+ setValueByPath(toObject, ['environment'], fromEnvironment);
5987
+ }
5988
+ const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
5989
+ 'excludedPredefinedFunctions',
5990
+ ]);
5991
+ if (fromExcludedPredefinedFunctions != null) {
5992
+ setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
5993
+ }
5994
+ const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
5995
+ 'enablePromptInjectionDetection',
5996
+ ]);
5997
+ if (fromEnablePromptInjectionDetection != null) {
5998
+ setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
5999
+ }
6000
+ if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
6001
+ throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
6002
+ }
6003
+ return toObject;
6004
+ }
5946
6005
  function contentToMldev$3(fromObject) {
5947
6006
  const toObject = {};
5948
6007
  const fromParts = getValueByPath(fromObject, ['parts']);
@@ -6618,7 +6677,7 @@ function toolToVertex$2(fromObject) {
6618
6677
  }
6619
6678
  const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
6620
6679
  if (fromComputerUse != null) {
6621
- setValueByPath(toObject, ['computerUse'], fromComputerUse);
6680
+ setValueByPath(toObject, ['computerUse'], computerUseToVertex$2(fromComputerUse));
6622
6681
  }
6623
6682
  if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
6624
6683
  throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
@@ -7685,7 +7744,7 @@ class Files extends BaseModule {
7685
7744
  * file extension.
7686
7745
  * - For Blob object inputs, the `mimeType` will be set to the Blob's `type`
7687
7746
  * property.
7688
- * Somex eamples for file extension to mimeType mapping:
7747
+ * Some examples for file extension to mimeType mapping:
7689
7748
  * .txt -> text/plain
7690
7749
  * .json -> application/json
7691
7750
  * .jpg -> image/jpeg
@@ -8048,6 +8107,29 @@ function codeExecutionResultToVertex$2(fromObject) {
8048
8107
  }
8049
8108
  return toObject;
8050
8109
  }
8110
+ function computerUseToVertex$1(fromObject) {
8111
+ const toObject = {};
8112
+ const fromEnvironment = getValueByPath(fromObject, ['environment']);
8113
+ if (fromEnvironment != null) {
8114
+ setValueByPath(toObject, ['environment'], fromEnvironment);
8115
+ }
8116
+ const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
8117
+ 'excludedPredefinedFunctions',
8118
+ ]);
8119
+ if (fromExcludedPredefinedFunctions != null) {
8120
+ setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
8121
+ }
8122
+ const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
8123
+ 'enablePromptInjectionDetection',
8124
+ ]);
8125
+ if (fromEnablePromptInjectionDetection != null) {
8126
+ setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
8127
+ }
8128
+ if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
8129
+ throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
8130
+ }
8131
+ return toObject;
8132
+ }
8051
8133
  function contentToMldev$2(fromObject) {
8052
8134
  const toObject = {};
8053
8135
  const fromParts = getValueByPath(fromObject, ['parts']);
@@ -9006,7 +9088,7 @@ function toolToVertex$1(fromObject) {
9006
9088
  }
9007
9089
  const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
9008
9090
  if (fromComputerUse != null) {
9009
- setValueByPath(toObject, ['computerUse'], fromComputerUse);
9091
+ setValueByPath(toObject, ['computerUse'], computerUseToVertex$1(fromComputerUse));
9010
9092
  }
9011
9093
  if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
9012
9094
  throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
@@ -9350,6 +9432,29 @@ function computeTokensResponseFromVertex(fromObject, _rootObject) {
9350
9432
  }
9351
9433
  return toObject;
9352
9434
  }
9435
+ function computerUseToVertex(fromObject, _rootObject) {
9436
+ const toObject = {};
9437
+ const fromEnvironment = getValueByPath(fromObject, ['environment']);
9438
+ if (fromEnvironment != null) {
9439
+ setValueByPath(toObject, ['environment'], fromEnvironment);
9440
+ }
9441
+ const fromExcludedPredefinedFunctions = getValueByPath(fromObject, [
9442
+ 'excludedPredefinedFunctions',
9443
+ ]);
9444
+ if (fromExcludedPredefinedFunctions != null) {
9445
+ setValueByPath(toObject, ['excludedPredefinedFunctions'], fromExcludedPredefinedFunctions);
9446
+ }
9447
+ const fromEnablePromptInjectionDetection = getValueByPath(fromObject, [
9448
+ 'enablePromptInjectionDetection',
9449
+ ]);
9450
+ if (fromEnablePromptInjectionDetection != null) {
9451
+ setValueByPath(toObject, ['enablePromptInjectionDetection'], fromEnablePromptInjectionDetection);
9452
+ }
9453
+ if (getValueByPath(fromObject, ['disabledSafetyPolicies']) !== undefined) {
9454
+ throw new Error('disabledSafetyPolicies parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
9455
+ }
9456
+ return toObject;
9457
+ }
9353
9458
  function contentEmbeddingFromVertex(fromObject, rootObject) {
9354
9459
  const toObject = {};
9355
9460
  const fromValues = getValueByPath(fromObject, ['values']);
@@ -12428,7 +12533,7 @@ function toolToVertex(fromObject, rootObject) {
12428
12533
  }
12429
12534
  const fromComputerUse = getValueByPath(fromObject, ['computerUse']);
12430
12535
  if (fromComputerUse != null) {
12431
- setValueByPath(toObject, ['computerUse'], fromComputerUse);
12536
+ setValueByPath(toObject, ['computerUse'], computerUseToVertex(fromComputerUse));
12432
12537
  }
12433
12538
  if (getValueByPath(fromObject, ['fileSearch']) !== undefined) {
12434
12539
  throw new Error('fileSearch parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
@@ -13052,7 +13157,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
13052
13157
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
13053
13158
  const USER_AGENT_HEADER = 'User-Agent';
13054
13159
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
13055
- const SDK_VERSION = '2.9.0'; // x-release-please-version
13160
+ const SDK_VERSION = '2.10.0'; // x-release-please-version
13056
13161
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
13057
13162
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
13058
13163
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -14766,7 +14871,7 @@ class Models extends BaseModule {
14766
14871
  this.generateContent = async (params) => {
14767
14872
  var _a, _b, _c, _d, _e;
14768
14873
  const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
14769
- this.maybeMoveToResponseJsonSchem(params);
14874
+ this.maybeMoveToResponseJsonSchema(params);
14770
14875
  if (!hasCallableTools(params) || shouldDisableAfc(params.config)) {
14771
14876
  return await this.generateContentInternal(transformedParams);
14772
14877
  }
@@ -14858,7 +14963,7 @@ class Models extends BaseModule {
14858
14963
  */
14859
14964
  this.generateContentStream = async (params) => {
14860
14965
  var _a, _b, _c, _d, _e;
14861
- this.maybeMoveToResponseJsonSchem(params);
14966
+ this.maybeMoveToResponseJsonSchema(params);
14862
14967
  if (shouldDisableAfc(params.config)) {
14863
14968
  const transformedParams = await this.processParamsMaybeAddMcpUsage(params);
14864
14969
  return await this.generateContentStreamInternal(transformedParams);
@@ -15083,7 +15188,7 @@ class Models extends BaseModule {
15083
15188
  * To maintain backward compatibility, we move the data that was treated as
15084
15189
  * JSON schema from the responseSchema field to the responseJsonSchema field.
15085
15190
  */
15086
- maybeMoveToResponseJsonSchem(params) {
15191
+ maybeMoveToResponseJsonSchema(params) {
15087
15192
  if (params.config && params.config.responseSchema) {
15088
15193
  if (!params.config.responseJsonSchema) {
15089
15194
  if (Object.keys(params.config.responseSchema).includes('$schema')) {
@@ -15185,7 +15290,7 @@ class Models extends BaseModule {
15185
15290
  throw new Error('Function call name was not returned by the model.');
15186
15291
  }
15187
15292
  if (!afcTools.has(part.functionCall.name)) {
15188
- 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}`);
15293
+ 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}`);
15189
15294
  }
15190
15295
  else {
15191
15296
  const responseParts = yield __await(afcTools
@@ -24176,5 +24281,5 @@ class GoogleGenAI {
24176
24281
  }
24177
24282
  }
24178
24283
 
24179
- 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 };
24284
+ 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 };
24180
24285
  //# sourceMappingURL=index.mjs.map