session

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Copyright 2026 Teradata

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Package session provides session types compatible with Crush's interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service interface {
	Create(ctx context.Context, title string) (Session, error)
	Get(ctx context.Context, id string) (Session, error)
	List(ctx context.Context) ([]Session, error)
	Delete(ctx context.Context, id string) error
	Subscribe(ctx context.Context) <-chan pubsub.Event[Session]
	ParseAgentToolSessionID(sessionID string) (string, string, bool)
	CreateAgentToolSessionID(messageID, toolCallID string) string
}

Service defines the session service interface.

type Session

type Session struct {
	ID                string
	Title             string
	CreatedAt         int64
	UpdatedAt         int64
	CompletionTokens  int
	PromptTokens      int
	Cost              float64
	Todos             []Todo
	Model             string // Model used in this session (e.g., "claude-sonnet-4-6")
	Provider          string // Provider used in this session (e.g., "anthropic")
	ContextTokensUsed int64  // Actual context window fill (from server ContextState)
	ContextTokensMax  int64  // Context window capacity (from server ContextState)
}

Session represents a chat session.

func (Session) Merge added in v1.2.0

func (s Session) Merge(update Session) Session

Merge returns a copy of s with non-zero fields from update applied. This preserves existing fields like Title and Todos when receiving partial updates (e.g., cost/token updates from the coordinator).

type Todo

type Todo struct {
	Content    string
	ActiveForm string
	Status     TodoStatus
}

Todo represents a todo item.

type TodoStatus

type TodoStatus string

TodoStatus represents the status of a todo item.

const (
	TodoStatusPending    TodoStatus = "pending"
	TodoStatusInProgress TodoStatus = "in_progress"
	TodoStatusCompleted  TodoStatus = "completed"
)

Jump to

Keyboard shortcuts

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