Poll OpenCode permission requests and forward chat_reply
This commit is contained in:
@@ -116,6 +116,16 @@ func (c *Connection) Call(ctx context.Context, method, path string, body any) ([
|
||||
return json.Marshal(map[string]any{"data": map[string]string{"id": session.ID}})
|
||||
}
|
||||
clean := strings.SplitN(path, "?", 2)[0]
|
||||
// The brokered approval surface is implemented against the V2 HTTP API: the
|
||||
// documented endpoints are GET /api/permission/request and POST
|
||||
// /api/session/{id}/permission/{requestID}/reply. This native serve
|
||||
// translation does not implement them, so answer with an actionable gate
|
||||
// error instead of the generic unsupported-operation error; the permission
|
||||
// poller surfaces that limitation rather than silently reporting no pending
|
||||
// requests.
|
||||
if clean == "/api/permission/request" {
|
||||
return nil, fmt.Errorf("permission listing: %w", ErrPermissionUnsupported)
|
||||
}
|
||||
parts := strings.Split(strings.TrimPrefix(clean, "/api/session/"), "/")
|
||||
if strings.HasPrefix(clean, "/api/experimental/session/") {
|
||||
parts = strings.Split(strings.TrimPrefix(clean, "/api/experimental/session/"), "/")
|
||||
@@ -124,6 +134,11 @@ func (c *Connection) Call(ctx context.Context, method, path string, body any) ([
|
||||
return nil, fmt.Errorf("unsupported native OpenCode operation")
|
||||
}
|
||||
id := parts[0]
|
||||
// The approval reply is V2-only in this translation (see the permission-list
|
||||
// gate above); the V2 path has four trailing segments.
|
||||
if len(parts) == 4 && parts[1] == "permission" && parts[3] == "reply" {
|
||||
return nil, fmt.Errorf("permission reply: %w", ErrPermissionUnsupported)
|
||||
}
|
||||
if len(parts) == 1 && method == "delete" {
|
||||
data, err := c.Native(ctx, "delete", "/session/"+id, nil)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user