@hebo-ai/gateway 0.10.0 → 0.10.2

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.
@@ -520,41 +520,79 @@ export declare const MessagesBodySchema: z.ZodObject<{
520
520
  }, z.core.$strip>;
521
521
  export type MessagesBody = z.infer<typeof MessagesBodySchema>;
522
522
  export type MessagesInputs = Omit<MessagesBody, "model" | "stream">;
523
- export type MessagesResponseContentBlock = {
524
- type: "text";
525
- text: string;
526
- } | {
527
- type: "tool_use";
528
- id: string;
529
- name: string;
530
- input: unknown;
531
- extra_content?: ProviderMetadata;
532
- } | {
533
- type: "thinking";
534
- thinking: string;
535
- signature: string;
536
- } | {
537
- type: "redacted_thinking";
538
- data: string;
539
- };
540
- export type MessagesUsage = {
541
- input_tokens: number;
542
- output_tokens: number;
543
- cache_creation_input_tokens?: number;
544
- cache_read_input_tokens?: number;
545
- };
546
- export type MessagesStopReason = "end_turn" | "max_tokens" | "stop_sequence" | "tool_use" | null;
547
- export type Messages = {
548
- id: string;
549
- type: "message";
550
- role: "assistant";
551
- content: MessagesResponseContentBlock[];
552
- model: string;
553
- stop_reason: MessagesStopReason;
554
- stop_sequence: string | null;
555
- usage: MessagesUsage;
556
- service_tier?: MessagesServiceTier;
557
- };
523
+ export declare const MessagesResponseContentBlockSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
524
+ type: z.ZodLiteral<"text">;
525
+ text: z.ZodString;
526
+ }, z.core.$strip>, z.ZodObject<{
527
+ type: z.ZodLiteral<"tool_use">;
528
+ id: z.ZodString;
529
+ name: z.ZodString;
530
+ input: z.ZodUnknown;
531
+ extra_content: z.ZodOptional<z.ZodType<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown>>>;
532
+ }, z.core.$strip>, z.ZodObject<{
533
+ type: z.ZodLiteral<"thinking">;
534
+ thinking: z.ZodString;
535
+ signature: z.ZodString;
536
+ }, z.core.$strip>, z.ZodObject<{
537
+ type: z.ZodLiteral<"redacted_thinking">;
538
+ data: z.ZodString;
539
+ }, z.core.$strip>], "type">;
540
+ export type MessagesResponseContentBlock = z.infer<typeof MessagesResponseContentBlockSchema>;
541
+ export declare const MessagesUsageSchema: z.ZodObject<{
542
+ input_tokens: z.ZodNumber;
543
+ output_tokens: z.ZodNumber;
544
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
545
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
546
+ }, z.core.$strip>;
547
+ export type MessagesUsage = z.infer<typeof MessagesUsageSchema>;
548
+ export declare const MessagesStopReasonSchema: z.ZodNullable<z.ZodEnum<{
549
+ max_tokens: "max_tokens";
550
+ tool_use: "tool_use";
551
+ end_turn: "end_turn";
552
+ stop_sequence: "stop_sequence";
553
+ }>>;
554
+ export type MessagesStopReason = z.infer<typeof MessagesStopReasonSchema>;
555
+ export declare const MessagesSchema: z.ZodObject<{
556
+ id: z.ZodString;
557
+ type: z.ZodLiteral<"message">;
558
+ role: z.ZodLiteral<"assistant">;
559
+ content: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
560
+ type: z.ZodLiteral<"text">;
561
+ text: z.ZodString;
562
+ }, z.core.$strip>, z.ZodObject<{
563
+ type: z.ZodLiteral<"tool_use">;
564
+ id: z.ZodString;
565
+ name: z.ZodString;
566
+ input: z.ZodUnknown;
567
+ extra_content: z.ZodOptional<z.ZodType<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown, z.core.$ZodTypeInternals<import("@ai-sdk/provider").SharedV3ProviderMetadata, unknown>>>;
568
+ }, z.core.$strip>, z.ZodObject<{
569
+ type: z.ZodLiteral<"thinking">;
570
+ thinking: z.ZodString;
571
+ signature: z.ZodString;
572
+ }, z.core.$strip>, z.ZodObject<{
573
+ type: z.ZodLiteral<"redacted_thinking">;
574
+ data: z.ZodString;
575
+ }, z.core.$strip>], "type">>;
576
+ model: z.ZodString;
577
+ stop_reason: z.ZodNullable<z.ZodEnum<{
578
+ max_tokens: "max_tokens";
579
+ tool_use: "tool_use";
580
+ end_turn: "end_turn";
581
+ stop_sequence: "stop_sequence";
582
+ }>>;
583
+ stop_sequence: z.ZodNullable<z.ZodString>;
584
+ usage: z.ZodObject<{
585
+ input_tokens: z.ZodNumber;
586
+ output_tokens: z.ZodNumber;
587
+ cache_creation_input_tokens: z.ZodOptional<z.ZodNumber>;
588
+ cache_read_input_tokens: z.ZodOptional<z.ZodNumber>;
589
+ }, z.core.$strip>;
590
+ service_tier: z.ZodOptional<z.ZodEnum<{
591
+ auto: "auto";
592
+ standard_only: "standard_only";
593
+ }>>;
594
+ }, z.core.$strip>;
595
+ export type Messages = z.infer<typeof MessagesSchema>;
558
596
  export type MessageStartEvent = SseFrame<{
559
597
  type: "message_start";
560
598
  message: Messages;
@@ -183,3 +183,50 @@ export const MessagesBodySchema = z.object({
183
183
  cache_control: CacheControlSchema.optional(),
184
184
  output_config: MessagesOutputConfigSchema.optional(),
185
185
  });
186
+ // --- Response Schemas ---
187
+ const MessagesResponseTextBlockSchema = z.object({
188
+ type: z.literal("text"),
189
+ text: z.string(),
190
+ });
191
+ const MessagesResponseToolUseBlockSchema = z.object({
192
+ type: z.literal("tool_use"),
193
+ id: z.string(),
194
+ name: z.string(),
195
+ input: z.unknown(),
196
+ extra_content: ProviderMetadataSchema.optional(),
197
+ });
198
+ const MessagesResponseThinkingBlockSchema = z.object({
199
+ type: z.literal("thinking"),
200
+ thinking: z.string(),
201
+ signature: z.string(),
202
+ });
203
+ const MessagesResponseRedactedThinkingBlockSchema = z.object({
204
+ type: z.literal("redacted_thinking"),
205
+ data: z.string(),
206
+ });
207
+ export const MessagesResponseContentBlockSchema = z.discriminatedUnion("type", [
208
+ MessagesResponseTextBlockSchema,
209
+ MessagesResponseToolUseBlockSchema,
210
+ MessagesResponseThinkingBlockSchema,
211
+ MessagesResponseRedactedThinkingBlockSchema,
212
+ ]);
213
+ export const MessagesUsageSchema = z.object({
214
+ input_tokens: z.number().int().nonnegative(),
215
+ output_tokens: z.number().int().nonnegative(),
216
+ cache_creation_input_tokens: z.number().int().nonnegative().optional(),
217
+ cache_read_input_tokens: z.number().int().nonnegative().optional(),
218
+ });
219
+ export const MessagesStopReasonSchema = z
220
+ .enum(["end_turn", "max_tokens", "stop_sequence", "tool_use"])
221
+ .nullable();
222
+ export const MessagesSchema = z.object({
223
+ id: z.string(),
224
+ type: z.literal("message"),
225
+ role: z.literal("assistant"),
226
+ content: z.array(MessagesResponseContentBlockSchema),
227
+ model: z.string(),
228
+ stop_reason: MessagesStopReasonSchema,
229
+ stop_sequence: z.string().nullable(),
230
+ usage: MessagesUsageSchema,
231
+ service_tier: MessagesServiceTierSchema.optional(),
232
+ });
@@ -1,9 +1,14 @@
1
+ import * as z from "zod";
2
+ export declare const AnthropicErrorSchema: z.ZodObject<{
3
+ type: z.ZodLiteral<"error">;
4
+ error: z.ZodObject<{
5
+ type: z.ZodString;
6
+ message: z.ZodString;
7
+ }, z.core.$strip>;
8
+ }, z.core.$strip>;
1
9
  export declare class AnthropicError {
2
- readonly type = "error";
3
- readonly error: {
4
- type: string;
5
- message: string;
6
- };
10
+ readonly type: "error";
11
+ readonly error: z.infer<typeof AnthropicErrorSchema>["error"];
7
12
  constructor(message: string, type?: string);
8
13
  }
9
14
  export declare function toAnthropicError(error: unknown): AnthropicError;
@@ -1,6 +1,14 @@
1
+ import * as z from "zod";
1
2
  import { resolveRequestId } from "../utils/headers";
2
3
  import { toResponse } from "../utils/response";
3
4
  import { getErrorMeta, maybeMaskMessage } from "./utils";
5
+ export const AnthropicErrorSchema = z.object({
6
+ type: z.literal("error"),
7
+ error: z.object({
8
+ type: z.string(),
9
+ message: z.string(),
10
+ }),
11
+ });
4
12
  export class AnthropicError {
5
13
  type = "error";
6
14
  error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebo-ai/gateway",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "AI gateway as a framework. For full control over models, routing & lifecycle. OpenAI /chat/completions, OpenResponses /responses & Anthropic /messages.",
5
5
  "keywords": [
6
6
  "ai",