| package proxy |
|
|
| import ( |
| "encoding/json" |
| "sync" |
| "time" |
| ) |
|
|
| |
|
|
| type Account struct { |
| mu sync.RWMutex |
| quotaObservationMu sync.Mutex |
| TokenV2 string `json:"token_v2"` |
| UserID string `json:"user_id"` |
| UserName string `json:"user_name"` |
| UserEmail string `json:"user_email"` |
| SpaceID string `json:"space_id"` |
| SpaceName string `json:"space_name"` |
| AccountID string `json:"account_id,omitempty"` |
| SpaceViewID string `json:"space_view_id"` |
| PlanType string `json:"plan_type"` |
| Timezone string `json:"timezone"` |
| ClientVersion string `json:"client_version"` |
| BrowserID string `json:"browser_id,omitempty"` |
| DeviceID string `json:"device_id,omitempty"` |
| FullCookie string `json:"full_cookie,omitempty"` |
| Models []ModelEntry `json:"available_models"` |
| |
| |
| |
| RegisteredVia string `json:"registered_via,omitempty"` |
| |
| QuotaExhaustedAt *time.Time `json:"-"` |
| QuotaInfo *QuotaInfo `json:"-"` |
| QuotaCheckedAt *time.Time `json:"-"` |
| PermanentlyExhausted bool `json:"-"` |
| quotaObservationSeen bool |
| quotaObservationInfo *QuotaInfo |
| |
| |
| |
| |
| |
| |
| |
| |
| SpaceCount int `json:"-"` |
| WorkspaceCheckedAt *time.Time `json:"-"` |
| } |
|
|
| |
| type QuotaInfo struct { |
| IsEligible bool `json:"isEligible"` |
| SpaceUsage int `json:"spaceUsage"` |
| SpaceLimit int `json:"spaceLimit"` |
| UserUsage int `json:"userUsage"` |
| UserLimit int `json:"userLimit"` |
| LastUsageAtMs int64 `json:"lastSpaceUsageAtMs"` |
| |
| ResearchModeUsage int `json:"researchModeUsage"` |
| |
| HasPremium bool `json:"hasPremium"` |
| PremiumBalance int `json:"premiumBalance"` |
| PremiumUsage int `json:"premiumUsage"` |
| PremiumLimit int `json:"premiumLimit"` |
| |
| |
| |
| |
| TotalCreditBalance int `json:"totalCreditBalance"` |
| CreditsInOverage int `json:"creditsInOverage"` |
| MonthlyAllocatedUsage int `json:"monthlyAllocatedUsage"` |
| MonthlyAllocatedLimit int `json:"monthlyAllocatedLimit"` |
| MonthlyCommittedUsage int `json:"monthlyCommittedUsage"` |
| MonthlyCommittedLimit int `json:"monthlyCommittedLimit"` |
| YearlyElasticUsage int `json:"yearlyElasticUsage"` |
| YearlyElasticLimit int `json:"yearlyElasticLimit"` |
| V2SpaceUsage int `json:"v2SpaceUsage"` |
| V2SpaceLimit int `json:"v2SpaceLimit"` |
| V2UserUsage int `json:"v2UserUsage"` |
| V2UserLimit int `json:"v2UserLimit"` |
| V2LastUsageAtMs int64 `json:"v2LastSpaceUsageAtMs"` |
| } |
|
|
| |
| type quotaV1Response struct { |
| IsEligible bool `json:"isEligible"` |
| ResearchModeUsage int `json:"researchModeUsage"` |
| SpaceUsage int `json:"spaceUsage"` |
| SpaceLimit int `json:"spaceLimit"` |
| UserUsage int `json:"userUsage"` |
| UserLimit int `json:"userLimit"` |
| LastSpaceUsageAtMs int64 `json:"lastSpaceUsageAtMs"` |
| } |
|
|
| |
| type quotaV2Response struct { |
| BasicCredits struct { |
| SpaceUsage int `json:"spaceUsage"` |
| SpaceLimit int `json:"spaceLimit"` |
| UserUsage int `json:"userUsage"` |
| UserLimit int `json:"userLimit"` |
| LastSpaceUsageAtMs int64 `json:"lastSpaceUsageAtMs"` |
| } `json:"basicCredits"` |
| PremiumCredits struct { |
| TotalCreditBalance int `json:"totalCreditBalance"` |
| CreditsInOverage int `json:"creditsInOverage"` |
| PerSource struct { |
| MonthlyAllocated struct { |
| UsageTotal int `json:"usageTotal"` |
| Limit int `json:"limit"` |
| } `json:"monthlyAllocated"` |
| MonthlyCommitted struct { |
| UsageTotal int `json:"usageTotal"` |
| Limit int `json:"limit"` |
| } `json:"monthlyCommitted"` |
| YearlyElastic struct { |
| UsageTotal int `json:"usageTotal"` |
| Limit int `json:"limit"` |
| } `json:"yearlyElastic"` |
| } `json:"perSource"` |
| } `json:"premiumCredits"` |
| } |
|
|
| type ModelEntry struct { |
| Name string `json:"name"` |
| ID string `json:"id"` |
| } |
|
|
| |
|
|
| type ChatMessage struct { |
| Role string `json:"role"` |
| Content string `json:"content"` |
| ToolCalls []ToolCall `json:"tool_calls,omitempty"` |
| ToolCallID string `json:"tool_call_id,omitempty"` |
| Name string `json:"name,omitempty"` |
| } |
|
|
| type Tool struct { |
| Type string `json:"type"` |
| Function ToolFunction `json:"function"` |
| } |
|
|
| type ToolFunction struct { |
| Name string `json:"name"` |
| Description string `json:"description,omitempty"` |
| Parameters interface{} `json:"parameters,omitempty"` |
| } |
|
|
| type ToolCall struct { |
| Index_ int `json:"index"` |
| ID string `json:"id"` |
| Type string `json:"type"` |
| Function ToolCallFunction `json:"function"` |
| } |
|
|
| type ToolCallFunction struct { |
| Name string `json:"name"` |
| Arguments string `json:"arguments"` |
| } |
|
|
| type UsageInfo struct { |
| PromptTokens int `json:"prompt_tokens"` |
| CompletionTokens int `json:"completion_tokens"` |
| TotalTokens int `json:"total_tokens"` |
| } |
|
|
| |
|
|
| type NotionInferenceRequest struct { |
| TraceID string `json:"traceId"` |
| SpaceID string `json:"spaceId"` |
| ThreadID string `json:"threadId,omitempty"` |
| Transcript []interface{} `json:"transcript"` |
| CreateThread bool `json:"createThread"` |
| GenerateTitle bool `json:"generateTitle"` |
| SaveAllThreadOperations bool `json:"saveAllThreadOperations"` |
| SetUnreadState bool `json:"setUnreadState"` |
| ThreadType string `json:"threadType"` |
| CreatedSource string `json:"createdSource,omitempty"` |
| AsPatchResponse bool `json:"asPatchResponse"` |
| PatchResponseVersion int `json:"patchResponseVersion,omitempty"` |
| IsPartialTranscript bool `json:"isPartialTranscript"` |
| IsUserInAnySalesAssistedSpace *bool `json:"isUserInAnySalesAssistedSpace,omitempty"` |
| IsSpaceSalesAssisted *bool `json:"isSpaceSalesAssisted,omitempty"` |
| SupportsCustomAgentNudgeTranscriptStep *bool `json:"supportsCustomAgentNudgeTranscriptStep,omitempty"` |
| ThreadParentPointer *ThreadParentPointer `json:"threadParentPointer,omitempty"` |
| DebugOverrides DebugOverrides `json:"debugOverrides"` |
| } |
|
|
| |
| type ThreadParentPointer struct { |
| Table string `json:"table"` |
| ID string `json:"id"` |
| SpaceID string `json:"spaceId"` |
| } |
|
|
| |
| |
| type UpdatedConfigMsg struct { |
| ID string `json:"id"` |
| Type string `json:"type"` |
| } |
|
|
| type TranscriptMsg struct { |
| Type string `json:"type"` |
| Value interface{} `json:"value"` |
| } |
|
|
| |
| type ResearcherTranscriptMsg struct { |
| ID string `json:"id"` |
| Type string `json:"type"` |
| Value interface{} `json:"value"` |
| UserID string `json:"userId,omitempty"` |
| CreatedAt string `json:"createdAt,omitempty"` |
| } |
|
|
| type DebugOverrides struct { |
| EmitAgentSearchExtractedResults bool `json:"emitAgentSearchExtractedResults,omitempty"` |
| CachedInferences *struct{} `json:"cachedInferences,omitempty"` |
| AnnotationInferences *struct{} `json:"annotationInferences,omitempty"` |
| EmitInferences *bool `json:"emitInferences,omitempty"` |
| } |
|
|
| type NDJSONEvent struct { |
| Type string `json:"type"` |
| } |
|
|
| type AgentInferenceEvent struct { |
| ID string `json:"id"` |
| Type string `json:"type"` |
| Value []AgentValueEntry `json:"value"` |
| FinishedAt *int64 `json:"finishedAt"` |
| InputTokens *int `json:"inputTokens"` |
| OutputTokens *int `json:"outputTokens"` |
| Model *string `json:"model"` |
| } |
|
|
| type AgentValueEntry struct { |
| Type string `json:"type"` |
| Content string `json:"content"` |
| Signature string `json:"signature,omitempty"` |
| |
| ID string `json:"id,omitempty"` |
| Name string `json:"name,omitempty"` |
| Input json.RawMessage `json:"input,omitempty"` |
| } |
|
|
| |
| type ThinkingBlock struct { |
| Content string |
| Signature string |
| } |
|
|
| |
| |
| |
| type ThinkingDeltaCallback func(delta string, done bool, signature string) |
|
|
| |
| |
| type CitationCandidate struct { |
| URL string |
| Title string |
| Text string |
| } |
|
|
| |
| type CallOptions struct { |
| NativeToolUses *[]AgentValueEntry |
| ThinkingBlocks *[]ThinkingBlock |
| EnableWebSearch bool |
| EnableWorkspaceSearch *bool |
| UseReadOnlyMode bool |
| ReasoningEffort string |
| Attachments []UploadedAttachment |
| IsResearcher bool |
| ThinkingCallback ThinkingDeltaCallback |
| KnownCitationURLs *[]string |
| KnownCitationDocs *[]CitationCandidate |
| KnownToolCallURLs *map[string][]string |
| Session *Session |
| RequestID string |
| ObservationKind string |
| } |
|
|
| |
|
|
| |
| |
| type ResearcherNextStepsEvent struct { |
| ID string `json:"id"` |
| Type string `json:"type"` |
| Done bool `json:"done"` |
| Value struct { |
| NextSteps []struct { |
| Agent string `json:"agent"` |
| Question string `json:"question"` |
| Key string `json:"key"` |
| SearchType string `json:"searchType"` |
| DisplayName string `json:"displayName"` |
| } `json:"nextSteps"` |
| UserQuestion string `json:"userQuestion"` |
| } `json:"value"` |
| |
| Output []ResearcherThinkingEntry `json:"output,omitempty"` |
| |
| RawOutput []ResearcherRawOutputEntry `json:"rawOutput,omitempty"` |
| } |
|
|
| |
| type ResearcherThinkingEntry struct { |
| Type string `json:"type"` |
| Content string `json:"content"` |
| } |
|
|
| |
| type ResearcherRawOutputEntry struct { |
| Type string `json:"type"` |
| Content string `json:"content"` |
| Signature string `json:"signature,omitempty"` |
| ModelProvider string `json:"modelProvider,omitempty"` |
| NotionModelName string `json:"notionModelName,omitempty"` |
| } |
|
|
| |
| type ResearcherAgentEvent struct { |
| ID string `json:"id"` |
| Type string `json:"type"` |
| Value struct { |
| Key string `json:"key"` |
| Agent string `json:"agent"` |
| Input json.RawMessage `json:"input,omitempty"` |
| TimestampStartMs int64 `json:"timestampStartMs"` |
| TimestampEndMs int64 `json:"timestampEndMs,omitempty"` |
| Status string `json:"status"` |
| Output json.RawMessage `json:"output,omitempty"` |
| } `json:"value"` |
| } |
|
|
| |
| |
| type ResearcherReportEvent struct { |
| ID string `json:"id"` |
| Type string `json:"type"` |
| Value string `json:"value"` |
| } |
|
|
| type PatchEvent struct { |
| Type string `json:"type"` |
| V []PatchOp `json:"v"` |
| } |
|
|
| type PatchOp struct { |
| O string `json:"o"` |
| P string `json:"p"` |
| V json.RawMessage `json:"v"` |
| } |
|
|
| |
|
|
| |
| |
| type FileAttachment struct { |
| Data []byte |
| FileName string |
| ContentType string |
| } |
|
|
| |
| |
| |
| type AttachmentTranscriptMsg struct { |
| Type string `json:"type"` |
| ID string `json:"id"` |
| FileUrl string `json:"fileUrl"` |
| FileName string `json:"fileName"` |
| ContentType string `json:"contentType"` |
| Metadata AttachmentMetadata `json:"metadata"` |
| } |
|
|
| type AttachmentMetadata struct { |
| NumRows int `json:"numRows,omitempty"` |
| NumFields int `json:"numFields,omitempty"` |
| TruncatedContent string `json:"truncatedContent"` |
| FileSizeBytes int64 `json:"fileSizeBytes"` |
| WasTruncated bool `json:"wasTruncated"` |
| EstimatedTokens map[string]interface{} `json:"estimatedTokens"` |
| AttachmentSource string `json:"attachmentSource"` |
| AiTraceId string `json:"aiTraceId,omitempty"` |
| Guardrail *AttachmentGuardrail `json:"guardrail,omitempty"` |
| Width int `json:"width,omitempty"` |
| Height int `json:"height,omitempty"` |
| ContentType string `json:"contentType,omitempty"` |
| Moderation map[string]interface{} `json:"moderation,omitempty"` |
| } |
|
|
| type AttachmentGuardrail struct { |
| AttachmentRisk string `json:"attachmentRisk"` |
| InferenceId string `json:"inferenceId,omitempty"` |
| } |
|
|
| |
| type NotionUploadURLRequest struct { |
| Name string `json:"name"` |
| ContentType string `json:"contentType"` |
| ContentLen int `json:"contentLength"` |
| CreateThread bool `json:"createThread"` |
| Pointer NotionAssistantChatPointer `json:"assistantChatTranscriptSessionPointer"` |
| } |
|
|
| type NotionAssistantChatPointer struct { |
| SpaceID string `json:"spaceId"` |
| Table string `json:"table"` |
| ID string `json:"id"` |
| } |
|
|
| |
| type NotionUploadURLResponse struct { |
| URL string `json:"url"` |
| SignedGetURL string `json:"signedGetUrl"` |
| SignedUploadPostURL string `json:"signedUploadPostUrl"` |
| Fields map[string]string `json:"fields"` |
| } |
|
|
| |
| type NotionEnqueueTaskRequest struct { |
| Task NotionTask `json:"task"` |
| } |
|
|
| type NotionTask struct { |
| EventName string `json:"eventName"` |
| Request NotionTaskRequest `json:"request"` |
| CellRouting NotionCellRouting `json:"cellRouting"` |
| } |
|
|
| type NotionTaskRequest struct { |
| URL string `json:"url"` |
| SpaceID string `json:"spaceId"` |
| AISessionPointer NotionAssistantChatPointer `json:"aiSessionPointer"` |
| Source string `json:"source"` |
| ClientVersion string `json:"clientVersion"` |
| } |
|
|
| type NotionCellRouting struct { |
| SpaceIDs []string `json:"spaceIds"` |
| } |
|
|
| |
| type NotionGetTasksRequest struct { |
| TaskIDs []string `json:"taskIds"` |
| } |
|
|
| |
| type NotionGetTasksResponse struct { |
| Results []NotionTaskResult `json:"results"` |
| } |
|
|
| type NotionTaskResult struct { |
| ID string `json:"id"` |
| State string `json:"state"` |
| } |
|
|
| |
| type UploadedAttachment struct { |
| AttachmentURL string |
| FileName string |
| ContentType string |
| FileSizeBytes int64 |
| SessionID string |
| Metadata *AttachmentMetadata |
| } |
|
|