blob: 838be123031439a46909332082c24bccd6db0d5a [file]
// Copyright 2026 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
edition = "2024";
package optimization_guide.proto;
option optimize_for = LITE_RUNTIME;
option java_package = "org.chromium.components.optimization_guide.features.proto";
import "components/optimization_guide/proto/features/common_quality_data.proto";
import "components/optimization_guide/proto/features/wire/tool_declaration.proto";
import "components/optimization_guide/proto/common_types.proto";
import option "google/protobuf/cpp_features.proto";
option features.(pb.cpp).string_type = STRING;
option features.(pb.cpp).enum_name_uses_string_view = false;
option objc_class_prefix = "TTC";
// Audio codec format specification.
enum AudioCodec {
AUDIO_CODEC_UNSPECIFIED = 0;
AUDIO_CODEC_PCM16K16BIT = 1;
AUDIO_CODEC_OPUS24K = 2;
AUDIO_CODEC_OPUS48K = 3;
}
// Top-level container for outgoing stream messages from Chrome to Server.
message TtcClientFrame {
oneof frame {
SessionSetupRequest setup_request = 1;
AudioChunk audio_input = 2;
TextInput text_input = 3;
ContextUpdate context_update = 4;
ToolsetUpdate toolset_update = 5;
ToolResponse tool_response = 6;
PlaybackStatus playback_status = 7;
CloseSessionRequest close_request = 8;
}
// Client timestamp in milliseconds since the Unix epoch (Jan 1, 1970 UTC).
// Represents the client-side clock time (Unix epoch, Jan 1, 1970 UTC) when
// this frame was prepared and dispatched to the network stack.
// TODO(bokan): Update this to Timestamp
int64 client_timestamp_ms = 9;
}
// Top-level container for incoming stream messages from Server to Chrome.
message TtcServerFrame {
// Previously `ToolCall tool_call`, replaced by `tool_call_batch`.
reserved 3;
reserved tool_call;
oneof frame {
SessionStatusResponse session_status = 1;
ServerContent server_content = 2;
GoAway go_away = 4;
ServerErrorNotification server_error = 5;
// TODO(crbug.com/578715754): interrupted and turn_complete are deprecated in favor
// of ModelTurnStateUpdate below. Remove once client is updated.
InterruptionNotice interrupted = 6 [deprecated = true];
TurnComplete turn_complete = 7 [deprecated = true];
JournalEvent journal_event = 9;
ModelTurnStateUpdate model_turn_state_update = 10;
UserTurnStateUpdate user_turn_state_update = 11;
// One or more tool calls dispatched together in a single frame (can be more
// than one if the model emits several function calls in one response).
ToolCallBatch tool_call_batch = 12;
}
// Server timestamp in milliseconds since the Unix epoch (Jan 1, 1970 UTC).
// Represents the server-side clock time (Unix epoch, Jan 1, 1970 UTC) when
// this frame was generated and dispatched to the network stream.
// TODO(bokan): Update this to Timestamp
int64 server_timestamp_ms = 8;
}
// Model selection preference for multimodal streaming.
enum ModelPreference {
// Unspecified model preference. Server defaults to the default model.
MODEL_PREFERENCE_UNSPECIFIED = 0;
// Fallback streaming model.
MODEL_PREFERENCE_FALLBACK = 1;
// Default streaming model.
MODEL_PREFERENCE_DEFAULT = 2;
}
// Establishes authenticated session capabilities and initial setup.
message SessionSetupRequest {
// Optional system persona or instructions to customize assistant behavior.
string persona = 1;
// Audio codec format for input and output audio streams.
AudioCodec audio_codec = 2;
// Whether to enable turn metrics.
bool enable_turn_metrics = 3;
// Model selection preference for multimodal streaming.
// When unset or set to MODEL_PREFERENCE_UNSPECIFIED, the server uses the
// default model. Setting this to MODEL_PREFERENCE_FALLBACK explicitly
// requests the fallback model.
ModelPreference model_preference = 4;
}
// Acknowledges session readiness and connection status.
message SessionStatusResponse {
enum SessionState {
STATE_UNSPECIFIED = 0;
STATE_CONNECTED = 1;
STATE_REJECTED_QUOTA_EXCEEDED = 2;
STATE_REJECTED_POLICY_DISABLED = 3;
STATE_TERMINATED_ERROR = 4;
}
// Current connection state of the session.
SessionState state = 1;
// Unique server-assigned session identifier for logging and tracing.
string server_session_id = 2;
// Optional diagnostic details or error explanation if state is not CONNECTED.
string diagnostic_error_detail = 3;
}
// Audio chunk for bidirectional streaming (used in both client and server
// frames).
message AudioChunk {
// Binary audio payload. The encoding format and sample rate are determined
// during session establishment via SessionSetupRequest.audio_codec.
bytes audio_data = 1;
// Monotonically increasing chunk sequence number for ordering and
// interruption tracking.
int64 sequence_number = 2;
// Capture timestamp on client, or synthesis timestamp on server in
// milliseconds since the Unix epoch (Jan 1, 1970 UTC).
// TODO(bokan): Update this to Timestamp
int64 timestamp_ms = 3;
}
// Direct text query submission (e.g. prompt chips or keyboard input).
message TextInput {
// User text input query string.
string text_query = 1;
}
// Sent by the client to report the current playback state of generated audio
// for history truncation and turn completion.
message PlaybackStatus {
// The duration played back to the user since the last generation started, in
// terms of the content's duration.
Duration playback_progress = 1;
// If true, indicates that playback is complete for the current generation
// (either naturally finished or stopped/discarded on interruption).
bool playback_complete = 2;
// Identifier of the model generation this playback status applies to.
int64 generation_id = 3;
}
// Model response content and speech transcriptions.
message ServerContent {
// Generated audio output.
AudioChunk audio_output = 1;
// Real-time user ASR transcription.
string input_transcription = 2;
// Model output transcription (speech captions).
string output_transcription = 3;
}
// TODO(crbug.com/578715754): Deprecated in favor of ModelTurnStateUpdate
// below. Remove once client is updated.
// Signals that model generation was interrupted (e.g. user barge-in)
// and that client audio playback should immediately cease.
message InterruptionNotice {}
// TODO(crbug.com/578715754): Deprecated in favor of ModelTurnStateUpdate
// below. Remove once client is updated.
// Signals that the model has completed its turn.
message TurnComplete {
// Resource usage metrics for the completed turn.
message TurnMetrics {
// Number of input tokens consumed in this turn.
int32 input_tokens_used = 1;
// Number of output tokens generated in this turn.
int32 output_tokens_used = 2;
}
TurnMetrics turn_metrics = 1;
}
// Signals a change in the state of the model's current turn.
message ModelTurnStateUpdate {
enum State {
STATE_UNSPECIFIED = 0;
// The model has started generating a response. Marks the start of a model
// turn.
TURN_STARTED = 1;
// The model has finished generating a response. Note that the client may
// still be playing back output audio. This will not be sent when
// INTERRUPTED is sent.
GENERATION_COMPLETED = 2;
// Model generation was interrupted (e.g. user barge-in).
INTERRUPTED = 3;
// The model has completed its turn. When completed naturally, this is sent
// after audio has finished playing on the client (when
// playback_status_reporting is enabled, otherwise sent after generation
// ends). When interrupted, this is sent immediately after the interrupt is
// detected.
TURN_COMPLETED = 4;
}
// The new state of the model's turn.
State state = 1;
// Identifier of the model generation this update applies to.
int64 generation_id = 2;
}
// Signals a change in the state of the user's current turn. Note that a user
// turn can start while a model turn is still in progress. In this case the
// model interrupt and turn_completed states follow the user turn_start
// message.
message UserTurnStateUpdate {
enum State {
STATE_UNSPECIFIED = 0;
// The user has started their turn (e.g. started speaking).
TURN_STARTED = 1;
// The user has completed their turn.
TURN_COMPLETED = 2;
}
// The new state of the user's turn.
State state = 1;
}
// Mid-stream tab switch / page navigation context update.
message ContextUpdate {
// Navigation context for the active browser tab.
TabContext active_tab = 1;
// Optional on-demand or proactive page DOM tree representation.
AnnotatedPageContent annotated_page_content = 2;
// Broad category explaining why the browser withheld page context for the
// active tab. Recorded for diagnostics only and never included in model
// prompts.
enum PageRestrictionReason {
// Default value used when normal page context (tab metadata and
// AnnotatedPageContent) may be shared, or when sent by older clients.
PAGE_RESTRICTION_REASON_UNSPECIFIED = 0;
// Page context is withheld for an uncategorized reason.
PAGE_RESTRICTION_REASON_OTHER = 1;
// Active tab uses a non-web protocol or privileged internal browser page
// (such as internal browser schemes, local files, or extension pages).
PAGE_RESTRICTION_REASON_UNSUPPORTED_SCHEME = 2;
// Active tab URL is blocked by an enterprise administrator policy.
PAGE_RESTRICTION_REASON_ENTERPRISE_POLICY = 3;
// Active tab URL is blocked by client safety or page-eligibility checks.
PAGE_RESTRICTION_REASON_SAFETY_POLICY = 4;
// Active tab content cannot be read because the main frame is unavailable
// (such as when the renderer process has crashed).
PAGE_RESTRICTION_REASON_RENDERER_UNAVAILABLE = 5;
}
// Reason why page context was withheld for the active tab. Populated by the
// browser process, never from page content.
PageRestrictionReason restriction_reason = 3;
}
// Context for active browser tab navigation.
message TabContext {
// URL of the active browser tab.
string url = 1;
// Page title of the active browser tab.
string title = 2;
// MIME type of the active browser tab's main document (e.g. "text/html",
// "application/pdf").
string mime_type = 3;
}
// Dynamic browser tool manifest update.
message ToolsetUpdate {
// List of tools currently available for the model to invoke.
repeated ToolDefinition active_tools = 1;
}
// Single tool definition.
message ToolDefinition {
// Deprecated in favor of tool_declaration below.
reserved 1, 2, 3;
reserved name, description, parameters_json_schema;
enum ExecutionBehavior {
EXECUTION_BEHAVIOR_UNSPECIFIED = 0;
BEHAVIOR_BLOCKING = 1;
BEHAVIOR_NON_BLOCKING = 2;
}
// Execution behavior indicating whether the tool blocks model generation.
ExecutionBehavior behavior = 4;
enum VerbalizationBehavior {
VERBALIZATION_BEHAVIOR_UNSPECIFIED = 0;
VERBALIZATION_STANDARD = 1;
VERBALIZATION_SILENT_ACTION = 2;
}
// Verbalization behavior indicating whether action should be spoken aloud.
VerbalizationBehavior verbalization = 5;
// Shared metadata and parameter schema for this tool.
ToolDeclaration tool_declaration = 6;
}
// Tool call request dispatched from server to client.
message ToolCall {
// Name of the function or tool to execute.
string name = 1;
// Unique call ID correlating this request with a subsequent ToolResponse.
string call_id = 2;
// JSON-encoded arguments matching the tool's parameter schema.
string arguments_json = 3;
}
// A batch of tool calls dispatched from server to client in a single frame.
// Each call has its own call_id and is answered with its own ToolResponse.
message ToolCallBatch {
// Tool calls in the order the model emitted them.
repeated ToolCall tool_calls = 1;
}
// Visual content returned by tools.
message VisualContent {
// Encoded image bytes.
bytes image_data = 1;
// MIME type of the visual content (e.g. "image/png", "image/jpeg",
// "image/webp").
string mime_type = 2;
}
// Tool execution response sent from client to server.
message ToolResponse {
// Name of the function/tool that was executed (e.g. "getpointer",
// "open_tab").
string name = 1;
// Correlation ID matching the ToolCall that initiated this execution.
string call_id = 2;
// JSON-encoded result of the tool execution.
string response_json = 3;
// Optional visual content (e.g. screenshot) produced by tool execution.
VisualContent visual_content = 4;
}
// Notice that the server will soon disconnect the session.
message GoAway {
// Estimated time remaining in milliseconds before connection termination.
int64 time_left_ms = 1;
}
// Signals that the client requests clean closure of the streaming session.
message CloseSessionRequest {
// Client reason for closing the session.
string reason = 1;
}
// Notifies client of an error condition encountered during streaming.
message ServerErrorNotification {
enum ErrorCode {
ERROR_CODE_UNSPECIFIED = 0;
ERROR_CODE_RATE_LIMITED = 1;
ERROR_CODE_SAFETY_BLOCKED = 2;
ERROR_CODE_INTERNAL_BACKEND_ERROR = 3;
ERROR_CODE_SESSION_EXPIRED = 4;
}
// Categorized error code.
ErrorCode error_code = 1;
// Human-readable error description for debugging and logging.
string error_message = 2;
}
// Event recorded in the session journal for logging and debugging.
message JournalEvent {
// Type of the journal event.
enum JournalEventType {
JOURNAL_EVENT_TYPE_UNSPECIFIED = 0;
// A journal event that's a single instant in time and has no duration.
JOURNAL_EVENT_TYPE_INSTANT = 1;
// The start and end points of an asynchronous event that has a duration.
// Must specify an `async_event_id` to correlate the start and end events.
// Note, that the end event may provide different details from the begin,
// however, the `name` on the end event is ignored. Clients are encourated
// to provide the name anyways as it can help identify stray events.
JOURNAL_EVENT_TYPE_ASYNC_BEGIN = 2;
JOURNAL_EVENT_TYPE_ASYNC_END = 3;
// A special journal event used to compute the delta between client and
// server clocks in order to align all events to one clock.
JOURNAL_EVENT_TYPE_CLOCK_SYNC = 4;
}
// Key-value detail entry for a journal event.
message JournalDetails {
string key = 1;
string value = 2;
}
// Timestamp when the event was recorded.
Timestamp timestamp = 1;
// Type of the journal event.
JournalEventType type = 2;
// Name of the event.
string name = 3;
// Specific key-value details associated with the event.
repeated JournalDetails details = 4;
// Identifier correlating an async begin event with its corresponding async
// end event. Must be set if and only if `type` is
// `JOURNAL_EVENT_TYPE_ASYNC_BEGIN` or `JOURNAL_EVENT_TYPE_ASYNC_END`.
int32 async_event_id = 5;
// Timestamp when the message was sent from the client *as recorded by the
// client's clock*. This value is sent back to the client along with the
// server clock received timestamp and is used to estimate the delta between
// clocks on client and server. Set only for `JOURNAL_EVENT_TYPE_CLOCK_SYNC`.
Timestamp sync_timestamp = 6;
enum Track {
TRACK_UNSPECIFIED = 0;
// MES main event track
TRACK_MAIN = 1;
// Tracks model/user turn state in a dedicated track.
TRACK_TURN = 2;
}
// The tracing track on which this event is recorded.
Track track = 7;
}