A per-DataDir background process owns ticket JSON, history, and sync so multiple TUI instances stay consistent; MCP token APIs are ready for phase 2. Co-authored-by: Cursor <cursoragent@cursor.com>
48 lines
1.6 KiB
Go
48 lines
1.6 KiB
Go
package client
|
|
|
|
import (
|
|
"net/http"
|
|
"net/url"
|
|
|
|
"task/internal/ytsync"
|
|
)
|
|
|
|
// SyncPull runs daemon sync pull for projectID.
|
|
func (c *Client) SyncPull(projectID string) (ytsync.Result, error) {
|
|
var out ytsync.Result
|
|
err := c.do(http.MethodPost, "/v1/sync/pull", map[string]string{"projectId": projectID}, &out)
|
|
return out, err
|
|
}
|
|
|
|
// SyncPush runs daemon sync push for projectID.
|
|
func (c *Client) SyncPush(projectID string) (ytsync.Result, error) {
|
|
var out ytsync.Result
|
|
err := c.do(http.MethodPost, "/v1/sync/push", map[string]string{"projectId": projectID}, &out)
|
|
return out, err
|
|
}
|
|
|
|
// CreateMCPToken creates a new MCP token for projectID (plaintext once).
|
|
func (c *Client) CreateMCPToken(projectID string) (token, createdAt string, err error) {
|
|
var out struct {
|
|
Token string `json:"token"`
|
|
CreatedAt string `json:"createdAt"`
|
|
}
|
|
err = c.do(http.MethodPost, "/v1/projects/"+url.PathEscape(projectID)+"/mcp-token", map[string]any{}, &out)
|
|
return out.Token, out.CreatedAt, err
|
|
}
|
|
|
|
// RevokeMCPToken removes the MCP token for projectID.
|
|
func (c *Client) RevokeMCPToken(projectID string) error {
|
|
return c.do(http.MethodDelete, "/v1/projects/"+url.PathEscape(projectID)+"/mcp-token", nil, nil)
|
|
}
|
|
|
|
// MCPTokenStatus returns whether a token is configured.
|
|
func (c *Client) MCPTokenStatus(projectID string) (configured bool, createdAt string, err error) {
|
|
var out struct {
|
|
Configured bool `json:"configured"`
|
|
CreatedAt string `json:"createdAt"`
|
|
}
|
|
err = c.do(http.MethodGet, "/v1/projects/"+url.PathEscape(projectID)+"/mcp-token", nil, &out)
|
|
return out.Configured, out.CreatedAt, err
|
|
}
|