Skip to content

refactor(daemon): type the hook dispatch against the agent SDK - #125

Merged
rgao-coreweave merged 1 commit into
mainfrom
109-04-typed-hooks
Jul 17, 2026
Merged

refactor(daemon): type the hook dispatch against the agent SDK#125
rgao-coreweave merged 1 commit into
mainfrom
109-04-typed-hooks

Conversation

@rgao-coreweave

@rgao-coreweave rgao-coreweave commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Casts the socket JSON once against the SDK's HookInput and dispatches on the discriminant, so handlers take typed inputs. Deletes ~40 payload['x'] as T casts.

  • Fields the SDK types as required drop their invented fallbacks ('unknown', 'teammate', '?').
  • Payloads that carry more than the SDK declares keep documented raw-record reads (PreCompact summary/counts, reconstruction source/model).

Behavior notes: PostToolUseFailure trusts the typed error field and drops the undocumented tool_response fallback; InstructionsLoaded drops its missing-file_path branch (the type requires it, and unreadable paths still hit the existing catch).

Test plan: npm run check (84 tests; two test harnesses updated to the new handler signatures)

🤖 Generated with Claude Code

rgao-coreweave commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@drtangible drtangible left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🔥

@rgao-coreweave
rgao-coreweave force-pushed the 109-03-config-extract branch from 1a97da0 to 2761356 Compare July 17, 2026 20:18
@rgao-coreweave
rgao-coreweave force-pushed the 109-03-config-extract branch from 2761356 to 7693513 Compare July 17, 2026 20:34
@rgao-coreweave
rgao-coreweave changed the base branch from 109-03-config-extract to graphite-base/125 July 17, 2026 20:36
Cast the socket JSON once against the SDK's HookInput and dispatch on the
discriminant, so handlers take typed inputs instead of re-casting every
field (~40 payload[...] as X casts deleted). Fields the SDK types as
required drop their invented fallbacks ('unknown'/'teammate'/'?'); the two
payloads that carry more than the SDK declares (PreCompact summary/counts,
reconstruction source/model) keep documented raw-record reads.

Behavior notes: PostToolUseFailure now trusts the typed `error` field
(drops the undocumented tool_response fallback), and InstructionsLoaded
drops its missing-file_path branch (the type requires it; a bad path still
lands in the unreadable-file catch).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rgao-coreweave
rgao-coreweave changed the base branch from graphite-base/125 to main July 17, 2026 20:39

rgao-coreweave commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Jul 17, 8:46 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jul 17, 8:46 PM UTC: @rgao-coreweave merged this pull request with Graphite.

@rgao-coreweave
rgao-coreweave merged commit 4be37dc into main Jul 17, 2026
6 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants