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
package/dist/providers/gemini.js
CHANGED
|
@@ -33,7 +33,6 @@ __export(llmasaservice_exports, {
|
|
|
33
33
|
LLMASASERVICE_BASE_URL: () => LLMASASERVICE_BASE_URL,
|
|
34
34
|
LLMASASERVICE_DEFAULT_MODEL: () => LLMASASERVICE_DEFAULT_MODEL,
|
|
35
35
|
LLMASASERVICE_RESPONSE_HEADER_NAMES: () => LLMASASERVICE_RESPONSE_HEADER_NAMES,
|
|
36
|
-
LLMASASERVICE_SDK_PLACEHOLDER_API_KEY: () => LLMASASERVICE_SDK_PLACEHOLDER_API_KEY,
|
|
37
36
|
createLLMAsAServiceOpenAIConfig: () => createLLMAsAServiceOpenAIConfig,
|
|
38
37
|
llmasaserviceAdapter: () => llmasaserviceAdapter
|
|
39
38
|
});
|
|
@@ -1406,6 +1405,7 @@ var LLMAsAServiceCustomerSchema = import_zod.z.object({
|
|
|
1406
1405
|
});
|
|
1407
1406
|
var LLMAsAServiceProviderOptionsSchema = import_zod.z.object({
|
|
1408
1407
|
base_url: import_zod.z.string().url().optional(),
|
|
1408
|
+
// Deprecated compatibility fields; the gateway no longer requires project routing.
|
|
1409
1409
|
project_id: import_zod.z.string().optional(),
|
|
1410
1410
|
customer: LLMAsAServiceCustomerSchema.optional(),
|
|
1411
1411
|
conversationId: import_zod.z.string().optional(),
|
|
@@ -2462,6 +2462,7 @@ async function applyPromptCompressionForRender(asset, runtime) {
|
|
|
2462
2462
|
aggressiveness: theTokenCompanyConfig?.aggressiveness
|
|
2463
2463
|
});
|
|
2464
2464
|
promptTemplate = result.output;
|
|
2465
|
+
warnings.push(...result.warnings ?? []);
|
|
2465
2466
|
compression.push({
|
|
2466
2467
|
provider: "thetokencompany",
|
|
2467
2468
|
model,
|
|
@@ -2527,41 +2528,80 @@ function reportHeuristicCompressionWarnings2(warnings, compressionWarnings, scop
|
|
|
2527
2528
|
async function compressWithTheTokenCompany(input, options) {
|
|
2528
2529
|
const apiKey = options.apiKey ?? getEnv("THETOKENCOMPANY_API_KEY") ?? getEnv("TTC_API_KEY");
|
|
2529
2530
|
if (!apiKey) {
|
|
2530
|
-
|
|
2531
|
-
|
|
2531
|
+
return createTheTokenCompanyFallback(
|
|
2532
|
+
input,
|
|
2533
|
+
"no API key was provided"
|
|
2532
2534
|
);
|
|
2533
2535
|
}
|
|
2534
2536
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
2535
2537
|
if (!fetchImpl) {
|
|
2536
|
-
|
|
2538
|
+
return createTheTokenCompanyFallback(
|
|
2539
|
+
input,
|
|
2540
|
+
"fetch is unavailable in this runtime"
|
|
2541
|
+
);
|
|
2537
2542
|
}
|
|
2538
2543
|
const baseURL = (options.baseURL ?? THETOKENCOMPANY_DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
2539
2544
|
const compressionSettings = options.aggressiveness === void 0 ? void 0 : { aggressiveness: options.aggressiveness };
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2545
|
+
let response;
|
|
2546
|
+
try {
|
|
2547
|
+
response = await fetchImpl(`${baseURL}/v1/compress`, {
|
|
2548
|
+
method: "POST",
|
|
2549
|
+
headers: {
|
|
2550
|
+
Authorization: `Bearer ${apiKey}`,
|
|
2551
|
+
"Content-Type": "application/json"
|
|
2552
|
+
},
|
|
2553
|
+
body: JSON.stringify({
|
|
2554
|
+
model: options.model,
|
|
2555
|
+
input,
|
|
2556
|
+
...compressionSettings ? { compression_settings: compressionSettings } : {}
|
|
2557
|
+
})
|
|
2558
|
+
});
|
|
2559
|
+
} catch (error) {
|
|
2560
|
+
return createTheTokenCompanyFallback(
|
|
2548
2561
|
input,
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
}
|
|
2562
|
+
`request failed: ${toErrorMessage(error)}`
|
|
2563
|
+
);
|
|
2564
|
+
}
|
|
2552
2565
|
if (!response.ok) {
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
`
|
|
2566
|
+
return createTheTokenCompanyFallback(
|
|
2567
|
+
input,
|
|
2568
|
+
`service returned HTTP ${response.status}`
|
|
2569
|
+
);
|
|
2570
|
+
}
|
|
2571
|
+
let data;
|
|
2572
|
+
try {
|
|
2573
|
+
data = await response.json();
|
|
2574
|
+
} catch (error) {
|
|
2575
|
+
return createTheTokenCompanyFallback(
|
|
2576
|
+
input,
|
|
2577
|
+
`response body was not valid JSON: ${toErrorMessage(error)}`
|
|
2556
2578
|
);
|
|
2557
2579
|
}
|
|
2558
|
-
const data = await response.json();
|
|
2559
2580
|
const normalized = normalizeTheTokenCompanyCompressResponse(data);
|
|
2560
2581
|
if (!normalized) {
|
|
2561
|
-
|
|
2582
|
+
return createTheTokenCompanyFallback(
|
|
2583
|
+
input,
|
|
2584
|
+
"response payload was invalid"
|
|
2585
|
+
);
|
|
2562
2586
|
}
|
|
2563
2587
|
return normalized;
|
|
2564
2588
|
}
|
|
2589
|
+
function createTheTokenCompanyFallback(input, reason) {
|
|
2590
|
+
const tokens = estimateHeuristicTokens(input);
|
|
2591
|
+
return {
|
|
2592
|
+
output: input,
|
|
2593
|
+
output_tokens: tokens,
|
|
2594
|
+
input_tokens: tokens,
|
|
2595
|
+
tokens_saved: 0,
|
|
2596
|
+
compression_ratio: tokens === 0 ? 0 : 1,
|
|
2597
|
+
warnings: [
|
|
2598
|
+
`POK057: TheTokenCompany compression skipped; using uncompressed prompt with zero token savings (${reason}).`
|
|
2599
|
+
]
|
|
2600
|
+
};
|
|
2601
|
+
}
|
|
2602
|
+
function toErrorMessage(error) {
|
|
2603
|
+
return error instanceof Error && error.message ? error.message : "unknown error";
|
|
2604
|
+
}
|
|
2565
2605
|
function normalizeTheTokenCompanyCompressResponse(data) {
|
|
2566
2606
|
if (typeof data.output !== "string" || typeof data.output_tokens !== "number") {
|
|
2567
2607
|
return void 0;
|
|
@@ -2761,20 +2801,17 @@ var openaiAdapter = withPromptInputSupport({
|
|
|
2761
2801
|
|
|
2762
2802
|
// src/providers/llmasaservice.ts
|
|
2763
2803
|
var LLMASASERVICE_BASE_URL = "https://gateway.llmasaservice.io";
|
|
2764
|
-
var LLMASASERVICE_SDK_PLACEHOLDER_API_KEY = "not-used-by-llm-gateway";
|
|
2765
2804
|
var LLMASASERVICE_DEFAULT_MODEL = "group:standard";
|
|
2766
2805
|
var LLMASASERVICE_RESPONSE_HEADER_NAMES = [
|
|
2767
2806
|
"x-request-id",
|
|
2768
2807
|
"x-llm-model-id",
|
|
2769
2808
|
"x-llm-model-group"
|
|
2770
2809
|
];
|
|
2771
|
-
function createLLMAsAServiceOpenAIConfig(options
|
|
2810
|
+
function createLLMAsAServiceOpenAIConfig(options) {
|
|
2772
2811
|
return {
|
|
2773
2812
|
baseURL: options.baseURL ?? LLMASASERVICE_BASE_URL,
|
|
2774
|
-
apiKey:
|
|
2775
|
-
defaultHeaders: {
|
|
2776
|
-
"x-project-id": options.projectId ?? ""
|
|
2777
|
-
}
|
|
2813
|
+
apiKey: options.apiKey,
|
|
2814
|
+
...options.projectId ? { defaultHeaders: { "x-project-id": options.projectId } } : {}
|
|
2778
2815
|
};
|
|
2779
2816
|
}
|
|
2780
2817
|
function isGPT5ModelSelector(model) {
|
|
@@ -2791,9 +2828,6 @@ function rawCustomerId(asset) {
|
|
|
2791
2828
|
const customer = isRecord(asset.raw?.llmasaservice?.customer) ? asset.raw.llmasaservice.customer : void 0;
|
|
2792
2829
|
return customer?.customer_id;
|
|
2793
2830
|
}
|
|
2794
|
-
function isGatewayRenderValidation(runtime) {
|
|
2795
|
-
return runtime?.runtime !== void 0;
|
|
2796
|
-
}
|
|
2797
2831
|
var llmasaserviceAdapter = withPromptInputSupport({
|
|
2798
2832
|
name: "llmasaservice",
|
|
2799
2833
|
validate(asset, runtime) {
|
|
@@ -2810,12 +2844,12 @@ var llmasaserviceAdapter = withPromptInputSupport({
|
|
|
2810
2844
|
);
|
|
2811
2845
|
const errors = [...validation.errors];
|
|
2812
2846
|
const gatewayOptions = resolvedAsset.provider_options?.llmasaservice;
|
|
2813
|
-
const
|
|
2847
|
+
const missingApiKey = !runtime?.llmasaservice?.apiKey;
|
|
2814
2848
|
const missingCustomerId = !gatewayOptions?.customer?.customer_id && typeof rawCustomerId(resolvedAsset) !== "string";
|
|
2815
|
-
const validateRenderMetadata =
|
|
2816
|
-
if (
|
|
2849
|
+
const validateRenderMetadata = runtime !== void 0;
|
|
2850
|
+
if (missingApiKey && validateRenderMetadata) {
|
|
2817
2851
|
errors.push(
|
|
2818
|
-
"LLMAsAService adapter requires
|
|
2852
|
+
"LLMAsAService adapter requires llmasaservice.apiKey for Authorization Bearer authentication."
|
|
2819
2853
|
);
|
|
2820
2854
|
}
|
|
2821
2855
|
if (missingCustomerId && validateRenderMetadata) {
|
|
@@ -2823,9 +2857,9 @@ var llmasaserviceAdapter = withPromptInputSupport({
|
|
|
2823
2857
|
"LLMAsAService adapter requires customer.customer_id in provider_options.llmasaservice.customer or raw.llmasaservice.customer."
|
|
2824
2858
|
);
|
|
2825
2859
|
}
|
|
2826
|
-
if ((
|
|
2860
|
+
if ((missingApiKey || missingCustomerId) && !validateRenderMetadata) {
|
|
2827
2861
|
warnings.push(
|
|
2828
|
-
"LLMAsAService
|
|
2862
|
+
"LLMAsAService apiKey and customer.customer_id must be supplied before rendering."
|
|
2829
2863
|
);
|
|
2830
2864
|
}
|
|
2831
2865
|
return {
|
|
@@ -2858,14 +2892,21 @@ var llmasaserviceAdapter = withPromptInputSupport({
|
|
|
2858
2892
|
if (options?.conversationTitle !== void 0) body.conversationTitle = options.conversationTitle;
|
|
2859
2893
|
if (options?.projectId !== void 0) body.projectId = options.projectId;
|
|
2860
2894
|
body = applyRawProviderBody(body, resolvedAsset, "llmasaservice");
|
|
2861
|
-
const
|
|
2895
|
+
const apiKey = runtime.llmasaservice?.apiKey;
|
|
2896
|
+
if (!apiKey) {
|
|
2897
|
+
throw new Error(
|
|
2898
|
+
"LLMAsAService adapter requires llmasaservice.apiKey for Authorization Bearer authentication."
|
|
2899
|
+
);
|
|
2900
|
+
}
|
|
2901
|
+
const projectId = options?.project_id;
|
|
2862
2902
|
return {
|
|
2863
2903
|
body,
|
|
2864
2904
|
provider: "llmasaservice",
|
|
2865
2905
|
model,
|
|
2866
2906
|
baseURL: options?.base_url ?? LLMASASERVICE_BASE_URL,
|
|
2867
2907
|
headers: {
|
|
2868
|
-
|
|
2908
|
+
Authorization: `Bearer ${apiKey}`,
|
|
2909
|
+
...projectId ? { "x-project-id": projectId } : {}
|
|
2869
2910
|
}
|
|
2870
2911
|
};
|
|
2871
2912
|
}
|
|
@@ -2875,7 +2916,6 @@ var llmasaserviceAdapter = withPromptInputSupport({
|
|
|
2875
2916
|
LLMASASERVICE_BASE_URL,
|
|
2876
2917
|
LLMASASERVICE_DEFAULT_MODEL,
|
|
2877
2918
|
LLMASASERVICE_RESPONSE_HEADER_NAMES,
|
|
2878
|
-
LLMASASERVICE_SDK_PLACEHOLDER_API_KEY,
|
|
2879
2919
|
createLLMAsAServiceOpenAIConfig,
|
|
2880
2920
|
llmasaserviceAdapter
|
|
2881
2921
|
});
|