Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/paywallai/paywallai.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ type InputAttachment struct {
DataBase64 string `json:"data_base64"`
}

// editorSource tags CLI traffic so the editor can report it.
const editorSource = "cli"

// EditorRequest is the POST /editor/v1/stream body. UIConfig, SessionItems,
// and AppContext are opaque server round-trips.
type EditorRequest struct {
Expand All @@ -61,6 +64,7 @@ type EditorRequest struct {
SessionItems json.RawMessage `json:"__unstable_session_items"`
AppContext json.RawMessage `json:"app_context,omitempty"`
IncludeResultScreenshots bool `json:"include_result_screenshots,omitempty"`
Source string `json:"source"`
}

type ToolActivity struct {
Expand Down Expand Up @@ -207,6 +211,7 @@ func errorMessage(body []byte) string {

// Stream starts an editor run and returns the live event stream.
func (c *Client) Stream(ctx context.Context, request EditorRequest) (*Stream, error) {
request.Source = editorSource
req, err := c.newRequest(ctx, "/editor/v1/stream", request)
if err != nil {
return nil, err
Expand Down Expand Up @@ -242,6 +247,7 @@ func (c *Client) Feedback(ctx context.Context, sessionID, traceID, rating string
"session_id": sessionID,
"trace_id": traceID,
"rating": rating,
"source": editorSource,
})
}

Expand Down
6 changes: 6 additions & 0 deletions internal/paywallai/paywallai_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func TestStreamDecodesEvents(t *testing.T) {
if gotBody["message"] != "make it blue" {
t.Errorf("message = %v", gotBody["message"])
}
if gotBody["source"] != "cli" {
t.Errorf("source = %v", gotBody["source"])
}
if _, present := gotBody["__unstable_session_items"]; !present {
t.Error("__unstable_session_items missing")
}
Expand Down Expand Up @@ -129,6 +132,9 @@ func TestFeedbackAndRewind(t *testing.T) {
if body["session_id"] != "sess1" {
t.Errorf("session_id = %v", body["session_id"])
}
if r.URL.Path == "/editor/v1/feedback" && body["source"] != "cli" {
t.Errorf("feedback source = %v", body["source"])
}
}))
defer server.Close()
client := NewClient(Options{BaseURL: server.URL, Token: "tok"})
Expand Down
Loading