@to11ai/sdk 2.1.0-rc → 2.1.0-rc.2
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 +3 -4
- package/dist/context.d.ts +1 -1
- package/dist/errors.d.ts +3 -7
- package/dist/gateway.cjs +0 -3
- package/dist/gateway.d.ts +0 -3
- package/dist/gateway.js +0 -3
- package/dist/generated/index.d.ts +1 -1
- package/dist/generated/types.gen.d.ts +455 -1275
- package/dist/generated/zod.gen.d.ts +540 -933
- package/dist/prompts/resource.cjs +1 -4
- package/dist/prompts/resource.d.ts +1 -1
- package/dist/prompts/resource.js +1 -4
- package/dist/prompts/shape.d.ts +1 -2
- package/dist/prompts/types.d.ts +0 -1
- package/dist/traceparent.d.ts +1 -1
- package/package.json +1 -1
- package/src/context.ts +1 -1
- package/src/errors.ts +3 -7
- package/src/gateway.ts +0 -7
- package/src/generated/index.ts +1 -1
- package/src/generated/types.gen.ts +459 -1310
- package/src/generated/zod.gen.ts +282 -741
- package/src/projectEnvironments/resource.ts +2 -2
- package/src/prompts/resource.ts +12 -17
- package/src/prompts/shape.ts +1 -4
- package/src/prompts/types.ts +0 -1
- package/src/traceparent.ts +1 -1
- package/src/transport.ts +5 -16
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// ---------------------------------------------------------------------------
|
|
2
2
|
// ProjectEnvironmentResource — fluent SDK surface for project environments.
|
|
3
3
|
// ---------------------------------------------------------------------------
|
|
4
|
-
// Spec: docs/
|
|
5
|
-
// Plan: docs/
|
|
4
|
+
// Spec: docs/archive-2026-08/specs/2026-05-14-environments-registry.md
|
|
5
|
+
// Plan: docs/archive-2026-08/plans/active/2026-05-14-env-registry-plan.md §S21
|
|
6
6
|
//
|
|
7
7
|
// Mirrors `PromptResource` in shape so existing call-site intuition
|
|
8
8
|
// transfers: each method takes a flat input object, unwraps the API
|
package/src/prompts/resource.ts
CHANGED
|
@@ -138,13 +138,22 @@ function getProjectPromptsPath(projectId: string): string {
|
|
|
138
138
|
* first-class case: a non-chat payload throws rather than being silently
|
|
139
139
|
* coerced (a text prompt is sugar for a single-block chat and is being removed
|
|
140
140
|
* from the API).
|
|
141
|
+
*
|
|
142
|
+
* a SKILL cannot arrive here in practice — the platform excludes
|
|
143
|
+
* skills from `GET …/prompts` unless a caller asks for them, so a consumer
|
|
144
|
+
* that never asked never learns a skill's slug, and the render response for
|
|
145
|
+
* one carries no `rendered` field for the closed generated schema to accept.
|
|
146
|
+
* The guard stays anyway, because it is why a mistake fails loudly rather than
|
|
147
|
+
* quietly, and it now says something TRUE for the case it would catch:
|
|
148
|
+
* advising a maintainer to "author the prompt as chat blocks" is impossible
|
|
149
|
+
* for a skill and would send them to change content that is already correct.
|
|
141
150
|
*/
|
|
142
151
|
function renderedToMessages(
|
|
143
152
|
rendered: ResolvedPrompt["rendered"],
|
|
144
153
|
): RenderedChatMessage[] {
|
|
145
154
|
if (rendered.format !== "chat") {
|
|
146
155
|
throw new Error(
|
|
147
|
-
|
|
156
|
+
`[to11ai/sdk] unsupported prompt format \`${rendered.format}\`: only \`chat\` resolves to messages`,
|
|
148
157
|
);
|
|
149
158
|
}
|
|
150
159
|
return rendered.messages;
|
|
@@ -156,8 +165,6 @@ function renderedToMessages(
|
|
|
156
165
|
* - `messages` is derived from the `rendered` chat payload.
|
|
157
166
|
* - `releaseId` is ALWAYS a key: a string when the server sends one, else
|
|
158
167
|
* explicit `null` (R5 `string | null`).
|
|
159
|
-
* - `variantName` is present IFF the server sent one (i.e. weighted release);
|
|
160
|
-
* absent for `single` — never `null`/`""`.
|
|
161
168
|
* - `blockRenderRecord` defaults to `{}` when the server omitted it.
|
|
162
169
|
*/
|
|
163
170
|
function normalizeResolvedEnvelope(
|
|
@@ -193,17 +200,6 @@ function normalizeResolvedEnvelope(
|
|
|
193
200
|
if (raw.toolChoice != null) {
|
|
194
201
|
result.toolChoice = raw.toolChoice;
|
|
195
202
|
}
|
|
196
|
-
// Set `variantName` only when it is a non-empty string, so the key is
|
|
197
|
-
// genuinely absent for `single`-strategy releases (R5: present IFF weighted —
|
|
198
|
-
// never `null`, never `""`). A `null`/`""` from the wire is normalized to
|
|
199
|
-
// absent, which also keeps the D8 `variantName !== undefined` weighted
|
|
200
|
-
// inference honest (Cursor).
|
|
201
|
-
if (
|
|
202
|
-
typeof provenance.variantName === "string" &&
|
|
203
|
-
provenance.variantName.length > 0
|
|
204
|
-
) {
|
|
205
|
-
result.variantName = provenance.variantName;
|
|
206
|
-
}
|
|
207
203
|
return result;
|
|
208
204
|
}
|
|
209
205
|
|
|
@@ -560,8 +556,7 @@ export class PromptResource<F extends RenderFormat | undefined = undefined> {
|
|
|
560
556
|
const { variables, fallback } = options;
|
|
561
557
|
|
|
562
558
|
// TO11-2743: slug + the single resolved label live in the PATH; the body
|
|
563
|
-
// carries only `variables`.
|
|
564
|
-
// supported by the render endpoint yet, so it's dropped from the surface.
|
|
559
|
+
// carries only `variables`.
|
|
565
560
|
const body: Record<string, unknown> = {};
|
|
566
561
|
if (variables !== undefined) body.variables = variables;
|
|
567
562
|
|
|
@@ -655,7 +650,7 @@ export class PromptResource<F extends RenderFormat | undefined = undefined> {
|
|
|
655
650
|
* Note on `description` semantics: `undefined` means "do not change" —
|
|
656
651
|
* the SDK omits the field from the body in that case. Pass
|
|
657
652
|
* `description: ""` (empty string) or `description: null` to explicitly
|
|
658
|
-
* clear it (the server
|
|
653
|
+
* clear it (the server normalizes both).
|
|
659
654
|
*/
|
|
660
655
|
async updateProjectLabel(
|
|
661
656
|
input: UpdateProjectPromptLabelInput,
|
package/src/prompts/shape.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Format-at-load shaping: turn a neutral `RenderedPrompt` into a provider-shaped
|
|
3
3
|
* `{ messages, config, metadata }` result the caller spreads into their own
|
|
4
4
|
* provider `create()` call. Header-only — this only reshapes data, it never
|
|
5
|
-
* sends a request. See docs/
|
|
5
|
+
* sends a request. See docs/archive-2026-08/specs/2026-07-14-to11-2691-sdk-simpler-setup.md.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import {
|
|
@@ -44,7 +44,6 @@ export interface PromptMetadata {
|
|
|
44
44
|
label: string;
|
|
45
45
|
/** The prompt's human-readable slug — surfaced as `x-to11-prompt-slug`. */
|
|
46
46
|
slug: string;
|
|
47
|
-
variantName?: string;
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
/** OpenAI-shaped render result: spread `{ ...config, messages }` into create(). */
|
|
@@ -94,8 +93,6 @@ function toMetadata(prompt: RenderedPrompt): PromptMetadata {
|
|
|
94
93
|
label: prompt.label,
|
|
95
94
|
slug: prompt.slug,
|
|
96
95
|
};
|
|
97
|
-
if (prompt.variantName !== undefined)
|
|
98
|
-
metadata.variantName = prompt.variantName;
|
|
99
96
|
return metadata;
|
|
100
97
|
}
|
|
101
98
|
|
package/src/prompts/types.ts
CHANGED
package/src/traceparent.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* trace/span ids in `traceparent`. We return `null` (caller omits).
|
|
17
17
|
*
|
|
18
18
|
* @see https://www.w3.org/TR/trace-context/ for the wire format.
|
|
19
|
-
* @see docs/
|
|
19
|
+
* @see docs/archive-2026-08/specs/2026-05-20-to11-1016-sdk-traceparent-propagation.md
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
// NOTE: deliberately NO top-level `import ... from "node:module"`. With the
|
package/src/transport.ts
CHANGED
|
@@ -53,23 +53,12 @@ const PROMPT_NOT_FOUND_DETAILS_CODES = new Set([
|
|
|
53
53
|
]);
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
|
-
* Prompt-resolution policy violation codes
|
|
57
|
-
* `
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* 403 policy violation is not swallowed as an auth error (D3, AC6).
|
|
56
|
+
* Prompt-resolution policy violation codes. `POLICY_VIOLATION` maps to
|
|
57
|
+
* `PromptPolicyViolationError`. This set is matched on `details.code` BEFORE
|
|
58
|
+
* the generic `401 || 403 → auth` guard so a 403 policy violation is not
|
|
59
|
+
* swallowed as an auth error (D3, AC6).
|
|
61
60
|
*/
|
|
62
|
-
const PROMPT_POLICY_VIOLATION_DETAILS_CODES = new Set([
|
|
63
|
-
"POLICY_VIOLATION",
|
|
64
|
-
"ENV_POLICY_REQUIRED_SOURCE_ENV",
|
|
65
|
-
"ENV_POLICY_MINIMUM_DWELL_TIME",
|
|
66
|
-
"ENV_POLICY_NO_ROLLBACK_IN_SOURCE",
|
|
67
|
-
"ENV_POLICY_REQUIRES_APPROVAL",
|
|
68
|
-
"ENV_POLICY_SEPARATION_OF_DUTIES",
|
|
69
|
-
"ENV_POLICY_SOURCE_ENV_UNAVAILABLE",
|
|
70
|
-
"ENV_POLICY_ENV_NOT_FOUND",
|
|
71
|
-
"ENV_POLICY_INVALID_CONFIG",
|
|
72
|
-
]);
|
|
61
|
+
const PROMPT_POLICY_VIOLATION_DETAILS_CODES = new Set(["POLICY_VIOLATION"]);
|
|
73
62
|
|
|
74
63
|
/**
|
|
75
64
|
* Map a prompt-resolution envelope (keyed on `details.code`) to a typed S9
|