Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-7782 feat(plugin-api): task transcript endpoint GET /v1/tasks/{task_id}/messages (#8914)
Cloud16ce2df18c32
diff --git a/server/cmd/server/router.go b/server/cmd/server/router.goindex ec1058da51..a1d632755f 100644--- a/server/cmd/server/router.go+++ b/server/cmd/server/router.go@@ -110,6 +110,7 @@ func registerPluginActionRoutes(r chi.Router, h *handler.Handler) {r.Patch(publicapiv1.PathIssue, h.PatchPluginIssue)r.Get(publicapiv1.PathIssueComments, h.ListPluginComments)r.Post(publicapiv1.PathIssueComments, h.CreatePluginComment)+ r.Get(publicapiv1.PathTaskMessages, h.ListPluginTaskMessages)r.Get(publicapiv1.PathStorageScope, h.ListPluginStorage)r.Get(publicapiv1.PathStorageValue, h.GetPluginStorage)r.Put(publicapiv1.PathStorageValue, h.PutPluginStorage)diff --git a/server/internal/handler/plugin_action.go b/server/internal/handler/plugin_action.goindex 6e55bf0ec0..dd59f7ad5c 100644--- a/server/internal/handler/plugin_action.go+++ b/server/internal/handler/plugin_action.go@@ -9,6 +9,7 @@ import ("strings""github.com/go-chi/chi/v5"+ "github.com/jackc/pgx/v5""github.com/jackc/pgx/v5/pgtype""github.com/multica-ai/multica/server/internal/middleware""github.com/multica-ai/multica/server/internal/service"@@ -409,6 +410,96 @@ func (h *Handler) PatchPluginIssue(w http.ResponseWriter, r *http.Request) {writeJSON(w, http.StatusOK, h.pluginIssuePayload(r, caller, updated))}+// ListPluginTaskMessages — GET /v1/tasks/{task_id}/messages+//+// The task-event twin of GetPluginIssue: task.completed/task.failed deliver a+// task id under the tasks:read grant, and this endpoint is what makes that+// grant worth something — the persisted run transcript (thinking, tool_use,+// tool_result, text, error) for memory/archive/audit plugins, so they no longer need+// a human PAT plus the CLI to read what an agent did.+//+// ?since=<seq> returns only messages after that sequence (incremental+// catch-up, same semantics as the daemon endpoint). ?include=thinking=false+// drops thinking messages for audit-style consumers; memory plugins want+// reasoning traces as distillation input, so they ship by default.+func (h *Handler) ListPluginTaskMessages(w http.ResponseWriter, r *http.Request) {+ caller, actor, ok := h.pluginCaller(w, r, plugincontract.ScopeTasksRead)+ if !ok {+ return+ }+ taskID := chi.URLParam(r, "task_id")+ parsed, err := util.ParseUUID(taskID)+ if err != nil {+ publicapiv1.WriteProblem(w, r, http.StatusNotFound, "not_found", "task not found")+ return+ }+ task, err := h.Queries.GetAgentTask(r.Context(), parsed)+ if err != nil {+ if errors.Is(err, pgx.ErrNoRows) {+ publicapiv1.WriteProblem(w, r, http.StatusNotFound, "not_found", "task not found")+ } else {+ publicapiv1.WriteProblem(w, r, http.StatusInternalServerError, "internal_error", "failed to load task")+ }+ return+ }+ scope, err := h.TaskService.ResolveTaskScopeChecked(r.Context(), task)+ if err != nil {+ publicapiv1.WriteProblem(w, r, http.StatusInternalServerError, "internal_error", "failed to resolve task scope")+ return+ }+ if scope.WorkspaceID != uuidToString(caller.WorkspaceID) {+ publicapiv1.WriteProblem(w, r, http.StatusNotFound, "not_found", "task not found")+ return+ }+ // Private transcripts require the session creator, even for workspace+ // admins. Plugin actors have no member authorization for private chats.+ if task.ChatSessionID.Valid && (!actor.isMember() ||+ scope.ChatSessionOwnerID == "" ||+ scope.ChatSessionOwnerID != uuidToString(actor.Member.UserID)) {+ publicapiv1.WriteProblem(w, r, http.StatusNotFound, "not_found", "task not found")+ return+ }+ // An issue-scoped grant reaches only tasks belonging to that issue.+ if caller.IssueScope.Valid && (!task.IssueID.Valid ||+ uuidToString(task.IssueID) != uuidToString(caller.IssueScope)) {+ publicapiv1.WriteProblem(w, r, http.StatusNotFound, "not_found", "task not found")+ return+ }++ var messages []db.TaskMessage+ if sinceStr := r.URL.Query().Get("since"); sinceStr != "" {+ sinceSeq, parseErr := strconv.Atoi(sinceStr)+ if parseErr != nil || sinceSeq < 0 {+ publicapiv1.WriteProblem(w, r, http.StatusBadRequest, "invalid_request", "invalid since parameter")+ return+ }+ messages, err = h.Queries.ListTaskMessagesSince(r.Context(), db.ListTaskMessagesSinceParams{+ TaskID: parsed,+ Seq: int32(sinceSeq),+ })+ } else {+ messages, err = h.Queries.ListTaskMessages(r.Context(), parsed)+ }+ if err != nil {+ publicapiv1.WriteProblem(w, r, http.StatusInternalServerError, "internal_error", "failed to list task messages")+ return+ }++ includeThinking := r.URL.Query().Get("include") != "thinking=false"+ issueID := ""+ if task.IssueID.Valid {+ issueID = uuidToString(task.IssueID)+ }+ resp := make([]protocol.TaskMessagePayload, 0, len(messages))+ for _, m := range messages {+ if !includeThinking && m.Type == "thinking" {+ continue+ }+ resp = append(resp, taskMessageToPayload(m, taskID, issueID))+ }+ writeJSON(w, http.StatusOK, map[string]any{"messages": resp})+}+func setPublicIssueETag(w http.ResponseWriter, revision int64) {w.Header().Set("ETag", fmt.Sprintf(`W/"%d"`, revision))}diff --git a/server/internal/handler/plugin_task_messages_test.go b/server/internal/handler/plugin_task_messages_test.gonew file mode 100644index 0000000000..f2646ae617--- /dev/null+++ b/server/internal/handler/plugin_task_messages_test.go@@ -0,0 +1,388 @@+package handler++import (+ "context"+ "encoding/json"+ db "github.com/multica-ai/multica/server/pkg/db/generated"+ publicapiv1 "github.com/multica-ai/multica/server/pkg/publicapi/v1"+ "gopkg.in/yaml.v3"+ "net/http"+ "net/http/httptest"+ "slices"+ "testing"++ "github.com/multica-ai/multica/server/internal/service"+ "github.com/multica-ai/multica/server/internal/testutil"+ "github.com/multica-ai/multica/server/pkg/plugincontract"+)++// The transcript endpoint, exercised through the paths that actually decide+// what a plugin may read: the tasks:read grant, the workspace the token's+// installation lives in, and the issue a callback grant narrows to.++const taskReaderPluginManifest = `{+ "manifest_version": 1,+ "key": "com.example.taskreader",+ "name": "Task Reader",+ "version": "1.0.0",+ "author": { "name": "example" },+ "scopes": ["tasks:read", "net:example.com"],+ "contributes": {+ "hooks": [{+ "key": "archive",+ "name": "Archive",+ "description": "Archive finished runs.",+ "triggers": ["event"],+ "events": ["task.completed"],+ "transport": { "type": "http", "url": "https://example.com/hooks/archive" }+ }]+ }+}`++func installTaskReaderPlugin(t *testing.T) string {+ t.Helper()+ versionID := withLocalPluginSource(t, taskReaderPluginManifest)+ body, _ := json.Marshal(map[string]any{+ "version_id": versionID,+ "granted_scopes": []string{"tasks:read", "net:example.com"},+ })+ recorder := httptest.NewRecorder()+ testHandler.InstallPlugin(recorder, pluginHandlerRequest(http.MethodPost, "/plugins", body, map[string]string{"id": testWorkspaceID}))+ if recorder.Code != http.StatusCreated {+ t.Fatalf("install task reader plugin: status=%d body=%s", recorder.Code, recorder.Body.String())+ }+ var installed struct {+ ID string `json:"id"`+ }+ if err := json.Unmarshal(recorder.Body.Bytes(), &installed); err != nil {+ t.Fatalf("decode installation: %v", err)+ }+ return installed.ID+}++// taskCallbackToken mints a callback grant the way a task.completed dispatch+// would: the archive hook, event trigger, and — when issueID is set — the+// issue-scoped narrowing a hook about one issue carries.+func taskCallbackToken(t *testing.T, installationID string, issueID string) string {+ t.Helper()+ installation, err := testHandler.PluginService.InstallationForWorkspace(+ context.Background(), parseUUID(testWorkspaceID), installationID)+ if err != nil {+ t.Fatalf("load installation: %v", err)+ }+ invocation := service.HookInvocation{+ Installation: installation,+ Hook: plugincontract.Hook{Key: "archive"},+ Trigger: plugincontract.TriggerEvent,+ Actor: service.HookActor{Type: "plugin", ID: parseUUID(installationID)},+ }+ if issueID != "" {+ invocation.IssueID = parseUUID(issueID)+ }+ token, err := testHandler.PluginService.Callbacks.Issue(context.Background(), invocation)+ if err != nil {+ t.Fatalf("issue callback token: %v", err)+ }+ return token+}++func pluginTaskMessagesRequest(token, taskID, query string) *http.Request {+ return callbackRequest(token, http.MethodGet, "/v1/tasks/"+taskID+"/messages"+query, nil,+ map[string]string{"task_id": taskID})+}++func seedTranscript(t *testing.T, label string) (taskID, issueID string) {+ t.Helper()+ taskID = seedBatchTask(t, label)+ task, err := testHandler.Queries.GetAgentTask(context.Background(), parseUUID(taskID))+ if err != nil || !task.IssueID.Valid {+ t.Fatalf("load seeded task: err=%v issue_valid=%v", err, task.IssueID.Valid)+ }+ issueID = uuidToString(task.IssueID)+ testutil.Call(t, testHandler.ReportTaskMessages, batchMessagesRequest(t, taskID, []any{+ map[string]any{"seq": 1, "type": "thinking", "content": "planning the run"},+ map[string]any{"seq": 2, "type": "tool_use", "tool": "fs_read",+ "input": map[string]any{"path": "/etc/hosts"}, "output": "127.0.0.1 localhost"},+ map[string]any{"seq": 3, "type": "text", "content": "done"},+ }))+ return taskID, issueID+}++type taskMessagesBody struct {+ Messages []struct {+ Content string `json:"content"`+ Seq int `json:"seq"`+ Type string `json:"type"`+ IssueID string `json:"issue_id"`+ } `json:"messages"`+}++func decodeTaskMessages(t *testing.T, recorder *httptest.ResponseRecorder) taskMessagesBody {+ t.Helper()+ var body taskMessagesBody+ if err := json.Unmarshal(recorder.Body.Bytes(), &body); err != nil {+ t.Fatalf("decode messages: %v (body=%s)", err, recorder.Body.String())+ }+ return body+}++func TestPluginTaskMessagesReturnsTranscriptInSeqOrder(t *testing.T) {+ if testHandler == nil {+ t.Skip("database not available")+ }+ withPluginsV1Flag(t, testHandler, true)+ cleanupPluginInstallations(t)+ withCallbackTokens(t)+ installationID := installTaskReaderPlugin(t)++ taskID, issueID := seedTranscript(t, "plugin-transcript")+ recorder := httptest.NewRecorder()+ testHandler.ListPluginTaskMessages(recorder, pluginTaskMessagesRequest(taskCallbackToken(t, installationID, ""), taskID, ""))+ if recorder.Code != http.StatusOK {+ t.Fatalf("status=%d body=%s", recorder.Code, recorder.Body.String())+ }+ body := decodeTaskMessages(t, recorder)+ if len(body.Messages) != 3 {+ t.Fatalf("messages = %d, want 3 (thinking ships by default)", len(body.Messages))+ }+ for i, want := range []string{"thinking", "tool_use", "text"} {+ if body.Messages[i].Type != want || body.Messages[i].Seq != i+1 {+ t.Fatalf("message[%d] = seq %d %s, want seq %d %s", i, body.Messages[i].Seq, body.Messages[i].Type, i+1, want)+ }+ }+ if body.Messages[0].IssueID != issueID {+ t.Fatalf("issue_id = %q, want %q", body.Messages[0].IssueID, issueID)+ }+}++func TestPluginTaskMessagesIncludeThinkingFalseDropsThinking(t *testing.T) {+ if testHandler == nil {+ t.Skip("database not available")+ }+ withPluginsV1Flag(t, testHandler, true)+ cleanupPluginInstallations(t)+ withCallbackTokens(t)+ installationID := installTaskReaderPlugin(t)++ taskID, _ := seedTranscript(t, "plugin-transcript-nothinking")+ recorder := httptest.NewRecorder()+ testHandler.ListPluginTaskMessages(recorder, pluginTaskMessagesRequest(taskCallbackToken(t, installationID, ""), taskID, "?include=thinking=false"))+ if recorder.Code != http.StatusOK {+ t.Fatalf("status=%d body=%s", recorder.Code, recorder.Body.String())+ }+ body := decodeTaskMessages(t, recorder)+ if len(body.Messages) != 2 || body.Messages[0].Type == "thinking" {+ t.Fatalf("messages = %+v, want the two non-thinking entries", body.Messages)+ }+}++func TestPluginTaskMessagesSinceReturnsOnlyNewer(t *testing.T) {+ if testHandler == nil {+ t.Skip("database not available")+ }+ withPluginsV1Flag(t, testHandler, true)+ cleanupPluginInstallations(t)+ withCallbackTokens(t)+ installationID := installTaskReaderPlugin(t)++ taskID, _ := seedTranscript(t, "plugin-transcript-since")+ recorder := httptest.NewRecorder()+ testHandler.ListPluginTaskMessages(recorder, pluginTaskMessagesRequest(taskCallbackToken(t, installationID, ""), taskID, "?since=1"))+ if recorder.Code != http.StatusOK {+ t.Fatalf("status=%d body=%s", recorder.Code, recorder.Body.String())+ }+ body := decodeTaskMessages(t, recorder)+ if len(body.Messages) != 2 || body.Messages[0].Seq != 2 {+ t.Fatalf("messages = %+v, want seq 2..3 only", body.Messages)+ }+}++// A callback grant issued about one issue must not reach another issue's+// tasks, even inside the same workspace — same 404-not-403 rule the issue+// endpoint uses, so the grant's reach is not observable by probing.+func TestPluginTaskMessagesIssueScopedGrant404sOtherIssue(t *testing.T) {+ if testHandler == nil {+ t.Skip("database not available")+ }+ withPluginsV1Flag(t, testHandler, true)+ cleanupPluginInstallations(t)+ withCallbackTokens(t)+ installationID := installTaskReaderPlugin(t)++ _, issueA := seedTranscript(t, "plugin-transcript-scope-a")+ taskB, _ := seedTranscript(t, "plugin-transcript-scope-b")++ recorder := httptest.NewRecorder()+ testHandler.ListPluginTaskMessages(recorder, pluginTaskMessagesRequest(taskCallbackToken(t, installationID, issueA), taskB, ""))+ if recorder.Code != http.StatusNotFound {+ t.Fatalf("status=%d body=%s, want 404 for an out-of-scope issue's task", recorder.Code, recorder.Body.String())+ }+}++func TestPluginTaskMessagesUnknownTask404s(t *testing.T) {+ if testHandler == nil {+ t.Skip("database not available")+ }+ withPluginsV1Flag(t, testHandler, true)+ cleanupPluginInstallations(t)+ withCallbackTokens(t)+ installationID := installTaskReaderPlugin(t)++ recorder := httptest.NewRecorder()+ testHandler.ListPluginTaskMessages(recorder, pluginTaskMessagesRequest(taskCallbackToken(t, installationID, ""),+ "00000000-0000-0000-0000-000000000000", ""))+ if recorder.Code != http.StatusNotFound {+ t.Fatalf("status=%d, want 404", recorder.Code)+ }+}++// tasks:read is the gate: an installation holding only the hooked-plugin+// fixture's scopes must not read transcripts.+func TestPluginTaskMessagesRequiresTasksReadScope(t *testing.T) {+ if testHandler == nil {+ t.Skip("database not available")+ }+ withPluginsV1Flag(t, testHandler, true)+ cleanupPluginInstallations(t)+ withCallbackTokens(t)+ installationID := installHookPlugin(t) // issues:read + comments:write, no tasks:read++ taskID, _ := seedTranscript(t, "plugin-transcript-scope-gate")+ recorder := httptest.NewRecorder()+ testHandler.ListPluginTaskMessages(recorder, pluginTaskMessagesRequest(taskCallbackToken(t, installationID, ""), taskID, ""))+ if recorder.Code == http.StatusOK {+ t.Fatalf("status=200 without tasks:read — scope gate broken (body=%s)", recorder.Body.String())+ }+}++func TestPluginTaskMessagesPrivateChatAuthorization(t *testing.T) {+ withPluginsV1Flag(t, testHandler, true)+ cleanupPluginInstallations(t)+ withCallbackTokens(t)+ installationID := installTaskReaderPlugin(t)+ runtimeID := dbfx.Runtime(t, "transcript privacy")+ agentID := dbfx.Agent(t, "transcript privacy", runtimeID)+ otherUser := dbfx.User(t, "transcript-other", "[email protected]")+ dbfx.Member(t, testWorkspaceID, otherUser, "admin")+ chatID := dbfx.ChatSession(t, agentID)+ taskID := dbfx.Task(t, agentID, testutil.Cols{"runtime_id": runtimeID, "chat_session_id": chatID})+ testutil.Call(t, testHandler.ReportTaskMessages, batchMessagesRequest(t, taskID, []any{+ map[string]any{"seq": 1, "type": "text", "content": "private chat content"},+ })).Want(http.StatusOK)+ installToken := rotateToken(t, installationID).Token++ for _, tc := range []struct {+ name, user, token string+ want int+ }{+ {"owner bridge", testUserID, "", http.StatusOK},+ {"non-owner admin bridge", otherUser, "", http.StatusNotFound},+ {"owner callback", "", issueCallbackToken(t, installationID, service.HookActor{Type: "member", ID: parseUUID(testUserID)}), http.StatusOK},+ {"non-owner admin callback", "", issueCallbackToken(t, installationID, service.HookActor{Type: "member", ID: parseUUID(otherUser)}), http.StatusNotFound},+ {"installation token", "", installToken, http.StatusNotFound},+ {"event callback", "", taskCallbackToken(t, installationID, ""), http.StatusNotFound},+ } {+ t.Run(tc.name, func(t *testing.T) {+ req := pluginTaskMessagesRequest(tc.token, taskID, "")+ if tc.user != "" {+ req.Header.Del("Authorization")+ req.Header.Set("X-User-ID", tc.user)+ req.Header.Set(pluginInstallationHeader, installationID)+ }+ testutil.Call(t, testHandler.ListPluginTaskMessages, req).Want(tc.want)+ })+ }+}++func TestPluginTaskMessagesIssueScopeRejectsTasksWithoutIssue(t *testing.T) {+ withPluginsV1Flag(t, testHandler, true)+ cleanupPluginInstallations(t)+ withCallbackTokens(t)+ installationID := installTaskReaderPlugin(t)+ issueTask, issueID := seedTranscript(t, "scoped transcript")+ token := taskCallbackToken(t, installationID, issueID)+ installation, err := testHandler.PluginService.InstallationForWorkspace(context.Background(), parseUUID(testWorkspaceID), installationID)+ if err != nil {+ t.Fatal(err)+ }+ memberToken, err := testHandler.PluginService.Callbacks.Issue(context.Background(), service.HookInvocation{+ Installation: installation, Hook: plugincontract.Hook{Key: "archive"},+ Trigger: plugincontract.TriggerManual, Actor: service.HookActor{Type: "member", ID: parseUUID(testUserID)},+ IssueID: parseUUID(issueID),+ })+ if err != nil {+ t.Fatal(err)+ }+ testutil.Call(t, testHandler.ListPluginTaskMessages, pluginTaskMessagesRequest(token, issueTask, "")).Want(http.StatusOK)+ runtimeID := dbfx.Runtime(t, "scope runtime")+ agentID := dbfx.Agent(t, "scope agent", runtimeID)+ chatID := dbfx.ChatSession(t, agentID)+ apID := dbfx.Insert(t, "autopilot", testutil.Cols{+ "workspace_id": testWorkspaceID, "title": "scope autopilot", "assignee_id": agentID,+ "status": "paused", "created_by_type": "member", "created_by_id": testUserID,+ })+ runID := dbfx.Insert(t, "autopilot_run", testutil.Cols{"autopilot_id": apID, "source": "manual", "status": "running"})+ for _, tc := range []struct{ name, column, id string }{+ {"chat", "chat_session_id", chatID}, {"autopilot", "autopilot_run_id", runID},+ } {+ t.Run(tc.name, func(t *testing.T) {+ taskID := dbfx.Task(t, agentID, testutil.Cols{"runtime_id": runtimeID, tc.column: tc.id})+ testutil.Call(t, testHandler.ListPluginTaskMessages, pluginTaskMessagesRequest(token, taskID, "")).Want(http.StatusNotFound)+ testutil.Call(t, testHandler.ListPluginTaskMessages, pluginTaskMessagesRequest(memberToken, taskID, "")).Want(http.StatusNotFound)+ })+ }+}++func TestPluginTaskMessagesLookupFailuresAreRetryable(t *testing.T) {+ withPluginsV1Flag(t, testHandler, true)+ cleanupPluginInstallations(t)+ withCallbackTokens(t)+ installationID := installTaskReaderPlugin(t)+ taskID, _ := seedTranscript(t, "lookup transcript")+ token := taskCallbackToken(t, installationID, "")+ for _, query := range []string{"GetAgentTask", "GetIssue"} {+ t.Run(query, func(t *testing.T) {+ fault := &lookupFaultPool{DBTX: testPool, query: query}+ h := *testHandler+ h.Queries = db.New(fault)+ h.TaskService = &service.TaskService{Queries: h.Queries}+ testutil.Call(t, h.ListPluginTaskMessages, pluginTaskMessagesRequest(token, taskID, "")).Want(http.StatusInternalServerError)+ if !fault.called {+ t.Fatal("lookup fault was not exercised")+ }+ })+ }+}++func TestPluginTaskMessagesFailedRunMatchesSchema(t *testing.T) {+ withPluginsV1Flag(t, testHandler, true)+ cleanupPluginInstallations(t)+ withCallbackTokens(t)+ installationID := installTaskReaderPlugin(t)+ taskID, _ := seedTranscript(t, "failed transcript")+ testutil.Call(t, testHandler.ReportTaskMessages, batchMessagesRequest(t, taskID, []any{+ map[string]any{"seq": 4, "type": "error", "content": "agent failed"},+ })).Want(http.StatusOK)+ dbfx.Exec(t, "UPDATE agent_task_queue SET status = 'failed' WHERE id = $1", taskID)+ var body taskMessagesBody+ testutil.Call(t, testHandler.ListPluginTaskMessages, pluginTaskMessagesRequest(taskCallbackToken(t, installationID, ""), taskID, "")).Want(http.StatusOK).JSON(&body)+ var doc struct {+ Components struct {+ Schemas map[string]struct {+ Properties map[string]struct{ Enum []string }+ }+ }+ }+ if err := yaml.Unmarshal(publicapiv1.OpenAPI(), &doc); err != nil {+ t.Fatal(err)+ }+ allowed := doc.Components.Schemas["TaskMessage"].Properties["type"].Enum+ if len(body.Messages) != 4 || body.Messages[3].Type != "error" || body.Messages[3].Content != "agent failed" {+ t.Fatalf("missing persisted error: %+v", body.Messages)+ }+ for _, message := range body.Messages {+ if !slices.Contains(allowed, message.Type) {+ t.Errorf("message type %q violates schema %v", message.Type, allowed)+ }+ }+}diff --git a/server/pkg/publicapi/v1/openapi.yaml b/server/pkg/publicapi/v1/openapi.yamlindex 856fa1fc76..8aaf1df1df 100644--- a/server/pkg/publicapi/v1/openapi.yaml+++ b/server/pkg/publicapi/v1/openapi.yaml@@ -108,6 +108,43 @@ paths:$ref: "#/components/schemas/Comment"default:$ref: "#/components/responses/Problem"+ /tasks/{task_id}/messages:+ parameters:+ - $ref: "#/components/parameters/TaskId"+ get:+ operationId: listTaskMessages+ summary: List the persisted run messages of one task in seq order+ description: >-+ The transcript companion to the task lifecycle events: plugins holding+ tasks:read can read what an agent actually did during a run (thinking,+ tool_use, tool_result, text, error) without a user PAT. ?since=<seq> returns+ only newer messages; ?include=thinking=false drops thinking messages.+ Private chat transcripts require a member credential for the session+ creator; plugin-only credentials cannot read them. Issue-scoped callbacks+ can read only tasks belonging to that issue. Missing or inaccessible+ tasks return 404; lookup failures return a retryable 500.+ x-multica-contract: shared_resource+ x-multica-scope: tasks:read+ parameters:+ - name: since+ in: query+ schema: { type: integer, minimum: 0 }+ description: Return only messages with seq greater than this value.+ - name: include+ in: query+ schema: { type: string, enum: [thinking, thinking=false] }+ description: >-+ thinking messages ship by default because memory plugins use them+ as distillation input; pass thinking=false to drop them.+ responses:+ "200":+ description: Task messages+ content:+ application/json:+ schema:+ $ref: "#/components/schemas/TaskMessageListResponse"+ default:+ $ref: "#/components/responses/Problem"/storage/{scope}:get:operationId: listPluginStorageKeys@@ -179,6 +216,12 @@ components:description: Issue UUID or workspace identifier such as MUL-123schema:type: string+ TaskId:+ name: task_id+ in: path+ required: true+ schema: { type: string, format: uuid }+ description: The task (run) whose persisted messages to list.StorageScope:name: scopein: path@@ -375,6 +418,31 @@ components:type: arrayitems:$ref: "#/components/schemas/Comment"+ TaskMessage:+ type: object+ required: [task_id, seq, type, created_at]+ properties:+ task_id: { type: string }+ issue_id:+ type: string+ description: Empty for chat and autopilot tasks that carry no issue.+ seq: { type: integer }+ type: { type: string, enum: [thinking, tool_use, tool_result, text, error] }+ tool: { type: string }+ call_id: { type: string }+ content: { type: string }+ input: { type: object, additionalProperties: true }+ output: { type: string }+ output_truncated: { type: boolean }+ created_at: { type: string, format: date-time }+ TaskMessageListResponse:+ type: object+ required: [messages]+ properties:+ messages:+ type: array+ items:+ $ref: "#/components/schemas/TaskMessage"CreateCommentRequest:type: objectrequired: [content]diff --git a/server/pkg/publicapi/v1/routes.go b/server/pkg/publicapi/v1/routes.goindex f0f39d94d3..361abe2f30 100644--- a/server/pkg/publicapi/v1/routes.go+++ b/server/pkg/publicapi/v1/routes.go@@ -14,6 +14,7 @@ const (PathContext = "/context"PathIssue = "/issues/{issue_ref}"PathIssueComments = "/issues/{issue_ref}/comments"+ PathTaskMessages = "/tasks/{task_id}/messages"PathStorageScope = "/storage/{scope}"PathStorageValue = "/storage/{scope}/{key}")@@ -60,6 +61,7 @@ var Operations = []Operation{{Method: http.MethodPatch, Path: PathIssue, Contract: ContractSharedResource, Policy: OperationPolicy{Credentials: sharedCredentials, Scope: "issues:write", Risk: RiskContentWrite, Audit: AuditPlanned, RateLimits: sharedRateLimits}},{Method: http.MethodGet, Path: PathIssueComments, Contract: ContractSharedResource, Policy: OperationPolicy{Credentials: sharedCredentials, Scope: "comments:read", Risk: RiskRead, Audit: AuditPlanned, RateLimits: sharedRateLimits}},{Method: http.MethodPost, Path: PathIssueComments, Contract: ContractSharedResource, Policy: OperationPolicy{Credentials: sharedCredentials, Scope: "comments:write", Risk: RiskContentWrite, Audit: AuditPlanned, RateLimits: sharedRateLimits}},+ {Method: http.MethodGet, Path: PathTaskMessages, Contract: ContractSharedResource, Policy: OperationPolicy{Credentials: sharedCredentials, Scope: "tasks:read", Risk: RiskRead, Audit: AuditPlanned, RateLimits: sharedRateLimits}},{Method: http.MethodGet, Path: PathStorageScope, Contract: ContractPluginExtension, Policy: OperationPolicy{Credentials: pluginCredentials, Risk: RiskRead, Audit: AuditNotRequired, RateLimits: pluginRateLimits}},{Method: http.MethodGet, Path: PathStorageValue, Contract: ContractPluginExtension, Policy: OperationPolicy{Credentials: pluginCredentials, Risk: RiskRead, Audit: AuditNotRequired, RateLimits: pluginRateLimits}},{Method: http.MethodPut, Path: PathStorageValue, Contract: ContractPluginExtension, Policy: OperationPolicy{Credentials: pluginCredentials, Risk: RiskContentWrite, Audit: AuditPlanned, RateLimits: pluginRateLimits}},