Skip to content

feat(client): add InitClient for the deferred-init endpoints#243

Open
VascoSch92 wants to merge 2 commits into
mainfrom
vasco/init-client
Open

feat(client): add InitClient for the deferred-init endpoints#243
VascoSch92 wants to merge 2 commits into
mainfrom
vasco/init-client

Conversation

@VascoSch92

Copy link
Copy Markdown
Member

Summary

Split from #231 (one feature per PR). Adds client coverage for the warm-pool deferred-init endpoints that the audit reported as missing. Implementations follow the agent-server init router in OpenHands/software-agent-sdk (see software-agent-sdk#2523).

Endpoint Status before Change
GET /api/init missing new InitClient.getStatus()
POST /api/init missing new InitClient.initialize() (sends X-Init-API-Key)

Details

  • New src/client/init-client.ts wraps the deferred-init / warm-pool endpoints. POST /api/init authenticates with the bootstrap X-Init-API-Key header (distinct from the per-session X-Session-API-Key); it is omitted when no key is given.
  • Model types InitState / InitStatus / InitRequest added to models/api.ts and exported from index.ts.
  • InitClient exported from clients.ts and wired into ConversationManager as the init namespace (constructed and closed alongside the other clients).

Testing

  • Unit (src/__tests__/api-clients.test.ts, mocked fetch): init namespace wiring, getStatus GET, initialize POST (header + body present), and initialize omitting the header when no key is given.
  • Integration (deterministic-api.integration.test.ts): both routes return 404 on the non-deferred pinned image (get_init_service answers 404 when no InitService is registered) — proving the GET/POST routes exist on the image and the client targets the right path/method.
  • npm run build, lint (0 errors), and format:check pass; full unit suite green (273).

Adds coverage for the warm-pool deferred-init routes the client was
missing:

- GET /api/init  -> InitClient.getStatus()
- POST /api/init -> InitClient.initialize() (sends the bootstrap
  X-Init-API-Key header, distinct from the per-session key)

New src/client/init-client.ts, InitState/InitStatus/InitRequest model
types, exports from clients.ts and index.ts, and an `init` namespace on
ConversationManager. Includes unit tests (namespace wiring, getStatus,
initialize with and without the init key) and an integration contract
guard (both routes 404 on the non-deferred pinned image, proving the
paths/methods exist).
@github-actions github-actions Bot added the type: feat A new feature label Jun 29, 2026
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Endpoint audit

❌ 7 off-contract call(s) — not on the agent-server · classifiers: cloud

Category Count
❌ Off-contract (not on agent-server) 7
  ⛔ no known backend 6
  ↗️ served by cloud 1
➕ Missing API (agent-server has, client lacks) 5
agent-server endpoints 112
client endpoints 112

❌ Not on agent-server (gated, 7)

⛔ (no known backend) — served by no backend we can see (6)

  • DELETE /api/meta-profiles/{}
  • GET /api/meta-profiles
  • GET /api/meta-profiles/{}
  • POST /api/cloud-proxy
  • POST /api/meta-profiles/{}
  • POST /api/meta-profiles/{}/activate

↗️ served by cloud (1)

  • GET /api/shared-events/search

➕ Missing API — agent-server exposes it, client does not implement (5)

  • GET /
  • GET /api/conversations
  • GET /api/conversations/{}/events
  • GET /api/conversations/{}/workspace
  • GET /api/conversations/{}/workspace/{}

all-hands-bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review complete.

This review was performed through OpenHands Cloud Automation. You can log in and view the conversation here.

View the review on PR #243

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed this end-to-end. The implementation is small, idiomatic, and follows the conventions established by BashClient, HooksClient, etc. — HttpClient wrapper, host.replace(/\/$/, '') normalization, close() parity, model types colocated in models/api.ts, exposed via clients.ts and index.ts. The deferred-init integration test is genuinely useful: asserting 404 (not 405/422) proves both that the routes exist on the pinned image and that the client targets the right path/method — that's a real contract test, not a mock-pile. CI is green across all 11 checks. Two minor doc clarifications below; otherwise ready to merge.


This review was generated by an AI agent (OpenHands) on behalf of the user through OpenHands Automation. View conversation

Comment thread src/client/init-client.ts
Comment thread src/client/init-client.ts
@VascoSch92

Copy link
Copy Markdown
Member Author

@OpenHands address the comments and fix the conflicts.

@openhands-ai

openhands-ai Bot commented Jun 29, 2026

Copy link
Copy Markdown

I'm on it! VascoSch92 can track my progress at all-hands.dev

Resolve conflicts with main and clarify InitClient header behavior.

Co-authored-by: openhands <openhands@all-hands.dev>
@openhands-ai

openhands-ai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Done — PR #243 is updated: #243

Summary:

  • Merged latest main into vasco/init-client and resolved conflicts.
  • Addressed both inline review comments by clarifying InitClient header behavior:
    • InitClientOptions.apiKey maps to X-Session-API-Key through HttpClient.
    • InitializeOptions.initApiKey maps to X-Init-API-Key.
    • getStatus() docs now warn to omit apiKey for dormant warm-pool polling that must not send a session header.
  • Kept both new main-branch tests and the init-client tests during conflict resolution.
  • Committed and pushed 8e347cf to vasco/init-client.
  • Replied to and resolved both review threads.

Validation:

  • npm test -- --runInBand src/__tests__/api-clients.test.ts passed.
  • npm run build passed.
  • npm run lint passed with existing warnings only.
  • npm run format:check passed.
  • Full npm test -- --runInBand passed: 275 tests.
  • GitHub PR checks all passed: 11/11 successful.

Current PR state: conflicts are fixed; merge is still blocked only by required review (REVIEW_REQUIRED).

@VascoSch92 VascoSch92 requested a review from all-hands-bot June 29, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants