Skip to content

feat(cli): execute generated public API operations - #40

Merged
robinbraemer merged 4 commits into
mainfrom
feat/generated-public-executor
Aug 13, 2026
Merged

feat(cli): execute generated public API operations#40
robinbraemer merged 4 commits into
mainfrom
feat/generated-public-executor

Conversation

@robinbraemer

Copy link
Copy Markdown
Member

Summary

Closes #40. Makes every representable PUBLIC OpenAPI operation executable through the provider-neutral akua CLI.

  • Generates a static, type-preserving Effect dispatch artifact for all 232 current PUBLIC operations; no reflection or handwritten endpoint map.
  • Adds generic --input -|<file> request partitions (path, query, headers, body) with strict generated-schema validation and redacted diagnostics.
  • Uses the generated Effect HttpApi client with token isolation: anonymous operations never read or send a credential; protected operations correctly honor operation/root OpenAPI security.
  • Preserves HTTP status separately from server error codes and renders generated SSE operations incrementally with backpressure/cancellation.
  • Extends OpenAPI automation to regenerate and review all three generated artifacts.

Verification

  • bun install --frozen-lockfile from an empty cache
  • mise run generate:check
  • mise run check — 143 tests, 0 failures
  • strict Effect source scan and AST invariants
  • independent final review plus targeted follow-up review

Remaining contract dependency

agentEvents.stream is currently published as an untyped SSE 200 response. A separate Cnap producer fix is in progress; this PR does not add an endpoint-specific workaround.

Rationale: Agents and users need every PUBLIC OpenAPI operation executable without handwritten endpoints. The generated static dispatcher keeps requests, successes, structured status errors, anonymous authentication, and streaming responses aligned with the specification.

Rejected: Runtime OpenAPI reflection, dynamic property dispatch, provider-specific commands, and a handwritten endpoint map because they erase operation types or drift from OpenAPI.

Risk: The generated executor is large and changes with the public specification. Drift checks, completeness tests, strict schema decoding, and reproducible Effect patches constrain that risk.

Tested: BUN_INSTALL_CACHE_DIR=<empty temporary directory> bun install --frozen-lockfile
Tested: mise run generate:check
Tested: mise run check (135 tests, 0 failures, 695 assertions)
Tested: git diff --check
Tested: production source invariant scan for Promise/async/await/raw throw/TypeScript assertions
Not-tested: Live production mutation endpoints were not invoked; deterministic Fetch test layers cover request and response contracts.
Rationale: Anonymous PUBLIC operations must follow the OpenAPI security contract without resolving or leaking local credentials. Operation security now overrides root security, absent operation security inherits the root, and empty or anonymous alternatives remain unauthenticated.

Rejected: Allowing optional token attachment on anonymous operations because it reads user configuration unnecessarily and can make public calls fail or disclose credentials.

Risk: Future OpenAPI security changes alter generated command authentication metadata. Generator tests cover root inheritance, operation overrides, explicit empty security, and anonymous requirement alternatives.

Tested: bun test test/generate-commands.test.ts test/generated-command.test.ts
Tested: mise run build
Tested: mise run check (143 tests, 0 failures, 708 assertions)
Tested: Effect v4 production source scans
Tested: git diff --check
Not-tested: Live production API endpoints were not invoked; injected Fetch transport tests verify request headers and config isolation.
Rationale: The default login is a browser/device authorization flow; help must not imply that users need a pre-issued token.

Risk: Copy-only change in the human help view.

Tested: mise run check
Rationale: agents need executable help at the exact command they are about to run, rather than a generic home screen.

Risk: help routing changes only; command execution remains unchanged.

Tested: bun test test/cli.test.ts; bun run build; mise run check.
@robinbraemer
robinbraemer merged commit 255d9d6 into main Aug 13, 2026
2 checks passed
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