Skip to content

feat(cli): add oxlint and adopt authoritative SDK types#21

Merged
LucasRoesler merged 7 commits intomainfrom
refactor/adopt-agent-sdk-types
Feb 26, 2026
Merged

feat(cli): add oxlint and adopt authoritative SDK types#21
LucasRoesler merged 7 commits intomainfrom
refactor/adopt-agent-sdk-types

Conversation

@LucasRoesler
Copy link
Member

Summary

  • Adopts types from @anthropic-ai/claude-agent-sdk to replace hand-rolled SDK type definitions, keeping HAPI in sync with the upstream CLI wire format
  • Adds oxlint to the CLI workspace and wires it into CI (test.yml) so it runs on every PR after typecheck
  • Fixes all 49 lint violations surfaced by the initial oxlint run (unused imports/variables, dead code, unnecessary spread fallbacks, empty catch bindings, escape and control-char regex issues)

Test plan

  • bun run typecheck passes
  • bun run lint passes with 0 warnings and 0 errors
  • bun run test passes (183 tests, 0 failures)
  • CI Tests job passes with the new lint step

Replace hand-rolled SDK types with the upstream package types. Key changes:
PermissionResult gains interrupt/updatedPermissions fields; SDKResultMessage
is split into SDKResultSuccess and SDKResultError; SDKSystemMessage now has
required fields; new message types added (SDKStatusMessage,
SDKCompactBoundaryMessage, etc.); CanUseTool callback receives full context
(suggestions, blockedPath, toolUseID, agentID); canCallTool renamed to
canUseTool; permissionHandler gains cancelPendingWithInterrupt().
Adds oxlint as a dev dependency in the CLI workspace with a `lint`
script. Wires it into the root package.json and the CI test workflow
so it runs on every PR after typecheck.

Fixes all 49 violations reported by the initial run: unused imports,
unused variables, dead code (codexRemoteLauncher helpers,
formatAskUserQuestionAnswers), unnecessary spread fallbacks, and two
no-control-regex suppressions for legitimate terminal escape sequences.
- QueryPrompt: narrow AsyncIterable<SDKMessage> to AsyncIterable<SDKUserMessage>
  to match the actual constraint of the SDK query() function
- SDKControlResponse: add missing response? field to match the wire format
- claudeRemote: fix misleading comment on the SDKMessage cast
@LucasRoesler LucasRoesler force-pushed the refactor/adopt-agent-sdk-types branch from 5d7026e to 3811e4f Compare February 24, 2026 17:19
Switches from `runner start` (detaches as daemon) to `runner start-sync`
(foreground) run as a background job, so both server and runner PIDs are
tracked and killed cleanly on Ctrl+C without needing `runner stop`.
@LucasRoesler LucasRoesler marked this pull request as ready for review February 24, 2026 17:56
Inline type imports (import('pkg').Type) in interface/type positions are
an anti-pattern. Hoists all occurrences to explicit top-level import type
statements for clarity and consistency.
…er objects

- ClaudeRemoteOptions: extracts the claudeRemote() opts parameter (9 fields)
- CanCallTool: names the HAPI-specific canCallTool signature (CanUseTool + EnhancedMode)
- SessionOptions: extracts the Session constructor opts (17 fields)
- LocalRemoteLoopOptions / LocalRemoteSessionOptions: extracts the two
  overlapping loop opts types in loopBase.ts, sharing fields via extension
- permissionHandler.handleToolCall: replaces the 6-field inline options
  object with Parameters<CanUseTool>[2], referencing the SDK type directly
- Replace Record<string, any> for mcpServers with McpServerConfig from
  the SDK (5 occurrences: loop.ts, session.ts x2, claudeRemote.ts,
  claudeLocal.ts); re-export McpServerConfig from sdk/types.ts and index.ts
- Extract ClaudeLocalOptions interface from claudeLocal.ts inline opts
- Extract BuildSessionMetadataOptions from sessionFactory.ts inline opts
- Extract GetOrCreateSessionOptions and GetOrCreateMachineOptions from
  ApiClient method signatures in api.ts
- Fix runLocalRemoteSession to use destructuring rest instead of manually
  re-spreading all 5 inherited fields from LocalRemoteLoopOptions
- Replace console.log with logger.debug in sessionFactory.bootstrapSession
@LucasRoesler LucasRoesler merged commit d1db2b9 into main Feb 26, 2026
2 checks passed
@LucasRoesler LucasRoesler deleted the refactor/adopt-agent-sdk-types branch February 26, 2026 22:30
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