Merge branch 'worktree-agent-a82ec64b6cc1a2809'
# Conflicts: # internal/app/archie/operations.go # modules/events/events.go # modules/governance/accounts_api.go # modules/governance/governance.go
This commit is contained in:
44 files changed
+1462
-266
No files matched your search
@@ -356,7 +356,7 @@ func chatServer(t *testing.T, session, turn uuid.UUID) *httptest.Server {
|
||||
wake: make(chan struct{}, 1), running: map[uuid.UUID]context.CancelFunc{},
|
||||
}
|
||||
mux := http.NewServeMux()
|
||||
m.Register(httpapi.New(mux, "test", headerAuth{}))
|
||||
m.Register(httpapi.New(mux, "test", headerAuth{}, allowAll{}))
|
||||
srv := httptest.NewServer(mux)
|
||||
t.Cleanup(srv.Close)
|
||||
return srv
|
||||
@@ -569,3 +569,8 @@ func (f *fakeStore) EventsOf(context.Context, uuid.UUID, []string) ([]store.Even
|
||||
// noPrivilegedEffects is a declaration that states it has no privileged effect,
|
||||
// the only kind chat offers.
|
||||
var noPrivilegedEffects = connectors.PrivilegedEffects{Declared: true}
|
||||
|
||||
// allowAll leaves every decision to the handlers under test.
|
||||
type allowAll struct{}
|
||||
|
||||
func (allowAll) Allow(context.Context, string, string) error { return nil }
|
||||
+18
-18
@@ -28,40 +28,40 @@ const (
|
||||
// Register adds the chat API.
|
||||
func (m *Module) Register(api huma.API) {
|
||||
tags := []string{"Chat"}
|
||||
huma.Register(api, httpapi.SignedIn(huma.Operation{
|
||||
httpapi.Register(api, httpapi.Authorized(governance.ActionRead, governance.KindChatSession), huma.Operation{
|
||||
OperationID: "list-chat-sessions", Method: http.MethodGet, Path: "/api/chat/sessions",
|
||||
Summary: "List conversations, most recently active first, with the model that answers", Tags: tags,
|
||||
}), m.listSessions)
|
||||
huma.Register(api, httpapi.SignedIn(huma.Operation{
|
||||
}, m.listSessions)
|
||||
httpapi.Register(api, httpapi.Authorized(governance.ActionCreate, governance.KindChatSession), huma.Operation{
|
||||
OperationID: "create-chat-session", Method: http.MethodPost, Path: "/api/chat/sessions",
|
||||
Summary: "Start a conversation", Tags: tags, DefaultStatus: http.StatusCreated,
|
||||
}), m.createSession)
|
||||
huma.Register(api, httpapi.SignedIn(huma.Operation{
|
||||
}, m.createSession)
|
||||
httpapi.Register(api, httpapi.Authorized(governance.ActionUpdate, governance.KindChatSession), huma.Operation{
|
||||
OperationID: "rename-chat-session", Method: http.MethodPatch, Path: "/api/chat/sessions/{id}",
|
||||
Summary: "Rename a conversation", Tags: tags,
|
||||
}), m.renameSession)
|
||||
huma.Register(api, httpapi.SignedIn(huma.Operation{
|
||||
}, m.renameSession)
|
||||
httpapi.Register(api, httpapi.Authorized(governance.ActionDelete, governance.KindChatSession), huma.Operation{
|
||||
OperationID: "delete-chat-session", Method: http.MethodDelete, Path: "/api/chat/sessions/{id}",
|
||||
Summary: "Delete a conversation and its turns", Tags: tags, DefaultStatus: http.StatusNoContent,
|
||||
}), m.deleteSession)
|
||||
huma.Register(api, httpapi.SignedIn(huma.Operation{
|
||||
}, m.deleteSession)
|
||||
httpapi.Register(api, httpapi.Authorized(governance.ActionRead, governance.KindChatSession), huma.Operation{
|
||||
OperationID: "list-chat-turns", Method: http.MethodGet, Path: "/api/chat/sessions/{id}/turns",
|
||||
Summary: "List a conversation's turns with what each did", Tags: tags,
|
||||
}), m.listTurns)
|
||||
huma.Register(api, httpapi.SignedIn(huma.Operation{
|
||||
}, m.listTurns)
|
||||
httpapi.Register(api, httpapi.Authorized(governance.ActionCreate, governance.KindChatSession), huma.Operation{
|
||||
OperationID: "send-chat-turn", Method: http.MethodPost, Path: "/api/chat/sessions/{id}/turns",
|
||||
Summary: "Send a message; it is stored, then answered after the turns before it", Tags: tags,
|
||||
DefaultStatus: http.StatusAccepted,
|
||||
}), m.sendTurn)
|
||||
huma.Register(api, httpapi.SignedIn(huma.Operation{
|
||||
}, m.sendTurn)
|
||||
httpapi.Register(api, httpapi.Authorized(governance.ActionRead, governance.KindChatSession), huma.Operation{
|
||||
OperationID: "get-chat-turn", Method: http.MethodGet, Path: "/api/chat/turns/{id}",
|
||||
Summary: "Get one turn with what it did", Tags: tags,
|
||||
}), m.getTurn)
|
||||
huma.Register(api, httpapi.SignedIn(huma.Operation{
|
||||
}, m.getTurn)
|
||||
httpapi.Register(api, httpapi.Authorized(governance.ActionUpdate, governance.KindChatSession), huma.Operation{
|
||||
OperationID: "cancel-chat-turn", Method: http.MethodPost, Path: "/api/chat/turns/{id}/cancel",
|
||||
Summary: "Stop a turn that is queued or running", Tags: tags,
|
||||
}), m.cancelTurn)
|
||||
huma.Register(api, httpapi.SignedIn(huma.Operation{
|
||||
}, m.cancelTurn)
|
||||
httpapi.Register(api, httpapi.Authorized(governance.ActionRead, governance.KindChatSession), huma.Operation{
|
||||
OperationID: "stream-chat-turn", Method: http.MethodGet, Path: "/api/chat/turns/{id}/events",
|
||||
Summary: "Stream what a turn records, from a cursor, until it ends", Tags: tags,
|
||||
Responses: map[string]*huma.Response{"200": {
|
||||
@@ -70,7 +70,7 @@ func (m *Module) Register(api huma.API) {
|
||||
"the stream ends after done, error or cancelled.",
|
||||
Content: map[string]*huma.MediaType{"text/event-stream": {Schema: &huma.Schema{Type: huma.TypeString}}},
|
||||
}},
|
||||
}), m.streamTurn)
|
||||
}, m.streamTurn)
|
||||
}
|
||||
|
||||
// Sessions is the conversation list with the model that answers turns.
|
||||
|
||||
Reference in new issue
Block a user