@to11ai/sdk 3.0.0-rc.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -4
- package/dist/client.cjs +29 -21
- package/dist/client.d.ts +6 -0
- package/dist/client.js +27 -19
- package/dist/errors.cjs +15 -16
- package/dist/errors.js +15 -15
- package/dist/gateway.cjs +11 -11
- package/dist/gateway.js +11 -11
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/types.gen.d.ts +9495 -4795
- package/dist/generated/zod.gen.d.ts +8260 -4911
- package/dist/pagination.d.ts +32 -0
- package/dist/projectEnvironments/resource.cjs +20 -2
- package/dist/projectEnvironments/resource.d.ts +21 -5
- package/dist/projectEnvironments/resource.js +20 -2
- package/dist/projectEnvironments/types.d.ts +14 -1
- package/dist/prompts/resource.cjs +49 -3
- package/dist/prompts/resource.d.ts +41 -2
- package/dist/prompts/resource.js +61 -5
- package/dist/prompts/types.d.ts +40 -15
- package/dist/routingRules/resource.d.ts +44 -2
- package/dist/routingRules/types.d.ts +33 -3
- package/dist/transport.d.ts +5 -1
- package/dist/usage/resource.cjs +113 -0
- package/dist/usage/resource.d.ts +29 -0
- package/dist/usage/resource.js +78 -0
- package/dist/usage/types.d.ts +81 -0
- package/package.json +14 -6
- package/src/client.ts +12 -0
- package/src/generated/index.ts +1 -1
- package/src/generated/types.gen.ts +9670 -4790
- package/src/generated/zod.gen.ts +6112 -3115
- package/src/pagination.ts +64 -0
- package/src/projectEnvironments/resource.ts +44 -9
- package/src/projectEnvironments/types.ts +19 -1
- package/src/prompts/resource.ts +149 -4
- package/src/prompts/types.ts +56 -15
- package/src/routingRules/resource.ts +77 -5
- package/src/routingRules/types.ts +35 -3
- package/src/transport.ts +14 -2
- package/src/usage/resource.ts +183 -0
- package/src/usage/types.ts +121 -0
package/README.md
CHANGED
|
@@ -15,13 +15,17 @@ npm install @to11ai/sdk
|
|
|
15
15
|
|
|
16
16
|
Runs anywhere Node, Bun, Deno, or edge runs — servers, CLIs, and backend jobs. Not for browsers: a to11 API key carries gateway access and must never ship in client-side code.
|
|
17
17
|
|
|
18
|
+
### Upgrading from 2.x
|
|
19
|
+
|
|
20
|
+
3.0 takes environments out of prompt resolution: a prompt has one label, `latest`, and the client `env` only routes gateway calls. `moveLabel()`, the project label registry and weighted releases are gone, and `listVersions()`, `listLabels()` and `projectEnvironments.list()` return cursor pages instead of arrays. See [Migrating from 2.x to 3.0](https://github.com/to11ai/platform/blob/main/packages/js-sdk/CHANGELOG.md#migrating-from-2x-to-30) for the full list.
|
|
21
|
+
|
|
18
22
|
### Upgrading from 1.x
|
|
19
23
|
|
|
20
24
|
2.0 reshapes prompt access around a single `render()` call and trims the public surface to what we keep stable. `prompts.resolve()` is gone, the per-call `env` option is now `label`, and routing rules are no longer exported. See [Migrating from 1.x to 2.0](https://github.com/to11ai/platform/blob/main/packages/js-sdk/CHANGELOG.md#migrating-from-1x-to-20) for the full list of renames and removals.
|
|
21
25
|
|
|
22
26
|
## Quick start
|
|
23
27
|
|
|
24
|
-
Create a client, render a prompt
|
|
28
|
+
Create a client, render a prompt, and send it through the gateway with your normal provider client:
|
|
25
29
|
|
|
26
30
|
```typescript
|
|
27
31
|
import { createClient } from "@to11ai/sdk";
|
|
@@ -117,7 +121,7 @@ const to11 = createClient({ apiKey, projectId: "proj_abc123" });
|
|
|
117
121
|
await to11.prompts.list(); // uses the bound projectId
|
|
118
122
|
await to11.prompts.get({ promptId: "prompt_1" });
|
|
119
123
|
await to11.prompts.getVersion({ promptId: "prompt_1", versionNumber: 3 });
|
|
120
|
-
await to11.prompts.listLabels({ promptId: "prompt_1" }); // [{ label: "latest", versionId: "ver_9", … }]
|
|
124
|
+
await to11.prompts.listLabels({ promptId: "prompt_1" }); // { items: [{ label: "latest", versionId: "ver_9", … }], pagination }
|
|
121
125
|
```
|
|
122
126
|
|
|
123
127
|
`listVersions` pages a prompt's versions newest first and returns summaries — `id`, `version`, `format`, `changelog`, who created it and when — without the content. Pass `pagination.nextCursor` back as `cursor` for the next page (`null` on the last one); `limit` defaults to 50 and clamps to 100. Read one version's `templateJson`, `variablesSchema` and `modelConfig` with `getVersion`:
|
|
@@ -128,7 +132,30 @@ const page = await to11.prompts.listVersions({ promptId: "prompt_1", limit: 20 }
|
|
|
128
132
|
const newest = await to11.prompts.getVersion({ promptId: "prompt_1", versionNumber: page.items[0].version });
|
|
129
133
|
```
|
|
130
134
|
|
|
131
|
-
Full set: `create`, `list`, `get`, `update`, `archive`, `createVersion`, `listVersions`, `getVersion`, `listLabels`. Creating a version moves `latest`; there is no label to move by hand. `client.projectEnvironments` exposes the project-environments registry.
|
|
135
|
+
Full set: `render`, `create`, `list`, `get`, `update`, `archive`, `createVersion`, `listVersions`, `iterateVersions`, `getVersion`, `listLabels`, `iterateLabels`, `listOrgPrompts`, `renderSkillVersion`. Creating a version moves `latest`; there is no label to move by hand. `client.projectEnvironments` exposes the project-environments registry.
|
|
136
|
+
|
|
137
|
+
Skills across an organization: `listOrgPrompts` lists the skills in every project of an org you may read prompts in, each with the version `latest` serves (at most `limit` rows, default 20, max 50). Render exactly that version with `renderSkillVersion`:
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
const { items, excludedProjects } = await to11.prompts.listOrgPrompts({ orgId: "org_1", query: "release" });
|
|
141
|
+
const skill = await to11.prompts.renderSkillVersion({ projectId: items[0].projectId, slug: items[0].slug, version: items[0].version });
|
|
142
|
+
// skill.files: [{ filename: "SKILL.md", content, … }]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Organization usage
|
|
146
|
+
|
|
147
|
+
`client.usage` reads an organization's usage. Every method takes the `orgId` and, except `findPrincipals`, a `window`: absolute (`{ from, to }`, ISO 8601 with an offset) or a preset the server resolves in an IANA time zone (`{ preset, n?, timezone }`; `n` only for `last_n_hours` / `last_n_days`). Figures carry `billedUsd` and `apiEquivalentUsd`; every response echoes the absolute window and lists the readable projects it left out (`excludedProjects`).
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
const { items } = await to11.usage.findPrincipals({ orgId: "org_1", query: "nigel" }); // or { email }
|
|
151
|
+
const window = { preset: "last_n_days", n: 7, timezone: "Europe/Berlin" } as const;
|
|
152
|
+
|
|
153
|
+
await to11.usage.listSessions({ orgId: "org_1", window, principalId: items[0].principalId }); // cursor-paged
|
|
154
|
+
await to11.usage.getCosts({ orgId: "org_1", window, groupBy: ["principal", "model"] });
|
|
155
|
+
await to11.usage.listTopTraces({ orgId: "org_1", window, sort: "cost", limit: 5 }); // window ≤ 60 days
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Types: `import type { UsageWindow, GetCostsResult, … } from "@to11ai/sdk/usage"`.
|
|
132
159
|
|
|
133
160
|
## Error handling
|
|
134
161
|
|
|
@@ -158,7 +185,7 @@ try {
|
|
|
158
185
|
|
|
159
186
|
## TypeScript types
|
|
160
187
|
|
|
161
|
-
All inputs/outputs are typed; declarations ship as `dist/*.d.ts` (no separate `@types`). Import types from the entrypoint or the `@to11ai/sdk/prompts`
|
|
188
|
+
All inputs/outputs are typed; declarations ship as `dist/*.d.ts` (no separate `@types`). Import types from the entrypoint or the `@to11ai/sdk/prompts` and `@to11ai/sdk/usage` subpaths:
|
|
162
189
|
|
|
163
190
|
```typescript
|
|
164
191
|
import type { ClientOptions, RenderOptions, RenderedPrompt } from "@to11ai/sdk";
|
package/dist/client.cjs
CHANGED
|
@@ -39,26 +39,29 @@ var __export = (target, all) => {
|
|
|
39
39
|
// src/client.ts
|
|
40
40
|
var exports_client = {};
|
|
41
41
|
__export(exports_client, {
|
|
42
|
-
|
|
43
|
-
gatewayAuthHeaders: () => import_gateway2.gatewayAuthHeaders,
|
|
44
|
-
createClient: () => createClient,
|
|
45
|
-
UnknownRoleError: () => import_errors.UnknownRoleError,
|
|
46
|
-
Turn: () => import_context2.Turn,
|
|
47
|
-
To11aiValidationError: () => import_errors.To11aiValidationError,
|
|
48
|
-
To11aiRateLimitError: () => import_errors.To11aiRateLimitError,
|
|
49
|
-
To11aiNetworkError: () => import_errors.To11aiNetworkError,
|
|
50
|
-
To11aiError: () => import_errors.To11aiError,
|
|
51
|
-
To11aiAuthError: () => import_errors.To11aiAuthError,
|
|
52
|
-
To11aiApiError: () => import_errors.To11aiApiError,
|
|
53
|
-
Session: () => import_context2.Session,
|
|
54
|
-
PromptResource: () => import_resource4.PromptResource,
|
|
55
|
-
PromptPolicyViolationError: () => import_errors.PromptPolicyViolationError,
|
|
56
|
-
PromptNotFoundError: () => import_errors.PromptNotFoundError,
|
|
57
|
-
PromptHasNoVersionsError: () => import_errors.PromptHasNoVersionsError,
|
|
58
|
-
ProjectEnvironmentResource: () => import_resource3.ProjectEnvironmentResource,
|
|
59
|
-
LabelNotFoundError: () => import_errors.LabelNotFoundError,
|
|
42
|
+
Conversation: () => import_context2.Conversation,
|
|
60
43
|
ENV_SLUG_REGEX: () => import_types2.ENV_SLUG_REGEX,
|
|
61
|
-
|
|
44
|
+
LabelNotFoundError: () => import_errors.LabelNotFoundError,
|
|
45
|
+
ProjectEnvironmentResource: () => import_resource4.ProjectEnvironmentResource,
|
|
46
|
+
PromptHasNoVersionsError: () => import_errors.PromptHasNoVersionsError,
|
|
47
|
+
PromptNotFoundError: () => import_errors.PromptNotFoundError,
|
|
48
|
+
PromptPolicyViolationError: () => import_errors.PromptPolicyViolationError,
|
|
49
|
+
PromptResource: () => import_resource5.PromptResource,
|
|
50
|
+
Session: () => import_context2.Session,
|
|
51
|
+
To11aiApiError: () => import_errors.To11aiApiError,
|
|
52
|
+
To11aiAuthError: () => import_errors.To11aiAuthError,
|
|
53
|
+
To11aiError: () => import_errors.To11aiError,
|
|
54
|
+
To11aiNetworkError: () => import_errors.To11aiNetworkError,
|
|
55
|
+
To11aiRateLimitError: () => import_errors.To11aiRateLimitError,
|
|
56
|
+
To11aiValidationError: () => import_errors.To11aiValidationError,
|
|
57
|
+
Turn: () => import_context2.Turn,
|
|
58
|
+
UnknownRoleError: () => import_errors.UnknownRoleError,
|
|
59
|
+
UsageResource: () => import_resource6.UsageResource,
|
|
60
|
+
createClient: () => createClient,
|
|
61
|
+
gatewayAuthHeaders: () => import_gateway2.gatewayAuthHeaders,
|
|
62
|
+
gatewayPromptHeaders: () => import_gateway2.gatewayPromptHeaders,
|
|
63
|
+
iterateCursorItems: () => import_pagination.iterateCursorItems,
|
|
64
|
+
iterateCursorPages: () => import_pagination.iterateCursorPages
|
|
62
65
|
});
|
|
63
66
|
module.exports = __toCommonJS(exports_client);
|
|
64
67
|
var import_store = require("./behaviors/store");
|
|
@@ -69,12 +72,15 @@ var import_resource = require("./projectEnvironments/resource");
|
|
|
69
72
|
var import_resource2 = require("./prompts/resource");
|
|
70
73
|
var import_types = require("./prompts/types");
|
|
71
74
|
var import_transport = require("./transport");
|
|
75
|
+
var import_resource3 = require("./usage/resource");
|
|
72
76
|
var import_context2 = require("./context");
|
|
73
77
|
var import_errors = require("./errors");
|
|
74
78
|
var import_gateway2 = require("./gateway");
|
|
75
|
-
var
|
|
76
|
-
var import_resource4 = require("./
|
|
79
|
+
var import_pagination = require("./pagination");
|
|
80
|
+
var import_resource4 = require("./projectEnvironments/resource");
|
|
81
|
+
var import_resource5 = require("./prompts/resource");
|
|
77
82
|
var import_types2 = require("./prompts/types");
|
|
83
|
+
var import_resource6 = require("./usage/resource");
|
|
78
84
|
function createClient(options = {}) {
|
|
79
85
|
const isDomBrowser = typeof globalThis === "object" && typeof globalThis.document !== "undefined";
|
|
80
86
|
const workerLikeGlobal = globalThis;
|
|
@@ -128,6 +134,7 @@ function createClient(options = {}) {
|
|
|
128
134
|
onUnknownRole: options.onUnknownRole
|
|
129
135
|
});
|
|
130
136
|
const projectEnvironments = new import_resource.ProjectEnvironmentResource(transport);
|
|
137
|
+
const usage = new import_resource3.UsageResource(transport);
|
|
131
138
|
const gatewayAuthContext = () => {
|
|
132
139
|
if (projectId === undefined) {
|
|
133
140
|
throw new Error("[to11ai/sdk] session()/turn() need a `projectId` (or `TO11_PROJECT_ID`).");
|
|
@@ -162,6 +169,7 @@ function createClient(options = {}) {
|
|
|
162
169
|
return {
|
|
163
170
|
prompts,
|
|
164
171
|
projectEnvironments,
|
|
172
|
+
usage,
|
|
165
173
|
apiKey,
|
|
166
174
|
baseUrl,
|
|
167
175
|
gatewayUrl,
|
package/dist/client.d.ts
CHANGED
|
@@ -2,12 +2,15 @@ import { type Conversation, Session, type Turn } from "./context";
|
|
|
2
2
|
import { ProjectEnvironmentResource } from "./projectEnvironments/resource";
|
|
3
3
|
import { PromptResource } from "./prompts/resource";
|
|
4
4
|
import { type RenderFormat, type UnknownRoleMode } from "./prompts/types";
|
|
5
|
+
import { UsageResource } from "./usage/resource";
|
|
5
6
|
export type { TurnAuthContext } from "./context";
|
|
6
7
|
export { Conversation, Session, Turn } from "./context";
|
|
7
8
|
export type { PromptHasNoVersionsReason, PromptNotFoundReason, PromptPolicyViolationReason, } from "./errors";
|
|
8
9
|
export { LabelNotFoundError, PromptHasNoVersionsError, PromptNotFoundError, PromptPolicyViolationError, To11aiApiError, To11aiAuthError, To11aiError, To11aiNetworkError, To11aiRateLimitError, To11aiValidationError, UnknownRoleError, } from "./errors";
|
|
9
10
|
export type { ConvertMessagesOptions, GatewayAuthOptions } from "./gateway";
|
|
10
11
|
export { gatewayAuthHeaders, gatewayPromptHeaders } from "./gateway";
|
|
12
|
+
export type { CursorPaginatedResult, CursorPaginationInfo, FetchCursorPage, } from "./pagination";
|
|
13
|
+
export { iterateCursorItems, iterateCursorPages } from "./pagination";
|
|
11
14
|
export type { ArchiveProjectEnvironmentInput, ArchiveProjectEnvironmentResult, CreateProjectEnvironmentInput, CreateProjectEnvironmentResult, GetProjectEnvironmentInput, GetProjectEnvironmentResult, ListProjectEnvironmentsInput, ListProjectEnvironmentsResult, ProjectEnvironment, RestoreProjectEnvironmentInput, RestoreProjectEnvironmentResult, UpdateProjectEnvironmentInput, UpdateProjectEnvironmentResult, } from "./projectEnvironments/resource";
|
|
12
15
|
export { ProjectEnvironmentResource } from "./projectEnvironments/resource";
|
|
13
16
|
export type { PromptResourceConfig } from "./prompts/resource";
|
|
@@ -15,6 +18,7 @@ export { PromptResource } from "./prompts/resource";
|
|
|
15
18
|
export type { AnthropicRenderedPrompt, OpenAiRenderedPrompt, PromptConfig, PromptMetadata, RenderResult, } from "./prompts/shape";
|
|
16
19
|
export type { BlockRenderRecord, RenderedChatMessage, RenderedPrompt, RenderFormat, RenderOptions, UnknownRoleMode, } from "./prompts/types";
|
|
17
20
|
export { ENV_SLUG_REGEX } from "./prompts/types";
|
|
21
|
+
export { UsageResource } from "./usage/resource";
|
|
18
22
|
export interface ClientOptions {
|
|
19
23
|
/**
|
|
20
24
|
* Control-plane base URL. Precedence: this option → `TO11_API_URL` env →
|
|
@@ -99,6 +103,8 @@ export type ProviderClientOptions<T extends ProviderClientOverrides = ProviderCl
|
|
|
99
103
|
export interface To11aiClient<F extends RenderFormat | undefined = undefined> {
|
|
100
104
|
readonly prompts: PromptResource<F>;
|
|
101
105
|
readonly projectEnvironments: ProjectEnvironmentResource;
|
|
106
|
+
/** Org usage reads: members, sessions, costs and top traces (`orgId` per call). */
|
|
107
|
+
readonly usage: UsageResource;
|
|
102
108
|
/** Resolved API key (option → `TO11_API_KEY`). */
|
|
103
109
|
readonly apiKey: string;
|
|
104
110
|
/** Resolved control-plane base URL (option → `TO11_API_URL` → default). */
|
package/dist/client.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
ENV_SLUG_REGEX
|
|
12
12
|
} from "./prompts/types";
|
|
13
13
|
import { Transport } from "./transport";
|
|
14
|
+
import { UsageResource } from "./usage/resource";
|
|
14
15
|
import { Conversation, Session as Session2, Turn } from "./context";
|
|
15
16
|
import {
|
|
16
17
|
LabelNotFoundError,
|
|
@@ -26,9 +27,11 @@ import {
|
|
|
26
27
|
UnknownRoleError
|
|
27
28
|
} from "./errors";
|
|
28
29
|
import { gatewayAuthHeaders as gatewayAuthHeaders2, gatewayPromptHeaders } from "./gateway";
|
|
30
|
+
import { iterateCursorItems, iterateCursorPages } from "./pagination";
|
|
29
31
|
import { ProjectEnvironmentResource as ProjectEnvironmentResource2 } from "./projectEnvironments/resource";
|
|
30
32
|
import { PromptResource as PromptResource2 } from "./prompts/resource";
|
|
31
33
|
import { ENV_SLUG_REGEX as ENV_SLUG_REGEX2 } from "./prompts/types";
|
|
34
|
+
import { UsageResource as UsageResource2 } from "./usage/resource";
|
|
32
35
|
function createClient(options = {}) {
|
|
33
36
|
const isDomBrowser = typeof globalThis === "object" && typeof globalThis.document !== "undefined";
|
|
34
37
|
const workerLikeGlobal = globalThis;
|
|
@@ -82,6 +85,7 @@ function createClient(options = {}) {
|
|
|
82
85
|
onUnknownRole: options.onUnknownRole
|
|
83
86
|
});
|
|
84
87
|
const projectEnvironments = new ProjectEnvironmentResource(transport);
|
|
88
|
+
const usage = new UsageResource(transport);
|
|
85
89
|
const gatewayAuthContext = () => {
|
|
86
90
|
if (projectId === undefined) {
|
|
87
91
|
throw new Error("[to11ai/sdk] session()/turn() need a `projectId` (or `TO11_PROJECT_ID`).");
|
|
@@ -116,6 +120,7 @@ function createClient(options = {}) {
|
|
|
116
120
|
return {
|
|
117
121
|
prompts,
|
|
118
122
|
projectEnvironments,
|
|
123
|
+
usage,
|
|
119
124
|
apiKey,
|
|
120
125
|
baseUrl,
|
|
121
126
|
gatewayUrl,
|
|
@@ -129,24 +134,27 @@ function createClient(options = {}) {
|
|
|
129
134
|
};
|
|
130
135
|
}
|
|
131
136
|
export {
|
|
132
|
-
|
|
133
|
-
gatewayAuthHeaders2 as gatewayAuthHeaders,
|
|
134
|
-
createClient,
|
|
135
|
-
UnknownRoleError,
|
|
136
|
-
Turn,
|
|
137
|
-
To11aiValidationError,
|
|
138
|
-
To11aiRateLimitError,
|
|
139
|
-
To11aiNetworkError,
|
|
140
|
-
To11aiError,
|
|
141
|
-
To11aiAuthError,
|
|
142
|
-
To11aiApiError,
|
|
143
|
-
Session2 as Session,
|
|
144
|
-
PromptResource2 as PromptResource,
|
|
145
|
-
PromptPolicyViolationError,
|
|
146
|
-
PromptNotFoundError,
|
|
147
|
-
PromptHasNoVersionsError,
|
|
148
|
-
ProjectEnvironmentResource2 as ProjectEnvironmentResource,
|
|
149
|
-
LabelNotFoundError,
|
|
137
|
+
Conversation,
|
|
150
138
|
ENV_SLUG_REGEX2 as ENV_SLUG_REGEX,
|
|
151
|
-
|
|
139
|
+
LabelNotFoundError,
|
|
140
|
+
ProjectEnvironmentResource2 as ProjectEnvironmentResource,
|
|
141
|
+
PromptHasNoVersionsError,
|
|
142
|
+
PromptNotFoundError,
|
|
143
|
+
PromptPolicyViolationError,
|
|
144
|
+
PromptResource2 as PromptResource,
|
|
145
|
+
Session2 as Session,
|
|
146
|
+
To11aiApiError,
|
|
147
|
+
To11aiAuthError,
|
|
148
|
+
To11aiError,
|
|
149
|
+
To11aiNetworkError,
|
|
150
|
+
To11aiRateLimitError,
|
|
151
|
+
To11aiValidationError,
|
|
152
|
+
Turn,
|
|
153
|
+
UnknownRoleError,
|
|
154
|
+
UsageResource2 as UsageResource,
|
|
155
|
+
createClient,
|
|
156
|
+
gatewayAuthHeaders2 as gatewayAuthHeaders,
|
|
157
|
+
gatewayPromptHeaders,
|
|
158
|
+
iterateCursorItems,
|
|
159
|
+
iterateCursorPages
|
|
152
160
|
};
|
package/dist/errors.cjs
CHANGED
|
@@ -39,25 +39,24 @@ var __export = (target, all) => {
|
|
|
39
39
|
// src/errors.ts
|
|
40
40
|
var exports_errors = {};
|
|
41
41
|
__export(exports_errors, {
|
|
42
|
-
|
|
43
|
-
To11aiValidationError: () => To11aiValidationError,
|
|
44
|
-
To11aiResponseValidationError: () => To11aiResponseValidationError,
|
|
45
|
-
To11aiRateLimitError: () => To11aiRateLimitError,
|
|
46
|
-
To11aiNetworkError: () => To11aiNetworkError,
|
|
47
|
-
To11aiError: () => To11aiError,
|
|
48
|
-
To11aiAuthError: () => To11aiAuthError,
|
|
49
|
-
To11aiApiError: () => To11aiApiError,
|
|
50
|
-
RuleVersionInvalidSnapshotError: () => RuleVersionInvalidSnapshotError,
|
|
51
|
-
RuleNotFoundError: () => RuleNotFoundError,
|
|
52
|
-
PromptPolicyViolationError: () => PromptPolicyViolationError,
|
|
53
|
-
PromptNotFoundError: () => PromptNotFoundError,
|
|
54
|
-
PromptHasNoVersionsError: () => PromptHasNoVersionsError,
|
|
55
|
-
NoApplicableRouteError: () => NoApplicableRouteError,
|
|
42
|
+
EnvNotEnabledForProviderError: () => EnvNotEnabledForProviderError,
|
|
56
43
|
LabelNotFoundError: () => LabelNotFoundError,
|
|
57
|
-
|
|
44
|
+
NoApplicableRouteError: () => NoApplicableRouteError,
|
|
45
|
+
PromptHasNoVersionsError: () => PromptHasNoVersionsError,
|
|
46
|
+
PromptNotFoundError: () => PromptNotFoundError,
|
|
47
|
+
PromptPolicyViolationError: () => PromptPolicyViolationError,
|
|
48
|
+
RuleNotFoundError: () => RuleNotFoundError,
|
|
49
|
+
RuleVersionInvalidSnapshotError: () => RuleVersionInvalidSnapshotError,
|
|
50
|
+
To11aiApiError: () => To11aiApiError,
|
|
51
|
+
To11aiAuthError: () => To11aiAuthError,
|
|
52
|
+
To11aiError: () => To11aiError,
|
|
53
|
+
To11aiNetworkError: () => To11aiNetworkError,
|
|
54
|
+
To11aiRateLimitError: () => To11aiRateLimitError,
|
|
55
|
+
To11aiResponseValidationError: () => To11aiResponseValidationError,
|
|
56
|
+
To11aiValidationError: () => To11aiValidationError,
|
|
57
|
+
UnknownRoleError: () => UnknownRoleError
|
|
58
58
|
});
|
|
59
59
|
module.exports = __toCommonJS(exports_errors);
|
|
60
|
-
|
|
61
60
|
class To11aiError extends Error {
|
|
62
61
|
constructor(message, options) {
|
|
63
62
|
super(message, options);
|
package/dist/errors.js
CHANGED
|
@@ -206,20 +206,20 @@ class RuleVersionInvalidSnapshotError extends To11aiApiError {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
export {
|
|
209
|
-
|
|
210
|
-
To11aiValidationError,
|
|
211
|
-
To11aiResponseValidationError,
|
|
212
|
-
To11aiRateLimitError,
|
|
213
|
-
To11aiNetworkError,
|
|
214
|
-
To11aiError,
|
|
215
|
-
To11aiAuthError,
|
|
216
|
-
To11aiApiError,
|
|
217
|
-
RuleVersionInvalidSnapshotError,
|
|
218
|
-
RuleNotFoundError,
|
|
219
|
-
PromptPolicyViolationError,
|
|
220
|
-
PromptNotFoundError,
|
|
221
|
-
PromptHasNoVersionsError,
|
|
222
|
-
NoApplicableRouteError,
|
|
209
|
+
EnvNotEnabledForProviderError,
|
|
223
210
|
LabelNotFoundError,
|
|
224
|
-
|
|
211
|
+
NoApplicableRouteError,
|
|
212
|
+
PromptHasNoVersionsError,
|
|
213
|
+
PromptNotFoundError,
|
|
214
|
+
PromptPolicyViolationError,
|
|
215
|
+
RuleNotFoundError,
|
|
216
|
+
RuleVersionInvalidSnapshotError,
|
|
217
|
+
To11aiApiError,
|
|
218
|
+
To11aiAuthError,
|
|
219
|
+
To11aiError,
|
|
220
|
+
To11aiNetworkError,
|
|
221
|
+
To11aiRateLimitError,
|
|
222
|
+
To11aiResponseValidationError,
|
|
223
|
+
To11aiValidationError,
|
|
224
|
+
UnknownRoleError
|
|
225
225
|
};
|
package/dist/gateway.cjs
CHANGED
|
@@ -39,15 +39,15 @@ var __export = (target, all) => {
|
|
|
39
39
|
// src/gateway.ts
|
|
40
40
|
var exports_gateway = {};
|
|
41
41
|
__export(exports_gateway, {
|
|
42
|
-
|
|
43
|
-
toOpenAIToolChoice: () => toOpenAIToolChoice,
|
|
44
|
-
toOpenAIMessages: () => toOpenAIMessages,
|
|
45
|
-
toAnthropicTools: () => toAnthropicTools,
|
|
46
|
-
toAnthropicToolChoice: () => toAnthropicToolChoice,
|
|
47
|
-
toAnthropicSystem: () => toAnthropicSystem,
|
|
48
|
-
toAnthropicMessages: () => toAnthropicMessages,
|
|
42
|
+
gatewayAuthHeaders: () => gatewayAuthHeaders,
|
|
49
43
|
gatewayPromptHeaders: () => gatewayPromptHeaders,
|
|
50
|
-
|
|
44
|
+
toAnthropicMessages: () => toAnthropicMessages,
|
|
45
|
+
toAnthropicSystem: () => toAnthropicSystem,
|
|
46
|
+
toAnthropicToolChoice: () => toAnthropicToolChoice,
|
|
47
|
+
toAnthropicTools: () => toAnthropicTools,
|
|
48
|
+
toOpenAIMessages: () => toOpenAIMessages,
|
|
49
|
+
toOpenAIToolChoice: () => toOpenAIToolChoice,
|
|
50
|
+
toOpenAITools: () => toOpenAITools
|
|
51
51
|
});
|
|
52
52
|
module.exports = __toCommonJS(exports_gateway);
|
|
53
53
|
var import_errors = require("./errors");
|
|
@@ -177,10 +177,10 @@ function toOpenAIMessages(messages, options = {}) {
|
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
179
|
if (message.role === "assistant") {
|
|
180
|
-
const
|
|
180
|
+
const content = message.content ?? null;
|
|
181
181
|
out.push(message.toolCalls != null && message.toolCalls.length > 0 ? {
|
|
182
182
|
role: "assistant",
|
|
183
|
-
content
|
|
183
|
+
content,
|
|
184
184
|
tool_calls: message.toolCalls.map((call) => ({
|
|
185
185
|
id: requireToolCallId(call.id),
|
|
186
186
|
type: "function",
|
|
@@ -189,7 +189,7 @@ function toOpenAIMessages(messages, options = {}) {
|
|
|
189
189
|
arguments: JSON.stringify(call.arguments)
|
|
190
190
|
}
|
|
191
191
|
}))
|
|
192
|
-
} : { role: "assistant", content
|
|
192
|
+
} : { role: "assistant", content });
|
|
193
193
|
return;
|
|
194
194
|
}
|
|
195
195
|
const content = message.content ?? "";
|
package/dist/gateway.js
CHANGED
|
@@ -128,10 +128,10 @@ function toOpenAIMessages(messages, options = {}) {
|
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
130
|
if (message.role === "assistant") {
|
|
131
|
-
const
|
|
131
|
+
const content = message.content ?? null;
|
|
132
132
|
out.push(message.toolCalls != null && message.toolCalls.length > 0 ? {
|
|
133
133
|
role: "assistant",
|
|
134
|
-
content
|
|
134
|
+
content,
|
|
135
135
|
tool_calls: message.toolCalls.map((call) => ({
|
|
136
136
|
id: requireToolCallId(call.id),
|
|
137
137
|
type: "function",
|
|
@@ -140,7 +140,7 @@ function toOpenAIMessages(messages, options = {}) {
|
|
|
140
140
|
arguments: JSON.stringify(call.arguments)
|
|
141
141
|
}
|
|
142
142
|
}))
|
|
143
|
-
} : { role: "assistant", content
|
|
143
|
+
} : { role: "assistant", content });
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
146
|
const content = message.content ?? "";
|
|
@@ -214,13 +214,13 @@ function toAnthropicSystem(messages) {
|
|
|
214
214
|
`) : undefined;
|
|
215
215
|
}
|
|
216
216
|
export {
|
|
217
|
-
|
|
218
|
-
toOpenAIToolChoice,
|
|
219
|
-
toOpenAIMessages,
|
|
220
|
-
toAnthropicTools,
|
|
221
|
-
toAnthropicToolChoice,
|
|
222
|
-
toAnthropicSystem,
|
|
223
|
-
toAnthropicMessages,
|
|
217
|
+
gatewayAuthHeaders,
|
|
224
218
|
gatewayPromptHeaders,
|
|
225
|
-
|
|
219
|
+
toAnthropicMessages,
|
|
220
|
+
toAnthropicSystem,
|
|
221
|
+
toAnthropicToolChoice,
|
|
222
|
+
toAnthropicTools,
|
|
223
|
+
toOpenAIMessages,
|
|
224
|
+
toOpenAIToolChoice,
|
|
225
|
+
toOpenAITools
|
|
226
226
|
};
|