promptopskit 0.3.8 → 0.4.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/README.md +97 -10
- package/SKILL.md +69 -6
- package/dist/chunk-F6UJ73Y6.js +113 -0
- package/dist/chunk-F6UJ73Y6.js.map +1 -0
- package/dist/chunk-HLNVKKMS.js +145 -0
- package/dist/chunk-HLNVKKMS.js.map +1 -0
- package/dist/{chunk-5OYWNRNC.js → chunk-JBLUPKY4.js} +191 -5
- package/dist/chunk-JBLUPKY4.js.map +1 -0
- package/dist/{chunk-UJU5XERR.js → chunk-L2V7LDKD.js} +25 -4
- package/dist/chunk-L2V7LDKD.js.map +1 -0
- package/dist/{chunk-E6NPZOJL.js → chunk-RY5DVTLV.js} +29 -4
- package/dist/chunk-RY5DVTLV.js.map +1 -0
- package/dist/chunk-UPTCSWK3.js +60 -0
- package/dist/chunk-UPTCSWK3.js.map +1 -0
- package/dist/{chunk-X73VG645.js → chunk-XNNDGDPI.js} +64 -3
- package/dist/chunk-XNNDGDPI.js.map +1 -0
- package/dist/cli/index.js +423 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +655 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +172 -11
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.cjs +306 -10
- 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 +274 -6
- 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 +1245 -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 +270 -6
- 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 +305 -9
- 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-B9A1zLRk.d.cts +2403 -0
- package/dist/schema-B9A1zLRk.d.ts +2403 -0
- package/dist/testing.cjs +264 -6
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +59 -2
- package/dist/testing.d.ts +59 -2
- package/dist/testing.js +70 -2
- package/dist/testing.js.map +1 -1
- package/dist/{types-fBvo_d4k.d.ts → types-DjGAwJxC.d.ts} +13 -1
- package/dist/{types-C6RG0Si0.d.cts → types-DpbzzZO2.d.cts} +13 -1
- package/dist/usagetap/index.d.cts +2 -2
- package/dist/usagetap/index.d.ts +2 -2
- package/package.json +12 -2
- package/dist/chunk-5OYWNRNC.js.map +0 -1
- package/dist/chunk-BBVVA27J.js +0 -92
- package/dist/chunk-BBVVA27J.js.map +0 -1
- package/dist/chunk-E2NXJLS6.js +0 -26
- package/dist/chunk-E2NXJLS6.js.map +0 -1
- package/dist/chunk-E6NPZOJL.js.map +0 -1
- package/dist/chunk-UJU5XERR.js.map +0 -1
- package/dist/chunk-X73VG645.js.map +0 -1
- package/dist/schema-DwzYbZba.d.cts +0 -859
- package/dist/schema-DwzYbZba.d.ts +0 -859
|
@@ -103,8 +103,53 @@ function mergeOverride(base, override) {
|
|
|
103
103
|
if (override.response !== void 0) {
|
|
104
104
|
result.response = { ...result.response, ...override.response };
|
|
105
105
|
}
|
|
106
|
+
if (override.cache !== void 0) {
|
|
107
|
+
result.cache = {
|
|
108
|
+
...result.cache,
|
|
109
|
+
...override.cache,
|
|
110
|
+
openai: mergeRecordBlock(result.cache?.openai, override.cache.openai),
|
|
111
|
+
anthropic: mergeRecordBlock(result.cache?.anthropic, override.cache.anthropic),
|
|
112
|
+
gemini: mergeRecordBlock(result.cache?.gemini, override.cache.gemini),
|
|
113
|
+
google: mergeRecordBlock(result.cache?.google, override.cache.google)
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (override.raw !== void 0) {
|
|
117
|
+
result.raw = {
|
|
118
|
+
...result.raw,
|
|
119
|
+
...override.raw,
|
|
120
|
+
openai: mergeRecordBlock(result.raw?.openai, override.raw.openai),
|
|
121
|
+
"openai-responses": mergeRecordBlock(result.raw?.["openai-responses"], override.raw["openai-responses"]),
|
|
122
|
+
openai_responses: mergeRecordBlock(result.raw?.openai_responses, override.raw.openai_responses),
|
|
123
|
+
anthropic: mergeRecordBlock(result.raw?.anthropic, override.raw.anthropic),
|
|
124
|
+
gemini: mergeRecordBlock(result.raw?.gemini, override.raw.gemini),
|
|
125
|
+
google: mergeRecordBlock(result.raw?.google, override.raw.google),
|
|
126
|
+
openrouter: mergeRecordBlock(result.raw?.openrouter, override.raw.openrouter)
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
if (override.provider_options !== void 0) {
|
|
130
|
+
result.provider_options = {
|
|
131
|
+
...result.provider_options,
|
|
132
|
+
...override.provider_options,
|
|
133
|
+
anthropic: {
|
|
134
|
+
...result.provider_options?.anthropic,
|
|
135
|
+
...override.provider_options.anthropic
|
|
136
|
+
},
|
|
137
|
+
gemini: {
|
|
138
|
+
...result.provider_options?.gemini,
|
|
139
|
+
...override.provider_options.gemini
|
|
140
|
+
},
|
|
141
|
+
openrouter: {
|
|
142
|
+
...result.provider_options?.openrouter,
|
|
143
|
+
...override.provider_options.openrouter
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
}
|
|
106
147
|
return result;
|
|
107
148
|
}
|
|
149
|
+
function mergeRecordBlock(base, override) {
|
|
150
|
+
if (override === void 0) return base;
|
|
151
|
+
return { ...base, ...override };
|
|
152
|
+
}
|
|
108
153
|
|
|
109
154
|
// src/providers/resolve-asset.ts
|
|
110
155
|
function resolveAssetForProvider(asset, runtime = {}) {
|
|
@@ -205,7 +250,66 @@ var SamplingSchema = import_zod.z.object({
|
|
|
205
250
|
});
|
|
206
251
|
var ResponseSchema = import_zod.z.object({
|
|
207
252
|
format: import_zod.z.enum(["text", "json", "markdown"]).optional(),
|
|
208
|
-
stream: import_zod.z.boolean().optional()
|
|
253
|
+
stream: import_zod.z.boolean().optional(),
|
|
254
|
+
schema: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
255
|
+
schema_name: import_zod.z.string().optional(),
|
|
256
|
+
schema_description: import_zod.z.string().optional(),
|
|
257
|
+
schema_strict: import_zod.z.boolean().optional()
|
|
258
|
+
});
|
|
259
|
+
var AnthropicProviderOptionsSchema = import_zod.z.object({
|
|
260
|
+
top_k: import_zod.z.number().int().min(0).optional(),
|
|
261
|
+
tool_choice: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
262
|
+
output_config: import_zod.z.record(import_zod.z.unknown()).optional()
|
|
263
|
+
});
|
|
264
|
+
var GeminiProviderOptionsSchema = import_zod.z.object({
|
|
265
|
+
candidate_count: import_zod.z.number().int().positive().optional(),
|
|
266
|
+
top_k: import_zod.z.number().int().min(0).optional(),
|
|
267
|
+
seed: import_zod.z.number().int().optional(),
|
|
268
|
+
response_schema: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
269
|
+
response_json_schema: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
270
|
+
response_modalities: import_zod.z.array(import_zod.z.string()).optional(),
|
|
271
|
+
thinking_budget_tokens: import_zod.z.number().int().positive().optional()
|
|
272
|
+
});
|
|
273
|
+
var OpenRouterProviderOptionsSchema = import_zod.z.object({
|
|
274
|
+
provider: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
275
|
+
transforms: import_zod.z.array(import_zod.z.string()).optional(),
|
|
276
|
+
plugins: import_zod.z.array(import_zod.z.record(import_zod.z.unknown())).optional(),
|
|
277
|
+
models: import_zod.z.array(import_zod.z.string()).optional()
|
|
278
|
+
});
|
|
279
|
+
var ProviderOptionsSchema = import_zod.z.object({
|
|
280
|
+
anthropic: AnthropicProviderOptionsSchema.optional(),
|
|
281
|
+
gemini: GeminiProviderOptionsSchema.optional(),
|
|
282
|
+
openrouter: OpenRouterProviderOptionsSchema.optional()
|
|
283
|
+
});
|
|
284
|
+
var RawProviderBodySchema = import_zod.z.object({
|
|
285
|
+
openai: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
286
|
+
"openai-responses": import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
287
|
+
openai_responses: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
288
|
+
anthropic: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
289
|
+
gemini: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
290
|
+
google: import_zod.z.record(import_zod.z.unknown()).optional(),
|
|
291
|
+
openrouter: import_zod.z.record(import_zod.z.unknown()).optional()
|
|
292
|
+
});
|
|
293
|
+
var OpenAICacheSchema = import_zod.z.object({
|
|
294
|
+
prompt_cache_key: import_zod.z.string().min(1).optional(),
|
|
295
|
+
retention: import_zod.z.enum(["in_memory", "24h"]).optional()
|
|
296
|
+
});
|
|
297
|
+
var AnthropicCacheSchema = import_zod.z.object({
|
|
298
|
+
mode: import_zod.z.enum(["automatic", "explicit"]).optional(),
|
|
299
|
+
type: import_zod.z.literal("ephemeral").optional(),
|
|
300
|
+
ttl: import_zod.z.enum(["5m", "1h"]).optional(),
|
|
301
|
+
cache_system_instructions: import_zod.z.boolean().optional(),
|
|
302
|
+
cache_tools: import_zod.z.boolean().optional(),
|
|
303
|
+
cache_prompt_template: import_zod.z.boolean().optional()
|
|
304
|
+
});
|
|
305
|
+
var GeminiCacheSchema = import_zod.z.object({
|
|
306
|
+
cached_content: import_zod.z.string().min(1).optional()
|
|
307
|
+
});
|
|
308
|
+
var CacheSchema = import_zod.z.object({
|
|
309
|
+
openai: OpenAICacheSchema.optional(),
|
|
310
|
+
anthropic: AnthropicCacheSchema.optional(),
|
|
311
|
+
gemini: GeminiCacheSchema.optional(),
|
|
312
|
+
google: GeminiCacheSchema.optional()
|
|
209
313
|
});
|
|
210
314
|
var HistorySchema = import_zod.z.object({
|
|
211
315
|
max_items: import_zod.z.number().int().positive().optional()
|
|
@@ -256,7 +360,10 @@ var PromptAssetOverridesSchema = import_zod.z.object({
|
|
|
256
360
|
reasoning: ReasoningSchema.optional(),
|
|
257
361
|
sampling: SamplingSchema.optional(),
|
|
258
362
|
response: ResponseSchema.optional(),
|
|
259
|
-
|
|
363
|
+
cache: CacheSchema.optional(),
|
|
364
|
+
raw: RawProviderBodySchema.optional(),
|
|
365
|
+
tools: import_zod.z.array(ToolRefSchema).optional(),
|
|
366
|
+
provider_options: ProviderOptionsSchema.optional()
|
|
260
367
|
});
|
|
261
368
|
var SourceSchema = import_zod.z.object({
|
|
262
369
|
file_path: import_zod.z.string().optional(),
|
|
@@ -268,8 +375,9 @@ var SectionsSchema = import_zod.z.object({
|
|
|
268
375
|
notes: import_zod.z.string().optional()
|
|
269
376
|
});
|
|
270
377
|
var PromptDefaultsSchema = import_zod.z.object({
|
|
271
|
-
provider: import_zod.z.enum(["openai", "anthropic", "google", "gemini", "openrouter", "any"]).optional(),
|
|
378
|
+
provider: import_zod.z.enum(["openai", "openai-responses", "anthropic", "google", "gemini", "openrouter", "any"]).optional(),
|
|
272
379
|
model: import_zod.z.string().optional(),
|
|
380
|
+
cache: CacheSchema.optional(),
|
|
273
381
|
metadata: MetadataSchema.optional(),
|
|
274
382
|
sections: import_zod.z.object({
|
|
275
383
|
system_instructions: import_zod.z.string().optional()
|
|
@@ -279,13 +387,16 @@ var PromptAssetSchema = import_zod.z.object({
|
|
|
279
387
|
id: import_zod.z.string(),
|
|
280
388
|
schema_version: import_zod.z.number().int().positive().default(1),
|
|
281
389
|
description: import_zod.z.string().optional(),
|
|
282
|
-
provider: import_zod.z.enum(["openai", "anthropic", "google", "gemini", "openrouter", "any"]).optional(),
|
|
390
|
+
provider: import_zod.z.enum(["openai", "openai-responses", "anthropic", "google", "gemini", "openrouter", "any"]).optional(),
|
|
283
391
|
model: import_zod.z.string().optional(),
|
|
284
392
|
fallback_models: import_zod.z.array(import_zod.z.string()).optional(),
|
|
285
393
|
reasoning: ReasoningSchema.optional(),
|
|
286
394
|
sampling: SamplingSchema.optional(),
|
|
287
395
|
response: ResponseSchema.optional(),
|
|
396
|
+
cache: CacheSchema.optional(),
|
|
397
|
+
raw: RawProviderBodySchema.optional(),
|
|
288
398
|
tools: import_zod.z.array(ToolRefSchema).optional(),
|
|
399
|
+
provider_options: ProviderOptionsSchema.optional(),
|
|
289
400
|
mcp: MCPSchema.optional(),
|
|
290
401
|
context: ContextSchema.optional(),
|
|
291
402
|
includes: import_zod.z.array(import_zod.z.string()).optional(),
|
|
@@ -297,6 +408,123 @@ var PromptAssetSchema = import_zod.z.object({
|
|
|
297
408
|
source: SourceSchema.optional()
|
|
298
409
|
});
|
|
299
410
|
|
|
411
|
+
// src/parser/frontmatter-guard.ts
|
|
412
|
+
var FRONT_MATTER_DELIMITER = /^---[ \t]*$/;
|
|
413
|
+
var REGEX_FIELD = /^(?<indent>\s*)(?<field>allow_regex|deny_regex)\s*:\s*(?<value>.*)$/;
|
|
414
|
+
var PATTERN_FIELD = /^(?<indent>\s*)pattern\s*:\s*(?<value>.*)$/;
|
|
415
|
+
var INLINE_PATTERN_FIELD = /(?:^|[{,]\s*)pattern\s*:\s*(?<value>"(?:\\.|[^"\\])*")/;
|
|
416
|
+
function assertRegexFrontMatterQuoting(content, filePath) {
|
|
417
|
+
const frontMatter = extractFrontMatter(content);
|
|
418
|
+
if (!frontMatter) {
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
let pendingRegex;
|
|
422
|
+
for (const [index, line] of frontMatter.lines.entries()) {
|
|
423
|
+
const lineNumber = frontMatter.startLine + index;
|
|
424
|
+
const regexMatch = line.match(REGEX_FIELD);
|
|
425
|
+
if (regexMatch?.groups) {
|
|
426
|
+
const field = regexMatch.groups.field;
|
|
427
|
+
const indent2 = regexMatch.groups.indent.length;
|
|
428
|
+
const value = regexMatch.groups.value.trim();
|
|
429
|
+
pendingRegex = value === "" ? { field, indent: indent2 } : void 0;
|
|
430
|
+
assertNoUnescapedBackslashInDoubleQuotedRegex(value, field, filePath, lineNumber);
|
|
431
|
+
assertNoUnescapedBackslashInInlinePattern(value, field, filePath, lineNumber);
|
|
432
|
+
continue;
|
|
433
|
+
}
|
|
434
|
+
if (!pendingRegex) {
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
if (line.trim() === "" || line.trimStart().startsWith("#")) {
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
const indent = line.match(/^\s*/)?.[0].length ?? 0;
|
|
441
|
+
if (indent <= pendingRegex.indent) {
|
|
442
|
+
pendingRegex = void 0;
|
|
443
|
+
continue;
|
|
444
|
+
}
|
|
445
|
+
const patternMatch = line.match(PATTERN_FIELD);
|
|
446
|
+
if (!patternMatch?.groups) {
|
|
447
|
+
continue;
|
|
448
|
+
}
|
|
449
|
+
assertNoUnescapedBackslashInDoubleQuotedRegex(
|
|
450
|
+
patternMatch.groups.value.trim(),
|
|
451
|
+
`${pendingRegex.field}.pattern`,
|
|
452
|
+
filePath,
|
|
453
|
+
lineNumber
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
function assertNoUnescapedBackslashInInlinePattern(value, field, filePath, lineNumber) {
|
|
458
|
+
const match = value.match(INLINE_PATTERN_FIELD);
|
|
459
|
+
const pattern = match?.groups?.value;
|
|
460
|
+
if (!pattern) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
assertNoUnescapedBackslashInDoubleQuotedRegex(pattern, `${field}.pattern`, filePath, lineNumber);
|
|
464
|
+
}
|
|
465
|
+
function extractFrontMatter(content) {
|
|
466
|
+
const lines = content.split(/\r?\n/);
|
|
467
|
+
if (!FRONT_MATTER_DELIMITER.test(lines[0] ?? "")) {
|
|
468
|
+
return void 0;
|
|
469
|
+
}
|
|
470
|
+
for (let index = 1; index < lines.length; index += 1) {
|
|
471
|
+
if (FRONT_MATTER_DELIMITER.test(lines[index] ?? "")) {
|
|
472
|
+
return {
|
|
473
|
+
lines: lines.slice(1, index),
|
|
474
|
+
startLine: 2
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
return void 0;
|
|
479
|
+
}
|
|
480
|
+
function assertNoUnescapedBackslashInDoubleQuotedRegex(value, field, filePath, lineNumber) {
|
|
481
|
+
if (!value.startsWith('"')) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const quoted = readDoubleQuotedScalar(value);
|
|
485
|
+
if (!quoted) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (!hasUnescapedBackslash(quoted)) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
const location = filePath ? `${filePath}:${lineNumber}` : `line ${lineNumber}`;
|
|
492
|
+
throw new Error(
|
|
493
|
+
`POK013: Invalid context regex YAML at ${location}, field "${field}": double-quoted regex strings treat backslashes as YAML escapes. Use unquoted /pattern/i literal form, single quotes, or double each backslash.`
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
function readDoubleQuotedScalar(value) {
|
|
497
|
+
let result = "";
|
|
498
|
+
for (let index = 1; index < value.length; index += 1) {
|
|
499
|
+
const char = value[index];
|
|
500
|
+
if (char === '"') {
|
|
501
|
+
return result;
|
|
502
|
+
}
|
|
503
|
+
result += char;
|
|
504
|
+
if (char === "\\" && index + 1 < value.length) {
|
|
505
|
+
index += 1;
|
|
506
|
+
result += value[index];
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
return void 0;
|
|
510
|
+
}
|
|
511
|
+
function hasUnescapedBackslash(value) {
|
|
512
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
513
|
+
if (value[index] !== "\\") {
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
let count = 1;
|
|
517
|
+
while (value[index + count] === "\\") {
|
|
518
|
+
count += 1;
|
|
519
|
+
}
|
|
520
|
+
if (count % 2 === 1) {
|
|
521
|
+
return true;
|
|
522
|
+
}
|
|
523
|
+
index += count - 1;
|
|
524
|
+
}
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
|
|
300
528
|
// src/parser/sections.ts
|
|
301
529
|
var SECTION_MAP = {
|
|
302
530
|
"system instructions": "system_instructions",
|
|
@@ -337,6 +565,7 @@ function extractSections(body) {
|
|
|
337
565
|
|
|
338
566
|
// src/parser/parser.ts
|
|
339
567
|
function parsePrompt(content, filePath) {
|
|
568
|
+
assertRegexFrontMatterQuoting(content, filePath);
|
|
340
569
|
const { data: frontMatter, content: body } = (0, import_gray_matter.default)(content);
|
|
341
570
|
const sections = extractSections(body);
|
|
342
571
|
const raw = {
|
|
@@ -893,6 +1122,21 @@ function withPromptInputSupport(adapter) {
|
|
|
893
1122
|
};
|
|
894
1123
|
}
|
|
895
1124
|
|
|
1125
|
+
// src/providers/raw.ts
|
|
1126
|
+
function applyRawProviderBody(body, asset, provider) {
|
|
1127
|
+
const raw = getRawProviderBody(asset, provider);
|
|
1128
|
+
return raw ? { ...body, ...raw } : body;
|
|
1129
|
+
}
|
|
1130
|
+
function getRawProviderBody(asset, provider) {
|
|
1131
|
+
if (provider === "openai-responses") {
|
|
1132
|
+
return asset.raw?.["openai-responses"] ?? asset.raw?.openai_responses;
|
|
1133
|
+
}
|
|
1134
|
+
if (provider === "gemini") {
|
|
1135
|
+
return asset.raw?.gemini ?? asset.raw?.google;
|
|
1136
|
+
}
|
|
1137
|
+
return asset.raw?.[provider];
|
|
1138
|
+
}
|
|
1139
|
+
|
|
896
1140
|
// src/providers/gemini.ts
|
|
897
1141
|
var geminiAdapter = withPromptInputSupport({
|
|
898
1142
|
name: "gemini",
|
|
@@ -900,6 +1144,8 @@ var geminiAdapter = withPromptInputSupport({
|
|
|
900
1144
|
const resolvedAsset = resolveAssetForProvider(asset, runtime);
|
|
901
1145
|
const errors = [];
|
|
902
1146
|
const warnings = [];
|
|
1147
|
+
const geminiCache = resolvedAsset.cache?.gemini?.cached_content;
|
|
1148
|
+
const googleCache = resolvedAsset.cache?.google?.cached_content;
|
|
903
1149
|
if (!resolvedAsset.model) {
|
|
904
1150
|
errors.push("Gemini adapter requires a model to be specified.");
|
|
905
1151
|
}
|
|
@@ -909,6 +1155,12 @@ var geminiAdapter = withPromptInputSupport({
|
|
|
909
1155
|
if (resolvedAsset.sampling?.presence_penalty !== void 0) {
|
|
910
1156
|
warnings.push("Gemini does not support presence_penalty. It will be ignored.");
|
|
911
1157
|
}
|
|
1158
|
+
if (geminiCache && googleCache && geminiCache !== googleCache) {
|
|
1159
|
+
warnings.push("Both cache.gemini.cached_content and cache.google.cached_content are set. Gemini uses cache.gemini.cached_content.");
|
|
1160
|
+
}
|
|
1161
|
+
if (resolvedAsset.response?.stream !== void 0) {
|
|
1162
|
+
warnings.push("Gemini streaming is endpoint-based (streamGenerateContent), not body-based. response.stream will be ignored.");
|
|
1163
|
+
}
|
|
912
1164
|
return { valid: errors.length === 0, errors, warnings };
|
|
913
1165
|
},
|
|
914
1166
|
render(asset, runtime) {
|
|
@@ -935,20 +1187,33 @@ var geminiAdapter = withPromptInputSupport({
|
|
|
935
1187
|
const body = {
|
|
936
1188
|
contents
|
|
937
1189
|
};
|
|
1190
|
+
const geminiCacheConfig = resolvedAsset.cache?.gemini ?? resolvedAsset.cache?.google;
|
|
938
1191
|
if (sections.system_instructions) {
|
|
939
1192
|
body.systemInstruction = {
|
|
940
1193
|
parts: [{ text: sections.system_instructions }]
|
|
941
1194
|
};
|
|
942
1195
|
}
|
|
943
1196
|
const generationConfig = {};
|
|
1197
|
+
const geminiOptions = resolvedAsset.provider_options?.gemini;
|
|
944
1198
|
if (resolvedAsset.sampling?.temperature !== void 0) generationConfig.temperature = resolvedAsset.sampling.temperature;
|
|
945
1199
|
if (resolvedAsset.sampling?.top_p !== void 0) generationConfig.topP = resolvedAsset.sampling.top_p;
|
|
946
1200
|
if (resolvedAsset.sampling?.max_output_tokens !== void 0) generationConfig.maxOutputTokens = resolvedAsset.sampling.max_output_tokens;
|
|
947
1201
|
if (resolvedAsset.sampling?.stop !== void 0) generationConfig.stopSequences = resolvedAsset.sampling.stop;
|
|
1202
|
+
if (geminiOptions?.candidate_count !== void 0) generationConfig.candidateCount = geminiOptions.candidate_count;
|
|
1203
|
+
if (geminiOptions?.top_k !== void 0) generationConfig.topK = geminiOptions.top_k;
|
|
1204
|
+
if (geminiOptions?.seed !== void 0) generationConfig.seed = geminiOptions.seed;
|
|
1205
|
+
if (geminiOptions?.response_modalities !== void 0) generationConfig.responseModalities = geminiOptions.response_modalities;
|
|
1206
|
+
if (resolvedAsset.response?.schema !== void 0) generationConfig.responseJsonSchema = resolvedAsset.response.schema;
|
|
1207
|
+
if (geminiOptions?.response_schema !== void 0) generationConfig.responseSchema = geminiOptions.response_schema;
|
|
1208
|
+
if (geminiOptions?.response_json_schema !== void 0) generationConfig.responseJsonSchema = geminiOptions.response_json_schema;
|
|
948
1209
|
if (resolvedAsset.response?.format === "json") {
|
|
949
1210
|
generationConfig.responseMimeType = "application/json";
|
|
950
1211
|
}
|
|
951
|
-
if (
|
|
1212
|
+
if (geminiOptions?.thinking_budget_tokens !== void 0) {
|
|
1213
|
+
body.thinkingConfig = {
|
|
1214
|
+
thinkingBudget: geminiOptions.thinking_budget_tokens
|
|
1215
|
+
};
|
|
1216
|
+
} else if (resolvedAsset.reasoning?.effort) {
|
|
952
1217
|
body.thinkingConfig = {
|
|
953
1218
|
thinkingBudget: resolvedAsset.reasoning.effort === "high" ? 8192 : resolvedAsset.reasoning.effort === "medium" ? 4096 : 1024
|
|
954
1219
|
};
|
|
@@ -956,6 +1221,9 @@ var geminiAdapter = withPromptInputSupport({
|
|
|
956
1221
|
if (Object.keys(generationConfig).length > 0) {
|
|
957
1222
|
body.generationConfig = generationConfig;
|
|
958
1223
|
}
|
|
1224
|
+
if (geminiCacheConfig?.cached_content) {
|
|
1225
|
+
body.cachedContent = geminiCacheConfig.cached_content;
|
|
1226
|
+
}
|
|
959
1227
|
if (resolvedAsset.tools && resolvedAsset.tools.length > 0) {
|
|
960
1228
|
const functionDeclarations = resolvedAsset.tools.map((tool) => {
|
|
961
1229
|
if (typeof tool === "string") {
|
|
@@ -972,7 +1240,7 @@ var geminiAdapter = withPromptInputSupport({
|
|
|
972
1240
|
body.tools = [{ functionDeclarations }];
|
|
973
1241
|
}
|
|
974
1242
|
return {
|
|
975
|
-
body,
|
|
1243
|
+
body: applyRawProviderBody(body, resolvedAsset, "gemini"),
|
|
976
1244
|
provider: "gemini",
|
|
977
1245
|
model: resolvedAsset.model ?? "unknown"
|
|
978
1246
|
};
|