Skip to content

feat(sdk): add aigateway runtime wrapper with name registry narrowing - #1625

Merged
toiroakr merged 3 commits into
mainfrom
feat/aigateway-runtime
Jul 2, 2026
Merged

feat(sdk): add aigateway runtime wrapper with name registry narrowing#1625
toiroakr merged 3 commits into
mainfrom
feat/aigateway-runtime

Conversation

@toiroakr

@toiroakr toiroakr commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add aigateway.get(name) to @tailor-platform/sdk/runtime, a thin typed wrapper around the platform's tailor.aigateway.get global that resolves an AI Gateway's platform-assigned URL from resolvers, executors, and workflow jobs. Also available as its own subpath, @tailor-platform/sdk/runtime/aigateway, matching every other runtime/* module.
  • Add mockAigateway() to @tailor-platform/sdk/vitest for mocking tailor.aigateway.get in unit tests, following the same pattern as the other platform API mocks.
  • Add a generated AIGatewayNameRegistry (and AIGatewayName type) to tailor.d.ts, mirroring the existing MachineUserNameRegistry/IdpNameRegistry/ConnectionNameRegistry pattern, so aigateway.get(...) is type-checked and autocompleted against the AI Gateways defined via defineAIGateway().
  • Update create-sdk template tailor.d.ts files and docs (runtime.md, testing.md, services/aigateway.md) accordingly.

Notes

  • Verified against the platform runtime implementation (tailor.aigateway.get(name): Promise<{ url: string }>, backed by the dataplane.aigateway.v1.AIGatewayService/GetAIGateway RPC) before adding the wrapper, since the SDK previously had no runtime-side binding for AI Gateway — only the defineAIGateway() provisioning config existed.

@changeset-bot

changeset-bot Bot commented Jul 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f791cf9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@tailor-platform/sdk Minor
@tailor-platform/create-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jul 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/@tailor-platform/create-sdk@f791cf9
pnpm add https://pkg.pr.new/@tailor-platform/sdk@f791cf9

commit: f791cf9

@github-actions

This comment has been minimized.

@toiroakr
toiroakr requested a review from Copilot July 2, 2026 01:35
@toiroakr
toiroakr marked this pull request as ready for review July 2, 2026 01:37
@toiroakr
toiroakr requested review from a team as code owners July 2, 2026 01:37
@github-actions

This comment has been minimized.

This comment was marked as outdated.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📖 Docs Quality & Consistency Check

✅ Docs are consistent with the implementation and contain no user-facing internal-detail leaks.

Checked areas:

  • packages/sdk/docs/runtime.md - New aigateway import and namespace documented correctly
  • packages/sdk/docs/services/aigateway.md - Runtime Usage section matches implementation signature and behavior
  • packages/sdk/docs/testing.md - mockAigateway() API documented correctly with setUrls, calls, and error behavior
  • .changeset/aigateway-runtime-wrapper.md - User-facing description accurate
  • packages/sdk/src/runtime/aigateway.ts - Exported JSDoc appropriate for user audience
  • packages/sdk/src/vitest/mock.ts - Mock API implementation matches documented behavior
  • packages/sdk/src/configure/types/aigateway-name.ts - Type narrowing behavior documented correctly
  • packages/sdk/src/cli/shared/type-generator.ts - AIGatewayNameRegistry generation matches documented behavior
  • All create-sdk templates correctly include empty AIGatewayNameRegistry interface

Verification details:

  • Runtime API signature (aigateway.get(name): Promise<{ url: string }>) matches docs
  • Type narrowing via AIGatewayNameRegistry works as documented
  • Mock API (setUrls, calls, error behavior) matches testing docs
  • No internal RPC names (dataplane.aigateway.v1.*) or protocol details leaked into user-facing docs
  • JSDoc on exported symbols appropriately describes user-facing behavior without implementation details
  • References to tailor.aigateway global appropriately explain the wrapper relationship for user understanding

Re-run this check by adding the docs-check label to the PR.


@dqn dqn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dqn dqn removed their assignment Jul 2, 2026
@dqn

dqn commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

@toiroakr
pls fix conflict and merge 🙏

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Code Metrics Report (packages/sdk)

main (31b645b) #1625 (5fb893d) +/-
Coverage 71.2% 71.2% +0.0%
Code to Test Ratio 1:0.4 1:0.4 +0.0
Details
  |                    | main (31b645b) | #1625 (5fb893d) |  +/-  |
  |--------------------|----------------|-----------------|-------|
+ | Coverage           |          71.2% |           71.2% | +0.0% |
  |   Files            |            428 |             429 |    +1 |
  |   Lines            |          15737 |           15763 |   +26 |
+ |   Covered          |          11211 |           11234 |   +23 |
+ | Code to Test Ratio |          1:0.4 |           1:0.4 |  +0.0 |
  |   Code             |         107016 |          107175 |  +159 |
+ |   Test             |          48418 |           48491 |   +73 |

Code coverage of files in pull request scope (90.6% → 90.4%)

Files Coverage +/- Status
packages/sdk/src/cli/shared/type-generator.ts 82.6% +0.2% modified
packages/sdk/src/configure/index.ts 100.0% 0.0% modified
packages/sdk/src/runtime/aigateway.ts 100.0% +100.0% added
packages/sdk/src/vitest/index.ts 100.0% 0.0% modified
packages/sdk/src/vitest/mock.ts 93.0% -0.4% modified

SDK Configure Bundle Size

main (31b645b) #1625 (5fb893d) +/-
configure-index-size 20.32KB 20.32KB 0KB
dependency-chunks-size 47.12KB 47.12KB 0KB
total-bundle-size 67.44KB 67.44KB 0KB

Runtime Performance

main (31b645b) #1625 (5fb893d) +/-
Generate Median 2,911ms 3,197ms 286ms
Generate Max 2,922ms 3,285ms 363ms
Apply Build Median 2,958ms 3,252ms 294ms
Apply Build Max 2,974ms 3,282ms 308ms

Type Performance (instantiations)

main (31b645b) #1625 (5fb893d) +/-
tailordb-basic 39,480 39,480 0
tailordb-optional 4,385 4,385 0
tailordb-relation 5,103 5,103 0
tailordb-validate 742 742 0
tailordb-hooks 5,222 5,222 0
tailordb-object 12,510 12,510 0
tailordb-enum 1,450 1,450 0
resolver-basic 9,272 9,272 0
resolver-nested 26,139 26,139 0
resolver-array 18,078 18,078 0
executor-schedule 4,310 4,310 0
executor-webhook 949 949 0
executor-record 5,664 5,664 0
executor-resolver 4,108 4,108 0
executor-operation-function 937 937 0
executor-operation-gql 945 945 0
executor-operation-webhook 956 956 0
executor-operation-workflow 1,785 1,785 0

Reported by octocov

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 23 changed files in this pull request and generated no new comments.

@toiroakr
toiroakr merged commit cce97d8 into main Jul 2, 2026
44 checks passed
@toiroakr
toiroakr deleted the feat/aigateway-runtime branch July 2, 2026 05:31
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.

4 participants