refactor: consolidate handrolled infra with @cadre-dev/framework#173
Merged
refactor: consolidate handrolled infra with @cadre-dev/framework#173
Conversation
Leverage framework 0.2.1 new APIs to delegate infrastructure that AAMF previously implemented from scratch: - RetryExecutor: delegate to framework with computeDelay for infra-fast-retry, async onRetry, RETRY_ORIGINAL for recovery - TokenTracker: delegate with loadFromAggregates() for checkpoint restore, gains per-task breakdowns via getByTask() - stripVSCodeEnv: delegate to framework - Process tracking: replace activeChildPids with framework - classifyError: fall back to framework binary classifier - parseAamfOutput: fall back to cadre-json extractor
e34a874 to
809e0b9
Compare
Replace handrolled pricing resolution/math with framework CostEstimator, passing AAMF 50+ model pricing table via the models config. Removes resolvePricing, WarnFn, and the three-tier fallback chain. Keeps AMF-specific methods (projectCost, formatCost) as thin wrappers. Framework uses per-1K pricing; AAMF table is per-1M — converted on construction. Cache discount mapped to framework estimateDetailed calls with manual 50% rate calculation.
…hing
Align AgentInvocation and AgentResult with @cadre-dev/framework types:
- Rename contextFile→contextPath, taskId→workItemId, phase required
- Add outputPath, timedOut, stdout, stderr, outputExists to AgentResult
- Rename tokenUsage fields: prompt→input, completion→output, drop total
- Move AAMF-specific fields to extensions (outputFiles, structuredOutput,
outputParsed, parseError, copilotEvents, mcpConfig, kbDbPath, etc.)
Replace CliAgentRunner/CopilotRunner/ClaudeCodeRunner with framework's
AgentLauncher + CopilotBackend/ClaudeBackend (693→391 lines). AAMF's
AgentLauncher now delegates CLI spawning to the framework and only runs
post-processing: aamf-json parsing, copilot event extraction, output
file detection, and log writing.
Update buildContext to return { contextPath, outputPath } and
buildInvocation to accept the tuple. Update buildInvocation to accept the tuple. Update buildInvocation to accept the tuple. Update buildInvocation to accept the tuple. Update buildInvocation to accept the t) buildInvocation to accept the tuple. Update buildInvocation to acceps spawning are now tested by the framework.
The lockfile resolved 0.2.0 but the code depends on 0.2.1 types (workItemId on AgentInvocation, modelOverride, extensions). CI was failing because npm ci installed 0.2.0 from the stale lockfile.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reduces duplication between AAMF's handrolled infrastructure and
@cadre-dev/frameworkby delegating to framework primitives where the API fits, and documenting where it doesn't (with suggested upstream improvements).Changes
Token tracking —
TokenTrackerdelegates live record storage to the framework'sTokenTracker, gaining per-task token breakdowns viagetByTask(). Checkpoint-restored state is held in explicitrestoredTotal/restoredByPhase/restoredByAgentmaps (no sentinel-phase hack).Retry execution —
RetryExecutordelegates the outer retry loop to the framework's genericRetryExecutor<T>, adding awithInfraRetry()inner loop for transient infrastructure errors (503, GOAWAY, connection resets) with a fast 250ms-2s backoff profiRetry execution —RetryExecutordelegates the outer retry loop to ffRetry executd Retry execution —RetryExmfO**Retry execution** —RetryExecutordelegates the outer retry loop en noaRetry executi is found.VS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code enVS Code en*ithVS Code work's
trackProcess()/killAllTrackedProcesses().Error classification — AAMF's fine-grained
classifyError()now falls back to the framework's binaryclassifyError()for additional infra patterns, returninginfra-otherwhen the framework catches something AAMF's patterns miss.Cost estimator / fs utils — Documented why these remain handrolled (framework gaps) with notes for when delegation becomes viable.
Test results
All 1475 tests pass across 45 test files.