@to11ai/sdk 2.1.0-rc.5 → 3.0.0-rc.6

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 CHANGED
@@ -36,7 +36,7 @@ const to11 = createClient({
36
36
  env: process.env.TO11_ENV, // "prod", "staging", … → TO11_ENV
37
37
  });
38
38
 
39
- // Render a released prompt for the client's project + environment.
39
+ // Render the prompt's `latest` version for the client's project.
40
40
  const prompt = await to11.prompts.render("welcome-message", {
41
41
  variables: { name: "Ada" },
42
42
  format: "openai", // omit for the provider-neutral result
@@ -62,7 +62,7 @@ const completion = await openai.chat.completions.create(
62
62
  | `gatewayUrl` | option → `TO11_GATEWAY_URL` | `https://gw.to11.ai` |
63
63
  | `apiKey` | option → `TO11_API_KEY` | — (throws if constructed in a browser) |
64
64
  | `projectId` | option → `TO11_PROJECT_ID` | — |
65
- | `env` | option → `TO11_ENV` | — (must match `^[a-z0-9-]{1,63}$`) |
65
+ | `env` | option → `TO11_ENV` | — (gateway routing via `x-to11-env`; must match `^[a-z0-9-]{1,63}$`) |
66
66
  | `providerApiKey` | option | — (BYOK; carried by `openaiOptions()`/`anthropicOptions()`) |
67
67
  | `format` | option | — (`"openai"` \| `"anthropic"`; omit for the neutral result) |
68
68
  | `onUnknownRole` | option | `"drop"` |
@@ -74,23 +74,23 @@ The client exposes read-only accessors for the resolved values — **`to11.baseU
74
74
 
75
75
  ## Rendering prompts
76
76
 
77
- `prompts.render(slug, options?)` resolves the released prompt for the client's `projectId` + `env` in one request. Set `format` (on the client or per call) to get a result shaped for that provider; omit it for the provider-neutral result.
77
+ `prompts.render(slug, options?)` resolves the prompt's `latest` version for the client's `projectId` in one request. Set `format` (on the client or per call) to get a result shaped for that provider; omit it for the provider-neutral result.
78
78
 
79
79
  ```typescript
80
80
  const prompt = await to11.prompts.render("weather-concierge", {
81
81
  variables: { city: "New York", units: "fahrenheit" },
82
- // label?: label to resolve for this call (defaults to the client's env)
82
+ // label?: label to resolve for this call (defaults to "latest", the one label a prompt carries)
83
83
  // fallback?: a previously-rendered RenderedPrompt served on a network error
84
84
  // format?: "openai" | "anthropic"
85
85
  });
86
86
  ```
87
87
 
88
- - **With `format`** the result is spread-ready: `{ messages, config, metadata }` (`config` = the version's model params; `metadata` = prompt/version/release provenance).
89
- - **Without `format`** you get the neutral **`RenderedPrompt`**: `messages`, `tools`, `toolChoice`, `promptId`, `version`, `versionId`, `releaseId`, `contentHash`, `label`, `slug`, `blockRenderRecord`, and `modelConfig`. This is the path for providers the shaper doesn't cover (Vercel AI, LangChain) or for driving one prompt through more than one provider.
88
+ - **With `format`** the result is spread-ready: `{ messages, config, metadata }` (`config` = the version's model params; `metadata` = prompt/version provenance).
89
+ - **Without `format`** you get the neutral **`RenderedPrompt`**: `messages`, `tools`, `toolChoice`, `promptId`, `version`, `versionId`, `contentHash`, `label`, `slug`, `blockRenderRecord`, and `modelConfig`. This is the path for providers the shaper doesn't cover (Vercel AI, LangChain) or for driving one prompt through more than one provider.
90
90
 
91
91
  Authored `developer` blocks come back as-is; the SDK maps them per provider (OpenAI keeps `developer`; Anthropic folds `system`/`developer` into the top-level `system`). `onUnknownRole` (`"drop"` default, `"warn"`, `"error"`) controls how an unrecognized role is handled during provider conversion.
92
92
 
93
- > Prompts render as **chat blocks**. The pre-2.0 `resolve()` and the `text` render format have been removed — use `render()` with a `label` (the client's `env` is the default; env is just a label value).
93
+ > Prompts render as **chat blocks**. The pre-2.0 `resolve()` and the `text` render format have been removed — use `render()`. A prompt carries one label, `latest`, which follows the newest version; the client's `env` routes gateway calls and never selects a prompt version.
94
94
 
95
95
  ## Sending through the gateway
96
96
 
@@ -117,10 +117,18 @@ const to11 = createClient({ apiKey, projectId: "proj_abc123" });
117
117
  await to11.prompts.list(); // uses the bound projectId
118
118
  await to11.prompts.get({ promptId: "prompt_1" });
119
119
  await to11.prompts.getVersion({ promptId: "prompt_1", versionNumber: 3 });
120
- await to11.prompts.moveLabel({ promptId: "prompt_1", label: "production", versionId: "ver_9", reason: "promote" });
120
+ await to11.prompts.listLabels({ promptId: "prompt_1" }); // [{ label: "latest", versionId: "ver_9", … }]
121
121
  ```
122
122
 
123
- Full set: `create`, `list`, `get`, `update`, `archive`, `createVersion`, `listVersions`, `getVersion`, `moveLabel`, `listLabels`, and the project-label registry (`listProjectLabels`, `createProjectLabel`, `getProjectLabel`, `updateProjectLabel`, `deleteProjectLabel`, `listProjectLabelUsages`, `listLabelEvents`). `client.projectEnvironments` exposes the project-environments registry.
123
+ `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`:
124
+
125
+ ```typescript
126
+ const page = await to11.prompts.listVersions({ promptId: "prompt_1", limit: 20 });
127
+ // page.items: PromptVersionSummary[] page.pagination: { nextCursor: string | null, limit: number }
128
+ const newest = await to11.prompts.getVersion({ promptId: "prompt_1", versionNumber: page.items[0].version });
129
+ ```
130
+
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.
124
132
 
125
133
  ## Error handling
126
134
 
@@ -145,7 +153,7 @@ try {
145
153
  | `To11aiRateLimitError` | 429 (`retryAfterSeconds`) |
146
154
  | `To11aiValidationError` | 400 |
147
155
  | `To11aiNetworkError` | network failure / timeout |
148
- | `PromptNotFoundError` · `LabelNotFoundError` · `MissingLabelError` · `NoActiveReleaseError` · `PromptPolicyViolationError` · `PromptLabelNotRegisteredError` | typed prompt-resolution errors |
156
+ | `PromptNotFoundError` · `LabelNotFoundError` · `PromptHasNoVersionsError` · `PromptPolicyViolationError` | typed prompt-resolution errors |
149
157
  | `UnknownRoleError` | an unrecognized message role with `onUnknownRole: "error"` |
150
158
 
151
159
  ## TypeScript types
package/dist/client.cjs CHANGED
@@ -54,10 +54,8 @@ __export(exports_client, {
54
54
  PromptResource: () => import_resource4.PromptResource,
55
55
  PromptPolicyViolationError: () => import_errors.PromptPolicyViolationError,
56
56
  PromptNotFoundError: () => import_errors.PromptNotFoundError,
57
- PromptLabelNotRegisteredError: () => import_errors.PromptLabelNotRegisteredError,
57
+ PromptHasNoVersionsError: () => import_errors.PromptHasNoVersionsError,
58
58
  ProjectEnvironmentResource: () => import_resource3.ProjectEnvironmentResource,
59
- NoActiveReleaseError: () => import_errors.NoActiveReleaseError,
60
- MissingLabelError: () => import_errors.MissingLabelError,
61
59
  LabelNotFoundError: () => import_errors.LabelNotFoundError,
62
60
  ENV_SLUG_REGEX: () => import_types2.ENV_SLUG_REGEX,
63
61
  Conversation: () => import_context2.Conversation
@@ -126,7 +124,6 @@ function createClient(options = {}) {
126
124
  });
127
125
  const prompts = new import_resource2.PromptResource(transport, {
128
126
  projectId,
129
- env,
130
127
  format: options.format,
131
128
  onUnknownRole: options.onUnknownRole
132
129
  });
package/dist/client.d.ts CHANGED
@@ -4,11 +4,11 @@ import { PromptResource } from "./prompts/resource";
4
4
  import { type RenderFormat, type UnknownRoleMode } from "./prompts/types";
5
5
  export type { TurnAuthContext } from "./context";
6
6
  export { Conversation, Session, Turn } from "./context";
7
- export type { NoActiveReleaseReason, PromptNotFoundReason, PromptPolicyViolationReason, } from "./errors";
8
- export { LabelNotFoundError, MissingLabelError, NoActiveReleaseError, PromptLabelNotRegisteredError, PromptNotFoundError, PromptPolicyViolationError, To11aiApiError, To11aiAuthError, To11aiError, To11aiNetworkError, To11aiRateLimitError, To11aiValidationError, UnknownRoleError, } from "./errors";
7
+ export type { PromptHasNoVersionsReason, PromptNotFoundReason, PromptPolicyViolationReason, } from "./errors";
8
+ export { LabelNotFoundError, PromptHasNoVersionsError, PromptNotFoundError, PromptPolicyViolationError, To11aiApiError, To11aiAuthError, To11aiError, To11aiNetworkError, To11aiRateLimitError, To11aiValidationError, UnknownRoleError, } from "./errors";
9
9
  export type { ConvertMessagesOptions, GatewayAuthOptions } from "./gateway";
10
10
  export { gatewayAuthHeaders, gatewayPromptHeaders } from "./gateway";
11
- export type { ArchiveProjectEnvironmentInput, ArchiveProjectEnvironmentResult, CreateProjectEnvironmentInput, CreateProjectEnvironmentResult, GetProjectEnvironmentInput, GetProjectEnvironmentResult, ListProjectEnvironmentsInput, ListProjectEnvironmentsResult, LivePointerCounts, ProjectEnvironment, RestoreProjectEnvironmentInput, RestoreProjectEnvironmentResult, UpdateProjectEnvironmentInput, UpdateProjectEnvironmentResult, } from "./projectEnvironments/resource";
11
+ export type { ArchiveProjectEnvironmentInput, ArchiveProjectEnvironmentResult, CreateProjectEnvironmentInput, CreateProjectEnvironmentResult, GetProjectEnvironmentInput, GetProjectEnvironmentResult, ListProjectEnvironmentsInput, ListProjectEnvironmentsResult, ProjectEnvironment, RestoreProjectEnvironmentInput, RestoreProjectEnvironmentResult, UpdateProjectEnvironmentInput, UpdateProjectEnvironmentResult, } from "./projectEnvironments/resource";
12
12
  export { ProjectEnvironmentResource } from "./projectEnvironments/resource";
13
13
  export type { PromptResourceConfig } from "./prompts/resource";
14
14
  export { PromptResource } from "./prompts/resource";
@@ -48,10 +48,12 @@ export interface ClientOptions {
48
48
  */
49
49
  projectId?: string;
50
50
  /**
51
- * Default serving environment for `prompts.render(slug)`, inherited by every
52
- * render unless overridden per call. Precedence: this option → `TO11_ENV`
53
- * env. Validated eagerly against the project-environments slug rule
54
- * (`^[a-z0-9-]{1,63}$`).
51
+ * Gateway environment, sent as `x-to11-env` by `turn().headers()` and the
52
+ * `openaiOptions()` / `anthropicOptions()` tenant headers so the gateway
53
+ * routes the call. Precedence: this option → `TO11_ENV` env. Validated
54
+ * eagerly against the project-environments slug rule (`^[a-z0-9-]{1,63}$`).
55
+ * Prompts are not environment-scoped: `prompts.render()` serves `latest`
56
+ * regardless of `env`.
55
57
  */
56
58
  env?: string;
57
59
  /**
@@ -110,8 +112,8 @@ export interface To11aiClient<F extends RenderFormat | undefined = undefined> {
110
112
  */
111
113
  readonly projectId: string | undefined;
112
114
  /**
113
- * Resolved default serving environment (option → `TO11_ENV`); `undefined`
114
- * when none is configured. `prompts.render()` already defaults to it.
115
+ * Resolved gateway environment (option → `TO11_ENV`); `undefined` when none
116
+ * is configured. The gateway helpers already send it as `x-to11-env`.
115
117
  */
116
118
  readonly env: string | undefined;
117
119
  /** A new session (unit of work). Pass an id to group telemetry by your own id. */
@@ -154,7 +156,7 @@ export interface To11aiClient<F extends RenderFormat | undefined = undefined> {
154
156
  * Create a to11ai SDK client. Resolution precedence differs per option:
155
157
  * - URLs (`baseUrl` / `gatewayUrl`) — option → env var → built-in default.
156
158
  * - `apiKey` / `projectId` — option → env var (no default).
157
- * - `env` / `format` — option only.
159
+ * - `env` — option → `TO11_ENV` (gateway routing); `format` — option only.
158
160
  * Authenticate with `apiKey` (or `TO11_API_KEY`) — required, and server-side
159
161
  * only (server, CLI, backend job); constructing with `apiKey` in a browser throws.
160
162
  *
package/dist/client.js CHANGED
@@ -14,9 +14,7 @@ import { Transport } from "./transport";
14
14
  import { Conversation, Session as Session2, Turn } from "./context";
15
15
  import {
16
16
  LabelNotFoundError,
17
- MissingLabelError,
18
- NoActiveReleaseError,
19
- PromptLabelNotRegisteredError,
17
+ PromptHasNoVersionsError,
20
18
  PromptNotFoundError,
21
19
  PromptPolicyViolationError,
22
20
  To11aiApiError,
@@ -80,7 +78,6 @@ function createClient(options = {}) {
80
78
  });
81
79
  const prompts = new PromptResource(transport, {
82
80
  projectId,
83
- env,
84
81
  format: options.format,
85
82
  onUnknownRole: options.onUnknownRole
86
83
  });
@@ -147,10 +144,8 @@ export {
147
144
  PromptResource2 as PromptResource,
148
145
  PromptPolicyViolationError,
149
146
  PromptNotFoundError,
150
- PromptLabelNotRegisteredError,
147
+ PromptHasNoVersionsError,
151
148
  ProjectEnvironmentResource2 as ProjectEnvironmentResource,
152
- NoActiveReleaseError,
153
- MissingLabelError,
154
149
  LabelNotFoundError,
155
150
  ENV_SLUG_REGEX2 as ENV_SLUG_REGEX,
156
151
  Conversation
package/dist/errors.cjs CHANGED
@@ -51,10 +51,8 @@ __export(exports_errors, {
51
51
  RuleNotFoundError: () => RuleNotFoundError,
52
52
  PromptPolicyViolationError: () => PromptPolicyViolationError,
53
53
  PromptNotFoundError: () => PromptNotFoundError,
54
- PromptLabelNotRegisteredError: () => PromptLabelNotRegisteredError,
54
+ PromptHasNoVersionsError: () => PromptHasNoVersionsError,
55
55
  NoApplicableRouteError: () => NoApplicableRouteError,
56
- NoActiveReleaseError: () => NoActiveReleaseError,
57
- MissingLabelError: () => MissingLabelError,
58
56
  LabelNotFoundError: () => LabelNotFoundError,
59
57
  EnvNotEnabledForProviderError: () => EnvNotEnabledForProviderError
60
58
  });
@@ -147,21 +145,6 @@ class UnknownRoleError extends To11aiError {
147
145
  }
148
146
  }
149
147
 
150
- class PromptLabelNotRegisteredError extends To11aiApiError {
151
- projectId;
152
- label;
153
- constructor(message, projectId, label, details) {
154
- super(message, 422, "PROMPT_LABEL_NOT_REGISTERED", details !== undefined ? details : { projectId, label });
155
- this.name = "PromptLabelNotRegisteredError";
156
- this.projectId = projectId;
157
- this.label = label;
158
- Object.setPrototypeOf(this, new.target.prototype);
159
- }
160
- static is(err) {
161
- return err instanceof PromptLabelNotRegisteredError;
162
- }
163
- }
164
-
165
148
  class RuleNotFoundError extends To11aiApiError {
166
149
  ruleId;
167
150
  model;
@@ -228,8 +211,8 @@ class PromptNotFoundError extends To11aiApiError {
228
211
 
229
212
  class LabelNotFoundError extends To11aiApiError {
230
213
  label;
231
- constructor(message, label, details, statusCode) {
232
- super(message, statusCode, "ENV_NOT_FOUND", details);
214
+ constructor(message, label, details, statusCode = 404) {
215
+ super(message, statusCode, "LABEL_NOT_FOUND", details);
233
216
  this.name = "LabelNotFoundError";
234
217
  this.label = label;
235
218
  Object.setPrototypeOf(this, new.target.prototype);
@@ -239,27 +222,16 @@ class LabelNotFoundError extends To11aiApiError {
239
222
  }
240
223
  }
241
224
 
242
- class MissingLabelError extends To11aiError {
243
- constructor(message = "[to11ai/sdk] No label resolvable for prompts.render(): none supplied per call, and no client env (or TO11_ENV) to fall back to. Pass `label` to render(slug, { label }) or set `env` on createClient.") {
244
- super(message);
245
- this.name = "MissingLabelError";
246
- Object.setPrototypeOf(this, new.target.prototype);
247
- }
248
- static is(err) {
249
- return err instanceof MissingLabelError;
250
- }
251
- }
252
-
253
- class NoActiveReleaseError extends To11aiApiError {
225
+ class PromptHasNoVersionsError extends To11aiApiError {
254
226
  reason;
255
227
  constructor(message, reason, details, statusCode = 409) {
256
- super(message, statusCode, "NO_ACTIVE_RELEASE", details);
257
- this.name = "NoActiveReleaseError";
228
+ super(message, statusCode, "PROMPT_HAS_NO_VERSIONS", details);
229
+ this.name = "PromptHasNoVersionsError";
258
230
  this.reason = reason;
259
231
  Object.setPrototypeOf(this, new.target.prototype);
260
232
  }
261
233
  static is(err) {
262
- return err instanceof NoActiveReleaseError;
234
+ return err instanceof PromptHasNoVersionsError;
263
235
  }
264
236
  }
265
237
 
package/dist/errors.d.ts CHANGED
@@ -68,25 +68,6 @@ export declare class UnknownRoleError extends To11aiError {
68
68
  constructor(role: string, index: number);
69
69
  static is(err: unknown): err is UnknownRoleError;
70
70
  }
71
- /**
72
- * Thrown when strict-mode rejects a label move for an unregistered label.
73
- *
74
- * The API returns 422 with `error.code === "PROMPT_LABEL_NOT_REGISTERED"`
75
- * when `project.enforce_label_registry = true` and the caller tries to
76
- * move a label that has no active entry in the project label registry.
77
- * The transport surfaces these as this typed subclass; existing
78
- * `instanceof To11aiApiError` blocks still match.
79
- *
80
- * Note: this extends `To11aiApiError` directly (not `To11aiValidationError`,
81
- * which hardcodes status 400). The API returns 422 for this case.
82
- */
83
- export declare class PromptLabelNotRegisteredError extends To11aiApiError {
84
- readonly projectId: string;
85
- readonly label: string;
86
- constructor(message: string, projectId: string, label: string, details?: unknown);
87
- /** Type guard helper — checks `instanceof` (not parent + errorCode string). */
88
- static is(err: unknown): err is PromptLabelNotRegisteredError;
89
- }
90
71
  /**
91
72
  * Thrown when a rule cannot be located. Covers two variants of the same
92
73
  * named class (single class so existing `catch (err: RuleNotFoundError)`
@@ -147,22 +128,15 @@ export declare class EnvNotEnabledForProviderError extends To11aiApiError {
147
128
  * Reason payload for `PromptNotFoundError`.
148
129
  *
149
130
  * Surfaced when the server cannot resolve the prompt for the given slug
150
- * (`PROMPT_NOT_FOUND`) or cannot find a version matching the supplied
151
- * labels (`PROMPT_LABELS_NOT_FOUND`). `slug` / `projectId` are echoed from
152
- * the request context when the server provides them in `details`.
131
+ * (`PROMPT_NOT_FOUND`). `slug` / `projectId` are echoed from the request
132
+ * context when the server provides them in `details`.
153
133
  */
154
134
  export interface PromptNotFoundReason {
155
135
  slug?: string;
156
136
  projectId?: string;
157
137
  }
158
138
  /**
159
- * Thrown when a prompt cannot be resolved. Covers two server codes (single
160
- * class so one `catch` matches both):
161
- *
162
- * * `PROMPT_NOT_FOUND` — no prompt exists for the requested slug.
163
- * * `PROMPT_LABELS_NOT_FOUND` — the prompt exists but no version matches
164
- * all the supplied labels (the `env`→label resolution found nothing).
165
- *
139
+ * Thrown when no prompt exists for the requested slug (`PROMPT_NOT_FOUND`).
166
140
  * Surfaces at HTTP 404 (the canonical code lives in `details.code`).
167
141
  */
168
142
  export declare class PromptNotFoundError extends To11aiApiError {
@@ -171,50 +145,35 @@ export declare class PromptNotFoundError extends To11aiApiError {
171
145
  static is(err: unknown): err is PromptNotFoundError;
172
146
  }
173
147
  /**
174
- * Thrown when the label supplied to `prompts.render()` does not resolve to an
175
- * existing (active) label on the server. Surfaced from the server's
176
- * `ENV_NOT_FOUND` code; `label` carries the rejected slug when the server
177
- * echoes it.
178
- *
179
- * This is distinct from `MissingLabelError`, which is raised client-side when
180
- * no label was supplied at all.
148
+ * Thrown when the label supplied to `prompts.render()` is not one the prompt
149
+ * carries. A prompt has exactly one label, `latest`, so any other value is
150
+ * rejected server-side with `LABEL_NOT_FOUND` (HTTP 404); `label` carries the
151
+ * rejected value when the server echoes it.
181
152
  */
182
153
  export declare class LabelNotFoundError extends To11aiApiError {
183
- /** The label slug that could not be found, when the server echoes it. */
154
+ /** The label that could not be found, when the server echoes it. */
184
155
  readonly label?: string;
185
- constructor(message: string, label: string | undefined, details: unknown, statusCode: number);
156
+ constructor(message: string, label: string | undefined, details?: unknown, statusCode?: number);
186
157
  static is(err: unknown): err is LabelNotFoundError;
187
158
  }
188
159
  /**
189
- * Thrown CLIENT-side, eagerly (before any request), when `prompts.render()` is
190
- * called but no label is resolvable at all: none supplied per call, and no
191
- * client `env` (or `TO11_ENV`) to fall back to. A usage error, not a lookup
192
- * failure — distinct from `LabelNotFoundError`.
193
- */
194
- export declare class MissingLabelError extends To11aiError {
195
- constructor(message?: string);
196
- static is(err: unknown): err is MissingLabelError;
197
- }
198
- /**
199
- * Reason payload for `NoActiveReleaseError`.
160
+ * Reason payload for `PromptHasNoVersionsError`.
200
161
  *
201
- * Identifies the prompt (by `slug` and/or `promptId`) and the `env` for
202
- * which no active release row exists.
162
+ * Identifies the prompt (by `slug` and/or `promptId`) that has no version yet.
203
163
  */
204
- export interface NoActiveReleaseReason {
164
+ export interface PromptHasNoVersionsReason {
205
165
  slug?: string;
206
166
  promptId?: string;
207
- env?: string;
208
167
  }
209
168
  /**
210
- * Thrown when a prompt resolves but has no active release for the requested
211
- * env (`NO_ACTIVE_RELEASE`). The release primitive (S3) found the prompt but
212
- * nothing is currently serving in that environment.
169
+ * Thrown when the prompt exists but has no version to serve
170
+ * (`PROMPT_HAS_NO_VERSIONS`, HTTP 409): `latest` has nothing to point at until
171
+ * the first version is created.
213
172
  */
214
- export declare class NoActiveReleaseError extends To11aiApiError {
215
- readonly reason: NoActiveReleaseReason;
216
- constructor(message: string, reason: NoActiveReleaseReason, details?: unknown, statusCode?: number);
217
- static is(err: unknown): err is NoActiveReleaseError;
173
+ export declare class PromptHasNoVersionsError extends To11aiApiError {
174
+ readonly reason: PromptHasNoVersionsReason;
175
+ constructor(message: string, reason: PromptHasNoVersionsReason, details?: unknown, statusCode?: number);
176
+ static is(err: unknown): err is PromptHasNoVersionsError;
218
177
  }
219
178
  /**
220
179
  * Reason payload for `PromptPolicyViolationError`.
package/dist/errors.js CHANGED
@@ -86,21 +86,6 @@ class UnknownRoleError extends To11aiError {
86
86
  }
87
87
  }
88
88
 
89
- class PromptLabelNotRegisteredError extends To11aiApiError {
90
- projectId;
91
- label;
92
- constructor(message, projectId, label, details) {
93
- super(message, 422, "PROMPT_LABEL_NOT_REGISTERED", details !== undefined ? details : { projectId, label });
94
- this.name = "PromptLabelNotRegisteredError";
95
- this.projectId = projectId;
96
- this.label = label;
97
- Object.setPrototypeOf(this, new.target.prototype);
98
- }
99
- static is(err) {
100
- return err instanceof PromptLabelNotRegisteredError;
101
- }
102
- }
103
-
104
89
  class RuleNotFoundError extends To11aiApiError {
105
90
  ruleId;
106
91
  model;
@@ -167,8 +152,8 @@ class PromptNotFoundError extends To11aiApiError {
167
152
 
168
153
  class LabelNotFoundError extends To11aiApiError {
169
154
  label;
170
- constructor(message, label, details, statusCode) {
171
- super(message, statusCode, "ENV_NOT_FOUND", details);
155
+ constructor(message, label, details, statusCode = 404) {
156
+ super(message, statusCode, "LABEL_NOT_FOUND", details);
172
157
  this.name = "LabelNotFoundError";
173
158
  this.label = label;
174
159
  Object.setPrototypeOf(this, new.target.prototype);
@@ -178,27 +163,16 @@ class LabelNotFoundError extends To11aiApiError {
178
163
  }
179
164
  }
180
165
 
181
- class MissingLabelError extends To11aiError {
182
- constructor(message = "[to11ai/sdk] No label resolvable for prompts.render(): none supplied per call, and no client env (or TO11_ENV) to fall back to. Pass `label` to render(slug, { label }) or set `env` on createClient.") {
183
- super(message);
184
- this.name = "MissingLabelError";
185
- Object.setPrototypeOf(this, new.target.prototype);
186
- }
187
- static is(err) {
188
- return err instanceof MissingLabelError;
189
- }
190
- }
191
-
192
- class NoActiveReleaseError extends To11aiApiError {
166
+ class PromptHasNoVersionsError extends To11aiApiError {
193
167
  reason;
194
168
  constructor(message, reason, details, statusCode = 409) {
195
- super(message, statusCode, "NO_ACTIVE_RELEASE", details);
196
- this.name = "NoActiveReleaseError";
169
+ super(message, statusCode, "PROMPT_HAS_NO_VERSIONS", details);
170
+ this.name = "PromptHasNoVersionsError";
197
171
  this.reason = reason;
198
172
  Object.setPrototypeOf(this, new.target.prototype);
199
173
  }
200
174
  static is(err) {
201
- return err instanceof NoActiveReleaseError;
175
+ return err instanceof PromptHasNoVersionsError;
202
176
  }
203
177
  }
204
178
 
@@ -244,10 +218,8 @@ export {
244
218
  RuleNotFoundError,
245
219
  PromptPolicyViolationError,
246
220
  PromptNotFoundError,
247
- PromptLabelNotRegisteredError,
221
+ PromptHasNoVersionsError,
248
222
  NoApplicableRouteError,
249
- NoActiveReleaseError,
250
- MissingLabelError,
251
223
  LabelNotFoundError,
252
224
  EnvNotEnabledForProviderError
253
225
  };
package/dist/gateway.cjs CHANGED
@@ -85,9 +85,6 @@ function gatewayPromptHeaders(prompt) {
85
85
  if (typeof p.version === "number" && Number.isFinite(p.version)) {
86
86
  headers["x-to11-prompt-version"] = String(p.version);
87
87
  }
88
- if (typeof p.releaseId === "string" && p.releaseId.length > 0) {
89
- headers["x-to11-release-id"] = p.releaseId;
90
- }
91
88
  if (typeof p.label === "string" && p.label.length > 0) {
92
89
  headers["x-to11-prompt-label"] = p.label;
93
90
  }
package/dist/gateway.d.ts CHANGED
@@ -39,8 +39,6 @@ export declare function gatewayAuthHeaders(options: GatewayAuthOptions): Record<
39
39
  * - `x-to11-prompt-id` — a non-empty string.
40
40
  * - `x-to11-prompt-version` — a finite number (a non-number/NaN is dropped
41
41
  * rather than stringified to junk like `"[object Object]"`).
42
- * - `x-to11-release-id` — a non-empty `releaseId` (the offline-fallback path
43
- * can carry an explicit `null`, which is omitted).
44
42
  * - `x-to11-prompt-label` — the single label the prompt resolved through.
45
43
  * - `x-to11-prompt-slug` — the prompt's human-readable slug.
46
44
  *
@@ -48,21 +46,19 @@ export declare function gatewayAuthHeaders(options: GatewayAuthOptions): Record<
48
46
  * a prompt-less `turn.headers()` call.
49
47
  *
50
48
  * @example
51
- * const result = await client.prompts.render(slug, { label: "prod" });
49
+ * const result = await client.prompts.render(slug);
52
50
  * const headers = gatewayPromptHeaders(result);
53
51
  */
54
52
  export interface GatewayPromptProvenance {
55
53
  promptId: string;
56
54
  version: number;
57
- /** The single label the prompt resolved through (env slug today). */
55
+ /** The label the prompt resolved through (`latest` unless pinned). */
58
56
  label: string;
59
57
  /**
60
58
  * The prompt's human-readable slug (the `render()`/`resolve()` input). Present
61
59
  * on an enriched `render()` result; a legacy `ResolvedPrompt` omits it.
62
60
  */
63
61
  slug?: string;
64
- /** Present on an enriched result; a legacy `resolve()` result omits it. */
65
- releaseId?: string | null;
66
62
  }
67
63
  export declare function gatewayPromptHeaders(prompt: GatewayPromptProvenance | {
68
64
  metadata: GatewayPromptProvenance;
package/dist/gateway.js CHANGED
@@ -36,9 +36,6 @@ function gatewayPromptHeaders(prompt) {
36
36
  if (typeof p.version === "number" && Number.isFinite(p.version)) {
37
37
  headers["x-to11-prompt-version"] = String(p.version);
38
38
  }
39
- if (typeof p.releaseId === "string" && p.releaseId.length > 0) {
40
- headers["x-to11-release-id"] = p.releaseId;
41
- }
42
39
  if (typeof p.label === "string" && p.label.length > 0) {
43
40
  headers["x-to11-prompt-label"] = p.label;
44
41
  }