From 1dbce6a124ff54a76b5eb10be0d984809c7a7615 Mon Sep 17 00:00:00 2001 From: Nihal Date: Wed, 12 Aug 2026 22:05:21 +0530 Subject: [PATCH] feat: expose cloud activity and project controls Publish native agent activity, resumable launch context, and durable project update/delete operations while advancing the private Cloud implementation. Co-authored-by: Cursor --- contracts/cloud/openapi.yaml | 133 +++++++++++++++++++++- packages/cloud-client/src/client.ts | 34 +++++- packages/cloud-client/src/schema.ts | 118 ++++++++++++++++++- packages/cloud-client/src/types.ts | 4 + packages/cloud-client/test/client.test.ts | 63 ++++++++++ private/ao-cloud | 2 +- 6 files changed, 341 insertions(+), 13 deletions(-) diff --git a/contracts/cloud/openapi.yaml b/contracts/cloud/openapi.yaml index 6f27b8ff4e..6cf1ed5f7b 100644 --- a/contracts/cloud/openapi.yaml +++ b/contracts/cloud/openapi.yaml @@ -163,6 +163,45 @@ paths: $ref: "#/components/schemas/Project" default: $ref: "#/components/responses/Error" + /api/cloud/v1/orgs/{orgId}/projects/{projectId}: + parameters: + - $ref: "#/components/parameters/OrgId" + - $ref: "#/components/parameters/ProjectId" + patch: + operationId: updateProject + tags: [Projects] + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateProjectInput" + responses: + "200": + description: Project settings updated. + content: + application/json: + schema: + type: object + additionalProperties: false + required: [project] + properties: + project: + $ref: "#/components/schemas/Project" + default: + $ref: "#/components/responses/Error" + delete: + operationId: deleteProject + tags: [Projects] + responses: + "202": + description: Project archived and sandbox teardown accepted. + content: + application/json: + schema: + $ref: "#/components/schemas/DeleteProjectResponse" + default: + $ref: "#/components/responses/Error" /api/cloud/v1/orgs/{orgId}/github/installations: parameters: - $ref: "#/components/parameters/OrgId" @@ -785,9 +824,10 @@ paths: security: - workerAuth: [] description: | - Publishes one allowlisted event. `worker.ready` must identify the - authenticated worker and epoch. `chat.assistant_delta` is fenced by - both the token epoch and the claimed turn attempt. + Publishes one allowlisted event. `agent.activity` carries an explicit + coding-agent lifecycle hook signal. `worker.ready` must identify the + authenticated worker and epoch. `chat.assistant_delta` is fenced by both + the token epoch and the claimed turn attempt. requestBody: required: true content: @@ -1019,6 +1059,7 @@ paths: tags: [Worker Orchestration] security: - workerAuth: [] + description: Creates a trusted child by default and passes its required prompt directly to the coding-agent launch command. parameters: - $ref: "#/components/parameters/Cursor" - $ref: "#/components/parameters/Limit" @@ -1349,6 +1390,13 @@ components: schema: type: string format: uuid + ProjectId: + name: projectId + in: path + required: true + schema: + type: string + format: uuid SessionId: name: sessionId in: path @@ -1655,6 +1703,34 @@ components: config: type: object additionalProperties: true + UpdateProjectInput: + type: object + additionalProperties: false + required: [displayName, defaultBranch] + properties: + displayName: + type: string + minLength: 1 + maxLength: 120 + defaultBranch: + type: string + minLength: 1 + maxLength: 255 + DeleteProjectResponse: + type: object + additionalProperties: false + required: [project] + properties: + project: + type: object + additionalProperties: false + required: [id, deleted] + properties: + id: + type: string + format: uuid + deleted: + type: boolean ProjectPage: type: object additionalProperties: false @@ -1997,6 +2073,9 @@ components: type: string prompt: type: string + agentSessionId: + type: string + maxLength: 256 mode: $ref: "#/components/schemas/SessionMode" deniedCommands: @@ -2120,13 +2199,56 @@ components: const: chat.assistant_delta payload: $ref: "#/components/schemas/WorkerOutputPayload" + WorkerActivityPayload: + type: object + additionalProperties: false + required: [harness, event] + properties: + harness: + type: string + enum: [claude-code, codex, cursor] + event: + type: string + enum: + - session-start + - user-prompt-submit + - pre-tool-use + - post-tool-use + - post-tool-use-failure + - permission-request + - stop + - notification + - session-end + state: + $ref: "#/components/schemas/SessionActivityState" + toolName: + type: string + maxLength: 256 + toolUseId: + type: string + maxLength: 256 + agentSessionId: + type: string + maxLength: 256 + WorkerActivityEventInput: + type: object + additionalProperties: false + required: [type, payload] + properties: + type: + type: string + const: agent.activity + payload: + $ref: "#/components/schemas/WorkerActivityPayload" WorkerEventInput: oneOf: + - $ref: "#/components/schemas/WorkerActivityEventInput" - $ref: "#/components/schemas/WorkerReadyEventInput" - $ref: "#/components/schemas/WorkerOutputEventInput" discriminator: propertyName: type mapping: + agent.activity: "#/components/schemas/WorkerActivityEventInput" worker.ready: "#/components/schemas/WorkerReadyEventInput" chat.assistant_delta: "#/components/schemas/WorkerOutputEventInput" WorkerOKResponse: @@ -2222,7 +2344,7 @@ components: CreateWorkerChildInput: type: object additionalProperties: false - required: [harness, displayName] + required: [harness, displayName, prompt] properties: harness: type: string @@ -2234,6 +2356,7 @@ components: maxLength: 80 prompt: type: string + minLength: 1 maxLength: 65536 mode: $ref: "#/components/schemas/SessionMode" @@ -2703,7 +2826,7 @@ components: maxLength: 65536 mode: $ref: "#/components/schemas/SessionMode" - default: standard + default: trusted deniedCommands: type: array items: diff --git a/packages/cloud-client/src/client.ts b/packages/cloud-client/src/client.ts index 02bb5c2c79..0fc87991a7 100644 --- a/packages/cloud-client/src/client.ts +++ b/packages/cloud-client/src/client.ts @@ -9,6 +9,7 @@ import type { CreateProjectInput, CreateSessionInput, CurrentAccount, + DeleteProjectResponse, DeleteSessionResponse, ErrorEnvelope, EventReplayOptions, @@ -30,6 +31,7 @@ import type { SessionReviewState, TerminalKind, TerminalTicket, + UpdateProjectInput, UserMessageEvent, WorkerBootstrapInput, WorkerBootstrapResponse, @@ -72,7 +74,7 @@ export interface WorkerClientConfig { } interface JSONRequestOptions extends RequestOptions { - method?: "GET" | "POST" | "PUT" | "DELETE"; + method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE"; body?: unknown; idempotencyKey?: string; cache?: RequestCache; @@ -154,6 +156,36 @@ export class CloudClient { }); } + updateProject( + orgId: string, + projectId: string, + input: UpdateProjectInput, + options: RequestOptions = {}, + ): Promise<{ project: Project }> { + return this.request( + this.orgPath(orgId, `/projects/${encodeURIComponent(projectId)}`), + { + method: "PATCH", + body: input, + signal: options.signal, + }, + ); + } + + deleteProject( + orgId: string, + projectId: string, + options: RequestOptions = {}, + ): Promise { + return this.request( + this.orgPath(orgId, `/projects/${encodeURIComponent(projectId)}`), + { + method: "DELETE", + signal: options.signal, + }, + ); + } + getGitHubUserConnection( options: RequestOptions = {}, ): Promise { diff --git a/packages/cloud-client/src/schema.ts b/packages/cloud-client/src/schema.ts index d2acbf4ead..5c20256bd7 100644 --- a/packages/cloud-client/src/schema.ts +++ b/packages/cloud-client/src/schema.ts @@ -104,6 +104,25 @@ export interface paths { patch?: never; trace?: never; }; + "/api/cloud/v1/orgs/{orgId}/projects/{projectId}": { + parameters: { + query?: never; + header?: never; + path: { + orgId: components["parameters"]["OrgId"]; + projectId: components["parameters"]["ProjectId"]; + }; + cookie?: never; + }; + get?: never; + put?: never; + post?: never; + delete: operations["deleteProject"]; + options?: never; + head?: never; + patch: operations["updateProject"]; + trace?: never; + }; "/api/cloud/v1/orgs/{orgId}/github/installations": { parameters: { query?: never; @@ -568,9 +587,10 @@ export interface paths { }; get?: never; put?: never; - /** @description Publishes one allowlisted event. `worker.ready` must identify the - * authenticated worker and epoch. `chat.assistant_delta` is fenced by - * both the token epoch and the claimed turn attempt. + /** @description Publishes one allowlisted event. `agent.activity` carries an explicit + * coding-agent lifecycle hook signal. `worker.ready` must identify the + * authenticated worker and epoch. `chat.assistant_delta` is fenced by both + * the token epoch and the claimed turn attempt. * */ post: operations["publishWorkerEvent"]; delete?: never; @@ -710,6 +730,7 @@ export interface paths { path?: never; cookie?: never; }; + /** @description Creates a trusted child by default and passes its required prompt directly to the coding-agent launch command. */ get: operations["listWorkerChildren"]; put?: never; post: operations["createWorkerChild"]; @@ -970,6 +991,17 @@ export interface components { [key: string]: unknown; }; }; + UpdateProjectInput: { + displayName: string; + defaultBranch: string; + }; + DeleteProjectResponse: { + project: { + /** Format: uuid */ + id: string; + deleted: boolean; + }; + }; ProjectPage: { items: components["schemas"]["Project"][]; page: components["schemas"]["PageInfo"]; @@ -1118,6 +1150,7 @@ export interface components { displayName: string; branch: string; prompt: string; + agentSessionId?: string; mode: components["schemas"]["SessionMode"]; deniedCommands: string[]; /** Format: uri */ @@ -1186,7 +1219,25 @@ export interface components { type: "chat.assistant_delta"; payload: components["schemas"]["WorkerOutputPayload"]; }; - WorkerEventInput: components["schemas"]["WorkerReadyEventInput"] | components["schemas"]["WorkerOutputEventInput"]; + WorkerActivityPayload: { + /** @enum {string} */ + harness: "claude-code" | "codex" | "cursor"; + /** @enum {string} */ + event: "session-start" | "user-prompt-submit" | "pre-tool-use" | "post-tool-use" | "post-tool-use-failure" | "permission-request" | "stop" | "notification" | "session-end"; + state?: components["schemas"]["SessionActivityState"]; + toolName?: string; + toolUseId?: string; + agentSessionId?: string; + }; + WorkerActivityEventInput: { + /** + * @description discriminator enum property added by openapi-typescript + * @enum {string} + */ + type: "agent.activity"; + payload: components["schemas"]["WorkerActivityPayload"]; + }; + WorkerEventInput: components["schemas"]["WorkerActivityEventInput"] | components["schemas"]["WorkerReadyEventInput"] | components["schemas"]["WorkerOutputEventInput"]; WorkerOKResponse: { /** @constant */ ok: true; @@ -1227,7 +1278,7 @@ export interface components { CreateWorkerChildInput: { harness: string; displayName: string; - prompt?: string; + prompt: string; mode?: components["schemas"]["SessionMode"]; deniedCommands?: string[]; /** Format: uuid */ @@ -1452,7 +1503,7 @@ export interface components { harness: string; displayName: string; prompt: string; - /** @default standard */ + /** @default trusted */ mode: components["schemas"]["SessionMode"]; /** @default [] */ deniedCommands: string[]; @@ -1876,6 +1927,7 @@ export interface components { }; parameters: { OrgId: string; + ProjectId: string; SessionId: string; TurnId: string; WorkerRequestId: string; @@ -2093,6 +2145,60 @@ export interface operations { default: components["responses"]["Error"]; }; }; + deleteProject: { + parameters: { + query?: never; + header?: never; + path: { + orgId: components["parameters"]["OrgId"]; + projectId: components["parameters"]["ProjectId"]; + }; + cookie?: never; + }; + requestBody?: never; + responses: { + /** @description Project archived and sandbox teardown accepted. */ + 202: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": components["schemas"]["DeleteProjectResponse"]; + }; + }; + default: components["responses"]["Error"]; + }; + }; + updateProject: { + parameters: { + query?: never; + header?: never; + path: { + orgId: components["parameters"]["OrgId"]; + projectId: components["parameters"]["ProjectId"]; + }; + cookie?: never; + }; + requestBody: { + content: { + "application/json": components["schemas"]["UpdateProjectInput"]; + }; + }; + responses: { + /** @description Project settings updated. */ + 200: { + headers: { + [name: string]: unknown; + }; + content: { + "application/json": { + project: components["schemas"]["Project"]; + }; + }; + }; + default: components["responses"]["Error"]; + }; + }; listGitHubInstallations: { parameters: { query?: never; diff --git a/packages/cloud-client/src/types.ts b/packages/cloud-client/src/types.ts index 0ab55adfbc..ff8cab3282 100644 --- a/packages/cloud-client/src/types.ts +++ b/packages/cloud-client/src/types.ts @@ -19,6 +19,8 @@ export type AgentProfile = Schemas["AgentProfile"]; export type Project = Schemas["Project"]; export type CreateProjectInput = Schemas["CreateProjectInput"]; +export type UpdateProjectInput = Schemas["UpdateProjectInput"]; +export type DeleteProjectResponse = Schemas["DeleteProjectResponse"]; export type ProjectPage = Schemas["ProjectPage"]; export type GitHubInstallationStatus = Schemas["GitHubInstallationStatus"]; @@ -112,8 +114,10 @@ export type WorkerHeartbeatInput = Schemas["WorkerHeartbeatInput"]; export type WorkerHeartbeatResponse = Schemas["WorkerHeartbeatResponse"]; export type WorkerReadyPayload = Schemas["WorkerReadyPayload"]; export type WorkerOutputPayload = Schemas["WorkerOutputPayload"]; +export type WorkerActivityPayload = Schemas["WorkerActivityPayload"]; export type WorkerReadyEventInput = Schemas["WorkerReadyEventInput"]; export type WorkerOutputEventInput = Schemas["WorkerOutputEventInput"]; +export type WorkerActivityEventInput = Schemas["WorkerActivityEventInput"]; export type WorkerEventInput = Schemas["WorkerEventInput"]; export type WorkerOKResponse = Schemas["WorkerOKResponse"]; export type WorkerTurn = Schemas["WorkerTurn"]; diff --git a/packages/cloud-client/test/client.test.ts b/packages/cloud-client/test/client.test.ts index 8dfc0c1265..884e96dfb1 100644 --- a/packages/cloud-client/test/client.test.ts +++ b/packages/cloud-client/test/client.test.ts @@ -74,6 +74,69 @@ describe("CloudClient", () => { expect(fetchMock.mock.calls[0]?.[1]?.method).toBe("DELETE"); }); + it("updates editable project settings on the project resource", async () => { + const project = { + id: "project one", + orgId: "org one", + displayName: "Cloud API", + repositoryUrl: "https://github.com/acme/cloud", + defaultBranch: "develop", + config: {}, + createdAt: "2026-08-12T00:00:00Z", + updatedAt: "2026-08-12T01:00:00Z", + }; + const fetchMock = vi.fn( + async (_input: RequestInfo | URL, _init?: RequestInit) => + jsonResponse({ project }), + ); + const client = createCloudClient({ + baseUrl: "https://cloud.example.com", + getAccessToken: () => "access-token", + fetch: fetchMock as typeof fetch, + }); + + await expect( + client.updateProject("org one", "project one", { + displayName: "Cloud API", + defaultBranch: "develop", + }), + ).resolves.toEqual({ project }); + + expect(fetchMock.mock.calls[0]?.[0]).toBe( + "https://cloud.example.com/api/cloud/v1/orgs/org%20one/projects/project%20one", + ); + expect(fetchMock.mock.calls[0]?.[1]?.method).toBe("PATCH"); + expect(JSON.parse(String(fetchMock.mock.calls[0]?.[1]?.body))).toEqual({ + displayName: "Cloud API", + defaultBranch: "develop", + }); + }); + + it("requests durable project deletion on the project resource", async () => { + const fetchMock = vi.fn( + async (_input: RequestInfo | URL, _init?: RequestInit) => + jsonResponse( + { project: { id: "project one", deleted: true } }, + 202, + ), + ); + const client = createCloudClient({ + baseUrl: "https://cloud.example.com", + getAccessToken: () => "access-token", + fetch: fetchMock as typeof fetch, + }); + + await expect( + client.deleteProject("org one", "project one"), + ).resolves.toEqual({ + project: { id: "project one", deleted: true }, + }); + expect(fetchMock.mock.calls[0]?.[0]).toBe( + "https://cloud.example.com/api/cloud/v1/orgs/org%20one/projects/project%20one", + ); + expect(fetchMock.mock.calls[0]?.[1]?.method).toBe("DELETE"); + }); + it("lists runtime-supplied agent profiles for an organization", async () => { const profile: AgentProfile = { id: "runtime-agent", diff --git a/private/ao-cloud b/private/ao-cloud index f812185e79..3fd7bf40d1 160000 --- a/private/ao-cloud +++ b/private/ao-cloud @@ -1 +1 @@ -Subproject commit f812185e79cbc3dbe6e53b85fc09b368e1a29b77 +Subproject commit 3fd7bf40d1ae8a0a7a7172191779803d2903088a