promptopskit 0.3.7 → 0.3.9
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 +37 -11
- package/SKILL.md +26 -3
- package/dist/{chunk-IXPIBZXT.js → chunk-4LEPCCSA.js} +60 -8
- package/dist/chunk-4LEPCCSA.js.map +1 -0
- package/dist/{chunk-5TLHYSP7.js → chunk-AN3OR7YC.js} +26 -3
- package/dist/chunk-AN3OR7YC.js.map +1 -0
- package/dist/{chunk-QPOHKVY5.js → chunk-LMURMZUA.js} +22 -3
- package/dist/chunk-LMURMZUA.js.map +1 -0
- package/dist/{chunk-KFSP5KN4.js → chunk-O6RQZYS4.js} +49 -7
- package/dist/chunk-O6RQZYS4.js.map +1 -0
- package/dist/{chunk-6XKV4YVK.js → chunk-V7QY7MRM.js} +85 -8
- package/dist/chunk-V7QY7MRM.js.map +1 -0
- package/dist/{chunk-DGLLQ3FR.js → chunk-YAD6COQX.js} +3 -3
- package/dist/chunk-YNIAA4ZJ.js +111 -0
- package/dist/chunk-YNIAA4ZJ.js.map +1 -0
- package/dist/cli/index.js +95 -11
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +354 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -5
- package/dist/index.d.ts +9 -5
- package/dist/index.js +28 -12
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.cjs +189 -18
- package/dist/providers/anthropic.cjs.map +1 -1
- package/dist/providers/anthropic.d.cts +2 -2
- package/dist/providers/anthropic.d.ts +2 -2
- package/dist/providers/anthropic.js +3 -3
- package/dist/providers/gemini.cjs +166 -14
- package/dist/providers/gemini.cjs.map +1 -1
- package/dist/providers/gemini.d.cts +2 -2
- package/dist/providers/gemini.d.ts +2 -2
- package/dist/providers/gemini.js +3 -3
- package/dist/providers/openai-responses.cjs +1059 -0
- package/dist/providers/openai-responses.cjs.map +1 -0
- package/dist/providers/openai-responses.d.cts +11 -0
- package/dist/providers/openai-responses.d.ts +11 -0
- package/dist/providers/openai-responses.js +9 -0
- package/dist/providers/openai-responses.js.map +1 -0
- package/dist/providers/openai.cjs +162 -14
- package/dist/providers/openai.cjs.map +1 -1
- package/dist/providers/openai.d.cts +2 -2
- package/dist/providers/openai.d.ts +2 -2
- package/dist/providers/openai.js +3 -3
- package/dist/providers/openrouter.cjs +162 -14
- package/dist/providers/openrouter.cjs.map +1 -1
- package/dist/providers/openrouter.d.cts +2 -2
- package/dist/providers/openrouter.d.ts +2 -2
- package/dist/providers/openrouter.js +4 -4
- package/dist/schema-BKkg93rL.d.cts +1923 -0
- package/dist/schema-BKkg93rL.d.ts +1923 -0
- package/dist/testing.cjs +59 -7
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/dist/{types-7U58bgVW.d.cts → types-7cC17GWp.d.cts} +24 -5
- package/dist/{types-HnZ46u5Q.d.ts → types-CsQ8tON_.d.ts} +24 -5
- package/dist/usagetap/index.d.cts +2 -2
- package/dist/usagetap/index.d.ts +2 -2
- package/package.json +11 -1
- package/dist/chunk-5TLHYSP7.js.map +0 -1
- package/dist/chunk-6XKV4YVK.js.map +0 -1
- package/dist/chunk-IXPIBZXT.js.map +0 -1
- package/dist/chunk-KFSP5KN4.js.map +0 -1
- package/dist/chunk-QPOHKVY5.js.map +0 -1
- package/dist/schema-Bgoff-CN.d.cts +0 -805
- package/dist/schema-Bgoff-CN.d.ts +0 -805
- /package/dist/{chunk-DGLLQ3FR.js.map → chunk-YAD6COQX.js.map} +0 -0
|
@@ -103,6 +103,20 @@ function mergeOverride(base, override) {
|
|
|
103
103
|
if (override.response !== void 0) {
|
|
104
104
|
result.response = { ...result.response, ...override.response };
|
|
105
105
|
}
|
|
106
|
+
if (override.provider_options !== void 0) {
|
|
107
|
+
result.provider_options = {
|
|
108
|
+
...result.provider_options,
|
|
109
|
+
...override.provider_options,
|
|
110
|
+
anthropic: {
|
|
111
|
+
...result.provider_options?.anthropic,
|
|
112
|
+
...override.provider_options.anthropic
|
|
113
|
+
},
|
|
114
|
+
gemini: {
|
|
115
|
+
...result.provider_options?.gemini,
|
|
116
|
+
...override.provider_options.gemini
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
106
120
|
return result;
|
|
107
121
|
}
|
|
108
122
|
|
|
@@ -205,7 +219,47 @@ var SamplingSchema = import_zod.z.object({
|
|
|
205
219
|
});
|
|
206
220
|
var ResponseSchema = import_zod.z.object({
|
|
207
221
|
format: import_zod.z.enum(["text", "json", "markdown"]).optional(),
|
|
208
|
-
stream: import_zod.z.boolean().optional()
|
|
222
|
+
stream: import_zod.z.boolean().optional(),
|
|
223
|
+
schema: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
224
|
+
schema_name: import_zod.z.string().optional(),
|
|
225
|
+
schema_strict: import_zod.z.boolean().optional()
|
|
226
|
+
});
|
|
227
|
+
var AnthropicProviderOptionsSchema = import_zod.z.object({
|
|
228
|
+
top_k: import_zod.z.number().int().min(0).optional(),
|
|
229
|
+
tool_choice: import_zod.z.record(import_zod.z.unknown()).optional()
|
|
230
|
+
});
|
|
231
|
+
var GeminiProviderOptionsSchema = import_zod.z.object({
|
|
232
|
+
candidate_count: import_zod.z.number().int().positive().optional(),
|
|
233
|
+
top_k: import_zod.z.number().int().min(0).optional(),
|
|
234
|
+
seed: import_zod.z.number().int().optional(),
|
|
235
|
+
response_schema: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
236
|
+
response_modalities: import_zod.z.array(import_zod.z.string()).optional(),
|
|
237
|
+
thinking_budget_tokens: import_zod.z.number().int().positive().optional()
|
|
238
|
+
});
|
|
239
|
+
var ProviderOptionsSchema = import_zod.z.object({
|
|
240
|
+
anthropic: AnthropicProviderOptionsSchema.optional(),
|
|
241
|
+
gemini: GeminiProviderOptionsSchema.optional()
|
|
242
|
+
});
|
|
243
|
+
var OpenAICacheSchema = import_zod.z.object({
|
|
244
|
+
prompt_cache_key: import_zod.z.string().min(1).optional(),
|
|
245
|
+
retention: import_zod.z.enum(["in_memory", "24h"]).optional()
|
|
246
|
+
});
|
|
247
|
+
var AnthropicCacheSchema = import_zod.z.object({
|
|
248
|
+
mode: import_zod.z.enum(["automatic", "explicit"]).optional(),
|
|
249
|
+
type: import_zod.z.literal("ephemeral").optional(),
|
|
250
|
+
ttl: import_zod.z.enum(["5m", "1h"]).optional(),
|
|
251
|
+
cache_system_instructions: import_zod.z.boolean().optional(),
|
|
252
|
+
cache_tools: import_zod.z.boolean().optional(),
|
|
253
|
+
cache_prompt_template: import_zod.z.boolean().optional()
|
|
254
|
+
});
|
|
255
|
+
var GeminiCacheSchema = import_zod.z.object({
|
|
256
|
+
cached_content: import_zod.z.string().min(1).optional()
|
|
257
|
+
});
|
|
258
|
+
var CacheSchema = import_zod.z.object({
|
|
259
|
+
openai: OpenAICacheSchema.optional(),
|
|
260
|
+
anthropic: AnthropicCacheSchema.optional(),
|
|
261
|
+
gemini: GeminiCacheSchema.optional(),
|
|
262
|
+
google: GeminiCacheSchema.optional()
|
|
209
263
|
});
|
|
210
264
|
var HistorySchema = import_zod.z.object({
|
|
211
265
|
max_items: import_zod.z.number().int().positive().optional()
|
|
@@ -214,7 +268,14 @@ var ContextRegexSchema = import_zod.z.union([
|
|
|
214
268
|
import_zod.z.string(),
|
|
215
269
|
import_zod.z.object({
|
|
216
270
|
pattern: import_zod.z.string(),
|
|
217
|
-
flags: import_zod.z.string().optional()
|
|
271
|
+
flags: import_zod.z.string().optional(),
|
|
272
|
+
return_message: import_zod.z.string().optional()
|
|
273
|
+
})
|
|
274
|
+
]);
|
|
275
|
+
var ContextBuiltInValidatorSchema = import_zod.z.union([
|
|
276
|
+
import_zod.z.boolean(),
|
|
277
|
+
import_zod.z.object({
|
|
278
|
+
return_message: import_zod.z.string().optional()
|
|
218
279
|
})
|
|
219
280
|
]);
|
|
220
281
|
var ContextInputDefinitionObjectSchema = import_zod.z.object({
|
|
@@ -223,8 +284,8 @@ var ContextInputDefinitionObjectSchema = import_zod.z.object({
|
|
|
223
284
|
trim: import_zod.z.union([import_zod.z.boolean(), import_zod.z.enum(["start", "end", "both"])]).optional(),
|
|
224
285
|
allow_regex: ContextRegexSchema.optional(),
|
|
225
286
|
deny_regex: ContextRegexSchema.optional(),
|
|
226
|
-
non_empty:
|
|
227
|
-
reject_secrets:
|
|
287
|
+
non_empty: ContextBuiltInValidatorSchema.optional(),
|
|
288
|
+
reject_secrets: ContextBuiltInValidatorSchema.optional()
|
|
228
289
|
});
|
|
229
290
|
var ContextInputDefinitionSchema = import_zod.z.union([
|
|
230
291
|
import_zod.z.string(),
|
|
@@ -249,7 +310,9 @@ var PromptAssetOverridesSchema = import_zod.z.object({
|
|
|
249
310
|
reasoning: ReasoningSchema.optional(),
|
|
250
311
|
sampling: SamplingSchema.optional(),
|
|
251
312
|
response: ResponseSchema.optional(),
|
|
252
|
-
|
|
313
|
+
cache: CacheSchema.optional(),
|
|
314
|
+
tools: import_zod.z.array(ToolRefSchema).optional(),
|
|
315
|
+
provider_options: ProviderOptionsSchema.optional()
|
|
253
316
|
});
|
|
254
317
|
var SourceSchema = import_zod.z.object({
|
|
255
318
|
file_path: import_zod.z.string().optional(),
|
|
@@ -261,8 +324,9 @@ var SectionsSchema = import_zod.z.object({
|
|
|
261
324
|
notes: import_zod.z.string().optional()
|
|
262
325
|
});
|
|
263
326
|
var PromptDefaultsSchema = import_zod.z.object({
|
|
264
|
-
provider: import_zod.z.enum(["openai", "anthropic", "google", "gemini", "openrouter", "any"]).optional(),
|
|
327
|
+
provider: import_zod.z.enum(["openai", "openai-responses", "anthropic", "google", "gemini", "openrouter", "any"]).optional(),
|
|
265
328
|
model: import_zod.z.string().optional(),
|
|
329
|
+
cache: CacheSchema.optional(),
|
|
266
330
|
metadata: MetadataSchema.optional(),
|
|
267
331
|
sections: import_zod.z.object({
|
|
268
332
|
system_instructions: import_zod.z.string().optional()
|
|
@@ -272,13 +336,15 @@ var PromptAssetSchema = import_zod.z.object({
|
|
|
272
336
|
id: import_zod.z.string(),
|
|
273
337
|
schema_version: import_zod.z.number().int().positive().default(1),
|
|
274
338
|
description: import_zod.z.string().optional(),
|
|
275
|
-
provider: import_zod.z.enum(["openai", "anthropic", "google", "gemini", "openrouter", "any"]).optional(),
|
|
339
|
+
provider: import_zod.z.enum(["openai", "openai-responses", "anthropic", "google", "gemini", "openrouter", "any"]).optional(),
|
|
276
340
|
model: import_zod.z.string().optional(),
|
|
277
341
|
fallback_models: import_zod.z.array(import_zod.z.string()).optional(),
|
|
278
342
|
reasoning: ReasoningSchema.optional(),
|
|
279
343
|
sampling: SamplingSchema.optional(),
|
|
280
344
|
response: ResponseSchema.optional(),
|
|
345
|
+
cache: CacheSchema.optional(),
|
|
281
346
|
tools: import_zod.z.array(ToolRefSchema).optional(),
|
|
347
|
+
provider_options: ProviderOptionsSchema.optional(),
|
|
282
348
|
mcp: MCPSchema.optional(),
|
|
283
349
|
context: ContextSchema.optional(),
|
|
284
350
|
includes: import_zod.z.array(import_zod.z.string()).optional(),
|
|
@@ -584,8 +650,8 @@ function normalizeContextInput(input) {
|
|
|
584
650
|
trim: input.trim,
|
|
585
651
|
allow_regex: normalizeContextRegex(input.allow_regex),
|
|
586
652
|
deny_regex: normalizeContextRegex(input.deny_regex),
|
|
587
|
-
non_empty: input.non_empty,
|
|
588
|
-
reject_secrets: input.reject_secrets
|
|
653
|
+
non_empty: normalizeBuiltInValidator(input.non_empty),
|
|
654
|
+
reject_secrets: normalizeBuiltInValidator(input.reject_secrets)
|
|
589
655
|
};
|
|
590
656
|
}
|
|
591
657
|
function normalizeContextRegex(value) {
|
|
@@ -611,7 +677,19 @@ function normalizeContextRegex(value) {
|
|
|
611
677
|
return {
|
|
612
678
|
pattern: value.pattern,
|
|
613
679
|
flags: value.flags ?? "",
|
|
614
|
-
raw: JSON.stringify(value)
|
|
680
|
+
raw: JSON.stringify(value),
|
|
681
|
+
returnMessage: value.return_message
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
function normalizeBuiltInValidator(value) {
|
|
685
|
+
if (value === void 0 || value === false) {
|
|
686
|
+
return void 0;
|
|
687
|
+
}
|
|
688
|
+
if (value === true) {
|
|
689
|
+
return {};
|
|
690
|
+
}
|
|
691
|
+
return {
|
|
692
|
+
returnMessage: value.return_message
|
|
615
693
|
};
|
|
616
694
|
}
|
|
617
695
|
function parseRegexLiteral(value) {
|
|
@@ -743,6 +821,17 @@ function sanitizeContextVariables(asset, variables = {}, options = {}) {
|
|
|
743
821
|
field: "allow_regex"
|
|
744
822
|
});
|
|
745
823
|
if (!matcher.test(candidate2)) {
|
|
824
|
+
if (input.allow_regex.returnMessage) {
|
|
825
|
+
return {
|
|
826
|
+
variables: sanitized,
|
|
827
|
+
shortCircuit: {
|
|
828
|
+
returnMessage: input.allow_regex.returnMessage,
|
|
829
|
+
code: "POK031",
|
|
830
|
+
variable: input.name,
|
|
831
|
+
field: "allow_regex"
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
}
|
|
746
835
|
throw new Error(
|
|
747
836
|
`POK031: Context variable "${input.name}" failed allow_regex validation for prompt "${asset.id}".`
|
|
748
837
|
);
|
|
@@ -756,12 +845,34 @@ function sanitizeContextVariables(asset, variables = {}, options = {}) {
|
|
|
756
845
|
field: "deny_regex"
|
|
757
846
|
});
|
|
758
847
|
if (matcher.test(candidate2)) {
|
|
848
|
+
if (input.deny_regex.returnMessage) {
|
|
849
|
+
return {
|
|
850
|
+
variables: sanitized,
|
|
851
|
+
shortCircuit: {
|
|
852
|
+
returnMessage: input.deny_regex.returnMessage,
|
|
853
|
+
code: "POK032",
|
|
854
|
+
variable: input.name,
|
|
855
|
+
field: "deny_regex"
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
}
|
|
759
859
|
throw new Error(
|
|
760
860
|
`POK032: Context variable "${input.name}" matched deny_regex for prompt "${asset.id}".`
|
|
761
861
|
);
|
|
762
862
|
}
|
|
763
863
|
}
|
|
764
864
|
if (input.non_empty && candidate.trim().length === 0) {
|
|
865
|
+
if (input.non_empty.returnMessage) {
|
|
866
|
+
return {
|
|
867
|
+
variables: sanitized,
|
|
868
|
+
shortCircuit: {
|
|
869
|
+
returnMessage: input.non_empty.returnMessage,
|
|
870
|
+
code: "POK033",
|
|
871
|
+
variable: input.name,
|
|
872
|
+
field: "non_empty"
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
}
|
|
765
876
|
throw new Error(
|
|
766
877
|
`POK033: Context variable "${input.name}" failed non_empty validation for prompt "${asset.id}".`
|
|
767
878
|
);
|
|
@@ -773,13 +884,24 @@ function sanitizeContextVariables(asset, variables = {}, options = {}) {
|
|
|
773
884
|
field: "reject_secrets"
|
|
774
885
|
});
|
|
775
886
|
if (matcher.test(candidate)) {
|
|
887
|
+
if (input.reject_secrets.returnMessage) {
|
|
888
|
+
return {
|
|
889
|
+
variables: sanitized,
|
|
890
|
+
shortCircuit: {
|
|
891
|
+
returnMessage: input.reject_secrets.returnMessage,
|
|
892
|
+
code: "POK034",
|
|
893
|
+
variable: input.name,
|
|
894
|
+
field: "reject_secrets"
|
|
895
|
+
}
|
|
896
|
+
};
|
|
897
|
+
}
|
|
776
898
|
throw new Error(
|
|
777
899
|
`POK034: Context variable "${input.name}" matched reject_secrets validation for prompt "${asset.id}".`
|
|
778
900
|
);
|
|
779
901
|
}
|
|
780
902
|
}
|
|
781
903
|
}
|
|
782
|
-
return sanitized;
|
|
904
|
+
return { variables: sanitized };
|
|
783
905
|
}
|
|
784
906
|
function measureContextValueSize(value) {
|
|
785
907
|
return textEncoder.encode(value).length;
|
|
@@ -808,12 +930,19 @@ function withPromptInputSupport(adapter) {
|
|
|
808
930
|
};
|
|
809
931
|
const renderPrompt = async (input, runtime) => {
|
|
810
932
|
const resolved = await resolveProviderPromptInput(input, runtime);
|
|
811
|
-
const
|
|
933
|
+
const sanitization = sanitizeContextVariables(resolved, runtime.variables, {
|
|
812
934
|
onContextOverflow: runtime.onContextOverflow
|
|
813
935
|
});
|
|
936
|
+
if (sanitization.shortCircuit) {
|
|
937
|
+
return {
|
|
938
|
+
provider: adapter.name,
|
|
939
|
+
model: resolved.model ?? "",
|
|
940
|
+
returnMessage: sanitization.shortCircuit.returnMessage
|
|
941
|
+
};
|
|
942
|
+
}
|
|
814
943
|
return adapter.render(resolved, {
|
|
815
944
|
...runtime,
|
|
816
|
-
variables
|
|
945
|
+
variables: sanitization.variables
|
|
817
946
|
});
|
|
818
947
|
};
|
|
819
948
|
return {
|
|
@@ -836,6 +965,9 @@ var openaiAdapter = withPromptInputSupport({
|
|
|
836
965
|
if (resolvedAsset.reasoning?.budget_tokens !== void 0) {
|
|
837
966
|
warnings.push("OpenAI uses reasoning_effort, not budget_tokens. budget_tokens will be ignored.");
|
|
838
967
|
}
|
|
968
|
+
if (resolvedAsset.response?.schema !== void 0 && resolvedAsset.response?.format !== "json") {
|
|
969
|
+
warnings.push("OpenAI response.schema requires response.format: json. schema will still be applied as JSON schema output.");
|
|
970
|
+
}
|
|
839
971
|
return { valid: errors.length === 0, errors, warnings };
|
|
840
972
|
},
|
|
841
973
|
render(asset, runtime) {
|
|
@@ -860,6 +992,7 @@ var openaiAdapter = withPromptInputSupport({
|
|
|
860
992
|
model: resolvedAsset.model,
|
|
861
993
|
messages
|
|
862
994
|
};
|
|
995
|
+
const openaiCacheConfig = resolvedAsset.cache?.openai;
|
|
863
996
|
if (resolvedAsset.sampling?.temperature !== void 0) body.temperature = resolvedAsset.sampling.temperature;
|
|
864
997
|
if (resolvedAsset.sampling?.top_p !== void 0) body.top_p = resolvedAsset.sampling.top_p;
|
|
865
998
|
if (resolvedAsset.sampling?.frequency_penalty !== void 0) body.frequency_penalty = resolvedAsset.sampling.frequency_penalty;
|
|
@@ -869,12 +1002,27 @@ var openaiAdapter = withPromptInputSupport({
|
|
|
869
1002
|
if (resolvedAsset.reasoning?.effort) {
|
|
870
1003
|
body.reasoning_effort = resolvedAsset.reasoning.effort;
|
|
871
1004
|
}
|
|
872
|
-
if (resolvedAsset.response?.
|
|
1005
|
+
if (resolvedAsset.response?.schema) {
|
|
1006
|
+
body.response_format = {
|
|
1007
|
+
type: "json_schema",
|
|
1008
|
+
json_schema: {
|
|
1009
|
+
name: resolvedAsset.response.schema_name ?? `${resolvedAsset.id}_response`,
|
|
1010
|
+
schema: resolvedAsset.response.schema,
|
|
1011
|
+
strict: resolvedAsset.response.schema_strict ?? true
|
|
1012
|
+
}
|
|
1013
|
+
};
|
|
1014
|
+
} else if (resolvedAsset.response?.format === "json") {
|
|
873
1015
|
body.response_format = { type: "json_object" };
|
|
874
1016
|
}
|
|
875
1017
|
if (resolvedAsset.response?.stream !== void 0) {
|
|
876
1018
|
body.stream = resolvedAsset.response.stream;
|
|
877
1019
|
}
|
|
1020
|
+
if (openaiCacheConfig?.prompt_cache_key) {
|
|
1021
|
+
body.prompt_cache_key = openaiCacheConfig.prompt_cache_key;
|
|
1022
|
+
}
|
|
1023
|
+
if (openaiCacheConfig?.retention) {
|
|
1024
|
+
body.prompt_cache_retention = openaiCacheConfig.retention;
|
|
1025
|
+
}
|
|
878
1026
|
if (resolvedAsset.tools && resolvedAsset.tools.length > 0) {
|
|
879
1027
|
body.tools = resolvedAsset.tools.map((tool) => {
|
|
880
1028
|
if (typeof tool === "string") {
|