@hiper2d/ai-agents 0.9.0 → 0.11.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/index.d.mts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.js +35 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -958,10 +958,15 @@ var SupportedAiModels = {
|
|
|
958
958
|
reasoningEffort: "minimal",
|
|
959
959
|
tags: ["fast", "cheap"]
|
|
960
960
|
},
|
|
961
|
-
// Always-on reasoning
|
|
961
|
+
// Always-on reasoning — no non-thinking sibling. Bumped 4.6 → 4.7 on 2026-09-22 (id verified
|
|
962
|
+
// against GET /v1/models). Same price, same 200K extended-context boundary; the context
|
|
963
|
+
// window is 500K. NOTE 4.7 newly accepts `reasoning_effort` (low | medium | high | xhigh,
|
|
964
|
+
// default high) where 4.6 had no knob at all. GrokAgent still sends none, so behaviour is
|
|
965
|
+
// unchanged — but Grok is the app's most expensive model per turn (94% of its output is
|
|
966
|
+
// reasoning), so a lower pin is the obvious lever to measure before anything else.
|
|
962
967
|
[LLM_CONSTANTS.GROK]: {
|
|
963
|
-
displayName: "Grok 4.
|
|
964
|
-
modelApiName: "grok-4.
|
|
968
|
+
displayName: "Grok 4.7",
|
|
969
|
+
modelApiName: "grok-4.7",
|
|
965
970
|
apiKeyName: API_KEY_CONSTANTS.GROK,
|
|
966
971
|
hasThinking: true,
|
|
967
972
|
temperature: 0.7
|
|
@@ -1373,8 +1378,9 @@ var MODEL_PRICING = {
|
|
|
1373
1378
|
cacheHitPrice: 0.015
|
|
1374
1379
|
},
|
|
1375
1380
|
// Grok models. Cached price is per-model on xAI (not a uniform ratio):
|
|
1376
|
-
// grok-4.
|
|
1377
|
-
// >= 200K tokens, per docs.x.ai/
|
|
1381
|
+
// grok-4.7 is $0.50/M cached vs $2.00/M input, and all rates double for prompts
|
|
1382
|
+
// >= 200K tokens, per docs.x.ai/docs/models (re-verified 2026-09-22 for 4.7).
|
|
1383
|
+
// 4.7 carries over 4.6's rates unchanged — the bump is capability-only, not a reprice.
|
|
1378
1384
|
[SupportedAiModels[LLM_CONSTANTS.GROK].modelApiName]: {
|
|
1379
1385
|
inputPrice: 2,
|
|
1380
1386
|
outputPrice: 6,
|
|
@@ -1524,6 +1530,7 @@ var DEEPSEEK_REASONING_EFFORTS = ["low", "high", "max"];
|
|
|
1524
1530
|
var FUGU_REASONING_EFFORTS = ["high", "xhigh", "max"];
|
|
1525
1531
|
var META_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh", "max"];
|
|
1526
1532
|
var MISTRAL_REASONING_EFFORTS = ["minimal", "low", "medium", "high", "xhigh"];
|
|
1533
|
+
var XAI_REASONING_EFFORTS = ["low", "medium", "high", "xhigh"];
|
|
1527
1534
|
function clampReasoningEffort(effort, allowed) {
|
|
1528
1535
|
const rank = REASONING_EFFORT_SCALE.indexOf(effort);
|
|
1529
1536
|
let best = allowed[0];
|
|
@@ -1545,6 +1552,7 @@ var toDeepSeekEffort = (effort) => clampReasoningEffort(effort, DEEPSEEK_REASONI
|
|
|
1545
1552
|
var toMetaEffort = (effort) => clampReasoningEffort(effort, META_REASONING_EFFORTS);
|
|
1546
1553
|
var toFuguEffort = (effort) => clampReasoningEffort(effort, FUGU_REASONING_EFFORTS);
|
|
1547
1554
|
var toMistralEffort = (effort) => clampReasoningEffort(effort, MISTRAL_REASONING_EFFORTS);
|
|
1555
|
+
var toXaiEffort = (effort) => clampReasoningEffort(effort, XAI_REASONING_EFFORTS);
|
|
1548
1556
|
|
|
1549
1557
|
// src/pricing/token-usage-utils.ts
|
|
1550
1558
|
function extractTokenUsage(response) {
|
|
@@ -3782,6 +3790,16 @@ ${schemaDescription}`;
|
|
|
3782
3790
|
throw new Error(this.errorMessages.apiError(error));
|
|
3783
3791
|
}
|
|
3784
3792
|
}
|
|
3793
|
+
/**
|
|
3794
|
+
* A stable key per (game, bot) so xAI routes this conversation's requests to the same
|
|
3795
|
+
* server. Without it a request often lands on a cache-cold machine and the whole prompt
|
|
3796
|
+
* bills at full input price — xAI calls this out as the most common caching mistake.
|
|
3797
|
+
* Falls back to the bot name alone outside a game (story generation, tests), which is
|
|
3798
|
+
* still stabler than sending nothing.
|
|
3799
|
+
*/
|
|
3800
|
+
get promptCacheKey() {
|
|
3801
|
+
return this.gameId ? `${this.gameId}:${this.name}` : this.name;
|
|
3802
|
+
}
|
|
3785
3803
|
createResponse(input, jsonMode) {
|
|
3786
3804
|
return this.client.responses.create({
|
|
3787
3805
|
model: this.model,
|
|
@@ -3792,9 +3810,16 @@ ${schemaDescription}`;
|
|
|
3792
3810
|
// ever starts truncating — measured turns peak far below the shared default.
|
|
3793
3811
|
max_output_tokens: this.maxOutputTokens,
|
|
3794
3812
|
// We manage conversation state ourselves; encrypted reasoning is only
|
|
3795
|
-
// returned for unstored responses.
|
|
3813
|
+
// returned for unstored responses. Grok 4.7 returns reasoning.encrypted_content
|
|
3814
|
+
// on the Responses API whether or not `include` asks for it; we keep asking so
|
|
3815
|
+
// the behaviour is identical if the model is ever pointed back at 4.6.
|
|
3796
3816
|
store: false,
|
|
3797
3817
|
include: ["reasoning.encrypted_content"],
|
|
3818
|
+
prompt_cache_key: this.promptCacheKey,
|
|
3819
|
+
// Grok 4.7 is the first Grok with an effort knob (4.6 had none) and defaults to
|
|
3820
|
+
// "high". Only send it when the catalog asks for a level, so an unset entry keeps
|
|
3821
|
+
// the provider default rather than us silently picking one.
|
|
3822
|
+
...this.reasoningEffort ? { reasoning: { effort: toXaiEffort(this.reasoningEffort) } } : {},
|
|
3798
3823
|
...jsonMode ? { text: { format: { type: "json_object" } } } : {}
|
|
3799
3824
|
});
|
|
3800
3825
|
}
|
|
@@ -5207,6 +5232,7 @@ export {
|
|
|
5207
5232
|
VOICE_MODEL_PRICING,
|
|
5208
5233
|
VOICE_PROVIDER_API_KEY,
|
|
5209
5234
|
VoiceAgentFactory,
|
|
5235
|
+
XAI_REASONING_EFFORTS,
|
|
5210
5236
|
ZodSchemaConverter,
|
|
5211
5237
|
applySpend,
|
|
5212
5238
|
buildGoogleTtsPrompt,
|
|
@@ -5287,6 +5313,7 @@ export {
|
|
|
5287
5313
|
toMetaEffort,
|
|
5288
5314
|
toMistralEffort,
|
|
5289
5315
|
toOpenAIEffort,
|
|
5316
|
+
toXaiEffort,
|
|
5290
5317
|
transcribeWithGemini,
|
|
5291
5318
|
transcribeWithOpenAi,
|
|
5292
5319
|
validateResponse
|