Skip to content

feat(middleware): add AgentRuntime interface and type contracts#4

Merged
alexey-pelykh merged 1 commit intomainfrom
feat/middleware-types
Feb 25, 2026
Merged

feat(middleware): add AgentRuntime interface and type contracts#4
alexey-pelykh merged 1 commit intomainfrom
feat/middleware-types

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

  • Add src/middleware/types.ts with foundational type contracts for the middleware layer
  • Define AgentRuntime interface with execute(params) -> AsyncIterable<AgentEvent> contract
  • Define AgentEvent discriminated union (text, tool_use, tool_result, error, done)
  • Define three-type delivery contract: AgentRunResult + McpSideEffects = AgentDeliveryResult
  • Add supporting types: AgentUsage, PermissionDenial, ChannelMessage, BridgeCallbacks

Closes #3

Test plan

  • pnpm build passes
  • pnpm check passes (format + typecheck + lint)
  • CI build and test jobs pass
  • Types-only file — no runtime code to test

🤖 Generated with Claude Code

Define foundational type contracts for the middleware layer that all
downstream components depend on: CLI runtime implementations, event
extractors, session map, channel bridge, and delivery adapter.

Closes #3

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-pelykh alexey-pelykh merged commit 15fa470 into main Feb 25, 2026
2 checks passed
@alexey-pelykh alexey-pelykh deleted the feat/middleware-types branch February 25, 2026 10:03
alexey-pelykh pushed a commit that referenced this pull request Mar 25, 2026
1. [P1] Treat remap failures as resume failures — if replaceSubagentRunAfterSteer
   returns false, do NOT clear abortedLastRun, increment failed count.

2. [P2] Count scan-level exceptions as retryable failures — set result.failed > 0
   in the outer catch block so scheduleOrphanRecovery retry logic triggers.

3. [P2] Persist resumed-session dedupe across recovery retries — accept
   resumedSessionKeys as a parameter; scheduleOrphanRecovery lifts the Set to
   its own scope and passes it through retries.

4. [Greptile] Use typed config accessors instead of raw structural cast for TLS
   check in lifecycle.ts.

5. [Greptile] Forward gateway.reload.deferralTimeoutMs to deferGatewayRestartUntilIdle
   in scheduleGatewaySigusr1Restart so user-configured value is not silently ignored.

6. [Greptile] Same as #4 — already addressed by the typed config fix.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 98f6ec5)
alexey-pelykh pushed a commit that referenced this pull request Mar 25, 2026
1. [P1] Treat remap failures as resume failures — if replaceSubagentRunAfterSteer
   returns false, do NOT clear abortedLastRun, increment failed count.

2. [P2] Count scan-level exceptions as retryable failures — set result.failed > 0
   in the outer catch block so scheduleOrphanRecovery retry logic triggers.

3. [P2] Persist resumed-session dedupe across recovery retries — accept
   resumedSessionKeys as a parameter; scheduleOrphanRecovery lifts the Set to
   its own scope and passes it through retries.

4. [Greptile] Use typed config accessors instead of raw structural cast for TLS
   check in lifecycle.ts.

5. [Greptile] Forward gateway.reload.deferralTimeoutMs to deferGatewayRestartUntilIdle
   in scheduleGatewaySigusr1Restart so user-configured value is not silently ignored.

6. [Greptile] Same as #4 — already addressed by the typed config fix.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
(cherry picked from commit 98f6ec5)
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.

Implement AgentRuntime interface and type contracts

1 participant