msgutil

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package msgutil provides shared message utilities for subprocess-based providers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckExtraArgs added in v0.9.0

func CheckExtraArgs(args []string, reserved ...string) error

CheckExtraArgs rejects command-line arguments that set a reserved flag.

It is used by subprocess-based providers to validate GenOption.ExtraArgs against the flags the provider owns to drive its protocol. A flag matches with one or two leading dashes and with or without an "=value" suffix.

func ExtractOpaqueID

func ExtractOpaqueID(msgs genai.Messages, key string) string

ExtractOpaqueID extracts a string value from Reply.Opaque by walking messages in reverse order.

It is used by subprocess-based providers to retrieve session or thread IDs stored in previous replies.

func LastUserMsg

func LastUserMsg(msgs genai.Messages) (genai.Message, error)

LastUserMsg returns the last user message in msgs.

It is used by subprocess-based providers that send only the final user message to a subprocess. Earlier supplied user events are not serialized. Some callers resume CLI-owned sessions for context; others launch a fresh process. A successful call does not establish full-history or burst support.

func RejectModelMarker added in v0.9.0

func RejectModelMarker(m genai.ProviderOptionModel) error

RejectModelMarker returns an error when m is genai.ModelCheap, genai.ModelGood, or genai.ModelSOTA.

Subprocess-based providers do not resolve these markers: listing the models requires launching the CLI, which makes construction slow.

func WriteNDJSON

func WriteNDJSON(w io.Writer, v any) error

WriteNDJSON marshals v as JSON and writes it followed by a newline.

It is used by subprocess-based providers that communicate via NDJSON over stdin/stdout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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