Documentation
¶
Index ¶
- Constants
- func DetectFileContentType(filePath string, data []byte) string
- func DownloadMedia(mediaURL, backendURL, accessToken, client, uid string) ([]byte, error)
- func PrettyJSON(raw []byte) (string, error)
- func ResolveFinalURL(rawURL string, fallbackBase string) string
- func ResolveThreadUser(backendURL, accessToken, client, uid, user string) (string, error)
- func SafeCredentialResponseBody(raw []byte, credentials ...string) string
- func SafeResponseBody(raw []byte) string
- func SetOAuthRefresher(refresh func(stale string) (string, error))
- func SharedOperation(backendURL, accessToken, clientID, uid, tool string, ...) (json.RawMessage, error)
- func UploadSharedFile(backendURL, token, client, uid, path, purpose string) (map[string]interface{}, error)
- type AIModelRef
- type AIModelsResponse
- type AIRun
- type AIRunOutput
- type Answer
- type AnswerFileURL
- type AnswerImageURL
- type AnswerImageV2
- type AnswerResponse
- type BsvAttachment
- type BsvOrdinal
- type BsvUpvalue
- type BsvUpvalueAnswer
- type BsvUpvalueTx
- type ChildQuest
- type Client
- type CreateAnswerResponse
- type CreateQuestResponse
- type GenerationMedia
- type GenerationQuote
- type GenerationResponse
- type HTTPError
- type MessagesResponse
- type NotificationsCountResponse
- type NotificationsResponse
- type PollOptionPayload
- type Quest
- type ResolvedMediaLink
- type StripeAiBillingCheckoutResponse
- type StripeAiBillingStatusResponse
- type StripeAiBillingStripe
- type StripeAiBillingSyncResponse
- type StripeAiBillingUsEvent
- type StripeAiBillingUsage
- type StripeAiPaymentModeResponse
- type TeamRef
- type TeamsResponse
- type ThreadListOptions
- type ThreadPagination
- type ThreadResponse
- type ThreadsResponse
- type ToolDefinition
- type ToolList
- type ToolResult
- type URL
- type UpvalueHistoryResponse
- type UpvaluedContentLeaderboardItem
- type UpvaluedContentLeaderboardResponse
- type User
Constants ¶
const OAuthClient = "oauth"
OAuthClient marks a saved profile whose credentials are an OAuth bearer from `treecli connect`. Such profiles reach the backend only through /mcp.
Variables ¶
This section is empty.
Functions ¶
func DetectFileContentType ¶
DetectFileContentType returns a stable media MIME type for local upload paths.
func DownloadMedia ¶
DownloadMedia fetches a generated media URL. Treechat auth headers are sent only to same-origin API URLs so signed storage/CDN URLs never receive credentials.
func PrettyJSON ¶
func ResolveFinalURL ¶
func ResolveThreadUser ¶ added in v0.2.7
ResolveThreadUser accepts IDs, usernames (optionally @-prefixed), and me. The server resolves me from the authenticated session, even for old profiles.
func SafeCredentialResponseBody ¶ added in v0.2.13
SafeCredentialResponseBody also removes active credential values from freeform upstream errors, where key-based JSON redaction cannot identify them.
func SafeResponseBody ¶
func SetOAuthRefresher ¶ added in v0.2.13
SetOAuthRefresher installs the hook that trades an expired bearer for a fresh one (and persists it). The CLI owns credential storage; this package never does.
func SharedOperation ¶ added in v0.2.13
func SharedOperation(backendURL, accessToken, clientID, uid, tool string, arguments map[string]interface{}) (json.RawMessage, error)
SharedOperation is the sole RPC envelope used by legacy CLI adapters and MCP. The backend owns operation validation, authorization and business decisions.
func UploadSharedFile ¶ added in v0.2.13
func UploadSharedFile(backendURL, token, client, uid, path, purpose string) (map[string]interface{}, error)
UploadSharedFile keeps file selection and storage transport local, while the shared server operations own registration, validation and reference ownership.
Types ¶
type AIModelRef ¶
type AIModelRef struct {
ID string `json:"id"`
Name string `json:"name"`
HumanName string `json:"human_name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
DescriptionShort string `json:"description_short"`
Provider string `json:"provider"`
ModelType string `json:"model_type"`
ActionTagName string `json:"action_tag_name"`
}
type AIModelsResponse ¶
type AIModelsResponse []AIModelRef
func ListAIModels ¶
func ListAIModels(backendURL, accessToken, client, uid string) (AIModelsResponse, error)
type AIRun ¶
type AIRun struct {
ID string `json:"id"`
Status string `json:"status"`
OutputURLs []AIRunOutput `json:"output_urls"`
}
type AIRunOutput ¶
type Answer ¶
type Answer struct {
ReplyToAnswerID string `json:"reply_to_answer_id"`
ID string `json:"id"`
SpaceID string `json:"space_id"`
QuestID string `json:"quest_id"`
UserID string `json:"user_id"`
Content string `json:"content"`
DeltaJSON json.RawMessage `json:"delta_json,omitempty"`
DisplayContent string `json:"display_content"`
Path string `json:"path"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
MessageType string `json:"message_type"`
IsPost bool `json:"is_post"`
IsDraft bool `json:"is_draft"`
IsSystem bool `json:"is_system"`
IsClip bool `json:"is_clip"`
Deleted bool `json:"deleted"`
RecordingURL *string `json:"recording_url"`
MP4RecordingURL *string `json:"mp4_recording_url"`
RecordingThumbnailURL *string `json:"recording_thumbnail_url"`
RecordingType *string `json:"recording_type"`
OriginalRecordingType *string `json:"original_recording_type"`
RecordingInfo json.RawMessage `json:"recording_info"`
AnswerImageURL *string `json:"answer_image_url"`
ImagesV2 []AnswerImageV2 `json:"images_v2"`
ImageURLs []AnswerImageURL `json:"image_urls"`
FileURLs []AnswerFileURL `json:"file_urls"`
AIRuns []AIRun `json:"ai_runs"`
IsGeneratingImage bool `json:"is_generating_image"`
ImageGenerationFailed bool `json:"image_generation_failed"`
ImageGenerationFailureReason *string `json:"image_generation_failure_reason"`
User *User `json:"user"`
URL *URL `json:"url"`
ChildQuests []ChildQuest `json:"child_quests"`
BsvAttachments []BsvAttachment `json:"bsv_attachments"`
ImageBsvOrdinal *BsvOrdinal `json:"image_bsv_ordinal"`
VideoBsvOrdinal *BsvOrdinal `json:"video_bsv_ordinal"`
PollOpen bool `json:"poll_open"`
PollTotalVotes int `json:"poll_total_votes"`
PollUserVoteOptionID *string `json:"poll_user_vote_option_id"`
PollResultsVisible bool `json:"poll_results_visible"`
PollOptionsPayload []PollOptionPayload `json:"poll_options_payload"`
}
func (Answer) CanonicalMediaURLs ¶
func (Answer) GenerationFailureReason ¶
func (Answer) GenerationStatus ¶
type AnswerFileURL ¶
type AnswerImageURL ¶
type AnswerImageURL struct {
ImageURL string `json:"image_url"`
AttachmentID string `json:"attachment_id"`
ImageByteSize *int64 `json:"image_byte_size"`
ImageWidth *int `json:"image_width"`
ImageHeight *int `json:"image_height"`
ImageContentType string `json:"image_content_type"`
ImageFilename string `json:"image_filename"`
PreviewURLs map[string]string `json:"preview_urls"`
PreviewURL *string `json:"preview_url"`
}
type AnswerImageV2 ¶
type AnswerImageV2 struct {
AttachmentID string `json:"attachment_id"`
BlobID string `json:"blob_id"`
AttachedAt string `json:"attached_at"`
BlobCreatedAt string `json:"blob_created_at"`
Access string `json:"access"`
ImageByteSize *int64 `json:"image_byte_size"`
ImageWidth *int `json:"image_width"`
ImageHeight *int `json:"image_height"`
ImageContentType string `json:"image_content_type"`
ImageFilename string `json:"image_filename"`
URLs map[string]string `json:"urls"`
PreviewURL *string `json:"preview_url"`
}
type AnswerResponse ¶
type AnswerResponse struct {
Answer Answer `json:"answer"`
Raw json.RawMessage `json:"-"`
}
func GetAnswer ¶
func GetAnswer(backendURL, answerID, accessToken, client, uid string) (AnswerResponse, error)
type BsvAttachment ¶
type BsvOrdinal ¶
type BsvUpvalue ¶ added in v0.2.6
type BsvUpvalue struct {
ID string `json:"id"`
TxID string `json:"tx_id"`
Amount string `json:"amount"`
Fee string `json:"fee"`
CreatedAt string `json:"created_at"`
FromUserID string `json:"from_user_id"`
ToUserID string `json:"to_user_id"`
IsBoost bool `json:"is_boost"`
Metadata map[string]interface{} `json:"metadata"`
Status string `json:"status"`
FromUser User `json:"from_user"`
ToUser User `json:"to_user"`
BsvTx *BsvUpvalueTx `json:"bsv_tx"`
Answer BsvUpvalueAnswer `json:"answer"`
}
type BsvUpvalueAnswer ¶ added in v0.2.6
type BsvUpvalueAnswer struct {
ID string `json:"id"`
ChildQuests []ChildQuest `json:"child_quests"`
}
type BsvUpvalueTx ¶ added in v0.2.6
type ChildQuest ¶
type Client ¶ added in v0.2.13
type Client struct {
// contains filtered or unexported fields
}
Client binds explicit credentials to one origin. It never reads CLI configuration. Bearer support here does not grant access to any server endpoint or scope.
func NewOAuthClient ¶ added in v0.2.13
func NewTokenClient ¶ added in v0.2.13
func (*Client) DoJSON ¶ added in v0.2.13
func (c *Client) DoJSON(ctx context.Context, method, path string, query url.Values, body, out interface{}) error
DoJSON is a transport primitive for typed operations, not an MCP tool. Callers select the endpoint; model-supplied arbitrary methods/paths must not be exposed.
type CreateAnswerResponse ¶
type CreateAnswerResponse struct {
Answer Answer `json:"answer"`
Quest *Quest `json:"quest"`
SideQuest *Quest `json:"side_quest"`
Raw json.RawMessage `json:"-"`
}
type CreateQuestResponse ¶
type CreateQuestResponse struct {
Quest Quest `json:"quest"`
Raw json.RawMessage `json:"-"`
}
type GenerationMedia ¶
type GenerationMedia struct {
URL string `json:"url"`
ContentType string `json:"content_type,omitempty"`
Kind string `json:"kind,omitempty"`
}
GenerationMedia describes one generated media artifact.
type GenerationQuote ¶
type GenerationQuote struct {
AmountSats int64 `json:"amount_sats"`
AmountUSD float64 `json:"amount_usd"`
Action string `json:"action,omitempty"`
Tag string `json:"tag"`
Provider string `json:"provider,omitempty"`
PaymentMode string `json:"payment_mode,omitempty"`
}
GenerationQuote is the price for a generation, returned when quote=true (no media is produced).
type GenerationResponse ¶
type GenerationResponse struct {
ID string `json:"id"`
Status string `json:"status"`
Tag string `json:"tag"`
Action string `json:"action,omitempty"`
Source string `json:"source"`
Provider string `json:"provider,omitempty"`
PaymentMode string `json:"payment_mode,omitempty"`
MediaURLs []string `json:"media_urls"`
MediaOutputs []GenerationMedia `json:"media_outputs,omitempty"`
AmountSats int64 `json:"amount_sats,omitempty"`
AmountUSD float64 `json:"amount_usd,omitempty"`
Quote *GenerationQuote `json:"quote,omitempty"`
Failure map[string]interface{} `json:"failure,omitempty"`
Error string `json:"error,omitempty"`
Raw []byte `json:"-"`
}
GenerationResponse is the payload from the direct (post-less) generation endpoints.
func DecodeGeneration ¶ added in v0.2.13
func DecodeGeneration(raw json.RawMessage) (GenerationResponse, error)
DecodeGeneration adapts response naming only; billing and media decisions stay server-side.
func GetGeneration ¶
func GetGeneration(backendURL, id, accessToken, client, uid string) (GenerationResponse, error)
GetGeneration polls a direct generation by id. GET /api/v1/ai/generations/:id.
type HTTPError ¶ added in v0.2.10
HTTPError preserves the response status and safe response body for callers that need to distinguish a rejected request from an ambiguous transport failure.
type MessagesResponse ¶
type MessagesResponse struct {
Answers []Answer `json:"answers"`
Raw json.RawMessage `json:"-"`
}
func GetMessages ¶
func GetMessages(backendURL, accessToken, client, uid string, messageIDs []string) (MessagesResponse, error)
GetMessages fetches messages from the API and returns them
type NotificationsCountResponse ¶
type NotificationsCountResponse struct {
NumNotifications *int `json:"num_noti"`
ClientVersion int `json:"client_version"`
Raw json.RawMessage `json:"-"`
}
func GetNotificationsCount ¶
type NotificationsResponse ¶
type NotificationsResponse struct {
Quests []Quest `json:"quests"`
PinnedQuest *Quest `json:"pinned_quest"`
Raw json.RawMessage `json:"-"`
}
type PollOptionPayload ¶
type Quest ¶
type Quest struct {
SideQuest bool `json:"side_quest"`
ID string `json:"id"`
TeamID string `json:"team_id"`
Public *bool `json:"public"`
Private *bool `json:"private"`
IsClip *bool `json:"is_clip"`
ThreadType string `json:"thread_type"`
SpaceID string `json:"space_id"`
UserID string `json:"user_id"`
Content string `json:"content"`
Path string `json:"path"`
QuestURL string `json:"quest_url"`
ParentID string `json:"parent_id"`
NotificationReasonLabel string `json:"notification_reason_label"`
SortedAnswerIDs []string `json:"sorted_answer_ids"`
MatchingAnswerIDs []string `json:"matching_answer_ids"`
Parent *Answer `json:"parent"`
SortedAnswers []Answer `json:"sorted_answers"`
}
type ResolvedMediaLink ¶
func ResolveAnswerMediaLinks ¶
func ResolveAnswerMediaLinks(answer Answer, fallbackBase string) []ResolvedMediaLink
type StripeAiBillingCheckoutResponse ¶ added in v0.2.2
type StripeAiBillingCheckoutResponse struct {
URL string `json:"url"`
Raw json.RawMessage `json:"-"`
}
StripeAiBillingCheckoutResponse is returned by POST /api/v1/stripe_ai_billing/checkout.
func CreateStripeAiBillingCheckoutSession ¶ added in v0.2.2
func CreateStripeAiBillingCheckoutSession(backendURL, accessToken, client, uid string) (StripeAiBillingCheckoutResponse, error)
type StripeAiBillingStatusResponse ¶ added in v0.2.2
type StripeAiBillingStatusResponse struct {
Stripe StripeAiBillingStripe `json:"stripe"`
Usage StripeAiBillingUsage `json:"usage"`
Raw json.RawMessage `json:"-"`
}
StripeAiBillingStatusResponse is returned by GET /api/v1/stripe_ai_billing/status.
func GetStripeAiBillingStatus ¶ added in v0.2.2
func GetStripeAiBillingStatus(backendURL, accessToken, client, uid string, refresh bool) (StripeAiBillingStatusResponse, error)
type StripeAiBillingStripe ¶ added in v0.2.2
type StripeAiBillingStripe struct {
CustomerID string `json:"customer_id"`
SubscriptionID string `json:"subscription_id"`
SubscriptionStatus string `json:"subscription_status"`
AIPaymentMode string `json:"ai_payment_mode"`
MeteredLockedAt string `json:"metered_locked_at"`
MeteredLockReason string `json:"metered_lock_reason"`
RefreshedAt string `json:"refreshed_at"`
}
type StripeAiBillingSyncResponse ¶ added in v0.2.2
type StripeAiBillingSyncResponse struct {
OK bool `json:"ok"`
Raw json.RawMessage `json:"-"`
}
StripeAiBillingSyncResponse is returned by GET /api/v1/stripe_ai_billing/sync.
func SyncStripeAiBillingCheckoutSession ¶ added in v0.2.2
func SyncStripeAiBillingCheckoutSession(backendURL, accessToken, client, uid, sessionID string) (StripeAiBillingSyncResponse, error)
type StripeAiBillingUsEvent ¶ added in v0.2.2
type StripeAiBillingUsage ¶ added in v0.2.2
type StripeAiBillingUsage struct {
UnpaidTotalCents int64 `json:"unpaid_total_cents"`
TotalsCentsByStatus map[string]int64 `json:"totals_cents_by_status"`
Events []StripeAiBillingUsEvent `json:"events"`
}
type StripeAiPaymentModeResponse ¶ added in v0.2.2
type StripeAiPaymentModeResponse struct {
OK bool `json:"ok"`
AIPaymentMode string `json:"ai_payment_mode"`
Raw json.RawMessage `json:"-"`
}
StripeAiPaymentModeResponse is returned by POST /api/v1/stripe_ai_billing/mode.
func SetStripeAiPaymentMode ¶ added in v0.2.2
func SetStripeAiPaymentMode(backendURL, accessToken, client, uid, mode string) (StripeAiPaymentModeResponse, error)
type TeamsResponse ¶
type TeamsResponse struct {
Teams []TeamRef `json:"teams"`
Raw json.RawMessage `json:"-"`
}
func ListPublicTeams ¶
type ThreadListOptions ¶ added in v0.2.7
ThreadListOptions describes an authored, creation-ordered collection.
type ThreadPagination ¶ added in v0.2.7
type ThreadResponse ¶
type ThreadResponse struct {
Quest Quest `json:"quest"`
Raw json.RawMessage `json:"-"`
}
func GetThread ¶
func GetThread(backendURL, threadID, accessToken, client, uid string) (ThreadResponse, error)
type ThreadsResponse ¶ added in v0.2.7
type ThreadsResponse struct {
Threads []Quest `json:"threads"`
Pagination *ThreadPagination `json:"pagination,omitempty"`
Raw json.RawMessage `json:"-"`
}
func ListThreads ¶ added in v0.2.7
func ListThreads(backendURL, accessToken, client, uid string, options ThreadListOptions) (ThreadsResponse, error)
func ThreadsForAnswer ¶ added in v0.2.7
func ThreadsForAnswer(backendURL, accessToken, client, uid, answerID string) (ThreadsResponse, error)
ThreadsForAnswer preserves complete thread payloads and server-side visibility.
type ToolDefinition ¶ added in v0.2.13
type ToolDefinition map[string]interface{}
ToolDefinition preserves the backend-owned schema and annotations without a second model/option registry in the CLI.
type ToolList ¶ added in v0.2.13
type ToolList struct {
Tools []ToolDefinition `json:"tools"`
}
type ToolResult ¶ added in v0.2.13
type UpvalueHistoryResponse ¶ added in v0.2.6
type UpvalueHistoryResponse struct {
Upvalues []BsvUpvalue `json:"upvalues"`
Page int `json:"page"`
PerPage int `json:"per_page"`
HasMore bool `json:"has_more"`
Raw json.RawMessage `json:"-"`
}
func GetUpvalueHistory ¶ added in v0.2.6
type UpvaluedContentLeaderboardItem ¶
type UpvaluedContentLeaderboardItem struct {
AnswerID string `json:"answer_id"`
QuestID string `json:"quest_id"`
QuestURL string `json:"quest_url"`
User User `json:"user"`
TotalSats int64 `json:"total_sats"`
UpvalueCount int `json:"upvalue_count"`
LastUpvalueAt string `json:"last_upvalue_at"`
Answer Answer `json:"answer"`
Quest Quest `json:"quest"`
}
type UpvaluedContentLeaderboardResponse ¶
type UpvaluedContentLeaderboardResponse struct {
Period struct {
StartDate string `json:"start_date"`
EndDate string `json:"end_date"`
} `json:"period"`
Limit int `json:"limit"`
Items []UpvaluedContentLeaderboardItem `json:"items"`
Raw json.RawMessage `json:"-"`
}