common

package
v6.10.9-aug.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSSEEventBytes

func AppendSSEEventBytes(out []byte, event string, payload []byte, trailingNewlines int) []byte

func AppendSSEEventString

func AppendSSEEventString(out []byte, event, payload string, trailingNewlines int) []byte

func ClaudeInputTokensJSON

func ClaudeInputTokensJSON(count int64) []byte

func EchoRequestFields

func EchoRequestFields(dest []byte, req gjson.Result, prefix string) []byte

EchoRequestFields copies known OpenAI Responses API request fields from req into dest under the given key prefix. For streaming response.completed events the prefix is "response." ; for non-streaming responses it is "".

func GeminiTokenCountJSON

func GeminiTokenCountJSON(count int64) []byte

func SSEEventData

func SSEEventData(event string, payload []byte) []byte

func WrapGeminiCLIResponse

func WrapGeminiCLIResponse(response []byte) []byte

Types

type ClaudeBlockState

type ClaudeBlockState struct {
	ResponseType  int  // 0=none, 1=text, 2=thinking
	ResponseIndex int  // Current content block index
	HasContent    bool // Whether any content has been emitted
}

ClaudeBlockState tracks the state machine for streaming Claude-format content blocks (thinking / text). Callers should persist this across chunks.

type ClaudeSSEEvent

type ClaudeSSEEvent struct {
	Event string
	Data  string
}

ClaudeSSEEvent is a single SSE event to emit.

func EmitTextOrThinkingBlock

func EmitTextOrThinkingBlock(st *ClaudeBlockState, text string, isThought bool) []ClaudeSSEEvent

EmitTextOrThinkingBlock generates the SSE events needed to stream a Gemini text/thought part as Claude-format content blocks. It mutates st in place.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL