Skip to content

Implement @workkit/ai → @workkit/ai-gateway deprecation shim (ADR-001) #63

@beeeku

Description

@beeeku

Context

ADR-001 (`.maina/decisions/001-ai-package-consolidation.md`) accepted folding `@workkit/ai` into `@workkit/ai-gateway` via a deprecation shim at v1.0, removal at v2.0. This ticket tracks the implementation.

Scope

Changes to `@workkit/ai`

  1. Reimplement all public exports as thin wrappers over `@workkit/ai-gateway`:
    • `ai(binding)` → construct an internal `createGateway({providers:{ai:{type:'workers-ai',binding}},defaultProvider:'ai'})`.
    • `streamAI(binding, model, input, opts)` → call `.stream(model, input, opts)`; map `GatewayStreamEvent` back to `ReadableStream` for backwards compat.
    • `withRetry`, `fallback`, `structuredAI`, `aiWithTools`, `createToolRegistry` → delegate.
    • `StructuredOutputError` stays in `@workkit/ai` but is re-exported from `@workkit/ai-gateway` as well.
    • `estimateTokens` stays where it is (low-cost, no dependency on gateway).
  2. Add `@deprecated` JSDoc on every public export citing ADR-001 and pointing at the migration guide.
  3. Update `package.json` description and `README.md` to lead with the deprecation notice.
  4. Add `@workkit/ai-gateway` as a `peerDependency` (or `dependency` — caller's choice after reviewing bundle impact).

Changes to `@workkit/ai-gateway`

  1. Add `README.md` migration section with before/after examples for every `@workkit/ai` export.
  2. Consider adding a `workersAiGateway(binding)` convenience factory equivalent to the common Workers-AI gateway config, as noted in ADR-001's open questions. Only if user feedback requests it post-shim.

Release

  • `@workkit/ai` bumps to v1.0.0.
  • Changeset explains the shim + deprecation timeline (remove at v2.0 after ≥2 minor releases).
  • Announce in workkit release notes.

Acceptance

  • All existing `@workkit/ai` tests pass against the shim (no code changes on the test side).
  • `@deprecated` JSDoc on every public export.
  • Migration guide with ≥5 before/after examples covering the common surface.
  • Changeset + release notes.
  • Follow-up ticket filed for v2.0 removal timeline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    aiAI packages (ai, ai-gateway, memory)enhancementNew feature or requestpackages/ai@workkit/aipackages/ai-gateway@workkit/ai-gateway

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions