Documentation
¶
Overview ¶
Package transform contains CLI-owned response transformations. Presentation and output formats belong to internal/app and shared output helpers.
Index ¶
- func AgentsRootTurnTerminal(value gjson.Result, route Route) bool
- func AgentsStreamFailure(value gjson.Result, route Route) string
- func CompletedImageResult(ctx context.Context, event gjson.Result) (gjson.Result, error)
- func Identity(_ context.Context, value gjson.Result) (gjson.Result, error)
- func ImageGenerationResult(ctx context.Context, event gjson.Result) (gjson.Result, error)
- func IsAgentsStream(route Route) bool
- func ProjectAudioResponse(value gjson.Result, route Route) (readable.StreamEvent, bool)
- func ProjectAudioStream(value gjson.Result, route Route) (readable.StreamEvent, bool)
- func ProjectFileMetadata(ctx context.Context, value gjson.Result) (gjson.Result, error)
- func ProjectListTable(ctx context.Context, operation string, items []gjson.Result) (headers []string, rows [][]string, supported bool, err error)
- func ProjectTextStream(value gjson.Result, route Route) (readable.StreamEvent, bool)
- func ProjectWebhookEventTypes(ctx context.Context, value gjson.Result) (gjson.Result, error)
- func ProjectWebhookTestOutcome(ctx context.Context, value gjson.Result) (gjson.Result, error)
- func ProjectWebhookTestResult(ctx context.Context, value gjson.Result) (gjson.Result, error)
- func SelectModels(ctx context.Context, items []gjson.Result, selection ModelSelection) ([]gjson.Result, bool, error)
- func StreamFailure(value gjson.Result, route Route) string
- func SummarizeResource(ctx context.Context, value gjson.Result, route Route) (gjson.Result, bool, error)
- type AgentsStreamProjector
- type AgentsStreamState
- type ModelListRow
- type ModelSelection
- type OutputKind
- type ProjectLifecycleReceipt
- type Route
- type StreamCompletionState
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AgentsRootTurnTerminal ¶ added in v1.40.3
AgentsRootTurnTerminal excludes subagent and malformed terminal events. It classifies outcomes only. Trailing stream events must remain visible.
func AgentsStreamFailure ¶ added in v1.40.3
AgentsStreamFailure classifies lifecycle failures without exposing API prose. A failed tool or subagent remains data, not a failed root turn.
func CompletedImageResult ¶
CompletedImageResult selects the final image bytes into the same data array used by nonstreaming generation and editing. It does not write files or handle previews.
func ImageGenerationResult ¶
ImageGenerationResult retains the generation-only contract for existing callers.
func IsAgentsStream ¶ added in v1.40.3
IsAgentsStream limits presentation and lifecycle rules to generated Agents routes.
func ProjectAudioResponse ¶
ProjectAudioResponse separates a transcript from its metadata for readable presentation. Native text and subtitle bodies reach this boundary as strings. The original value remains available to every explicit data format.
func ProjectAudioStream ¶
ProjectAudioStream selects ordinary transcription deltas and final snapshots. Diarized segments retain their complete structured representation: segment deltas cannot safely be reconciled with a final transcript by position alone.
func ProjectFileMetadata ¶
ProjectFileMetadata preserves complete file records and formats known timestamps. Machine output never calls this presentation-only projection.
func ProjectListTable ¶
func ProjectListTable(ctx context.Context, operation string, items []gjson.Result) (headers []string, rows [][]string, supported bool, err error)
ProjectListTable selects columns from one loaded API page. It preserves IDs and leaves terminal escaping to the renderer. Unsupported or unfamiliar records require full-page fallback, so no partial table hides their details. Cancellation returns an error instead of a partial table or fallback.
func ProjectTextStream ¶
ProjectTextStream selects text components without modifying the API event. Unknown content stays in Details; a false result preserves the complete event. The caller applies this only to readable output, never explicit data formats.
func ProjectWebhookEventTypes ¶ added in v1.40.3
ProjectWebhookEventTypes groups the supported catalog for CLI discovery. Unknown response fields or item types retain their full generic representation.
func ProjectWebhookTestOutcome ¶ added in v1.40.3
ProjectWebhookTestOutcome leaves request context to the command presenter.
func ProjectWebhookTestResult ¶ added in v1.40.3
ProjectWebhookTestResult separates test completion from receiver acceptance. Unknown or malformed results retain their complete readable representation.
func SelectModels ¶
func SelectModels(ctx context.Context, items []gjson.Result, selection ModelSelection) ([]gjson.Result, bool, error)
SelectModels retains original records and stable ordering for equal IDs. Ambiguous identities make the whole selection unsupported, including records that would otherwise be filtered out. Metadata does not affect selection.
func StreamFailure ¶
StreamFailure classifies ordinary SSE results before projection or extraction. Messages are fixed API classifications; the caller separately preserves the original event, including error details, for every presentation format.
func SummarizeResource ¶
func SummarizeResource(ctx context.Context, value gjson.Result, route Route) (gjson.Result, bool, error)
SummarizeResource projects known list/get records without modifying API data. A zero summary asks the presenter to show the full value. Omitted reports whether the projection hides fields; presentation owns any explanatory hint.
Types ¶
type AgentsStreamProjector ¶ added in v1.40.3
type AgentsStreamProjector struct {
// contains filtered or unexported fields
}
AgentsStreamProjector retains a digest and completion bit per text component, never its text. Machine output never calls it.
func (*AgentsStreamProjector) HasOmissions ¶ added in v1.40.3
func (s *AgentsStreamProjector) HasOmissions() bool
HasOmissions reports whether projection omitted known fields from any event. Presentation owns diagnostic wording, destination, and suppression policy.
func (*AgentsStreamProjector) Project ¶ added in v1.40.3
func (s *AgentsStreamProjector) Project(ctx context.Context, value gjson.Result, route Route) (readable.StreamEvent, bool, error)
Project selects text and lifecycle details for the existing StreamWriter. Unknown events and unsupported shapes return false for complete rendering.
type AgentsStreamState ¶ added in v1.40.3
type AgentsStreamState struct {
// Enable only for finalized self-hosted creation with omitted or null input.
AllowNoInputSessionCreation bool
// contains filtered or unexported fields
}
AgentsStreamState tracks root outcomes without retaining event bodies. Memory scales with distinct turn identities. Digest-only tombstones preserve terminal outcomes and subagent attribution across late, out-of-order events.
func (*AgentsStreamState) CompletionError ¶ added in v1.40.3
func (s *AgentsStreamState) CompletionError(route Route) string
CompletionError applies only when the source reaches EOF, not a local item limit.
type ModelListRow ¶
ModelListRow preserves an ID and its owner from the same API record. Owner is nil when the field is absent, empty, malformed, or ambiguous.
func ProjectModelsList ¶
func ProjectModelsList(ctx context.Context, items []gjson.Result, descending bool) ([]ModelListRow, bool, error)
ProjectModelsList selects ID/owner pairs from already-selected records. Equal IDs retain their input order. Other metadata does not affect selection. Ambiguous identities require full rendering; the renderer escapes controls.
type ModelSelection ¶
ModelSelection filters exact IDs, sorts them, and then limits the result. Negative limits retain every match. Configured filters must both match.
type OutputKind ¶
type OutputKind string
OutputKind identifies the successful-response boundary being presented.
const ( OutputUnspecified OutputKind = "" OutputResponse OutputKind = "response" OutputPageItem OutputKind = "page_item" OutputStreamEvent OutputKind = "stream_event" )
type ProjectLifecycleReceipt ¶ added in v1.41.0
ProjectLifecycleReceipt contains only values confirmed by a project response.
func ProjectLifecycle ¶ added in v1.41.0
func ProjectLifecycle(ctx context.Context, value gjson.Result, route Route) (ProjectLifecycleReceipt, bool, error)
ProjectLifecycle selects successful lifecycle responses for readable receipts. Unfamiliar, ambiguous, and incomplete responses retain the full output path.
type Route ¶
type Route struct {
Operation string
OutputKind OutputKind
}
Route identifies an operation independently of its presentation format.
type StreamCompletionState ¶
type StreamCompletionState struct {
// contains filtered or unexported fields
}
StreamCompletionState remembers only observed API progress, not event bodies. It detects clean EOF after an unfinished result even when transport framing reports no error. Empty streams and wholly unfamiliar events remain unchanged.
func (*StreamCompletionState) CompletionError ¶
func (s *StreamCompletionState) CompletionError(route Route) string
type Transformer ¶
Transformer changes one response or iterator value before presentation. Implementations must respect cancellation and must not consume other values.
func Select ¶
func Select(route Route) Transformer
Select is the SDK-owned hook for command-specific default transformations. Only known API fields are summarized; unfamiliar routes preserve their values.
Source Files
¶
- agents_encoded_images.go
- agents_session_creation.go
- agents_stream_state.go
- completed_image_result.go
- project_agents_reasoning.go
- project_agents_stream.go
- project_audio_response.go
- project_audio_stream.go
- project_file_metadata.go
- project_lifecycle.go
- project_list_table.go
- project_models_list.go
- project_text_stream.go
- project_webhook_event_types.go
- project_webhook_test_result.go
- select_models.go
- select_transformer.go
- stream_completion.go
- stream_failure.go
- summarize_agents.go
- summarize_agents_events.go
- summarize_agents_items.go
- summarize_media_and_vectors.go
- summarize_resources.go