Skip to content

Commit cce97d8

Browse files
authored
Merge pull request #1625 from tailor-platform/feat/aigateway-runtime
feat(sdk): add aigateway runtime wrapper with name registry narrowing
2 parents 31b645b + f791cf9 commit cce97d8

23 files changed

Lines changed: 332 additions & 10 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@tailor-platform/sdk": minor
3+
---
4+
5+
Add a runtime wrapper for AI Gateway. Resolvers, executors, and workflow jobs can now resolve an AI Gateway's platform-assigned URL by name via `aigateway.get(name)` (imported from `@tailor-platform/sdk/runtime`), instead of using the raw `tailor.aigateway.get(...)` global. Use `mockAigateway()` from `@tailor-platform/sdk/vitest` to mock it in unit tests.
6+
7+
The gateway name is type-checked and autocompleted against the AI Gateways defined via `defineAIGateway()`, once `tailor.d.ts` has been generated (via `tailor-sdk deploy`/`generate`), mirroring the existing `MachineUserNameRegistry`/`IdpNameRegistry`/`ConnectionNameRegistry` pattern.

packages/create-sdk/templates/executor/tailor.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ declare module "@tailor-platform/sdk" {
1717
"main-idp": true;
1818
}
1919
interface ConnectionNameRegistry {}
20+
interface AIGatewayNameRegistry {}
2021
}
2122

2223
export {};

packages/create-sdk/templates/generators/tailor.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ declare module "@tailor-platform/sdk" {
1717
"main-idp": true;
1818
}
1919
interface ConnectionNameRegistry {}
20+
interface AIGatewayNameRegistry {}
2021
}
2122

2223
export {};

packages/create-sdk/templates/hello-world/tailor.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ declare module "@tailor-platform/sdk" {
1111
interface MachineUserNameRegistry {}
1212
interface IdpNameRegistry {}
1313
interface ConnectionNameRegistry {}
14+
interface AIGatewayNameRegistry {}
1415
}
1516

1617
export {};

packages/create-sdk/templates/inventory-management/tailor.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ declare module "@tailor-platform/sdk" {
1616
}
1717
interface IdpNameRegistry {}
1818
interface ConnectionNameRegistry {}
19+
interface AIGatewayNameRegistry {}
1920
}
2021

2122
export {};

packages/create-sdk/templates/resolver/tailor.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ declare module "@tailor-platform/sdk" {
1818
}
1919
interface IdpNameRegistry {}
2020
interface ConnectionNameRegistry {}
21+
interface AIGatewayNameRegistry {}
2122
}
2223

2324
export {};

packages/create-sdk/templates/static-web-site/tailor.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ declare module "@tailor-platform/sdk" {
1717
"my-idp": true;
1818
}
1919
interface ConnectionNameRegistry {}
20+
interface AIGatewayNameRegistry {}
2021
}
2122

2223
export {};

packages/create-sdk/templates/tailordb/tailor.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ declare module "@tailor-platform/sdk" {
1616
}
1717
interface IdpNameRegistry {}
1818
interface ConnectionNameRegistry {}
19+
interface AIGatewayNameRegistry {}
1920
}
2021

2122
export {};

packages/create-sdk/templates/workflow/tailor.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ declare module "@tailor-platform/sdk" {
1515
}
1616
interface IdpNameRegistry {}
1717
interface ConnectionNameRegistry {}
18+
interface AIGatewayNameRegistry {}
1819
}
1920

2021
export {};

packages/sdk/docs/runtime.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
workflow,
2020
context,
2121
file,
22+
aigateway,
2223
} from "@tailor-platform/sdk/runtime";
2324

2425
const utf8 = iconv.convert(sjisBuffer, "Shift_JIS", "UTF-8");
@@ -35,6 +36,8 @@ const executionId = await workflow.triggerWorkflow("approval", { reportId });
3536
const invoker = context.getInvoker();
3637

3738
const { metadata } = await file.upload("my-namespace", "Document", "attachment", recordId, bytes);
39+
40+
const { url } = await aigateway.get("my-aigateway");
3841
```
3942

4043
## Subpath imports
@@ -79,6 +82,7 @@ The runtime entry re-exports the following namespaces. Detailed signatures, para
7982
- `workflow` — workflow & job control (`triggerWorkflow`, `resumeWorkflow`, `triggerJobFunction`, `wait`, `resolve`)
8083
- `context` — execution context (`getInvoker`)
8184
- `file``tailordb.file` BLOB API (`upload`, `download`, `downloadAsBase64`, `delete`, `getMetadata`, `downloadStream`, `uploadStream`, `openDownloadStream` _(deprecated)_)
85+
- `aigateway` — AI Gateway URL resolution (`get`)
8286

8387
## Testing
8488

0 commit comments

Comments
 (0)