promptopskit 0.9.1 → 0.10.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 +9 -7
- package/SKILL.md +5 -4
- package/dist/{chunk-QZHR2YMK.js → chunk-46Z64RVO.js} +61 -21
- package/dist/{chunk-QZHR2YMK.js.map → chunk-46Z64RVO.js.map} +1 -1
- package/dist/{chunk-EDHPVR2F.js → chunk-7XLJOH2K.js} +3 -3
- package/dist/{chunk-VOXMOGU5.js → chunk-ALBSFXYR.js} +2 -1
- package/dist/chunk-ALBSFXYR.js.map +1 -0
- package/dist/{chunk-C5HHTLZX.js → chunk-IGLKVT74.js} +2 -2
- package/dist/{chunk-7GMCNHXJ.js → chunk-PSQWMBKX.js} +21 -21
- package/dist/chunk-PSQWMBKX.js.map +1 -0
- package/dist/{chunk-O3SRIDTH.js → chunk-QVJTND5A.js} +2 -2
- package/dist/{chunk-QHAIOVQ3.js → chunk-UULXO5I6.js} +2 -2
- package/dist/{chunk-D23T3X4V.js → chunk-VUQEB5ML.js} +2 -2
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +81 -39
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.cjs +60 -19
- package/dist/providers/anthropic.cjs.map +1 -1
- package/dist/providers/anthropic.d.cts +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +3 -3
- package/dist/providers/gemini.cjs +60 -19
- package/dist/providers/gemini.cjs.map +1 -1
- package/dist/providers/gemini.d.cts +1 -1
- package/dist/providers/gemini.d.ts +1 -1
- package/dist/providers/gemini.js +3 -3
- package/dist/providers/llmasaservice.cjs +78 -38
- package/dist/providers/llmasaservice.cjs.map +1 -1
- package/dist/providers/llmasaservice.d.cts +6 -5
- package/dist/providers/llmasaservice.d.ts +6 -5
- package/dist/providers/llmasaservice.js +4 -6
- package/dist/providers/openai-responses.cjs +60 -19
- package/dist/providers/openai-responses.cjs.map +1 -1
- package/dist/providers/openai-responses.d.cts +1 -1
- package/dist/providers/openai-responses.d.ts +1 -1
- package/dist/providers/openai-responses.js +3 -3
- package/dist/providers/openai.cjs +60 -19
- package/dist/providers/openai.cjs.map +1 -1
- package/dist/providers/openai.d.cts +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.js +3 -3
- package/dist/providers/openrouter.cjs +60 -19
- package/dist/providers/openrouter.cjs.map +1 -1
- package/dist/providers/openrouter.d.cts +1 -1
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.js +4 -4
- package/dist/testing.cjs +1 -0
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/{types-D6VJJo1x.d.ts → types-9Jv8eHhM.d.ts} +8 -1
- package/dist/{types-B4TWRzUY.d.cts → types-D3MemVmM.d.cts} +8 -1
- package/dist/usagetap/index.d.cts +1 -1
- package/dist/usagetap/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-7GMCNHXJ.js.map +0 -1
- package/dist/chunk-VOXMOGU5.js.map +0 -1
- /package/dist/{chunk-EDHPVR2F.js.map → chunk-7XLJOH2K.js.map} +0 -0
- /package/dist/{chunk-C5HHTLZX.js.map → chunk-IGLKVT74.js.map} +0 -0
- /package/dist/{chunk-O3SRIDTH.js.map → chunk-QVJTND5A.js.map} +0 -0
- /package/dist/{chunk-QHAIOVQ3.js.map → chunk-UULXO5I6.js.map} +0 -0
- /package/dist/{chunk-D23T3X4V.js.map → chunk-VUQEB5ML.js.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
openaiResponsesAdapter
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-UULXO5I6.js";
|
|
4
|
+
import "../chunk-46Z64RVO.js";
|
|
5
|
+
import "../chunk-ALBSFXYR.js";
|
|
6
6
|
export {
|
|
7
7
|
openaiResponsesAdapter
|
|
8
8
|
};
|
|
@@ -1401,6 +1401,7 @@ var LLMAsAServiceCustomerSchema = import_zod.z.object({
|
|
|
1401
1401
|
});
|
|
1402
1402
|
var LLMAsAServiceProviderOptionsSchema = import_zod.z.object({
|
|
1403
1403
|
base_url: import_zod.z.string().url().optional(),
|
|
1404
|
+
// Deprecated compatibility fields; the gateway no longer requires project routing.
|
|
1404
1405
|
project_id: import_zod.z.string().optional(),
|
|
1405
1406
|
customer: LLMAsAServiceCustomerSchema.optional(),
|
|
1406
1407
|
conversationId: import_zod.z.string().optional(),
|
|
@@ -2457,6 +2458,7 @@ async function applyPromptCompressionForRender(asset, runtime) {
|
|
|
2457
2458
|
aggressiveness: theTokenCompanyConfig?.aggressiveness
|
|
2458
2459
|
});
|
|
2459
2460
|
promptTemplate = result.output;
|
|
2461
|
+
warnings.push(...result.warnings ?? []);
|
|
2460
2462
|
compression.push({
|
|
2461
2463
|
provider: "thetokencompany",
|
|
2462
2464
|
model,
|
|
@@ -2522,41 +2524,80 @@ function reportHeuristicCompressionWarnings2(warnings, compressionWarnings, scop
|
|
|
2522
2524
|
async function compressWithTheTokenCompany(input, options) {
|
|
2523
2525
|
const apiKey = options.apiKey ?? getEnv("THETOKENCOMPANY_API_KEY") ?? getEnv("TTC_API_KEY");
|
|
2524
2526
|
if (!apiKey) {
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
+
return createTheTokenCompanyFallback(
|
|
2528
|
+
input,
|
|
2529
|
+
"no API key was provided"
|
|
2527
2530
|
);
|
|
2528
2531
|
}
|
|
2529
2532
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2530
2533
|
if (!fetchImpl) {
|
|
2531
|
-
|
|
2534
|
+
return createTheTokenCompanyFallback(
|
|
2535
|
+
input,
|
|
2536
|
+
"fetch is unavailable in this runtime"
|
|
2537
|
+
);
|
|
2532
2538
|
}
|
|
2533
2539
|
const baseURL = (options.baseURL ?? THETOKENCOMPANY_DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
2534
2540
|
const compressionSettings = options.aggressiveness === void 0 ? void 0 : { aggressiveness: options.aggressiveness };
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2541
|
+
let response;
|
|
2542
|
+
try {
|
|
2543
|
+
response = await fetchImpl(`${baseURL}/v1/compress`, {
|
|
2544
|
+
method: "POST",
|
|
2545
|
+
headers: {
|
|
2546
|
+
Authorization: `Bearer ${apiKey}`,
|
|
2547
|
+
"Content-Type": "application/json"
|
|
2548
|
+
},
|
|
2549
|
+
body: JSON.stringify({
|
|
2550
|
+
model: options.model,
|
|
2551
|
+
input,
|
|
2552
|
+
...compressionSettings ? { compression_settings: compressionSettings } : {}
|
|
2553
|
+
})
|
|
2554
|
+
});
|
|
2555
|
+
} catch (error) {
|
|
2556
|
+
return createTheTokenCompanyFallback(
|
|
2543
2557
|
input,
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
}
|
|
2558
|
+
`request failed: ${toErrorMessage(error)}`
|
|
2559
|
+
);
|
|
2560
|
+
}
|
|
2547
2561
|
if (!response.ok) {
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
`
|
|
2562
|
+
return createTheTokenCompanyFallback(
|
|
2563
|
+
input,
|
|
2564
|
+
`service returned HTTP ${response.status}`
|
|
2565
|
+
);
|
|
2566
|
+
}
|
|
2567
|
+
let data;
|
|
2568
|
+
try {
|
|
2569
|
+
data = await response.json();
|
|
2570
|
+
} catch (error) {
|
|
2571
|
+
return createTheTokenCompanyFallback(
|
|
2572
|
+
input,
|
|
2573
|
+
`response body was not valid JSON: ${toErrorMessage(error)}`
|
|
2551
2574
|
);
|
|
2552
2575
|
}
|
|
2553
|
-
const data = await response.json();
|
|
2554
2576
|
const normalized = normalizeTheTokenCompanyCompressResponse(data);
|
|
2555
2577
|
if (!normalized) {
|
|
2556
|
-
|
|
2578
|
+
return createTheTokenCompanyFallback(
|
|
2579
|
+
input,
|
|
2580
|
+
"response payload was invalid"
|
|
2581
|
+
);
|
|
2557
2582
|
}
|
|
2558
2583
|
return normalized;
|
|
2559
2584
|
}
|
|
2585
|
+
function createTheTokenCompanyFallback(input, reason) {
|
|
2586
|
+
const tokens = estimateHeuristicTokens(input);
|
|
2587
|
+
return {
|
|
2588
|
+
output: input,
|
|
2589
|
+
output_tokens: tokens,
|
|
2590
|
+
input_tokens: tokens,
|
|
2591
|
+
tokens_saved: 0,
|
|
2592
|
+
compression_ratio: tokens === 0 ? 0 : 1,
|
|
2593
|
+
warnings: [
|
|
2594
|
+
`POK057: TheTokenCompany compression skipped; using uncompressed prompt with zero token savings (${reason}).`
|
|
2595
|
+
]
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
function toErrorMessage(error) {
|
|
2599
|
+
return error instanceof Error && error.message ? error.message : "unknown error";
|
|
2600
|
+
}
|
|
2560
2601
|
function normalizeTheTokenCompanyCompressResponse(data) {
|
|
2561
2602
|
if (typeof data.output !== "string" || typeof data.output_tokens !== "number") {
|
|
2562
2603
|
return void 0;
|