@to11ai/sdk 3.0.0-rc.9 → 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.
Files changed (40) hide show
  1. package/README.md +31 -4
  2. package/dist/client.cjs +28 -23
  3. package/dist/client.d.ts +4 -0
  4. package/dist/client.js +26 -21
  5. package/dist/errors.cjs +15 -16
  6. package/dist/errors.js +15 -15
  7. package/dist/gateway.cjs +11 -11
  8. package/dist/gateway.js +11 -11
  9. package/dist/generated/index.d.ts +1 -1
  10. package/dist/generated/types.gen.d.ts +9480 -4788
  11. package/dist/generated/zod.gen.d.ts +8445 -5096
  12. package/dist/projectEnvironments/resource.cjs +20 -2
  13. package/dist/projectEnvironments/resource.d.ts +21 -5
  14. package/dist/projectEnvironments/resource.js +20 -2
  15. package/dist/projectEnvironments/types.d.ts +14 -1
  16. package/dist/prompts/resource.cjs +45 -3
  17. package/dist/prompts/resource.d.ts +28 -2
  18. package/dist/prompts/resource.js +57 -5
  19. package/dist/prompts/types.d.ts +33 -2
  20. package/dist/routingRules/resource.d.ts +44 -2
  21. package/dist/routingRules/types.d.ts +33 -3
  22. package/dist/transport.d.ts +5 -1
  23. package/dist/usage/resource.cjs +113 -0
  24. package/dist/usage/resource.d.ts +29 -0
  25. package/dist/usage/resource.js +78 -0
  26. package/dist/usage/types.d.ts +81 -0
  27. package/package.json +14 -6
  28. package/src/client.ts +6 -0
  29. package/src/generated/index.ts +1 -1
  30. package/src/generated/types.gen.ts +9720 -4848
  31. package/src/generated/zod.gen.ts +6103 -3109
  32. package/src/projectEnvironments/resource.ts +44 -9
  33. package/src/projectEnvironments/types.ts +19 -1
  34. package/src/prompts/resource.ts +125 -4
  35. package/src/prompts/types.ts +43 -1
  36. package/src/routingRules/resource.ts +77 -5
  37. package/src/routingRules/types.ts +35 -3
  38. package/src/transport.ts +14 -2
  39. package/src/usage/resource.ts +183 -0
  40. 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 for the current environment, and send it through the gateway with your normal provider client:
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` subpath:
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,28 +39,29 @@ var __export = (target, all) => {
39
39
  // src/client.ts
40
40
  var exports_client = {};
41
41
  __export(exports_client, {
42
- iterateCursorPages: () => import_pagination.iterateCursorPages,
43
- iterateCursorItems: () => import_pagination.iterateCursorItems,
44
- gatewayPromptHeaders: () => import_gateway2.gatewayPromptHeaders,
45
- gatewayAuthHeaders: () => import_gateway2.gatewayAuthHeaders,
46
- createClient: () => createClient,
47
- UnknownRoleError: () => import_errors.UnknownRoleError,
48
- Turn: () => import_context2.Turn,
49
- To11aiValidationError: () => import_errors.To11aiValidationError,
50
- To11aiRateLimitError: () => import_errors.To11aiRateLimitError,
51
- To11aiNetworkError: () => import_errors.To11aiNetworkError,
52
- To11aiError: () => import_errors.To11aiError,
53
- To11aiAuthError: () => import_errors.To11aiAuthError,
54
- To11aiApiError: () => import_errors.To11aiApiError,
55
- Session: () => import_context2.Session,
56
- PromptResource: () => import_resource4.PromptResource,
57
- PromptPolicyViolationError: () => import_errors.PromptPolicyViolationError,
58
- PromptNotFoundError: () => import_errors.PromptNotFoundError,
59
- PromptHasNoVersionsError: () => import_errors.PromptHasNoVersionsError,
60
- ProjectEnvironmentResource: () => import_resource3.ProjectEnvironmentResource,
61
- LabelNotFoundError: () => import_errors.LabelNotFoundError,
42
+ Conversation: () => import_context2.Conversation,
62
43
  ENV_SLUG_REGEX: () => import_types2.ENV_SLUG_REGEX,
63
- Conversation: () => import_context2.Conversation
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
64
65
  });
65
66
  module.exports = __toCommonJS(exports_client);
66
67
  var import_store = require("./behaviors/store");
@@ -71,13 +72,15 @@ var import_resource = require("./projectEnvironments/resource");
71
72
  var import_resource2 = require("./prompts/resource");
72
73
  var import_types = require("./prompts/types");
73
74
  var import_transport = require("./transport");
75
+ var import_resource3 = require("./usage/resource");
74
76
  var import_context2 = require("./context");
75
77
  var import_errors = require("./errors");
76
78
  var import_gateway2 = require("./gateway");
77
79
  var import_pagination = require("./pagination");
78
- var import_resource3 = require("./projectEnvironments/resource");
79
- var import_resource4 = require("./prompts/resource");
80
+ var import_resource4 = require("./projectEnvironments/resource");
81
+ var import_resource5 = require("./prompts/resource");
80
82
  var import_types2 = require("./prompts/types");
83
+ var import_resource6 = require("./usage/resource");
81
84
  function createClient(options = {}) {
82
85
  const isDomBrowser = typeof globalThis === "object" && typeof globalThis.document !== "undefined";
83
86
  const workerLikeGlobal = globalThis;
@@ -131,6 +134,7 @@ function createClient(options = {}) {
131
134
  onUnknownRole: options.onUnknownRole
132
135
  });
133
136
  const projectEnvironments = new import_resource.ProjectEnvironmentResource(transport);
137
+ const usage = new import_resource3.UsageResource(transport);
134
138
  const gatewayAuthContext = () => {
135
139
  if (projectId === undefined) {
136
140
  throw new Error("[to11ai/sdk] session()/turn() need a `projectId` (or `TO11_PROJECT_ID`).");
@@ -165,6 +169,7 @@ function createClient(options = {}) {
165
169
  return {
166
170
  prompts,
167
171
  projectEnvironments,
172
+ usage,
168
173
  apiKey,
169
174
  baseUrl,
170
175
  gatewayUrl,
package/dist/client.d.ts CHANGED
@@ -2,6 +2,7 @@ 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";
@@ -17,6 +18,7 @@ export { PromptResource } from "./prompts/resource";
17
18
  export type { AnthropicRenderedPrompt, OpenAiRenderedPrompt, PromptConfig, PromptMetadata, RenderResult, } from "./prompts/shape";
18
19
  export type { BlockRenderRecord, RenderedChatMessage, RenderedPrompt, RenderFormat, RenderOptions, UnknownRoleMode, } from "./prompts/types";
19
20
  export { ENV_SLUG_REGEX } from "./prompts/types";
21
+ export { UsageResource } from "./usage/resource";
20
22
  export interface ClientOptions {
21
23
  /**
22
24
  * Control-plane base URL. Precedence: this option → `TO11_API_URL` env →
@@ -101,6 +103,8 @@ export type ProviderClientOptions<T extends ProviderClientOverrides = ProviderCl
101
103
  export interface To11aiClient<F extends RenderFormat | undefined = undefined> {
102
104
  readonly prompts: PromptResource<F>;
103
105
  readonly projectEnvironments: ProjectEnvironmentResource;
106
+ /** Org usage reads: members, sessions, costs and top traces (`orgId` per call). */
107
+ readonly usage: UsageResource;
104
108
  /** Resolved API key (option → `TO11_API_KEY`). */
105
109
  readonly apiKey: string;
106
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,
@@ -30,6 +31,7 @@ import { iterateCursorItems, iterateCursorPages } from "./pagination";
30
31
  import { ProjectEnvironmentResource as ProjectEnvironmentResource2 } from "./projectEnvironments/resource";
31
32
  import { PromptResource as PromptResource2 } from "./prompts/resource";
32
33
  import { ENV_SLUG_REGEX as ENV_SLUG_REGEX2 } from "./prompts/types";
34
+ import { UsageResource as UsageResource2 } from "./usage/resource";
33
35
  function createClient(options = {}) {
34
36
  const isDomBrowser = typeof globalThis === "object" && typeof globalThis.document !== "undefined";
35
37
  const workerLikeGlobal = globalThis;
@@ -83,6 +85,7 @@ function createClient(options = {}) {
83
85
  onUnknownRole: options.onUnknownRole
84
86
  });
85
87
  const projectEnvironments = new ProjectEnvironmentResource(transport);
88
+ const usage = new UsageResource(transport);
86
89
  const gatewayAuthContext = () => {
87
90
  if (projectId === undefined) {
88
91
  throw new Error("[to11ai/sdk] session()/turn() need a `projectId` (or `TO11_PROJECT_ID`).");
@@ -117,6 +120,7 @@ function createClient(options = {}) {
117
120
  return {
118
121
  prompts,
119
122
  projectEnvironments,
123
+ usage,
120
124
  apiKey,
121
125
  baseUrl,
122
126
  gatewayUrl,
@@ -130,26 +134,27 @@ function createClient(options = {}) {
130
134
  };
131
135
  }
132
136
  export {
133
- iterateCursorPages,
134
- iterateCursorItems,
135
- gatewayPromptHeaders,
136
- gatewayAuthHeaders2 as gatewayAuthHeaders,
137
- createClient,
138
- UnknownRoleError,
139
- Turn,
140
- To11aiValidationError,
141
- To11aiRateLimitError,
142
- To11aiNetworkError,
143
- To11aiError,
144
- To11aiAuthError,
145
- To11aiApiError,
146
- Session2 as Session,
147
- PromptResource2 as PromptResource,
148
- PromptPolicyViolationError,
149
- PromptNotFoundError,
150
- PromptHasNoVersionsError,
151
- ProjectEnvironmentResource2 as ProjectEnvironmentResource,
152
- LabelNotFoundError,
137
+ Conversation,
153
138
  ENV_SLUG_REGEX2 as ENV_SLUG_REGEX,
154
- Conversation
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
155
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
- UnknownRoleError: () => UnknownRoleError,
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
- EnvNotEnabledForProviderError: () => EnvNotEnabledForProviderError
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
- UnknownRoleError,
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
- EnvNotEnabledForProviderError
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
- toOpenAITools: () => toOpenAITools,
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
- gatewayAuthHeaders: () => gatewayAuthHeaders
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 content2 = message.content ?? null;
180
+ const content = message.content ?? null;
181
181
  out.push(message.toolCalls != null && message.toolCalls.length > 0 ? {
182
182
  role: "assistant",
183
- content: content2,
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: content2 });
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 content2 = message.content ?? null;
131
+ const content = message.content ?? null;
132
132
  out.push(message.toolCalls != null && message.toolCalls.length > 0 ? {
133
133
  role: "assistant",
134
- content: content2,
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: content2 });
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
- toOpenAITools,
218
- toOpenAIToolChoice,
219
- toOpenAIMessages,
220
- toAnthropicTools,
221
- toAnthropicToolChoice,
222
- toAnthropicSystem,
223
- toAnthropicMessages,
217
+ gatewayAuthHeaders,
224
218
  gatewayPromptHeaders,
225
- gatewayAuthHeaders
219
+ toAnthropicMessages,
220
+ toAnthropicSystem,
221
+ toAnthropicToolChoice,
222
+ toAnthropicTools,
223
+ toOpenAIMessages,
224
+ toOpenAIToolChoice,
225
+ toOpenAITools
226
226
  };