Skip to content

feat: Unified Provider Interface — lifecycle hooks + context injection API#529

Merged
Pizzaface merged 20 commits into
mainfrom
feat/unified-provider-interface
May 13, 2026
Merged

feat: Unified Provider Interface — lifecycle hooks + context injection API#529
Pizzaface merged 20 commits into
mainfrom
feat/unified-provider-interface

Conversation

@Pizzaface
Copy link
Copy Markdown
Owner

@Pizzaface Pizzaface commented May 6, 2026

Summary

This PR currently collects the unified provider-interface work plus follow-up hardening that landed while stabilizing the branch.

Main provider API work

  • Adds ExtensionProvider types, capability guards, and config schema for provider services.
  • Adds provider discovery/loading from user and project provider directories with trust-gated project providers and per-provider enable/disable config.
  • Adds ProviderBridge aggregation with deterministic ordering, per-prompt dedupe, error isolation, and provider disable-on-repeat-failure behavior.
  • Wires a provider Pi extension into the daemon extension chain so providers can react to session/turn lifecycle events and inject context into prompts.
  • Documents the Extension Providers API in the docs site and updates runner-service skill guidance.

Follow-up hardening included on the branch

  • Adds session finalization reducer coverage for safer streamed/session-close state handling.
  • Wires session-close finalization into daemon archival paths.
  • Hardens hook/browser notification behavior.
  • Fixes tunnel streaming/rollback paths and related server/tunnel tests.
  • Adds UI error-boundary and browser-notification coverage.

Key design decisions

  • Provider capabilities are duck-typed so providers can implement only the surfaces they need.
  • Context contributions are sorted by order and providerId for deterministic prompt placement.
  • dedupeKey deduplication is scoped per prompt and resets on prompt boundaries.
  • Provider failures are isolated: repeated failures disable that provider for the rest of the session instead of breaking the whole run.
  • Project-local providers require an explicit trust gate and default off.

Verification

Fresh local verification on this branch:

  • bun run typecheck — passed
  • bun run test — 988 pass, 1 skip, 0 fail
  • bun run build — passed
  • git diff --check origin/main...HEAD — passed
  • Branch sync: git pull --rebase and git push both reported up-to-date

Notes

  • Existing ServiceHandler services continue to work; the provider API is additive.
  • Pertinence is expected to be the first external consumer of this API.

Pizzaface added 20 commits May 5, 2026 19:25
- Adds programmatic E2E test covering full provider lifecycle
- Discovery → loading → bridge → hooks → cleanup
- Tests: sorting, deduplication, error isolation, 3-strikes disable, lifecycle hooks
- 13 tests; all pass with bun test
- New customization/providers.mdx covering the full provider system:
  concept, quick start, interface, capabilities, config, bridge behavior,
  examples, troubleshooting
- Add sidebar entry in astro.config.mjs under Customization
- Cross-reference from features/providers-and-models.mdx to avoid
  confusion between AI model providers and ExtensionProviders
Server:
- proxyTunnelRequestViaRelay: safe stream closure with closeStream()
  guard — prevents double-close and stream errors after response starts
- On late relay error during streaming: close body instead of erroring
  the stream (avoids Bun write-after-end crashes)
- Added test for clean streaming error handling
- Tunnel upgrade: guard against null wss, add logging for connections,
  errors, and upgrades with remote addr and user-agent

Tunnel client:
- Enhanced disconnect/error logging with structured metadata (code,
  reason, uptime, active connections, failure count)
- Track connection wall-clock start time for uptime reporting

Tunnel relay (server):
- Clear timer once response headers arrive — prevents killing long-lived
  SSE/streaming responses (fixes false timeout for EventSource, dev servers)
- Tests: timeout when runner never responds, no timeout for long streams
  after headers arrive

Server index:
- Guard res.end() against writableEnded/destroyed on 404 and 500 paths
  (prevents ERR_STREAM_WRITE_AFTER_END crashes)

Health endpoint:
- Debounce health status log to avoid log spam on every /health poll
- Add optional model field to SessionStartEvent (providers/types.ts)
- Populate model from ctx.model in providers/extension.ts
- Add SessionStart hook to HooksConfig and config/io.ts
- Handle SessionStart hook in hooks/extension.ts with model in payload
- Update Claude Code plugin adapter to include model in session_start stdin
- Add SessionStart to hook-summary.ts entry keys
- Add tests for SessionStart hook and model payload
@Pizzaface Pizzaface merged commit ccd5989 into main May 13, 2026
11 checks passed
@Pizzaface Pizzaface deleted the feat/unified-provider-interface branch May 13, 2026 19:42
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