feat(miner-hands): Agent-SDK CodingAgentDriver (query() loop) - #4548
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4548 +/- ##
=======================================
Coverage 94.06% 94.07%
=======================================
Files 425 426 +1
Lines 37774 37815 +41
Branches 13794 13813 +19
=======================================
+ Hits 35533 35574 +41
Misses 1586 1586
Partials 655 655
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-10 01:12:56 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Closes #4267
What
The Agent-SDK
CodingAgentDriverimplementation of #4262's seam:createAgentSdkCodingAgentDriverdrives the coding agent in-process via@anthropic-ai/claude-agent-sdk'squery()async-iterable loop, complementing the CLI-subprocess driver that just landed for #4266. Rebased onto current main, so it composes cleanly with the CLI driver's and repo-map's engine exports. New dependency@anthropic-ai/claude-agent-sdk@^0.3.205onpackages/gittensory-engine— no@anthropic-ai/*package existed in the repo before this, peer deps satisfied by existing root versions,npm audit --audit-level=moderateclean. Supply-chain note: the package publishes no SLSA/sigstore attestation yet; caret-pinned and lockfile-resolved.How it maps to the issue's deliverables
query()loop → shared result shape: streamed SDK frames fold in the driver — assistant text into the transcript,tool_useframes forEdit/Write/NotebookEditintochangedFiles(deduped;Bashet al. are not file changes), the terminalresultframe into ok/error/turnsUsed/summary. No SDK event type leaks intoCodingAgentDriver— the exportedAgentSdkQueryFnconsumes plain records.cwd=task.workingDirectory,maxTurnsbudget, instructions verbatim as the prompt, acceptance criteria materialized in the worktree per feat(miner-hands): immutable acceptance-criteria file written before the coding agent starts #4271), structured failures that never throw,changedFilesreported only on success, and the same edit-permission scope (permissionMode: "acceptEdits"here vs--permission-mode acceptEditsthere — documented at the call site) so test(miner-hands): parity/contract test suite for CodingAgentDriver implementations #4296's parity suite can hold both to one contract.hooksand forwards them verbatim onto thequery()session options (PreToolUseetc.) — the SDK's hook surface stays reachable from outside the module.AgentSdkQueryFn(the injected-SpawnFnconvention); the real-SDK path is a lazy dynamic import behind the default.Failure mapping: non-
successresult subtype →agent_sdk_<subtype>;success+is_error→agent_sdk_errored; stream ending without a result frame →agent_sdk_no_result; a mid-stream throw →agent_sdk_thrown: <redacted detail>. Text that can carry model output (summary, transcript, error detail) passes through the engine's sharedredactSecrets(#4284), bounded by one namedMAX_REDACTED_TEXT_LENGTHceiling. Test fixtures build secret-shaped strings at runtime, so no token-shaped literal appears in the diff.Testing
test/unit/agent-sdk-driver.test.ts(the codecov-measured path) and a parity-matchednode:testsuite inpackages/gittensory-engine/test/— success path (session options, hooks pass-through, changed-file tracking/dedupe, turn count),error_max_turns,is_erroron a success subtype, unknown-subtype fallback, missing result frame, Error and non-Error mid-stream throws (redacted), secret redaction in summary/transcript, malformed-frame tolerance, and the no-options constructor.typecheck,git diff --check,npm audit --audit-level=moderate, and 100% line+branch coverage on the new module.