Restrict chat_sessions to server-owned sessions
chat_sessions now brokers GET /api/session but filters the global list to the sessions this server recorded in run_steps, deduped by session id, and fails closed to an empty list when no ownership source is configured. A session another client holds (in-server claim, released on stream end or disconnect) or an active run is marked busy; a second client's chat_prompt for a held session is rejected before any OpenCode call. chat_create stays unbrokered.
This commit is contained in:
@@ -115,6 +115,13 @@ func (c *Connection) Call(ctx context.Context, method, path string, body any) ([
|
||||
c.models[session.ID] = map[string]string{"providerID": request.Model["providerID"], "modelID": request.Model["id"]}
|
||||
return json.Marshal(map[string]any{"data": map[string]string{"id": session.ID}})
|
||||
}
|
||||
// The brokered chat session list is GET /api/session on the V2 HTTP API; the
|
||||
// native serve surface lists sessions at /session and returns a bare array,
|
||||
// which the adapter's tolerant decoder accepts. This keeps chat_sessions
|
||||
// working on the backend that currently enables brokered chat.
|
||||
if path == "/api/session" && method == "get" {
|
||||
return c.Native(ctx, "get", "/session", nil)
|
||||
}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user