Skip to content

feat(sdk): read the log of a build - #11

Merged
dada-sudo merged 1 commit into
mainfrom
feat/build-logs-stream
Nov 12, 2026
Merged

dada-sudo merged 1 commit into
mainfrom
feat/build-logs-stream

Conversation

@dada-sudo

@dada-sudo dada-sudo commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What

CloudApi.buildLogs(buildId, request) reads the output of one build, and the public spec gains the operation it calls, streamBuildLogs (GET /api/cloud/builds/{buildId}/logs).

A failed build carries a one-line reason (builds[].failureReason). Its log says the rest: which step, which package, which line. The API already serves that log to the console; it was missing from the public contract, so a client built on the SDK could only show the one line.

Contract, as the server implements it

  • Same contract as a service's logs: server-sent events, log ({ at, level, message, instance }, the event id is the cursor), then end; error with a code when the platform cannot serve the stream.
  • Without follow, the read is a tail: the newest lines, oldest first, 500 at most. Read from the start, it opens with one Build recipe: ... line that has no cursor and does not count towards limit.
  • With Last-Event-ID, the read resumes after that event, oldest first.
  • Authorisation: a member who may observe the build's project. Anything else answers 404 cloud.errors.builds.not_found: an unknown build, a build of another workspace, and a build whose service was removed.
  • A follow may answer 429 when the member or the workspace holds every live follow; a bounded read never does.

Changes

  • sdk/openapi/builds.yaml: the operation, in its own part file; one $ref line in the root spec.
  • sdk/src/logs.ts: LogRequest moves here from api.ts, next to the new BuildLogRequest (limit added) and the one function that turns a request into its query and headers. CloudApi.logs sends exactly what it sent before.
  • sdk/src/api.ts: buildLogs.
  • sdk/test/builds.test.ts: the request a bounded read, a resumed follow and a plain read send; the events yielded in order; onOpen before the first line; the 404 as a CloudApiError; and a service's log read unchanged.

Checked

  • pnpm --dir sdk test: 46 tests pass, 5 of them new.
  • Typecheck, lint, knip, size, ratchet and suppressions pass (pnpm run checks). On my Windows checkout three steps fail for reasons outside this change: the format check reads CRLF working files (the index is LF, and the changed files pass oxfmt --check), the CLI's Ctrl+C test expects exit code 130, and the sync check wants symlinks.
  • Read against a running AntelopeJS Cloud with a member token, read-only: a build of a live service answers 200 with the recipe line and the tail; an unknown build and a build of a removed service answer 404 cloud.errors.builds.not_found.

Release

Needs a release of @antelopejs/cloud-sdk before a client can depend on it.

A failed build carries a one-line reason; its log says the rest. The API
already serves it at GET /api/cloud/builds/{buildId}/logs, under the same
contract as a service's logs: server-sent log events with a cursor, a tail
of the newest lines when the read does not follow.

- spec: streamBuildLogs, in its own part file (builds.yaml)
- CloudApi.buildLogs(buildId, { follow, limit, lastEventId, onOpen })
- the request shapes move to logs.ts; a service's log read is unchanged

Co-Authored-By: Claude <noreply@anthropic.com>
@dada-sudo
dada-sudo merged commit a9cf229 into main Nov 12, 2026
8 checks passed
@dada-sudo
dada-sudo deleted the feat/build-logs-stream branch November 12, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant