@hiper2d/ai-agents 0.1.2 → 0.1.4
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 +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +78 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -257,6 +257,19 @@ declare class ModelAuthenticationError extends ModelError {
|
|
|
257
257
|
declare class ModelQuotaExceededError extends ModelError {
|
|
258
258
|
constructor(message: string, modelType: string);
|
|
259
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* The model failed to produce a valid response: the output was malformed (unparseable
|
|
262
|
+
* JSON from a structured-output ask) or cut off at the output-token cap before the
|
|
263
|
+
* answer was complete (`status: "incomplete"` on the OpenAI Responses API). Not a
|
|
264
|
+
* transport or availability problem — the request worked, the generation went wrong.
|
|
265
|
+
* A retry with the same prompt often succeeds; `truncated` distinguishes a cap hit
|
|
266
|
+
* (raise maxOutputTokens if legitimate responses genuinely need more room) from a
|
|
267
|
+
* degenerate/runaway generation (a bigger cap only makes failures slower).
|
|
268
|
+
*/
|
|
269
|
+
declare class ModelInvalidResponseError extends ModelError {
|
|
270
|
+
truncated: boolean;
|
|
271
|
+
constructor(modelType: string, detail: string, truncated?: boolean);
|
|
272
|
+
}
|
|
260
273
|
/**
|
|
261
274
|
* The model declined to answer: Anthropic returns `stop_reason: "refusal"` with no content
|
|
262
275
|
* blocks when its safety layer rejects the request as a whole. Not retryable as-is — the
|
|
@@ -327,6 +340,7 @@ declare const LLM_CONSTANTS: {
|
|
|
327
340
|
CLAUDE_HAIKU: string;
|
|
328
341
|
DEEPSEEK_FLASH: string;
|
|
329
342
|
DEEPSEEK_PRO: string;
|
|
343
|
+
GPT_ASTRA: string;
|
|
330
344
|
GPT_SOL: string;
|
|
331
345
|
GPT: string;
|
|
332
346
|
GPT_MINI: string;
|
|
@@ -1188,4 +1202,4 @@ declare class MiniMaxAgent extends AbstractAgent {
|
|
|
1188
1202
|
doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
|
|
1189
1203
|
}
|
|
1190
1204
|
|
|
1191
|
-
export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleTokenUsage, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SupportedAiKeyNames, SupportedAiModels, type TokenUsage$1 as TokenUsage, ZodSchemaConverter, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, clampReasoningEffort, cleanResponse, createCatalog, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, validateResponse };
|
|
1205
|
+
export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleTokenUsage, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SupportedAiKeyNames, SupportedAiModels, type TokenUsage$1 as TokenUsage, ZodSchemaConverter, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, clampReasoningEffort, cleanResponse, createCatalog, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, validateResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -257,6 +257,19 @@ declare class ModelAuthenticationError extends ModelError {
|
|
|
257
257
|
declare class ModelQuotaExceededError extends ModelError {
|
|
258
258
|
constructor(message: string, modelType: string);
|
|
259
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* The model failed to produce a valid response: the output was malformed (unparseable
|
|
262
|
+
* JSON from a structured-output ask) or cut off at the output-token cap before the
|
|
263
|
+
* answer was complete (`status: "incomplete"` on the OpenAI Responses API). Not a
|
|
264
|
+
* transport or availability problem — the request worked, the generation went wrong.
|
|
265
|
+
* A retry with the same prompt often succeeds; `truncated` distinguishes a cap hit
|
|
266
|
+
* (raise maxOutputTokens if legitimate responses genuinely need more room) from a
|
|
267
|
+
* degenerate/runaway generation (a bigger cap only makes failures slower).
|
|
268
|
+
*/
|
|
269
|
+
declare class ModelInvalidResponseError extends ModelError {
|
|
270
|
+
truncated: boolean;
|
|
271
|
+
constructor(modelType: string, detail: string, truncated?: boolean);
|
|
272
|
+
}
|
|
260
273
|
/**
|
|
261
274
|
* The model declined to answer: Anthropic returns `stop_reason: "refusal"` with no content
|
|
262
275
|
* blocks when its safety layer rejects the request as a whole. Not retryable as-is — the
|
|
@@ -327,6 +340,7 @@ declare const LLM_CONSTANTS: {
|
|
|
327
340
|
CLAUDE_HAIKU: string;
|
|
328
341
|
DEEPSEEK_FLASH: string;
|
|
329
342
|
DEEPSEEK_PRO: string;
|
|
343
|
+
GPT_ASTRA: string;
|
|
330
344
|
GPT_SOL: string;
|
|
331
345
|
GPT: string;
|
|
332
346
|
GPT_MINI: string;
|
|
@@ -1188,4 +1202,4 @@ declare class MiniMaxAgent extends AbstractAgent {
|
|
|
1188
1202
|
doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
|
|
1189
1203
|
}
|
|
1190
1204
|
|
|
1191
|
-
export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleTokenUsage, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SupportedAiKeyNames, SupportedAiModels, type TokenUsage$1 as TokenUsage, ZodSchemaConverter, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, clampReasoningEffort, cleanResponse, createCatalog, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, validateResponse };
|
|
1205
|
+
export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleTokenUsage, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SupportedAiKeyNames, SupportedAiModels, type TokenUsage$1 as TokenUsage, ZodSchemaConverter, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, clampReasoningEffort, cleanResponse, createCatalog, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, validateResponse };
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,7 @@ __export(index_exports, {
|
|
|
58
58
|
MistralAgent: () => MistralAgent,
|
|
59
59
|
ModelAuthenticationError: () => ModelAuthenticationError,
|
|
60
60
|
ModelError: () => ModelError,
|
|
61
|
+
ModelInvalidResponseError: () => ModelInvalidResponseError,
|
|
61
62
|
ModelOverloadError: () => ModelOverloadError,
|
|
62
63
|
ModelQuotaExceededError: () => ModelQuotaExceededError,
|
|
63
64
|
ModelRateLimitError: () => ModelRateLimitError,
|
|
@@ -836,6 +837,14 @@ var ModelQuotaExceededError = class extends ModelError {
|
|
|
836
837
|
this.name = "ModelQuotaExceededError";
|
|
837
838
|
}
|
|
838
839
|
};
|
|
840
|
+
var ModelInvalidResponseError = class extends ModelError {
|
|
841
|
+
truncated;
|
|
842
|
+
constructor(modelType, detail, truncated = false) {
|
|
843
|
+
super(`${modelType} failed to produce a valid response: ${detail}`, modelType);
|
|
844
|
+
this.name = "ModelInvalidResponseError";
|
|
845
|
+
this.truncated = truncated;
|
|
846
|
+
}
|
|
847
|
+
};
|
|
839
848
|
var ModelRefusalError = class extends ModelError {
|
|
840
849
|
constructor(modelType, message = `${modelType} refused to answer (stop_reason: refusal)`) {
|
|
841
850
|
super(message, modelType);
|
|
@@ -910,6 +919,7 @@ var LLM_CONSTANTS = {
|
|
|
910
919
|
DEEPSEEK_PRO: "deepseek-pro",
|
|
911
920
|
// GPT-5.6 family. 'gpt' and 'gpt-mini' are stable picker ids carried over from the
|
|
912
921
|
// GPT-5.5 / GPT-5.4-mini era so existing consumers keep working across the repoint.
|
|
922
|
+
GPT_ASTRA: "gpt-astra",
|
|
913
923
|
GPT_SOL: "gpt-sol",
|
|
914
924
|
GPT: "gpt",
|
|
915
925
|
GPT_MINI: "gpt-mini",
|
|
@@ -994,6 +1004,17 @@ var SupportedAiModels = {
|
|
|
994
1004
|
tags: ["cheap"]
|
|
995
1005
|
},
|
|
996
1006
|
// Models with always-on reasoning
|
|
1007
|
+
// GPT-6 Astra (2026-09-03): OpenAI's frontier tier above Sol. No `none` reasoning effort;
|
|
1008
|
+
// temperature/top_p are rejected — Gpt5Agent sends neither, so the same agent serves it.
|
|
1009
|
+
// The catalog temperature is only carried for the agent constructor signature.
|
|
1010
|
+
[LLM_CONSTANTS.GPT_ASTRA]: {
|
|
1011
|
+
displayName: "GPT-6 Astra",
|
|
1012
|
+
modelApiName: "gpt-6-astra",
|
|
1013
|
+
apiKeyName: API_KEY_CONSTANTS.OPENAI,
|
|
1014
|
+
hasThinking: true,
|
|
1015
|
+
temperature: 1,
|
|
1016
|
+
tags: ["expensive"]
|
|
1017
|
+
},
|
|
997
1018
|
// GPT-5.6 family (promoted July 2026 when the limited preview opened up):
|
|
998
1019
|
// sol is the flagship, terra the mainline, luna the cheap tier.
|
|
999
1020
|
[LLM_CONSTANTS.GPT_SOL]: {
|
|
@@ -1265,6 +1286,19 @@ var DEEPSEEK_PEAK_SCHEDULE = {
|
|
|
1265
1286
|
weekendOffPeak: { utcOffsetHours: 8 }
|
|
1266
1287
|
};
|
|
1267
1288
|
var MODEL_PRICING = {
|
|
1289
|
+
// OpenAI GPT-6 Astra (developers.openai.com/api/docs/pricing, 2026-09-03): $10/$50 cache-hit $1
|
|
1290
|
+
// short context, $20/$75 cache-hit $2 long context. OpenAI's pricing table doesn't restate
|
|
1291
|
+
// the boundary; we assume the same 272k threshold as the GPT-5.6 siblings. Cache writes
|
|
1292
|
+
// ($12.50/$25) are not modelled — caching is automatic and we only see hits.
|
|
1293
|
+
[SupportedAiModels[LLM_CONSTANTS.GPT_ASTRA].modelApiName]: {
|
|
1294
|
+
inputPrice: 10,
|
|
1295
|
+
outputPrice: 50,
|
|
1296
|
+
cacheHitPrice: 1,
|
|
1297
|
+
extendedContextInputPrice: 20,
|
|
1298
|
+
extendedContextOutputPrice: 75,
|
|
1299
|
+
extendedContextCacheHitPrice: 2,
|
|
1300
|
+
extendedContextThresholdTokens: 272e3
|
|
1301
|
+
},
|
|
1268
1302
|
// OpenAI GPT-5.6 models
|
|
1269
1303
|
// Sol repriced 2026-08-30 (developers.openai.com/api/docs/pricing): $4/$20 short context,
|
|
1270
1304
|
// $8/$30 past the long-context threshold — the same 272k boundary its siblings use.
|
|
@@ -1903,18 +1937,37 @@ var Gpt5Agent = class extends AbstractAgent {
|
|
|
1903
1937
|
thinking: import_zod2.z.string().describe("Your internal chain-of-thought reasoning process used to arrive at the final answer.")
|
|
1904
1938
|
});
|
|
1905
1939
|
}
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1940
|
+
let response;
|
|
1941
|
+
try {
|
|
1942
|
+
response = await this.client.responses.parse({
|
|
1943
|
+
model: this.model,
|
|
1944
|
+
instructions: this.instruction,
|
|
1945
|
+
input,
|
|
1946
|
+
max_output_tokens: this.maxOutputTokens,
|
|
1947
|
+
text: {
|
|
1948
|
+
format: (0, import_zod3.zodTextFormat)(schemaToSend, "response_schema")
|
|
1949
|
+
}
|
|
1950
|
+
});
|
|
1951
|
+
} catch (error) {
|
|
1952
|
+
if (error instanceof SyntaxError) {
|
|
1953
|
+
throw new ModelInvalidResponseError(
|
|
1954
|
+
this.model,
|
|
1955
|
+
`malformed JSON output \u2014 the generation was cut off at the ${this.maxOutputTokens}-token output cap or went off the rails (${error.message})`
|
|
1956
|
+
);
|
|
1913
1957
|
}
|
|
1914
|
-
|
|
1958
|
+
throw error;
|
|
1959
|
+
}
|
|
1960
|
+
if (response.status === "incomplete") {
|
|
1961
|
+
const reason = response.incomplete_details?.reason ?? "unknown";
|
|
1962
|
+
throw new ModelInvalidResponseError(
|
|
1963
|
+
this.model,
|
|
1964
|
+
`response incomplete (${reason}) at max_output_tokens=${this.maxOutputTokens}`,
|
|
1965
|
+
reason === "max_output_tokens"
|
|
1966
|
+
);
|
|
1967
|
+
}
|
|
1915
1968
|
if (!response.output_parsed) {
|
|
1916
1969
|
this.logger(`Parsing failed. Raw content: ${response.output_text}`);
|
|
1917
|
-
throw new
|
|
1970
|
+
throw new ModelInvalidResponseError(this.model, this.errorMessages.invalidFormat);
|
|
1918
1971
|
}
|
|
1919
1972
|
let reasoningContent = "";
|
|
1920
1973
|
if (this.enableThinking && response.output_parsed.thinking) {
|
|
@@ -1953,6 +2006,9 @@ var Gpt5Agent = class extends AbstractAgent {
|
|
|
1953
2006
|
return [response.output_parsed, reasoningContent, tokenUsage];
|
|
1954
2007
|
} catch (error) {
|
|
1955
2008
|
this.logger(this.logTemplates.error(this.name, error));
|
|
2009
|
+
if (error instanceof ModelError) {
|
|
2010
|
+
throw error;
|
|
2011
|
+
}
|
|
1956
2012
|
throw new Error(this.errorMessages.apiError(error));
|
|
1957
2013
|
}
|
|
1958
2014
|
}
|
|
@@ -1978,6 +2034,14 @@ var Gpt5Agent = class extends AbstractAgent {
|
|
|
1978
2034
|
});
|
|
1979
2035
|
const content = response.output_text;
|
|
1980
2036
|
if (!content) {
|
|
2037
|
+
if (response.status === "incomplete") {
|
|
2038
|
+
const reason = response.incomplete_details?.reason ?? "unknown";
|
|
2039
|
+
throw new ModelInvalidResponseError(
|
|
2040
|
+
this.model,
|
|
2041
|
+
`empty response, incomplete (${reason}) at max_output_tokens=${this.maxOutputTokens}`,
|
|
2042
|
+
reason === "max_output_tokens"
|
|
2043
|
+
);
|
|
2044
|
+
}
|
|
1981
2045
|
throw new Error(this.errorMessages.emptyResponse);
|
|
1982
2046
|
}
|
|
1983
2047
|
let tokenUsage;
|
|
@@ -2010,6 +2074,9 @@ var Gpt5Agent = class extends AbstractAgent {
|
|
|
2010
2074
|
return [content, "", tokenUsage];
|
|
2011
2075
|
} catch (error) {
|
|
2012
2076
|
this.logger(this.logTemplates.error(this.name, error));
|
|
2077
|
+
if (error instanceof ModelError) {
|
|
2078
|
+
throw error;
|
|
2079
|
+
}
|
|
2013
2080
|
throw new Error(this.errorMessages.apiError(error));
|
|
2014
2081
|
}
|
|
2015
2082
|
}
|
|
@@ -4348,6 +4415,7 @@ var AgentFactory = class {
|
|
|
4348
4415
|
case LLM_CONSTANTS.CLAUDE_HAIKU:
|
|
4349
4416
|
return new ClaudeAgent(name, instruction, model.modelApiName, key, shouldEnableThinking);
|
|
4350
4417
|
// Always-on reasoning models
|
|
4418
|
+
case LLM_CONSTANTS.GPT_ASTRA:
|
|
4351
4419
|
case LLM_CONSTANTS.GPT_SOL:
|
|
4352
4420
|
case LLM_CONSTANTS.GPT:
|
|
4353
4421
|
case LLM_CONSTANTS.GPT_MINI:
|
|
@@ -4426,6 +4494,7 @@ var AgentFactory = class {
|
|
|
4426
4494
|
MistralAgent,
|
|
4427
4495
|
ModelAuthenticationError,
|
|
4428
4496
|
ModelError,
|
|
4497
|
+
ModelInvalidResponseError,
|
|
4429
4498
|
ModelOverloadError,
|
|
4430
4499
|
ModelQuotaExceededError,
|
|
4431
4500
|
ModelRateLimitError,
|