@google/genai 2.2.0 → 2.3.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/README.md CHANGED
@@ -369,7 +369,10 @@ async function main() {
369
369
  main();
370
370
  ```
371
371
 
372
- ## Interactions
372
+ ## Interactions (Experimental)
373
+
374
+ > **Warning:** The Interactions API is in **Beta**. This is a preview of an
375
+ experimental feature. Features and schemas are subject to **breaking changes**.
373
376
 
374
377
  The Interactions API is a unified interface for interacting with Gemini models
375
378
  and agents. It simplifies state management, tool orchestration, and long-running
package/dist/genai.d.ts CHANGED
@@ -700,7 +700,7 @@ declare interface BaseCreateAgentInteractionParams {
700
700
  * Body param: Enforces that the generated response is a JSON object that complies
701
701
  * with the JSON schema specified in this field.
702
702
  */
703
- response_format?: Array<AudioResponseFormat | TextResponseFormat | ImageResponseFormat | VideoResponseFormat | unknown> | AudioResponseFormat | TextResponseFormat | ImageResponseFormat | VideoResponseFormat | unknown;
703
+ response_format?: Array<AudioResponseFormat | TextResponseFormat | ImageResponseFormat | unknown> | AudioResponseFormat | TextResponseFormat | ImageResponseFormat | unknown;
704
704
  /**
705
705
  * Body param: The mime type of the response. This is required if response_format
706
706
  * is set.
@@ -767,7 +767,7 @@ declare interface BaseCreateModelInteractionParams {
767
767
  * Body param: Enforces that the generated response is a JSON object that complies
768
768
  * with the JSON schema specified in this field.
769
769
  */
770
- response_format?: Array<AudioResponseFormat | TextResponseFormat | ImageResponseFormat | VideoResponseFormat | unknown> | AudioResponseFormat | TextResponseFormat | ImageResponseFormat | VideoResponseFormat | unknown;
770
+ response_format?: Array<AudioResponseFormat | TextResponseFormat | ImageResponseFormat | unknown> | AudioResponseFormat | TextResponseFormat | ImageResponseFormat | unknown;
771
771
  /**
772
772
  * Body param: The mime type of the response. This is required if response_format
773
773
  * is set.
@@ -6280,7 +6280,7 @@ declare interface Interaction {
6280
6280
  * Enforces that the generated response is a JSON object that complies with the
6281
6281
  * JSON schema specified in this field.
6282
6282
  */
6283
- response_format?: Array<AudioResponseFormat | TextResponseFormat | ImageResponseFormat | VideoResponseFormat | unknown> | AudioResponseFormat | TextResponseFormat | ImageResponseFormat | VideoResponseFormat | unknown;
6283
+ response_format?: Array<AudioResponseFormat | TextResponseFormat | ImageResponseFormat | unknown> | AudioResponseFormat | TextResponseFormat | ImageResponseFormat | unknown;
6284
6284
  /**
6285
6285
  * The mime type of the response. This is required if response_format is set.
6286
6286
  */
@@ -6314,6 +6314,30 @@ declare interface Interaction {
6314
6314
  * completes.
6315
6315
  */
6316
6316
  webhook_config?: WebhookConfig_2;
6317
+ /**
6318
+ * Concatenated text from the last model output in response to the current request.
6319
+ *
6320
+ * Note: this is added by the SDK.
6321
+ */
6322
+ output_text?: string;
6323
+ /**
6324
+ * The last image generated by the model in response to the current request.
6325
+ *
6326
+ * Note: this is added by the SDK.
6327
+ */
6328
+ output_image?: ImageContent;
6329
+ /**
6330
+ * The last audio generated by the model in response to the current request.
6331
+ *
6332
+ * Note: this is added by the SDK.
6333
+ */
6334
+ output_audio?: AudioContent;
6335
+ /**
6336
+ * The last video generated by the model in response to the current request.
6337
+ *
6338
+ * Note: this is added by the SDK.
6339
+ */
6340
+ output_video?: VideoContent;
6317
6341
  }
6318
6342
 
6319
6343
  declare interface InteractionCancelParams {
@@ -6408,7 +6432,7 @@ export declare class Interactions extends BaseInteractions {
6408
6432
  }
6409
6433
 
6410
6434
  export declare namespace Interactions {
6411
- export { type AllowedTools as AllowedTools, type Annotation as Annotation, type AudioContent as AudioContent, type AudioResponseFormat as AudioResponseFormat, type CodeExecutionCallArguments as CodeExecutionCallArguments, type CodeExecutionCallStep as CodeExecutionCallStep, type CodeExecutionResultStep as CodeExecutionResultStep, type Content_2 as Content, type DeepResearchAgentConfig as DeepResearchAgentConfig, type DocumentContent as DocumentContent, type DynamicAgentConfig as DynamicAgentConfig, type ErrorEvent_2 as ErrorEvent, type FileCitation as FileCitation, type FileSearchCallStep as FileSearchCallStep, type FileSearchResultStep as FileSearchResultStep, type Function_2 as Function, type FunctionCallStep as FunctionCallStep, type FunctionResultStep as FunctionResultStep, type GenerationConfig_2 as GenerationConfig, type GoogleMapsCallArguments as GoogleMapsCallArguments, type GoogleMapsCallStep as GoogleMapsCallStep, type GoogleMapsResult as GoogleMapsResult, type GoogleMapsResultStep as GoogleMapsResultStep, type GoogleSearchCallArguments as GoogleSearchCallArguments, type GoogleSearchCallStep as GoogleSearchCallStep, type GoogleSearchResult as GoogleSearchResult, type GoogleSearchResultStep as GoogleSearchResultStep, type ImageConfig_2 as ImageConfig, type ImageContent as ImageContent, type ImageResponseFormat as ImageResponseFormat, type Interaction as Interaction, type InteractionCompletedEvent as InteractionCompletedEvent, type InteractionCreatedEvent as InteractionCreatedEvent, type InteractionSSEEvent as InteractionSSEEvent, type InteractionStatusUpdate as InteractionStatusUpdate, type MCPServerToolCallStep as MCPServerToolCallStep, type MCPServerToolResultStep as MCPServerToolResultStep, type Model_2 as Model, type ModelOutputStep as ModelOutputStep, type PlaceCitation as PlaceCitation, type SpeechConfig_2 as SpeechConfig, type Step as Step, type StepDelta as StepDelta, type StepStart as StepStart, type StepStop as StepStop, type TextContent as TextContent, type TextResponseFormat as TextResponseFormat, type ThinkingLevel_2 as ThinkingLevel, type ThoughtStep as ThoughtStep, type Tool_2 as Tool, type ToolChoiceConfig as ToolChoiceConfig, type ToolChoiceType as ToolChoiceType, type URLCitation as URLCitation, type URLContextCallArguments as URLContextCallArguments, type URLContextCallStep as URLContextCallStep, type URLContextResult as URLContextResult, type URLContextResultStep as URLContextResultStep, type Usage as Usage, type UserInputStep as UserInputStep, type VideoContent as VideoContent, type VideoResponseFormat as VideoResponseFormat, type WebhookConfig_2 as WebhookConfig, type InteractionDeleteResponse as InteractionDeleteResponse, type InteractionCreateParams as InteractionCreateParams, type CreateModelInteractionParamsNonStreaming as CreateModelInteractionParamsNonStreaming, type CreateModelInteractionParamsStreaming as CreateModelInteractionParamsStreaming, type CreateAgentInteractionParamsNonStreaming as CreateAgentInteractionParamsNonStreaming, type CreateAgentInteractionParamsStreaming as CreateAgentInteractionParamsStreaming, type InteractionDeleteParams as InteractionDeleteParams, type InteractionCancelParams as InteractionCancelParams, type InteractionGetParams as InteractionGetParams, type InteractionGetParamsNonStreaming as InteractionGetParamsNonStreaming, type InteractionGetParamsStreaming as InteractionGetParamsStreaming, };
6435
+ export { type AllowedTools as AllowedTools, type Annotation as Annotation, type AudioContent as AudioContent, type AudioResponseFormat as AudioResponseFormat, type CodeExecutionCallArguments as CodeExecutionCallArguments, type CodeExecutionCallStep as CodeExecutionCallStep, type CodeExecutionResultStep as CodeExecutionResultStep, type Content_2 as Content, type DeepResearchAgentConfig as DeepResearchAgentConfig, type DocumentContent as DocumentContent, type DynamicAgentConfig as DynamicAgentConfig, type ErrorEvent_2 as ErrorEvent, type FileCitation as FileCitation, type FileSearchCallStep as FileSearchCallStep, type FileSearchResultStep as FileSearchResultStep, type Function_2 as Function, type FunctionCallStep as FunctionCallStep, type FunctionResultStep as FunctionResultStep, type GenerationConfig_2 as GenerationConfig, type GoogleMapsCallArguments as GoogleMapsCallArguments, type GoogleMapsCallStep as GoogleMapsCallStep, type GoogleMapsResult as GoogleMapsResult, type GoogleMapsResultStep as GoogleMapsResultStep, type GoogleSearchCallArguments as GoogleSearchCallArguments, type GoogleSearchCallStep as GoogleSearchCallStep, type GoogleSearchResult as GoogleSearchResult, type GoogleSearchResultStep as GoogleSearchResultStep, type ImageConfig_2 as ImageConfig, type ImageContent as ImageContent, type ImageResponseFormat as ImageResponseFormat, type Interaction as Interaction, type InteractionCompletedEvent as InteractionCompletedEvent, type InteractionCreatedEvent as InteractionCreatedEvent, type InteractionSSEEvent as InteractionSSEEvent, type InteractionStatusUpdate as InteractionStatusUpdate, type MCPServerToolCallStep as MCPServerToolCallStep, type MCPServerToolResultStep as MCPServerToolResultStep, type Model_2 as Model, type ModelOutputStep as ModelOutputStep, type PlaceCitation as PlaceCitation, type SpeechConfig_2 as SpeechConfig, type Step as Step, type StepDelta as StepDelta, type StepStart as StepStart, type StepStop as StepStop, type TextContent as TextContent, type TextResponseFormat as TextResponseFormat, type ThinkingLevel_2 as ThinkingLevel, type ThoughtStep as ThoughtStep, type Tool_2 as Tool, type ToolChoiceConfig as ToolChoiceConfig, type ToolChoiceType as ToolChoiceType, type URLCitation as URLCitation, type URLContextCallArguments as URLContextCallArguments, type URLContextCallStep as URLContextCallStep, type URLContextResult as URLContextResult, type URLContextResultStep as URLContextResultStep, type Usage as Usage, type UserInputStep as UserInputStep, type VideoContent as VideoContent, type WebhookConfig_2 as WebhookConfig, type InteractionDeleteResponse as InteractionDeleteResponse, type InteractionCreateParams as InteractionCreateParams, type CreateModelInteractionParamsNonStreaming as CreateModelInteractionParamsNonStreaming, type CreateModelInteractionParamsStreaming as CreateModelInteractionParamsStreaming, type CreateAgentInteractionParamsNonStreaming as CreateAgentInteractionParamsNonStreaming, type CreateAgentInteractionParamsStreaming as CreateAgentInteractionParamsStreaming, type InteractionDeleteParams as InteractionDeleteParams, type InteractionCancelParams as InteractionCancelParams, type InteractionGetParams as InteractionGetParams, type InteractionGetParamsNonStreaming as InteractionGetParamsNonStreaming, type InteractionGetParamsStreaming as InteractionGetParamsStreaming, };
6412
6436
  }
6413
6437
 
6414
6438
  declare namespace InteractionsAPI {
@@ -6475,7 +6499,6 @@ declare namespace InteractionsAPI {
6475
6499
  Usage,
6476
6500
  UserInputStep,
6477
6501
  VideoContent,
6478
- VideoResponseFormat,
6479
6502
  WebhookConfig_2 as WebhookConfig,
6480
6503
  InteractionDeleteResponse,
6481
6504
  InteractionCreateParams,
@@ -7136,6 +7159,8 @@ export declare interface LiveConnectConfig {
7136
7159
  response.
7137
7160
  */
7138
7161
  safetySettings?: SafetySetting[];
7162
+ /** Config for stream translation. */
7163
+ streamTranslationConfig?: StreamTranslationConfig;
7139
7164
  }
7140
7165
 
7141
7166
  /** Config for LiveConnectConstraints for Auth Token creation. */
@@ -10237,6 +10262,17 @@ export declare interface StreamableHttpTransport {
10237
10262
  url?: string;
10238
10263
  }
10239
10264
 
10265
+ /** Config for stream translation. */
10266
+ export declare interface StreamTranslationConfig {
10267
+ /** If true, the model will generate audio when the target language is
10268
+ spoken, essentially it will parrot the input. If false, we will not produce
10269
+ audio for the target language. */
10270
+ echoTargetLanguage?: boolean;
10271
+ /** The target language for translation. Supported values are BCP-47
10272
+ language codes (e.g. "en", "es", "fr"). */
10273
+ targetLanguageCode?: string;
10274
+ }
10275
+
10240
10276
  /** User provided string values assigned to a single metadata key. This data type is not supported in Vertex AI. */
10241
10277
  export declare interface StringList {
10242
10278
  /** The string values of the metadata to store. */
@@ -11834,6 +11870,7 @@ declare namespace types {
11834
11870
  LiveClientRealtimeInput,
11835
11871
  LiveClientToolResponse,
11836
11872
  LiveClientMessage,
11873
+ StreamTranslationConfig,
11837
11874
  LiveConnectConfig,
11838
11875
  LiveConnectParameters,
11839
11876
  CreateChatParameters,
@@ -12691,30 +12728,6 @@ export declare interface VideoMetadata {
12691
12728
  startOffset?: string;
12692
12729
  }
12693
12730
 
12694
- /**
12695
- * Configuration for video output format.
12696
- */
12697
- declare interface VideoResponseFormat {
12698
- type: 'video';
12699
- /**
12700
- * The aspect ratio for the video output.
12701
- */
12702
- aspectRatio?: '16:9' | '9:16';
12703
- /**
12704
- * The delivery mode for the video output.
12705
- */
12706
- delivery?: 'inline' | 'uri';
12707
- /**
12708
- * The duration for the video output.
12709
- */
12710
- duration?: string;
12711
- /**
12712
- * The GCS URI to store the video output. Required for Vertex if delivery mode is
12713
- * URI.
12714
- */
12715
- gcsUri?: string;
12716
- }
12717
-
12718
12731
  /** Voice activity signal. */
12719
12732
  export declare interface VoiceActivity {
12720
12733
  /** The type of the voice activity signal. */
package/dist/index.cjs CHANGED
@@ -7596,7 +7596,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
7596
7596
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
7597
7597
  const USER_AGENT_HEADER = 'User-Agent';
7598
7598
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
7599
- const SDK_VERSION = '2.2.0'; // x-release-please-version
7599
+ const SDK_VERSION = '2.3.0'; // x-release-please-version
7600
7600
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
7601
7601
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
7602
7602
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -10693,10 +10693,14 @@ class BaseInteractions extends APIResource {
10693
10693
  });
10694
10694
  const isStreaming = (_a = params.stream) !== null && _a !== void 0 ? _a : false;
10695
10695
  const promise = this._client.post(path `/${api_version}/interactions`, Object.assign(Object.assign(Object.assign({ body }, options), { stream: isStreaming }), (needsLegacyLyriaShim && isStreaming ? { __streamClass: LegacyLyriaStream } : {})));
10696
- if (needsLegacyLyriaShim && !isStreaming) {
10697
- return promise._thenUnwrap((data) => coerceLegacyInteractionResponse(data));
10696
+ if (isStreaming) {
10697
+ return promise;
10698
10698
  }
10699
- return promise;
10699
+ let nonStreaming = promise;
10700
+ if (needsLegacyLyriaShim) {
10701
+ nonStreaming = nonStreaming._thenUnwrap((data) => coerceLegacyInteractionResponse(data));
10702
+ }
10703
+ return nonStreaming._thenUnwrap(addOutputProperties);
10700
10704
  }
10701
10705
  /**
10702
10706
  * Deletes the interaction by id.
@@ -10725,17 +10729,64 @@ class BaseInteractions extends APIResource {
10725
10729
  */
10726
10730
  cancel(id, params = {}, options) {
10727
10731
  const { api_version = this._client.apiVersion } = params !== null && params !== void 0 ? params : {};
10728
- return this._client.post(path `/${api_version}/interactions/${id}/cancel`, options);
10732
+ return this._client.post(path `/${api_version}/interactions/${id}/cancel`, options)._thenUnwrap(addOutputProperties);
10729
10733
  }
10730
10734
  get(id, params = {}, options) {
10731
10735
  var _a;
10732
10736
  const _b = params !== null && params !== void 0 ? params : {}, { api_version = this._client.apiVersion } = _b, query = __rest(_b, ["api_version"]);
10733
- return this._client.get(path `/${api_version}/interactions/${id}`, Object.assign(Object.assign({ query }, options), { stream: (_a = params === null || params === void 0 ? void 0 : params.stream) !== null && _a !== void 0 ? _a : false }));
10737
+ const response = this._client.get(path `/${api_version}/interactions/${id}`, Object.assign(Object.assign({ query }, options), { stream: (_a = params === null || params === void 0 ? void 0 : params.stream) !== null && _a !== void 0 ? _a : false }));
10738
+ if (params === null || params === void 0 ? void 0 : params.stream) {
10739
+ return response;
10740
+ }
10741
+ return response._thenUnwrap(addOutputProperties);
10734
10742
  }
10735
10743
  }
10736
10744
  BaseInteractions._key = Object.freeze(['interactions']);
10737
10745
  class Interactions extends BaseInteractions {
10738
10746
  }
10747
+ function addOutputProperties(interaction) {
10748
+ var _a, _b;
10749
+ const steps = (_a = interaction.steps) !== null && _a !== void 0 ? _a : [];
10750
+ let firstTrailing = steps.length;
10751
+ while (firstTrailing > 0 && steps[firstTrailing - 1].type === 'model_output') {
10752
+ firstTrailing--;
10753
+ }
10754
+ const modelSteps = steps.slice(firstTrailing);
10755
+ const output = modelSteps.flatMap((step) => { var _a; return (_a = step.content) !== null && _a !== void 0 ? _a : []; });
10756
+ const textParts = [];
10757
+ for (let i = output.length - 1; i >= 0; i--) {
10758
+ const content = output[i];
10759
+ if (content.type !== 'text')
10760
+ break;
10761
+ textParts.push((_b = content.text) !== null && _b !== void 0 ? _b : '');
10762
+ }
10763
+ const output_text = textParts.reverse().join('');
10764
+ let output_image;
10765
+ let output_audio;
10766
+ let output_video;
10767
+ for (let i = steps.length - 1; i >= 0; i--) {
10768
+ const step = steps[i];
10769
+ const anyStep = step;
10770
+ if (anyStep.type === 'user_input') {
10771
+ break;
10772
+ }
10773
+ if (anyStep.type === 'model_output' && anyStep.content) {
10774
+ for (let j = anyStep.content.length - 1; j >= 0; j--) {
10775
+ const content = anyStep.content[j];
10776
+ if (content.type === 'image' && !output_image) {
10777
+ output_image = content;
10778
+ }
10779
+ if (content.type === 'audio' && !output_audio) {
10780
+ output_audio = content;
10781
+ }
10782
+ if (content.type === 'video' && !output_video) {
10783
+ output_video = content;
10784
+ }
10785
+ }
10786
+ }
10787
+ }
10788
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, interaction), (output_text && { output_text })), (output_image && { output_image })), (output_audio && { output_audio })), (output_video && { output_video }));
10789
+ }
10739
10790
 
10740
10791
  /**
10741
10792
  * @license
@@ -11885,6 +11936,12 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
11885
11936
  }
11886
11937
  setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
11887
11938
  }
11939
+ const fromStreamTranslationConfig = getValueByPath(fromObject, [
11940
+ 'streamTranslationConfig',
11941
+ ]);
11942
+ if (parentObject !== undefined && fromStreamTranslationConfig != null) {
11943
+ setValueByPath(parentObject, ['setup', 'generationConfig', 'streamTranslationConfig'], fromStreamTranslationConfig);
11944
+ }
11888
11945
  return toObject;
11889
11946
  }
11890
11947
  function liveConnectConfigToVertex(fromObject, parentObject) {
@@ -12017,6 +12074,9 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
12017
12074
  }
12018
12075
  setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
12019
12076
  }
12077
+ if (getValueByPath(fromObject, ['streamTranslationConfig']) !== undefined) {
12078
+ throw new Error('streamTranslationConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
12079
+ }
12020
12080
  return toObject;
12021
12081
  }
12022
12082
  function liveConnectParametersToMldev(apiClient, fromObject) {
@@ -19145,6 +19205,12 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
19145
19205
  }
19146
19206
  setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
19147
19207
  }
19208
+ const fromStreamTranslationConfig = getValueByPath(fromObject, [
19209
+ 'streamTranslationConfig',
19210
+ ]);
19211
+ if (parentObject !== undefined && fromStreamTranslationConfig != null) {
19212
+ setValueByPath(parentObject, ['setup', 'generationConfig', 'streamTranslationConfig'], fromStreamTranslationConfig);
19213
+ }
19148
19214
  return toObject;
19149
19215
  }
19150
19216
  function liveConnectConstraintsToMldev(apiClient, fromObject) {
@@ -20876,6 +20942,7 @@ class GoogleGenAI {
20876
20942
  if (this._interactions !== undefined) {
20877
20943
  return this._interactions;
20878
20944
  }
20945
+ console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
20879
20946
  this._interactions = this.getNextGenClient().interactions;
20880
20947
  return this._interactions;
20881
20948
  }
package/dist/index.mjs CHANGED
@@ -7594,7 +7594,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
7594
7594
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
7595
7595
  const USER_AGENT_HEADER = 'User-Agent';
7596
7596
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
7597
- const SDK_VERSION = '2.2.0'; // x-release-please-version
7597
+ const SDK_VERSION = '2.3.0'; // x-release-please-version
7598
7598
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
7599
7599
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
7600
7600
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -10691,10 +10691,14 @@ class BaseInteractions extends APIResource {
10691
10691
  });
10692
10692
  const isStreaming = (_a = params.stream) !== null && _a !== void 0 ? _a : false;
10693
10693
  const promise = this._client.post(path `/${api_version}/interactions`, Object.assign(Object.assign(Object.assign({ body }, options), { stream: isStreaming }), (needsLegacyLyriaShim && isStreaming ? { __streamClass: LegacyLyriaStream } : {})));
10694
- if (needsLegacyLyriaShim && !isStreaming) {
10695
- return promise._thenUnwrap((data) => coerceLegacyInteractionResponse(data));
10694
+ if (isStreaming) {
10695
+ return promise;
10696
10696
  }
10697
- return promise;
10697
+ let nonStreaming = promise;
10698
+ if (needsLegacyLyriaShim) {
10699
+ nonStreaming = nonStreaming._thenUnwrap((data) => coerceLegacyInteractionResponse(data));
10700
+ }
10701
+ return nonStreaming._thenUnwrap(addOutputProperties);
10698
10702
  }
10699
10703
  /**
10700
10704
  * Deletes the interaction by id.
@@ -10723,17 +10727,64 @@ class BaseInteractions extends APIResource {
10723
10727
  */
10724
10728
  cancel(id, params = {}, options) {
10725
10729
  const { api_version = this._client.apiVersion } = params !== null && params !== void 0 ? params : {};
10726
- return this._client.post(path `/${api_version}/interactions/${id}/cancel`, options);
10730
+ return this._client.post(path `/${api_version}/interactions/${id}/cancel`, options)._thenUnwrap(addOutputProperties);
10727
10731
  }
10728
10732
  get(id, params = {}, options) {
10729
10733
  var _a;
10730
10734
  const _b = params !== null && params !== void 0 ? params : {}, { api_version = this._client.apiVersion } = _b, query = __rest(_b, ["api_version"]);
10731
- return this._client.get(path `/${api_version}/interactions/${id}`, Object.assign(Object.assign({ query }, options), { stream: (_a = params === null || params === void 0 ? void 0 : params.stream) !== null && _a !== void 0 ? _a : false }));
10735
+ const response = this._client.get(path `/${api_version}/interactions/${id}`, Object.assign(Object.assign({ query }, options), { stream: (_a = params === null || params === void 0 ? void 0 : params.stream) !== null && _a !== void 0 ? _a : false }));
10736
+ if (params === null || params === void 0 ? void 0 : params.stream) {
10737
+ return response;
10738
+ }
10739
+ return response._thenUnwrap(addOutputProperties);
10732
10740
  }
10733
10741
  }
10734
10742
  BaseInteractions._key = Object.freeze(['interactions']);
10735
10743
  class Interactions extends BaseInteractions {
10736
10744
  }
10745
+ function addOutputProperties(interaction) {
10746
+ var _a, _b;
10747
+ const steps = (_a = interaction.steps) !== null && _a !== void 0 ? _a : [];
10748
+ let firstTrailing = steps.length;
10749
+ while (firstTrailing > 0 && steps[firstTrailing - 1].type === 'model_output') {
10750
+ firstTrailing--;
10751
+ }
10752
+ const modelSteps = steps.slice(firstTrailing);
10753
+ const output = modelSteps.flatMap((step) => { var _a; return (_a = step.content) !== null && _a !== void 0 ? _a : []; });
10754
+ const textParts = [];
10755
+ for (let i = output.length - 1; i >= 0; i--) {
10756
+ const content = output[i];
10757
+ if (content.type !== 'text')
10758
+ break;
10759
+ textParts.push((_b = content.text) !== null && _b !== void 0 ? _b : '');
10760
+ }
10761
+ const output_text = textParts.reverse().join('');
10762
+ let output_image;
10763
+ let output_audio;
10764
+ let output_video;
10765
+ for (let i = steps.length - 1; i >= 0; i--) {
10766
+ const step = steps[i];
10767
+ const anyStep = step;
10768
+ if (anyStep.type === 'user_input') {
10769
+ break;
10770
+ }
10771
+ if (anyStep.type === 'model_output' && anyStep.content) {
10772
+ for (let j = anyStep.content.length - 1; j >= 0; j--) {
10773
+ const content = anyStep.content[j];
10774
+ if (content.type === 'image' && !output_image) {
10775
+ output_image = content;
10776
+ }
10777
+ if (content.type === 'audio' && !output_audio) {
10778
+ output_audio = content;
10779
+ }
10780
+ if (content.type === 'video' && !output_video) {
10781
+ output_video = content;
10782
+ }
10783
+ }
10784
+ }
10785
+ }
10786
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, interaction), (output_text && { output_text })), (output_image && { output_image })), (output_audio && { output_audio })), (output_video && { output_video }));
10787
+ }
10737
10788
 
10738
10789
  /**
10739
10790
  * @license
@@ -11883,6 +11934,12 @@ function liveConnectConfigToMldev$1(fromObject, parentObject) {
11883
11934
  }
11884
11935
  setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
11885
11936
  }
11937
+ const fromStreamTranslationConfig = getValueByPath(fromObject, [
11938
+ 'streamTranslationConfig',
11939
+ ]);
11940
+ if (parentObject !== undefined && fromStreamTranslationConfig != null) {
11941
+ setValueByPath(parentObject, ['setup', 'generationConfig', 'streamTranslationConfig'], fromStreamTranslationConfig);
11942
+ }
11886
11943
  return toObject;
11887
11944
  }
11888
11945
  function liveConnectConfigToVertex(fromObject, parentObject) {
@@ -12015,6 +12072,9 @@ function liveConnectConfigToVertex(fromObject, parentObject) {
12015
12072
  }
12016
12073
  setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
12017
12074
  }
12075
+ if (getValueByPath(fromObject, ['streamTranslationConfig']) !== undefined) {
12076
+ throw new Error('streamTranslationConfig parameter is only supported in Gemini Developer API mode, not in Gemini Enterprise Agent Platform mode.');
12077
+ }
12018
12078
  return toObject;
12019
12079
  }
12020
12080
  function liveConnectParametersToMldev(apiClient, fromObject) {
@@ -19143,6 +19203,12 @@ function liveConnectConfigToMldev(fromObject, parentObject) {
19143
19203
  }
19144
19204
  setValueByPath(parentObject, ['setup', 'safetySettings'], transformedList);
19145
19205
  }
19206
+ const fromStreamTranslationConfig = getValueByPath(fromObject, [
19207
+ 'streamTranslationConfig',
19208
+ ]);
19209
+ if (parentObject !== undefined && fromStreamTranslationConfig != null) {
19210
+ setValueByPath(parentObject, ['setup', 'generationConfig', 'streamTranslationConfig'], fromStreamTranslationConfig);
19211
+ }
19146
19212
  return toObject;
19147
19213
  }
19148
19214
  function liveConnectConstraintsToMldev(apiClient, fromObject) {
@@ -20874,6 +20940,7 @@ class GoogleGenAI {
20874
20940
  if (this._interactions !== undefined) {
20875
20941
  return this._interactions;
20876
20942
  }
20943
+ console.warn('GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions.');
20877
20944
  this._interactions = this.getNextGenClient().interactions;
20878
20945
  return this._interactions;
20879
20946
  }