@to11ai/sdk 0.8.1 → 1.1.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/dist/client.d.ts +1 -1
- package/dist/generated/types.gen.d.ts +15 -13
- package/dist/generated/zod.gen.d.ts +13 -17
- package/dist/prompts/cache.d.ts +4 -4
- package/dist/prompts/resource.cjs +1 -4
- package/dist/prompts/resource.d.ts +5 -5
- package/dist/prompts/resource.js +1 -4
- package/dist/prompts/types.d.ts +0 -3
- package/package.json +1 -1
- package/src/client.ts +0 -1
- package/src/generated/types.gen.ts +15 -13
- package/src/generated/zod.gen.ts +13 -18
- package/src/prompts/cache.ts +4 -7
- package/src/prompts/resource.ts +4 -8
- package/src/prompts/types.ts +0 -6
package/dist/client.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { ProjectEnvironmentResource } from "./projectEnvironments/resource";
|
|
|
12
12
|
export type { CacheConfig } from "./prompts/cache";
|
|
13
13
|
export type { PromptResourceConfig } from "./prompts/resource";
|
|
14
14
|
export { PromptResource } from "./prompts/resource";
|
|
15
|
-
export type { BlockRenderRecord, DeveloperRole, FetchedPrompt, FetchPromptOptions,
|
|
15
|
+
export type { BlockRenderRecord, DeveloperRole, FetchedPrompt, FetchPromptOptions, RenderedChatMessage, RenderedPrompt, ResolvedPrompt, ResolvedPromptEnvelope, } from "./prompts/types";
|
|
16
16
|
export { ENV_SLUG_REGEX } from "./prompts/types";
|
|
17
17
|
export type { CreateRuleVersionInput, CreateRuleVersionResult, GetRuleVersionInput, GetRuleVersionResult, ListRuleReleasesInput, ListRuleReleasesResult, ListRuleVersionsInput, ListRuleVersionsResult, RollbackRuleReleaseInput, RollbackRuleReleaseResult, RuleModelBinding, RuleProviderRef, RuleRelease, RuleReleaseActorType, RuleReleaseApprovalStatus, RuleReleaseChangeKind, RuleReleaseStrategy, RuleReleaseWeight, RuleSnapshot, RuleStrategy, RuleVersion, SetRuleReleaseInput, SetRuleReleaseResult, } from "./routingRules/resource";
|
|
18
18
|
export { RoutingRuleReleaseResource, RoutingRulesResource, RoutingRuleVersionResource, } from "./routingRules/resource";
|
|
@@ -233,7 +233,6 @@ export type PromptRelease = {
|
|
|
233
233
|
};
|
|
234
234
|
export type PromptVersion = {
|
|
235
235
|
changelog: string | null;
|
|
236
|
-
contextSchema: unknown;
|
|
237
236
|
createdAt: string;
|
|
238
237
|
createdByDisplayName: string | null;
|
|
239
238
|
createdByImage: string | null;
|
|
@@ -14578,15 +14577,6 @@ export type PromptsCreatePromptVersionData = {
|
|
|
14578
14577
|
allowBlockRemovals?: Array<string> | null;
|
|
14579
14578
|
baseVersionId?: string | null;
|
|
14580
14579
|
changelog?: string | null;
|
|
14581
|
-
contextSchema?: {
|
|
14582
|
-
properties?: {
|
|
14583
|
-
[key: string]: {
|
|
14584
|
-
enum?: Array<string> | null;
|
|
14585
|
-
type?: 'string' | 'number' | 'boolean' | 'enum' | null;
|
|
14586
|
-
};
|
|
14587
|
-
} | null;
|
|
14588
|
-
required?: Array<string> | null;
|
|
14589
|
-
} | null;
|
|
14590
14580
|
format: 'text' | 'chat';
|
|
14591
14581
|
modelConfig?: unknown | null;
|
|
14592
14582
|
templateJson: unknown;
|
|
@@ -15266,9 +15256,6 @@ export type PromptsWithdrawPromptReviewResponses = {
|
|
|
15266
15256
|
export type PromptsWithdrawPromptReviewResponse = PromptsWithdrawPromptReviewResponses[keyof PromptsWithdrawPromptReviewResponses];
|
|
15267
15257
|
export type PromptsResolvePromptData = {
|
|
15268
15258
|
body: {
|
|
15269
|
-
context?: {
|
|
15270
|
-
[key: string]: string | number | boolean;
|
|
15271
|
-
} | null;
|
|
15272
15259
|
developerRole?: 'user' | 'developer' | 'system' | null;
|
|
15273
15260
|
labels: Array<string>;
|
|
15274
15261
|
slug: string;
|
|
@@ -22813,6 +22800,12 @@ export type TracesGetTraceDetailResponses = {
|
|
|
22813
22800
|
attributes: {
|
|
22814
22801
|
[key: string]: string | number | boolean | null;
|
|
22815
22802
|
};
|
|
22803
|
+
consumedBy?: Array<{
|
|
22804
|
+
kind: string;
|
|
22805
|
+
name: string;
|
|
22806
|
+
spanId: string;
|
|
22807
|
+
traceId: string;
|
|
22808
|
+
}> | null;
|
|
22816
22809
|
cost: {
|
|
22817
22810
|
currency: 'USD';
|
|
22818
22811
|
tokens: {
|
|
@@ -22861,6 +22854,15 @@ export type TracesGetTraceDetailResponses = {
|
|
|
22861
22854
|
timestampOffsetMs: number;
|
|
22862
22855
|
}>;
|
|
22863
22856
|
kind: 'SERVER' | 'CLIENT' | 'INTERNAL';
|
|
22857
|
+
links?: Array<{
|
|
22858
|
+
attributes: {
|
|
22859
|
+
[key: string]: string;
|
|
22860
|
+
};
|
|
22861
|
+
kind: string;
|
|
22862
|
+
name: string;
|
|
22863
|
+
spanId: string;
|
|
22864
|
+
traceId: string;
|
|
22865
|
+
}> | null;
|
|
22864
22866
|
name: string;
|
|
22865
22867
|
parent_span_id: string | null;
|
|
22866
22868
|
span_id: string;
|
|
@@ -301,7 +301,6 @@ export declare const zPromptRelease: z.ZodObject<{
|
|
|
301
301
|
}, z.core.$strip>;
|
|
302
302
|
export declare const zPromptVersion: z.ZodObject<{
|
|
303
303
|
changelog: z.ZodNullable<z.ZodString>;
|
|
304
|
-
contextSchema: z.ZodUnknown;
|
|
305
304
|
createdAt: z.ZodISODateTime;
|
|
306
305
|
createdByDisplayName: z.ZodNullable<z.ZodString>;
|
|
307
306
|
createdByImage: z.ZodNullable<z.ZodString>;
|
|
@@ -8386,7 +8385,6 @@ export declare const zPromptsListPromptVersionsResponse: z.ZodObject<{
|
|
|
8386
8385
|
code: z.ZodNumber;
|
|
8387
8386
|
data: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
8388
8387
|
changelog: z.ZodNullable<z.ZodString>;
|
|
8389
|
-
contextSchema: z.ZodUnknown;
|
|
8390
8388
|
createdAt: z.ZodISODateTime;
|
|
8391
8389
|
createdByDisplayName: z.ZodNullable<z.ZodString>;
|
|
8392
8390
|
createdByImage: z.ZodNullable<z.ZodString>;
|
|
@@ -8428,18 +8426,6 @@ export declare const zPromptsCreatePromptVersionBody: z.ZodObject<{
|
|
|
8428
8426
|
allowBlockRemovals: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
8429
8427
|
baseVersionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8430
8428
|
changelog: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
8431
|
-
contextSchema: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
8432
|
-
properties: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
8433
|
-
enum: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
8434
|
-
type: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
8435
|
-
string: "string";
|
|
8436
|
-
number: "number";
|
|
8437
|
-
boolean: "boolean";
|
|
8438
|
-
enum: "enum";
|
|
8439
|
-
}>>>;
|
|
8440
|
-
}, z.core.$strip>>>>;
|
|
8441
|
-
required: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
8442
|
-
}, z.core.$strip>>>;
|
|
8443
8429
|
format: z.ZodEnum<{
|
|
8444
8430
|
text: "text";
|
|
8445
8431
|
chat: "chat";
|
|
@@ -8459,7 +8445,6 @@ export declare const zPromptsCreatePromptVersionResponse: z.ZodObject<{
|
|
|
8459
8445
|
code: z.ZodNumber;
|
|
8460
8446
|
data: z.ZodNullable<z.ZodObject<{
|
|
8461
8447
|
changelog: z.ZodNullable<z.ZodString>;
|
|
8462
|
-
contextSchema: z.ZodUnknown;
|
|
8463
8448
|
createdAt: z.ZodISODateTime;
|
|
8464
8449
|
createdByDisplayName: z.ZodNullable<z.ZodString>;
|
|
8465
8450
|
createdByImage: z.ZodNullable<z.ZodString>;
|
|
@@ -8664,7 +8649,6 @@ export declare const zPromptsGetPromptVersionResponse: z.ZodObject<{
|
|
|
8664
8649
|
code: z.ZodNumber;
|
|
8665
8650
|
data: z.ZodNullable<z.ZodObject<{
|
|
8666
8651
|
changelog: z.ZodNullable<z.ZodString>;
|
|
8667
|
-
contextSchema: z.ZodUnknown;
|
|
8668
8652
|
createdAt: z.ZodISODateTime;
|
|
8669
8653
|
createdByDisplayName: z.ZodNullable<z.ZodString>;
|
|
8670
8654
|
createdByImage: z.ZodNullable<z.ZodString>;
|
|
@@ -8876,7 +8860,6 @@ export declare const zPromptsWithdrawPromptReviewResponse: z.ZodObject<{
|
|
|
8876
8860
|
success: z.ZodBoolean;
|
|
8877
8861
|
}, z.core.$strip>;
|
|
8878
8862
|
export declare const zPromptsResolvePromptBody: z.ZodObject<{
|
|
8879
|
-
context: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>>;
|
|
8880
8863
|
developerRole: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
8881
8864
|
user: "user";
|
|
8882
8865
|
system: "system";
|
|
@@ -13631,6 +13614,12 @@ export declare const zTracesGetTraceDetailResponse: z.ZodObject<{
|
|
|
13631
13614
|
duration_ms: z.ZodNumber;
|
|
13632
13615
|
spans: z.ZodArray<z.ZodObject<{
|
|
13633
13616
|
attributes: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
13617
|
+
consumedBy: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
13618
|
+
kind: z.ZodString;
|
|
13619
|
+
name: z.ZodString;
|
|
13620
|
+
spanId: z.ZodString;
|
|
13621
|
+
traceId: z.ZodString;
|
|
13622
|
+
}, z.core.$strip>>>>;
|
|
13634
13623
|
cost: z.ZodNullable<z.ZodObject<{
|
|
13635
13624
|
currency: z.ZodEnum<{
|
|
13636
13625
|
USD: "USD";
|
|
@@ -13691,6 +13680,13 @@ export declare const zTracesGetTraceDetailResponse: z.ZodObject<{
|
|
|
13691
13680
|
CLIENT: "CLIENT";
|
|
13692
13681
|
INTERNAL: "INTERNAL";
|
|
13693
13682
|
}>;
|
|
13683
|
+
links: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
13684
|
+
attributes: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
13685
|
+
kind: z.ZodString;
|
|
13686
|
+
name: z.ZodString;
|
|
13687
|
+
spanId: z.ZodString;
|
|
13688
|
+
traceId: z.ZodString;
|
|
13689
|
+
}, z.core.$strip>>>>;
|
|
13694
13690
|
name: z.ZodString;
|
|
13695
13691
|
parent_span_id: z.ZodNullable<z.ZodString>;
|
|
13696
13692
|
span_id: z.ZodString;
|
package/dist/prompts/cache.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FetchedPrompt,
|
|
1
|
+
import type { FetchedPrompt, ResolvedPrompt } from "./types";
|
|
2
2
|
export interface CacheConfig {
|
|
3
3
|
/** Time-to-live in seconds. Default: 300 (5 minutes) */
|
|
4
4
|
ttlSeconds?: number;
|
|
@@ -26,9 +26,9 @@ export declare function buildCacheKey(projectId: string, slug: string, labels: s
|
|
|
26
26
|
/**
|
|
27
27
|
* Build a cache key for an env-aware `fetch()` call.
|
|
28
28
|
*
|
|
29
|
-
* Folds in `env
|
|
29
|
+
* Folds in `env` and `subject` ON TOP of the base
|
|
30
30
|
* project/slug/labels/variables key so two calls that differ only by
|
|
31
|
-
* env/
|
|
31
|
+
* env/subject do not return a stale cross-env / cross-cohort hit
|
|
32
32
|
* (spec §3 "Caching key changes"). The env slug is also forwarded as the
|
|
33
33
|
* single resolution label (env→label mapping, correction #3), so it appears
|
|
34
34
|
* in the `labels` segment too; including it explicitly here keeps the key
|
|
@@ -38,7 +38,7 @@ export declare function buildCacheKey(projectId: string, slug: string, labels: s
|
|
|
38
38
|
* caches as the same deterministic variant on repeat (D8); the
|
|
39
39
|
* weighted-no-subject bypass is handled in the resource, not here.
|
|
40
40
|
*/
|
|
41
|
-
export declare function buildFetchCacheKey(projectId: string, slug: string, env: string,
|
|
41
|
+
export declare function buildFetchCacheKey(projectId: string, slug: string, env: string, subject?: string, variables?: Record<string, unknown>, developerRole?: string): string;
|
|
42
42
|
/**
|
|
43
43
|
* In-memory LRU cache for ResolvedPrompt objects.
|
|
44
44
|
*
|
|
@@ -219,22 +219,19 @@ class PromptResource {
|
|
|
219
219
|
throw new Error(`[to11ai/sdk] \`env\` must match ${import_types.ENV_SLUG_REGEX} (lowercase-kebab, 1-63 chars). Received: ${JSON.stringify(env)}`);
|
|
220
220
|
}
|
|
221
221
|
const {
|
|
222
|
-
context,
|
|
223
222
|
subject,
|
|
224
223
|
variables,
|
|
225
224
|
cache: useCache = true,
|
|
226
225
|
fallback,
|
|
227
226
|
developerRole
|
|
228
227
|
} = options;
|
|
229
|
-
const cacheKey = import_cache.buildFetchCacheKey(this.projectId, slug, env,
|
|
228
|
+
const cacheKey = import_cache.buildFetchCacheKey(this.projectId, slug, env, subject, variables, developerRole);
|
|
230
229
|
if (useCache) {
|
|
231
230
|
const cached = this.cache.get(cacheKey);
|
|
232
231
|
if (cached && "messages" in cached)
|
|
233
232
|
return structuredClone(cached);
|
|
234
233
|
}
|
|
235
234
|
const body = { slug, labels: [env] };
|
|
236
|
-
if (context !== undefined)
|
|
237
|
-
body.context = context;
|
|
238
235
|
if (subject !== undefined)
|
|
239
236
|
body.subject = subject;
|
|
240
237
|
if (variables !== undefined)
|
|
@@ -2,7 +2,7 @@ import type { Transport } from "../transport";
|
|
|
2
2
|
import type { CacheConfig } from "./cache";
|
|
3
3
|
import type { ArchivePromptInput, ArchivePromptResult, CreateProjectPromptLabelInput, CreateProjectPromptLabelResult, CreatePromptInput, CreatePromptResult, CreatePromptVersionInput, CreatePromptVersionResult, DeleteProjectPromptLabelInput, DeleteProjectPromptLabelResult, FetchedPrompt, FetchPromptOptions, GetProjectPromptLabelInput, GetProjectPromptLabelResult, GetPromptInput, GetPromptResult, GetPromptVersionInput, GetPromptVersionResult, ListLabelEventsInput, ListLabelEventsResult, ListProjectPromptLabelsInput, ListProjectPromptLabelsResult, ListProjectPromptLabelUsagesInput, ListProjectPromptLabelUsagesResult, ListPromptLabelsInput, ListPromptLabelsResult, ListPromptsInput, ListPromptsResult, ListPromptVersionsInput, ListPromptVersionsResult, MovePromptLabelInput, MovePromptLabelResult, PaginatedResult, ResolvePromptInput, ResolvePromptResult, UpdateProjectPromptLabelInput, UpdateProjectPromptLabelResult, UpdatePromptInput, UpdatePromptResult } from "./types";
|
|
4
4
|
export type { CacheConfig } from "./cache";
|
|
5
|
-
export type { ArchivePromptInput, ArchivePromptResult, BlockRenderRecord, ChatMessage, CreateProjectPromptLabelInput, CreateProjectPromptLabelResult, CreatePromptInput, CreatePromptResult, CreatePromptVersionInput, CreatePromptVersionResult, DeleteProjectPromptLabelInput, DeleteProjectPromptLabelResult, FetchedPrompt, FetchPromptOptions, GetProjectPromptLabelInput, GetProjectPromptLabelResult, GetPromptInput, GetPromptResult, GetPromptVersionInput, GetPromptVersionResult, ListLabelEventsInput, ListLabelEventsResult, ListProjectPromptLabelsInput, ListProjectPromptLabelsResult, ListProjectPromptLabelUsagesInput, ListProjectPromptLabelUsagesResult, ListPromptLabelsInput, ListPromptLabelsResult, ListPromptsInput, ListPromptsResult, ListPromptVersionsInput, ListPromptVersionsResult, MovePromptLabelInput, MovePromptLabelResult, PaginatedResult, PaginationInfo, PaletteToken, ProjectPromptLabel, ProjectPromptLabelUsage, Prompt,
|
|
5
|
+
export type { ArchivePromptInput, ArchivePromptResult, BlockRenderRecord, ChatMessage, CreateProjectPromptLabelInput, CreateProjectPromptLabelResult, CreatePromptInput, CreatePromptResult, CreatePromptVersionInput, CreatePromptVersionResult, DeleteProjectPromptLabelInput, DeleteProjectPromptLabelResult, FetchedPrompt, FetchPromptOptions, GetProjectPromptLabelInput, GetProjectPromptLabelResult, GetPromptInput, GetPromptResult, GetPromptVersionInput, GetPromptVersionResult, ListLabelEventsInput, ListLabelEventsResult, ListProjectPromptLabelsInput, ListProjectPromptLabelsResult, ListProjectPromptLabelUsagesInput, ListProjectPromptLabelUsagesResult, ListPromptLabelsInput, ListPromptLabelsResult, ListPromptsInput, ListPromptsResult, ListPromptVersionsInput, ListPromptVersionsResult, MovePromptLabelInput, MovePromptLabelResult, PaginatedResult, PaginationInfo, PaletteToken, ProjectPromptLabel, ProjectPromptLabelUsage, Prompt, PromptFormat, PromptLabelEvent, PromptLabelPointer, PromptStatus, PromptVersion, RenderedChatMessage, RenderedPrompt, ResolvedPrompt, ResolvedPromptEnvelope, ResolvedToolCall, ResolvedToolDefinition, ResolvePromptInput, ResolvePromptResult, RowError, TextChatMessage, TextChatRole, UpdateProjectPromptLabelInput, UpdateProjectPromptLabelResult, UpdatePromptInput, UpdatePromptResult, } from "./types";
|
|
6
6
|
/**
|
|
7
7
|
* Init-time config for the env-aware `fetch()` surface (TO11-980 / S9).
|
|
8
8
|
*
|
|
@@ -41,8 +41,8 @@ export declare class PromptResource {
|
|
|
41
41
|
* label-based (`/v1/projects/:projectId/prompts:resolve`, body
|
|
42
42
|
* `labels[]`); it does NOT accept a top-level `env` field. The resolved
|
|
43
43
|
* env slug (lowercase-kebab — a valid label name) is therefore sent as
|
|
44
|
-
* the single resolution label: body `{ slug, labels: [env],
|
|
45
|
-
*
|
|
44
|
+
* the single resolution label: body `{ slug, labels: [env], subject?,
|
|
45
|
+
* variables? }`.
|
|
46
46
|
* - **No silent fallback (R4):** if no env is resolvable (none at init AND
|
|
47
47
|
* none per call) this throws `EnvNotFoundError` (`reason.source =
|
|
48
48
|
* "missing"`) CLIENT-side, eagerly, before any transport call.
|
|
@@ -55,8 +55,8 @@ export declare class PromptResource {
|
|
|
55
55
|
fetch(slug: string, options?: FetchPromptOptions): Promise<FetchedPrompt>;
|
|
56
56
|
/**
|
|
57
57
|
* @deprecated Use {@link PromptResource.fetch | `prompts.fetch(slug,
|
|
58
|
-
* options?)`} instead. `resolve()` is env-agnostic (no `env` / `
|
|
59
|
-
*
|
|
58
|
+
* options?)`} instead. `resolve()` is env-agnostic (no `env` / `subject`,
|
|
59
|
+
* no enriched release/variant provenance, no typed-env errors)
|
|
60
60
|
* and is retained only for back-compat. It is NOT subject to the R4
|
|
61
61
|
* no-silent-fallback env gate (it has no env concept). New code should
|
|
62
62
|
* configure `projectId` + `env` at `createClient` and call `fetch()`.
|
package/dist/prompts/resource.js
CHANGED
|
@@ -176,22 +176,19 @@ class PromptResource {
|
|
|
176
176
|
throw new Error(`[to11ai/sdk] \`env\` must match ${ENV_SLUG_REGEX} (lowercase-kebab, 1-63 chars). Received: ${JSON.stringify(env)}`);
|
|
177
177
|
}
|
|
178
178
|
const {
|
|
179
|
-
context,
|
|
180
179
|
subject,
|
|
181
180
|
variables,
|
|
182
181
|
cache: useCache = true,
|
|
183
182
|
fallback,
|
|
184
183
|
developerRole
|
|
185
184
|
} = options;
|
|
186
|
-
const cacheKey = buildFetchCacheKey(this.projectId, slug, env,
|
|
185
|
+
const cacheKey = buildFetchCacheKey(this.projectId, slug, env, subject, variables, developerRole);
|
|
187
186
|
if (useCache) {
|
|
188
187
|
const cached = this.cache.get(cacheKey);
|
|
189
188
|
if (cached && "messages" in cached)
|
|
190
189
|
return structuredClone(cached);
|
|
191
190
|
}
|
|
192
191
|
const body = { slug, labels: [env] };
|
|
193
|
-
if (context !== undefined)
|
|
194
|
-
body.context = context;
|
|
195
192
|
if (subject !== undefined)
|
|
196
193
|
body.subject = subject;
|
|
197
194
|
if (variables !== undefined)
|
package/dist/prompts/types.d.ts
CHANGED
|
@@ -81,7 +81,6 @@ export interface CreatePromptVersionInput {
|
|
|
81
81
|
format: PromptFormat;
|
|
82
82
|
templateJson: unknown;
|
|
83
83
|
variablesSchema: unknown;
|
|
84
|
-
contextSchema?: unknown;
|
|
85
84
|
modelConfig?: unknown;
|
|
86
85
|
changelog?: string;
|
|
87
86
|
}
|
|
@@ -123,7 +122,6 @@ export interface ResolvePromptInput {
|
|
|
123
122
|
export type ResolvePromptResult = ResolvedPrompt;
|
|
124
123
|
export declare const ENV_SLUG_REGEX: RegExp;
|
|
125
124
|
export type BlockRenderRecord = Record<string, "rendered" | "dimmed">;
|
|
126
|
-
export type PromptContext = Record<string, string | number | boolean>;
|
|
127
125
|
export interface FetchedPrompt {
|
|
128
126
|
messages: RenderedChatMessage[];
|
|
129
127
|
version: number;
|
|
@@ -165,7 +163,6 @@ export type ResolvedPromptEnvelope = GenResolvedPrompt & {
|
|
|
165
163
|
export type DeveloperRole = "user" | "developer" | "system";
|
|
166
164
|
export interface FetchPromptOptions {
|
|
167
165
|
env?: string;
|
|
168
|
-
context?: PromptContext;
|
|
169
166
|
subject?: string;
|
|
170
167
|
variables?: Record<string, unknown>;
|
|
171
168
|
cache?: boolean;
|
package/package.json
CHANGED
package/src/client.ts
CHANGED
|
@@ -254,7 +254,6 @@ export type PromptRelease = {
|
|
|
254
254
|
|
|
255
255
|
export type PromptVersion = {
|
|
256
256
|
changelog: string | null;
|
|
257
|
-
contextSchema: unknown;
|
|
258
257
|
createdAt: string;
|
|
259
258
|
createdByDisplayName: string | null;
|
|
260
259
|
createdByImage: string | null;
|
|
@@ -15314,15 +15313,6 @@ export type PromptsCreatePromptVersionData = {
|
|
|
15314
15313
|
allowBlockRemovals?: Array<string> | null;
|
|
15315
15314
|
baseVersionId?: string | null;
|
|
15316
15315
|
changelog?: string | null;
|
|
15317
|
-
contextSchema?: {
|
|
15318
|
-
properties?: {
|
|
15319
|
-
[key: string]: {
|
|
15320
|
-
enum?: Array<string> | null;
|
|
15321
|
-
type?: 'string' | 'number' | 'boolean' | 'enum' | null;
|
|
15322
|
-
};
|
|
15323
|
-
} | null;
|
|
15324
|
-
required?: Array<string> | null;
|
|
15325
|
-
} | null;
|
|
15326
15316
|
format: 'text' | 'chat';
|
|
15327
15317
|
modelConfig?: unknown | null;
|
|
15328
15318
|
templateJson: unknown;
|
|
@@ -16032,9 +16022,6 @@ export type PromptsWithdrawPromptReviewResponse = PromptsWithdrawPromptReviewRes
|
|
|
16032
16022
|
|
|
16033
16023
|
export type PromptsResolvePromptData = {
|
|
16034
16024
|
body: {
|
|
16035
|
-
context?: {
|
|
16036
|
-
[key: string]: string | number | boolean;
|
|
16037
|
-
} | null;
|
|
16038
16025
|
developerRole?: 'user' | 'developer' | 'system' | null;
|
|
16039
16026
|
labels: Array<string>;
|
|
16040
16027
|
slug: string;
|
|
@@ -23917,6 +23904,12 @@ export type TracesGetTraceDetailResponses = {
|
|
|
23917
23904
|
attributes: {
|
|
23918
23905
|
[key: string]: string | number | boolean | null;
|
|
23919
23906
|
};
|
|
23907
|
+
consumedBy?: Array<{
|
|
23908
|
+
kind: string;
|
|
23909
|
+
name: string;
|
|
23910
|
+
spanId: string;
|
|
23911
|
+
traceId: string;
|
|
23912
|
+
}> | null;
|
|
23920
23913
|
cost: {
|
|
23921
23914
|
currency: 'USD';
|
|
23922
23915
|
tokens: {
|
|
@@ -23965,6 +23958,15 @@ export type TracesGetTraceDetailResponses = {
|
|
|
23965
23958
|
timestampOffsetMs: number;
|
|
23966
23959
|
}>;
|
|
23967
23960
|
kind: 'SERVER' | 'CLIENT' | 'INTERNAL';
|
|
23961
|
+
links?: Array<{
|
|
23962
|
+
attributes: {
|
|
23963
|
+
[key: string]: string;
|
|
23964
|
+
};
|
|
23965
|
+
kind: string;
|
|
23966
|
+
name: string;
|
|
23967
|
+
spanId: string;
|
|
23968
|
+
traceId: string;
|
|
23969
|
+
}> | null;
|
|
23968
23970
|
name: string;
|
|
23969
23971
|
parent_span_id: string | null;
|
|
23970
23972
|
span_id: string;
|
package/src/generated/zod.gen.ts
CHANGED
|
@@ -280,7 +280,6 @@ export const zPromptRelease = z.object({
|
|
|
280
280
|
|
|
281
281
|
export const zPromptVersion = z.object({
|
|
282
282
|
changelog: z.string().nullable(),
|
|
283
|
-
contextSchema: z.unknown(),
|
|
284
283
|
createdAt: z.iso.datetime(),
|
|
285
284
|
createdByDisplayName: z.string().nullable(),
|
|
286
285
|
createdByImage: z.string().nullable(),
|
|
@@ -7894,18 +7893,6 @@ export const zPromptsCreatePromptVersionBody = z.object({
|
|
|
7894
7893
|
allowBlockRemovals: z.array(z.string()).nullish(),
|
|
7895
7894
|
baseVersionId: z.string().nullish(),
|
|
7896
7895
|
changelog: z.string().nullish(),
|
|
7897
|
-
contextSchema: z.object({
|
|
7898
|
-
properties: z.record(z.string(), z.object({
|
|
7899
|
-
enum: z.array(z.string()).nullish(),
|
|
7900
|
-
type: z.enum([
|
|
7901
|
-
'string',
|
|
7902
|
-
'number',
|
|
7903
|
-
'boolean',
|
|
7904
|
-
'enum'
|
|
7905
|
-
]).nullish()
|
|
7906
|
-
})).nullish(),
|
|
7907
|
-
required: z.array(z.string()).nullish()
|
|
7908
|
-
}).nullish(),
|
|
7909
7896
|
format: z.enum(['text', 'chat']),
|
|
7910
7897
|
modelConfig: z.unknown().nullish(),
|
|
7911
7898
|
templateJson: z.unknown(),
|
|
@@ -8313,11 +8300,6 @@ export const zPromptsWithdrawPromptReviewResponse = z.object({
|
|
|
8313
8300
|
});
|
|
8314
8301
|
|
|
8315
8302
|
export const zPromptsResolvePromptBody = z.object({
|
|
8316
|
-
context: z.record(z.string(), z.union([
|
|
8317
|
-
z.string(),
|
|
8318
|
-
z.number(),
|
|
8319
|
-
z.boolean()
|
|
8320
|
-
])).nullish(),
|
|
8321
8303
|
developerRole: z.enum([
|
|
8322
8304
|
'user',
|
|
8323
8305
|
'developer',
|
|
@@ -12638,6 +12620,12 @@ export const zTracesGetTraceDetailResponse = z.object({
|
|
|
12638
12620
|
z.number(),
|
|
12639
12621
|
z.boolean()
|
|
12640
12622
|
]).nullable()),
|
|
12623
|
+
consumedBy: z.array(z.object({
|
|
12624
|
+
kind: z.string(),
|
|
12625
|
+
name: z.string(),
|
|
12626
|
+
spanId: z.string(),
|
|
12627
|
+
traceId: z.string()
|
|
12628
|
+
})).nullish(),
|
|
12641
12629
|
cost: z.object({
|
|
12642
12630
|
currency: z.enum(['USD']),
|
|
12643
12631
|
tokens: z.object({
|
|
@@ -12700,6 +12688,13 @@ export const zTracesGetTraceDetailResponse = z.object({
|
|
|
12700
12688
|
'CLIENT',
|
|
12701
12689
|
'INTERNAL'
|
|
12702
12690
|
]),
|
|
12691
|
+
links: z.array(z.object({
|
|
12692
|
+
attributes: z.record(z.string(), z.string()),
|
|
12693
|
+
kind: z.string(),
|
|
12694
|
+
name: z.string(),
|
|
12695
|
+
spanId: z.string(),
|
|
12696
|
+
traceId: z.string()
|
|
12697
|
+
})).nullish(),
|
|
12703
12698
|
name: z.string(),
|
|
12704
12699
|
parent_span_id: z.string().nullable(),
|
|
12705
12700
|
span_id: z.string(),
|
package/src/prompts/cache.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FetchedPrompt,
|
|
1
|
+
import type { FetchedPrompt, ResolvedPrompt } from "./types";
|
|
2
2
|
|
|
3
3
|
export interface CacheConfig {
|
|
4
4
|
/** Time-to-live in seconds. Default: 300 (5 minutes) */
|
|
@@ -46,9 +46,9 @@ export function buildCacheKey(
|
|
|
46
46
|
/**
|
|
47
47
|
* Build a cache key for an env-aware `fetch()` call.
|
|
48
48
|
*
|
|
49
|
-
* Folds in `env
|
|
49
|
+
* Folds in `env` and `subject` ON TOP of the base
|
|
50
50
|
* project/slug/labels/variables key so two calls that differ only by
|
|
51
|
-
* env/
|
|
51
|
+
* env/subject do not return a stale cross-env / cross-cohort hit
|
|
52
52
|
* (spec §3 "Caching key changes"). The env slug is also forwarded as the
|
|
53
53
|
* single resolution label (env→label mapping, correction #3), so it appears
|
|
54
54
|
* in the `labels` segment too; including it explicitly here keeps the key
|
|
@@ -62,17 +62,14 @@ export function buildFetchCacheKey(
|
|
|
62
62
|
projectId: string,
|
|
63
63
|
slug: string,
|
|
64
64
|
env: string,
|
|
65
|
-
context?: PromptContext,
|
|
66
65
|
subject?: string,
|
|
67
66
|
variables?: Record<string, unknown>,
|
|
68
67
|
developerRole?: string,
|
|
69
68
|
): string {
|
|
70
69
|
const base = buildCacheKey(projectId, slug, [env], variables);
|
|
71
|
-
const ctxPart =
|
|
72
|
-
context !== undefined ? JSON.stringify(sortObjectKeys(context)) : null;
|
|
73
70
|
// `developerRole` partitions the cache; coalesce the default so omitted and
|
|
74
71
|
// `"user"` (the documented default) share one entry, not two.
|
|
75
|
-
return `fetch|${base}|${JSON.stringify(env)}|${JSON.stringify(
|
|
72
|
+
return `fetch|${base}|${JSON.stringify(env)}|${JSON.stringify(subject ?? null)}|${JSON.stringify(developerRole ?? "user")}`;
|
|
76
73
|
}
|
|
77
74
|
|
|
78
75
|
function sortObjectKeys(obj: unknown): unknown {
|
package/src/prompts/resource.ts
CHANGED
|
@@ -94,7 +94,6 @@ export type {
|
|
|
94
94
|
ProjectPromptLabel,
|
|
95
95
|
ProjectPromptLabelUsage,
|
|
96
96
|
Prompt,
|
|
97
|
-
PromptContext,
|
|
98
97
|
PromptFormat,
|
|
99
98
|
PromptLabelEvent,
|
|
100
99
|
PromptLabelPointer,
|
|
@@ -448,8 +447,8 @@ export class PromptResource {
|
|
|
448
447
|
* label-based (`/v1/projects/:projectId/prompts:resolve`, body
|
|
449
448
|
* `labels[]`); it does NOT accept a top-level `env` field. The resolved
|
|
450
449
|
* env slug (lowercase-kebab — a valid label name) is therefore sent as
|
|
451
|
-
* the single resolution label: body `{ slug, labels: [env],
|
|
452
|
-
*
|
|
450
|
+
* the single resolution label: body `{ slug, labels: [env], subject?,
|
|
451
|
+
* variables? }`.
|
|
453
452
|
* - **No silent fallback (R4):** if no env is resolvable (none at init AND
|
|
454
453
|
* none per call) this throws `EnvNotFoundError` (`reason.source =
|
|
455
454
|
* "missing"`) CLIENT-side, eagerly, before any transport call.
|
|
@@ -488,7 +487,6 @@ export class PromptResource {
|
|
|
488
487
|
}
|
|
489
488
|
|
|
490
489
|
const {
|
|
491
|
-
context,
|
|
492
490
|
subject,
|
|
493
491
|
variables,
|
|
494
492
|
cache: useCache = true,
|
|
@@ -500,7 +498,6 @@ export class PromptResource {
|
|
|
500
498
|
this.projectId,
|
|
501
499
|
slug,
|
|
502
500
|
env,
|
|
503
|
-
context,
|
|
504
501
|
subject,
|
|
505
502
|
variables,
|
|
506
503
|
developerRole,
|
|
@@ -515,7 +512,6 @@ export class PromptResource {
|
|
|
515
512
|
|
|
516
513
|
// env→label mapping: the env slug is the single resolution label.
|
|
517
514
|
const body: Record<string, unknown> = { slug, labels: [env] };
|
|
518
|
-
if (context !== undefined) body.context = context;
|
|
519
515
|
if (subject !== undefined) body.subject = subject;
|
|
520
516
|
if (variables !== undefined) body.variables = variables;
|
|
521
517
|
if (developerRole !== undefined) body.developerRole = developerRole;
|
|
@@ -566,8 +562,8 @@ export class PromptResource {
|
|
|
566
562
|
|
|
567
563
|
/**
|
|
568
564
|
* @deprecated Use {@link PromptResource.fetch | `prompts.fetch(slug,
|
|
569
|
-
* options?)`} instead. `resolve()` is env-agnostic (no `env` / `
|
|
570
|
-
*
|
|
565
|
+
* options?)`} instead. `resolve()` is env-agnostic (no `env` / `subject`,
|
|
566
|
+
* no enriched release/variant provenance, no typed-env errors)
|
|
571
567
|
* and is retained only for back-compat. It is NOT subject to the R4
|
|
572
568
|
* no-silent-fallback env gate (it has no env concept). New code should
|
|
573
569
|
* configure `projectId` + `env` at `createClient` and call `fetch()`.
|
package/src/prompts/types.ts
CHANGED
|
@@ -126,9 +126,6 @@ export interface CreatePromptVersionInput {
|
|
|
126
126
|
format: PromptFormat;
|
|
127
127
|
templateJson: unknown;
|
|
128
128
|
variablesSchema: unknown;
|
|
129
|
-
// TO11-2609: server-trusted, gating-only context schema (scalar/enum keys).
|
|
130
|
-
// Optional on write; omitted → no context keys.
|
|
131
|
-
contextSchema?: unknown;
|
|
132
129
|
modelConfig?: unknown;
|
|
133
130
|
changelog?: string;
|
|
134
131
|
}
|
|
@@ -184,8 +181,6 @@ export const ENV_SLUG_REGEX = /^[a-z0-9-]{1,63}$/;
|
|
|
184
181
|
|
|
185
182
|
export type BlockRenderRecord = Record<string, "rendered" | "dimmed">;
|
|
186
183
|
|
|
187
|
-
export type PromptContext = Record<string, string | number | boolean>;
|
|
188
|
-
|
|
189
184
|
export interface FetchedPrompt {
|
|
190
185
|
messages: RenderedChatMessage[];
|
|
191
186
|
version: number;
|
|
@@ -230,7 +225,6 @@ export type DeveloperRole = "user" | "developer" | "system";
|
|
|
230
225
|
|
|
231
226
|
export interface FetchPromptOptions {
|
|
232
227
|
env?: string;
|
|
233
|
-
context?: PromptContext;
|
|
234
228
|
subject?: string;
|
|
235
229
|
variables?: Record<string, unknown>;
|
|
236
230
|
cache?: boolean;
|