@layer-ai/sdk 2.5.9 → 2.5.10

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.
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Anthropic Messages API compatible types for /v1/messages endpoint
3
+ * These match the official Anthropic API format to enable drop-in replacement
4
+ */
5
+ export interface AnthropicMessage {
6
+ role: 'user' | 'assistant';
7
+ content: string | AnthropicContentBlock[];
8
+ }
9
+ export type AnthropicContentBlock = AnthropicTextBlock | AnthropicImageBlock | AnthropicToolUseBlock | AnthropicToolResultBlock;
10
+ export interface AnthropicTextBlock {
11
+ type: 'text';
12
+ text: string;
13
+ }
14
+ export interface AnthropicImageBlock {
15
+ type: 'image';
16
+ source: {
17
+ type: 'base64' | 'url';
18
+ media_type?: string;
19
+ data?: string;
20
+ url?: string;
21
+ };
22
+ }
23
+ export interface AnthropicToolUseBlock {
24
+ type: 'tool_use';
25
+ id: string;
26
+ name: string;
27
+ input: Record<string, unknown>;
28
+ }
29
+ export interface AnthropicToolResultBlock {
30
+ type: 'tool_result';
31
+ tool_use_id: string;
32
+ content: string | AnthropicContentBlock[];
33
+ is_error?: boolean;
34
+ }
35
+ export interface AnthropicTool {
36
+ name: string;
37
+ description?: string;
38
+ input_schema: {
39
+ type: 'object';
40
+ properties?: Record<string, unknown>;
41
+ required?: string[];
42
+ [key: string]: unknown;
43
+ };
44
+ }
45
+ export type AnthropicToolChoice = {
46
+ type: 'auto';
47
+ } | {
48
+ type: 'any';
49
+ } | {
50
+ type: 'tool';
51
+ name: string;
52
+ };
53
+ export interface AnthropicSystemContentBlock {
54
+ type: 'text';
55
+ text: string;
56
+ cache_control?: {
57
+ type: 'ephemeral';
58
+ };
59
+ }
60
+ export interface AnthropicMetadata {
61
+ user_id?: string;
62
+ }
63
+ export interface AnthropicMessageCreateParams {
64
+ model: string;
65
+ messages: AnthropicMessage[];
66
+ max_tokens: number;
67
+ system?: string | AnthropicSystemContentBlock[];
68
+ temperature?: number;
69
+ top_p?: number;
70
+ top_k?: number;
71
+ stream?: boolean;
72
+ stop_sequences?: string[];
73
+ tools?: AnthropicTool[];
74
+ tool_choice?: AnthropicToolChoice;
75
+ metadata?: AnthropicMetadata;
76
+ gateId?: string;
77
+ }
78
+ export interface AnthropicUsage {
79
+ input_tokens: number;
80
+ output_tokens: number;
81
+ }
82
+ export interface AnthropicMessageResponse {
83
+ id: string;
84
+ type: 'message';
85
+ role: 'assistant';
86
+ content: AnthropicContentBlock[];
87
+ model: string;
88
+ stop_reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | null;
89
+ stop_sequence?: string | null;
90
+ usage: AnthropicUsage;
91
+ }
92
+ export type AnthropicMessageStreamEvent = AnthropicMessageStartEvent | AnthropicMessageDeltaEvent | AnthropicMessageStopEvent | AnthropicContentBlockStartEvent | AnthropicContentBlockDeltaEvent | AnthropicContentBlockStopEvent | AnthropicPingEvent | AnthropicErrorEvent;
93
+ export interface AnthropicMessageStartEvent {
94
+ type: 'message_start';
95
+ message: {
96
+ id: string;
97
+ type: 'message';
98
+ role: 'assistant';
99
+ content: [];
100
+ model: string;
101
+ stop_reason: null;
102
+ stop_sequence: null;
103
+ usage: {
104
+ input_tokens: number;
105
+ output_tokens: number;
106
+ };
107
+ };
108
+ }
109
+ export interface AnthropicMessageDeltaEvent {
110
+ type: 'message_delta';
111
+ delta: {
112
+ stop_reason?: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use';
113
+ stop_sequence?: string | null;
114
+ };
115
+ usage: {
116
+ output_tokens: number;
117
+ };
118
+ }
119
+ export interface AnthropicMessageStopEvent {
120
+ type: 'message_stop';
121
+ }
122
+ export interface AnthropicContentBlockStartEvent {
123
+ type: 'content_block_start';
124
+ index: number;
125
+ content_block: AnthropicContentBlock;
126
+ }
127
+ export interface AnthropicContentBlockDeltaEvent {
128
+ type: 'content_block_delta';
129
+ index: number;
130
+ delta: {
131
+ type: 'text_delta' | 'input_json_delta';
132
+ text?: string;
133
+ partial_json?: string;
134
+ };
135
+ }
136
+ export interface AnthropicContentBlockStopEvent {
137
+ type: 'content_block_stop';
138
+ index: number;
139
+ }
140
+ export interface AnthropicPingEvent {
141
+ type: 'ping';
142
+ }
143
+ export interface AnthropicErrorEvent {
144
+ type: 'error';
145
+ error: {
146
+ type: string;
147
+ message: string;
148
+ };
149
+ }
150
+ export interface AnthropicError {
151
+ type: 'error';
152
+ error: {
153
+ type: 'invalid_request_error' | 'authentication_error' | 'permission_error' | 'not_found_error' | 'rate_limit_error' | 'api_error' | 'overloaded_error';
154
+ message: string;
155
+ };
156
+ }
157
+ //# sourceMappingURL=anthropic-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anthropic-format.d.ts","sourceRoot":"","sources":["../../src/types/anthropic-format.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,qBAAqB,EAAE,CAAC;CAC3C;AAED,MAAM,MAAM,qBAAqB,GAC7B,kBAAkB,GAClB,mBAAmB,GACnB,qBAAqB,GACrB,wBAAwB,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ,GAAG,KAAK,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAA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**
2
+ * Anthropic Messages API compatible types for /v1/messages endpoint
3
+ * These match the official Anthropic API format to enable drop-in replacement
4
+ */
5
+ export {};
@@ -10,4 +10,5 @@ export * from './config.js';
10
10
  export * from './provider-keys.js';
11
11
  export * from './history.js';
12
12
  export * from './openai-format.js';
13
+ export * from './anthropic-format.js';
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC"}
@@ -11,3 +11,4 @@ export * from './config.js';
11
11
  export * from './provider-keys.js';
12
12
  export * from './history.js';
13
13
  export * from './openai-format.js';
14
+ export * from './anthropic-format.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layer-ai/sdk",
3
- "version": "2.5.9",
3
+ "version": "2.5.10",
4
4
  "description": "Configure multiple AI models at runtime without code changes or deployments",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",