@anvia/core 1.0.0-rc.10 → 1.0.0-rc.11

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.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/agent/errors.ts"],"sourcesContent":["import type { CompletionFinishReason, Message, Usage } from \"../completion/index\";\nimport type { AgentBlockedResult, AgentSuspendedResult } from \"./run-types\";\n\nexport type AgentStructuredOutputPhase = \"truncated\" | \"content-filter\" | \"parse\" | \"schema\";\n\nexport type AgentStructuredOutputFormat = \"raw\" | \"json-fence\" | \"unlabeled-fence\";\n\nexport class AgentStructuredOutputError extends Error {\n readonly phase: AgentStructuredOutputPhase;\n readonly attempt: number;\n readonly maxAttempts: number;\n readonly outputLength: number;\n readonly normalizedLength: number;\n readonly outputFormat: AgentStructuredOutputFormat;\n readonly attemptUsage: Usage;\n readonly usage: Usage;\n readonly finishReason: CompletionFinishReason | undefined;\n readonly providerFinishReason: string | undefined;\n\n constructor(options: {\n phase: AgentStructuredOutputPhase;\n attempt: number;\n maxAttempts: number;\n outputLength: number;\n normalizedLength: number;\n outputFormat: AgentStructuredOutputFormat;\n attemptUsage: Usage;\n usage: Usage;\n finishReason?: CompletionFinishReason | undefined;\n providerFinishReason?: string | undefined;\n cause?: unknown;\n }) {\n const failure =\n options.phase === \"truncated\"\n ? \"because the provider reached its output limit\"\n : options.phase === \"content-filter\"\n ? \"because the provider filtered the response\"\n : options.phase === \"parse\"\n ? \"during JSON parsing\"\n : \"during schema validation\";\n const errorOptions = options.cause === undefined ? undefined : { cause: options.cause };\n super(\n `Agent structured output failed ${failure} on attempt ${options.attempt} of ${options.maxAttempts}.`,\n errorOptions,\n );\n this.name = \"AgentStructuredOutputError\";\n this.phase = options.phase;\n this.attempt = options.attempt;\n this.maxAttempts = options.maxAttempts;\n this.outputLength = options.outputLength;\n this.normalizedLength = options.normalizedLength;\n this.outputFormat = options.outputFormat;\n this.attemptUsage = options.attemptUsage;\n this.usage = options.usage;\n this.finishReason = options.finishReason;\n this.providerFinishReason = options.providerFinishReason;\n }\n}\n\nexport class MaxTurnsError extends Error {\n constructor(\n readonly maxTurns: number,\n readonly chatHistory: Message[],\n readonly prompt: Message,\n ) {\n super(`Reached max turn limit: ${maxTurns}`);\n this.name = \"MaxTurnsError\";\n }\n}\n\nexport class AgentRunCancelledError extends Error {\n constructor(\n readonly chatHistory: Message[],\n readonly reason: string,\n options?: ErrorOptions,\n ) {\n super(`Agent run cancelled: ${reason}`, options);\n this.name = \"AgentRunCancelledError\";\n }\n}\n\nexport class AgentRunBlockedError extends Error {\n constructor(readonly result: AgentBlockedResult) {\n super(`Agent run was blocked by an ${result.stage} guardrail.`);\n this.name = \"AgentRunBlockedError\";\n }\n}\n\nexport class AgentStreamClosedError extends Error {\n constructor() {\n super(\"Agent stream is no longer accepting steering input.\");\n this.name = \"AgentStreamClosedError\";\n }\n}\n\nexport class AgentToolSuspensionError extends Error {\n constructor(readonly result: AgentSuspendedResult) {\n super(\"Agent tool execution suspended for human interaction.\");\n this.name = \"AgentToolSuspensionError\";\n }\n}\n"],"mappings":";AAOO,IAAM,6BAAN,cAAyC,MAAM;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,SAYT;AACD,UAAM,UACJ,QAAQ,UAAU,cACd,kDACA,QAAQ,UAAU,mBAChB,+CACA,QAAQ,UAAU,UAChB,wBACA;AACV,UAAM,eAAe,QAAQ,UAAU,SAAY,SAAY,EAAE,OAAO,QAAQ,MAAM;AACtF;AAAA,MACE,kCAAkC,OAAO,eAAe,QAAQ,OAAO,OAAO,QAAQ,WAAW;AAAA,MACjG;AAAA,IACF;AACA,SAAK,OAAO;AACZ,SAAK,QAAQ,QAAQ;AACrB,SAAK,UAAU,QAAQ;AACvB,SAAK,cAAc,QAAQ;AAC3B,SAAK,eAAe,QAAQ;AA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