package model

import (
	"context"
	"encoding/json"
)

type Client interface {
	Generate(ctx context.Context, input GenerateInput) (GenerateResult, error)
}

// WorkspaceMetadata carries workspace-bound authoring context. On the wire,
// only the Path is serialized as a flat string to metadata.workspace in the
// /v1/responses payload. Other fields are used on the client-side/authoring
// logic.
type WorkspaceMetadata struct {
	Path         string `json:"path"`
	SourceBranch string `json:"source_branch,omitempty"`
	Provider     string `json:"provider,omitempty"`
	WorkItemID   string `json:"work_item_id,omitempty"`
	Tenant       string `json:"tenant,omitempty"`
	Project      string `json:"project,omitempty"`
	ExternalURL  string `json:"external_url,omitempty"`
	StateID      string `json:"state_id,omitempty"`
}

type GenerateInput struct {
	Model             string
	Instructions      string
	Input             string
	Metadata          map[string]string
	WorkspaceMetadata *WorkspaceMetadata
	MaxOutputTokens   int
	Temperature       *float64
	TopP              *float64
}

type GenerateResult struct {
	ID    string
	Model string
	Text  string
	Usage Usage
	Raw   json.RawMessage
}

type Usage struct {
	InputTokens  int
	OutputTokens int
	TotalTokens  int
}
