{"modulePath":"github.com/wavetermdev/waveterm","version":"v0.14.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sse\n\n## Constants\n\n```go\nconst (\n\tSSEContentType       = \"text/event-stream\"\n\tSSECacheControl      = \"no-cache\"\n\tSSEConnection        = \"keep-alive\"\n\tSSEKeepaliveMsg      = \": keepalive\\n\\n\"\n\tSSEStreamStartMsg    = \": stream-start\\n\\n\"\n\tSSEKeepaliveInterval = 1 * time.Second\n)\n```\n\n```go\nconst (\n\tAiMsgStart               = \"start\"\n\tAiMsgTextStart           = \"text-start\"\n\tAiMsgTextDelta           = \"text-delta\"\n\tAiMsgTextEnd             = \"text-end\"\n\tAiMsgReasoningStart      = \"reasoning-start\"\n\tAiMsgReasoningDelta      = \"reasoning-delta\"\n\tAiMsgReasoningEnd        = \"reasoning-end\"\n\tAiMsgToolInputStart      = \"tool-input-start\"\n\tAiMsgToolInputDelta      = \"tool-input-delta\"\n\tAiMsgToolInputAvailable  = \"tool-input-available\"\n\tAiMsgToolOutputAvailable = \"tool-output-available\" // not used here, but reserved\n\tAiMsgStartStep           = \"start-step\"\n\tAiMsgFinishStep          = \"finish-step\"\n\tAiMsgFinish              = \"finish\"\n\tAiMsgError               = \"error\"\n)\n```\nAI message type constants\n\n## Types\n\n```go\ntype SSEHandlerCh struct {\n\t// contains filtered or unexported fields\n}\n```\nSSEHandlerCh provides channel-based Server-Sent Events functionality\n\n```go\nfunc MakeSSEHandlerCh(w http.ResponseWriter, ctx context.Context) *SSEHandlerCh\n```\nMakeSSEHandlerCh creates a new channel-based SSE handler\n\n```go\nfunc (h *SSEHandlerCh) AiMsgData(dataType string, id string, data interface{}) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgError(errText string) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgFinish(finishReason string, usage interface{}) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgFinishStep() error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgReasoningDelta(reasoningId string, reasoning string) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgReasoningEnd(reasoningId string) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgReasoningStart(reasoningId string) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgStart(messageId string) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgStartStep() error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgTextDelta(textId string, text string) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgTextEnd(textId string) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgTextStart(textId string) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgToolInputAvailable(toolCallId, toolName string, input json.RawMessage) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgToolInputDelta(toolCallId, inputTextDelta string) error\n```\n\n```go\nfunc (h *SSEHandlerCh) AiMsgToolInputStart(toolCallId, toolName string) error\n```\n\n```go\nfunc (h *SSEHandlerCh) Close()\n```\nClose closes the write channel, sends \\[DONE], and cleans up resources\n\n```go\nfunc (h *SSEHandlerCh) Context() context.Context\n```\n\n```go\nfunc (h *SSEHandlerCh) Err() error\n```\nErr returns any error that occurred during writing\n\n```go\nfunc (h *SSEHandlerCh) RegisterOnClose(fn func()) string\n```\nRegisterOnClose registers a handler function to be called when the connection closes Returns an ID that can be used to unregister the handler\n\n```go\nfunc (h *SSEHandlerCh) SetupSSE() error\n```\nSetupSSE configures the response headers and starts the writer goroutine\n\n```go\nfunc (h *SSEHandlerCh) UnregisterOnClose(id string)\n```\nUnregisterOnClose removes a previously registered onClose handler by ID\n\n```go\nfunc (h *SSEHandlerCh) WriteComment(comment string) error\n```\nWriteComment queues an SSE comment\n\n```go\nfunc (h *SSEHandlerCh) WriteData(data string) error\n```\nWriteData queues data to be written in SSE format\n\n```go\nfunc (h *SSEHandlerCh) WriteError(errorMsg string) error\n```\nWriteError queues an error message and closes the handler\n\n```go\nfunc (h *SSEHandlerCh) WriteEvent(eventType, data string) error\n```\nWriteEvent queues an SSE event with optional event type\n\n```go\nfunc (h *SSEHandlerCh) WriteJsonData(data interface{}) error\n```\nWriteJsonData marshals data to JSON and queues it for writing\n\n```go\ntype SSEMessage struct {\n\tType      SSEMessageType\n\tData      string\n\tEventType string // Only used for SSEMsgEvent\n}\n```\nSSEMessage represents a message to be written to the SSE stream\n\n```go\ntype SSEMessageType string\n```\nSSEMessageType represents the type of message to write\n\n```go\nconst (\n\tSSEMsgData    SSEMessageType = \"data\"\n\tSSEMsgEvent   SSEMessageType = \"event\"\n\tSSEMsgComment SSEMessageType = \"comment\"\n\tSSEMsgError   SSEMessageType = \"error\"\n)\n```\n\n","path":"github.com/wavetermdev/waveterm/pkg/web/sse","name":"sse","synopsis":"","isRedistributable":true}
